[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Wesnoth-cvs-commits] wesnoth/src theme.cpp theme.hpp editor/editor.c...
From: |
Bram Ridder |
Subject: |
[Wesnoth-cvs-commits] wesnoth/src theme.cpp theme.hpp editor/editor.c... |
Date: |
Sun, 17 Jul 2005 10:01:21 -0400 |
CVSROOT: /cvsroot/wesnoth
Module name: wesnoth
Branch:
Changes by: Bram Ridder <address@hidden> 05/07/17 14:01:21
Modified files:
src : theme.cpp theme.hpp
src/editor : editor.cpp editor.hpp
Log message:
Added tooltips to the editor toolbar buttons.
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/theme.cpp.diff?tr1=1.38&tr2=1.39&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/theme.hpp.diff?tr1=1.9&tr2=1.10&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/editor/editor.cpp.diff?tr1=1.108&tr2=1.109&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/editor/editor.hpp.diff?tr1=1.46&tr2=1.47&r1=text&r2=text
Patches:
Index: wesnoth/src/editor/editor.cpp
diff -u wesnoth/src/editor/editor.cpp:1.108 wesnoth/src/editor/editor.cpp:1.109
--- wesnoth/src/editor/editor.cpp:1.108 Tue Jul 12 19:59:16 2005
+++ wesnoth/src/editor/editor.cpp Sun Jul 17 14:01:21 2005
@@ -91,7 +91,7 @@
theme_(theme), game_config_(game_config), map_dirty_(false),
l_button_palette_dirty_(true),
everything_dirty_(false), palette_(gui, size_specs_, map),
brush_(gui, size_specs_),
l_button_held_func_(NONE), highlighted_locs_cleared_(false),
prefs_disp_manager_(&gui_),
- all_hexes_selected_(false) {
+ all_hexes_selected_(false), tooltip_manager_(gui_.video()),
floating_label_manager_() {
// Set size specs.
adjust_sizes(gui_, size_specs_);
@@ -117,6 +117,7 @@
palette_.select_bg_terrain(old_bg_terrain_);
brush_.select_brush_size(old_brush_size_);
}
+
hotkey::load_descriptions();
recalculate_starting_pos_labels();
gui_.invalidate_game_status();
@@ -127,6 +128,54 @@
brush_.adjust_size();
events::raise_draw_event();
redraw_everything();
+ load_tooltips();
+}
+
+/**
+ * This should be replaced by a WML tag called 'tooltip=' in the
+ * data/themes/editor.cfg file. The theme and display classes
+ * should then load the given tooltip in the button.
+ */
+void map_editor::load_tooltips()
+{
+ // Add tooltips to all buttons
+ const theme &t = gui_.get_theme();
+ const std::vector<theme::menu> &menus = t.menus();
+ std::vector<theme::menu>::const_iterator it;
+ for (it = menus.begin(); it != menus.end(); it++) {
+
+ const SDL_Rect draw_rect = (*it).get_location();
+ std::string text = "";
+
+ const std::vector<std::string> &menu_items = (*it).items();
+ if (menu_items.size() == 1) {
+ if(menu_items.back() == "editdraw")
+ text = _("Draw tiles");
+ else if(menu_items.back() == "editfloodfill")
+ text = _("Fill");
+ else if(menu_items.back() == "editsetstartpos")
+ text = _("Set player's starting position");
+ else if(menu_items.back() == "zoomin")
+ text = _("Zoom in");
+ else if(menu_items.back() == "zoomout")
+ text = _("Zoom out");
+ else if(menu_items.back() == "undo")
+ text = _("Undo");
+ else if(menu_items.back() == "redo")
+ text = _("Redo");
+ else if(menu_items.back() == "zoomdefault")
+ text = _("Zoom to default view");
+ else if(menu_items.back() == "togglegrid")
+ text = _("Toggle grid");
+ else if(menu_items.back() == "editresize")
+ text = _("Resize the map");
+ else if(menu_items.back() == "editflip")
+ text = _("Flip map");
+ }
+
+ if(text != "")
+ tooltips::add_tooltip(draw_rect, text);
+ }
}
map_editor::~map_editor() {
@@ -148,14 +197,17 @@
void map_editor::handle_event(const SDL_Event &event) {
if (event.type == SDL_VIDEORESIZE) {
everything_dirty_ = true;
- }
+ }
int mousex, mousey;
+
SDL_GetMouseState(&mousex,&mousey);
const SDL_KeyboardEvent keyboard_event = event.key;
handle_keyboard_event(keyboard_event, mousex, mousey);
const SDL_MouseButtonEvent mouse_button_event = event.button;
handle_mouse_button_event(mouse_button_event, mousex, mousey);
+
+ tooltips::process(mousex, mousey);
}
void map_editor::handle_keyboard_event(const SDL_KeyboardEvent &event,
Index: wesnoth/src/editor/editor.hpp
diff -u wesnoth/src/editor/editor.hpp:1.46 wesnoth/src/editor/editor.hpp:1.47
--- wesnoth/src/editor/editor.hpp:1.46 Tue Jul 12 19:56:39 2005
+++ wesnoth/src/editor/editor.hpp Sun Jul 17 14:01:21 2005
@@ -18,9 +18,11 @@
#include "../display.hpp"
#include "../events.hpp"
+#include "../font.hpp"
#include "../hotkeys.hpp"
#include "../preferences.hpp"
#include "../theme.hpp"
+#include "../tooltips.hpp"
#include <map>
#include <queue>
@@ -273,6 +275,9 @@
/// for brush size.
void draw_on_mouseover_hexes(const gamemap::TERRAIN t);
+ // Load the tooltips for each button
+ void load_tooltips(void);
+
/// An item in the clipboard. Consists of the copied terrain and an
/// offset. When pasting stuff, the offset is used to calculate
/// where to put the pasted hex when calculating from the one
@@ -314,6 +319,9 @@
gamemap::location clipboard_offset_loc_;
LEFT_BUTTON_HELD_FUNC l_button_held_func_;
gamemap::location selection_move_start_;
+
+ tooltips::manager tooltip_manager_;
+ font::floating_label_context floating_label_manager_;
// mouse_moved_ will be true if the mouse have moved between two
// cycles.
bool mouse_moved_;
Index: wesnoth/src/theme.cpp
diff -u wesnoth/src/theme.cpp:1.38 wesnoth/src/theme.cpp:1.39
--- wesnoth/src/theme.cpp:1.38 Sat Jun 4 19:16:06 2005
+++ wesnoth/src/theme.cpp Sun Jul 17 14:01:21 2005
@@ -318,6 +318,11 @@
return relative_loc_;
}
+const SDL_Rect& theme::object::get_location(void) const
+{
+ return loc_;
+}
+
theme::object::ANCHORING theme::object::read_anchor(const std::string& str)
{
static const std::string top_anchor = "top", left_anchor = "left",
@@ -423,6 +428,8 @@
const std::string& theme::menu::image() const { return image_; }
const std::vector<std::string>& theme::menu::items() const { return items_; }
+
+const SDL_Rect& theme::menu::get_location(void) const { return
object::get_location(); }
theme::theme(const config& cfg, const SDL_Rect&
screen):cfg_(resolve_rects(cfg)){
set_resolution(screen);
Index: wesnoth/src/theme.hpp
diff -u wesnoth/src/theme.hpp:1.9 wesnoth/src/theme.hpp:1.10
--- wesnoth/src/theme.hpp:1.9 Sat Jun 4 19:16:06 2005
+++ wesnoth/src/theme.hpp Sun Jul 17 14:01:21 2005
@@ -19,6 +19,7 @@
object(const config& cfg);
SDL_Rect& location(const SDL_Rect& screen) const;
+ const SDL_Rect& get_location(void) const;
//all on-screen objects have 'anchoring' in the x and y
dimensions
//'fixed' means that they have fixed co-ordinates and don't move
@@ -112,6 +113,8 @@
const std::string& image() const;
const std::vector<std::string>& items() const;
+
+ const SDL_Rect& get_location(void) const;
private:
bool context_;
std::string title_, image_;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Wesnoth-cvs-commits] wesnoth/src theme.cpp theme.hpp editor/editor.c...,
Bram Ridder <=