Add auto-generated Git version to window titles

This commit is contained in:
Connor McLaughlin
2020-04-17 01:56:11 +10:00
parent 610ebcf2fa
commit 277c03aca0
17 changed files with 642 additions and 8 deletions

View File

@ -10,7 +10,7 @@ add_executable(duckstation-sdl
)
target_include_directories(duckstation-sdl PRIVATE ${SDL2_INCLUDE_DIRS})
target_link_libraries(duckstation-sdl PRIVATE core common imgui nativefiledialog glad frontend-common ${SDL2_LIBRARIES})
target_link_libraries(duckstation-sdl PRIVATE core common imgui nativefiledialog glad frontend-common scmversion ${SDL2_LIBRARIES})
if(WIN32)
target_sources(duckstation-sdl PRIVATE

View File

@ -50,6 +50,9 @@
<ProjectReference Include="..\frontend-common\frontend-common.vcxproj">
<Project>{6245dec8-d2da-47ee-a373-cbd6fcf3ece6}</Project>
</ProjectReference>
<ProjectReference Include="..\scmversion\scmversion.vcxproj">
<Project>{075ced82-6a20-46df-94c7-9624ac9ddbeb}</Project>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<ClCompile Include="d3d11_host_display.cpp" />
@ -395,4 +398,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>

View File

@ -16,6 +16,7 @@
#include "imgui_impl_sdl.h"
#include "opengl_host_display.h"
#include "sdl_key_names.h"
#include "scmversion/scmversion.h"
#include <cinttypes>
#include <cmath>
#include <imgui.h>
@ -39,6 +40,11 @@ const char* SDLHostInterface::GetFrontendName() const
return "DuckStation SDL/ImGui Frontend";
}
ALWAYS_INLINE static TinyString GetWindowTitle()
{
return TinyString::FromFormat("DuckStation %s (%s)", g_scm_tag_str, g_scm_branch_str);
}
float SDLHostInterface::GetDPIScaleFactor(SDL_Window* window)
{
#ifdef __APPLE__
@ -91,7 +97,7 @@ bool SDLHostInterface::CreateSDLWindow()
}
#endif
m_window = SDL_CreateWindow("DuckStation", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, window_width,
m_window = SDL_CreateWindow(GetWindowTitle(), SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, window_width,
window_height, window_flags);
if (!m_window)
return false;
@ -272,7 +278,7 @@ void SDLHostInterface::OnRunningGameChanged()
if (m_system && !m_system->GetRunningTitle().empty())
SDL_SetWindowTitle(m_window, m_system->GetRunningTitle().c_str());
else
SDL_SetWindowTitle(m_window, "DuckStation");
SDL_SetWindowTitle(m_window, GetWindowTitle());
}
void SDLHostInterface::RequestExit()