From 86faf1b0ec73a7b606f73f894de7438acf5a5aad Mon Sep 17 00:00:00 2001 From: yixy <34703796+yixy-only@users.noreply.github.com> Date: Tue, 30 Apr 2024 23:31:34 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=20showwindow(),=20hi?= =?UTF-8?q?dewindow()=20=E5=87=BD=E6=95=B0,=20=E6=94=AF=E6=8C=81=E7=AA=97?= =?UTF-8?q?=E5=8F=A3=E6=98=BE=E7=A4=BA=E5=92=8C=E9=9A=90=E8=97=8F=20(#161)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/ege.h | 2 ++ src/ege_graph.h | 4 ++++ src/ege_head.h | 1 + src/graphics.cpp | 1 + src/window.cpp | 54 ++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 62 insertions(+) diff --git a/include/ege.h b/include/ege.h index bc39fdf0..9df6e127 100644 --- a/include/ege.h +++ b/include/ege.h @@ -854,6 +854,8 @@ void EGEAPI setcaption(LPCWSTR caption); void EGEAPI seticon(int icon_id); int EGEAPI attachHWND(HWND hWnd); +void EGEAPI showwindow(); +void EGEAPI hidewindow(); void EGEAPI movewindow(int x, int y, bool redraw = true); void EGEAPI resizewindow(int width, int height); void EGEAPI flushwindow(); diff --git a/src/ege_graph.h b/src/ege_graph.h index 04fb30a4..760f1139 100644 --- a/src/ege_graph.h +++ b/src/ege_graph.h @@ -21,6 +21,10 @@ namespace ege extern struct _graph_setting graph_setting; class egeControlBase; // 前置声明 +int getinitmode(); + +void logoscene(); + int dealmessage(_graph_setting* pg, bool force_update); void guiupdate(_graph_setting* pg, egeControlBase* root); diff --git a/src/ege_head.h b/src/ege_head.h index 2c9a033a..044b90b3 100644 --- a/src/ege_head.h +++ b/src/ege_head.h @@ -193,6 +193,7 @@ struct _graph_setting bool lock_window; bool timer_stop_mark; bool skip_timer_mark; + bool first_show; thread_queue*msgkey_queue, *msgmouse_queue; diff --git a/src/graphics.cpp b/src/graphics.cpp index 32b81c5c..378e2e7c 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -860,6 +860,7 @@ void initgraph(int* gdriver, int* gmode, const char* path) setrendermode(RENDER_MANUAL); } + pg->first_show = true; pg->mouse_show = true; } diff --git a/src/window.cpp b/src/window.cpp index 8e35ca27..f1876591 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -53,6 +53,60 @@ void seticon(int icon_id) } } +void showwindow() +{ + struct _graph_setting* pg = &graph_setting; + + bool showLogo = false; + + PIMAGE background = NULL; + color_t bkColor = getbkcolor(); + + if (pg->first_show) { + pg->first_show = false; + + int initmode = getinitmode(); + if ((initmode & INIT_WITHLOGO) && (initmode & INIT_HIDE)) { + showLogo = true; + } + } + + if (showLogo) { + background = newimage(); + getimage(background, 0, 0, getwidth(), getheight()); + setbkcolor_f(EGERGB(0, 0, 0)); + cleardevice(); + } + + ShowWindow(pg->hwnd, SW_SHOWNORMAL); + BringWindowToTop(pg->hwnd); + SetForegroundWindow(pg->hwnd); + + if (showLogo) { + bool isRenderManual = pg->lock_window; + + logoscene(); + + setbkcolor_f(bkColor); + + if (background != NULL) { + putimage(0, 0, background); + flushwindow(); + delimage(background); + } + + if (!isRenderManual) { + setrendermode(RENDER_AUTO); + } + } +} + +void hidewindow() +{ + struct _graph_setting* pg = &graph_setting; + ShowWindow(pg->hwnd, SW_HIDE); +} + void movewindow(int x, int y, bool redraw) { ::MoveWindow(getHWnd(), x, y, getwidth(), getheight(), redraw);