Skip to content

Commit

Permalink
Do not rebuild interface while changing settings (#9317)
Browse files Browse the repository at this point in the history
  • Loading branch information
ihhub authored Dec 11, 2024
1 parent 5c4979a commit 23aedf7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
13 changes: 10 additions & 3 deletions src/fheroes2/dialog/dialog_system_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,13 +416,18 @@ namespace fheroes2
auto redrawAdventureMap = []() {
Interface::AdventureMap & adventureMap = Interface::AdventureMap::Get();

adventureMap.reset();
// Since radar interface has a restorer we must redraw it first to avoid the restorer do some nasty work.
adventureMap.redraw( Interface::REDRAW_RADAR );

adventureMap.redraw( Interface::REDRAW_ALL & ( ~Interface::REDRAW_RADAR ) );
};

auto rebildAdventureMap = [&redrawAdventureMap]() {
Interface::AdventureMap::Get().reset();

redrawAdventureMap();
};

DialogAction action = DialogAction::Configuration;

while ( action != DialogAction::Close ) {
Expand All @@ -445,13 +450,15 @@ namespace fheroes2
Dialog::OK );
}

// We can redraw only status window as it is the only place that has text but to be safe let's redraw everything.
redrawAdventureMap();

saveConfiguration = true;
action = DialogAction::Configuration;
break;
}
case DialogAction::Graphics:
saveConfiguration |= fheroes2::openGraphicsSettingsDialog( redrawAdventureMap );
saveConfiguration |= fheroes2::openGraphicsSettingsDialog( rebildAdventureMap );

action = DialogAction::Configuration;
break;
Expand All @@ -466,7 +473,7 @@ namespace fheroes2
action = DialogAction::Configuration;
break;
case DialogAction::InterfaceSettings:
saveConfiguration |= fheroes2::openInterfaceSettingsDialog( redrawAdventureMap );
saveConfiguration |= fheroes2::openInterfaceSettingsDialog( rebildAdventureMap );

action = DialogAction::Configuration;
break;
Expand Down
15 changes: 10 additions & 5 deletions src/fheroes2/editor/editor_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,9 @@ namespace Editor
bool saveConfiguration = false;
Settings & conf = Settings::Get();

auto redrawEditorMap = [&conf]() {
auto redrawEditor = [&conf]() {
Interface::EditorInterface & editorInterface = Interface::EditorInterface::Get();

editorInterface.reset();
// Since the radar interface has a restorer we must redraw it first to avoid the restorer doing something nasty.
editorInterface.redraw( Interface::REDRAW_RADAR );

Expand All @@ -251,6 +250,12 @@ namespace Editor
editorInterface.redraw( redrawOptions & ( ~Interface::REDRAW_RADAR ) );
};

auto rebuildEditor = [&redrawEditor]() {
Interface::EditorInterface::Get().reset();

redrawEditor();
};

DialogAction action = DialogAction::Configuration;

while ( action != DialogAction::Close ) {
Expand All @@ -273,13 +278,13 @@ namespace Editor
Dialog::OK );
}

redrawEditorMap();
redrawEditor();
saveConfiguration = true;
action = DialogAction::Configuration;
break;
}
case DialogAction::Graphics:
saveConfiguration |= fheroes2::openGraphicsSettingsDialog( redrawEditorMap );
saveConfiguration |= fheroes2::openGraphicsSettingsDialog( rebuildEditor );

action = DialogAction::Configuration;
break;
Expand Down Expand Up @@ -310,7 +315,7 @@ namespace Editor
conf.setEditorPassability( !conf.isEditorPassabilityEnabled() );
saveConfiguration = true;

redrawEditorMap();
redrawEditor();

action = DialogAction::Configuration;
break;
Expand Down

0 comments on commit 23aedf7

Please sign in to comment.