Merge lp:~widelands-dev/widelands/bug-1392406 into lp:widelands

Proposed by GunChleoc
Status: Merged
Merged at revision: 7262
Proposed branch: lp:~widelands-dev/widelands/bug-1392406
Merge into: lp:widelands
Diff against target: 28 lines (+11/-7)
1 file modified
src/editor/editorinteractive.cc (+11/-7)
To merge this branch: bzr merge lp:~widelands-dev/widelands/bug-1392406
Reviewer Review Type Date Requested Status
SirVer Approve
Review via email: mp+241727@code.launchpad.net

Description of the change

When leaving the editor after the map has changed, the confirmation dialog can now be skipped by pressing CTRL.

To post a comment you must log in.
Revision history for this message
SirVer (sirver) wrote :

Do we not have this code all over the place in the code base already? It maybe makes more sense to pull this out and reuse some code.

Revision history for this message
GunChleoc (gunchleoc) wrote :

The common code is:

if (get_key_state(SDL_SCANCODE_LCTRL) || get_key_state(SDL_SCANCODE_RCTRL)) {
    do_something_arbitrary();
} else {
   do_something_else_arbitrary();
}

There is an ActionConfirm object for Buildings and Ships.

For end_modal, we have 2 occurrences only: Here and in the game options window. There is no quick fix for making them the same, because the game options window needs m_gb.end_modal(0) and the editor needs end_modal(0) - they are different object types. So, the change would need to be bigger than I want to get into right now.

Revision history for this message
SirVer (sirver) wrote :

Makes sense. lgtm.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/editor/editorinteractive.cc'
--- src/editor/editorinteractive.cc 2014-11-13 08:25:45 +0000
+++ src/editor/editorinteractive.cc 2014-11-13 18:52:58 +0000
@@ -251,13 +251,17 @@
251251
252void EditorInteractive::exit() {252void EditorInteractive::exit() {
253 if (m_need_save) {253 if (m_need_save) {
254 UI::WLMessageBox mmb254 if (get_key_state(SDL_SCANCODE_LCTRL) || get_key_state(SDL_SCANCODE_RCTRL)) {
255 (this,255 end_modal(0);
256 _("Unsaved Map"),256 } else {
257 _("The map has not been saved, do you really want to quit?"),257 UI::WLMessageBox mmb
258 UI::WLMessageBox::YESNO);258 (this,
259 if (mmb.run() == 0)259 _("Unsaved Map"),
260 return;260 _("The map has not been saved, do you really want to quit?"),
261 UI::WLMessageBox::YESNO);
262 if (mmb.run() == 0)
263 return;
264 }
261 }265 }
262 end_modal(0);266 end_modal(0);
263}267}

Subscribers

People subscribed via source and target branches

to status/vote changes: