Merge remote-tracking branch 'origin/master' into guifixes

This commit is contained in:
Andreas Löf 2016-02-28 08:46:33 +13:00
commit 46a0eb0e55
84 changed files with 448 additions and 439 deletions

View file

@ -43,6 +43,7 @@ Version 1.13.2+dev:
* Implemented a new GUI2 Attack dialog
* Added gui2 comboboxes.
* Removed prompt when purging the WML cache from Preferences.
* Implemented a new GUI2 Preferences dialog
* WML engine:
* Added new event "unit placed", which triggers when (and regardless of how)
a unit appears on the map.
@ -56,6 +57,7 @@ Version 1.13.2+dev:
* Added {CURRENT_FILE} and {CURRENT_DIRECTORY} macros.
* add support for relative dirs in wesnoth.dofile/require
* Added name= and write_name= attributes in [item]
* Added description_alignment= key to [campaign]
* Miscellaneous and bug fixes:
* Fix the new log code on Windows to actually use Unicode-aware functions
in a couple of places so Wesnoth does not quit on startup when trying to

View file

@ -68,7 +68,6 @@
id=Lomarfel
name= _ "Lomarfel"
profile=portraits/lomarfel.png
unrenamable=yes
x,y=15,18
[modifications]
{TRAIT_LOYAL}

View file

@ -119,7 +119,6 @@
id=Lomarfel
name= _ "Lomarfel"
profile=portraits/lomarfel.png
unrenamable=yes
x,y=16,18
[modifications]
{TRAIT_LOYAL}
@ -140,7 +139,6 @@
id=Celodith
name= _ "Celodith"
gender=female
unrenamable=yes
x,y=17,18
side=1
[modifications]
@ -161,7 +159,6 @@
id=Earanduil
name= _ "Earanduil"
gender=male
unrenamable=yes
x,y=17,19
side=1
[modifications]
@ -182,7 +179,6 @@
id=Elvyniel
name= _ "Elvyniel"
gender=female
unrenamable=yes
x,y=18,18
side=1
[modifications]
@ -203,7 +199,6 @@
id=Delorfilith
name= _ "Delorfilith"
gender=male
unrenamable=yes
x,y=18,19
side=1
[modifications]

View file

@ -100,7 +100,6 @@
type=Orcish Warlord
id=Upgar
name= _ "Upgar"
unrenamable=yes
side=2
controller=ai
canrecruit=yes
@ -155,7 +154,6 @@
type=Lieutenant
id=Niktor
name= _ "Niktor"
unrenamable=yes
side=4
controller=ai
canrecruit=yes
@ -182,7 +180,6 @@
type=White Mage
id=Arpus
name= _ "Arpus"
unrenamable=yes
side=5
controller=ai
canrecruit=yes

View file

@ -156,7 +156,6 @@
id=Taylor
name= _ "Taylor"
canrecruit=yes
unrenamable=yes
fog=yes
color=green

View file

@ -222,6 +222,7 @@
type=Paladin
id=Terraent
name= _ "Terraent"
unrenamable=yes
x,y=$prison_locations[$i].x,$prison_locations[$i].y
random_traits=no
facing=sw

View file

@ -73,6 +73,7 @@
type=Ogre
id=Grug
name= _ "Grug"
unrenamable=yes
side=4
canrecruit=yes
facing=sw

View file

@ -185,6 +185,7 @@
[unit]
id=Engineer
name= _ "Engineer"
unrenamable=yes
type=Red Mage
x,y=18,5
side=1

View file

@ -326,7 +326,6 @@
id=Gwaba
type=Merman Fighter
name= _ "Gwaba"
unrenamable=yes
[modifications]
{TRAIT_LOYAL}
{TRAIT_STRONG}
@ -340,7 +339,6 @@
id=Nepba
type=Merman Fighter
name= _ "Nepba"
unrenamable=yes
[modifications]
{TRAIT_LOYAL}
{TRAIT_INTELLIGENT}
@ -354,7 +352,6 @@
id=Triram
type=Merman Fighter
name= _ "Triram"
unrenamable=yes
[modifications]
{TRAIT_LOYAL}
{TRAIT_RESILIENT}
@ -370,7 +367,6 @@
id=Mriram
type=Merman Fighter
name= _ "Mriram"
unrenamable=yes
[modifications]
{TRAIT_LOYAL}
{TRAIT_STRONG}
@ -403,7 +399,6 @@
id=Mabooa
type=Merman Fighter
name= _ "Mabooa"
unrenamable=yes
[modifications]
{TRAIT_LOYAL}
{TRAIT_RESILIENT}
@ -419,7 +414,6 @@
id=Earooa
type=Merman Fighter
name= _ "Earooa"
unrenamable=yes
[modifications]
{TRAIT_LOYAL}
{TRAIT_STRONG}
@ -433,7 +427,6 @@
id=Nethuns
type=Merman Fighter
name= _ "Nethuns"
unrenamable=yes
[modifications]
{TRAIT_LOYAL}
{TRAIT_INTELLIGENT}
@ -448,7 +441,6 @@
id=Gwoama
type=Merman Fighter
name= _ "Gwoama"
unrenamable=yes
[modifications]
{TRAIT_LOYAL}
{TRAIT_RESILIENT}
@ -481,7 +473,6 @@
id=Kaba
type=Merman Fighter
name= _ "Kaba"
unrenamable=yes
[modifications]
{TRAIT_LOYAL}
{TRAIT_QUICK}
@ -497,7 +488,6 @@
id=Kwaboo
type=Merman Fighter
name= _ "Kwaboo"
unrenamable=yes
[modifications]
{TRAIT_LOYAL}
{TRAIT_INTELLIGENT}
@ -531,7 +521,6 @@
id=Gwimli
type=Merman Fighter
name= _ "Gwimli"
unrenamable=yes
[modifications]
{TRAIT_LOYAL}
{TRAIT_STRONG}
@ -545,7 +534,6 @@
id=Jarla
type=Merman Fighter
name= _ "Jarla"
unrenamable=yes
[modifications]
{TRAIT_LOYAL}
{TRAIT_INTELLIGENT}
@ -561,7 +549,6 @@
id=Gwarloa
type=Merman Fighter
name= _ "Gwarloa"
unrenamable=yes
[modifications]
{TRAIT_LOYAL}
{TRAIT_RESILIENT}
@ -594,7 +581,6 @@
id=Heldaga
type=Merman Fighter
name= _ "Heldaga"
unrenamable=yes
[modifications]
{TRAIT_LOYAL}
{TRAIT_QUICK}
@ -608,7 +594,6 @@
id=Apalala
type=Merman Hunter
name= _ "Apalala"
unrenamable=yes
[modifications]
{TRAIT_LOYAL}
{TRAIT_STRONG}
@ -622,7 +607,6 @@
id=Oceania
type=Mermaid Initiate
name= _ "Oceania"
unrenamable=yes
[modifications]
{TRAIT_LOYAL}
{TRAIT_INTELLIGENT}
@ -637,7 +621,6 @@
id=Elcmar
type=Merman Fighter
name= _ "Elcmar"
unrenamable=yes
[modifications]
{TRAIT_LOYAL}
{TRAIT_STRONG}
@ -651,7 +634,6 @@
id=Aigaion
type=Merman Fighter
name= _ "Aigaion"
unrenamable=yes
[modifications]
{TRAIT_LOYAL}
{TRAIT_QUICK}
@ -666,7 +648,6 @@
id=Tini
type=Merman Fighter
name= _ "Tini"
unrenamable=yes
[modifications]
{TRAIT_LOYAL}
{TRAIT_RESILIENT}

View file

@ -85,7 +85,6 @@
type=Princess
id="Li'sar"
name= _ "Lisar"
unrenamable=yes
profile=portraits/lisar.png
side=2
canrecruit=yes

View file

@ -190,7 +190,6 @@
side=2
x,y=2,21
random_traits=no
unrenamable=yes
[modifications]
{TRAIT_LOYAL}

View file

@ -16,6 +16,7 @@
type=Dwarvish Fighter
id=Rugnur
name= _ "Rugnur"
unrenamable=yes
side=1
canrecruit=yes
facing=sw
@ -305,6 +306,7 @@
side=1
id=Alanin
name= _ "Alanin"
unrenamable=yes
{IS_HERO}
profile=portraits/alanin.png
[modifications]

View file

@ -211,6 +211,7 @@
side=1
id=Baglur
name= _ "Baglur"
unrenamable=yes
{IS_HERO}
profile=portraits/baglur.png
facing=sw

View file

@ -286,6 +286,7 @@
type=Gryphon
id=Krawg
name= _ "Krawg"
unrenamable=yes
{IS_HERO}
x,y=5,24
side=1
@ -494,6 +495,7 @@
type=Dwarvish Runemaster
id=Thursagan
name= _ "Thursagan"
unrenamable=yes
{IS_HERO}
profile=portraits/thursagan.png
advances_to=Dwarvish Arcanister

View file

@ -183,6 +183,7 @@
type=Dwarvish Lord
id=Durstorn
name= _ "Durstorn"
unrenamable=yes
side=1
{IS_HERO}
profile=portraits/durstorn-insane.png

View file

@ -54,6 +54,7 @@
type=Orcish Leader
id="Kapou'e"
name= _ "Kapoue"
unrenamable=yes
profile=portraits/kapoue.png
side=1
canrecruit=yes

View file

@ -246,6 +246,7 @@
[unit]
id=Grüü
name= _ "Grüü"
unrenamable=yes
type=Troll Hero
side=3
x=30

View file

@ -238,6 +238,7 @@
[+unit]
random_traits=no
profile=portraits/inarix.png
unrenamable=yes
[/unit]
{GENERIC_UNIT 1 "Saurian Skirmisher" 8 42}

View file

@ -4,6 +4,7 @@
[unit]
id={ID_STRING}
name={NAME_STRING}
unrenamable=yes
type=Old Orcish Shaman
profile=portraits/old_orcish_shaman.png
side={SIDE}
@ -21,6 +22,7 @@
[unit]
id={ID_STRING}
name={NAME_STRING}
unrenamable=yes
type=Novice Orcish Shaman
profile=portraits/young_orcish_shaman.png
side={SIDE}
@ -38,6 +40,7 @@
[unit]
id={ID_STRING}
name={NAME_STRING}
unrenamable=yes
type=Orcish Shaman
profile=portraits/orcish_shaman.png
side={SIDE}
@ -72,6 +75,7 @@
type=Orcish Warlord
id="Al'Brock"
name= _ "AlBrock"
unrenamable=yes
side=2
canrecruit=yes
profile=portraits/albrock.png
@ -85,6 +89,7 @@
type=Orcish Warlord
id="Flar'Tar"
name= _ "FlarTar"
unrenamable=yes
side=3
canrecruit=yes
profile=portraits/flartar.png

View file

@ -322,6 +322,7 @@
[unit]
id=Lady Outlaw
name= _ "Lady Outlaw"
unrenamable=yes
type=$wesfolk_leader_store.type
gender=female
side=1

View file

@ -401,7 +401,6 @@
id=Minister Edren
name= _ "Minister Edren"
profile="portraits/edmond.png"
unrenamable=yes
x={X}
y={Y}
[modifications]
@ -576,7 +575,6 @@ Enter at Your Own Risk!"
id=Sir Ruddry
name= _ "Sir Ruddry"
profile="portraits/ruddry.png"
unrenamable=yes
x=35
y=35
[modifications]

View file

@ -256,6 +256,7 @@
[unit]
id=Lady Jessene
name= _ "Lady Jessene"
unrenamable=yes
type=$lady_store.type
gender=female
variation=unmasked

View file

@ -197,6 +197,10 @@
description= _ "Death of Lady Jessene"
condition=lose
[/objective]
[objective]
description= _ "Death of Lord Typhon"
condition=lose
[/objective]
#textdomain wesnoth
notes_string = _"Gold carryover:"
#textdomain wesnoth-trow

View file

@ -165,6 +165,7 @@
{QUANTITY type Pikeman Spearman Peasant}
id=Moreth
name= _ "Moreth"
unrenamable=yes
side=1
x,y=19,5
[modifications]
@ -235,6 +236,7 @@
type=Infantry Lieutenant
id=Sir Gerrick
name= _ "Sir Gerrick"
unrenamable=yes
profile=portraits/sir-gerrick.png
{IS_HERO}
x,y=14,9

View file

@ -285,6 +285,7 @@
id=Minister Hylas
profile=portraits/hylas.png
name= _ "Minister Hylas"
unrenamable=yes
{IS_HERO}
side=1
x,y=21,16

View file

@ -305,6 +305,7 @@
#endif
id=Ethiliel
name= _ "Ethiliel"
unrenamable=yes
profile=portraits/ethiliel.png
{IS_HERO}
side=1

View file

@ -61,6 +61,7 @@
type=Outlaw
id=Urza Afalas
name= _ "Urza Afalas"
unrenamable=yes
profile=portraits/urza-afalas-masked.png
{GOLD 50 70 90}

View file

@ -89,7 +89,6 @@ Yet for some reason I fear these brothers more. If Mordak were here it would be
id=Rotharik
name= _ "Rotharik"
canrecruit=yes
unrenamable=yes
facing=sw
@ -141,7 +140,6 @@ Yet for some reason I fear these brothers more. If Mordak were here it would be
id=Knago-Brek
name= _ "Knago-Brek"
type=Orcish Warrior
unrenamable=yes
x,y=19,17
ai_special=guardian
facing=se

View file

@ -89,7 +89,6 @@ But I am still troubled. I wonder... is this sense of foreboding I feel merely a
id=Tairach
name= _ "Tairach"
canrecruit=yes
unrenamable=yes
facing=sw
@ -120,7 +119,6 @@ But I am still troubled. I wonder... is this sense of foreboding I feel merely a
id=Reeve Hoban
name= _ "Reeve Hoban"
canrecruit=yes
unrenamable=yes
facing=se
[/side]

View file

@ -1091,7 +1091,7 @@
{VARIABLE shooters {ON_DIFFICULTY 1 1 2} }
{VARIABLE revenants {ON_DIFFICULTY 0 1 1} }
{PLACE_UNITS_RANDOMLY 1 4 "Revenant" "ElyssaUndead" ( _ "Gohag") ( id="Go_hag" )}
{PLACE_UNITS_RANDOMLY 1 4 "Revenant" "ElyssaUndead" ( _ "Gohag") ( id="Go'hag" )}
{PLACE_UNITS_RANDOMLY $skeletons 4 "Skeleton" "ElyssaUndead" ( _ "Undead Raider") ()}
{PLACE_UNITS_RANDOMLY $archers 4 "Skeleton Archer" "ElyssaUndead" ( _ "Undead Raider") ()}
{PLACE_UNITS_RANDOMLY $revenants 4 "Revenant" "ElyssaUndead" ( _ "Undead Raider") ()}
@ -1113,14 +1113,14 @@
#ifdef HARD
[message]
id="Go_hag"
speaker="Go'hag"
message= _ "You have defied our master for the last time. Now you shall die! And I shall personally make it slow and painful, to thank you for that scorching you gave me."
[/message]
#else
[message]
id="Go_hag"
speaker="Go'hag"
message= _ "You have defied our master for the last time. Now you shall die!"
[/message]

View file

@ -93,6 +93,7 @@ function wml_actions.select_character()
type = "Fighteress",
id = unit.id,
name = _"Lisar",
unrenamable = true,
profile = "portraits/lisar.png",
canrecruit = true,
facing = unit.facing,

View file

@ -32,6 +32,7 @@
type=Fighter
id=student
name= _"Konrad"
unrenamable=yes
profile=portraits/konrad.png
canrecruit=yes
@ -75,9 +76,11 @@
type=Elder Mage
profile=portraits/delfador.png~RIGHT()
x,y=13,6
random_traits=no
facing=nw
{IS_HERO}
[modifications]
{TRAIT_INTELLIGENT}
[object]
[effect]
apply_to=new_animation

View file

@ -29,6 +29,7 @@
type=Fighter
id=student
name= _ "Konrad"
unrenamable=yes
canrecruit=yes
facing=se

View file

@ -229,6 +229,14 @@
[/stacked_widget]
#enddef
#define GUI_WINDOW_FULLSCREEN
automatic_placement = "false"
x = 0
y = 0
width = "(screen_width)"
height = "(screen_height)"
#enddef
###############################################################################
### ###
### Macros for the normal gui. ###

View file

@ -162,7 +162,20 @@
[button]
id = "ok"
definition = "default"
label = _ "Close"
label = _ "OK"
[/button]
[/column]
[column]
border = "all"
border_size = 5
horizontal_alignment = "right"
[button]
id = "cancel"
definition = "default"
label = _ "Cancel"
[/button]
[/column]

View file

@ -8,10 +8,9 @@
description = "Gamestate inspector dialog."
[resolution]
definition = "default"
automatic_placement = "true"
vertical_placement = "top"
horizontal_placement = "left"
definition = "borderless"
{GUI_WINDOW_FULLSCREEN}
[linked_group]
id = "name"
@ -65,11 +64,12 @@
[/row]
[row] #stack-title
grow_factor = 4
grow_factor = 1
[column]
grow_factor = 7
grow_factor = 1
horizontal_grow = "true"
vertical_alignment = "top"
[grid]
[row]
[column]
@ -78,7 +78,7 @@
[grid]
[row]
[column]
grow_factor = 3
grow_factor = 1
border = "all"
border_size = 5
horizontal_grow = "true"
@ -86,6 +86,7 @@
[listbox]
id = "stuff_types_list"
definition = "default"
horizontal_scrollbar_mode = "never"
[header]
[row]
[column]
@ -140,7 +141,7 @@
[row]
[column]
grow_factor = 3
grow_factor = 1
border = "all"
border_size = 5
horizontal_grow = "false"
@ -148,6 +149,7 @@
[listbox]
id = "stuff_list"
definition = "default"
horizontal_scrollbar_mode = "never"
[header]
[row]
[column]
@ -203,9 +205,9 @@
[/column]
[column]
grow_factor = 6
grow_factor = 1
vertical_alignment = "top"
horizontal_alignment = "left"
horizontal_grow = "true"
[grid]
[row]
[column]
@ -250,7 +252,7 @@
[column]
border = "left,bottom,right"
border_size = 5
horizontal_alignment = "left"
horizontal_grow = "true"
[scroll_label]
id = "inspect"

View file

@ -725,11 +725,7 @@
description = "Lobby screen."
[resolution]
definition = "borderless"
automatic_placement = "false"
x = 0
y = 0
width = "(screen_width)"
height = "(screen_height)"
{GUI_WINDOW_FULLSCREEN}
[tooltip]
id = "tooltip_large"
[/tooltip]

View file

@ -278,11 +278,7 @@
[resolution]
definition = "title_screen"
automatic_placement = "false"
x = 0
y = 0
width = "(screen_width)"
height = "(screen_height)"
{GUI_WINDOW_FULLSCREEN}
[tooltip]
id = "tooltip_large"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View file

@ -36,6 +36,7 @@
<Add option="-fopenmp" />
<Add option="-Wno-strict-aliasing" />
<Add option="-Wno-missing-braces" />
<Add option="-Wunused" />
<Add option="-DHAVE_LIBPNG" />
<Add option="-D_WIN32_WINDOWS" />
<Add option="-D_WIN32_WINNT=0x0501" />
@ -759,6 +760,7 @@
<Unit filename="../../src/gui/widgets/grid.cpp" />
<Unit filename="../../src/gui/widgets/grid.hpp" />
<Unit filename="../../src/gui/widgets/grid_private.hpp" />
<Unit filename="../../src/gui/widgets/group.hpp" />
<Unit filename="../../src/gui/widgets/helper.cpp" />
<Unit filename="../../src/gui/widgets/helper.hpp" />
<Unit filename="../../src/gui/widgets/horizontal_scrollbar.cpp" />

View file

@ -5411,6 +5411,10 @@
RelativePath="..\..\src\gui\widgets\grid_private.hpp"
>
</File>
<File
RelativePath="..\..\src\gui\widgets\group.hpp"
>
</File>
<File
RelativePath="..\..\src\gui\widgets\helper.cpp"
>

View file

@ -1493,6 +1493,7 @@
91F4628F1C7116E30050A9C9 /* combobox.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = combobox.hpp; sourceTree = "<group>"; };
91F462921C7117400050A9C9 /* drop_down_list.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = drop_down_list.cpp; sourceTree = "<group>"; };
91F462931C7117400050A9C9 /* drop_down_list.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = drop_down_list.hpp; sourceTree = "<group>"; };
91FAC70B1C80168600DAB2C3 /* group.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = group.hpp; sourceTree = "<group>"; };
B504B94A1284C06B00261FE9 /* tips.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = tips.cpp; sourceTree = "<group>"; };
B504B94B1284C06B00261FE9 /* tips.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = tips.hpp; sourceTree = "<group>"; };
B508D13E10013BF900B12852 /* Growl.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Growl.framework; path = lib/Growl.framework; sourceTree = "<group>"; };
@ -4230,6 +4231,7 @@
B5A9BCF70ECA805A002BE442 /* grid.cpp */,
B5A9BCF80ECA805A002BE442 /* grid.hpp */,
B54AC6F70FEA9FA5006F6FBD /* grid_private.hpp */,
91FAC70B1C80168600DAB2C3 /* group.hpp */,
B5A9BCF90ECA805A002BE442 /* helper.cpp */,
B5A9BCFA0ECA805A002BE442 /* helper.hpp */,
B5795A610F05858100EB190E /* horizontal_scrollbar.cpp */,

View file

@ -217,7 +217,10 @@ void unit_creator::post_create(const map_location &loc, const unit &new_unit, bo
}
}
resources::game_events->pump().fire("unit placed", loc);
// Only fire the events if it's safe; it's not if we're in the middle of play_controller::reset_gamestate()
if (resources::lua_kernel != NULL) {
resources::game_events->pump().fire("unit placed", loc);
}
if (resources::screen!=NULL) {

View file

@ -278,7 +278,7 @@ void strategy_formulation_with_rca::switch_side()
else
this->set_side(1);
resources::tod_manager->next_turn(*resources::gamedata);
resources::tod_manager->next_turn(resources::gamedata);
DBG_AI_TESTING_SF_WITH_RCA << "switch to turn " << resources::tod_manager->turn() << std::endl;
DBG_AI_TESTING_SF_WITH_RCA << "------switch_side() end------" << std::endl;

View file

@ -83,7 +83,7 @@ editor_controller::editor_controller(const config &game_config, CVideo& video)
init_gui();
toolkit_.reset(new editor_toolkit(*gui_.get(), key_, game_config_, *context_manager_.get()));
help_manager_.reset(new help::help_manager(&game_config));
context_manager_->switch_context(0);
context_manager_->switch_context(0, true);
init_tods(game_config);
init_music(game_config);
context_manager_->get_map_context().set_starting_position_labels(gui());

View file

@ -122,10 +122,6 @@ void editor_display::draw_hex(const map_location& loc)
drawing_buffer_add(LAYER_SELECTED_HEX, loc, xpos, ypos,
image::get_texture(brush, image::SCALED_TO_HEX));
}
if (map().on_board(loc) && loc == mouseoverHex_) {
drawing_buffer_add(LAYER_MOUSEOVER_BOTTOM, loc, xpos, ypos,
image::get_texture("misc/hover-hex.png", image::SCALED_TO_HEX));
}
#else
if (map().in_selection(loc)) {
drawing_buffer_add(LAYER_FOG_SHROUD, loc, xpos, ypos,
@ -137,10 +133,6 @@ void editor_display::draw_hex(const map_location& loc)
drawing_buffer_add(LAYER_SELECTED_HEX, loc, xpos, ypos,
image::get_image(brush, image::SCALED_TO_HEX));
}
if (map().on_board(loc) && loc == mouseoverHex_) {
drawing_buffer_add(LAYER_MOUSEOVER_BOTTOM, loc, xpos, ypos,
image::get_image("misc/hover-hex.png", image::SCALED_TO_HEX));
}
#endif
}
}

View file

@ -699,7 +699,6 @@ void context_manager::generate_map_dialog()
gui2::teditor_generate_map dialog;
dialog.set_map_generators(map_generators_);
dialog.select_map_generator(last_map_generator_);
dialog.set_gui(&gui_);
dialog.show(gui_.video());
if (dialog.get_retval() == gui2::twindow::OK) {
std::string map_string;
@ -903,9 +902,7 @@ bool context_manager::check_switch_open_map(const std::string& fn)
size_t i = check_open_map(fn);
if (i < map_contexts_.size()) {
gui2::show_transient_message(gui_.video(), _("This map is already open."), fn);
if (i != static_cast<unsigned>(current_context_index_)) {
switch_context(i);
}
switch_context(i);
return true;
}
return false;
@ -997,12 +994,15 @@ void context_manager::reload_map()
refresh_all();
}
void context_manager::switch_context(const int index)
void context_manager::switch_context(const int index, const bool force)
{
if (index < 0 || static_cast<size_t>(index) >= map_contexts_.size()) {
WRN_ED << "Invalid index in switch map context: " << index << std::endl;
return;
}
if (index == current_context_index_ && !force) {
return;
}
map_context_refresher mcr(*this, *map_contexts_[index]);
current_labels = &get_map_context().get_labels();
current_context_index_ = index;

View file

@ -219,7 +219,7 @@ public:
void close_current_context();
/** Switches the context to the one under the specified index. */
void switch_context(const int index);
void switch_context(const int index, const bool force = false);
private:
/**

View file

@ -409,7 +409,7 @@ WML_HANDLER_FUNCTION(modify_turns, /*event_info*/, cfg)
if(new_turn_number_u < 1 || (new_turn_number > tod_man.number_of_turns() && tod_man.number_of_turns() != -1)) {
ERR_NG << "attempted to change current turn number to one out of range (" << new_turn_number << ")" << std::endl;
} else if(new_turn_number_u != current_turn_number) {
tod_man.set_turn_by_wml(new_turn_number_u, *resources::gamedata);
tod_man.set_turn_by_wml(new_turn_number_u, resources::gamedata);
resources::screen->new_turn();
}
}

View file

@ -613,7 +613,9 @@ void ui::layout_children(const SDL_Rect& /*rect*/)
entry_textbox_.set_width(xscale(833) - 8);
}
bool ui::user_info::operator> (const user_info& b) const {
bool ui::user_info::operator> (const user_info& b) const
{
//FIXME: to cmpare names, use translation::compare from gettext.hpp
user_info const& a = *this;
// ME always on top

View file

@ -75,6 +75,7 @@ namespace translation
void set_language(const std::string& language, const std::vector<std::string>* alternates);
void init();
int compare(const std::string& s1,const std::string& s2);
}
//#define _(String) translation::dsgettext(GETTEXT_DOMAIN,String)

View file

@ -82,7 +82,7 @@ namespace
}
generator_.use_ansi_encoding(false);
generator_.categories(bl::message_facet | bl::information_facet);
generator_.categories(bl::message_facet | bl::information_facet | bl::collation_facet);
generator_.characters(bl::char_facet);
//we cannot have current_locale_ beeing a non boost gerenerated locale since it might not suppy
//the boost::locale::info facet. as soon as we add message paths update_locale_internal might fail
@ -266,6 +266,10 @@ void set_language(const std::string& language, const std::vector<std::string>* /
LOG_G << "setting language to '" << language << "' \n";
get_manager().set_language(language);
}
int compare(const std::string& s1, const std::string& s2)
{
return std::use_facet<std::collate<char> >(get_manager().get_locale()).compare(s1.c_str(), s1.c_str() + s1.size(), s2.c_str(), s2.c_str() + s2.size());
}
void init()
{

View file

@ -175,38 +175,14 @@ void taddon_filter_options::toggle_all_displayed_types_button_callback(
}
}
void taddon_filter_options::toggle_sort_callback(ttoggle_button* active)
void taddon_filter_options::toggle_sort_callback()
{
FOREACH(const AUTO & e, sort_tgroup_)
{
ttoggle_button* const b = e.first;
if(b == NULL) {
continue;
} else if(b == active && !b->get_value()) {
b->set_value(true);
} else if(b == active) {
sort_ = e.second;
} else if(b != active && b->get_value()) {
b->set_value(false);
}
}
sort_ = sort_tgroup_.get_active_member_value();
}
void taddon_filter_options::toggle_dir_callback(ttoggle_button* active)
void taddon_filter_options::toggle_dir_callback()
{
FOREACH(const AUTO & e, dir_tgroup_)
{
ttoggle_button* const b = e.first;
if(b == NULL) {
continue;
} else if(b == active && !b->get_value()) {
b->set_value(true);
} else if(b == active) {
dir_ = e.second;
} else if(b != active && b->get_value()) {
b->set_value(false);
}
}
dir_ = dir_tgroup_.get_active_member_value();
}
void taddon_filter_options::pre_show(CVideo& /*video*/, twindow& window)
@ -251,11 +227,12 @@ void taddon_filter_options::register_sort_toggle(twindow& window,
= &find_widget<ttoggle_button>(&window, "sort_" + toggle_id, false);
b->set_value(value == sort_);
sort_tgroup_.add_member(b, value);
connect_signal_mouse_left_click(
*b,
boost::bind(&taddon_filter_options::toggle_sort_callback, this, b));
sort_tgroup_.push_back(std::make_pair(b, value));
boost::bind(&taddon_filter_options::toggle_sort_callback, this));
}
void taddon_filter_options::register_dir_toggle(twindow& window,
@ -266,11 +243,12 @@ void taddon_filter_options::register_dir_toggle(twindow& window,
= &find_widget<ttoggle_button>(&window, "sort_" + toggle_id, false);
b->set_value(value == dir_);
dir_tgroup_.add_member(b, value);
connect_signal_mouse_left_click(
*b,
boost::bind(&taddon_filter_options::toggle_dir_callback, this, b));
dir_tgroup_.push_back(std::make_pair(b, value));
boost::bind(&taddon_filter_options::toggle_dir_callback, this));
}
void taddon_filter_options::post_show(twindow& window)

View file

@ -16,6 +16,7 @@
#define GUI_DIALOGS_ADDON_FILTER_OPTIONS_HPP_INCLUDED
#include "gui/dialogs/dialog.hpp"
#include "gui/widgets/group.hpp"
#include "addon/validation.hpp"
#include "addon/state.hpp"
@ -85,8 +86,8 @@ private:
typedef std::pair<ttoggle_button*, ADDON_SORT_DIRECTION> dir_toggle;
// Dialog display state variables.
std::vector<sort_toggle> sort_tgroup_;
std::vector<dir_toggle> dir_tgroup_;
tgroup<ADDON_SORT> sort_tgroup_;
tgroup<ADDON_SORT_DIRECTION> dir_tgroup_;
void register_displayed_type_field(const std::string& field_id,
ADDON_TYPE addon_type);
@ -102,8 +103,8 @@ private:
const std::string& toggle_id,
ADDON_SORT_DIRECTION value);
void toggle_sort_callback(ttoggle_button* active);
void toggle_dir_callback(ttoggle_button* active);
void toggle_sort_callback();
void toggle_dir_callback();
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
virtual const std::string& window_id() const;

View file

@ -54,8 +54,7 @@ namespace gui2
REGISTER_DIALOG(addon_connect)
taddon_connect::taddon_connect(std::string& host_name,
const bool allow_remove,
display*)
const bool allow_remove)
: allow_remove_(allow_remove)
{
set_restore(true);

View file

@ -39,8 +39,7 @@ public:
* in-game help when requested.
*/
taddon_connect(std::string& host_name,
const bool allow_remove,
display* disp = NULL);
const bool allow_remove);
private:
/** Enable the addon remove button? */

View file

@ -38,83 +38,42 @@
namespace gui2
{
/*WIKI
* @page = GUIWindowDefinitionWML
* @order = 2_mp_alerts_options
*
* == Lobby sounds options ==
*
* A Preferences subdialog permitting to configure the sounds and notifications
* generated in response to various mp lobby / game events.
*
* @begin{table}{dialog_widgets}
*
* _label & & label & m &
* Item name. $
*
* _sound & & toggle_button & m &
* Toggles whether to play the item sound. $
*
* _notif & & toggle_button & m &
* Toggles whether to give a notification. $
*
* _lobby & & toggle_button & m &
* Toggles whether to take actions for this item when in the lobby. $
*
* @end{table}
*/
REGISTER_DIALOG(advanced_graphics_options)
const std::vector<std::string> tadvanced_graphics_options::scale_cases = boost::assign::list_of("zoom")("hex");
void tadvanced_graphics_options::setup_scale_button(const std::string & case_id, SCALING_ALGORITHM button, twindow & window )
tadvanced_graphics_options::SCALING_ALGORITHM tadvanced_graphics_options::get_scale_pref(const std::string& pref_id)
{
SCALING_ALGORITHM algo = SCALING_ALGORITHM::LINEAR;
try {
algo = SCALING_ALGORITHM::string_to_enum(preferences::get(pref_id));
} catch (bad_enum_cast &) {
preferences::set(pref_id, algo.to_string());
}
// algo is now synced with preference, and default value of linear if something went wrong
return algo;
}
void tadvanced_graphics_options::setup_scale_case(const std::string & case_id, twindow & window)
{
std::string pref_id = "scale_" + case_id;
tadvanced_graphics_options::SCALING_ALGORITHM algo = tadvanced_graphics_options::SCALING_ALGORITHM::LINEAR;
try {
algo = SCALING_ALGORITHM::string_to_enum(preferences::get(pref_id));
} catch (bad_enum_cast &) {
preferences::set(pref_id, algo.to_string());
tgroup<SCALING_ALGORITHM>& group = groups_[case_id];
for (size_t x = 0; x < SCALING_ALGORITHM::count; ++x) {
SCALING_ALGORITHM scale = SCALING_ALGORITHM::from_int(x);
ttoggle_button* button = &find_widget<ttoggle_button>(&window, pref_id + "_" + scale.to_string(), false);
group.add_member(button, scale);
}
// algo is now synced with preference, and default value of linear if something went wrong
ttoggle_button * b = &find_widget<ttoggle_button>(&window, pref_id + "_" + button.to_string(), false);
b->set_value(algo == button);
connect_signal_mouse_left_click(*b, boost::bind(&tadvanced_graphics_options::scale_button_callback, this, pref_id, button, boost::ref(window)));
group.set_member_states(get_scale_pref(pref_id));
}
void tadvanced_graphics_options::scale_button_callback(std::string pref_id, SCALING_ALGORITHM me, twindow & window)
void tadvanced_graphics_options::update_scale_case(const std::string & case_id)
{
tadvanced_graphics_options::SCALING_ALGORITHM algo = tadvanced_graphics_options::SCALING_ALGORITHM::LINEAR;
try {
algo = SCALING_ALGORITHM::string_to_enum(preferences::get(pref_id));
} catch (bad_enum_cast &) {
preferences::set(pref_id, algo.to_string());
}
if (algo != me) {
std::string pref_id = "scale_" + case_id;
SCALING_ALGORITHM new_val = groups_[case_id].get_active_member_value();
if(new_val != get_scale_pref(pref_id)) {
image::flush_cache();
}
preferences::set(pref_id, me.to_string());
for (size_t x = 0; x < SCALING_ALGORITHM::count; ++x) {
ttoggle_button * b = &find_widget<ttoggle_button>(&window, pref_id + "_" + SCALING_ALGORITHM::from_int(x).to_string(), false);
b->set_value(x == me.cast<size_t>());
}
image::update_from_preferences();
}
void tadvanced_graphics_options::setup_scale_case(const std::string & i, twindow & window)
{
for (size_t x = 0; x < SCALING_ALGORITHM::count; ++x) {
setup_scale_button(i, SCALING_ALGORITHM::from_int(x), window);
}
preferences::set(pref_id, new_val.to_string());
}
tadvanced_graphics_options::tadvanced_graphics_options()
@ -136,6 +95,12 @@ void tadvanced_graphics_options::pre_show(CVideo& /*video*/, twindow& window)
void tadvanced_graphics_options::post_show(twindow& /*window*/)
{
if(get_retval() == twindow::OK) {
BOOST_FOREACH(const std::string & i, scale_cases) {
update_scale_case(i);
}
image::update_from_preferences();
}
}
} // end namespace gui2

View file

@ -16,6 +16,7 @@
#define GUI_DIALOGS_ADVANCED_GRAPHICS_OPTIONS_HPP_INCLUDED
#include "gui/dialogs/dialog.hpp"
#include "gui/widgets/group.hpp"
#include "make_enum.hpp"
namespace gui2
@ -61,8 +62,10 @@ private:
void post_show(twindow& window);
void setup_scale_case(const std::string &, twindow &);
void setup_scale_button(const std::string &, SCALING_ALGORITHM, twindow &);
void scale_button_callback(std::string, SCALING_ALGORITHM, twindow &);
void update_scale_case(const std::string &);
SCALING_ALGORITHM get_scale_pref(const std::string& pref_id);
std::map<std::string,tgroup<SCALING_ALGORITHM> > groups_;
};
} // end namespace gui2

