Skip to content

Commit

Permalink
editor: don't switch contexts if attempting to switch to current context
Browse files Browse the repository at this point in the history
This extends ae305e9 to add context switching
  • Loading branch information
Vultraz committed Feb 27, 2016
1 parent 2e36ed2 commit 2ee1cf3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/editor/controller/editor_controller.cpp
Expand Up @@ -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());
Expand Down
9 changes: 5 additions & 4 deletions src/editor/map/context_manager.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/editor/map/context_manager.hpp
Expand Up @@ -219,7 +219,7 @@ class context_manager {
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:
/**
Expand Down

1 comment on commit 2ee1cf3

@Vultraz
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commit message is supposed to say 'all context switching'.

Please sign in to comment.