editor2: sidebar tweaks

This commit is contained in:
Tomasz Śniatowski 2008-08-16 20:42:19 +01:00
parent 06aa851094
commit 5c99f2ccb9
12 changed files with 67 additions and 20 deletions

View file

@ -8,7 +8,6 @@
{core/terrain.cfg}
{core/terrain-graphics/}
{core/editor-groups.cfg}
#else
{core/macros/}
{core/about.cfg}
@ -23,5 +22,6 @@
{core/editor-groups.cfg}
{core/editor2-brushes.cfg}
{core/editor2-hotkeys.cfg}
{core/editor2-tool-hints.cfg}
#endif
#endif

View file

@ -0,0 +1,22 @@
#textdomain wesnoth-editor
# Tool information / help
[editor2_tool_hint]
id="editor-tool-paint"
text= _ "Use left/right mouse button to draw fore-/background terrain. Hold ALT to paint base layer only"
[/editor2_tool_hint]
[editor2_tool_hint]
id="editor-tool-fill"
text= _ "Use left/right mouse button to draw fore-/background terrain. Hold ALT to paint base layer only"
[/editor2_tool_hint]
[editor2_tool_hint]
id="editor-tool-select"
text= _ "Left mouse button selects, right deselects. Hold Shift for magic-wand selection of tiles with same terrain"
[/editor2_tool_hint]
[editor2_tool_hint]
id="editor-tool-starting-position"
text= _ "Left mouse button displays player selection, right clears. Keys 1-9 set respectove starting position under cursor and delete clears"
[/editor2_tool_hint]

View file

@ -215,10 +215,10 @@
items=undo
auto_tooltip=yes
ref=draw_button_editor
rect="=,+6,+24,+24"
rect="=,+104,+24,+24"
xanchor=right
yachnor=fixed
[/menu]
[/menu]
[menu]
id=redo_button_editor
image=redo_button_editor
@ -268,6 +268,17 @@
[/label]
[status]
[editor2_tool_hint]
id=tool-hint
font_size={DEFAULT_EDITOR_FONT_REALLYTINY}
ref=draw_button_editor
rect="=,+6,+110,+40"
xanchor=right
yanchor=fixed
prefix=
prefix_literal=""
[/editor2_tool_hint]
# the time of day image
# [time_of_day]
# id=image-tod
@ -277,6 +288,7 @@
# yanchor=fixed
# [/time_of_day]
[villages]
id=villages
font_size={DEFAULT_EDITOR_FONT_SMALL}
@ -287,6 +299,8 @@
prefix=
prefix_literal=""
[/villages]
# This panel encloses the location information displays and the
# observer icon. This separate container is used so that we can

View file

