Windows: Add menubar

This commit is contained in:
kichikuou
2020-12-12 16:20:53 +09:00
parent 89a4ba2bd2
commit 4d5fd5efca
8 changed files with 112 additions and 3 deletions
+1 -1
View File
@@ -70,7 +70,7 @@ target_sources(xsystem35 PRIVATE
network.c)
if (WIN32)
target_sources(xsystem35 PRIVATE win/dialog.c win/resources.rc)
target_sources(xsystem35 PRIVATE win/dialog.c win/resources.rc win/menubar.c)
endif()
if (EMSCRIPTEN)
+6
View File
@@ -55,4 +55,10 @@ extern void menu_widgetinit(void);
extern void menu_init();
extern void menu_gtkmainiteration();
#ifdef _WIN32
struct SDL_SysWMmsg;
extern void win_menu_init(void);
extern void win_menu_onsyswmevent(struct SDL_SysWMmsg* msg);
#endif
#endif /* !__MENULL */
+3 -1
View File
@@ -88,7 +88,9 @@ void menu_msgbox_open(char *msg) {
}
void menu_init(void) {
return;
#ifdef _WIN32
win_menu_init();
#endif
}
void menu_gtkmainiteration() {
+5
View File
@@ -126,6 +126,11 @@ static void sdl_getEvent(void) {
break;
}
break;
#ifdef _WIN32
case SDL_SYSWMEVENT:
win_menu_onsyswmevent(e.syswm.msg);
break;
#endif
case SDL_APP_DIDENTERFOREGROUND:
sdl_dirty = TRUE;
break;
+61
View File
@@ -0,0 +1,61 @@
/*
* Copyright (C) 2020 <KichikuouChrome@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <windows.h>
#undef min
#undef max
#include <SDL_syswm.h>
#include "system.h"
#include "menu.h"
#include "sdl_private.h"
#include "resources.h"
#include "ags.h"
static HWND get_hwnd(SDL_Window *window) {
SDL_SysWMinfo info;
SDL_VERSION(&info.version);
SDL_GetWindowWMInfo(window, &info);
return info.info.win.window;
}
void win_menu_init(void) {
HINSTANCE hinst = (HINSTANCE)GetModuleHandle(NULL);
HMENU hmenu = LoadMenu(hinst, MAKEINTRESOURCE(IDR_MENU1));
SetMenu(get_hwnd(sdl_window), hmenu);
SDL_EventState(SDL_SYSWMEVENT, SDL_ENABLE);
// Let SDL recalc the window size, taking menu height into account.
SDL_SetWindowSize(sdl_window, view_w, view_h);
}
void win_menu_onsyswmevent(SDL_SysWMmsg* msg) {
switch (msg->msg.win.msg) {
case WM_COMMAND:
switch (msg->msg.win.wParam) {
case ID_EXIT:
menu_quitmenu_open();
break;
case ID_SCREEN_WINDOW:
ags_fullscreen(FALSE);
break;
case ID_SCREEN_FULL:
ags_fullscreen(TRUE);
break;
}
break;
}
}
+5
View File
@@ -21,10 +21,15 @@
#define XSYSTEM35_REGKEY "Software\\Kichikuou\\xsystem35"
#define IDR_MENU1 101
#define IDD_DIALOG1 103
#define IDC_TEXT 104
#define IDC_EDITBOX 105
#define IDS_CHOOSE_GAME_FOLDER 1001
#define ID_EXIT 40001
#define ID_SCREEN_WINDOW 40002
#define ID_SCREEN_FULL 40003
#endif /* __RESOURCES_H__ */
+30
View File
@@ -4,7 +4,22 @@
100 ICON DISCARDABLE "xsystem35.ico"
////////////////////////////////////////////////////////////////////////
LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL
IDR_MENU1 MENU DISCARDABLE
{
POPUP "File"
{
MENUITEM "Exit", ID_EXIT
}
POPUP "Screen"
{
MENUITEM "Window", ID_SCREEN_WINDOW
MENUITEM "Fullscreen", ID_SCREEN_FULL
}
}
STRINGTABLE
{
IDS_CHOOSE_GAME_FOLDER "Choose a game folder:"
@@ -20,7 +35,22 @@ FONT 9, "MS Shell Dlg"
DEFPUSHBUTTON "OK",IDOK,35,36,50,14
}
////////////////////////////////////////////////////////////////////////
LANGUAGE LANG_JAPANESE, SUBLANG_DEFAULT
IDR_MENU1 MENU DISCARDABLE
{
POPUP "ファイル"
{
MENUITEM "閉じる", ID_EXIT
}
POPUP "画面"
{
MENUITEM "ウィンドウ", ID_SCREEN_WINDOW
MENUITEM "フルスクリーン", ID_SCREEN_FULL
}
}
STRINGTABLE
{
IDS_CHOOSE_GAME_FOLDER "ゲームフォルダを選んでください:"
+1 -1
View File
@@ -518,8 +518,8 @@ int main(int argc, char **argv) {
gtk_rc_parse(rc_path);
free(rc_path);
menu_init();
#endif
menu_init();
nact_main();
#ifdef __EMSCRIPTEN__