[App] Build title using StringBuffer.
This commit is contained in:
parent
38c3db1afb
commit
0419a9f13d
|
@ -430,31 +430,40 @@ void EmulatorWindow::ShowCommitID() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmulatorWindow::UpdateTitle() {
|
void EmulatorWindow::UpdateTitle() {
|
||||||
std::string title(base_title_);
|
xe::StringBuffer sb;
|
||||||
|
sb.Append(base_title_);
|
||||||
|
|
||||||
|
// Title information, if available
|
||||||
if (emulator()->is_title_open()) {
|
if (emulator()->is_title_open()) {
|
||||||
auto game_title = emulator()->game_title();
|
sb.AppendFormat(u8" | [{:08X}]", emulator()->title_id());
|
||||||
title += fmt::format(" | [{:08X}] {}", emulator()->title_id(), game_title);
|
|
||||||
|
auto title_name = emulator()->title_name();
|
||||||
|
if (!title_name.empty()) {
|
||||||
|
sb.Append(u8" ");
|
||||||
|
sb.Append(title_name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Graphics system name, if available
|
||||||
auto graphics_system = emulator()->graphics_system();
|
auto graphics_system = emulator()->graphics_system();
|
||||||
if (graphics_system) {
|
if (graphics_system) {
|
||||||
auto graphics_name = graphics_system->name();
|
auto graphics_name = graphics_system->name();
|
||||||
title += fmt::format(" <{}>", graphics_name);
|
if (!graphics_name.empty()) {
|
||||||
|
sb.Append(u8" <");
|
||||||
|
sb.Append(graphics_name);
|
||||||
|
sb.Append(u8">");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Clock::guest_time_scalar() != 1.0) {
|
if (Clock::guest_time_scalar() != 1.0) {
|
||||||
title += fmt::format(" (@{:.2f}x)", Clock::guest_time_scalar());
|
sb.AppendFormat(u8" (@{:.2f}x)", Clock::guest_time_scalar());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (initializing_shader_storage_) {
|
if (initializing_shader_storage_) {
|
||||||
title +=
|
sb.Append(u8" (Preloading shaders\u2026)");
|
||||||
" (Preloading shaders"
|
|
||||||
u8"\u2026"
|
|
||||||
")";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
window_->set_title(title);
|
window_->set_title(sb.to_string_view());
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmulatorWindow::SetInitializingShaderStorage(bool initializing) {
|
void EmulatorWindow::SetInitializingShaderStorage(bool initializing) {
|
||||||
|
|
|
@ -48,7 +48,7 @@ class Window {
|
||||||
virtual void DisableMainMenu() = 0;
|
virtual void DisableMainMenu() = 0;
|
||||||
|
|
||||||
const std::string& title() const { return title_; }
|
const std::string& title() const { return title_; }
|
||||||
virtual bool set_title(const std::string& title) {
|
virtual bool set_title(const std::string_view title) {
|
||||||
if (title == title_) {
|
if (title == title_) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,11 +99,12 @@ void GTKWindow::OnClose() {
|
||||||
super::OnClose();
|
super::OnClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GTKWindow::set_title(const std::string& title) {
|
bool GTKWindow::set_title(const std::string_view title) {
|
||||||
if (!super::set_title(title)) {
|
if (!super::set_title(title)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
gtk_window_set_title(GTK_WINDOW(window_), (gchar*)title.c_str());
|
std::string titlez(title);
|
||||||
|
gtk_window_set_title(GTK_WINDOW(window_), (gchar*)titlez.c_str());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ class GTKWindow : public Window {
|
||||||
void EnableMainMenu() override {}
|
void EnableMainMenu() override {}
|
||||||
void DisableMainMenu() override {}
|
void DisableMainMenu() override {}
|
||||||
|
|
||||||
bool set_title(const std::string& title) override;
|
bool set_title(const std::string_view title) override;
|
||||||
|
|
||||||
bool SetIcon(const void* buffer, size_t size) override;
|
bool SetIcon(const void* buffer, size_t size) override;
|
||||||
|
|
||||||
|
|
|
@ -199,11 +199,12 @@ void Win32Window::DisableMainMenu() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Win32Window::set_title(const std::string& title) {
|
bool Win32Window::set_title(const std::string_view title) {
|
||||||
if (!super::set_title(title)) {
|
if (!super::set_title(title)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
SetWindowTextW(hwnd_, reinterpret_cast<LPCWSTR>(xe::to_utf16(title).c_str()));
|
auto wide_title = xe::to_utf16(title);
|
||||||
|
SetWindowTextW(hwnd_, reinterpret_cast<LPCWSTR>(wide_title.c_str()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ class Win32Window : public Window {
|
||||||
void EnableMainMenu() override;
|
void EnableMainMenu() override;
|
||||||
void DisableMainMenu() override;
|
void DisableMainMenu() override;
|
||||||
|
|
||||||
bool set_title(const std::string& title) override;
|
bool set_title(const std::string_view title) override;
|
||||||
|
|
||||||
bool SetIcon(const void* buffer, size_t size) override;
|
bool SetIcon(const void* buffer, size_t size) override;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue