Skip to content

Commit

Permalink
Added editor status bar
Browse files Browse the repository at this point in the history
  • Loading branch information
twist84 committed Sep 25, 2024
1 parent 1450972 commit 7fdd147
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 8 deletions.
2 changes: 1 addition & 1 deletion game/source/rasterizer/rasterizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ bool __cdecl c_rasterizer::reset_device()
SetParent(console_window, g_windows_params.editor_window_handle);
SetWindowPos(
console_window,
HWND_TOP,
HWND_BOTTOM,
3, rect.bottom - 297,
1406, 296,
SWP_SHOWWINDOW);
Expand Down
46 changes: 39 additions & 7 deletions game/source/shell/shell_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
#include "rasterizer/rasterizer.hpp"
#include "shell/shell.hpp"

#include <commctrl.h> // For common controls like status bar
#pragma comment(lib, "Comctl32.lib")

REFERENCE_DECLARE(0x0199C010, s_windows_params, g_windows_params);

HOOK_DECLARE(0x0042E940, shell_idle);
Expand Down Expand Up @@ -64,17 +67,20 @@ CHAR s_windows_params::editor_window_name[64]{};

LRESULT CALLBACK EditorWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
static HMENU menu_handle = NULL;
static HMENU file_menu_handle = NULL;
static HMENU edit_menu_handle = NULL;
static HMENU view_menu_handle = NULL;
static HMENU scenarios_menu_handle = NULL;
static HMENU help_menu_handle = NULL;

static HINSTANCE status_bar_instance = NULL;
static HWND status_bar_handle = NULL;

switch (uMsg)
{
case WM_CREATE:
{
static HMENU menu_handle = NULL;
static HMENU file_menu_handle = NULL;
static HMENU edit_menu_handle = NULL;
static HMENU view_menu_handle = NULL;
static HMENU scenarios_menu_handle = NULL;
static HMENU help_menu_handle = NULL;

if (menu_handle = CreateMenu())
{
if (file_menu_handle = CreateMenu())
Expand Down Expand Up @@ -147,6 +153,32 @@ LRESULT CALLBACK EditorWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPara

SetMenu(hwnd, menu_handle);
}

INITCOMMONCONTROLSEX init_common_controls_ex{};
init_common_controls_ex.dwSize = sizeof(init_common_controls_ex);
init_common_controls_ex.dwICC = ICC_BAR_CLASSES;
InitCommonControlsEx(&init_common_controls_ex);

status_bar_handle = CreateWindowEx(
0,
STATUSCLASSNAME,
NULL,
WS_CHILD | WS_VISIBLE | SBARS_SIZEGRIP,
0, 0,
0, 0,
hwnd,
(HMENU)1,
status_bar_instance,
NULL);

SendMessageA(status_bar_handle, SB_SETTEXT, 0, (LPARAM)L"Ready");
SetWindowPos(status_bar_handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
}
break;
case WM_SIZE:
{
SendMessageA(status_bar_handle, WM_SIZE, 0, 0);
SetWindowPos(status_bar_handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
}
break;
case WM_COMMAND:
Expand Down

0 comments on commit 7fdd147

Please sign in to comment.