new map dialog in editor2 (compiles but doesn't work atm)
This commit is contained in:
parent
3ec1d79883
commit
aaa239fdce
8 changed files with 168 additions and 1 deletions
111
data/gui/default/window/editor_new_map.cfg
Normal file
111
data/gui/default/window/editor_new_map.cfg
Normal file
|
@ -0,0 +1,111 @@
|
|||
###
|
||||
### Definition of the window to create a new map in editor2.
|
||||
###
|
||||
|
||||
[window]
|
||||
id = "editor_new_map"
|
||||
description = "New map dialog."
|
||||
|
||||
[resolution]
|
||||
definition = "default"
|
||||
|
||||
automatic_placement = "true"
|
||||
vertical_placement = "center"
|
||||
horizontal_placement = "center"
|
||||
|
||||
[grid]
|
||||
|
||||
[row]
|
||||
grow_factor = 0
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "left"
|
||||
|
||||
[text_box]
|
||||
id = "width"
|
||||
definition = "default"
|
||||
label = _ "Width"
|
||||
[/text_box]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[row]
|
||||
grow_factor = 0
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "left"
|
||||
|
||||
[text_box]
|
||||
id = "height"
|
||||
definition = "default"
|
||||
label = _ "Height"
|
||||
[/text_box]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[row]
|
||||
grow_factor = 0
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
[grid]
|
||||
|
||||
[row]
|
||||
grow_factor = 0
|
||||
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "right"
|
||||
|
||||
[button]
|
||||
id = "ok"
|
||||
definition = "default"
|
||||
|
||||
size_text = _ "Create new map"
|
||||
label = _ "Create new map"
|
||||
[/button]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "right"
|
||||
|
||||
[button]
|
||||
id = "cancel"
|
||||
definition = "default"
|
||||
|
||||
label = _ "Cancel"
|
||||
[/button]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[/grid]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[/grid]
|
||||
|
||||
[/resolution]
|
||||
|
||||
[/window]
|
|
@ -304,6 +304,7 @@ SET(wesnoth-main_SRC
|
|||
IF(ENABLE_EDITOR2)
|
||||
|
||||
SET(wesnoth-editor2_SRC
|
||||
gui/dialogs/editor_new_map.cpp
|
||||
editor2/action.cpp
|
||||
editor2/brush.cpp
|
||||
editor2/editor_main.cpp
|
||||
|
|
|
@ -149,6 +149,7 @@ wesnoth_source = \
|
|||
|
||||
# used with editor2 option in the wesnoth target
|
||||
wesnoth_editor2_SOURCES = \
|
||||
gui/dialogs/editor_new_map.cpp \
|
||||
editor2/action.cpp \
|
||||
editor2/brush.cpp \
|
||||
editor2/editor_main.cpp \
|
||||
|
|
|
@ -241,6 +241,7 @@ wesnoth_sources.extend(python_env.Object(Split("""
|
|||
|
||||
# used with editor2 option in the wesnoth target
|
||||
wesnoth_editor2_sources = Split("""
|
||||
gui/dialogs/editor_new_map.cpp
|
||||
editor2/action.cpp
|
||||
editor2/brush.cpp
|
||||
editor2/editor_main.cpp
|
||||
|
|
|
@ -16,6 +16,9 @@
|
|||
#include "editor_map.hpp"
|
||||
#include "mouse_action.hpp"
|
||||
|
||||
#include "gui/dialogs/editor_new_map.hpp"
|
||||
#include "gui/widgets/button.hpp"
|
||||
|
||||
#include "../config_adapter.hpp"
|
||||
#include "../construct_dialog.hpp"
|
||||
#include "../cursor.hpp"
|
||||
|
@ -119,6 +122,38 @@ void editor_controller::load_map_dialog()
|
|||
}
|
||||
}
|
||||
|
||||
void editor_controller::new_map_dialog()
|
||||
{
|
||||
gui2::teditor_new_map dialog;;
|
||||
dialog.set_map_width(map_.w());
|
||||
dialog.set_map_height(map_.h());
|
||||
|
||||
dialog.show(gui().video());
|
||||
int res = dialog.get_retval();
|
||||
if(res == gui2::tbutton::OK) {
|
||||
int w = dialog.map_width();
|
||||
int h = dialog.map_height();
|
||||
t_translation::t_terrain fill = t_translation::GRASS_LAND;
|
||||
new_map(w, h, fill);
|
||||
}
|
||||
}
|
||||
|
||||
void editor_controller::save_map_as_dialog()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void editor_controller::save_map()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void editor_controller::save_map_as(const std::string& filename)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void editor_controller::load_map(const std::string& filename)
|
||||
{
|
||||
std::string map_string = read_file(filename);
|
||||
|
@ -140,6 +175,11 @@ void editor_controller::load_map(const std::string& filename)
|
|||
}
|
||||
}
|
||||
|
||||
void editor_controller::new_map(int width, int height, t_translation::t_terrain fill)
|
||||
{
|
||||
set_map(editor_map::new_map(game_config_, width, height, fill));
|
||||
}
|
||||
|
||||
void editor_controller::set_map(const editor_map& map)
|
||||
{
|
||||
map_ = map;
|
||||
|
@ -244,6 +284,9 @@ bool editor_controller::execute_command(hotkey::HOTKEY_COMMAND command, int inde
|
|||
case HOTKEY_EDITOR_MAP_LOAD:
|
||||
load_map_dialog();
|
||||
return true;
|
||||
case HOTKEY_EDITOR_MAP_NEW:
|
||||
new_map_dialog();
|
||||
return true;
|
||||
default:
|
||||
return controller_base::execute_command(command, index);
|
||||
}
|
||||
|
|
|
@ -46,6 +46,11 @@ class editor_controller : public controller_base,
|
|||
void hotkey_quit();
|
||||
void quit_confirm(EXIT_STATUS status);
|
||||
void load_map_dialog();
|
||||
void new_map_dialog();
|
||||
void save_map_as_dialog();
|
||||
void save_map();
|
||||
void save_map_as(const std::string& filename);
|
||||
void new_map(int width, int height, t_translation::t_terrain fill);
|
||||
void load_map(const std::string& filename);
|
||||
void set_map(const editor_map& map);
|
||||
bool can_execute_command(hotkey::HOTKEY_COMMAND, int index = -1) const;
|
||||
|
|
|
@ -87,6 +87,9 @@ static void fill_window_types()
|
|||
window_type_list[MP_CONNECT] = "mp_connect";
|
||||
window_type_list[MP_METHOD_SELECTION] = "mp_method_selection";
|
||||
window_type_list[MP_SERVER_LIST] = "mp_server_list";
|
||||
#ifdef USE_EDITOR2
|
||||
window_type_list[EDITOR_NEW_MAP] = "editor_new_map";
|
||||
#endif
|
||||
}
|
||||
|
||||
const std::string& get_id(const twindow_type window_type)
|
||||
|
|
|
@ -40,7 +40,9 @@ enum twindow_type {
|
|||
MP_METHOD_SELECTION, //<! The dialog which allows you to choose the kind
|
||||
//! mp game the user wants to play.
|
||||
MP_SERVER_LIST, //<! The mp server list dialog.
|
||||
|
||||
#ifdef USE_EDITOR2
|
||||
EDITOR_NEW_MAP, //<! New map dialog
|
||||
#endif
|
||||
DUMMY //<! Dummy always the last one.
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue