add sample wml menu items to scenario-test

add themes support

fix minor bugs
This commit is contained in:
Patrick Parker 2007-03-27 03:52:59 +00:00
parent c4eb0633ad
commit 17fad43a69
7 changed files with 57 additions and 13 deletions

View file

@ -487,5 +487,45 @@ _s, _s, _s, _s, Aa, Aa, _s, _s, _s, _s
[/rule]
[/terrain_mask]
[/event]
[event]
name=start
[set_menu_item]
id=test1
description="Summon Troll"
[show_if]
[not]
[have_unit]
x,y=$x1,$y1
[/have_unit]
[/not]
[/show_if]
[location_filter]
[/location_filter]
[command]
{UNIT (Troll) (MagicTroll) ( "Magic Troll") $side_number $x1 $y1}
[sound]
name=magic-holy-miss-3.ogg
[/sound]
[/command]
[/set_menu_item]
[set_menu_item]
id=test2
image="buttons/group_all.png"
description="Dismiss Troll"
[show_if]
[have_unit]
x,y=$x1,$y1
type=Troll
side=$side_number
[/have_unit]
[/show_if]
[command]
[kill]
x,y=$x1,$y1
animate=yes
[/kill]
[/command]
[/set_menu_item]
[/event]
[/test]

View file

@ -98,7 +98,7 @@ height=768
[menu]
is_context_menu=true
items=undo,redo,describeunit,renameunit,createunit,changeside,labelteamterrain,labelterrain,clearlabels,speak,continue,recruit,recall,delayshroud,updateshroud,cycle,endturn
items=wml,undo,redo,describeunit,renameunit,createunit,changeside,labelteamterrain,labelterrain,clearlabels,speak,continue,recruit,recall,delayshroud,updateshroud,cycle,endturn
[/menu]
[mini_map]
id=mini-map

View file

@ -119,7 +119,7 @@ height=768
[menu]
is_context_menu=true
items=undo,redo,describeunit,renameunit,createunit,changeside,labelteamterrain,labelterrain,clearlabels,speak,continue,recruit,recall,delayshroud,updateshroud,cycle,endturn
items=wml,undo,redo,describeunit,renameunit,createunit,changeside,labelteamterrain,labelterrain,clearlabels,speak,continue,recruit,recall,delayshroud,updateshroud,cycle,endturn
[/menu]
[menu]

View file

@ -89,7 +89,7 @@ height=768
[menu]
is_context_menu=true
items=undo,redo,describeunit,renameunit,createunit,changeside,labelteamterrain,labelterrain,clearlabels,speak,continue,recruit,recall,delayshroud,updateshroud,cycle,endturn
items=wml,undo,redo,describeunit,renameunit,createunit,changeside,labelteamterrain,labelterrain,clearlabels,speak,continue,recruit,recall,delayshroud,updateshroud,cycle,endturn
[/menu]
[mini_map]
id=mini-map

View file

@ -1742,11 +1742,13 @@ bool event_handler::handle_event_command(const queued_event& event_info,
const bool no_current_handler = mref->command.empty();
mref->command = cfg.child("command").get_config();
if(no_current_handler) {
mref->command["name"] = mref->name;
mref->command["first_time_only"] = "no";
event_handler new_handler(mref->command);
events_map.insert(std::pair<std::string,event_handler>(
new_handler.name(), new_handler));
if(!mref->command.empty()) {
mref->command["name"] = mref->name;
mref->command["first_time_only"] = "no";
event_handler new_handler(mref->command);
events_map.insert(std::pair<std::string,event_handler>(
new_handler.name(), new_handler));
}
} else if(mref->command.empty()) {
mref->command.add_child("allow_undo");
}

View file

@ -809,7 +809,7 @@ std::vector<std::string> command_executor::get_menu_images(const std::vector<std
bool has_image = false;
for(int i = 0; i < items.size(); ++i) {
std::string &item = items[i];
std::string const& item = items[i];
const hotkey::hotkey_item hk = hotkey::get_hotkey(item);
std::stringstream str;
@ -821,7 +821,7 @@ std::vector<std::string> command_executor::get_menu_images(const std::vector<std
}
if (hk.get_id() == hotkey::HOTKEY_NULL) {
str << utils::strip(item) << COLUMN_SEPARATOR;
str << item.substr(0, item.find_last_not_of(' ') + 1) << COLUMN_SEPARATOR;
} else {
str << hk.get_description() << COLUMN_SEPARATOR << hk.get_name();
}

View file

@ -868,9 +868,11 @@ bool play_controller::in_context_menu(hotkey::HOTKEY_COMMAND command) const
std::string play_controller::get_action_image(hotkey::HOTKEY_COMMAND command, int index) const
{
wml_menu_item* const& wmi = wml_commands_[index];
if(wmi != NULL) {
return wmi->image.empty() ? game_config::wml_menu_image : wmi->image;
if(index < wml_commands_.size()) {
wml_menu_item* const& wmi = wml_commands_[index];
if(wmi != NULL) {
return wmi->image.empty() ? game_config::wml_menu_image : wmi->image;
}
}
return command_executor::get_action_image(command, index);
}