Author: fendrin
Date: Fri Mar 11 04:04:44 2011
New Revision: 48837
URL: http://svn.gna.org/viewcvs/wesnoth?rev=48837&view=rev
Log:
Added a pointer gui which is a display to resources and made the map_labels use
it.
This seems to work well but it's not tested very much.
Modified:
branches/editor/src/display.cpp
branches/editor/src/editor/editor_controller.cpp
branches/editor/src/map_label.cpp
branches/editor/src/map_label.hpp
branches/editor/src/play_controller.cpp
branches/editor/src/resources.cpp
branches/editor/src/resources.hpp
Modified: branches/editor/src/display.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/branches/editor/src/display.cpp?rev=48837&r1=48836&r2=48837&view=diff
==============================================================================
--- branches/editor/src/display.cpp (original)
+++ branches/editor/src/display.cpp Fri Mar 11 04:04:44 2011
@@ -85,7 +85,7 @@
turbo_speed_(2),
turbo_(false),
invalidateGameStatus_(true),
- map_labels_(new map_labels(*this, 0)),
+ map_labels_(new map_labels(0)),
scroll_event_("scrolled"),
complete_redraw_event_("completely_redrawn"),
nextDraw_(0),
Modified: branches/editor/src/editor/editor_controller.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/branches/editor/src/editor/editor_controller.cpp?rev=48837&r1=48836&r2=48837&view=diff
==============================================================================
--- branches/editor/src/editor/editor_controller.cpp (original)
+++ branches/editor/src/editor/editor_controller.cpp Fri Mar 11 04:04:44 2011
@@ -44,6 +44,9 @@
#include "formula_string_utils.hpp"
#include <boost/bind.hpp>
+
+//TODO sort in
+#include "resources.hpp"
namespace {
static std::vector<std::string> saved_windows_;
@@ -153,6 +156,8 @@
floating_label_manager_.reset(new font::floating_label_context());
gui().set_draw_coordinates(preferences::editor::draw_hex_coordinates());
gui().set_draw_terrain_codes(preferences::editor::draw_terrain_codes());
+ //TODO is that the right place?
+ resources::gui = gui_.get();
}
void editor_controller::init_sidebar(const config& game_config)
Modified: branches/editor/src/map_label.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/branches/editor/src/map_label.cpp?rev=48837&r1=48836&r2=48837&view=diff
==============================================================================
--- branches/editor/src/map_label.cpp (original)
+++ branches/editor/src/map_label.cpp Fri Mar 11 04:04:44 2011
@@ -31,8 +31,8 @@
return disp.shrouded(loc) || disp.shrouded(map_location(loc.x,loc.y+1));
}
-map_labels::map_labels(const display &disp, const team *team) :
- disp_(disp), team_(team), labels_()
+map_labels::map_labels(const team *team) :
+ team_(team), labels_()
{
}
@@ -91,10 +91,10 @@
}
-const display& map_labels::disp() const
-{
- return disp_;
-}
+//const display& map_labels::disp() const
+//{
+// return disp_;
+//}
const std::string& map_labels::team_name() const
{
@@ -421,7 +421,7 @@
if (handle_)
{
- bool shrouded = visible_in_shroud_ || !is_shrouded(parent_->disp(),
loc_);
+ bool shrouded = visible_in_shroud_ || !is_shrouded(*resources::gui,
loc_);
font::show_floating_label(handle_, shrouded);
}
}
@@ -437,9 +437,10 @@
const map_location loc_nextx(loc_.x+1,loc_.y);
const map_location loc_nexty(loc_.x,loc_.y+1);
- const int xloc = (parent_->disp().get_location_x(loc_) +
- parent_->disp().get_location_x(loc_nextx)*2)/3;
- const int yloc = parent_->disp().get_location_y(loc_nexty) -
font::SIZE_NORMAL;
+ display& dsp = *resources::gui;
+ const int xloc = (dsp.get_location_x(loc_) +
+ dsp.get_location_x(loc_nextx)*2)/3;
+ const int yloc = dsp.get_location_y(loc_nexty) - font::SIZE_NORMAL;
// If a color is specified don't allow to override it with markup.
(prevents faking map labels for example)
// FIXME: @todo Better detect if it's team label and not provided by
@@ -449,7 +450,7 @@
font::floating_label flabel(text_.str());
flabel.set_color(color_);
flabel.set_position(xloc, yloc);
- flabel.set_clip_rect(parent_->disp().map_outside_area());
+ flabel.set_clip_rect(dsp.map_outside_area());
flabel.set_width(font::SIZE_NORMAL * 13);
flabel.set_height(font::SIZE_NORMAL * 4);
flabel.set_scroll_mode(font::ANCHOR_LABEL_MAP);
@@ -463,8 +464,9 @@
bool terrain_label::visible() const
{
- if ((!visible_in_fog_ && parent_->disp().fogged(loc_))
- || (!visible_in_shroud_ && parent_->disp().shrouded(loc_))) {
+ display& dsp = *resources::gui;
+ if ((!visible_in_fog_ && dsp.fogged(loc_))
+ || (!visible_in_shroud_ && dsp.shrouded(loc_))) {
return false;
}
Modified: branches/editor/src/map_label.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/branches/editor/src/map_label.hpp?rev=48837&r1=48836&r2=48837&view=diff
==============================================================================
--- branches/editor/src/map_label.hpp (original)
+++ branches/editor/src/map_label.hpp Fri Mar 11 04:04:44 2011
@@ -32,7 +32,7 @@
typedef std::map<map_location, terrain_label *> label_map;
typedef std::map<std::string,label_map> team_label_map;
- map_labels(const display& disp, const team*);
+ map_labels(const team*);
~map_labels();
void write(config& res) const;
@@ -58,7 +58,7 @@
void recalculate_shroud();
- const display& disp() const;
+ //const display& disp() const;
const std::string& team_name() const;
@@ -70,7 +70,7 @@
map_labels(const map_labels&);
void operator=(const map_labels&);
- const display& disp_;
+ //const display& disp_;
const team* team_;
team_label_map labels_;
Modified: branches/editor/src/play_controller.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/branches/editor/src/play_controller.cpp?rev=48837&r1=48836&r2=48837&view=diff
==============================================================================
--- branches/editor/src/play_controller.cpp (original)
+++ branches/editor/src/play_controller.cpp Fri Mar 11 04:04:44 2011
@@ -245,6 +245,7 @@
mouse_handler_.set_gui(gui_.get());
menu_handler_.set_gui(gui_.get());
resources::screen = gui_.get();
+ resources::gui = gui_.get();
theme::set_known_themes(&game_config_);
LOG_NG << "done initializing display... " << (SDL_GetTicks() - ticks_)
<< "\n";
Modified: branches/editor/src/resources.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/branches/editor/src/resources.cpp?rev=48837&r1=48836&r2=48837&view=diff
==============================================================================
--- branches/editor/src/resources.cpp (original)
+++ branches/editor/src/resources.cpp Fri Mar 11 04:04:44 2011
@@ -18,6 +18,7 @@
namespace resources
{
game_display *screen;
+ display *gui;
soundsource::manager *soundsources;
gamemap *game_map;
unit_map *units;
Modified: branches/editor/src/resources.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/branches/editor/src/resources.hpp?rev=48837&r1=48836&r2=48837&view=diff
==============================================================================
--- branches/editor/src/resources.hpp (original)
+++ branches/editor/src/resources.hpp Fri Mar 11 04:04:44 2011
@@ -19,6 +19,7 @@
#include <vector>
class game_display;
+class display;
class gamemap;
class game_state;
class LuaKernel;
@@ -38,6 +39,7 @@
namespace resources
{
extern game_display *screen;
+ extern display *gui;
extern soundsource::manager *soundsources;
extern gamemap *game_map;
extern unit_map *units;
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits