WIP unit-create dialog (debug mode only) using GUI2.
It is only used with --new-widgets for now. If you open it you'll have to use ESC since there are no OK or Cancel buttons yet.
This commit is contained in:
parent
ce93debef0
commit
8d77912423
9 changed files with 313 additions and 0 deletions
201
data/gui/default/window/unit_create.cfg
Normal file
201
data/gui/default/window/unit_create.cfg
Normal file
|
@ -0,0 +1,201 @@
|
|||
#textdomain wesnoth-lib
|
||||
###
|
||||
### Definition of the window to create units in debug mode.
|
||||
###
|
||||
|
||||
[window]
|
||||
id = "unit_create"
|
||||
description = "Debug-mode unit creation dialog."
|
||||
|
||||
[resolution]
|
||||
definition = "default"
|
||||
automatic_placement = "true"
|
||||
vertical_placement = "center"
|
||||
horizontal_placement = "center"
|
||||
|
||||
[linked_group]
|
||||
id = "race"
|
||||
fixed_width = "true"
|
||||
[/linked_group]
|
||||
[linked_group]
|
||||
id = "unit_type"
|
||||
fixed_width = "true"
|
||||
[/linked_group]
|
||||
|
||||
[grid]
|
||||
[row]
|
||||
grow_factor = 0
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "left"
|
||||
|
||||
[label]
|
||||
definition = "title"
|
||||
label = _ "Create Unit (Debug!)"
|
||||
[/label]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
[spacer]
|
||||
definition = "default"
|
||||
[/spacer]
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
[spacer]
|
||||
definition = "default"
|
||||
[/spacer]
|
||||
[/column]
|
||||
[/row]
|
||||
|
||||
[row]
|
||||
grow_factor = 0
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "left"
|
||||
|
||||
[label]
|
||||
definition = "default"
|
||||
label= _ "Gender:"
|
||||
[/label]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "left"
|
||||
|
||||
[toggle_button]
|
||||
id = "male_toggle"
|
||||
definition = "default"
|
||||
label= _ "Male"
|
||||
[/toggle_button]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "left"
|
||||
|
||||
[toggle_button]
|
||||
id = "female_toggle"
|
||||
definition = "default"
|
||||
label= _ "Female"
|
||||
[/toggle_button]
|
||||
|
||||
[/column]
|
||||
[/row]
|
||||
|
||||
[row]
|
||||
grow_factor = 0
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "left"
|
||||
|
||||
[listbox]
|
||||
id = "unit_type_list"
|
||||
definition = "default"
|
||||
linked_widgets_disabled = "true"
|
||||
[header]
|
||||
[row]
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
border = "all"
|
||||
border_size = 5
|
||||
[label]
|
||||
id = "race"
|
||||
definition = "default"
|
||||
linked_group = "race"
|
||||
label = _ "Race"
|
||||
[/label]
|
||||
[/column]
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
border = "all"
|
||||
border_size = 5
|
||||
[label]
|
||||
id = "unit_type"
|
||||
definition = "default"
|
||||
linked_group = "unit_type"
|
||||
label = _ "Type"
|
||||
[/label]
|
||||
[/column]
|
||||
[/row]
|
||||
[/header]
|
||||
|
||||
[list_definition]
|
||||
[row]
|
||||
[column]
|
||||
vertical_grow = "true"
|
||||
horizontal_grow = "true"
|
||||
|
||||
[toggle_panel]
|
||||
definition = "default"
|
||||
|
||||
return_value_id = "ok"
|
||||
[grid]
|
||||
[row]
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
border = "all"
|
||||
border_size = 5
|
||||
[label]
|
||||
id = "race"
|
||||
definition = "default"
|
||||
linked_group = "race"
|
||||
[/label]
|
||||
[/column]
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
border = "all"
|
||||
border_size = 5
|
||||
[label]
|
||||
id = "unit_type"
|
||||
definition = "default"
|
||||
linked_group = "unit_type"
|
||||
[/label]
|
||||
[/column]
|
||||
[/row]
|
||||
[/grid]
|
||||
[/toggle_panel]
|
||||
[/column]
|
||||
[/row]
|
||||
[/list_definition]
|
||||
[/listbox]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
[spacer]
|
||||
definition = "default"
|
||||
[/spacer]
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
[spacer]
|
||||
definition = "default"
|
||||
[/spacer]
|
||||
[/column]
|
||||
[/row]
|
||||
[/grid]
|
||||
[/resolution]
|
||||
|
||||
[/window]
|
|
@ -316,6 +316,7 @@ SET(wesnoth-main_SRC
|
|||
gui/dialogs/mp_cmd_wrapper.cpp
|
||||
gui/dialogs/title_screen.cpp
|
||||
gui/dialogs/transient_message.cpp
|
||||
gui/widgets/unit_create.cpp
|
||||
gui/dialogs/wml_message.cpp
|
||||
gui/widgets/button.cpp
|
||||
gui/widgets/control.cpp
|
||||
|
|
|
@ -137,6 +137,7 @@ wesnoth_source = \
|
|||
gui/dialogs/mp_cmd_wrapper.cpp \
|
||||
gui/dialogs/title_screen.cpp \
|
||||
gui/dialogs/transient_message.cpp \
|
||||
gui/widgets/unit_create.cpp \
|
||||
gui/dialogs/wml_message.cpp \
|
||||
gui/widgets/button.cpp \
|
||||
gui/widgets/control.cpp \
|
||||
|
|
|
@ -296,6 +296,7 @@ wesnoth_sources = Split("""
|
|||
gui/dialogs/mp_cmd_wrapper.cpp
|
||||
gui/dialogs/title_screen.cpp
|
||||
gui/dialogs/transient_message.cpp
|
||||
gui/dialogs/unit_create.cpp
|
||||
gui/dialogs/wml_message.cpp
|
||||
gui/widgets/button.cpp
|
||||
gui/widgets/control.cpp
|
||||
|
|
49
src/gui/dialogs/unit_create.cpp
Normal file
49
src/gui/dialogs/unit_create.cpp
Normal file
|
@ -0,0 +1,49 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2009 by Ignacio R. Morelle <shadowm2006@gmail.com>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License version 2
|
||||
or at your option any later version.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY.
|
||||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
#define GETTEXT_DOMAIN "wesnoth-lib"
|
||||
|
||||
#include "gui/dialogs/unit_create.hpp"
|
||||
|
||||
#include "gui/widgets/toggle_button.hpp"
|
||||
#include "gui/widgets/window.hpp"
|
||||
|
||||
namespace gui2 {
|
||||
|
||||
/* TODO: wiki-doc me! */
|
||||
|
||||
twindow* tunit_create::build_window(CVideo& video)
|
||||
{
|
||||
return build(video, get_id(UNIT_CREATE));
|
||||
}
|
||||
|
||||
void tunit_create::pre_show(CVideo& /*video*/, twindow& window)
|
||||
{
|
||||
ttoggle_button* male_toggle = dynamic_cast<ttoggle_button*>(window.find_widget("male_toggle", false));
|
||||
ttoggle_button* female_toggle = dynamic_cast<ttoggle_button*>(window.find_widget("female_toggle", false));
|
||||
|
||||
VALIDATE(male_toggle, missing_widget("male_toggle"));
|
||||
VALIDATE(female_toggle, missing_widget("female_toggle"));
|
||||
|
||||
if(gender_ == unit_race::FEMALE) {
|
||||
female_toggle->set_value(true);
|
||||
male_toggle->set_value(false);
|
||||
}
|
||||
else {
|
||||
female_toggle->set_value(false);
|
||||
male_toggle->set_value(true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
45
src/gui/dialogs/unit_create.hpp
Normal file
45
src/gui/dialogs/unit_create.hpp
Normal file
|
@ -0,0 +1,45 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2009 by Ignacio R. Morelle <shadowm2006@gmail.com>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License version 2
|
||||
or at your option any later version.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY.
|
||||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
#ifndef GUI_DIALOGS_UNIT_CREATE_HPP_INCLUDED
|
||||
#define GUI_DIALOGS_UNIT_CREATE_HPP_INCLUDED
|
||||
|
||||
#include "gui/dialogs/dialog.hpp"
|
||||
#include "race.hpp"
|
||||
|
||||
namespace gui2 {
|
||||
|
||||
class tunit_create : public tdialog
|
||||
{
|
||||
public:
|
||||
tunit_create(unit_race::GENDER default_gender = unit_race::MALE) :
|
||||
gender_(default_gender)
|
||||
{}
|
||||
|
||||
unit_race::GENDER gender() const { return gender_; }
|
||||
void set_gender(unit_race::GENDER gender) { gender_ = gender; }
|
||||
|
||||
private:
|
||||
unit_race::GENDER gender_;
|
||||
|
||||
/** Inherited from tdialog. */
|
||||
twindow* build_window(CVideo& video);
|
||||
|
||||
/** Inherited from tdialog. */
|
||||
void pre_show(CVideo& video, twindow& window);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* ! GUI_DIALOGS_UNIT_CREATE_HPP_INCLUDED */
|
|
@ -101,6 +101,7 @@ static void fill_window_types()
|
|||
#endif
|
||||
window_type_list[LOBBY_MAIN] = "lobby_main";
|
||||
window_type_list[LOBBY_PLAYER_INFO] = "lobby_player_info";
|
||||
window_type_list[UNIT_CREATE] = "unit_create";
|
||||
}
|
||||
|
||||
const std::string& get_id(const twindow_type window_type)
|
||||
|
|
|
@ -74,6 +74,7 @@ enum twindow_type {
|
|||
GAME_SAVE_OOS, /**< Save game dialog for processing OOS. */
|
||||
LOBBY_MAIN, /**< Main MP lobby screen */
|
||||
LOBBY_PLAYER_INFO, /**< MP lobby player info dialog */
|
||||
UNIT_CREATE, /**< Debug-mode unit creation dialog */
|
||||
COUNT /**<
|
||||
* The last one to hold the number of items and as
|
||||
* sentinel.
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "game_events.hpp"
|
||||
#include "gettext.hpp"
|
||||
#include "gui/dialogs/transient_message.hpp"
|
||||
#include "gui/dialogs/unit_create.hpp"
|
||||
#include "gui/widgets/window.hpp"
|
||||
#include "help.hpp"
|
||||
#include "log.hpp"
|
||||
|
@ -1370,6 +1371,18 @@ private:
|
|||
|
||||
void menu_handler::create_unit(mouse_handler& mousehandler)
|
||||
{
|
||||
if(gui2::new_widgets) {
|
||||
assert(gui_ != NULL);
|
||||
static unit_race::GENDER last_gender = unit_race::MALE;
|
||||
|
||||
gui2::tunit_create create_dlg;
|
||||
create_dlg.set_gender(last_gender);
|
||||
|
||||
create_dlg.show(gui_->video());
|
||||
|
||||
last_gender = create_dlg.gender();
|
||||
return;
|
||||
}
|
||||
std::vector<std::string> options;
|
||||
static int last_selection = -1;
|
||||
static bool random_gender = false;
|
||||
|
|
Loading…
Add table
Reference in a new issue