feat: Add global access for selected Game object

> separated commit in case this functionality is already provided through other means and needs to be reverted
> probably target for rehaul in the future for better/less invasive approach
This commit is contained in:
[ ]
2023-10-02 23:56:13 +09:00
parent f6f62e0e9d
commit 32f4f1871d
5 changed files with 10 additions and 1 deletions
+4
View File
@@ -5,6 +5,10 @@ games::Game::Game(std::string name) {
this->name = name; this->name = name;
} }
const char *games::Game::title() {
return this->name.c_str();
}
void games::Game::attach() { void games::Game::attach() {
log_info("game", "attach: {}", name); log_info("game", "attach: {}", name);
} }
+1
View File
@@ -15,6 +15,7 @@ namespace games {
// where the main magic will happen // where the main magic will happen
virtual void attach(); virtual void attach();
virtual const char *title();
// optional // optional
virtual void pre_attach(); virtual void pre_attach();
+1 -1
View File
@@ -34,7 +34,7 @@ HRESULT PipewireBackend::on_initialize(
if (!bmsw_) log_fatal("audio::pipewire", "Library not found: '{}'", (MODULE_PATH / "bmsound-wine.dll").string()); if (!bmsw_) log_fatal("audio::pipewire", "Library not found: '{}'", (MODULE_PATH / "bmsound-wine.dll").string());
auto pipewireinit = (BmswClientInit_t)GetProcAddress(bmsw_, "BmswClientInit"); auto pipewireinit = (BmswClientInit_t)GetProcAddress(bmsw_, "BmswClientInit");
if (!pipewireinit) log_fatal("audio::pipewire", "Library invalid: '{}'", (MODULE_PATH / "bmsound-wine.dll").string()); if (!pipewireinit) log_fatal("audio::pipewire", "Library invalid: '{}'", (MODULE_PATH / "bmsound-wine.dll").string());
internal_ = std::thread(pipewireinit,"GAME TITLE"); internal_ = std::thread(pipewireinit,GAME_INSTANCE->title());
return S_OK; return S_OK;
} }
+2
View File
@@ -108,6 +108,7 @@ std::string LOG_FILE_PATH = "";
int LAUNCHER_ARGC = 0; int LAUNCHER_ARGC = 0;
char **LAUNCHER_ARGV = nullptr; char **LAUNCHER_ARGV = nullptr;
std::unique_ptr<std::vector<Option>> LAUNCHER_OPTIONS; std::unique_ptr<std::vector<Option>> LAUNCHER_OPTIONS;
games::Game *GAME_INSTANCE = nullptr;
std::string CARD_OVERRIDES[2]; std::string CARD_OVERRIDES[2];
// sub-systems // sub-systems
@@ -1424,6 +1425,7 @@ int main_implementation(int argc, char *argv[]) {
avs::core::set_default_heap_size("kamunity.dll"); avs::core::set_default_heap_size("kamunity.dll");
games.push_back(new games::bc::BCGame()); games.push_back(new games::bc::BCGame());
} }
GAME_INSTANCE = games.back();
// apply user heap size, if defined // apply user heap size, if defined
if (user_heap_size > 0) { if (user_heap_size > 0) {
+2
View File
@@ -7,6 +7,7 @@
#include <windows.h> #include <windows.h>
#include "cfg/option.h" #include "cfg/option.h"
#include "games/game.h"
namespace rawinput { namespace rawinput {
class RawInputManager; class RawInputManager;
@@ -21,6 +22,7 @@ extern std::string LOG_FILE_PATH;
extern int LAUNCHER_ARGC; extern int LAUNCHER_ARGC;
extern char **LAUNCHER_ARGV; extern char **LAUNCHER_ARGV;
extern std::unique_ptr<std::vector<Option>> LAUNCHER_OPTIONS; 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<api::Controller> API_CONTROLLER;
extern std::unique_ptr<rawinput::RawInputManager> RI_MGR; extern std::unique_ptr<rawinput::RawInputManager> RI_MGR;