Skip to content

Commit

Permalink
gui: Remove GUI1 filechooser
Browse files Browse the repository at this point in the history
This switches all existing callsites to using gui2::tfile_dialog, and
fixes a build issue due to editor/controller/editor_controller.cpp
relying on an indirect include from gui/dialogs/editor/custom_tod.hpp
for a full type declaration.
  • Loading branch information
irydacea committed Oct 5, 2016
1 parent 8056d63 commit 285bbe7
Show file tree
Hide file tree
Showing 13 changed files with 84 additions and 849 deletions.
4 changes: 0 additions & 4 deletions projectfiles/CodeBlocks/wesnoth.cbp
Expand Up @@ -322,8 +322,6 @@
<Unit filename="../../src/fake_unit_manager.hpp" />
<Unit filename="../../src/fake_unit_ptr.cpp" />
<Unit filename="../../src/fake_unit_ptr.hpp" />
<Unit filename="../../src/filechooser.cpp" />
<Unit filename="../../src/filechooser.hpp" />
<Unit filename="../../src/filesystem.hpp" />
<Unit filename="../../src/filesystem_boost.cpp" />
<Unit filename="../../src/filesystem_common.cpp" />
Expand Down Expand Up @@ -1153,8 +1151,6 @@
<Unit filename="../../src/widgets/combo_drag.hpp" />
<Unit filename="../../src/widgets/drop_target.cpp" />
<Unit filename="../../src/widgets/drop_target.hpp" />
<Unit filename="../../src/widgets/file_menu.cpp" />
<Unit filename="../../src/widgets/file_menu.hpp" />
<Unit filename="../../src/widgets/label.cpp" />
<Unit filename="../../src/widgets/label.hpp" />
<Unit filename="../../src/widgets/menu.cpp" />
Expand Down
2 changes: 0 additions & 2 deletions src/CMakeLists.txt
Expand Up @@ -726,7 +726,6 @@ set(wesnoth-main_SRC
editor/map/context_manager.cpp
fake_unit_manager.cpp
fake_unit_ptr.cpp
filechooser.cpp
filesystem_sdl.cpp
game_initialization/flg_manager.cpp
floating_textbox.cpp
Expand Down Expand Up @@ -1026,7 +1025,6 @@ set(libwesnoth-game_STAT_SRC
video.cpp
theme.cpp
widgets/button.cpp
widgets/file_menu.cpp
widgets/label.cpp
widgets/menu.cpp
widgets/menu_style.cpp
Expand Down
2 changes: 0 additions & 2 deletions src/SConscript
Expand Up @@ -131,7 +131,6 @@ libwesnoth_sources = Split("""
utils/make_enum.cpp
video.cpp
widgets/button.cpp
widgets/file_menu.cpp
widgets/label.cpp
widgets/menu_style.cpp
widgets/menu.cpp
Expand Down Expand Up @@ -284,7 +283,6 @@ wesnoth_sources = Split("""
editor/toolkit/editor_toolkit.cpp
fake_unit_manager.cpp
fake_unit_ptr.cpp
filechooser.cpp
filesystem_sdl.cpp
floating_textbox.cpp
formula/callable_objects.cpp
Expand Down
1 change: 1 addition & 0 deletions src/editor/controller/editor_controller.cpp
Expand Up @@ -42,6 +42,7 @@
#include "reports.hpp"

#include "desktop/clipboard.hpp"
#include "floating_label.hpp"
#include "game_board.hpp"
#include "game_preferences.hpp"
#include "gettext.hpp"
Expand Down
67 changes: 51 additions & 16 deletions src/editor/map/context_manager.cpp
Expand Up @@ -19,7 +19,6 @@
#include "context_manager.hpp"
#include "display.hpp"
#include "filesystem.hpp"
#include "filechooser.hpp"
#include "formula/string_utils.hpp"
#include "game_board.hpp"
#include "gettext.hpp"
Expand All @@ -35,6 +34,7 @@
#include "gui/dialogs/editor/new_map.hpp"
#include "gui/dialogs/editor/resize_map.hpp"
#include "gui/dialogs/edit_text.hpp"
#include "gui/dialogs/file_dialog.hpp"
#include "gui/dialogs/message.hpp"
#include "gui/dialogs/transient_message.hpp"
#include "gui/widgets/window.hpp"
Expand Down Expand Up @@ -190,9 +190,14 @@ void context_manager::load_map_dialog(bool force_same_context /* = false */)
if (fn.empty()) {
fn = default_dir_;
}
int res = dialogs::show_file_chooser_dialog(gui_.video(), fn, _("Choose a File to Open"));
if (res == 0) {
load_map(fn, !force_same_context);

gui2::tfile_dialog dlg;

dlg.set_title(_("Choose a File to Open"))
.set_path(fn);

if(dlg.show(gui_.video())) {
load_map(dlg.path(), !force_same_context);
}
}

Expand Down Expand Up @@ -444,10 +449,15 @@ void context_manager::apply_mask_dialog()
if (fn.empty()) {
fn = default_dir_;
}
int res = dialogs::show_file_chooser_dialog(gui_.video(), fn, _("Choose a Mask to Apply"));
if (res == 0) {

gui2::tfile_dialog dlg;

dlg.set_title(_("Choose a Mask to Apply"))
.set_path(fn);

if(dlg.show(gui_.video())) {
try {
map_context mask(game_config_, fn, gui_);
map_context mask(game_config_, dlg.path(), gui_);
editor_action_apply_mask a(mask.get_map());
perform_refresh(a);
} catch (editor_map_load_exception& e) {
Expand Down Expand Up @@ -481,10 +491,15 @@ void context_manager::create_mask_to_dialog()
if (fn.empty()) {
fn = default_dir_;
}
int res = dialogs::show_file_chooser_dialog(gui_.video(), fn, _("Choose Target Map"));
if (res == 0) {

gui2::tfile_dialog dlg;

dlg.set_title(_("Choose Target Map"))
.set_path(fn);

if(dlg.show(gui_.video())) {
try {
map_context map(game_config_, fn, gui_);
map_context map(game_config_, dlg.path(), gui_);
editor_action_create_mask a(map.get_map());
perform_refresh(a);
} catch (editor_map_load_exception& e) {
Expand Down Expand Up @@ -605,10 +620,20 @@ void context_manager::save_map_as_dialog()
int overwrite_res = 1;
do {
input_name = old_input_name;
int res = dialogs::show_file_chooser_dialog_save(gui_.video(), input_name, _("Save the Map As"), ".map");
if (res == 0) {

gui2::tfile_dialog dlg;

dlg.set_title(_("Save the Map As"))
.set_ok_label(_("Save"))
.set_save_mode(true)
.set_path(input_name)
.set_extension(".map");

if(dlg.show(gui_.video())) {
input_name = dlg.path();

if (filesystem::file_exists(input_name)) {
res = gui2::show_message(gui_.video(), "",
int res = gui2::show_message(gui_.video(), "",
_("The file already exists. Do you want to overwrite it?"), gui2::tmessage::yes_no_buttons);
overwrite_res = gui2::twindow::CANCEL == res ? 1 : 0;
} else {
Expand All @@ -633,10 +658,20 @@ void context_manager::save_scenario_as_dialog()
int overwrite_res = 1;
do {
input_name = old_input_name;
int res = dialogs::show_file_chooser_dialog_save(gui_.video(), input_name, _("Save the Scenario As"), ".cfg");
if (res == 0) {

gui2::tfile_dialog dlg;

dlg.set_title(_("Save the Scenario As"))
.set_ok_label(_("Save"))
.set_save_mode(true)
.set_path(input_name)
.set_extension(".cfg");

if(dlg.show(gui_.video())) {
input_name = dlg.path();

if (filesystem::file_exists(input_name)) {
res = gui2::show_message(gui_.video(), "",
int res = gui2::show_message(gui_.video(), "",
_("The file already exists. Do you want to overwrite it?"), gui2::tmessage::yes_no_buttons);
overwrite_res = gui2::twindow::CANCEL == res ? 1 : 0;
} else {
Expand Down

0 comments on commit 285bbe7

Please sign in to comment.