editor: don't switch contexts if attempting to switch to current context
This extends ae305e9cc7
to add context switching
This commit is contained in:
parent
2e36ed230f
commit
2ee1cf3cc0
3 changed files with 7 additions and 6 deletions
|
@ -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());
|
||||
|
|
|
@ -901,9 +901,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;
|
||||
|
@ -995,12 +993,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;
|
||||
|
|
|
@ -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:
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue