Add global access for selected game object on 24-08-24

This commit is contained in:
Hazel 2024-08-28 11:56:30 -04:00
parent 8db3a552d6
commit 915397b28f
4 changed files with 9 additions and 0 deletions

View File

@ -5,6 +5,10 @@ games::Game::Game(std::string name) {
this->name = name;
}
const char *games::Game::title() {
return this->name.c_str();
}
void games::Game::attach() {
log_info("game", "attach: {}", name);
}

View File

@ -15,6 +15,7 @@ namespace games {
// where the main magic will happen
virtual void attach();
virtual const char *title();
// optional
virtual void pre_attach();

View File

@ -121,6 +121,7 @@ std::string LOG_FILE_PATH = "";
int LAUNCHER_ARGC = 0;
char **LAUNCHER_ARGV = nullptr;
std::unique_ptr<std::vector<Option>> LAUNCHER_OPTIONS;
games::Game *GAME_INSTANCE = nullptr;
std::string CARD_OVERRIDES[2];
// sub-systems
@ -1616,6 +1617,7 @@ int main_implementation(int argc, char *argv[]) {
avs::core::set_default_heap_size("kamunity.dll");
games.push_back(new games::qks::QKSGame());
}
GAME_INSTANCE = games.back();
// apply user heap size, if defined
if (user_heap_size > 0) {

View File

@ -7,6 +7,7 @@
#include <windows.h>
#include "cfg/option.h"
#include "games/game.h"
namespace rawinput {
class RawInputManager;
@ -21,6 +22,7 @@ extern std::string LOG_FILE_PATH;
extern int LAUNCHER_ARGC;
extern char **LAUNCHER_ARGV;
extern std::unique_ptr<std::vector<Option>> LAUNCHER_OPTIONS;
extern games::Game *GAME_INSTANCE;
extern std::unique_ptr<api::Controller> API_CONTROLLER;
extern std::unique_ptr<rawinput::RawInputManager> RI_MGR;