Skip to content

Commit

Permalink
Editor Display: override display::get_tod_man and display::get_time_o…
Browse files Browse the repository at this point in the history
…f_day
  • Loading branch information
Vultraz committed Apr 24, 2017
1 parent 4656cbf commit 21add65
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/editor/controller/editor_controller.cpp
Expand Up @@ -66,7 +66,7 @@ editor_controller::editor_controller(const config &game_config, CVideo& video)
, quit_confirmation(std::bind(&editor_controller::quit_confirm, this))
, active_menu_(editor::MAP)
, reports_(new reports())
, gui_(new editor_display(editor::get_dummy_display_context(), video, *reports_, controller_base::get_theme(game_config, "editor"), config()))
, gui_(new editor_display(*this, editor::get_dummy_display_context(), video, *reports_, controller_base::get_theme(game_config, "editor"), config()))
, tods_()
, context_manager_(new context_manager(*gui_.get(), game_config_))
, toolkit_(nullptr)
Expand Down
13 changes: 12 additions & 1 deletion src/editor/editor_display.cpp
Expand Up @@ -13,6 +13,7 @@
*/
#define GETTEXT_DOMAIN "wesnoth-editor"

#include "editor/controller/editor_controller.hpp"
#include "editor/editor_display.hpp"
#include "reports.hpp"
#include "team.hpp"
Expand Down Expand Up @@ -53,11 +54,12 @@ const display_context * get_dummy_display_context() {

// End dummy display context

editor_display::editor_display(const display_context * dc, CVideo& video,
editor_display::editor_display(editor_controller& controller, const display_context * dc, CVideo& video,
reports & reports_object,
const config& theme_cfg, const config& level)
: display(dc, video, std::shared_ptr<wb::manager>(), reports_object, theme_cfg, level)
, brush_locations_()
, controller_(controller)
{
clear_screen();
}
Expand Down Expand Up @@ -149,5 +151,14 @@ void editor_display::draw_sidebar()
}
}

const tod_manager& editor_display::get_tod_man() const
{
return *controller_.get_current_map_context().get_time_manager();
}

const time_of_day& editor_display::get_time_of_day(const map_location& /*loc*/) const
{
return get_tod_man().get_time_of_day();
}

} //end namespace editor
10 changes: 9 additions & 1 deletion src/editor/editor_display.hpp
Expand Up @@ -25,7 +25,7 @@ const display_context * get_dummy_display_context();
class editor_display : public display
{
public:
editor_display(const display_context * dc, CVideo& video,
editor_display(editor_controller& controller, const display_context * dc, CVideo& video,
reports & reports_object,
const config& theme_cfg, const config& level);

Expand All @@ -38,6 +38,12 @@ class editor_display : public display
const editor_map& map() const { return static_cast<const editor_map&>(get_map()); }
void rebuild_terrain(const map_location &loc);

/** Inherited from display. */
virtual const tod_manager& get_tod_man() const override;

/** Inherited from display. */
virtual const time_of_day& get_time_of_day(const map_location& loc = map_location::null_location()) const override;

protected:
void pre_draw();
/**
Expand All @@ -52,6 +58,8 @@ class editor_display : public display

std::set<map_location> brush_locations_;

/* The controller that owns this display. */
editor_controller& controller_;
};

} //end namespace editor
Expand Down

0 comments on commit 21add65

Please sign in to comment.