From 615186c592eaa86369d6253148f48a9ba2eeb7ff Mon Sep 17 00:00:00 2001 From: Squid Coder Date: Sat, 1 Feb 2025 13:36:29 -0600 Subject: [PATCH 1/5] Refactored out overlay mode Removed all code that was for the old overlay mode, and renamed what was left to "Immersive Mode" --- CMakeLists.txt | 2 -- GUI.cpp | 1 - GameConfiguration.h | 2 +- commonTypes.h | 1 - main.cpp | 88 ++++++++------------------------------------- 5 files changed, 15 insertions(+), 79 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 86523689..ff5117ae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,6 @@ install(DIRECTORY ${CMAKE_SOURCE_DIR}/plugins/stonesense/configs/ SET(PROJECT_SRCS TrackingModes.cpp - #Overlay.cpp Tile.cpp TileCondition.cpp TileTree.cpp @@ -64,7 +63,6 @@ SET(PROJECT_HDRS MapLoading.h MaterialMatcher.h OcclusionTest.h - #Overlay.h SegmentProcessing.h SpriteColors.h SpriteMaps.h diff --git a/GUI.cpp b/GUI.cpp index bfde84ec..29ff6883 100644 --- a/GUI.cpp +++ b/GUI.cpp @@ -946,7 +946,6 @@ void paintboard() draw_textf_border(font, uiColor(1), 10, 3*fontHeight, 0, "Map Read Time: %.2fms", clockToMs(stonesenseState.stoneSenseTimers.read_time)); draw_textf_border(font, uiColor(1), 10, 4*fontHeight, 0, "Map Beautification Time: %.2fms", clockToMs(stonesenseState.stoneSenseTimers.beautify_time)); draw_textf_border(font, uiColor(1), 10, 5*fontHeight, 0, "Tile Sprite Assembly Time: %.2fms", clockToMs(stonesenseState.stoneSenseTimers.assembly_time)); - draw_textf_border(font, uiColor(1), 10, 6*fontHeight, 0, "DF Renderer Overlay Time: %.2fms", clockToMs(stonesenseState.stoneSenseTimers.overlay_time)); draw_textf_border(font, uiColor(1), 10, 2*fontHeight, 0, "FPS: %.2f", 1000.0/clockToMs(stonesenseState.stoneSenseTimers.frame_total)); draw_textf_border(font, uiColor(1), 10, 7*fontHeight, 0, "Draw: %.2fms", clockToMs(stonesenseState.stoneSenseTimers.draw_time)); draw_textf_border(font, uiColor(1), 10, 9*fontHeight, 0, "%i/%i/%i, %i:%i", contentLoader->currentDay+1, contentLoader->currentMonth+1, contentLoader->currentYear, contentLoader->currentHour, (contentLoader->currentTickRel*60)/50); diff --git a/GameConfiguration.h b/GameConfiguration.h index 64f1c633..93466634 100644 --- a/GameConfiguration.h +++ b/GameConfiguration.h @@ -13,7 +13,7 @@ struct GameConfiguration { Config config; // items not configurable via the config file - bool overlay_mode; + bool immersive_mode; bool show_designations = true; bool show_announcements = false; bool show_keybinds = false; diff --git a/commonTypes.h b/commonTypes.h index 60657981..7b45aef6 100644 --- a/commonTypes.h +++ b/commonTypes.h @@ -189,7 +189,6 @@ struct FrameTimers{ RollingAverage beautify_time; RollingAverage assembly_time; RollingAverage draw_time; - RollingAverage overlay_time; RollingAverage frame_total; clock_t prev_frame_time{ clock() }; diff --git a/main.cpp b/main.cpp index ddf6da38..b11ecb65 100644 --- a/main.cpp +++ b/main.cpp @@ -6,7 +6,6 @@ #include "commonTypes.h" #include "Config.h" -//#include "Overlay.h" #include "Tile.h" #include "GUI.h" //#include "SpriteMaps.h" @@ -46,9 +45,6 @@ int keyoffset=0; std::vector v_stonetypes; -/*FIXME: Find a new replacement for the overlay mode. -std::unique_ptr overlay; -*/ ALLEGRO_DISPLAY * display; ALLEGRO_EVENT event; @@ -225,36 +221,6 @@ static void main_loop(ALLEGRO_DISPLAY * display, ALLEGRO_EVENT_QUEUE *queue, ALL al_rest(0); - /*FIXME: Find a new replacement for the overlay mode. - if (ssConfig.overlay_mode) - { - bool goodoverlay = ovrlay->GoodViewscreen(); - if (!goodoverlay) { - //do nothing; this isn't a view we can overlay - }if (ssConfig.spriteIndexOverlay) { - DrawSpriteIndexOverlay(ssConfig.currentSpriteOverlay); - ovrlay->Flip(); - } - else if (!Maps::IsValid()) { - drawcredits(); - ovrlay->Flip(); - } - else if (timeToReloadSegment) { - reloadPosition(); - al_clear_to_color(ssConfig.config.backcol); - paintboard(); - ovrlay->Flip(); - timeToReloadSegment = false; - animationFrameShown = true; - } - else if (animationFrameShown == false) { - al_clear_to_color(ssConfig.config.backcol); - paintboard(); - ovrlay->Flip(); - animationFrameShown = true; - } - } - else */ { if (ssConfig.spriteIndexOverlay) { DrawSpriteIndexOverlay(ssConfig.currentSpriteOverlay); @@ -280,10 +246,8 @@ static void main_loop(ALLEGRO_DISPLAY * display, ALLEGRO_EVENT_QUEUE *queue, ALL } } - if (!ssConfig.overlay_mode) { doMouse(); doRepeatActions(); - } redraw = false; } /* Take the next event out of the event queue, and store it in `event'. */ @@ -302,9 +266,6 @@ static void main_loop(ALLEGRO_DISPLAY * display, ALLEGRO_EVENT_QUEUE *queue, ALL if(in_time) { switch (event.type) { case ALLEGRO_EVENT_DISPLAY_RESIZE: - if (ssConfig.overlay_mode) { - break; - } stonesenseState.timeToReloadSegment = true; redraw = true; stonesenseState.ssState.ScreenH = event.display.height; @@ -317,9 +278,6 @@ static void main_loop(ALLEGRO_DISPLAY * display, ALLEGRO_EVENT_QUEUE *queue, ALL /* ALLEGRO_EVENT_KEY_DOWN - a keyboard key was pressed. */ case ALLEGRO_EVENT_KEY_CHAR: - if (ssConfig.overlay_mode) { - break; - } if(event.keyboard.display != display) { break; } @@ -394,9 +352,9 @@ static void* stonesense_thread(ALLEGRO_THREAD* main_thread, void* parms) auto& ssConfig = stonesenseState.ssConfig; al_set_new_display_flags( - (ssConfig.config.Fullscreen && !ssConfig.overlay_mode ? ALLEGRO_FULLSCREEN : ALLEGRO_WINDOWED) - |(ssConfig.overlay_mode ? 0 : ALLEGRO_RESIZABLE) - |(ssConfig.overlay_mode ? ALLEGRO_MINIMIZED : 0) + (ssConfig.config.Fullscreen ? ALLEGRO_FULLSCREEN : ALLEGRO_WINDOWED) + |(ALLEGRO_RESIZABLE) + |(0) |(ssConfig.config.opengl ? ALLEGRO_OPENGL : 0) |(ssConfig.config.directX ? ALLEGRO_DIRECT3D_INTERNAL : 0)); @@ -437,12 +395,6 @@ static void* stonesense_thread(ALLEGRO_THREAD* main_thread, void* parms) SetTitle("Stonesense"); drawcredits(); - /*FIXME: Find a new replacement for the overlay mode. - if(ssConfig.overlay_mode){ - overlay = std::make_unique(df::global::enabler->renderer); - df::global::enabler->renderer = overlay.get(); - } - */ std::filesystem::path p = std::filesystem::path{} / "stonesense" / "stonesense.png"; IMGIcon = load_bitmap_withWarning(p); @@ -502,9 +454,6 @@ static void* stonesense_thread(ALLEGRO_THREAD* main_thread, void* parms) // window is destroyed. al_destroy_display(display); display = 0; - /*FIXME: Find a new replacement for the overlay mode. - overlay.reset(); - */ if(ssConfig.threadmade) { al_broadcast_cond(ssConfig.readCond); @@ -556,31 +505,22 @@ DFhackCExport command_result plugin_shutdown ( color_ostream &out ) //and the actual stonesense command. Maybe. DFhackCExport command_result stonesense_command(color_ostream &out, std::vector & params) { -/* - if (!init->display.flag.is_set(init_display_flags::RENDER_2D) && - !params.empty() && params[0] == "overlay") - { - out.printerr("'stonesense overlay' is not supported in this print mode.\n" - "Try changing PRINT_MODE to 2D or a similar choice in init.txt.\n"); - return CR_FAILURE; - } -#ifdef _DARWIN - if (!init->display.flag.is_set(init_display_flags::RENDER_2D)) - { - out.printerr("The current print mode is not suported\n" - "Change PRINT_MODE in init.txt to 2D or a similar choice\n"); - return CR_FAILURE; - } -#endif -*/ if(stonesense_started) { out.print("Stonesense already running.\n"); return CR_OK; } - stonesenseState.ssConfig.overlay_mode = false; + stonesenseState.ssConfig.immersive_mode = false; if(params.size() > 0 ) { - if(params[0] == "overlay"){ - //ssConfig.overlay_mode = true; + if(params[0] == "immersive"){ + auto focusStr = DFHack::Gui::getCurFocus().front(); + if (!(focusStr.starts_with("title") || + focusStr.starts_with("loadgame"))) { + out.print( + "You need to start this mode from the titlescreen and enable keyboard cursor (in settings) to ensure a proper state." + ); + return CR_OK; + } + stonesenseState.ssConfig.immersive_mode = true; } else { DumpInfo(out, params); return CR_OK; From 0031ff15348e96b7b444956a16a00ba01d91d90c Mon Sep 17 00:00:00 2001 From: Squid Coder Date: Sun, 2 Feb 2025 11:50:25 -0600 Subject: [PATCH 2/5] fix indent --- main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.cpp b/main.cpp index b11ecb65..22bd6399 100644 --- a/main.cpp +++ b/main.cpp @@ -246,8 +246,8 @@ static void main_loop(ALLEGRO_DISPLAY * display, ALLEGRO_EVENT_QUEUE *queue, ALL } } - doMouse(); - doRepeatActions(); + doMouse(); + doRepeatActions(); redraw = false; } /* Take the next event out of the event queue, and store it in `event'. */ From 85b830f4e73949fa1e33e861956deae1ed6c31e7 Mon Sep 17 00:00:00 2001 From: Squid Coder <92821989+realSquidCoder@users.noreply.github.com> Date: Sun, 9 Feb 2025 19:50:18 -0600 Subject: [PATCH 3/5] No immersive mode Signed-off-by: Squid Coder <92821989+realSquidCoder@users.noreply.github.com> --- GameConfiguration.h | 1 - 1 file changed, 1 deletion(-) diff --git a/GameConfiguration.h b/GameConfiguration.h index 93466634..f60ede1b 100644 --- a/GameConfiguration.h +++ b/GameConfiguration.h @@ -13,7 +13,6 @@ struct GameConfiguration { Config config; // items not configurable via the config file - bool immersive_mode; bool show_designations = true; bool show_announcements = false; bool show_keybinds = false; From d816df8bad995ef70d5683c7771c345c075f3de8 Mon Sep 17 00:00:00 2001 From: Squid Coder <92821989+realSquidCoder@users.noreply.github.com> Date: Sun, 9 Feb 2025 19:51:50 -0600 Subject: [PATCH 4/5] Apply suggestions from code review Co-authored-by: Myk --- main.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/main.cpp b/main.cpp index 22bd6399..da369c7e 100644 --- a/main.cpp +++ b/main.cpp @@ -353,8 +353,7 @@ static void* stonesense_thread(ALLEGRO_THREAD* main_thread, void* parms) auto& ssConfig = stonesenseState.ssConfig; al_set_new_display_flags( (ssConfig.config.Fullscreen ? ALLEGRO_FULLSCREEN : ALLEGRO_WINDOWED) - |(ALLEGRO_RESIZABLE) - |(0) + | ALLEGRO_RESIZABLE |(ssConfig.config.opengl ? ALLEGRO_OPENGL : 0) |(ssConfig.config.directX ? ALLEGRO_DIRECT3D_INTERNAL : 0)); From b393664eecb9680c477d208738ca75106f1d6886 Mon Sep 17 00:00:00 2001 From: Squid Coder Date: Sun, 9 Feb 2025 19:54:23 -0600 Subject: [PATCH 5/5] remove immersive reference --- main.cpp | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/main.cpp b/main.cpp index da369c7e..4fe4f4cd 100644 --- a/main.cpp +++ b/main.cpp @@ -508,22 +508,9 @@ DFhackCExport command_result stonesense_command(color_ostream &out, std::vector< out.print("Stonesense already running.\n"); return CR_OK; } - stonesenseState.ssConfig.immersive_mode = false; if(params.size() > 0 ) { - if(params[0] == "immersive"){ - auto focusStr = DFHack::Gui::getCurFocus().front(); - if (!(focusStr.starts_with("title") || - focusStr.starts_with("loadgame"))) { - out.print( - "You need to start this mode from the titlescreen and enable keyboard cursor (in settings) to ensure a proper state." - ); - return CR_OK; - } - stonesenseState.ssConfig.immersive_mode = true; - } else { - DumpInfo(out, params); - return CR_OK; - } + DumpInfo(out, params); + return CR_OK; } if(!al_is_system_installed()) {