diff --git a/JacksEscape.vcxproj b/JacksEscape.vcxproj
index 8260e8e..a9e0293 100644
--- a/JacksEscape.vcxproj
+++ b/JacksEscape.vcxproj
@@ -132,6 +132,7 @@
+
@@ -153,9 +154,11 @@
+
+
diff --git a/JacksEscape.vcxproj.filters b/JacksEscape.vcxproj.filters
index c1bc3fa..6f9ce54 100644
--- a/JacksEscape.vcxproj.filters
+++ b/JacksEscape.vcxproj.filters
@@ -78,6 +78,9 @@
头文件
+
+ 头文件
+
@@ -155,5 +158,11 @@
源文件
+
+ 源文件
+
+
+ 源文件
+
\ No newline at end of file
diff --git a/app_render.cpp b/app_render.cpp
index c576002..9d19e5a 100644
--- a/app_render.cpp
+++ b/app_render.cpp
@@ -175,15 +175,12 @@ void app_Render(App *app) {
settextcolor(RGB(255, 255, 255));
// If paused, display a text
- if (app->paused) {
- RECT rect = {.left = SCREEN_WIDTH / 2 - 10, .top = 100, .right = SCREEN_WIDTH / 2 + 10, .bottom = 200};
- drawtext("Game Paused", &rect, DT_CENTER | DT_NOCLIP);
- }
- if (abs(app->timescale - 1.0) > EPS) {
- RECT rect = {.left = SCREEN_WIDTH / 2 - 10, .top = 50, .right = SCREEN_WIDTH / 2 + 10, .bottom = 150};
+ if (app->paused)
+ render_DrawTextEx("Game Paused", box2(SCREEN_WIDTH / 2 - 10, 100, 20, 100), DT_CENTER | DT_NOCLIP);
+ if (1.0 - app->timescale > EPS) {
char buf[128];
snprintf(buf, sizeof(buf), "*** TIMESCALE %.2lf ***", app->timescale);
- drawtext(buf, &rect, DT_CENTER | DT_NOCLIP);
+ render_DrawTextEx(buf, box2(SCREEN_WIDTH / 2 - 10, 50, 20, 100), DT_CENTER | DT_NOCLIP);
}
}
}
diff --git a/render_util.cpp b/render_util.cpp
index d7abddc..d14f839 100644
--- a/render_util.cpp
+++ b/render_util.cpp
@@ -54,6 +54,29 @@ void render_DrawText(int x, int y, const char *str) {
}
}
+void render_DrawTextEx(const char *str, Box2 rect, unsigned int flags) {
+ if (!tbuf)
+ tbuf = vector_Create(sizeof(NCHAR));
+
+ const NCHAR zero = 0;
+ vector_Clear(tbuf);
+ int len = strlen(str);
+ for (int i = 0; i < len; i++) {
+ NCHAR c = (NCHAR)str[i];
+ vector_Push(tbuf, &c);
+ }
+
+ if (vector_Size(tbuf) > 0) {
+ vector_Push(tbuf, &zero);
+ RECT r;
+ r.left = (int)round(rect.lefttop.x);
+ r.top = (int)round(rect.lefttop.y);
+ r.right = (int)round(rect.lefttop.x + rect.size.x);
+ r.bottom = (int)round(rect.lefttop.y + rect.size.y);
+ drawtext((LPCTSTR)vector_Data(tbuf), &r, flags);
+ }
+}
+
const FillMode render_ModeDefault = {
.rop2 = R2_COPYPEN,
diff --git a/render_util.h b/render_util.h
index 077cf18..d6aa991 100644
--- a/render_util.h
+++ b/render_util.h
@@ -17,6 +17,9 @@ extern "C" {
// for newlines.
void render_DrawText(int x, int y, const char *str);
+// A warpper around drawtext().
+void render_DrawTextEx(const char *str, Box2 rect, unsigned int flags);
+
// Fill modes.
typedef struct {