aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Config.cpp10
-rw-r--r--src/Config.h5
-rw-r--r--src/libui_sdl/libui/windows/menu.cpp15
-rw-r--r--src/libui_sdl/main.cpp21
4 files changed, 48 insertions, 3 deletions
diff --git a/src/Config.cpp b/src/Config.cpp
index d9c4757..213f03d 100644
--- a/src/Config.cpp
+++ b/src/Config.cpp
@@ -31,6 +31,11 @@ int JoyMapping[12];
int WindowWidth;
int WindowHeight;
+int ScreenRotation;
+int ScreenGap;
+int ScreenLayout;
+int ScreenSizing;
+
int DirectBoot;
int Threaded3D;
@@ -79,6 +84,11 @@ ConfigEntry ConfigFile[] =
{"WindowWidth", 0, &WindowWidth, 256, NULL, 0},
{"WindowHeight", 0, &WindowHeight, 384, NULL, 0},
+ {"ScreenRotation", 0, &ScreenRotation, 0, NULL, 0},
+ {"ScreenGap", 0, &ScreenGap, 0, NULL, 0},
+ {"ScreenLayout", 0, &ScreenLayout, 0, NULL, 0},
+ {"ScreenSizing", 0, &ScreenSizing, 0, NULL, 0},
+
{"DirectBoot", 0, &DirectBoot, 1, NULL, 0},
{"Threaded3D", 0, &Threaded3D, 1, NULL, 0},
diff --git a/src/Config.h b/src/Config.h
index 370f102..c40fa67 100644
--- a/src/Config.h
+++ b/src/Config.h
@@ -33,6 +33,11 @@ extern int JoyMapping[12];
extern int WindowWidth;
extern int WindowHeight;
+extern int ScreenRotation;
+extern int ScreenGap;
+extern int ScreenLayout;
+extern int ScreenSizing;
+
extern int DirectBoot;
extern int Threaded3D;
diff --git a/src/libui_sdl/libui/windows/menu.cpp b/src/libui_sdl/libui/windows/menu.cpp
index 1f721b6..ccf5c9c 100644
--- a/src/libui_sdl/libui/windows/menu.cpp
+++ b/src/libui_sdl/libui/windows/menu.cpp
@@ -14,6 +14,7 @@ static BOOL hasAbout = FALSE;
struct uiMenu {
WCHAR *name;
+ HMENU handle;
uiMenuItem **items;
BOOL ischild;
size_t len;
@@ -292,6 +293,7 @@ static HMENU makeMenu(uiMenu *m)
menu = CreatePopupMenu();
if (menu == NULL)
logLastError(L"error creating menu");
+ m->handle = menu;
for (i = 0; i < m->len; i++)
appendMenuItem(menu, m->items[i]);
return menu;
@@ -363,21 +365,28 @@ static void freeMenu(uiMenu *m, HMENU submenu)
item->hmenus[j] = item->hmenus[j + 1];
item->hmenus[j] = NULL;
item->len--;
+
+ if (item->popupchild)
+ freeMenu(item->popupchild, item->popupchild->handle);
}
}
void freeMenubar(HMENU menubar)
{
size_t i;
+ size_t j = 0;
MENUITEMINFOW mi;
- for (i = 0; i < len; i++) {
+ for (i = 0; i < len; i++)
+ {
+ if (menus[i]->ischild) continue;
ZeroMemory(&mi, sizeof (MENUITEMINFOW));
mi.cbSize = sizeof (MENUITEMINFOW);
mi.fMask = MIIM_SUBMENU;
- if (GetMenuItemInfoW(menubar, i, TRUE, &mi) == 0)
+ if (GetMenuItemInfoW(menubar, j, TRUE, &mi) == 0)
logLastError(L"error getting menu to delete item references from");
freeMenu(menus[i], mi.hSubMenu);
+ j++;
}
// no need to worry about destroying any menus; destruction of the window they're in will do it for us
}
@@ -396,7 +405,7 @@ void uninitMenus(void)
if (item->len != 0)
// LONGTERM userbug()?
implbug("menu item %p (%ws) still has uiWindows attached; did you forget to destroy some windows?", item, item->name);
- if (item->name != NULL)
+ if (item->type != typeSubmenu && item->name != NULL)
uiFree(item->name);
if (item->hmenus != NULL)
uiFree(item->hmenus);
diff --git a/src/libui_sdl/main.cpp b/src/libui_sdl/main.cpp
index b745e5b..1b5dfb3 100644
--- a/src/libui_sdl/main.cpp
+++ b/src/libui_sdl/main.cpp
@@ -865,6 +865,8 @@ void OnSetScreenRotation(uiMenuItem* item, uiWindow* window, void* param)
w = blarg;
uiWindowSetContentSize(window, w, h);
+ Config::WindowWidth = w;
+ Config::WindowHeight = h;
}
}
else if (ScreenLayout == 1) // vertical
@@ -1139,6 +1141,20 @@ int main(int argc, char** argv)
uiControlSetMinSize(uiControl(MainDrawArea), 256, 384);
uiAreaSetBackgroundColor(MainDrawArea, 0, 0, 0); // TODO: make configurable?
+ ScreenRotation = Config::ScreenRotation;
+ ScreenGap = Config::ScreenGap;
+ ScreenLayout = Config::ScreenLayout;
+ ScreenSizing = Config::ScreenSizing;
+
+#define SANITIZE(var, min, max) if ((var < min) || (var > max)) var = 0;
+ SANITIZE(ScreenRotation, 0, 3);
+ SANITIZE(ScreenGap, 0, 5);
+ SANITIZE(ScreenLayout, 0, 2);
+ SANITIZE(ScreenSizing, 0, 3);
+#undef SANITIZE
+
+ OnSetScreenRotation(MenuItem_ScreenRot[ScreenRotation], MainWindow, (void*)&kScreenRot[ScreenRotation]);
+
EmuRunning = 2;
RunningSomething = false;
EmuThread = SDL_CreateThread(EmuThreadFunc, "melonDS magic", NULL);
@@ -1165,6 +1181,11 @@ int main(int argc, char** argv)
EmuRunning = 0;
SDL_WaitThread(EmuThread, NULL);
+ Config::ScreenRotation = ScreenRotation;
+ Config::ScreenGap = ScreenGap;
+ Config::ScreenLayout = ScreenLayout;
+ Config::ScreenSizing = ScreenSizing;
+
Config::Save();
if (ScreenBitmap) uiDrawFreeBitmap(ScreenBitmap);