diff --git a/engine/engine.rc b/engine/engine.rc index 996da8d..3523ab7 100644 --- a/engine/engine.rc +++ b/engine/engine.rc @@ -1,6 +1,6 @@ #include -ENGINE ICON "../texture/goldfish.ico" +ENGINE ICON "../internal/goldfish.ico" VS_VERSION_INFO VERSIONINFO FILEVERSION 1,0,0,0 PRODUCTVERSION 1,0,0,0 diff --git a/internal/goldfish.bmp b/internal/goldfish.bmp new file mode 100644 index 0000000..0d3586d Binary files /dev/null and b/internal/goldfish.bmp differ diff --git a/texture/goldfish.ico b/internal/goldfish.ico similarity index 100% rename from texture/goldfish.ico rename to internal/goldfish.ico diff --git a/texture/icon.ico b/internal/icon.ico similarity index 100% rename from texture/icon.ico rename to internal/icon.ico diff --git a/texture/icon.png b/internal/icon.png similarity index 100% rename from texture/icon.png rename to internal/icon.png diff --git a/src/engineinfo/main_console.c b/src/engineinfo/main_console.c index ee2f679..d703999 100644 --- a/src/engineinfo/main_console.c +++ b/src/engineinfo/main_console.c @@ -11,6 +11,8 @@ int main(int argc, char** argv) { gf_get_version(&ver); printf("GoldFish Engine version: %s\n", ver.full); + printf("Thread model: %s\n", ver.thread); + printf("Renderer: %s on %s\n", ver.driver, ver.backend); return 0; } diff --git a/src/engineinfo/main_windows.c b/src/engineinfo/main_windows.c index c751a7f..0220254 100644 --- a/src/engineinfo/main_windows.c +++ b/src/engineinfo/main_windows.c @@ -2,12 +2,143 @@ #include /* External library */ +#include /* Standard */ +#include -int main(int argc, char** argv) { - gf_version_t ver; - gf_get_version(&ver); +HINSTANCE hInst; +HFONT monospace; +gf_version_t ver; +char vertxt[512]; +void ShowBitmapSize(HWND hWnd, HDC hdc, const char* name, int x, int y, int w, int h) { + HBITMAP hBitmap = LoadBitmap(hInst, name); + BITMAP bmp; + HDC hmdc; + GetObject(hBitmap, sizeof(bmp), &bmp); + hmdc = CreateCompatibleDC(hdc); + SelectObject(hmdc, hBitmap); + if(w == 0 && h == 0) { + StretchBlt(hdc, x, y, bmp.bmWidth, bmp.bmHeight, hmdc, 0, 0, bmp.bmWidth, bmp.bmHeight, SRCCOPY); + } else { + StretchBlt(hdc, x, y, w, h, hmdc, 0, 0, bmp.bmWidth, bmp.bmHeight, SRCCOPY); + } + DeleteDC(hmdc); + DeleteObject(hBitmap); +} + +LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) { + switch(msg) { + case WM_CLOSE: { + DestroyWindow(hWnd); + break; + } + case WM_DESTROY: { + PostQuitMessage(0); + break; + } + case WM_CREATE: { + monospace = (HFONT)GetStockObject(SYSTEM_FIXED_FONT); + break; + } + case WM_PAINT: { + HDC hdc; + PAINTSTRUCT ps; + RECT rc; + RECT tx; + int sz; + int width; + int height; + int padding; + + GetClientRect(hWnd, &rc); + width = rc.right - rc.left; + height = rc.bottom - rc.top; + sz = height * 4 / 5; + padding = height / 2 - sz / 2; + + hdc = BeginPaint(hWnd, &ps); + SelectObject(hdc, monospace); + ShowBitmapSize(hWnd, hdc, "GOLDFISH_BMP", padding, padding, sz, sz); + + tx.left = padding * 2 + sz; + tx.right = rc.right; + tx.top = padding; + tx.bottom = rc.bottom - padding * 2; + DrawText(hdc, vertxt, strlen(vertxt), &tx, DT_LEFT); + EndPaint(hWnd, &ps); + break; + } + default: { + return DefWindowProc(hWnd, msg, wp, lp); + } + } return 0; } + +BOOL InitApp(void) { + WNDCLASSEX wc; + wc.cbSize = sizeof(WNDCLASSEX); + wc.style = CS_HREDRAW | CS_VREDRAW; + wc.lpfnWndProc = WndProc; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + wc.hInstance = hInst; + wc.hIcon = LoadIcon(hInst, "GOLDFISH"); + wc.hCursor = LoadCursor(NULL, IDC_ARROW); + wc.hbrBackground = GetSysColorBrush(COLOR_MENU); + wc.lpszMenuName = NULL; + wc.lpszClassName = "goldfish"; + wc.hIconSm = LoadIcon(hInst, "GOLDFISH"); + return RegisterClassEx(&wc); +} + +BOOL InitWindow(int nCmdShow) { + HWND hWnd; + RECT deskrc, rc; + HWND hDeskWnd = GetDesktopWindow(); + GetWindowRect(hDeskWnd, &deskrc); + hWnd = CreateWindow("goldfish", "GoldFish Engine Info", (WS_OVERLAPPEDWINDOW ^ WS_THICKFRAME) ^ WS_MAXIMIZEBOX, 0, 0, 500, 250, NULL, 0, hInst, NULL); + + if(!hWnd) { + return FALSE; + } + GetWindowRect(hWnd, &rc); + SetWindowPos(hWnd, HWND_TOP, (deskrc.right - (rc.right - rc.left)) / 2, (deskrc.bottom - (rc.bottom - rc.top)) / 2, rc.right - rc.left, rc.bottom - rc.top, SWP_SHOWWINDOW); + ShowWindow(hWnd, nCmdShow); + UpdateWindow(hWnd); + return TRUE; +} + +int WINAPI WinMain(HINSTANCE hCurInst, HINSTANCE hPrevInst, LPSTR lpsCmdLine, int nCmdShow) { + MSG msg; + BOOL bret; + + hInst = hCurInst; + + gf_get_version(&ver); + vertxt[0] = 0; + sprintf(vertxt + strlen(vertxt), "GoldFish Engine %s\n", ver.full); + sprintf(vertxt + strlen(vertxt), "Thread Model: %s\n", ver.thread); + sprintf(vertxt + strlen(vertxt), "Renderer : %s on %s\n", ver.driver, ver.backend); + + if(!InitApp()) { + return FALSE; + } + + if(!InitWindow(nCmdShow)) { + return FALSE; + } + + while((bret = GetMessage(&msg, NULL, 0, 0)) != 0) { + if(bret == -1) { + break; + } else { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + } + + return (int)msg.wParam; +} diff --git a/src/nishbox.rc b/src/nishbox.rc index 4619956..ca8d081 100644 --- a/src/nishbox.rc +++ b/src/nishbox.rc @@ -1,3 +1,5 @@ #include -NISHBOX ICON "../texture/icon.ico" +NISHBOX ICON "../internal/icon.ico" +GOLDFISH ICON "../internal/goldfish.ico" +GOLDFISH_BMP BITMAP "../internal/goldfish.bmp" diff --git a/tool/format.sh b/tool/format.sh index 7334c65..6fb59cb 100755 --- a/tool/format.sh +++ b/tool/format.sh @@ -1,2 +1,2 @@ #!/bin/sh -exec clang-format --verbose -i `find engine src -name "*.c" -or -name "*.h"` +exec clang-format --verbose -i `find engine src "(" -name "*.c" -or -name "*.h" ")" -and -not -path "engine/external/*"`