From 35d7561fd750355193969dc3c55c45fa89d8f3df Mon Sep 17 00:00:00 2001 From: zeromus Date: Sat, 30 Jul 2022 16:47:43 -0400 Subject: [PATCH] make hud editor actually save position (fixes #572) --- .../src/frontend/modules/osd/agg/agg_osd.cpp | 18 ++++++++++++++++++ desmume/src/frontend/modules/osd/agg/agg_osd.h | 3 +++ .../modules/osd/agg/agg_osd_settings.inc | 12 ++++++++++++ desmume/src/frontend/windows/main.cpp | 4 ++++ 4 files changed, 37 insertions(+) create mode 100644 desmume/src/frontend/modules/osd/agg/agg_osd_settings.inc diff --git a/desmume/src/frontend/modules/osd/agg/agg_osd.cpp b/desmume/src/frontend/modules/osd/agg/agg_osd.cpp index 37a146c5c..06332ddab 100644 --- a/desmume/src/frontend/modules/osd/agg/agg_osd.cpp +++ b/desmume/src/frontend/modules/osd/agg/agg_osd.cpp @@ -36,6 +36,7 @@ #ifdef _MSC_VER #include +#include "winutil.h" #else #include #endif @@ -175,6 +176,12 @@ void HudStruct::reset() SavestateSlots.xsize = 240; SavestateSlots.ysize = 24; + #ifdef _MSC_VER + #define AGG_OSD_SETTING(which,comp) which.comp = GetPrivateProfileInt("HudEdit", #which "." #comp, which.comp, IniName); + #include "agg_osd_settings.inc" + #undef AGG_OSD_SETTING + #endif + SetHudDummy(&Dummy); clicked = false; } @@ -791,3 +798,14 @@ void OSDCLASS::border(bool enabled) { //render51.setTextBoxBorder(enabled); } + +void OSDCLASS::SaveHudEditor() +{ + #ifdef _MSC_VER + #define AGG_OSD_SETTING(which,comp) WritePrivateProfileInt("HudEdit", #which "." #comp, Hud.which.comp, IniName); + #include "agg_osd_settings.inc" + #undef AGG_OSD_SETTING + #endif + + //WritePrivateProfileInt("HudEdit", "FpsDisplay" "." "x", FpsDisplay.x, IniName); +} \ No newline at end of file diff --git a/desmume/src/frontend/modules/osd/agg/agg_osd.h b/desmume/src/frontend/modules/osd/agg/agg_osd.h index 689d40e3a..e62fcbd95 100644 --- a/desmume/src/frontend/modules/osd/agg/agg_osd.h +++ b/desmume/src/frontend/modules/osd/agg/agg_osd.h @@ -125,6 +125,8 @@ public: void addLine(const char* fmt, va_list args); void addFixed(u16 x, u16 y, const char *fmt, ...); void border(bool enabled); + + void SaveHudEditor(); }; extern OSDCLASS *osd; @@ -139,6 +141,7 @@ public: void clear(); void setLineColor(u8 r, u8 b, u8 g); void addLine(const char *fmt, ...); + void SaveHudEditor() {} }; extern OSDCLASS *osd; diff --git a/desmume/src/frontend/modules/osd/agg/agg_osd_settings.inc b/desmume/src/frontend/modules/osd/agg/agg_osd_settings.inc new file mode 100644 index 000000000..7fda0f9db --- /dev/null +++ b/desmume/src/frontend/modules/osd/agg/agg_osd_settings.inc @@ -0,0 +1,12 @@ +#define AGG_OSD_SETTING_ALL(which) AGG_OSD_SETTING(which,x) AGG_OSD_SETTING(which,y) AGG_OSD_SETTING(which,xsize) AGG_OSD_SETTING(which,ysize) + +AGG_OSD_SETTING_ALL(FpsDisplay); +AGG_OSD_SETTING_ALL(FrameCounter); +AGG_OSD_SETTING_ALL(InputDisplay); +AGG_OSD_SETTING_ALL(GraphicalInputDisplay); +AGG_OSD_SETTING_ALL(LagFrameCounter); +AGG_OSD_SETTING_ALL(Microphone); +AGG_OSD_SETTING_ALL(RTCDisplay); +AGG_OSD_SETTING_ALL(SavestateSlots); + +#undef AGG_OSD_SETTING_ALL diff --git a/desmume/src/frontend/windows/main.cpp b/desmume/src/frontend/windows/main.cpp index 5a3cb1608..caa8d0c63 100644 --- a/desmume/src/frontend/windows/main.cpp +++ b/desmume/src/frontend/windows/main.cpp @@ -4000,6 +4000,8 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM NDS_UnPause(); delete MainWindowToolbar; KillTimer(hwnd, autoHideCursorTimer); + if(HudEditorMode) + osd->SaveHudEditor(); return 0; } case WM_TIMER: @@ -5183,6 +5185,8 @@ DOKEYDOWN: HudEditorMode ^= true; osd->clear(); osd->border(HudEditorMode); + if(!HudEditorMode) + osd->SaveHudEditor(); return 0; case ID_VIEW_DISPLAYMICROPHONE: