mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-06-10 18:25:45 -04:00
HostInterface: Move running title info to System
This commit is contained in:
@ -438,7 +438,7 @@ void HostInterface::UpdateSpeedLimiterState()
|
||||
|
||||
void HostInterface::OnPerformanceCountersUpdated() {}
|
||||
|
||||
void HostInterface::OnRunningGameChanged(const char* path, const char* game_code, const char* game_title) {}
|
||||
void HostInterface::OnRunningGameChanged() {}
|
||||
|
||||
void HostInterface::SetUserDirectory()
|
||||
{
|
||||
@ -540,31 +540,3 @@ void HostInterface::ResetPerformanceCounters()
|
||||
m_worst_frame_time_accumulator = 0.0f;
|
||||
m_fps_timer.Reset();
|
||||
}
|
||||
|
||||
void HostInterface::UpdateRunningGame(const char* path, CDImage* image)
|
||||
{
|
||||
if (!path || std::strlen(path) == 0)
|
||||
{
|
||||
OnRunningGameChanged("", "", "");
|
||||
return;
|
||||
}
|
||||
|
||||
const GameListEntry* list_entry = m_game_list->GetEntryForPath(path);
|
||||
if (list_entry)
|
||||
{
|
||||
OnRunningGameChanged(path, list_entry->code.c_str(), list_entry->title.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
const std::string game_code = image ? GameList::GetGameCodeForImage(image) : std::string();
|
||||
const GameListDatabaseEntry* db_entry =
|
||||
(!game_code.empty()) ? m_game_list->GetDatabaseEntryForCode(game_code) : nullptr;
|
||||
if (!db_entry)
|
||||
{
|
||||
const std::string game_title(GameList::GetTitleForPath(path));
|
||||
OnRunningGameChanged(path, game_code.c_str(), game_title.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
OnRunningGameChanged(path, db_entry->code.c_str(), db_entry->title.c_str());
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ protected:
|
||||
};
|
||||
|
||||
virtual void OnPerformanceCountersUpdated();
|
||||
virtual void OnRunningGameChanged(const char* path, const char* game_code, const char* game_title);
|
||||
virtual void OnRunningGameChanged();
|
||||
|
||||
void SetUserDirectory();
|
||||
|
||||
@ -108,8 +108,6 @@ protected:
|
||||
void UpdatePerformanceCounters();
|
||||
void ResetPerformanceCounters();
|
||||
|
||||
void UpdateRunningGame(const char* path, CDImage* image);
|
||||
|
||||
std::unique_ptr<HostDisplay> m_display;
|
||||
std::unique_ptr<AudioStream> m_audio_stream;
|
||||
std::unique_ptr<System> m_system;
|
||||
|
@ -155,7 +155,7 @@ bool System::Boot(const char* filename)
|
||||
}
|
||||
|
||||
// Notify change of disc.
|
||||
m_host_interface->UpdateRunningGame(filename, media.get());
|
||||
UpdateRunningGame(filename, media.get());
|
||||
|
||||
// Insert CD, and apply fastboot patch if enabled.
|
||||
m_cdrom->InsertMedia(std::move(media));
|
||||
@ -251,7 +251,7 @@ bool System::DoState(StateWrapper& sw)
|
||||
Log_ErrorPrintf("Failed to open CD image from save state: '%s'", media_filename.c_str());
|
||||
}
|
||||
|
||||
m_host_interface->UpdateRunningGame(media_filename.c_str(), media.get());
|
||||
UpdateRunningGame(media_filename.c_str(), media.get());
|
||||
if (media)
|
||||
m_cdrom->InsertMedia(std::move(media));
|
||||
else
|
||||
@ -516,6 +516,7 @@ bool System::InsertMedia(const char* path)
|
||||
if (!image)
|
||||
return false;
|
||||
|
||||
UpdateRunningGame(path, image.get());
|
||||
m_cdrom->InsertMedia(std::move(image));
|
||||
return true;
|
||||
}
|
||||
@ -524,3 +525,37 @@ void System::RemoveMedia()
|
||||
{
|
||||
m_cdrom->RemoveMedia();
|
||||
}
|
||||
|
||||
void System::UpdateRunningGame(const char* path, CDImage* image)
|
||||
{
|
||||
m_running_game_path.clear();
|
||||
m_running_game_code.clear();
|
||||
m_running_game_title.clear();
|
||||
|
||||
if (path && std::strlen(path) > 0)
|
||||
{
|
||||
m_running_game_path = path;
|
||||
|
||||
const GameListEntry* list_entry = m_host_interface->GetGameList()->GetEntryForPath(path);
|
||||
if (list_entry)
|
||||
{
|
||||
m_running_game_code = list_entry->code;
|
||||
m_running_game_title = list_entry->title;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (image)
|
||||
m_running_game_code = GameList::GetGameCodeForImage(image);
|
||||
|
||||
const GameListDatabaseEntry* db_entry =
|
||||
(!m_running_game_code.empty()) ? m_host_interface->GetGameList()->GetDatabaseEntryForCode(m_running_game_code) :
|
||||
nullptr;
|
||||
if (db_entry)
|
||||
m_running_game_title = db_entry->title;
|
||||
else
|
||||
m_running_game_title = GameList::GetTitleForPath(path);
|
||||
}
|
||||
}
|
||||
|
||||
m_host_interface->OnRunningGameChanged();
|
||||
}
|
||||
|
@ -1,8 +1,9 @@
|
||||
#pragma once
|
||||
#include "types.h"
|
||||
#include "host_interface.h"
|
||||
#include "types.h"
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
class ByteStream;
|
||||
class CDImage;
|
||||
@ -11,7 +12,7 @@ class StateWrapper;
|
||||
namespace CPU {
|
||||
class Core;
|
||||
class CodeCache;
|
||||
}
|
||||
} // namespace CPU
|
||||
|
||||
class Bus;
|
||||
class DMA;
|
||||
@ -56,6 +57,10 @@ public:
|
||||
|
||||
const Settings& GetSettings() { return m_host_interface->GetSettings(); }
|
||||
|
||||
const std::string& GetRunningPath() const { return m_running_game_path; }
|
||||
const std::string& GetRunningCode() const { return m_running_game_code; }
|
||||
const std::string& GetRunningTitle() const { return m_running_game_title; }
|
||||
|
||||
bool Boot(const char* filename);
|
||||
void Reset();
|
||||
|
||||
@ -94,6 +99,8 @@ private:
|
||||
|
||||
void InitializeComponents();
|
||||
|
||||
void UpdateRunningGame(const char* path, CDImage* image);
|
||||
|
||||
HostInterface* m_host_interface;
|
||||
std::unique_ptr<CPU::Core> m_cpu;
|
||||
std::unique_ptr<CPU::CodeCache> m_cpu_code_cache;
|
||||
@ -112,4 +119,8 @@ private:
|
||||
u32 m_frame_number = 1;
|
||||
u32 m_internal_frame_number = 1;
|
||||
u32 m_global_tick_counter = 0;
|
||||
|
||||
std::string m_running_game_path;
|
||||
std::string m_running_game_code;
|
||||
std::string m_running_game_title;
|
||||
};
|
||||
|
Reference in New Issue
Block a user