Replace resources::screen with game_display singleton

This is consistent with the use of display::get_singleton() (in fact, it's the same
pointer). It also makes the code more readable, and means we get to further clean up
the resources set.
This commit is contained in:
Charles Dang 2018-01-26 12:33:51 +11:00
parent d11b62590f
commit 786233d5c9
43 changed files with 170 additions and 181 deletions

View file

@ -134,7 +134,7 @@ namespace
}
u = resources::gameboard->units().find(loc);
resources::screen->invalidate_unit();
game_display::get_singleton()->invalidate_unit();
if (animate && u != resources::gameboard->units().end() && !CVideo::get_singleton().update_locked()) {
unit_animator animator;
@ -142,11 +142,11 @@ namespace
animator.start_animations();
animator.wait_for_end();
animator.set_all_standing();
resources::screen->invalidate(loc);
game_display::get_singleton()->invalidate(loc);
events::pump();
}
resources::screen->invalidate_all();
game_display::get_singleton()->invalidate_all();
return true;
}

View file

@ -963,7 +963,7 @@ void attack::fire_event(const std::string& n)
actions::recalculate_fog(defender_side);
if(update_display_) {
resources::screen->redraw_minimap();
game_display::get_singleton()->redraw_minimap();
}
fire_event("attack_end");
@ -1227,7 +1227,7 @@ void attack::unit_killed(unit_info& attacker,
attacker.xp_ = game_config::kill_xp(defender.get_unit().level());
defender.xp_ = 0;
resources::screen->invalidate(attacker.loc_);
game_display::get_singleton()->invalidate(attacker.loc_);
game_events::entity_location death_loc(defender.loc_, defender.id_);
game_events::entity_location attacker_loc(attacker.loc_, attacker.id_);
@ -1321,7 +1321,7 @@ void attack::unit_killed(unit_info& attacker,
preferences::encountered_units().insert(newunit->type_id());
if(update_display_) {
resources::screen->invalidate(death_loc);
game_display::get_singleton()->invalidate(death_loc);
}
}
} else {
@ -1450,7 +1450,7 @@ void attack::perform()
// TODO: if we knew the viewing team, we could skip this display update
if(update_minimap_ && update_display_) {
resources::screen->redraw_minimap();
game_display::get_singleton()->redraw_minimap();
}
if(a_.valid()) {
@ -1469,9 +1469,9 @@ void attack::perform()
d_.loc_, d_.valid() ? &d_.get_unit() : nullptr);
if(update_display_) {
resources::screen->invalidate_unit();
resources::screen->invalidate(a_.loc_);
resources::screen->invalidate(d_.loc_);
game_display::get_singleton()->invalidate_unit();
game_display::get_singleton()->invalidate(a_.loc_);
game_display::get_singleton()->invalidate(d_.loc_);
}
if(OOS_error_) {

View file

@ -663,9 +663,9 @@ place_recruit_result place_recruit(unit_ptr u, const map_location &recruit_locat
}
// Make sure the unit appears (if either !show or the animation is suppressed).
new_unit_itor->set_hidden(false);
if ( resources::screen != nullptr ) {
resources::screen->invalidate(current_loc);
resources::screen->redraw_minimap();
if ( game_display::get_singleton() != nullptr ) {
game_display::get_singleton()->invalidate(current_loc);
game_display::get_singleton()->redraw_minimap();
}
// Village capturing.
@ -724,8 +724,8 @@ void recruit_unit(const unit_type & u_type, int side_num, const map_location & l
}
// Update the screen.
if ( resources::screen != nullptr )
resources::screen->invalidate_game_status();
if ( game_display::get_singleton() != nullptr )
game_display::get_singleton()->invalidate_game_status();
// Other updates were done by place_recruit().
}
@ -771,8 +771,8 @@ bool recall_unit(const std::string & id, team & current_team,
}
// Update the screen.
if ( resources::screen != nullptr )
resources::screen->invalidate_game_status();
if ( game_display::get_singleton() != nullptr )
game_display::get_singleton()->invalidate_game_status();
// Other updates were done by place_recruit().
return true;

View file

@ -238,7 +238,7 @@ namespace {
patient.heal(amount);
else if ( amount < 0 )
patient.take_hit(-amount);
resources::screen->invalidate_unit();
game_display::get_singleton()->invalidate_unit();
}
@ -347,7 +347,7 @@ void calculate_healing(int side, bool update_display)
}
const team & viewing_team =
resources::gameboard->teams()[resources::screen->viewing_team()];
resources::gameboard->teams()[game_display::get_singleton()->viewing_team()];
if (!resources::controller->is_skipping_replay() && update_display &&
patient.is_visible_to_team(viewing_team, *resources::gameboard, false) )
{

View file

@ -174,8 +174,8 @@ game_events::pump_result_t get_village(const map_location& loc, int side, bool *
}
if(not_defeated) {
if (resources::screen != nullptr) {
resources::screen->invalidate(loc);
if (game_display::get_singleton() != nullptr) {
game_display::get_singleton()->invalidate(loc);
}
return t->get_village(loc, old_owner_side, fire_event ? resources::gamedata : nullptr);
}
@ -348,7 +348,7 @@ namespace { // Private helpers for move_unit()
: spectator_(move_spectator)
, skip_sighting_(skip_sightings)
, skip_ally_sighting_(skip_ally_sightings)
, playing_team_is_viewing_(resources::screen->playing_team() == resources::screen->viewing_team() || resources::screen->show_everything())
, playing_team_is_viewing_(game_display::get_singleton()->playing_team() == game_display::get_singleton()->viewing_team() || game_display::get_singleton()->show_everything())
, route_(route)
, begin_(route.begin())
, full_end_(route.end())
@ -510,7 +510,7 @@ namespace { // Private helpers for move_unit()
const route_iterator & step_to,
unit_display::unit_mover & animator)
{
game_display &disp = *resources::screen;
game_display &disp = *game_display::get_singleton();
// Adjust the movement even if we cannot move yet.
// We will eventually be able to move if nothing unexpected
@ -875,7 +875,7 @@ namespace { // Private helpers for move_unit()
{
// Convenient alias:
unit_map &units = resources::gameboard->units();
game_display &disp = *resources::screen;
game_display &disp = *game_display::get_singleton();
// Find the unit at the indicated location.
unit_map::iterator ambusher = units.find(hex);
@ -1105,7 +1105,7 @@ namespace { // Private helpers for move_unit()
}
// Update the screen.
resources::screen->redraw_minimap();
game_display::get_singleton()->redraw_minimap();
}
@ -1115,7 +1115,7 @@ namespace { // Private helpers for move_unit()
void unit_mover::feedback() const
{
// Alias some resources.
game_display &disp = *resources::screen;
game_display &disp = *game_display::get_singleton();
// Multiple messages may be displayed simultaneously
// this variable is used to keep them from overlapping

View file

@ -350,7 +350,7 @@ void undo_list::undo()
const events::command_disabler disable_commands;
game_display & gui = *resources::screen;
game_display & gui = *game_display::get_singleton();
// Get the action to undo. (This will be placed on the redo stack, but
// only if the undo is successful.)
@ -400,7 +400,7 @@ void undo_list::redo()
const events::command_disabler disable_commands;
game_display & gui = *resources::screen;
game_display & gui = *game_display::get_singleton();
// Get the action to redo. (This will be placed on the undo stack, but
// only if the redo is successful.)
@ -437,7 +437,7 @@ void undo_list::redo()
*/
bool undo_list::apply_shroud_changes() const
{
game_display &disp = *resources::screen;
game_display &disp = *game_display::get_singleton();
team &tm = resources::gameboard->get_team(side_);
// No need to do clearing if fog/shroud has been kept up-to-date.
if ( tm.auto_shroud_updates() || !tm.fog_or_shroud() ) {

View file

@ -66,7 +66,7 @@ void move_action::write(config & cfg) const
*/
bool move_action::undo(int)
{
game_display & gui = *resources::screen;
game_display & gui = *game_display::get_singleton();
unit_map & units = resources::gameboard->units();
// Copy some of our stored data.

View file

@ -67,7 +67,7 @@ void recall_action::write(config & cfg) const
*/
bool recall_action::undo(int side)
{
game_display & gui = *resources::screen;
game_display & gui = *game_display::get_singleton();
unit_map & units = resources::gameboard->units();
team &current_team = resources::gameboard->get_team(side);

View file

@ -68,7 +68,7 @@ void recruit_action::write(config & cfg) const
*/
bool recruit_action::undo(int side)
{
game_display & gui = *resources::screen;
game_display & gui = *game_display::get_singleton();
unit_map & units = resources::gameboard->units();
team &current_team = resources::gameboard->get_team(side);

View file

@ -31,13 +31,13 @@
#include "log.hpp"
#include "map/map.hpp"
#include "pathfind/pathfind.hpp"
#include "resources.hpp" // for resources::screen, resources::gamedata
#include "resources.hpp" // for game_display::get_singleton(), resources::gamedata
#include "team.hpp" //for team
#include "units/unit.hpp" // for unit
#include "units/udisplay.hpp" // for unit_display
#include "variable.hpp" // for vconfig
#include "game_display.hpp" // for resources::screen
#include "game_display.hpp" // for game_display::get_singleton()
static lg::log_domain log_engine("engine");
#define DBG_NG LOG_STREAM(debug, log_engine)
@ -221,7 +221,7 @@ void unit_creator::post_create(const map_location &loc, const unit &new_unit, bo
preferences::encountered_units().insert(new_unit.type_id());
}
bool show = show_ && (resources::screen !=nullptr) && !resources::screen->fogged(loc);
bool show = show_ && (game_display::get_singleton() !=nullptr) && !game_display::get_singleton()->fogged(loc);
bool animate = show && anim;
if (get_village_) {
@ -236,10 +236,10 @@ void unit_creator::post_create(const map_location &loc, const unit &new_unit, bo
resources::game_events->pump().fire("unit_placed", loc);
}
if (resources::screen!=nullptr) {
if (game_display::get_singleton()!=nullptr) {
if (invalidate_ ) {
resources::screen->invalidate(loc);
game_display::get_singleton()->invalidate(loc);
}
if (animate) {

View file

@ -272,13 +272,13 @@ bool shroud_clearer::clear_loc(team &tm, const map_location &loc,
// Possible screen invalidation.
if ( was_fogged ) {
resources::screen->invalidate(loc);
game_display::get_singleton()->invalidate(loc);
// Need to also invalidate adjacent hexes to get rid of the
// "fog edge" graphics.
map_location adjacent[6];
get_adjacent_tiles(loc, adjacent);
for ( int i = 0; i != 6; ++i )
resources::screen->invalidate(adjacent[i]);
game_display::get_singleton()->invalidate(adjacent[i]);
}
// Check for units?
@ -336,8 +336,8 @@ bool shroud_clearer::clear_unit(const map_location &view_loc, team &view_team,
move_unit_spectator * spectator, bool instant)
{
// Give animations a chance to progress; see bug #20324.
if ( !instant && resources::screen )
resources::screen->draw(true);
if ( !instant && game_display::get_singleton() )
game_display::get_singleton()->draw(true);
bool cleared_something = false;
// Dummy variables to make some logic simpler.
@ -351,15 +351,15 @@ bool shroud_clearer::clear_unit(const map_location &view_loc, team &view_team,
if ( view_team_ != &view_team ) {
calculate_jamming(&view_team);
// Give animations a chance to progress; see bug #20324.
if ( !instant && resources::screen )
resources::screen->draw(true);
if ( !instant && game_display::get_singleton() )
game_display::get_singleton()->draw(true);
}
// Determine the hexes to clear.
pathfind::vision_path sight(costs, slowed, sight_range, view_loc, jamming_);
// Give animations a chance to progress; see bug #20324.
if ( !instant && resources::screen )
resources::screen->draw(true);
if ( !instant && game_display::get_singleton() )
game_display::get_singleton()->draw(true);
// Clear the fog.
for (const pathfind::paths::step &dest : sight.destinations) {
@ -580,9 +580,9 @@ game_events::pump_result_t shroud_clearer::fire_events()
*/
void shroud_clearer::invalidate_after_clear()
{
resources::screen->invalidate_game_status();
resources::screen->recalculate_minimap();
resources::screen->labels().recalculate_shroud();
game_display::get_singleton()->invalidate_game_status();
game_display::get_singleton()->recalculate_minimap();
game_display::get_singleton()->labels().recalculate_shroud();
// The tiles are invalidated as they are cleared, so no need
// to invalidate them here.
}
@ -721,7 +721,7 @@ void recalculate_fog(int side)
tm.refog();
// Invalidate the screen before clearing the shroud.
// This speeds up the invalidations within clear_shroud_unit().
resources::screen->invalidate_all();
game_display::get_singleton()->invalidate_all();
shroud_clearer clearer;
for (const unit &u : resources::gameboard->units())

View file

@ -326,7 +326,7 @@ game_info& readwrite_context_impl::get_info_w(){
void readonly_context_impl::diagnostic(const std::string& msg)
{
if(game_config::debug) {
resources::screen->set_diagnostic(msg);
game_display::get_singleton()->set_diagnostic(msg);
}
}
@ -340,7 +340,7 @@ const team& readonly_context_impl::current_team() const
void readonly_context_impl::log_message(const std::string& msg)
{
if(game_config::debug) {
resources::screen->get_chat_manager().add_chat_message(time(nullptr), "ai", get_side(), msg,
game_display::get_singleton()->get_chat_manager().add_chat_message(time(nullptr), "ai", get_side(), msg,
events::chat_handler::MESSAGE_PUBLIC, false);
}
}

View file

@ -732,10 +732,10 @@ void recruitment::show_important_hexes() const {
if (!game_config::debug) {
return;
}
resources::screen->labels().clear_all();
game_display::get_singleton()->labels().clear_all();
for (const map_location& loc : important_hexes_) {
// Little hack: use map_location north from loc and make 2 linebreaks to center the "X".
resources::screen->labels().set_label(loc.get_direction(map_location::NORTH), "\n\nX");
game_display::get_singleton()->labels().set_label(loc.get_direction(map_location::NORTH), "\n\nX");
}
}

View file

@ -135,7 +135,7 @@ void formula_ai::handle_exception(formula_error& e, const std::string& failed_op
void formula_ai::display_message(const std::string& msg) const
{
resources::screen->get_chat_manager().add_chat_message(time(nullptr), "wfl", get_side(), msg,
game_display::get_singleton()->get_chat_manager().add_chat_message(time(nullptr), "wfl", get_side(), msg,
events::chat_handler::MESSAGE_PUBLIC, false);
}

View file

@ -21,7 +21,6 @@
#include "game_display.hpp"
#include "log.hpp"
#include "resources.hpp"
static lg::log_domain log_arrows("arrows");
#define ERR_ARR LOG_STREAM(err, log_arrows)
@ -29,7 +28,7 @@ static lg::log_domain log_arrows("arrows");
#define LOG_ARR LOG_STREAM(info, log_arrows)
#define DBG_ARR LOG_STREAM(debug, log_arrows)
#define SCREEN (static_cast<display*>(resources::screen))
#define SCREEN (static_cast<display*>(game_display::get_singleton()))
arrow::arrow(bool hidden)
: layer_(display::LAYER_ARROWS)

View file

@ -99,8 +99,8 @@ void editor_action_item_replace::perform_without_undo(map_context& /*mc*/) const
// */
//
////TODO check if that is useful
//// resources::screen->invalidate_item_after_move(loc_, new_loc_);
//// resources::screen->draw();
//// game_display::get_singleton()->invalidate_item_after_move(loc_, new_loc_);
//// game_display::get_singleton()->draw();
}
IMPLEMENT_ACTION(item_facing)

View file

@ -103,8 +103,8 @@ void editor_action_unit_replace::perform_without_undo(map_context& mc) const
*/
// TODO check if that is useful
// resources::screen->invalidate_unit_after_move(loc_, new_loc_);
// resources::screen->draw();
// game_display::get_singleton()->invalidate_unit_after_move(loc_, new_loc_);
// game_display::get_singleton()->draw();
}
IMPLEMENT_ACTION(unit_facing)

View file

@ -21,7 +21,6 @@
#include "game_display.hpp"
#include "preferences/game.hpp"
#include "log.hpp"
#include "resources.hpp"
#include <ctime>
@ -139,7 +138,7 @@ namespace gui{
text.append(line_start ? ": " : " ");
} else if (matches.size() > 1) {
std::string completion_list = utils::join(matches, " ");
resources::screen->get_chat_manager().add_chat_message(time(nullptr), "", 0, completion_list,
game_display::get_singleton()->get_chat_manager().add_chat_message(time(nullptr), "", 0, completion_list,
events::chat_handler::MESSAGE_PRIVATE, false);
}
box_->set_text(text);

View file

@ -23,7 +23,6 @@
#include "formula/function.hpp"
#include "game_display.hpp"
#include "log.hpp"
#include "resources.hpp"
#include "gui/dialogs/formula_debugger.hpp"
#include "gui/widgets/settings.hpp"
@ -153,7 +152,7 @@ void formula_debugger::check_breakpoints()
void formula_debugger::show_gui()
{
if (resources::screen == nullptr) {
if (game_display::get_singleton() == nullptr) {
WRN_FDB << "do not showing debug window due to nullptr gui" << std::endl;
return;
}

View file

@ -368,7 +368,7 @@ WML_HANDLER_FUNCTION(modify_turns,, cfg)
ERR_NG << "attempted to change current turn number to one out of range (" << new_turn_number << ")" << std::endl;
} else if(new_turn_number_u != current_turn_number) {
tod_man.set_turn_by_wml(new_turn_number_u, resources::gamedata);
resources::screen->new_turn();
game_display::get_singleton()->new_turn();
}
}
}
@ -634,8 +634,8 @@ WML_HANDLER_FUNCTION(replace_map,, cfg)
lg::wml_error() << *errmsg << std::endl;
}
resources::screen->reload_map();
resources::screen->needs_rebuild(true);
game_display::get_singleton()->reload_map();
game_display::get_singleton()->needs_rebuild(true);
ai::manager::get_singleton().raise_map_changed();
}
@ -882,7 +882,7 @@ WML_HANDLER_FUNCTION(terrain_mask,, cfg)
}
resources::gameboard->overlay_map(mask_map, cfg.get_parsed_config(), loc);
resources::screen->needs_rebuild(true);
game_display::get_singleton()->needs_rebuild(true);
}
WML_HANDLER_FUNCTION(tunnel,, cfg)

View file

@ -308,8 +308,8 @@ void wml_event_pump::process_event(handler_ptr& handler_p, const queued_event& e
resources::gamedata->last_selected = ev.loc1;
}
if(resources::screen != nullptr) {
resources::screen->maybe_rebuild();
if(game_display::get_singleton() != nullptr) {
game_display::get_singleton()->maybe_rebuild();
}
}
@ -365,7 +365,7 @@ void wml_event_pump::show_wml_messages(std::stringstream& source, const std::str
msg << " (" << itor->second << ")";
}
resources::screen->get_chat_manager().add_chat_message(
game_display::get_singleton()->get_chat_manager().add_chat_message(
time(nullptr), caption, 0, msg.str(), events::chat_handler::MESSAGE_PUBLIC, false);
if(to_cerr) {
@ -511,7 +511,7 @@ void wml_event_pump::raise(const std::string& event,
const entity_location& loc2,
const config& data)
{
if(resources::screen == nullptr)
if(game_display::get_singleton() == nullptr)
return;
DBG_EH << "raising event name=" << event << ", id=" << id << "\n";
@ -522,7 +522,7 @@ void wml_event_pump::raise(const std::string& event,
pump_result_t wml_event_pump::operator()()
{
// Quick aborts:
if(resources::screen == nullptr) {
if(game_display::get_singleton() == nullptr) {
return pump_result_t();
}
@ -621,7 +621,7 @@ pump_result_t wml_event_pump::operator()()
void wml_event_pump::flush_messages()
{
// Dialogs can only be shown if the display is not locked
if(resources::screen && !CVideo::get_singleton().update_locked()) {
if(game_display::get_singleton() && !CVideo::get_singleton().update_locked()) {
show_wml_errors();
show_wml_messages();
}

View file

@ -21,7 +21,6 @@
#include "game_display.hpp"
#include "font/text_formatting.hpp"
#include "map/label.hpp"
#include "resources.hpp"
#include "gui/auxiliary/find_widget.hpp"
#include "gui/widgets/styled_widget.hpp"
#ifdef GUI2_EXPERIMENTAL_LISTBOX
@ -43,7 +42,7 @@ namespace dialogs
REGISTER_DIALOG(label_settings)
label_settings::label_settings(display_context& dc) : viewer(dc) {
const std::vector<std::string>& all_categories = resources::screen->labels().all_categories();
const std::vector<std::string>& all_categories = game_display::get_singleton()->labels().all_categories();
const std::vector<std::string>& hidden_categories = viewer.hidden_label_categories();
for(size_t i = 0; i < all_categories.size(); i++) {

View file

@ -35,7 +35,6 @@
#include "gui/widgets/window.hpp"
#include "log.hpp"
#include "menu_events.hpp"
#include "resources.hpp"
#include "team.hpp"
#include "utils/functional.hpp"
@ -130,7 +129,7 @@ void mp_change_control::pre_show(window& window)
}
}
const std::set<std::string>& observers = resources::screen->observers();
const std::set<std::string>& observers = game_display::get_singleton()->observers();
temp_nicks.insert(observers.begin(), observers.end());
// In case we are an observer, it isn't in the observers set and has to be added manually.

View file

@ -84,7 +84,7 @@ surface getMinimap(int w, int h, const gamemap &map, const team *vw, const std::
if(!map.on_board_with_border(loc))
continue;
const bool shrouded = (resources::screen != nullptr && resources::screen->is_blindfolded()) || (vw != nullptr && vw->shrouded(loc));
const bool shrouded = (game_display::get_singleton() != nullptr && game_display::get_singleton()->is_blindfolded()) || (vw != nullptr && vw->shrouded(loc));
// shrouded hex are not considered fogged (no need to fog a black image)
const bool fogged = (vw != nullptr && !shrouded && vw->fogged(loc));

View file

@ -580,7 +580,7 @@ vision_path::vision_path(const unit& viewer, const map_location& loc,
// The three nullptr parameters indicate (in order):
// ignore units, ignore ZoC (no effect), and don't build a cost_map.
const team& viewing_team = resources::gameboard->teams()[resources::screen->viewing_team()];
const team& viewing_team = resources::gameboard->teams()[game_display::get_singleton()->viewing_team()];
find_routes(loc, viewer.movement_type().get_vision(),
viewer.get_state(unit::STATE_SLOWED), sight_range, sight_range,
0, destinations, &edges, &viewer, nullptr, nullptr, &viewing_team, &jamming_map, nullptr, true);
@ -604,7 +604,7 @@ vision_path::vision_path(const movetype::terrain_costs & view_costs, bool slowed
{
// The three nullptr parameters indicate (in order):
// ignore units, ignore ZoC (no effect), and don't build a cost_map.
const team& viewing_team = resources::gameboard->teams()[resources::screen->viewing_team()];
const team& viewing_team = resources::gameboard->teams()[game_display::get_singleton()->viewing_team()];
const unit_map::const_iterator u = resources::gameboard->units().find(loc);
find_routes(loc, view_costs, slowed, sight_range, sight_range, 0,
destinations, &edges, u.valid() ? &*u : nullptr, nullptr, nullptr, &viewing_team, &jamming_map, nullptr, true);
@ -667,7 +667,7 @@ marked_route mark_route(const plain_route &rt)
assert(last_step || resources::gameboard->map().on_board(*(i+1)));
const int move_cost = last_step ? 0 : u.movement_cost((resources::gameboard->map())[*(i+1)]);
const team& viewing_team = resources::gameboard->teams()[resources::screen->viewing_team()];
const team& viewing_team = resources::gameboard->teams()[game_display::get_singleton()->viewing_team()];
if (last_step || zoc || move_cost > movement) {
// check if we stop an a village and so maybe capture it

View file

@ -120,7 +120,6 @@ static void clear_resources()
resources::game_events = nullptr;
resources::lua_kernel = nullptr;
resources::persist = nullptr;
resources::screen = nullptr;
resources::soundsources = nullptr;
resources::tod_manager = nullptr;
resources::tunnels = nullptr;
@ -249,7 +248,6 @@ void play_controller::init(const config& level)
gui2::dialogs::loading_screen::progress(loading_stage::init_display);
mouse_handler_.set_gui(gui_.get());
menu_handler_.set_gui(gui_.get());
resources::screen = gui_.get();
LOG_NG << "done initializing display... " << (SDL_GetTicks() - ticks()) << std::endl;

View file

@ -132,23 +132,23 @@ turn_info::PROCESS_DATA_RESULT turn_info::process_network_data(const config& cfg
if (const config &message = cfg.child("message"))
{
resources::screen->get_chat_manager().add_chat_message(time(nullptr), message["sender"], message["side"],
game_display::get_singleton()->get_chat_manager().add_chat_message(time(nullptr), message["sender"], message["side"],
message["message"], events::chat_handler::MESSAGE_PUBLIC,
preferences::message_bell());
}
else if (const config &whisper = cfg.child("whisper") /*&& is_observer()*/)
{
resources::screen->get_chat_manager().add_chat_message(time(nullptr), "whisper: " + whisper["sender"].str(), 0,
game_display::get_singleton()->get_chat_manager().add_chat_message(time(nullptr), "whisper: " + whisper["sender"].str(), 0,
whisper["message"], events::chat_handler::MESSAGE_PRIVATE,
preferences::message_bell());
}
else if (const config &observer = cfg.child("observer") )
{
resources::screen->get_chat_manager().add_observer(observer["name"]);
game_display::get_singleton()->get_chat_manager().add_observer(observer["name"]);
}
else if (const config &observer_quit = cfg.child("observer_quit"))
{
resources::screen->get_chat_manager().remove_observer(observer_quit["name"]);
game_display::get_singleton()->get_chat_manager().remove_observer(observer_quit["name"]);
}
else if (cfg.child("leave_game")) {
throw ingame_wesnothd_error("");
@ -186,21 +186,21 @@ turn_info::PROCESS_DATA_RESULT turn_info::process_network_data(const config& cfg
resources::controller->on_not_observer();
}
if (resources::gameboard->is_observer() || (resources::gameboard->teams())[resources::screen->playing_team()].is_local_human()) {
resources::screen->set_team(resources::screen->playing_team());
resources::screen->redraw_everything();
resources::screen->recalculate_minimap();
if (resources::gameboard->is_observer() || (resources::gameboard->teams())[game_display::get_singleton()->playing_team()].is_local_human()) {
game_display::get_singleton()->set_team(game_display::get_singleton()->playing_team());
game_display::get_singleton()->redraw_everything();
game_display::get_singleton()->recalculate_minimap();
} else if (tm.is_local_human()) {
resources::screen->set_team(side - 1);
resources::screen->redraw_everything();
resources::screen->recalculate_minimap();
game_display::get_singleton()->set_team(side - 1);
game_display::get_singleton()->redraw_everything();
game_display::get_singleton()->recalculate_minimap();
}
resources::whiteboard->on_change_controller(side,tm);
resources::screen->labels().recalculate_labels();
game_display::get_singleton()->labels().recalculate_labels();
const bool restart = resources::screen->playing_side() == side && (was_local || tm.is_local());
const bool restart = game_display::get_singleton()->playing_side() == side && (was_local || tm.is_local());
return restart ? PROCESS_RESTART_TURN : PROCESS_CONTINUE;
}
@ -209,7 +209,7 @@ turn_info::PROCESS_DATA_RESULT turn_info::process_network_data(const config& cfg
const int side_drop = side_drop_c["side_num"].to_int(0);
size_t index = side_drop -1;
bool restart = side_drop == resources::screen->playing_side();
bool restart = side_drop == game_display::get_singleton()->playing_side();
if (index >= resources::gameboard->teams().size()) {
ERR_NW << "unknown side " << side_drop << " is dropping game" << std::endl;
@ -267,7 +267,7 @@ turn_info::PROCESS_DATA_RESULT turn_info::process_network_data(const config& cfg
first_observer_option_idx = options.size();
//get all observers in as options to transfer control
for (const std::string &screen_observers : resources::screen->observers()) {
for (const std::string &screen_observers : game_display::get_singleton()->observers()) {
t_vars["player"] = screen_observers;
options.emplace_back(vgettext("Give control to observer $player", t_vars));
observers.push_back(screen_observers);
@ -347,7 +347,7 @@ turn_info::PROCESS_DATA_RESULT turn_info::process_network_data(const config& cfg
// The host has ended linger mode in a campaign -> enable the "End scenario" button
// and tell we did get the notification.
else if (cfg.child("notify_next_scenario")) {
std::shared_ptr<gui::button> btn_end = resources::screen->find_action_button("button-endturn");
std::shared_ptr<gui::button> btn_end = game_display::get_singleton()->find_action_button("button-endturn");
if(btn_end) {
btn_end->enable(true);
}

View file

@ -126,8 +126,8 @@ bool show_theme_dialog()
if (action >= 0) {
preferences::set_theme(themes[action].id);
if(resources::screen && resources::controller && resources::gamedata && resources::gamedata->get_theme().empty()) {
resources::screen->set_theme(resources::controller->get_theme(game_config_manager::get()->game_config(), themes[action].id));
if(game_display::get_singleton() && resources::controller && resources::gamedata && resources::gamedata->get_theme().empty()) {
game_display::get_singleton()->set_theme(resources::controller->get_theme(game_config_manager::get()->game_config(), themes[action].id));
}
return true;

View file

@ -668,7 +668,7 @@ REPLAY_RETURN do_replay(bool one_move)
log_scope("do replay");
if (!resources::controller->is_skipping_replay()) {
resources::screen->recalculate_minimap();
game_display::get_singleton()->recalculate_minimap();
}
update_locker lock_update(CVideo::get_singleton(), resources::controller->is_skipping_replay());
@ -725,7 +725,7 @@ REPLAY_RETURN do_replay_handle(bool one_move)
DBG_REPLAY << "tried to add a chat message twice.\n";
if (!resources::controller->is_skipping_replay() || is_whisper) {
int side = speak["side"];
resources::screen->get_chat_manager().add_chat_message(get_time(speak), speaker_name, side, message,
game_display::get_singleton()->get_chat_manager().add_chat_message(get_time(speak), speaker_name, side, message,
(team_name.empty() ? events::chat_handler::MESSAGE_PUBLIC
: events::chat_handler::MESSAGE_PRIVATE),
preferences::message_bell());
@ -734,9 +734,9 @@ REPLAY_RETURN do_replay_handle(bool one_move)
}
else if (const config &label_config = cfg->child("label"))
{
terrain_label label(resources::screen->labels(), label_config);
terrain_label label(game_display::get_singleton()->labels(), label_config);
resources::screen->labels().set_label(label.location(),
game_display::get_singleton()->labels().set_label(label.location(),
label.text(),
label.creator(),
label.team_name(),
@ -744,7 +744,7 @@ REPLAY_RETURN do_replay_handle(bool one_move)
}
else if (const config &clear_labels = cfg->child("clear_labels"))
{
resources::screen->labels().clear(std::string(clear_labels["team_name"]), clear_labels["force"].to_bool());
game_display::get_singleton()->labels().clear(std::string(clear_labels["team_name"]), clear_labels["force"].to_bool());
}
else if (const config &rename = cfg->child("rename"))
{

View file

@ -24,7 +24,6 @@ namespace resources
game_events::manager *game_events = nullptr;
game_lua_kernel *lua_kernel = nullptr;
persist_manager *persist = nullptr;
game_display *screen = nullptr;
soundsource::manager *soundsources = nullptr;
replay *recorder = nullptr;
::tod_manager *tod_manager = nullptr;

View file

@ -18,7 +18,6 @@
#include <vector>
class game_board;
class game_display;
class game_data;
class filter_context;
class game_lua_kernel;
@ -51,7 +50,6 @@ namespace resources
extern game_lua_kernel *lua_kernel; // Set by game_events::manager.
extern persist_manager *persist;
extern game_classification *classification;
extern game_display *screen;
extern filter_context *filter_con;
extern soundsource::manager *soundsources;
extern replay *recorder;

View file

@ -29,7 +29,6 @@
#include "variable.hpp" // for vconfig
#include "log.hpp"
#include "gettext.hpp"
#include "resources.hpp"
#include "lua_jailbreak_exception.hpp"
#include "game_display.hpp"
@ -923,8 +922,8 @@ bool luaW_checkvariable(lua_State *L, variable_access_create& v, int n)
void chat_message(const std::string& caption, const std::string& msg)
{
if (!resources::screen) return;
resources::screen->get_chat_manager().add_chat_message(time(nullptr), caption, 0, msg,
if (!game_display::get_singleton()) return;
game_display::get_singleton()->get_chat_manager().add_chat_message(time(nullptr), caption, 0, msg,
events::chat_handler::MESSAGE_PUBLIC, false);
}

View file

@ -394,7 +394,7 @@ namespace
symbols["player"] = resources::controller->current_team().current_player();
display::announce_options announce_options;
announce_options.lifetime = 1000;
resources::screen->announce(vgettext(message, symbols), font::NORMAL_COLOR, announce_options);
game_display::get_singleton()->announce(vgettext(message, symbols), font::NORMAL_COLOR, announce_options);
}
}
SYNCED_COMMAND_HANDLER_FUNCTION(debug_unit, child, use_undo, /*show*/, /*error_handler*/)
@ -456,8 +456,8 @@ SYNCED_COMMAND_HANDLER_FUNCTION(debug_unit, child, use_undo, /*show*/, /*error_
if (name == "fail") { //testcase for bug #18488
assert(i.valid());
}
resources::screen->invalidate(loc);
resources::screen->invalidate_unit();
game_display::get_singleton()->invalidate(loc);
game_display::get_singleton()->invalidate_unit();
return true;
}
@ -485,7 +485,7 @@ SYNCED_COMMAND_HANDLER_FUNCTION(debug_create_unit, child, use_undo, /*show*/, e
created->new_turn();
// Add the unit to the board.
std::pair<unit_map::iterator, bool> add_result = resources::gameboard->units().replace(loc, created);
resources::screen->invalidate_unit();
game_display::get_singleton()->invalidate_unit();
resources::game_events->pump().fire("unit_placed", loc);
unit_display::unit_recruited(loc);
@ -531,7 +531,7 @@ SYNCED_COMMAND_HANDLER_FUNCTION(debug_kill, child, use_undo, /*show*/, /*error_h
if (i.valid()) {
unit_display::unit_die(loc, *i);
}
resources::screen->redraw_minimap();
game_display::get_singleton()->redraw_minimap();
if (i.valid()) {
i->set_hitpoints(0);
}
@ -578,7 +578,7 @@ SYNCED_COMMAND_HANDLER_FUNCTION(debug_turn_limit, child, use_undo, /*show*/, /*e
debug_notification(":turn_limit debug command was used during turn of $player");
resources::tod_manager->set_number_of_turns(child["turn_limit"].to_int(-1));
resources::screen->redraw_everything();
game_display::get_singleton()->redraw_everything();
return true;
}
@ -592,8 +592,8 @@ SYNCED_COMMAND_HANDLER_FUNCTION(debug_turn, child, use_undo, /*show*/, /*error_h
resources::tod_manager->set_turn(child["turn"].to_int(1), resources::gamedata);
resources::screen->new_turn();
resources::screen->redraw_everything();
game_display::get_singleton()->new_turn();
game_display::get_singleton()->redraw_everything();
return true;
}
@ -625,7 +625,7 @@ SYNCED_COMMAND_HANDLER_FUNCTION(debug_gold, child, use_undo, /*show*/, /*error_h
debug_notification(":gold debug command was used during turn of $player");
resources::controller->current_team().spend_gold(-child["gold"].to_int(0));
resources::screen->redraw_everything();
game_display::get_singleton()->redraw_everything();
return true;
}
@ -639,7 +639,7 @@ SYNCED_COMMAND_HANDLER_FUNCTION(debug_event, child, use_undo, /*show*/, /*error_
debug_notification(":throw debug command was used during turn of $player");
resources::controller->pump().fire(child["eventname"]);
resources::screen->redraw_everything();
game_display::get_singleton()->redraw_everything();
return true;
}
@ -657,8 +657,8 @@ SYNCED_COMMAND_HANDLER_FUNCTION(debug_fog, /*child*/, use_undo, /*show*/, /*erro
current_team.set_fog(!current_team.uses_fog());
actions::recalculate_fog(current_team.side());
resources::screen->recalculate_minimap();
resources::screen->redraw_everything();
game_display::get_singleton()->recalculate_minimap();
game_display::get_singleton()->redraw_everything();
return true;
}
@ -676,8 +676,8 @@ SYNCED_COMMAND_HANDLER_FUNCTION(debug_shroud, /*child*/, use_undo, /*show*/, /*e
current_team.set_shroud(!current_team.uses_shroud());
actions::clear_shroud(current_team.side());
resources::screen->recalculate_minimap();
resources::screen->redraw_everything();
game_display::get_singleton()->recalculate_minimap();
game_display::get_singleton()->redraw_everything();
return true;
}

View file

@ -79,7 +79,7 @@ namespace
void start_show_label()
{
assert(label_id_ == -1);
SDL_Rect area = resources::screen->map_outside_area();
SDL_Rect area = game_display::get_singleton()->map_outside_area();
font::floating_label flabel(message_);
flabel.set_font_size(font::SIZE_XLARGE);
flabel.set_color(font::NORMAL_COLOR);

View file

@ -86,7 +86,7 @@ attack::attack(const config& cfg, bool hidden)
void attack::init()
{
resources::screen->invalidate(target_hex_);
game_display::get_singleton()->invalidate(target_hex_);
}
attack::~attack()
@ -102,11 +102,11 @@ void attack::accept(visitor& v)
/* private */
void attack::invalidate()
{
if(resources::screen)
if(game_display::get_singleton())
{
//invalidate dest and target hex so attack indicator is properly cleared
resources::screen->invalidate(get_dest_hex());
resources::screen->invalidate(target_hex_);
game_display::get_singleton()->invalidate(get_dest_hex());
game_display::get_singleton()->invalidate(target_hex_);
}
}
@ -200,18 +200,18 @@ void attack::draw_hex(const map_location& hex)
if (hex == get_dest_hex()) //add symbol to attacker hex
{
int xpos = resources::screen->get_location_x(get_dest_hex());
int ypos = resources::screen->get_location_y(get_dest_hex());
int xpos = game_display::get_singleton()->get_location_x(get_dest_hex());
int ypos = game_display::get_singleton()->get_location_y(get_dest_hex());
resources::screen->drawing_buffer_add(layer, get_dest_hex(), xpos, ypos,
game_display::get_singleton()->drawing_buffer_add(layer, get_dest_hex(), xpos, ypos,
image::get_image("whiteboard/attack-indicator-src-" + direction_text + ".png", image::SCALED_TO_HEX));
}
else if (hex == target_hex_) //add symbol to defender hex
{
int xpos = resources::screen->get_location_x(target_hex_);
int ypos = resources::screen->get_location_y(target_hex_);
int xpos = game_display::get_singleton()->get_location_x(target_hex_);
int ypos = game_display::get_singleton()->get_location_y(target_hex_);
resources::screen->drawing_buffer_add(layer, target_hex_, xpos, ypos,
game_display::get_singleton()->drawing_buffer_add(layer, target_hex_, xpos, ypos,
image::get_image("whiteboard/attack-indicator-dst-" + direction_text + ".png", image::SCALED_TO_HEX));
}
}
@ -220,7 +220,7 @@ void attack::draw_hex(const map_location& hex)
void attack::redraw()
{
move::redraw();
resources::screen->invalidate(target_hex_);
game_display::get_singleton()->invalidate(target_hex_);
}
action::error attack::check_validity() const

View file

@ -64,7 +64,7 @@ highlighter::highlighter(side_actions_ptr side_actions)
highlighter::~highlighter()
{
try {
if(resources::screen && owner_unit_) {
if(game_display::get_singleton() && owner_unit_) {
unhighlight();
}
} catch (...) {}
@ -146,7 +146,7 @@ void highlighter::highlight()
find_secondary_highlights();
//Make sure owner unit is the only one displayed in its hex
resources::screen->add_exclusive_draw(owner_unit_->get_location(), *owner_unit_);
game_display::get_singleton()->add_exclusive_draw(owner_unit_->get_location(), *owner_unit_);
exclusive_display_hexes_.insert(owner_unit_->get_location());
if(!secondary_highlights_.empty()) {
@ -179,7 +179,7 @@ void highlighter::unhighlight()
//unhide other units if needed
for(map_location hex : exclusive_display_hexes_) {
resources::screen->remove_exclusive_draw(hex);
game_display::get_singleton()->remove_exclusive_draw(hex);
}
exclusive_display_hexes_.clear();
}
@ -225,7 +225,7 @@ void highlighter::find_main_highlight()
assert(main_highlight_.expired());
//@todo re-enable the following assert once I find out what happends to
// viewing side assignments after victory
//assert(side_actions_->team_index() == resources::screen->viewing_team());
//assert(side_actions_->team_index() == game_display::get_singleton()->viewing_team());
main_highlight_ = find_action_at(mouseover_hex_);
if(action_ptr main = main_highlight_.lock()) {
@ -293,7 +293,7 @@ void highlighter::highlight_main_visitor::visit(move_ptr move)
///@todo find some highlight animation
move->get_fake_unit()->anim_comp().set_ghosted(true);
//Make sure the fake unit is the only one displayed in its hex
resources::screen->add_exclusive_draw(move->get_fake_unit()->get_location(), *move->get_fake_unit());
game_display::get_singleton()->add_exclusive_draw(move->get_fake_unit()->get_location(), *move->get_fake_unit());
highlighter_.exclusive_display_hexes_.insert(move->get_fake_unit()->get_location());
highlighter_.last_action_redraw(move);
@ -312,7 +312,7 @@ void highlighter::highlight_main_visitor::visit(recruit_ptr recruit)
///@todo: find some suitable effect for mouseover on planned recruit.
//Make sure the fake unit is the only one displayed in its hex
resources::screen->add_exclusive_draw(recruit->get_fake_unit()->get_location(), *recruit->get_fake_unit());
game_display::get_singleton()->add_exclusive_draw(recruit->get_fake_unit()->get_location(), *recruit->get_fake_unit());
highlighter_.exclusive_display_hexes_.insert(recruit->get_fake_unit()->get_location());
}
}
@ -325,7 +325,7 @@ void highlighter::highlight_secondary_visitor::visit(move_ptr move)
if(move->get_fake_unit()) {
move->get_fake_unit()->anim_comp().set_ghosted(true);
//Make sure the fake unit is the only one displayed in its hex
resources::screen->add_exclusive_draw(move->get_fake_unit()->get_location(), *move->get_fake_unit());
game_display::get_singleton()->add_exclusive_draw(move->get_fake_unit()->get_location(), *move->get_fake_unit());
highlighter_.exclusive_display_hexes_.insert(move->get_fake_unit()->get_location());
highlighter_.last_action_redraw(move);
@ -360,7 +360,7 @@ void highlighter::unhighlight_visitor::visit(recall_ptr recall)
//@todo: find some suitable effect for mouseover on planned recall.
//Make sure the fake unit is the only one displayed in its hex
resources::screen->add_exclusive_draw(recall->get_fake_unit()->get_location(), *recall->get_fake_unit());
game_display::get_singleton()->add_exclusive_draw(recall->get_fake_unit()->get_location(), *recall->get_fake_unit());
highlighter_.exclusive_display_hexes_.insert(recall->get_fake_unit()->get_location());
}
}

View file

@ -97,7 +97,7 @@ manager::~manager()
#if 0
static void print_to_chat(const std::string& title, const std::string& message)
{
resources::screen->add_chat_message(time(nullptr), title, 0, message,
game_display::get_singleton()->add_chat_message(time(nullptr), title, 0, message,
events::chat_handler::MESSAGE_PRIVATE, false);
}
#endif
@ -469,7 +469,7 @@ static void draw_numbers(const map_location& hex, side_actions::numbers_t number
color_t color = team::get_side_color(static_cast<int>(team_numbers[i]+1));
const double x_in_hex = x_origin + x_offset;
const double y_in_hex = y_origin + y_offset;
resources::screen->draw_text_in_hex(hex, display::LAYER_ACTIONS_NUMBERING,
game_display::get_singleton()->draw_text_in_hex(hex, display::LAYER_ACTIONS_NUMBERING,
number_text, font_size, color, x_in_hex, y_in_hex);
x_offset += x_offset_base;
y_offset += y_offset_base;
@ -601,7 +601,7 @@ void manager::on_gamestate_change()
// Set mutated flag so action queue gets validated on next future map build
gamestate_mutated_ = true;
//Clear exclusive draws that might not get a chance to be cleared the normal way
resources::screen->clear_exclusive_draws();
game_display::get_singleton()->clear_exclusive_draws();
}
void manager::send_network_data()
@ -669,7 +669,7 @@ void manager::create_temp_move()
if (!temp_moved_unit) temp_moved_unit =
future_visible_unit(resources::controller->get_mouse_handler_base().get_last_hex(), viewer_side());
if (!temp_moved_unit) return;
if (temp_moved_unit->side() != resources::screen->viewing_side()) return;
if (temp_moved_unit->side() != game_display::get_singleton()->viewing_side()) return;
/*
* DONE CHECKING PRE-CONDITIONS, CREATE THE TEMP MOVE
@ -847,8 +847,8 @@ void manager::save_temp_attack(const map_location& attacker_loc, const map_locat
print_help_once();
resources::screen->invalidate(defender_loc);
resources::screen->invalidate(attacker_loc);
game_display::get_singleton()->invalidate(defender_loc);
game_display::get_singleton()->invalidate(attacker_loc);
erase_temp_move();
LOG_WB << *viewer_actions() << "\n";
}
@ -859,7 +859,7 @@ bool manager::save_recruit(const std::string& name, int side_num, const map_loca
bool created_planned_recruit = false;
if (active_ && !executing_actions_ && !resources::controller->is_linger_mode()) {
if (side_num != resources::screen->viewing_side())
if (side_num != game_display::get_singleton()->viewing_side())
{
LOG_WB <<"manager::save_recruit called for a different side than viewing side.\n";
created_planned_recruit = false;
@ -888,7 +888,7 @@ bool manager::save_recall(const unit& unit, int side_num, const map_location& re
if (active_ && !executing_actions_ && !resources::controller->is_linger_mode())
{
if (side_num != resources::screen->viewing_side())
if (side_num != game_display::get_singleton()->viewing_side())
{
LOG_WB <<"manager::save_recall called for a different side than viewing side.\n";
created_planned_recall = false;

View file

@ -391,7 +391,7 @@ void move::draw_hex(const map_location& hex)
{
std::stringstream turn_text;
turn_text << turn_number_;
resources::screen->draw_text_in_hex(hex, display::LAYER_MOVE_INFO, turn_text.str(), 17, font::NORMAL_COLOR, 0.5,0.8);
game_display::get_singleton()->draw_text_in_hex(hex, display::LAYER_MOVE_INFO, turn_text.str(), 17, font::NORMAL_COLOR, 0.5,0.8);
}
}
@ -537,7 +537,7 @@ void move::calculate_move_cost()
// @todo: find a better treatment of movement points when defining moves out-of-turn
if(get_unit()->movement_left() - route_->move_cost < 0
&& resources::controller->current_side() == resources::screen->viewing_side()) {
&& resources::controller->current_side() == game_display::get_singleton()->viewing_side()) {
WRN_WB << "Move defined with insufficient movement left." << std::endl;
}
@ -555,8 +555,8 @@ void move::calculate_move_cost()
void move::redraw()
{
resources::screen->invalidate(get_source_hex());
resources::screen->invalidate(get_dest_hex());
game_display::get_singleton()->invalidate(get_source_hex());
game_display::get_singleton()->invalidate(get_dest_hex());
update_arrow_style();
}

View file

@ -161,7 +161,7 @@ void recall::apply_temp_modifier(unit_map& unit_map)
resources::gameboard->teams().at(team_index()).get_side_actions()->change_gold_spent_by(cost);
// Update gold in top bar
resources::screen->invalidate_game_status();
game_display::get_singleton()->invalidate_game_status();
}
void recall::remove_temp_modifier(unit_map& unit_map)
@ -191,14 +191,14 @@ void recall::draw_hex(const map_location& hex)
}
size_t font_size = 16;
color_t color {255, 0, 0}; //red
resources::screen->draw_text_in_hex(hex, display::LAYER_ACTIONS_NUMBERING,
game_display::get_singleton()->draw_text_in_hex(hex, display::LAYER_ACTIONS_NUMBERING,
number_text.str(), font_size, color, x_offset, y_offset);
}
}
void recall::redraw()
{
resources::screen->invalidate(recall_hex_);
game_display::get_singleton()->invalidate(recall_hex_);
}
action::error recall::check_validity() const

View file

@ -134,7 +134,7 @@ void recruit::apply_temp_modifier(unit_map& unit_map)
unit_map.insert(temp_unit_);
// Update gold in the top bar
resources::screen->invalidate_game_status();
game_display::get_singleton()->invalidate_game_status();
}
void recruit::remove_temp_modifier(unit_map& unit_map)
@ -155,14 +155,14 @@ void recruit::draw_hex(const map_location& hex)
number_text << font::unicode_minus << cost_;
size_t font_size = 16;
color_t color {255, 0, 0}; //red
resources::screen->draw_text_in_hex(hex, display::LAYER_ACTIONS_NUMBERING,
game_display::get_singleton()->draw_text_in_hex(hex, display::LAYER_ACTIONS_NUMBERING,
number_text.str(), font_size, color, x_offset, y_offset);
}
}
void recruit::redraw()
{
resources::screen->invalidate(recruit_hex_);
game_display::get_singleton()->invalidate(recruit_hex_);
}

View file

@ -726,7 +726,7 @@ void side_actions::execute_net_cmd(const net_cmd& cmd)
//update numbering hexes as necessary
++itor;
for(iterator end_itor = end(); itor != end_itor; ++itor) {
resources::screen->invalidate((*itor)->get_numbering_hex());
game_display::get_singleton()->invalidate((*itor)->get_numbering_hex());
}
} else if(type=="replace") {
size_t turn = cmd["turn"].to_int();
@ -765,7 +765,7 @@ void side_actions::execute_net_cmd(const net_cmd& cmd)
//update numbering hexes as necessary
for(iterator end_itor = end(); itor != end_itor; ++itor) {
resources::screen->invalidate((*itor)->get_numbering_hex());
game_display::get_singleton()->invalidate((*itor)->get_numbering_hex());
}
} else if(type=="bump_later") {
size_t turn = cmd["turn"].to_int();
@ -784,8 +784,8 @@ void side_actions::execute_net_cmd(const net_cmd& cmd)
LOG_WB << "Command received: action bumped later from turn #" << turn << ", position #" << pos << "\n";
//update numbering hexes as necessary
resources::screen->invalidate(first_action->get_numbering_hex());
resources::screen->invalidate(second_action->get_numbering_hex());
game_display::get_singleton()->invalidate(first_action->get_numbering_hex());
game_display::get_singleton()->invalidate(second_action->get_numbering_hex());
} else if(type=="clear") {
LOG_WB << "Command received: clear\n";
clear();

View file

@ -85,14 +85,14 @@ suppose_dead::suppose_dead(const config& cfg, bool hidden)
void suppose_dead::init()
{
resources::screen->invalidate(loc_);
game_display::get_singleton()->invalidate(loc_);
}
suppose_dead::~suppose_dead()
{
//invalidate hex so that skull indicator is properly cleared
if(resources::screen)
resources::screen->invalidate(loc_);
if(game_display::get_singleton())
game_display::get_singleton()->invalidate(loc_);
}
unit_ptr suppose_dead::get_unit() const
@ -140,16 +140,16 @@ void suppose_dead::draw_hex(const map_location& hex)
//@todo: Possibly use a different layer
const display::drawing_layer layer = display::LAYER_ARROWS;
int xpos = resources::screen->get_location_x(loc_);
int ypos = resources::screen->get_location_y(loc_);
resources::screen->drawing_buffer_add(layer, loc_, xpos, ypos,
int xpos = game_display::get_singleton()->get_location_x(loc_);
int ypos = game_display::get_singleton()->get_location_y(loc_);
game_display::get_singleton()->drawing_buffer_add(layer, loc_, xpos, ypos,
image::get_image("whiteboard/suppose_dead.png", image::SCALED_TO_HEX));
}
}
void suppose_dead::redraw()
{
resources::screen->invalidate(loc_);
game_display::get_singleton()->invalidate(loc_);
}
action::error suppose_dead::check_validity() const

View file

@ -39,18 +39,18 @@ namespace wb {
size_t viewer_team()
{
return resources::screen->viewing_team();
return game_display::get_singleton()->viewing_team();
}
int viewer_side()
{
return resources::screen->viewing_side();
return game_display::get_singleton()->viewing_side();
}
side_actions_ptr viewer_actions()
{
side_actions_ptr side_actions =
resources::gameboard->teams()[resources::screen->viewing_team()].get_side_actions();
resources::gameboard->teams()[game_display::get_singleton()->viewing_team()].get_side_actions();
return side_actions;
}
@ -142,13 +142,13 @@ temporary_unit_hider::~temporary_unit_hider()
void ghost_owner_unit(unit* unit)
{
unit->anim_comp().set_disabled_ghosted(false);
resources::screen->invalidate(unit->get_location());
game_display::get_singleton()->invalidate(unit->get_location());
}
void unghost_owner_unit(unit* unit)
{
unit->anim_comp().set_standing(true);
resources::screen->invalidate(unit->get_location());
game_display::get_singleton()->invalidate(unit->get_location());
}
bool has_actions()