2022-05-12 13:28:24 -04:00
|
|
|
#ifndef GLOBAL_CTX_2
|
|
|
|
#define GLOBAL_CTX_2
|
|
|
|
|
2022-03-21 21:52:44 -04:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
2022-06-20 13:54:44 -04:00
|
|
|
#include <filesystem>
|
2022-03-21 21:52:44 -04:00
|
|
|
#include <memory>
|
2022-07-13 23:12:11 -04:00
|
|
|
#include <fstream>
|
2022-03-21 21:52:44 -04:00
|
|
|
#include "spdlog/spdlog.h"
|
2022-07-13 23:12:11 -04:00
|
|
|
#include "Lib/Mercury/Mercury.h"
|
2022-03-21 21:52:44 -04:00
|
|
|
|
|
|
|
namespace Ship {
|
|
|
|
class ResourceMgr;
|
|
|
|
class Window;
|
|
|
|
|
|
|
|
class GlobalCtx2 {
|
|
|
|
public:
|
|
|
|
static std::shared_ptr<GlobalCtx2> GetInstance();
|
|
|
|
static std::shared_ptr<GlobalCtx2> CreateInstance(const std::string& Name);
|
|
|
|
|
|
|
|
std::string GetName() { return Name; }
|
|
|
|
std::shared_ptr<Window> GetWindow() { return Win; }
|
|
|
|
std::shared_ptr<ResourceMgr> GetResourceManager() { return ResMan; }
|
|
|
|
std::shared_ptr<spdlog::logger> GetLogger() { return Logger; }
|
2022-07-13 23:12:11 -04:00
|
|
|
std::shared_ptr<Mercury> GetConfig() { return Config; }
|
2022-03-21 21:52:44 -04:00
|
|
|
|
2022-07-13 00:19:07 -04:00
|
|
|
static std::string GetAppDirectoryPath();
|
|
|
|
static std::string GetPathRelativeToAppDirectory(const char* path);
|
|
|
|
|
2022-07-13 23:12:11 -04:00
|
|
|
void WriteSaveFile(const std::filesystem::path& savePath, uintptr_t addr, void* dramAddr, size_t size);
|
2022-06-20 13:54:44 -04:00
|
|
|
void ReadSaveFile(std::filesystem::path savePath, uintptr_t addr, void* dramAddr, size_t size);
|
|
|
|
|
2022-07-13 23:12:11 -04:00
|
|
|
GlobalCtx2(std::string Name);
|
2022-03-21 21:52:44 -04:00
|
|
|
~GlobalCtx2();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void InitWindow();
|
|
|
|
void InitLogging();
|
|
|
|
|
|
|
|
private:
|
|
|
|
static std::weak_ptr <GlobalCtx2> Context;
|
|
|
|
std::shared_ptr<spdlog::logger> Logger;
|
|
|
|
std::shared_ptr<Window> Win;
|
2022-07-13 23:12:11 -04:00
|
|
|
std::shared_ptr<Mercury> Config; // Config needs to be after the Window because we call the Window during it's destructor.
|
2022-03-21 21:52:44 -04:00
|
|
|
std::shared_ptr<ResourceMgr> ResMan;
|
|
|
|
std::string Name;
|
|
|
|
std::string MainPath;
|
|
|
|
std::string PatchesPath;
|
|
|
|
};
|
|
|
|
}
|
2022-05-12 13:28:24 -04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|