Game Display: don't use resources::tod_manager

This commit is contained in:
Charles Dang 2024-08-31 15:24:21 -04:00
parent 96489728ab
commit c21b049d52
3 changed files with 19 additions and 14 deletions

View file

@ -24,6 +24,7 @@
#include "cursor.hpp"
#include "display_chat_manager.hpp"
#include "fake_unit_manager.hpp"
#include "filter_context.hpp"
#include "floating_label.hpp"
#include "game_board.hpp"
#include "preferences/preferences.hpp"
@ -60,12 +61,14 @@ std::map<map_location, int> game_display::debugHighlights_;
*/
std::vector<texture> footsteps_images(const map_location& loc, const pathfind::marked_route & route_, const display_context * dc_);
game_display::game_display(game_board& board,
game_display::game_display(
const filter_context& fc,
std::weak_ptr<wb::manager> wb,
reports& reports_object,
const std::string& theme_id,
const config& level)
: display(&board, wb, reports_object, theme_id, level)
: display(&fc.get_disp_context(), wb, reports_object, theme_id, level)
, fc_(fc)
, overlay_map_()
, attack_indicator_src_()
, attack_indicator_dst_()
@ -91,8 +94,8 @@ game_display::~game_display()
void game_display::new_turn()
{
if(!first_turn_) {
const time_of_day& tod = resources::tod_manager->get_time_of_day();
const time_of_day& old_tod = resources::tod_manager->get_previous_time_of_day();
const time_of_day& tod = fc_.get_tod_man().get_time_of_day();
const time_of_day& old_tod = fc_.get_tod_man().get_previous_time_of_day();
if(old_tod.image_mask != tod.image_mask) {
fade_tod_mask(old_tod.image_mask, tod.image_mask);
@ -335,12 +338,12 @@ void game_display::draw_hex(const map_location& loc)
const time_of_day& game_display::get_time_of_day(const map_location& loc) const
{
return resources::tod_manager->get_time_of_day(loc);
return fc_.get_tod_man().get_time_of_day(loc);
}
bool game_display::has_time_area() const
{
return resources::tod_manager->has_time_area();
return fc_.get_tod_man().has_time_area();
}
void game_display::layout()

View file

@ -16,13 +16,12 @@
#pragma once
class config;
class game_board;
class filter_context;
#include "display.hpp"
#include "display_chat_manager.hpp"
#include "pathfind/pathfind.hpp"
// This needs to be separate from display.h because of the static
// singleton member, which will otherwise trigger link failure
// when building the editor.
@ -30,11 +29,12 @@ class game_board;
class game_display : public display
{
public:
game_display(game_board& board,
std::weak_ptr<wb::manager> wb,
reports & reports_object,
const std::string& theme_id,
const config& level);
game_display(
const filter_context& fc,
std::weak_ptr<wb::manager> wb,
reports & reports_object,
const std::string& theme_id,
const config& level);
~game_display();
@ -231,6 +231,8 @@ public:
bool maybe_rebuild();
private:
const filter_context& fc_;
overlay_map overlay_map_;
// Locations of the attack direction indicator's parts

View file

@ -239,7 +239,7 @@ void play_controller::init(const config& level)
LOG_NG << "building terrain rules... " << (SDL_GetTicks() - ticks());
gui2::dialogs::loading_screen::progress(loading_stage::build_terrain);
gui_.reset(new game_display(gamestate().board_, whiteboard_manager_, *gamestate().reports_, theme(), level));
gui_.reset(new game_display(gamestate(), whiteboard_manager_, *gamestate().reports_, theme(), level));
map_start_ = map_location(level.child_or_empty("display").child_or_empty("location"));
if(start_faded_) {
gui_->set_fade({0,0,0,255});