Reenabled the select terrain from map feature.
More code cleanups.
This commit is contained in:
parent
1f1437b8b5
commit
809c14f9a5
5 changed files with 49 additions and 59 deletions
|
@ -22,6 +22,7 @@
|
|||
#include "construct_dialog.hpp"
|
||||
#include "gettext.hpp"
|
||||
#include "gui/dialogs/editor_set_starting_position.hpp"
|
||||
#include "editor/palette/terrain_palettes.hpp"
|
||||
|
||||
namespace editor {
|
||||
|
||||
|
@ -255,10 +256,8 @@ const brush& brush_drag_mouse_action::get_brush()
|
|||
editor_action* mouse_action_paint::click_left(editor_display& disp, int x, int y)
|
||||
{
|
||||
if (has_ctrl_modifier()) {
|
||||
// map_location hex = disp.hex_clicked_on(x, y);
|
||||
// TODO
|
||||
// terrain_left_ = disp.map().get_terrain(hex);
|
||||
// terrain_palette_->select_fg_item( (disp.map().get_terrain(hex)).id() );
|
||||
map_location hex = disp.hex_clicked_on(x, y);
|
||||
set_selected_fg_terrain(disp.map().get_terrain(hex));
|
||||
return NULL;
|
||||
} else {
|
||||
return brush_drag_mouse_action::click_left(disp, x, y);
|
||||
|
@ -268,9 +267,8 @@ editor_action* mouse_action_paint::click_left(editor_display& disp, int x, int y
|
|||
editor_action* mouse_action_paint::click_right(editor_display& disp, int x, int y)
|
||||
{
|
||||
if (has_ctrl_modifier()) {
|
||||
// map_location hex = disp.hex_clicked_on(x, y);
|
||||
// TODO
|
||||
// terrain_right_ = disp.map().get_terrain(hex);
|
||||
map_location hex = disp.hex_clicked_on(x, y);
|
||||
set_selected_bg_terrain(disp.map().get_terrain(hex));
|
||||
return NULL;
|
||||
} else {
|
||||
return brush_drag_mouse_action::click_right(disp, x, y);
|
||||
|
@ -386,8 +384,7 @@ editor_action* mouse_action_fill::click_left(editor_display& disp, int x, int y)
|
|||
{
|
||||
map_location hex = disp.hex_clicked_on(x, y);
|
||||
if (has_ctrl_modifier()) {
|
||||
//TODO
|
||||
//terrain_left_ = disp.map().get_terrain(hex);
|
||||
set_selected_fg_terrain(disp.map().get_terrain(hex));
|
||||
return NULL;
|
||||
} else {
|
||||
//TODO only take the base terrain into account when searching for contiguous terrain when painting base only
|
||||
|
@ -402,8 +399,7 @@ editor_action* mouse_action_fill::click_right(editor_display& disp, int x, int y
|
|||
{
|
||||
map_location hex = disp.hex_clicked_on(x, y);
|
||||
if (has_ctrl_modifier()) {
|
||||
//TODO
|
||||
//terrain_right_ = disp.map().get_terrain(hex);
|
||||
set_selected_bg_terrain(disp.map().get_terrain(hex));
|
||||
return NULL;
|
||||
} else {
|
||||
//TODO only take the base terrain into account when searching for contiguous terrain when painting base only
|
||||
|
|
|
@ -24,7 +24,9 @@ namespace editor {
|
|||
|
||||
template<class Item>
|
||||
class editor_palette : public common_palette {
|
||||
|
||||
public:
|
||||
|
||||
editor_palette(editor_display &gui, const size_specs &sizes, const config& /*cfg*/
|
||||
, size_t item_size, size_t item_width, mouse_action** active_mouse_action)
|
||||
: groups_()
|
||||
|
@ -48,6 +50,10 @@ public:
|
|||
{
|
||||
};
|
||||
|
||||
void set_start_item(size_t index) { items_start_ = index; };
|
||||
|
||||
size_t start_num(void) { return items_start_; };
|
||||
|
||||
/** Menu expanding for palette group list */
|
||||
void expand_palette_groups_menu(std::vector<std::string>& items);
|
||||
|
||||
|
@ -55,7 +61,6 @@ public:
|
|||
|
||||
const std::vector<item_group>& get_groups() const { return groups_; };
|
||||
|
||||
|
||||
virtual void draw(bool);
|
||||
|
||||
bool left_mouse_click(const int, const int);
|
||||
|
@ -75,16 +80,23 @@ public:
|
|||
*/
|
||||
void adjust_size(const size_specs& size);
|
||||
|
||||
virtual bool scroll_up();
|
||||
virtual bool scroll_down();
|
||||
|
||||
virtual const config active_group_report();
|
||||
|
||||
void swap();
|
||||
|
||||
/** Return the currently selected foreground/background item. */
|
||||
const Item& selected_fg_item() const { return item_map_.find(selected_fg_item_)->second; };
|
||||
const Item& selected_bg_item() const { return item_map_.find(selected_bg_item_)->second; };
|
||||
|
||||
private:
|
||||
|
||||
/** 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;
|
||||
|
||||
virtual bool scroll_up();
|
||||
virtual bool scroll_down();
|
||||
|
||||
private:
|
||||
|
||||
/** TODO */
|
||||
size_t active_group_index();
|
||||
|
||||
/** Scroll the editor-palette to the top. */
|
||||
|
@ -102,9 +114,10 @@ private:
|
|||
|
||||
virtual const std::string& active_group_id() {return active_group_;};
|
||||
|
||||
public:
|
||||
virtual const config active_group_report();
|
||||
/** Return the number of items in the palette. */
|
||||
size_t num_items();
|
||||
|
||||
void draw_old(bool);
|
||||
|
||||
protected:
|
||||
/**
|
||||
|
@ -116,16 +129,10 @@ protected:
|
|||
virtual void set_group(const std::string& id);
|
||||
const std::vector<std::string>& active_group() { return group_map_[active_group_]; };
|
||||
|
||||
public:
|
||||
/** Return the currently selected foreground/background item. */
|
||||
const Item& selected_fg_item() const { return item_map_.find(selected_fg_item_)->second; };
|
||||
const Item& selected_bg_item() const { return item_map_.find(selected_bg_item_)->second; };
|
||||
/** Select a foreground item. */
|
||||
virtual void select_fg_item(std::string item_id);
|
||||
virtual void select_bg_item(std::string item_id);
|
||||
|
||||
void set_start_item(size_t index) { items_start_ = index; };
|
||||
|
||||
size_t start_num(void) { return items_start_; };
|
||||
|
||||
protected:
|
||||
/**
|
||||
* The editor_groups as defined in editor-groups.cfg.
|
||||
*
|
||||
|
@ -134,25 +141,6 @@ protected:
|
|||
*/
|
||||
std::vector<item_group> groups_;
|
||||
|
||||
private:
|
||||
/** Return the currently selected background item. */
|
||||
// Item selected_bg_item() const { return selected_bg_item_; };
|
||||
|
||||
void swap();
|
||||
|
||||
protected:
|
||||
/** Select a foreground item. */
|
||||
virtual void select_fg_item(std::string item_id);
|
||||
virtual void select_bg_item(std::string item_id);
|
||||
|
||||
private:
|
||||
|
||||
/** Return the number of items in the palette. */
|
||||
size_t num_items();
|
||||
|
||||
void draw_old(bool);
|
||||
|
||||
protected:
|
||||
editor_display &gui_;
|
||||
const size_specs &size_specs_;
|
||||
|
||||
|
@ -160,15 +148,6 @@ protected:
|
|||
int item_width_;
|
||||
int item_space_;
|
||||
|
||||
protected:
|
||||
|
||||
/** Update the report with the currently selected items. */
|
||||
/*
|
||||
virtual void update_report() = 0;
|
||||
*/
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
unsigned int palette_y_;
|
||||
unsigned int palette_x_;
|
||||
|
|
|
@ -26,13 +26,20 @@
|
|||
|
||||
namespace {
|
||||
static std::string selected_terrain;
|
||||
static t_translation::t_terrain fg_terrain;
|
||||
static t_translation::t_terrain bg_terrain;
|
||||
}
|
||||
|
||||
|
||||
|
||||
namespace editor {
|
||||
|
||||
void set_selected_bg_terrain(t_translation::t_terrain terrain) {
|
||||
bg_terrain = terrain;
|
||||
}
|
||||
|
||||
void set_selected_fg_terrain(t_translation::t_terrain terrain) {
|
||||
fg_terrain = terrain;
|
||||
}
|
||||
|
||||
t_translation::t_terrain get_selected_bg_terrain() {
|
||||
return bg_terrain;
|
||||
}
|
||||
|
|
|
@ -25,10 +25,16 @@
|
|||
|
||||
namespace editor {
|
||||
|
||||
std::string get_selected_terrain();
|
||||
//TODO
|
||||
//std::string get_selected_terrain();
|
||||
|
||||
t_translation::t_terrain get_selected_fg_terrain();
|
||||
t_translation::t_terrain get_selected_bg_terrain();
|
||||
|
||||
//Those could be moved inside the class.
|
||||
void set_selected_fg_terrain(t_translation::t_terrain terrain);
|
||||
void set_selected_bg_terrain(t_translation::t_terrain terrain);
|
||||
|
||||
/** Palette where the terrain to be drawn can be selected. */
|
||||
class terrain_palette : public editor_palette<t_translation::t_terrain> {
|
||||
public:
|
||||
|
|
|
@ -1184,6 +1184,7 @@ REPORT_GENERATOR(observers)
|
|||
return image_report(game_config::images::observer, str.str());
|
||||
}
|
||||
|
||||
/* TODO unused
|
||||
REPORT_GENERATOR(selected_terrain)
|
||||
{
|
||||
const std::string selected_terrain = editor::get_selected_terrain();
|
||||
|
@ -1192,6 +1193,7 @@ REPORT_GENERATOR(selected_terrain)
|
|||
else
|
||||
return text_report(selected_terrain);
|
||||
}
|
||||
*/
|
||||
|
||||
/* TODO this is unused
|
||||
REPORT_GENERATOR(edit_left_button_function)
|
||||
|
|
Loading…
Add table
Reference in a new issue