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
1=== modified file 'src/editor/editorinteractive.cc'
2--- src/editor/editorinteractive.cc 2014-11-13 08:25:45 +0000
3+++ src/editor/editorinteractive.cc 2014-11-13 18:52:58 +0000
4@@ -251,13 +251,17 @@
5
6 void EditorInteractive::exit() {
7 if (m_need_save) {
8- UI::WLMessageBox mmb
9- (this,
10- _("Unsaved Map"),
11- _("The map has not been saved, do you really want to quit?"),
12- UI::WLMessageBox::YESNO);
13- if (mmb.run() == 0)
14- return;
15+ if (get_key_state(SDL_SCANCODE_LCTRL) || get_key_state(SDL_SCANCODE_RCTRL)) {
16+ end_modal(0);
17+ } else {
18+ UI::WLMessageBox mmb
19+ (this,
20+ _("Unsaved Map"),
21+ _("The map has not been saved, do you really want to quit?"),
22+ UI::WLMessageBox::YESNO);
23+ if (mmb.run() == 0)
24+ return;
25+ }
26 }
27 end_modal(0);
28 }

Subscribers

People subscribed via source and target branches

to status/vote changes: