try to fix linker errors without new globals

This commit is contained in:
2025-04-10 18:09:45 -05:00
parent d5ba8cb62c
commit 06624d810c
5 changed files with 18 additions and 11 deletions

View File

@@ -43,6 +43,8 @@ const short cDialog::BG_DARK = 5, cDialog::BG_LIGHT = 16;
short cDialog::defaultBackground = cDialog::BG_DARK; short cDialog::defaultBackground = cDialog::BG_DARK;
cDialog* cDialog::topWindow = nullptr; cDialog* cDialog::topWindow = nullptr;
void (*cDialog::redraw_everything)() = nullptr; void (*cDialog::redraw_everything)() = nullptr;
std::function<sf::RenderWindow&()> cDialog::get_mini_map;
bool* cDialog::map_visible_p = nullptr;
extern std::map<std::string,sf::Color> colour_map; extern std::map<std::string,sf::Color> colour_map;
@@ -627,9 +629,6 @@ void cDialog::handleTab(bool reverse) {
} }
} }
extern sf::RenderWindow& mini_map();
extern bool map_visible;
// This method handles one event received by the dialog. // This method handles one event received by the dialog.
void cDialog::handle_one_event(const sf::Event& currentEvent, cFramerateLimiter& fps_limiter) { void cDialog::handle_one_event(const sf::Event& currentEvent, cFramerateLimiter& fps_limiter) {
using Key = sf::Keyboard::Key; using Key = sf::Keyboard::Key;
@@ -744,15 +743,23 @@ void cDialog::handle_one_event(const sf::Event& currentEvent, cFramerateLimiter&
break; break;
case sf::Event::LostFocus: case sf::Event::LostFocus:
has_focus = false; has_focus = false;
setWindowFloating(mini_map(), false); if(get_mini_map){
setWindowFloating(get_mini_map(), false);
}
break; break;
case sf::Event::GainedFocus: case sf::Event::GainedFocus:
if(!has_focus){ if(!has_focus){
has_focus = true; has_focus = true;
setWindowFloating(mini_map(), true); if(get_mini_map){
setWindowFloating(get_mini_map(), true);
}
makeFrontWindow(mainPtr()); makeFrontWindow(mainPtr());
if(map_visible) if(get_mini_map){
makeFrontWindow(mini_map()); if(*map_visible_p){
makeFrontWindow(get_mini_map());
}
}
std::vector<sf::RenderWindow*> dialog_stack; std::vector<sf::RenderWindow*> dialog_stack;
cDialog* next = this; cDialog* next = this;
while(next != nullptr){ while(next != nullptr){

View File

@@ -79,6 +79,8 @@ class cDialog : public iComponent, public iNameGiver {
bool doAnimations; bool doAnimations;
bool has_focus = false; bool has_focus = false;
public: public:
static std::function<sf::RenderWindow&()> get_mini_map;
static bool* map_visible_p;
static void (*redraw_everything)(); static void (*redraw_everything)();
/// Performs essential startup initialization. Generally should not be called directly. /// Performs essential startup initialization. Generally should not be called directly.
static void init(); static void init();

View File

@@ -236,6 +236,8 @@ int main(int argc, char* argv[]) {
try{ try{
#endif #endif
cDialog::redraw_everything = &redraw_everything; cDialog::redraw_everything = &redraw_everything;
cDialog::get_mini_map = &mini_map;
cDialog::map_visible_p = &map_visible;
init_boe(argc, argv); init_boe(argc, argv);

View File

@@ -83,8 +83,6 @@ char start_name[256];
// This is just to make location.hpp compile, and represents nothing: // This is just to make location.hpp compile, and represents nothing:
location center; location center;
bool map_visible = false;
static void process_args(int argc, char* argv[]) { static void process_args(int argc, char* argv[]) {
preprocess_args(argc, argv); preprocess_args(argc, argv);
clara::Args args(argc, argv); clara::Args args(argc, argv);

View File

@@ -101,8 +101,6 @@ fs::path game_dir;
fs::path game_binary; fs::path game_binary;
extern std::string last_load_file; extern std::string last_load_file;
bool map_visible = false;
enum class eLaunchType {LOC,START,ENTRANCE}; enum class eLaunchType {LOC,START,ENTRANCE};
static void launch_scenario(eLaunchType type) { static void launch_scenario(eLaunchType type) {