[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-Devel] [PATCH] Editor: show a confirmation dialog before exiting
From: |
Paul Hüber |
Subject: |
[Pingus-Devel] [PATCH] Editor: show a confirmation dialog before exiting |
Date: |
Sun, 29 Mar 2020 19:12:11 +0200 |
From: Paul Hüber <address@hidden>
Ask for users confirmation before leaving the editor screen.
Hitting <esc> on accident is all too easy, especially after exiting a
test run.
---
src/editor/editor_screen.cpp | 22 ++++++++++++++++------
src/editor/editor_screen.hpp | 4 ++--
src/editor/panel.cpp | 2 +-
3 files changed, 19 insertions(+), 9 deletions(-)
diff --git a/src/editor/editor_screen.cpp b/src/editor/editor_screen.cpp
index 37b23d094..1cd47992f 100644
--- a/src/editor/editor_screen.cpp
+++ b/src/editor/editor_screen.cpp
@@ -104,6 +104,16 @@ EditorScreen::EditorScreen() :
m_level_new_msgbox->on_ok.connect(std::bind(&EditorScreen::level_new_without_confirm,
this));
m_level_new_msgbox->hide();
+
+ close_confirm_msgbox =
gui_manager->create<MessageBox>(Rect(Vector2i((Display::get_width() -
msg_size.width)/2,
+
(Display::get_height() - msg_size.height)/2),
+ msg_size));
+ close_confirm_msgbox->set_title("Exit editor");
+ close_confirm_msgbox->set_text("Do you really want to exit the editor?");
+ close_confirm_msgbox->set_ok_text("Exit");
+
close_confirm_msgbox->on_ok.connect(std::bind(&EditorScreen::close_without_confirm,
this));
+
+ close_confirm_msgbox->hide();
}
viewport->selection_changed.connect(std::bind(&ObjectProperties::set_objects,
object_properties, std::placeholders::_1));
@@ -126,6 +136,12 @@ EditorScreen::on_startup ()
// Close the current screen
void
EditorScreen::close_screen()
+{
+ close_confirm_msgbox->show();
+}
+
+void
+EditorScreen::close_without_confirm()
{
ScreenManager::instance()->pop_screen();
}
@@ -510,12 +526,6 @@ EditorScreen::toggle_level_properties()
}
}
-void
-EditorScreen::exit()
-{
- ScreenManager::instance()->pop_screen();
-}
-
void
EditorScreen::update_layout()
{
diff --git a/src/editor/editor_screen.hpp b/src/editor/editor_screen.hpp
index 078bb0ca1..324bd72e8 100644
--- a/src/editor/editor_screen.hpp
+++ b/src/editor/editor_screen.hpp
@@ -60,6 +60,7 @@ private:
FileDialog* file_save_dialog;
MessageBox* m_level_new_msgbox;
+ MessageBox* close_confirm_msgbox;
bool show_help;
@@ -112,6 +113,7 @@ public:
// Functions accessible from the GUI
void level_new_without_confirm();
+ void close_without_confirm();
void level_new();
void level_load();
void level_save();
@@ -141,8 +143,6 @@ public:
void toggle_help();
- void exit();
-
void resize(const Size&);
void update_layout();
diff --git a/src/editor/panel.cpp b/src/editor/panel.cpp
index a6dde9b99..a717fc2b5 100644
--- a/src/editor/panel.cpp
+++ b/src/editor/panel.cpp
@@ -209,7 +209,7 @@ Panel::Panel(EditorScreen* editor_, const Rect& rect_) :
add_button("core/editor/help", _("Display help"),
&EditorScreen::toggle_help);
add_button("core/editor/exit", _("Exit"),
- &EditorScreen::exit);
+ &EditorScreen::close_screen);
}
Panel::~Panel()
--
2.25.1
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-Devel] [PATCH] Editor: show a confirmation dialog before exiting,
Paul Hüber <=