View file

@ -88,45 +88,29 @@ teditor_edit_side::teditor_edit_side(int side,
void teditor_edit_side::pre_show(CVideo& /*video*/, twindow& window)
{
register_radio_toggle<team::CONTROLLER>(window, "controller_human", team::CONTROLLER::HUMAN, controller_, controller_tgroup_);
register_radio_toggle<team::CONTROLLER>(window, "controller_ai", team::CONTROLLER::AI, controller_, controller_tgroup_);
register_radio_toggle<team::CONTROLLER>(window, "controller_null", team::CONTROLLER::EMPTY, controller_, controller_tgroup_);
register_radio_toggle<team::CONTROLLER>("controller_human", controller_group, team::CONTROLLER::HUMAN, controller_, window);
register_radio_toggle<team::CONTROLLER>("controller_ai", controller_group, team::CONTROLLER::AI, controller_, window);
register_radio_toggle<team::CONTROLLER>("controller_null", controller_group, team::CONTROLLER::EMPTY, controller_, window);
register_radio_toggle<team::SHARE_VISION>(window, "vision_all", team::SHARE_VISION::ALL, share_vision_, vision_tgroup_);
register_radio_toggle<team::SHARE_VISION>(window, "vision_shroud", team::SHARE_VISION::SHROUD, share_vision_, vision_tgroup_);
register_radio_toggle<team::SHARE_VISION>(window, "vision_null", team::SHARE_VISION::NONE, share_vision_, vision_tgroup_);
register_radio_toggle<team::SHARE_VISION>("vision_all", vision_group, team::SHARE_VISION::ALL, share_vision_, window);
register_radio_toggle<team::SHARE_VISION>("vision_shroud", vision_group, team::SHARE_VISION::SHROUD, share_vision_, window);
register_radio_toggle<team::SHARE_VISION>("vision_null", vision_group, team::SHARE_VISION::NONE, share_vision_, window);
}
template <typename T>
void teditor_edit_side::register_radio_toggle(twindow& window, const std::string& toggle_id, T enum_value, T& current_value, std::vector<std::pair<ttoggle_button*, T> >& dst)
void teditor_edit_side::register_radio_toggle(const std::string& toggle_id, tgroup<T>& group, const T& enum_value, T& current_value, twindow& window)
{
ttoggle_button* b = &find_widget<ttoggle_button>(
&window, toggle_id, false);
ttoggle_button& b = find_widget<ttoggle_button>(&window, toggle_id, false);
b->set_value(enum_value == current_value);
connect_signal_mouse_left_click(*b,
boost::bind(
&teditor_edit_side::toggle_radio_callback<T>, this, boost::ref(dst), boost::ref(current_value), b));
b.set_value(enum_value == current_value);
dst.push_back(std::make_pair(b, enum_value));
group.add_member(&b, enum_value);
}
template <typename C>
void teditor_edit_side::toggle_radio_callback(const std::vector<std::pair<ttoggle_button*, C> >& vec, C& value, ttoggle_button* active)
void teditor_edit_side::post_show(twindow&)
{
FOREACH(const AUTO & e, vec)
{
ttoggle_button* const b = e.first;
if(b == NULL) {
continue;
} else if(b == active && !b->get_value()) {
b->set_value(true);
} else if(b == active) {
value = e.second;
} else if(b != active && b->get_value()) {
b->set_value(false);
}
}
controller_ = controller_group.get_active_member_value();
share_vision_ = vision_group.get_active_member_value();
}
} // end namespace gui2

View file

@ -16,6 +16,7 @@
#define GUI_DIALOGS_EDITOR_EDIT_SIDE_HPP_INCLUDED
#include "gui/dialogs/dialog.hpp"
#include "gui/widgets/group.hpp"
#include "team.hpp"
namespace gui2
@ -73,22 +74,16 @@ public:
private:
void pre_show(CVideo& /*video*/, twindow& window);
void post_show(twindow& window);
template <typename T>
void register_radio_toggle(twindow& window, const std::string& toggle_id, T enum_value, T& current_value, std::vector<std::pair<ttoggle_button*, T> >& dst);
void register_radio_toggle(const std::string& toggle_id, tgroup<T>& group, const T& enum_value, T& current_value, twindow& window);
team::CONTROLLER& controller_;
tgroup<team::CONTROLLER> controller_group;
team::SHARE_VISION& share_vision_;
typedef std::pair<ttoggle_button*, team::CONTROLLER> controller_toggle;
std::vector<controller_toggle> controller_tgroup_;
typedef std::pair<ttoggle_button*, team::SHARE_VISION> vision_toggle;
std::vector<vision_toggle> vision_tgroup_;
template <typename C>
void toggle_radio_callback(const std::vector<std::pair<ttoggle_button*, C> >& vec, C& value, ttoggle_button* active);
tgroup<team::SHARE_VISION> vision_group;
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
virtual const std::string& window_id() const;

View file

@ -68,7 +68,6 @@ teditor_generate_map::teditor_generate_map()
, last_map_generator_(NULL)
, current_map_generator_(0)
, random_seed_()
, gui_(NULL)
{
}
@ -87,9 +86,9 @@ void teditor_generate_map::do_generator_selected(twindow& window)
current_map_generator_ = current;
}
void teditor_generate_map::do_settings(twindow&)
void teditor_generate_map::do_settings(twindow& window)
{
get_selected_map_generator()->user_config(gui_->video());
get_selected_map_generator()->user_config(window.video());
}
map_generator* teditor_generate_map::get_selected_map_generator()
@ -107,7 +106,6 @@ void teditor_generate_map::select_map_generator(map_generator* mg)
void teditor_generate_map::pre_show(CVideo& /*video*/, twindow& window)
{
assert(!map_generators_.empty());
assert(gui_);
register_text("seed_textbox", false, random_seed_, false);

View file

@ -48,14 +48,6 @@ public:
void select_map_generator(map_generator* mg);
void set_gui(display* d)
{
gui_ = d;
}
display* get_gui()
{
return gui_;
}
boost::optional<boost::uint32_t> get_seed();
private:
@ -82,9 +74,6 @@ private:
/** random seed integer input*/
std::string random_seed_;
/** Needed for the old-style map generator settings dialog */
display* gui_;
};
} // namespace gui2

View file

@ -248,22 +248,24 @@ void tpreferences::setup_combobox(
callback, options.second));
}
template <typename T>
void tpreferences::setup_radio_toggle(
const std::string& toggle_id,
LOBBY_JOINS enum_value,
int start_value,
std::vector<std::pair<ttoggle_button*, int> >& vec,
const T& enum_value,
const int start_value,
tgroup<T>& group,
boost::function<void(int)> callback,
twindow& window)
{
ttoggle_button& button = find_widget<ttoggle_button>(&window, toggle_id, false);
button.set_value(enum_value == start_value);
connect_signal_mouse_left_click(button, boost::bind(
&tpreferences::toggle_radio_callback,
this, boost::ref(vec), boost::ref(start_value), &button));
group.add_member(&button, enum_value);
vec.push_back(std::make_pair(&button, enum_value));
connect_signal_mouse_left_click(button, boost::bind(
&tpreferences::toggle_radio_callback<T>,
this, group, callback));
}
template <typename T>
@ -629,11 +631,11 @@ void tpreferences::initialize_members(twindow& window)
/* LOBBY JOIN NOTIFICATIONS */
setup_radio_toggle("lobby_joins_none", SHOW_NONE,
lobby_joins(), lobby_joins_, window);
lobby_joins(), lobby_joins_group, _set_lobby_joins, window);
setup_radio_toggle("lobby_joins_friends", SHOW_FRIENDS,
lobby_joins(), lobby_joins_, window);
lobby_joins(), lobby_joins_group, _set_lobby_joins, window);
setup_radio_toggle("lobby_joins_all", SHOW_ALL,
lobby_joins(), lobby_joins_, window);
lobby_joins(), lobby_joins_group, _set_lobby_joins, window);
/* FRIENDS LIST */
setup_friends_list(window);
@ -1022,25 +1024,12 @@ void tpreferences::font_scaling_slider_callback(tslider& slider)
font_scaling_ = slider.get_value();
}
template <typename T>
void tpreferences::toggle_radio_callback(
const std::vector<std::pair<ttoggle_button*, int> >& vec,
int& value,
ttoggle_button* active)
tgroup<T>& group,
boost::function<void(int)> setter)
{
FOREACH(const AUTO & e, vec)
{
ttoggle_button* const b = e.first;
if(b == NULL) {
continue;
} else if(b == active && !b->get_value()) {
b->set_value(true);
} else if(b == active) {
value = e.second;
_set_lobby_joins(value);
} else if(b != active && b->get_value()) {
b->set_value(false);
}
}
setter(group.get_active_member_value());
}
void tpreferences::on_page_select(twindow& window)

View file

@ -20,6 +20,7 @@
#include "game_preferences.hpp"
#include "make_enum.hpp"
#include "gui/dialogs/dialog.hpp"
#include "gui/widgets/group.hpp"
// This file is not named preferences.hpp in order -I conflicts with
// src/preferences.hpp.
@ -67,7 +68,7 @@ private:
void edit_friend_list_entry(tlistbox& friends, ttext_box& textbox);
void remove_friend_list_entry(tlistbox& friends_list,
void remove_friend_list_entry(tlistbox& friends_list,
ttext_box& textbox, twindow& window);
void add_tab(tlistbox& tab_bar, const std::string& label);
@ -152,17 +153,21 @@ private:
* If (at a later date) more groups need to be added, this will have to be
* generalized.
*/
tgroup<preferences::LOBBY_JOINS> lobby_joins_group;
template <typename T>
void setup_radio_toggle(
const std::string& toggle_id,
preferences::LOBBY_JOINS enum_value,
int start_value,
std::vector<std::pair<ttoggle_button*, int> >& vec,
const T& enum_value,
const int start_value,
tgroup<T>& group,
boost::function<void(int)> callback,
twindow& window);
template <typename T>
void toggle_radio_callback(
const std::vector<std::pair<ttoggle_button*, int> >& vec,
int& value,
ttoggle_button* active);
tgroup<T>& group,
boost::function<void(int)> setter);
/**
* Sets up a label that always displays the value of another widget.
@ -183,10 +188,7 @@ private:
void status_label_callback(T& parent_widget,
tcontrol& label_widget, const std::string& suffix = "");
typedef std::pair<ttoggle_button*, int> lobby_radio_toggle;
std::vector<lobby_radio_toggle> lobby_joins_;
MAKE_ENUM(ADVANCED_PREF_TYPE,
MAKE_ENUM(ADVANCED_PREF_TYPE,
(TOGGLE, "boolean")
(SLIDER, "int")
(COMBO, "combo")

View file

@ -38,21 +38,16 @@ tselect_orb_colors::tselect_orb_colors()
, show_moved_(preferences::show_moved_orb())
, show_ally_(preferences::show_allied_orb())
, show_enemy_(preferences::show_enemy_orb())
, unmoved_(preferences::unmoved_color())
, partial_(preferences::partial_color())
, moved_(preferences::moved_color())
, ally_(preferences::allied_color())
, enemy_(preferences::enemy_color())
{
}
void tselect_orb_colors::pre_show(CVideo&, twindow& window)
{
setup_orb_group("unmoved", show_unmoved_, unmoved_, window);
setup_orb_group("partial", show_partial_, partial_, window);
setup_orb_group("moved", show_moved_, moved_, window);
setup_orb_group("ally", show_ally_, ally_, window);
setup_orb_group("enemy", show_enemy_, enemy_, window);
setup_orb_group("unmoved", show_unmoved_, preferences::unmoved_color(), window);
setup_orb_group("partial", show_partial_, preferences::partial_color(), window);
setup_orb_group("moved", show_moved_, preferences::moved_color(), window);
setup_orb_group("ally", show_ally_, preferences::allied_color(), window);
setup_orb_group("enemy", show_enemy_, preferences::enemy_color(), window);
tbutton& reset = find_widget<tbutton>(&window, "orb_defaults", false);
connect_signal_mouse_left_click(reset, boost::bind(
@ -70,17 +65,18 @@ void tselect_orb_colors::post_show(twindow&)
preferences::set_show_allied_orb(show_ally_);
preferences::set_show_enemy_orb(show_enemy_);
preferences::set_unmoved_color(unmoved_);
preferences::set_partial_color(partial_);
preferences::set_moved_color(moved_);
preferences::set_allied_color(ally_);
preferences::set_enemy_color(enemy_);
preferences::set_unmoved_color(groups_["unmoved"].get_active_member_value());
preferences::set_partial_color(groups_["partial"].get_active_member_value());
preferences::set_moved_color(groups_["moved"].get_active_member_value());
preferences::set_allied_color(groups_["ally"].get_active_member_value());
preferences::set_enemy_color(groups_["enemy"].get_active_member_value());
}
}
void tselect_orb_colors::setup_orb_group(const std::string& base_id, bool& shown, std::string& color, twindow& window, bool connect)
void tselect_orb_colors::setup_orb_group(const std::string& base_id, bool& shown, const std::string& initial, twindow& window, bool connect)
{
ttoggle_button& toggle = find_widget<ttoggle_button>(&window, "orb_" + base_id + "_show", false);
std::string prefix = "orb_" + base_id + "_";
ttoggle_button& toggle = find_widget<ttoggle_button>(&window, prefix + "show", false);
toggle.set_value_bool(shown);
if(connect) {
connect_signal_mouse_left_click(toggle, boost::bind(
@ -90,44 +86,20 @@ void tselect_orb_colors::setup_orb_group(const std::string& base_id, bool& shown
));
}
tgrid& selection = find_widget<tgrid>(&window, "orb_" + base_id + "_selection", false);
std::vector<ttoggle_button*>& group = groups_[base_id];
tgrid& selection = find_widget<tgrid>(&window, prefix + "selection", false);
tgroup<std::string>& group = groups_[base_id];
using iterator::twalker_;
twalker_* iter = selection.create_walker();
while(!iter->at_end(twalker_::child)) {
twidget* next = iter->get(twalker_::child);
if(ttoggle_button* button = dynamic_cast<ttoggle_button*>(next)) {
group.push_back(button);
if(button->id().rfind("_" + color) != std::string::npos) {
button->set_value_bool(true);
} else {
button->set_value_bool(false);
}
if(connect) {
connect_signal_mouse_left_click(*button, boost::bind(
&tselect_orb_colors::handle_orb_click,
this,
button,
boost::ref(group),
boost::ref(color)
));
}
const std::string& id = button->id();
group.add_member(button, id.substr(prefix.size()));
}
iter->next(twalker_::child);
}
}
void tselect_orb_colors::handle_orb_click(ttoggle_button* clicked, const std::vector<ttoggle_button*>& group, std::string& storage)
{
int split = clicked->id().find_last_of('_');
storage = clicked->id().substr(split + 1);
FOREACH(const AUTO& button, group) {
button->set_value_bool(false);
}
clicked->set_value_bool(true);
group.set_member_states(initial);
}
void tselect_orb_colors::handle_toggle_click(bool& storage)
@ -143,17 +115,11 @@ void tselect_orb_colors::handle_reset_click(twindow& window)
show_ally_ = game_config::show_ally_orb;
show_enemy_ = game_config::show_enemy_orb;
unmoved_ = game_config::colors::unmoved_orb_color;
partial_ = game_config::colors::partial_orb_color;
moved_ = game_config::colors::moved_orb_color;
ally_ = game_config::colors::ally_orb_color;
enemy_ = game_config::colors::enemy_orb_color;
setup_orb_group("unmoved", show_unmoved_, unmoved_, window, false);
setup_orb_group("partial", show_partial_, partial_, window, false);
setup_orb_group("moved", show_moved_, moved_, window, false);
setup_orb_group("ally", show_ally_, ally_, window, false);
setup_orb_group("enemy", show_enemy_, enemy_, window, false);
setup_orb_group("unmoved", show_unmoved_, game_config::colors::unmoved_orb_color, window, false);
setup_orb_group("partial", show_partial_, game_config::colors::partial_orb_color, window, false);
setup_orb_group("moved", show_moved_, game_config::colors::moved_orb_color, window, false);
setup_orb_group("ally", show_ally_, game_config::colors::ally_orb_color, window, false);
setup_orb_group("enemy", show_enemy_, game_config::colors::enemy_orb_color, window, false);
}
}
}

View file

@ -15,6 +15,7 @@
#define GUI_DIALOGS_SELECT_ORB_COLORS_HPP_INCLUDED
#include "gui/dialogs/dialog.hpp"
#include "gui/widgets/group.hpp"
#include <map>
namespace gui2 {
@ -34,14 +35,12 @@ public:
tselect_orb_colors().show(video);
}
private:
void setup_orb_group(const std::string& base_id, bool& shown, std::string& color, twindow& window, bool connect = true);
void handle_orb_click(ttoggle_button* clicked, const std::vector<ttoggle_button*>& group, std::string& storage);
void setup_orb_group(const std::string& base_id, bool& shown, const std::string& initial, twindow& window, bool connect = true);
void handle_toggle_click(bool& storage);
void handle_reset_click(twindow& window);
bool show_unmoved_, show_partial_, show_moved_, show_ally_, show_enemy_;
std::string unmoved_, partial_, moved_, ally_, enemy_;
std::map<std::string, std::vector<ttoggle_button*> > groups_;
std::map<std::string, tgroup<std::string> > groups_;
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
virtual const std::string& window_id() const;

View file

@ -79,14 +79,12 @@ REGISTER_DIALOG(unit_attack)
tunit_attack::tunit_attack(const unit_map::iterator& attacker_itor,
const unit_map::iterator& defender_itor,
const std::vector<battle_context>& weapons,
const int best_weapon,
display* disp)
const int best_weapon)
: selected_weapon_(-1)
, attacker_itor_(attacker_itor)
, defender_itor_(defender_itor)
, weapons_(weapons)
, best_weapon_(best_weapon)
, disp_(disp)
{
}
@ -255,13 +253,9 @@ static void set_weapon_info(twindow& window,
weapon_list.select_row(best_weapon);
}
void tunit_attack::profile_button_callback(const std::string& type)
void tunit_attack::profile_button_callback(twindow& window, const std::string& type)
{
if (!disp_) {
return;
}
help::show_unit_help(disp_->video(), type);
help::show_unit_help(window.video(), type);
}
void tunit_attack::damage_calc_callback(twindow& window)
@ -277,11 +271,13 @@ void tunit_attack::pre_show(CVideo& /*video*/, twindow& window)
{
connect_signal_mouse_left_click(
find_widget<tbutton>(&window, "attacker_profile", false),
boost::bind(&tunit_attack::profile_button_callback, this, (*attacker_itor_).type_id()));
boost::bind(&tunit_attack::profile_button_callback, this, boost::ref(window),
(*attacker_itor_).type_id()));
connect_signal_mouse_left_click(
find_widget<tbutton>(&window, "defender_profile", false),
boost::bind(&tunit_attack::profile_button_callback, this, (*defender_itor_).type_id()));
boost::bind(&tunit_attack::profile_button_callback, this, boost::ref(window),
(*defender_itor_).type_id()));
connect_signal_mouse_left_click(
find_widget<tbutton>(&window, "damage_calculation", false),

View file

@ -29,8 +29,7 @@ public:
tunit_attack(const unit_map::iterator& attacker_itor,
const unit_map::iterator& defender_itor,
const std::vector<battle_context>& weapons,
const int best_weapon,
display* disp = NULL);
const int best_weapon);
/***** ***** ***** setters / getters for members ***** ****** *****/
@ -49,7 +48,7 @@ private:
/** Inherited from tdialog. */
void post_show(twindow& window);
void profile_button_callback(const std::string& type);
void profile_button_callback(twindow& window, const std::string& type);
void damage_calc_callback(twindow& window);
@ -67,8 +66,6 @@ private:
/** The best weapon, aka the one high-lighted. */
int best_weapon_;
display* disp_;
};
} // namespace gui2

View file

@ -46,26 +46,9 @@
#include <boost/bind.hpp>
namespace
{
static std::string last_chosen_type_id = "";
static unit_race::GENDER last_gender = unit_race::MALE;
/**
* Helper function for updating the male/female checkboxes.
* It's not a private member of class gui2::tunit_create so
* we don't have to expose a forward-declaration of ttoggle_button
* in the interface.
*/
void update_male_female_toggles(gui2::ttoggle_button& male,
gui2::ttoggle_button& female,
unit_race::GENDER choice)
{
male.set_value(choice == unit_race::MALE);
female.set_value(choice == unit_race::FEMALE);
}
}
namespace gui2
{
@ -99,11 +82,10 @@ namespace gui2
REGISTER_DIALOG(unit_create)
tunit_create::tunit_create(display* disp)
tunit_create::tunit_create()
: gender_(last_gender)
, choice_(last_chosen_type_id)
, last_words_()
, disp_(disp)
{
}
@ -113,6 +95,18 @@ void tunit_create::pre_show(CVideo& /*video*/, twindow& window)
= find_widget<ttoggle_button>(&window, "male_toggle", false);
ttoggle_button& female_toggle
= find_widget<ttoggle_button>(&window, "female_toggle", false);
gender_toggle.add_member(&male_toggle, unit_race::MALE);
gender_toggle.add_member(&female_toggle, unit_race::FEMALE);
gender_toggle.set_member_states(last_gender);
male_toggle.set_callback_state_change(
dialog_callback<tunit_create, &tunit_create::gender_toggle_callback>);
female_toggle.set_callback_state_change(
dialog_callback<tunit_create, &tunit_create::gender_toggle_callback>);
tlistbox& list = find_widget<tlistbox>(&window, "unit_type_list", false);
ttext_box* filter
@ -139,14 +133,6 @@ void tunit_create::pre_show(CVideo& /*video*/, twindow& window)
this,
boost::ref(window)));
male_toggle.set_callback_state_change(
dialog_callback<tunit_create, &tunit_create::gender_toggle_callback>);
female_toggle.set_callback_state_change(
dialog_callback<tunit_create, &tunit_create::gender_toggle_callback>);
update_male_female_toggles(male_toggle, female_toggle, gender_);
list.clear();
FOREACH(const AUTO & i, unit_types.types())
@ -213,8 +199,6 @@ bool tunit_create::compare_race_rev(unsigned i1, unsigned i2) const
void tunit_create::post_show(twindow& window)
{
ttoggle_button& female_toggle
= find_widget<ttoggle_button>(&window, "female_toggle", false);
tlistbox& list = find_widget<tlistbox>(&window, "unit_type_list", false);
choice_ = "";
@ -233,10 +217,8 @@ void tunit_create::post_show(twindow& window)
return;
}
last_chosen_type_id = choice_
= units_[selected_row]->id();
last_gender = gender_ = female_toggle.get_value() ? unit_race::FEMALE
: unit_race::MALE;
last_chosen_type_id = choice_ = units_[selected_row]->id();
last_gender = gender_;
}
void tunit_create::print_stats(std::stringstream& str, const int row)
@ -429,34 +411,16 @@ bool tunit_create::filter_text_changed(ttext_* textbox, const std::string& text)
void tunit_create::profile_button_callback(twindow& window)
{
if(!disp_) {
return;
}
const int selected_row
= find_widget<tlistbox>(&window, "unit_type_list", false).get_selected_row();
help::show_unit_help(disp_->video(),
help::show_unit_help(window.video(),
units_[selected_row]->id(),
units_[selected_row]->show_variations_in_help(), false);
}
void tunit_create::gender_toggle_callback(twindow& window)
void tunit_create::gender_toggle_callback(twindow&)
{
ttoggle_button& male_toggle
= find_widget<ttoggle_button>(&window, "male_toggle", false);
ttoggle_button& female_toggle
= find_widget<ttoggle_button>(&window, "female_toggle", false);
// TODO Ye olde ugly hack for the lack of radio buttons.
if(gender_ == unit_race::MALE) {
gender_ = female_toggle.get_value() ? unit_race::FEMALE
: unit_race::MALE;
} else {
gender_ = male_toggle.get_value() ? unit_race::MALE : unit_race::FEMALE;
}
update_male_female_toggles(male_toggle, female_toggle, gender_);
gender_ = gender_toggle.get_active_member_value();
}
}

View file

@ -16,6 +16,7 @@
#define GUI_DIALOGS_UNIT_CREATE_HPP_INCLUDED
#include "gui/dialogs/dialog.hpp"
#include "gui/widgets/group.hpp"
#include "gui/widgets/text.hpp"
#include "race.hpp"
#include "unit_types.hpp"
@ -31,7 +32,7 @@ namespace gui2
class tunit_create : public tdialog
{
public:
tunit_create(display* disp = NULL);
tunit_create();
/** Unit type choice from the user. */
const std::string& choice() const
@ -60,8 +61,6 @@ private:
std::vector<std::string> last_words_;
display* disp_;
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
virtual const std::string& window_id() const;
@ -83,6 +82,8 @@ private:
bool filter_text_changed(ttext_* textbox, const std::string& text);
void profile_button_callback(twindow& window);
void gender_toggle_callback(twindow& window);
tgroup<unit_race::GENDER> gender_toggle;
};
}

136
src/gui/widgets/group.hpp Normal file
View file

@ -0,0 +1,136 @@
/*
Copyright (C) 2008 - 2016 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 as published by
the Free Software Foundation; either version 2 of the License, 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_WIDGETS_GROUP_HPP_INCLUDED
#define GUI_WIDGETS_GROUP_HPP_INCLUDED
#include "gui/auxiliary/event/dispatcher.hpp"
#include "gui/widgets/selectable.hpp"
#include "gui/widgets/widget.hpp"
#include "utils/foreach.tpp"
#include <vector>
#include <boost/bind.hpp>
namespace gui2
{
template <class T>
class tgroup
{
public:
typedef typename std::pair<tselectable_*, T> group_type;
typedef typename std::vector<group_type> group_list;
typedef typename group_list::iterator group_iterator;
typedef typename group_list::const_iterator group_iterator_const;
/**
* Adds a widget/value pair to the group vector. A callback is set
* that sets all members' toggle states to false when clicked. This
* happens before individual widget handlers fire, meaning that the
* clicked widget will remain the only one selected.
*/
void add_member(tselectable_* widget, const T& value)
{
members_.push_back(std::make_pair(widget, value));
dynamic_cast<twidget*>(widget)->connect_signal<event::LEFT_BUTTON_CLICK>(boost::bind(
&tgroup::group_operator, this), event::tdispatcher::front_child);
}
/**
* Removes a member from the group vector.
*/
void remove_member(tselectable_* widget)
{
#ifdef HAVE_CXX11
members_.erase(std::find_if(members_.begin(), members_.end(),
[&widget](const group_type& member){ return member.first == widget; }));
#else
for(group_iterator iter = members_.end() - 1; iter >= members_.begin(); iter--) {
if(iter->first == widget) {
iter = members_.erase(iter);
}
}
#endif
}
/**
* Clears the entire group of members.
*/
void clear()
{
members_.clear();
}
/**
* Group member getters
*/
std::pair<group_iterator, group_iterator> members()
{
return std::make_pair(members_.begin(), members_.end());
}
std::pair<group_iterator_const, group_iterator_const> members() const
{
return std::make_pair(members_.begin(), members_.end());
}
/**
* The default actions to take when clicking on one of the widgets
* in the group.
*/
void group_operator()
{
FOREACH(AUTO& member, members())
{
member.first->set_value(false);
}
}
/**
* Returns the value paired with the currently activiely toggled member
* of the group.
*/
T get_active_member_value()
{
FOREACH(AUTO& member, members())
{
if(member.first->get_value_bool()) {
return member.second;
}
}
return T();
}
/**
* Sets the toggle values for all widgets besides the one associated
* with the specified value to false.
*/
void set_member_states(const T& value)
{
FOREACH(AUTO& member, members())
{
member.first->set_value(member.second == value);
}
}
private:
group_list members_;
};
} // namespace gui2
#endif

