parent
b5eecb79b8
commit
588035d9eb
|
@ -447,6 +447,7 @@ void Emulator::loadGame(const char *path, LoadProgress *progress)
|
|||
{
|
||||
hostfs::FileInfo info = hostfs::storage().getFileInfo(settings.content.path);
|
||||
settings.content.fileName = info.name;
|
||||
settings.content.title = get_file_basename(info.name);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -504,6 +505,8 @@ void Emulator::loadGame(const char *path, LoadProgress *progress)
|
|||
InitDrive("");
|
||||
}
|
||||
}
|
||||
if (settings.content.path.empty())
|
||||
settings.content.title = "Dreamcast BIOS";
|
||||
|
||||
if (progress)
|
||||
progress->progress = 1.0f;
|
||||
|
@ -761,8 +764,6 @@ void Emulator::setNetworkState(bool online)
|
|||
settings.input.fastForwardMode &= !online;
|
||||
}
|
||||
|
||||
EventManager EventManager::Instance;
|
||||
|
||||
void EventManager::registerEvent(Event event, Callback callback, void *param)
|
||||
{
|
||||
unregisterEvent(event, callback, param);
|
||||
|
|
|
@ -54,25 +54,28 @@ public:
|
|||
using Callback = void (*)(Event, void *);
|
||||
|
||||
static void listen(Event event, Callback callback, void *param = nullptr) {
|
||||
Instance.registerEvent(event, callback, param);
|
||||
instance().registerEvent(event, callback, param);
|
||||
}
|
||||
|
||||
static void unlisten(Event event, Callback callback, void *param = nullptr) {
|
||||
Instance.unregisterEvent(event, callback, param);
|
||||
instance().unregisterEvent(event, callback, param);
|
||||
}
|
||||
|
||||
static void event(Event event) {
|
||||
Instance.broadcastEvent(event);
|
||||
instance().broadcastEvent(event);
|
||||
}
|
||||
|
||||
private:
|
||||
EventManager() = default;
|
||||
static EventManager& instance() {
|
||||
static EventManager _instance;
|
||||
return _instance;
|
||||
}
|
||||
|
||||
void registerEvent(Event event, Callback callback, void *param);
|
||||
void unregisterEvent(Event event, Callback callback, void *param);
|
||||
void broadcastEvent(Event event);
|
||||
|
||||
static EventManager Instance;
|
||||
std::map<Event, std::vector<std::pair<Callback, void *>>> callbacks;
|
||||
};
|
||||
|
||||
|
|
|
@ -627,8 +627,10 @@ void naomi_cart_LoadRom(const std::string& path, const std::string& fileName, Lo
|
|||
bool systemSP = memcmp(bootId.boardName, "SystemSP", 8) == 0;
|
||||
std::string gameId = trim_trailing_ws(std::string(bootId.gameTitle[systemSP ? 1 : 0], &bootId.gameTitle[systemSP ? 1 : 0][32]));
|
||||
std::string romName;
|
||||
if (CurrentCartridge->game != nullptr)
|
||||
if (CurrentCartridge->game != nullptr) {
|
||||
romName = CurrentCartridge->game->name;
|
||||
settings.content.title = CurrentCartridge->game->description;
|
||||
}
|
||||
if (gameId == "SAMPLE GAME MAX LONG NAME-")
|
||||
{
|
||||
// Use better game names
|
||||
|
@ -885,7 +887,7 @@ void* NaomiCartridge::GetDmaPtr(u32& size)
|
|||
{
|
||||
if ((DmaOffset & 0x1fffffff) >= RomSize)
|
||||
{
|
||||
INFO_LOG(NAOMI, "Error: DmaOffset >= RomSize");
|
||||
INFO_LOG(NAOMI, "Error: DmaOffset (%x) >= RomSize (%x)", DmaOffset, RomSize);
|
||||
size = 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -88,6 +88,14 @@ static void sdl_close_joystick(SDL_JoystickID instance)
|
|||
gamepad->close();
|
||||
}
|
||||
|
||||
static void setWindowTitleGame()
|
||||
{
|
||||
if (settings.naomi.slave)
|
||||
SDL_SetWindowTitle(window, ("Flycast - Multiboard Slave " + cfgLoadStr("naomi", "BoardId", "")).c_str());
|
||||
else
|
||||
SDL_SetWindowTitle(window, ("Flycast - " + settings.content.title).c_str());
|
||||
}
|
||||
|
||||
static void captureMouse(bool capture)
|
||||
{
|
||||
if (window == nullptr || !gameRunning)
|
||||
|
@ -98,7 +106,7 @@ static void captureMouse(bool capture)
|
|||
SDL_SetRelativeMouseMode(SDL_FALSE);
|
||||
else
|
||||
SDL_ShowCursor(SDL_ENABLE);
|
||||
SDL_SetWindowTitle(window, "Flycast");
|
||||
setWindowTitleGame();
|
||||
mouseCaptured = false;
|
||||
}
|
||||
else
|
||||
|
@ -118,12 +126,15 @@ static void emuEventCallback(Event event, void *)
|
|||
{
|
||||
switch (event)
|
||||
{
|
||||
case Event::Terminate:
|
||||
SDL_SetWindowTitle(window, "Flycast");
|
||||
break;
|
||||
case Event::Pause:
|
||||
gameRunning = false;
|
||||
if (!config::UseRawInput)
|
||||
SDL_SetRelativeMouseMode(SDL_FALSE);
|
||||
SDL_ShowCursor(SDL_ENABLE);
|
||||
SDL_SetWindowTitle(window, "Flycast");
|
||||
setWindowTitleGame();
|
||||
break;
|
||||
case Event::Resume:
|
||||
gameRunning = true;
|
||||
|
@ -199,6 +210,9 @@ void input_sdl_init()
|
|||
|
||||
SDL_SetRelativeMouseMode(SDL_FALSE);
|
||||
|
||||
// Event::Start is called on a background thread, so we can't use it to change the window title (macOS)
|
||||
// However it's followed by Event::Resume which is fine.
|
||||
EventManager::listen(Event::Terminate, emuEventCallback);
|
||||
EventManager::listen(Event::Pause, emuEventCallback);
|
||||
EventManager::listen(Event::Resume, emuEventCallback);
|
||||
|
||||
|
@ -234,6 +248,9 @@ void input_sdl_init()
|
|||
|
||||
void input_sdl_quit()
|
||||
{
|
||||
EventManager::unlisten(Event::Terminate, emuEventCallback);
|
||||
EventManager::unlisten(Event::Pause, emuEventCallback);
|
||||
EventManager::unlisten(Event::Resume, emuEventCallback);
|
||||
SDLGamepad::closeAllGamepads();
|
||||
SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
|
||||
}
|
||||
|
|
|
@ -178,6 +178,7 @@ struct settings_t
|
|||
std::string path;
|
||||
std::string gameId;
|
||||
std::string fileName;
|
||||
std::string title;
|
||||
} content;
|
||||
|
||||
struct {
|
||||
|
|
Loading…
Reference in New Issue