Add 2 commands in the editor:

"update transitions"(key b) and "delay transitions update" (key ctrl+t)
This commit is contained in:
Ali El Gariani 2007-04-24 19:56:24 +00:00
parent cd185cf70f
commit a559247f43
5 changed files with 72 additions and 6 deletions

View file

@ -219,6 +219,23 @@ name=editor
alt=no
shift=no
[/hotkey]
[hotkey]
command="editupdate"
key="b"
cmd=no
alt=no
shift=no
[/hotkey]
[hotkey]
command="editautoupdate"
key="t"
cmd=yes
alt=no
shift=no
[/hotkey]
[hotkey]
command="changelanguage"
@ -437,6 +454,22 @@ name=editor
shift=no
[/hotkey]
[hotkey]
command="editupdate"
key="b"
ctrl=no
alt=no
shift=no
[/hotkey]
[hotkey]
command="editautoupdate"
key="t"
ctrl=yes
alt=no
shift=no
[/hotkey]
[hotkey]
command="changelanguage"
key="l"
@ -469,14 +502,14 @@ height=600
[menu]
title=_"Edit"
image=lite
items=undo,redo,editcut,editcopy,editpaste,editselectall,editfillselection,editresize,editflip,editrefresh
items=undo,redo,editcut,editcopy,editpaste,editselectall,editfillselection,editresize,editflip,editrefresh,editupdate,
rect=107,1,207,22
[/menu]
[menu]
title=_"Settings"
image=lite
items=changelanguage,preferences
items=changelanguage,preferences,editautoupdate
rect=211,1,311,22
[/menu]

View file

@ -170,7 +170,7 @@ int map_editor::old_brush_size_;
map_editor::map_editor(display &gui, editormap &map, config &theme, config &game_config)
: gui_(gui), map_(map), abort_(DONT_ABORT),
theme_(theme), game_config_(game_config), map_dirty_(false), l_button_palette_dirty_(true),
theme_(theme), game_config_(game_config), map_dirty_(false), auto_update_(true), l_button_palette_dirty_(true),
everything_dirty_(false), palette_(gui, size_specs_, map, game_config), brush_(gui, size_specs_),
l_button_held_func_(NONE), tooltip_manager_(gui_.video()), floating_label_manager_(),
mouse_moved_(false),
@ -261,6 +261,10 @@ void map_editor::load_tooltips()
text = _("Resize the map");
else if(menu_items.back() == "editflip")
text = _("Flip map");
else if(menu_items.back() == "editupdate")
text = _("Update transitions");
else if(menu_items.back() == "editautoupdate")
text = _("Delay transitions update");
}
if(text != "")
@ -738,6 +742,20 @@ void map_editor::edit_refresh() {
redraw_everything();
}
void map_editor::edit_update() {
if (map_dirty_) {
map_dirty_ = false;
gui_.rebuild_all();
gui_.invalidate_all();
recalculate_starting_pos_labels();
gui_.recalculate_minimap();
}
}
void map_editor::edit_auto_update() {
auto_update_ = !auto_update_;
}
void map_editor::insert_selection_in_clipboard() {
if (selected_hexes_.empty()) {
return;
@ -792,6 +810,8 @@ bool map_editor::can_execute_command(hotkey::HOTKEY_COMMAND command, int) const
case hotkey::HOTKEY_EDIT_SELECT_ALL:
case hotkey::HOTKEY_EDIT_DRAW:
case hotkey::HOTKEY_EDIT_REFRESH:
case hotkey::HOTKEY_EDIT_UPDATE:
case hotkey::HOTKEY_EDIT_AUTO_UPDATE:
case hotkey::HOTKEY_LANGUAGE:
return true;
default:
@ -1529,7 +1549,7 @@ void map_editor::main_loop() {
// When the map has changed, wait until the left mouse button is
// not held down and then update the minimap and the starting
// position labels.
if (map_dirty_) {
if (map_dirty_ && auto_update_) {
if (!l_button_down && !r_button_down) {
map_dirty_ = false;
gui_.rebuild_all();

View file

@ -125,6 +125,8 @@ public:
virtual void edit_select_all();
virtual void edit_draw();
virtual void edit_refresh();
virtual void edit_update();
virtual void edit_auto_update();
void perform_flood_fill();
void perform_paste();
@ -320,8 +322,9 @@ private:
gamemap::location selected_hex_;
// When map_dirty_ is true, schedule redraw of the minimap and
// perform some updates like recalculating labels of starting
// positions.
// positions. But only it the option auto_update is enabled
bool map_dirty_;
bool auto_update_;
bool l_button_palette_dirty_;
bool everything_dirty_;
terrain_palette palette_;

View file

@ -112,6 +112,8 @@ const struct {
{ hotkey::HOTKEY_EDIT_SELECT_ALL, "editselectall", N_("Select All"),true },
{ hotkey::HOTKEY_EDIT_DRAW, "editdraw", N_("Draw Terrain"),true },
{ hotkey::HOTKEY_EDIT_REFRESH, "editrefresh", N_("Refresh Image Cache"), true },
{ hotkey::HOTKEY_EDIT_AUTO_UPDATE, "editautoupdate", N_("Delay transitions updates"), true },
{ hotkey::HOTKEY_EDIT_UPDATE, "editupdate", N_("Update transitions"), true },
{ hotkey::HOTKEY_DELAY_SHROUD, "delayshroud", N_("Delay Shroud Updates"), false },
{ hotkey::HOTKEY_UPDATE_SHROUD, "updateshroud", N_("Update Shroud Now"), false },
@ -672,6 +674,12 @@ bool command_executor::execute_command(HOTKEY_COMMAND command, int index)
case HOTKEY_EDIT_REFRESH:
edit_refresh();
break;
case HOTKEY_EDIT_UPDATE:
edit_update();
break;
case HOTKEY_EDIT_AUTO_UPDATE:
edit_auto_update();
break;
case HOTKEY_LANGUAGE:
change_language();
break;

View file

@ -54,7 +54,7 @@ enum HOTKEY_COMMAND {
HOTKEY_EDIT_FILL_SELECTION, HOTKEY_EDIT_CUT, HOTKEY_EDIT_COPY,
HOTKEY_EDIT_PASTE, HOTKEY_EDIT_REVERT, HOTKEY_EDIT_RESIZE,
HOTKEY_EDIT_FLIP, HOTKEY_EDIT_SELECT_ALL, HOTKEY_EDIT_DRAW,
HOTKEY_EDIT_REFRESH,
HOTKEY_EDIT_REFRESH, HOTKEY_EDIT_UPDATE, HOTKEY_EDIT_AUTO_UPDATE,
//misc.
HOTKEY_USER_CMD,
@ -216,6 +216,8 @@ public:
virtual void edit_select_all() {}
virtual void edit_draw() {}
virtual void edit_refresh() {}
virtual void edit_update() {}
virtual void edit_auto_update() {}
//Gets the action's image (if any). Displayed left of the action text in menus.
virtual std::string get_action_image(hotkey::HOTKEY_COMMAND /*command*/, int /*index*/) const { return ""; }