Map editor code cleanups.
This commit is contained in:
parent
68a7ea1bc4
commit
1f1437b8b5
12 changed files with 211 additions and 159 deletions
|
@ -20,6 +20,8 @@
|
|||
#include "editor/action/action.hpp"
|
||||
#include "editor_controller.hpp"
|
||||
|
||||
#include "editor/palette/terrain_palettes.hpp"
|
||||
|
||||
#include "editor/action/mouse/mouse_action.hpp"
|
||||
|
||||
#include "editor_preferences.hpp"
|
||||
|
@ -37,8 +39,6 @@
|
|||
#include "../rng.hpp"
|
||||
#include "../sound.hpp"
|
||||
|
||||
#include "wml_separators.hpp"
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
namespace {
|
||||
|
@ -63,7 +63,6 @@ editor_controller::editor_controller(const config &game_config, CVideo& video)
|
|||
, floating_label_manager_(NULL)
|
||||
, do_quit_(false)
|
||||
, quit_mode_(EXIT_ERROR)
|
||||
, clipboard_()
|
||||
{
|
||||
init_gui();
|
||||
toolkit_.reset(new editor_toolkit(*gui_.get(), key_, game_config_));
|
||||
|
@ -86,8 +85,7 @@ editor_controller::editor_controller(const config &game_config, CVideo& video)
|
|||
}*/
|
||||
|
||||
gui().redraw_everything();
|
||||
//TODO
|
||||
//events::raise_draw_event();
|
||||
events::raise_draw_event();
|
||||
/* TODO enable if you can say what the purpose of the code is.
|
||||
if (default_tool_menu != NULL) {
|
||||
const SDL_Rect& menu_loc = default_tool_menu->location(get_display().screen_area());
|
||||
|
@ -260,7 +258,7 @@ bool editor_controller::can_execute_command(hotkey::HOTKEY_COMMAND command, int
|
|||
case HOTKEY_EDITOR_MAP_SAVE_AS:
|
||||
case HOTKEY_EDITOR_BRUSH_NEXT:
|
||||
case HOTKEY_EDITOR_TOOL_NEXT:
|
||||
case HOTKEY_EDITOR_TERRAIN_PALETTE_SWAP:
|
||||
case HOTKEY_EDITOR_PALETTE_ITEM_SWAP:
|
||||
return true; //editor hotkeys we can always do
|
||||
case HOTKEY_EDITOR_MAP_SAVE:
|
||||
case HOTKEY_EDITOR_MAP_SAVE_ALL:
|
||||
|
@ -288,12 +286,12 @@ bool editor_controller::can_execute_command(hotkey::HOTKEY_COMMAND command, int
|
|||
case HOTKEY_EDITOR_SELECTION_GENERATE:
|
||||
return false; //not implemented
|
||||
case HOTKEY_EDITOR_PASTE:
|
||||
return !clipboard_.empty();
|
||||
return !context_manager_->clipboard_empty();
|
||||
case HOTKEY_EDITOR_CLIPBOARD_ROTATE_CW:
|
||||
case HOTKEY_EDITOR_CLIPBOARD_ROTATE_CCW:
|
||||
case HOTKEY_EDITOR_CLIPBOARD_FLIP_HORIZONTAL:
|
||||
case HOTKEY_EDITOR_CLIPBOARD_FLIP_VERTICAL:
|
||||
return !clipboard_.empty();
|
||||
return !context_manager_->clipboard_empty();
|
||||
case HOTKEY_EDITOR_SELECT_ALL:
|
||||
case HOTKEY_EDITOR_SELECT_INVERSE:
|
||||
case HOTKEY_EDITOR_SELECT_NONE:
|
||||
|
@ -333,7 +331,7 @@ hotkey::ACTION_STATE editor_controller::get_action_state(hotkey::HOTKEY_COMMAND
|
|||
case HOTKEY_NULL:
|
||||
switch (active_menu_) {
|
||||
case editor::MAP:
|
||||
return index == context_manager_->current_context_index_ ? ACTION_ON : ACTION_OFF;
|
||||
return index == context_manager_->current_context_index() ? ACTION_ON : ACTION_OFF;
|
||||
case editor::PALETTE:
|
||||
return ACTION_STATELESS;
|
||||
case editor::AREA:
|
||||
|
@ -363,7 +361,7 @@ bool editor_controller::execute_command(hotkey::HOTKEY_COMMAND command, int inde
|
|||
}
|
||||
return false;
|
||||
case PALETTE:
|
||||
toolkit_->palette_manager_->set_group(index);
|
||||
toolkit_->get_palette_manager()->set_group(index);
|
||||
return true;
|
||||
case SIDE:
|
||||
//TODO
|
||||
|
@ -375,10 +373,10 @@ bool editor_controller::execute_command(hotkey::HOTKEY_COMMAND command, int inde
|
|||
case HOTKEY_EDITOR_PALETTE_GROUPS:
|
||||
return true;
|
||||
case HOTKEY_EDITOR_PALETTE_UPSCROLL:
|
||||
toolkit_->palette_manager_->scroll_up();
|
||||
toolkit_->get_palette_manager()->scroll_up();
|
||||
return true;
|
||||
case HOTKEY_EDITOR_PALETTE_DOWNSCROLL:
|
||||
toolkit_->palette_manager_->scroll_down();
|
||||
toolkit_->get_palette_manager()->scroll_down();
|
||||
return true;
|
||||
case HOTKEY_QUIT_GAME:
|
||||
quit_confirm(EXIT_NORMAL);
|
||||
|
@ -394,9 +392,8 @@ bool editor_controller::execute_command(hotkey::HOTKEY_COMMAND command, int inde
|
|||
case HOTKEY_EDITOR_SETTINGS:
|
||||
editor_settings_dialog();
|
||||
return true;
|
||||
//TODO rename that hotkey
|
||||
case HOTKEY_EDITOR_TERRAIN_PALETTE_SWAP:
|
||||
toolkit_->palette_manager_->active_palette().swap();
|
||||
case HOTKEY_EDITOR_PALETTE_ITEM_SWAP:
|
||||
toolkit_->get_palette_manager()->active_palette().swap();
|
||||
toolkit_->set_mouseover_overlay();
|
||||
return true;
|
||||
case HOTKEY_EDITOR_PARTIAL_UNDO:
|
||||
|
@ -419,19 +416,19 @@ bool editor_controller::execute_command(hotkey::HOTKEY_COMMAND command, int inde
|
|||
toolkit_->hotkey_set_mouse_action(command);
|
||||
return true;
|
||||
case HOTKEY_EDITOR_CLIPBOARD_ROTATE_CW:
|
||||
clipboard_.rotate_60_cw();
|
||||
context_manager_->get_clipboard().rotate_60_cw();
|
||||
toolkit_->update_mouse_action_highlights();
|
||||
return true;
|
||||
case HOTKEY_EDITOR_CLIPBOARD_ROTATE_CCW:
|
||||
clipboard_.rotate_60_ccw();
|
||||
context_manager_->get_clipboard().rotate_60_ccw();
|
||||
toolkit_->update_mouse_action_highlights();
|
||||
return true;
|
||||
case HOTKEY_EDITOR_CLIPBOARD_FLIP_HORIZONTAL:
|
||||
clipboard_.flip_horizontal();
|
||||
context_manager_->get_clipboard().flip_horizontal();
|
||||
toolkit_->update_mouse_action_highlights();
|
||||
return true;
|
||||
case HOTKEY_EDITOR_CLIPBOARD_FLIP_VERTICAL:
|
||||
clipboard_.flip_vertical();
|
||||
context_manager_->get_clipboard().flip_vertical();
|
||||
toolkit_->update_mouse_action_highlights();
|
||||
return true;
|
||||
case HOTKEY_EDITOR_BRUSH_NEXT:
|
||||
|
@ -459,7 +456,7 @@ bool editor_controller::execute_command(hotkey::HOTKEY_COMMAND command, int inde
|
|||
return true;
|
||||
case HOTKEY_EDITOR_SELECTION_FILL:
|
||||
//TODO
|
||||
//fill_selection();
|
||||
context_manager_->fill_selection();
|
||||
return true;
|
||||
case HOTKEY_EDITOR_SELECTION_RANDOMIZE:
|
||||
context_manager_->perform_refresh(editor_action_shuffle_area(
|
||||
|
@ -499,13 +496,9 @@ bool editor_controller::execute_command(hotkey::HOTKEY_COMMAND command, int inde
|
|||
context_manager_->resize_map_dialog();
|
||||
return true;
|
||||
case HOTKEY_EDITOR_AUTO_UPDATE_TRANSITIONS:
|
||||
//TODO move to context_manager and make the member privat
|
||||
context_manager_->auto_update_transitions_ = (context_manager_->auto_update_transitions_ + 1)
|
||||
% preferences::editor::TransitionUpdateMode::count;
|
||||
preferences::editor::set_auto_update_transitions(context_manager_->auto_update_transitions_);
|
||||
if (context_manager_->auto_update_transitions_ != preferences::editor::TransitionUpdateMode::on) {
|
||||
if (context_manager_->toggle_update_transitions())
|
||||
return true;
|
||||
} // else intentionally fall through
|
||||
// else intentionally fall through
|
||||
case HOTKEY_EDITOR_UPDATE_TRANSITIONS:
|
||||
context_manager_->refresh_all();
|
||||
return true;
|
||||
|
@ -530,35 +523,7 @@ bool editor_controller::execute_command(hotkey::HOTKEY_COMMAND command, int inde
|
|||
}
|
||||
}
|
||||
|
||||
//TODO move to the palette
|
||||
void editor_controller::expand_palette_groups_menu(std::vector<std::string>& items)
|
||||
{
|
||||
active_menu_ = editor::PALETTE;
|
||||
for (unsigned int i = 0; i < items.size(); ++i) {
|
||||
if (items[i] == "editor-palette-groups") {
|
||||
items.erase(items.begin() + i);
|
||||
|
||||
std::vector<std::string> groups;
|
||||
const std::vector<item_group>& item_groups = toolkit_->get_mouse_action()->get_palette().get_groups();
|
||||
|
||||
for (size_t mci = 0; mci < item_groups.size(); ++mci) {
|
||||
std::string groupname = item_groups[mci].name;
|
||||
if (groupname.empty()) {
|
||||
groupname = _("(Unknown Group)");
|
||||
}
|
||||
std::string img = item_groups[mci].icon;
|
||||
std::stringstream str;
|
||||
//TODO
|
||||
//std::string postfix = ".png"; //(toolkit_->active_group_index() == mci) ? "-pressed.png" : ".png";
|
||||
//str << IMAGE_PREFIX << "buttons/" << img << postfix << COLUMN_SEPARATOR << groupname;
|
||||
str << IMAGE_PREFIX << img << COLUMN_SEPARATOR << groupname;
|
||||
groups.push_back(str.str());
|
||||
}
|
||||
items.insert(items.begin() + i, groups.begin(), groups.end());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void editor_controller::show_menu(const std::vector<std::string>& items_arg, int xloc, int yloc, bool context_menu)
|
||||
{
|
||||
|
@ -586,18 +551,7 @@ void editor_controller::show_menu(const std::vector<std::string>& items_arg, int
|
|||
hotkey::get_hotkey(*i).set_description(_("Can’t Redo"));
|
||||
}
|
||||
} else if (command == hotkey::HOTKEY_EDITOR_AUTO_UPDATE_TRANSITIONS) {
|
||||
switch (context_manager_->auto_update_transitions_) {
|
||||
case preferences::editor::TransitionUpdateMode::on:
|
||||
hotkey::get_hotkey(*i).set_description(_("Auto-update Terrain Transitions: Yes"));
|
||||
break;
|
||||
case preferences::editor::TransitionUpdateMode::partial:
|
||||
hotkey::get_hotkey(*i).set_description(_("Auto-update Terrain Transitions: Partial"));
|
||||
break;
|
||||
case preferences::editor::TransitionUpdateMode::off:
|
||||
default:
|
||||
hotkey::get_hotkey(*i).set_description(_("Auto-update Terrain Transitions: No"));
|
||||
break;
|
||||
}
|
||||
context_manager_->set_update_transitions_hotkey(command);
|
||||
} else if(!can_execute_command(command)
|
||||
|| (context_menu && !in_context_menu(command))) {
|
||||
i = items.erase(i);
|
||||
|
@ -612,7 +566,7 @@ void editor_controller::show_menu(const std::vector<std::string>& items_arg, int
|
|||
}
|
||||
if (!items.empty() && items.front() == "editor-palette-groups") {
|
||||
active_menu_ = editor::PALETTE;
|
||||
expand_palette_groups_menu(items);
|
||||
toolkit_->get_palette_manager()->active_palette().expand_palette_groups_menu(items);
|
||||
context_menu = true; //FIXME hack to display a one-item menu
|
||||
}
|
||||
command_executor::show_menu(items, xloc, yloc, context_menu, gui());
|
||||
|
@ -633,16 +587,15 @@ void editor_controller::toggle_grid()
|
|||
void editor_controller::copy_selection()
|
||||
{
|
||||
if (!context_manager_->get_map().selection().empty()) {
|
||||
clipboard_ = map_fragment(context_manager_->get_map(), context_manager_->get_map().selection());
|
||||
clipboard_.center_by_mass();
|
||||
context_manager_->get_clipboard() = map_fragment(context_manager_->get_map(), context_manager_->get_map().selection());
|
||||
context_manager_->get_clipboard().center_by_mass();
|
||||
}
|
||||
}
|
||||
|
||||
void editor_controller::cut_selection()
|
||||
{
|
||||
copy_selection();
|
||||
//TODO
|
||||
//context_manager_->perform_refresh(editor_action_paint_area(get_map().selection(), selected_bg_terrain()));
|
||||
context_manager_->perform_refresh(editor_action_paint_area(context_manager_->get_map().selection(), get_selected_bg_terrain()));
|
||||
}
|
||||
|
||||
void editor_controller::export_selection_coords()
|
||||
|
@ -688,8 +641,7 @@ void editor_controller::refresh_image_cache()
|
|||
void editor_controller::display_redraw_callback(display&)
|
||||
{
|
||||
toolkit_->adjust_size();
|
||||
//TODO
|
||||
//seems not to be needed and speeds up drawing?
|
||||
//TODO seems not to be needed and slows down the drawing?
|
||||
//gui().invalidate_all();
|
||||
}
|
||||
|
||||
|
|
|
@ -108,9 +108,6 @@ class editor_controller : public controller_base,
|
|||
/** command_executor override */
|
||||
bool execute_command(hotkey::HOTKEY_COMMAND command, int index = -1);
|
||||
|
||||
/** Menu expanding for palette group list */
|
||||
void expand_palette_groups_menu(std::vector<std::string>& items);
|
||||
|
||||
/** controller_base override */
|
||||
void show_menu(const std::vector<std::string>& items_arg, int xloc, int yloc, bool context_menu);
|
||||
|
||||
|
@ -233,10 +230,6 @@ class editor_controller : public controller_base,
|
|||
bool do_quit_;
|
||||
EXIT_STATUS quit_mode_;
|
||||
|
||||
/** Clipboard map_fragment -- used for copy-paste. */
|
||||
map_fragment clipboard_;
|
||||
|
||||
|
||||
};
|
||||
|
||||
} //end namespace editor
|
||||
|
|
|
@ -65,6 +65,21 @@ private:
|
|||
bool refreshed_;
|
||||
};
|
||||
|
||||
void context_manager::set_update_transitions_hotkey(hotkey::HOTKEY_COMMAND i) {
|
||||
switch (auto_update_transitions_) {
|
||||
case preferences::editor::TransitionUpdateMode::on:
|
||||
hotkey::get_hotkey(i).set_description(_("Auto-update Terrain Transitions: Yes"));
|
||||
break;
|
||||
case preferences::editor::TransitionUpdateMode::partial:
|
||||
hotkey::get_hotkey(i).set_description(_("Auto-update Terrain Transitions: Partial"));
|
||||
break;
|
||||
case preferences::editor::TransitionUpdateMode::off:
|
||||
default:
|
||||
hotkey::get_hotkey(i).set_description(_("Auto-update Terrain Transitions: No"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
size_t context_manager::modified_maps(std::string& message) {
|
||||
std::vector<std::string> modified;
|
||||
foreach (map_context* mc, map_contexts_) {
|
||||
|
@ -90,6 +105,7 @@ context_manager::context_manager(editor_display& gui, const config& game_config)
|
|||
, current_context_index_(0)
|
||||
, auto_update_transitions_(preferences::editor::auto_update_transitions())
|
||||
, map_contexts_()
|
||||
, clipboard_()
|
||||
{
|
||||
if (default_dir_.empty()) {
|
||||
default_dir_ = get_dir(get_dir(get_user_data_dir() + "/editor") + "/maps");
|
||||
|
@ -431,6 +447,15 @@ void context_manager::create_default_context()
|
|||
}
|
||||
}
|
||||
|
||||
void context_manager::fill_selection()
|
||||
{
|
||||
//TODO
|
||||
|
||||
perform_refresh(editor_action_paint_area(get_map().selection(),
|
||||
get_selected_bg_terrain()));
|
||||
|
||||
}
|
||||
|
||||
void context_manager::close_current_context()
|
||||
{
|
||||
if (!confirm_discard()) return;
|
||||
|
|
|
@ -1,54 +1,81 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2003 - 2012 by David White <dave@whitevine.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
Copyright (C) 2003 - 2012 by David White <dave@whitevine.net>
|
||||
Part of 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.
|
||||
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.
|
||||
*/
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
#ifndef CONTEXT_MANAGER_HPP_INCLUDED
|
||||
#define CONTEXT_MANAGER_HPP_INCLUDED
|
||||
|
||||
#include "editor/map/map_context.hpp"
|
||||
#include "editor/editor_preferences.hpp"
|
||||
#include "editor/map/map_fragment.hpp"
|
||||
|
||||
#include "mapgen.hpp"
|
||||
|
||||
#include "hotkeys.hpp"
|
||||
|
||||
namespace editor {
|
||||
|
||||
class context_manager {
|
||||
|
||||
public:
|
||||
size_t modified_maps(std::string& modified);
|
||||
|
||||
private:
|
||||
editor_display& gui_;
|
||||
void set_update_transitions_hotkey(hotkey::HOTKEY_COMMAND i);
|
||||
|
||||
const config& game_config_;
|
||||
size_t modified_maps(std::string& modified);
|
||||
|
||||
/** Default directory for map load/save as dialogs */
|
||||
std::string default_dir_;
|
||||
//TODO move implementation
|
||||
bool toggle_update_transitions() {
|
||||
//TODO move to context_manager and make the member privat
|
||||
auto_update_transitions_ = (auto_update_transitions_ + 1)
|
||||
% preferences::editor::TransitionUpdateMode::count;
|
||||
preferences::editor::set_auto_update_transitions(
|
||||
auto_update_transitions_);
|
||||
if (auto_update_transitions_
|
||||
!= preferences::editor::TransitionUpdateMode::on) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
;
|
||||
|
||||
/** Available random map generators */
|
||||
std::vector<map_generator*> map_generators_;
|
||||
bool clipboard_empty() {
|
||||
return clipboard_.empty();
|
||||
}
|
||||
;
|
||||
|
||||
map_fragment& get_clipboard() {
|
||||
return clipboard_;
|
||||
}
|
||||
;
|
||||
|
||||
/** Fill the selection with the foreground terrain */
|
||||
void fill_selection();
|
||||
|
||||
public:
|
||||
/** Index into the map_contexts_ array */
|
||||
int current_context_index_;
|
||||
|
||||
/** Flag to rebuild terrain on every terrain change */
|
||||
int auto_update_transitions_;
|
||||
int current_context_index() {
|
||||
return current_context_index_;
|
||||
}
|
||||
;
|
||||
|
||||
public:
|
||||
context_manager(editor_display& gui, const config& game_config);
|
||||
~context_manager();
|
||||
|
||||
size_t open_maps(void) { return map_contexts_.size(); };
|
||||
size_t open_maps(void) {
|
||||
return map_contexts_.size();
|
||||
}
|
||||
;
|
||||
|
||||
/**
|
||||
* Peform an action on the current map_context, then refresh the display.
|
||||
|
@ -65,25 +92,16 @@ public:
|
|||
/** Save the map, open dialog if not named yet. */
|
||||
void save_map();
|
||||
|
||||
context_manager(editor_display& gui, const config& game_config);
|
||||
~context_manager();
|
||||
|
||||
editor_display& gui() { return gui_; };
|
||||
editor_display& gui() {
|
||||
return gui_;
|
||||
}
|
||||
;
|
||||
|
||||
/**
|
||||
* Refresh everything, i.e. invalidate all hexes and redraw them. Does *not* reload the map.
|
||||
*/
|
||||
void refresh_all();
|
||||
|
||||
|
||||
/** Set the default dir (where the filebrowser is pointing at when there is no map file opened) */
|
||||
void set_default_dir(const std::string& str);
|
||||
|
||||
/**
|
||||
* Replace the current map context and refresh accordingly
|
||||
*/
|
||||
void replace_map_context(map_context* new_mc);
|
||||
|
||||
/** Display an apply mask dialog and process user input. */
|
||||
void apply_mask_dialog();
|
||||
|
||||
|
@ -108,21 +126,6 @@ public:
|
|||
/** Display a load map dialog and process user input. */
|
||||
void resize_map_dialog();
|
||||
|
||||
/** init available random map generators */
|
||||
void init_map_generators(const config& game_config);
|
||||
|
||||
/**
|
||||
* Refresh the display after an action has been performed.
|
||||
* The map context contains details of what needs to be refreshed.
|
||||
*/
|
||||
void refresh_after_action(bool drag_part = false);
|
||||
|
||||
/**
|
||||
* Shows an are-you-sure dialog if the map was modified.
|
||||
* @return true if the user confirmed or the map was not modified, false otherwise
|
||||
*/
|
||||
bool confirm_discard();
|
||||
|
||||
size_t size() {
|
||||
return map_contexts_.size();
|
||||
}
|
||||
|
@ -132,16 +135,29 @@ public:
|
|||
return *map_contexts_[current_context_index_];
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
/** Set the default dir (where the filebrowser is pointing at when there is no map file opened) */
|
||||
void set_default_dir(const std::string& str);
|
||||
|
||||
/**
|
||||
* Replace the current map context and refresh accordingly
|
||||
*/
|
||||
void replace_map_context(map_context* new_mc);
|
||||
/** init available random map generators */
|
||||
void init_map_generators(const config& game_config);
|
||||
|
||||
/**
|
||||
* Shows an are-you-sure dialog if the map was modified.
|
||||
* @return true if the user confirmed or the map was not modified, false otherwise
|
||||
*/
|
||||
bool confirm_discard();
|
||||
|
||||
/** Get the current map context object - const version */
|
||||
const map_context& get_map_context() const {
|
||||
return *map_contexts_[current_context_index_];
|
||||
}
|
||||
|
||||
/** Get the map from the current map context object */
|
||||
editor_map& get_map() {
|
||||
return get_map_context().get_map();
|
||||
}
|
||||
|
||||
/** Get the map from the current map context object - const version*/
|
||||
const editor_map& get_map() const {
|
||||
return get_map_context().get_map();
|
||||
|
@ -159,6 +175,18 @@ public:
|
|||
*/
|
||||
void create_default_context();
|
||||
|
||||
public:
|
||||
/**
|
||||
* Refresh the display after an action has been performed.
|
||||
* The map context contains details of what needs to be refreshed.
|
||||
*/
|
||||
void refresh_after_action(bool drag_part = false);
|
||||
|
||||
/** Get the map from the current map context object */
|
||||
editor_map& get_map() {
|
||||
return get_map_context().get_map();
|
||||
}
|
||||
|
||||
/** Closes the active map context. Switches to a valid context afterward or creates a dummy one. */
|
||||
void close_current_context();
|
||||
|
||||
|
@ -166,10 +194,6 @@ public:
|
|||
void switch_context(const int index);
|
||||
|
||||
private:
|
||||
/** The currently opened map context object */
|
||||
std::vector<map_context*> map_contexts_;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Save the map under a given filename.
|
||||
* @return true on success
|
||||
|
@ -209,6 +233,7 @@ public:
|
|||
*/
|
||||
bool check_switch_open_map(const std::string& fn);
|
||||
|
||||
public:
|
||||
/**
|
||||
* Load a map given the filename
|
||||
*/
|
||||
|
@ -225,6 +250,30 @@ public:
|
|||
*/
|
||||
void reload_map();
|
||||
|
||||
private:
|
||||
|
||||
editor_display& gui_;
|
||||
|
||||
const config& game_config_;
|
||||
|
||||
/** Default directory for map load/save as dialogs */
|
||||
std::string default_dir_;
|
||||
|
||||
/** Available random map generators */
|
||||
std::vector<map_generator*> map_generators_;
|
||||
|
||||
int current_context_index_;
|
||||
|
||||
/** Flag to rebuild terrain on every terrain change */
|
||||
int auto_update_transitions_;
|
||||
|
||||
|
||||
/** The currently opened map context object */
|
||||
std::vector<map_context*> map_contexts_;
|
||||
|
||||
/** Clipboard map_fragment -- used for copy-paste. */
|
||||
map_fragment clipboard_;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -64,6 +64,9 @@ public:
|
|||
virtual const config active_group_report() = 0;
|
||||
virtual const std::vector<item_group>& get_groups() const = 0;
|
||||
|
||||
/** Menu expanding for palette group list */
|
||||
virtual void expand_palette_groups_menu(std::vector<std::string>& items) = 0;
|
||||
|
||||
//item
|
||||
virtual size_t num_items() = 0;
|
||||
virtual size_t start_num() = 0;
|
||||
|
|
|
@ -24,8 +24,44 @@
|
|||
|
||||
#include "editor/action/mouse/mouse_action.hpp"
|
||||
|
||||
#include "wml_separators.hpp"
|
||||
|
||||
namespace editor {
|
||||
|
||||
//TODO move to the palette
|
||||
template<class Item>
|
||||
void editor_palette<Item>::expand_palette_groups_menu(std::vector<std::string>& items)
|
||||
{
|
||||
//TODO
|
||||
//active_menu_ = editor::PALETTE;
|
||||
for (unsigned int i = 0; i < items.size(); ++i) {
|
||||
if (items[i] == "editor-palette-groups") {
|
||||
items.erase(items.begin() + i);
|
||||
|
||||
std::vector<std::string> groups;
|
||||
const std::vector<item_group>& item_groups = get_groups();
|
||||
|
||||
for (size_t mci = 0; mci < item_groups.size(); ++mci) {
|
||||
std::string groupname = item_groups[mci].name;
|
||||
if (groupname.empty()) {
|
||||
groupname = _("(Unknown Group)");
|
||||
}
|
||||
std::string img = item_groups[mci].icon;
|
||||
std::stringstream str;
|
||||
//TODO
|
||||
//std::string postfix = ".png"; //(toolkit_->active_group_index() == mci) ? "-pressed.png" : ".png";
|
||||
//str << IMAGE_PREFIX << "buttons/" << img << postfix << COLUMN_SEPARATOR << groupname;
|
||||
str << IMAGE_PREFIX << img << COLUMN_SEPARATOR << groupname;
|
||||
groups.push_back(str.str());
|
||||
}
|
||||
items.insert(items.begin() + i, groups.begin(), groups.end());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
template void editor_palette<t_translation::t_terrain>::expand_palette_groups_menu(std::vector<std::string>& items);
|
||||
template void editor_palette<unit_type>::expand_palette_groups_menu(std::vector<std::string>& items);
|
||||
|
||||
template<class Item>
|
||||
bool editor_palette<Item>::left_mouse_click(const int mousex, const int mousey)
|
||||
{
|
||||
|
|
|
@ -48,6 +48,9 @@ public:
|
|||
{
|
||||
};
|
||||
|
||||
/** Menu expanding for palette group list */
|
||||
void expand_palette_groups_menu(std::vector<std::string>& items);
|
||||
|
||||
void set_group(size_t index);
|
||||
|
||||
const std::vector<item_group>& get_groups() const { return groups_; };
|
||||
|
@ -77,8 +80,8 @@ public:
|
|||
/** Return the number of the tile that is at coordinates (x, y) in the panel. */
|
||||
int tile_selected(const int x, const int y) const;
|
||||
|
||||
bool scroll_up();
|
||||
bool scroll_down();
|
||||
virtual bool scroll_up();
|
||||
virtual bool scroll_down();
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -36,6 +36,9 @@ public:
|
|||
// think about removing it
|
||||
virtual void setup(const config& /*cfg*/) {};
|
||||
|
||||
bool scroll_up() { return false; };
|
||||
bool scroll_down() { return false; };
|
||||
|
||||
private:
|
||||
virtual const std::string& get_id(const unit_type& /*terrain*/) { return empty_string; };
|
||||
|
||||
|
|
|
@ -136,15 +136,6 @@ void editor_toolkit::hotkey_set_mouse_action(hotkey::HOTKEY_COMMAND command)
|
|||
|
||||
}
|
||||
|
||||
void editor_toolkit::fill_selection()
|
||||
{
|
||||
//TODO
|
||||
/*
|
||||
perform_refresh(editor_action_paint_area(get_map().selection(),
|
||||
toolkit_->terrain_palette_->selected_fg_item()));
|
||||
*/
|
||||
}
|
||||
|
||||
bool editor_toolkit::is_mouse_action_set(hotkey::HOTKEY_COMMAND command) const
|
||||
{
|
||||
std::map<hotkey::HOTKEY_COMMAND, mouse_action*>::const_iterator i = mouse_actions_.find(command);
|
||||
|
|
|
@ -64,8 +64,6 @@ public:
|
|||
*/
|
||||
bool is_mouse_action_set(hotkey::HOTKEY_COMMAND command) const;
|
||||
|
||||
/** Fill the selection with the foreground terrain */
|
||||
void fill_selection();
|
||||
|
||||
/** Get the current mouse action */
|
||||
mouse_action* get_mouse_action() { return mouse_action_; };
|
||||
|
@ -77,15 +75,14 @@ public:
|
|||
/** Cycle to the next brush. */
|
||||
void cycle_brush();
|
||||
|
||||
palette_manager* get_palette_manager() { return palette_manager_.get(); };
|
||||
|
||||
private:
|
||||
|
||||
editor_display& gui_;
|
||||
|
||||
const CKey& key_;
|
||||
|
||||
//Palette
|
||||
|
||||
public:
|
||||
/** TODO */
|
||||
boost::scoped_ptr<palette_manager> palette_manager_;
|
||||
|
||||
|
|
|
@ -130,7 +130,7 @@ const struct {
|
|||
{ hotkey::HOTKEY_EDITOR_MAP_SAVE_ALL, "editor-map-save-all", N_("Save All Maps"), false, hotkey::SCOPE_EDITOR },
|
||||
{ hotkey::HOTKEY_EDITOR_MAP_REVERT, "editor-map-revert", N_("Revert All Changes"), false, hotkey::SCOPE_EDITOR },
|
||||
{ hotkey::HOTKEY_EDITOR_MAP_INFO, "editor-map-info", N_("Map Information"), false, hotkey::SCOPE_EDITOR },
|
||||
{ hotkey::HOTKEY_EDITOR_TERRAIN_PALETTE_SWAP, "editor-terrain-palette-swap",
|
||||
{ hotkey::HOTKEY_EDITOR_PALETTE_ITEM_SWAP, "editor-terrain-palette-swap",
|
||||
N_("Swap Foreground/Background Terrains"), false, hotkey::SCOPE_EDITOR },
|
||||
{ hotkey::HOTKEY_EDITOR_PALETTE_GROUPS, "editor-palette-groups", N_("Change Palette Group"), false, hotkey::SCOPE_EDITOR },
|
||||
{ hotkey::HOTKEY_EDITOR_PALETTE_UPSCROLL, "editor-palette-upscroll", N_("Scroll Palette Left"), false, hotkey::SCOPE_EDITOR },
|
||||
|
|
|
@ -78,7 +78,7 @@ enum HOTKEY_COMMAND {
|
|||
HOTKEY_EDITOR_MAP_NEW, HOTKEY_EDITOR_MAP_LOAD, HOTKEY_EDITOR_MAP_SAVE,
|
||||
HOTKEY_EDITOR_MAP_SAVE_AS, HOTKEY_EDITOR_MAP_SAVE_ALL,
|
||||
HOTKEY_EDITOR_MAP_REVERT, HOTKEY_EDITOR_MAP_INFO,
|
||||
HOTKEY_EDITOR_TERRAIN_PALETTE_SWAP,
|
||||
HOTKEY_EDITOR_PALETTE_ITEM_SWAP,
|
||||
HOTKEY_EDITOR_PALETTE_GROUPS, HOTKEY_EDITOR_PALETTE_UPSCROLL, HOTKEY_EDITOR_PALETTE_DOWNSCROLL,
|
||||
HOTKEY_EDITOR_TOOL_NEXT,
|
||||
HOTKEY_EDITOR_TOOL_PAINT, HOTKEY_EDITOR_TOOL_FILL,
|
||||
|
|
Loading…
Add table
Reference in a new issue