View file

@ -668,8 +668,6 @@ void command_executor_default::lua_console()
{
if (get_display().in_game()) {
gui2::tlua_interpreter::display(get_video(), gui2::tlua_interpreter::GAME);
//WRN_G << "caution: attempting to interface console with game lua kernel when we are not in game...\n";
gui2::tlua_interpreter::display(get_video(), gui2::tlua_interpreter::APP);
} else {
command_executor::lua_console();
}

View file

@ -1278,16 +1278,17 @@ bool save_image(const surface & surf, const std::string & filename)
bool update_from_preferences()
{
gui2::tadvanced_graphics_options::SCALING_ALGORITHM algo = gui2::tadvanced_graphics_options::SCALING_ALGORITHM::LINEAR;
typedef gui2::tadvanced_graphics_options::SCALING_ALGORITHM SCALING_ALGORITHM;
SCALING_ALGORITHM algo = SCALING_ALGORITHM::LINEAR;
try {
algo = gui2::tadvanced_graphics_options::SCALING_ALGORITHM::string_to_enum(preferences::get("scale_hex"));
algo = SCALING_ALGORITHM::string_to_enum(preferences::get("scale_hex"));
} catch (bad_enum_cast &) {}
scale_to_hex_func = select_algorithm(algo);
algo = gui2::tadvanced_graphics_options::SCALING_ALGORITHM::LINEAR;
algo = SCALING_ALGORITHM::LINEAR;
try {
algo = gui2::tadvanced_graphics_options::SCALING_ALGORITHM::string_to_enum(preferences::get("scale_zoom"));
algo = SCALING_ALGORITHM::string_to_enum(preferences::get("scale_zoom"));
} catch (bad_enum_cast &) {}
scale_to_zoom_func = select_algorithm(algo);

View file

@ -211,7 +211,8 @@ static int l_strcmp (const TString *ls, const TString *rs) {
const char *r = getstr(rs);
size_t lr = rs->tsv.len;
for (;;) {
int temp = strcoll(l, r);
//TODO: simplify this by using memcmp?
int temp = strcmp(l, r);
if (temp != 0) return temp;
else { /* strings are equal up to a `\0' */
size_t len = strlen(l); /* index of first `\0' in both strings */

View file

@ -927,7 +927,7 @@ namespace { // Helpers for create_unit()
// The unit creation dialog makes sure unit types
// are properly cached.
//
gui2::tunit_create create_dlg(&gui);
gui2::tunit_create create_dlg;
create_dlg.show(gui.video());
if(create_dlg.no_choice()) {

View file

@ -978,8 +978,7 @@ int mouse_handler::show_attack_dialog(const map_location& attacker_loc, const ma
attacker
, defender
, bc_vector
, best
, gui_);
, best);
dlg.show(gui_->video());

View file

@ -1234,7 +1234,7 @@ void play_controller::play_turn()
void play_controller::check_time_over()
{
const bool time_left = gamestate().tod_manager_.next_turn(gamestate().gamedata_);
const bool time_left = gamestate().tod_manager_.next_turn(&gamestate().gamedata_);
if(!time_left) {
LOG_NG << "firing time over event...\n";

View file

@ -23,6 +23,7 @@
#include "map_location.hpp"
#include <deque>
#include <iterator>
#include <map>
#include <set>
class replay_recorder_base;

View file

@ -31,6 +31,7 @@
#include "tstring.hpp" // for t_string
#include "variable.hpp" // for vconfig
#include "log.hpp"
#include "gettext.hpp"
#include <boost/foreach.hpp>
#include <cstring>
@ -138,6 +139,30 @@ static int impl_tstring_collect(lua_State *L)
return 0;
}
static int impl_tstring_lt(lua_State *L)
{
t_string *t1 = static_cast<t_string *>(lua_touserdata(L, 1));
t_string *t2 = static_cast<t_string *>(lua_touserdata(L, 2));
lua_pushboolean(L, translation::compare(t1->get(), t2->get()) < 0);
return 1;
}
static int impl_tstring_le(lua_State *L)
{
t_string *t1 = static_cast<t_string *>(lua_touserdata(L, 1));
t_string *t2 = static_cast<t_string *>(lua_touserdata(L, 2));
lua_pushboolean(L, translation::compare(t1->get(), t2->get()) < 1);
return 1;
}
static int impl_tstring_eq(lua_State *L)
{
t_string *t1 = static_cast<t_string *>(lua_touserdata(L, 1));
t_string *t2 = static_cast<t_string *>(lua_touserdata(L, 2));
lua_pushboolean(L, translation::compare(t1->get(), t2->get()) == 0);
return 1;
}
/**
* Converts a t_string object to a string (__tostring metamethod);
* that is, performs a translation.
@ -376,6 +401,9 @@ std::string register_tstring_metatable(lua_State *L)
{ "__concat", &impl_tstring_concat},
{ "__gc", &impl_tstring_collect},
{ "__tostring", &impl_tstring_tostring},
{ "__lt", &impl_tstring_lt},
{ "__le", &impl_tstring_le},
{ "__eq", &impl_tstring_eq},
{ NULL, NULL }
};
luaL_setfuncs(L, callbacks, 0);

View file

@ -549,7 +549,7 @@ SYNCED_COMMAND_HANDLER_FUNCTION(debug_turn, child, use_undo, /*show*/, /*error_h
debug_notification(":turn debug command was used during turn of $player");
resources::tod_manager->set_turn(child["turn"].to_int(1), *resources::gamedata);
resources::tod_manager->set_turn(child["turn"].to_int(1), resources::gamedata);
resources::screen->new_turn();
resources::screen->redraw_everything();

View file

@ -874,9 +874,6 @@ struct twrapper<gui2::teditor_generate_map>
}
result->set_map_generators(map_generators);
result->set_gui(
static_cast<display*>(&test_utils::get_fake_display(-1, -1)));
return result;
}
};

View file

@ -410,7 +410,7 @@ void tod_manager::set_number_of_turns_by_wml(int num)
update_server_information();
}
void tod_manager::set_turn(const int num, boost::optional<game_data &> vars, const bool increase_limit_if_needed)
void tod_manager::set_turn(const int num, game_data* vars, const bool increase_limit_if_needed)
{
const int new_turn = std::max<int>(num, 1);
LOG_NG << "changing current turn number from " << turn_ << " to " << new_turn << '\n';
@ -425,7 +425,7 @@ void tod_manager::set_turn(const int num, boost::optional<game_data &> vars, con
vars->get_variable("turn_number") = new_turn;
}
void tod_manager::set_turn_by_wml(const int num, boost::optional<game_data &> vars, const bool increase_limit_if_needed)
void tod_manager::set_turn_by_wml(const int num, game_data* vars, const bool increase_limit_if_needed)
{
set_turn(num, vars, increase_limit_if_needed);
update_server_information();
@ -455,7 +455,7 @@ int tod_manager::calculate_current_time(
return new_current_time;
}
bool tod_manager::next_turn(boost::optional<game_data&> vars)
bool tod_manager::next_turn(game_data* vars)
{
set_turn(turn_ + 1, vars, false);
has_turn_event_fired_ = false;

View file

@ -163,16 +163,16 @@ class tod_manager : public savegame::savegame_config
void set_number_of_turns_by_wml(int num);
/** Dynamically change the current turn number. */
void set_turn(const int num, boost::optional<game_data&> vars = boost::none, const bool increase_limit_if_needed = true);
void set_turn(const int num, game_data* vars = NULL, const bool increase_limit_if_needed = true);
/** Dynamically change the current turn number. */
void set_turn_by_wml(const int num, boost::optional<game_data&> vars = boost::none, const bool increase_limit_if_needed = true);
void set_turn_by_wml(const int num, game_data* vars = NULL, const bool increase_limit_if_needed = true);
/**
* Function to move to the next turn.
*
* @returns True if time has not expired.
*/
bool next_turn(boost::optional<game_data&> vars);
bool next_turn(game_data* vars);
/**
* Function to check the end of turns.