@ -93,7 +93,13 @@ editor_controller::editor_controller(const config &game_config, CVideo& video)
i->second->set_toolbar_button(&menu);
}
}
}
}
foreach (const config* c, game_config.get_children("editor2_tool_hint")) {
mouse_action_map::iterator i = mouse_actions_.find(hotkey::get_hotkey((*c)["id"]).get_id());
if (i != mouse_actions_.end()) {
mouse_action_hints_.insert(std::make_pair(i->first, (*c)["text"]));
}
}
hotkey_set_mouse_action(hotkey::HOTKEY_EDITOR_TOOL_PAINT);
background_terrain_ = t_translation::GRASS_LAND;
@ -139,7 +145,7 @@ editor_controller::~editor_controller()
delete gui_;
foreach (const mouse_action_map::value_type a, mouse_actions_) {
delete a.second;
}
}
delete prefs_disp_manager_;
}
@ -700,6 +706,7 @@ void editor_controller::hotkey_set_mouse_action(hotkey::HOTKEY_COMMAND command)
redraw_toolbar();
gui().set_report_content(reports::EDIT_LEFT_BUTTON_FUNCTION,
hotkey::get_hotkey(command).get_description());
gui().set_toolbar_hint(mouse_action_hints_[command]);
gui().invalidate_game_status();
} else {
ERR_ED << "Invalid hotkey command (" << (int)command << ") passed to set_mouse_action\n";
@ -849,19 +856,14 @@ void editor_controller::mouse_motion(int x, int y, const bool /*browse*/, bool u
if (mouse_handler_base::mouse_motion_default(x, y, update)) return;
gamemap::location hex_clicked = gui().hex_clicked_on(x, y);
if (get_map().on_board_with_border(drag_from_hex_) && is_dragging()) {
LOG_ED << "Drag? " << dragging_left_ << " " << dragging_right_
<< " " <<(void*)(SDL_GetMouseState(NULL, NULL))
<< "\n";
editor_action* a = NULL;
bool partial = false;
editor_action* last_undo = get_map_context().last_undo_action();
if (dragging_left_ && (SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(1)) != 0) {
if (!get_map().on_board_with_border(hex_clicked)) return;
LOG_ED << "Mouse drag L\n";
a = get_mouse_action()->drag_left(*gui_, x, y, partial, last_undo);
} else if (dragging_right_ && (SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(3)) != 0) {
if (!get_map().on_board_with_border(hex_clicked)) return;
LOG_ED << "Mouse drag R\n";
a = get_mouse_action()->drag_right(*gui_, x, y, partial, last_undo);
}
//Partial means that the mouse action has modified the last undo action and the controller shouldn't add
@ -941,7 +943,6 @@ void editor_controller::right_mouse_up(int /*x*/, int /*y*/, const bool /*browse
void editor_controller::process_keyup_event(const SDL_Event& event)
{
LOG_ED << "keyup\n";
editor_action* a = get_mouse_action()->key_event(gui(), event);
perform_refresh_delete(a);
}

View file

@ -299,6 +299,10 @@ class editor_controller : public controller_base,
/** The mouse actions */
mouse_action_map mouse_actions_;
typedef std::map<hotkey::HOTKEY_COMMAND, std::string> mouse_action_string_map;
/** Usage tips for mouse actions */
mouse_action_string_map mouse_action_hints_;
/** The current mouse action */
mouse_action* mouse_action_;

View file

@ -88,6 +88,7 @@ void editor_display::draw_sidebar()
refresh_report(reports::POSITION, reports::report(lexical_cast<std::string>(mouseoverHex_)));
}
refresh_report(reports::VILLAGES, reports::report(lexical_cast<std::string>(map_.villages().size())));
refresh_report(reports::EDITOR2_TOOL_HINT, reports::report(toolbar_hint_));
}

View file

@ -33,6 +33,7 @@ public:
void remove_brush_loc(const gamemap::location& hex);
const editor_map& map() const { return static_cast<const editor_map&>(map_); }
void rebuild_terrain(const gamemap::location &loc);
void set_toolbar_hint(const std::string value) { toolbar_hint_ = value; }
protected:
void pre_draw();
/**
@ -43,6 +44,7 @@ protected:
void draw_sidebar();
std::set<gamemap::location> brush_locations_;
std::string toolbar_hint_;
};
} //end namespace editor2

View file

@ -33,7 +33,7 @@ size_specs::size_specs() {
terrain_width = default_palette_width;
brush_x = 0;
brush_y = 0;
brush_padding = 2;
brush_padding = 1;
palette_x = 0;
palette_y = 0;
palette_w = 10;
@ -42,11 +42,11 @@ size_specs::size_specs() {
void adjust_sizes(const display &disp, size_specs &sizes) {
//! @todo Hardcoded coordinates for brush selection, make it themeable
sizes.brush_x = disp.map_outside_area().w + 8;
sizes.brush_y = 245;
sizes.brush_x = disp.map_outside_area().w + 10;
sizes.brush_y = 270;
//! @todo Hardcoded coordinates for terrain palette, make it themeable
sizes.palette_x = disp.map_outside_area().w + 16;
sizes.palette_y = sizes.brush_y + 132 + 10;
sizes.palette_y = sizes.brush_y + 92;
sizes.palette_w = sizes.terrain_space * default_palette_width;
//the '-5' make sure that the scroll down button can not be outside of
//the window, this is probably a bug in placement anyway...

View file

@ -153,7 +153,7 @@ editor_action* mouse_action_paint::click_perform_right(
std::set<gamemap::location> mouse_action_select::affected_hexes(
editor_display& disp, const gamemap::location& hex)
{
if (key_[SDLK_RALT] || key_[SDLK_LALT]) {
if (has_shift_modifier()) {
return disp.map().get_contigious_terrain_tiles(hex);
} else {
return brush_drag_mouse_action::affected_hexes(disp, hex);

View file

@ -40,7 +40,7 @@ public:
}
virtual ~mouse_action() {}
/**
* Mouse move (not a drag). Never changes anything (other than temporary highlihts and similar)
*/
@ -108,6 +108,9 @@ protected:
const CKey& key_;
private:
/**
* Pointer to an associated menu/button, if such exists
*/
const theme::menu* toolbar_button_;
};
@ -176,7 +179,7 @@ protected:
gamemap::location previous_drag_hex_;
private:
/**
* Current brush handle.
* Current brush handle. Currently a pointer-to-pointer with full constness.
*/
const brush* const * const brush_;
};

View file

@ -29,7 +29,7 @@ namespace {
"turn", "gold", "villages", "num_units", "upkeep", "expenses",
"income", "terrain", "position", "side_playing", "observers",
"report_countdown", "report_clock",
"selected_terrain", "edit_left_button_function"
"selected_terrain", "edit_left_button_function", "editor2_tool_hint"
};
}

View file

@ -33,7 +33,7 @@ namespace reports {
TURN, GOLD, VILLAGES, NUM_UNITS, UPKEEP, EXPENSES,
INCOME, TERRAIN, POSITION, SIDE_PLAYING, OBSERVERS,
REPORT_COUNTDOWN, REPORT_CLOCK, SELECTED_TERRAIN,
EDIT_LEFT_BUTTON_FUNCTION, NUM_REPORTS};
EDIT_LEFT_BUTTON_FUNCTION, EDITOR2_TOOL_HINT, NUM_REPORTS};
enum { UNIT_REPORTS_BEGIN=UNIT_NAME, UNIT_REPORTS_END=UNIT_PROFILE+1 };
enum { STATUS_REPORTS_BEGIN=TIME_OF_DAY, STATUS_REPORTS_END=NUM_REPORTS };