add dev branding

This commit is contained in:
quaK 2024-07-13 22:46:07 +03:00
parent 049e6d0cf8
commit 9191b6a436
6 changed files with 71 additions and 12 deletions

View File

@ -251,7 +251,9 @@ warnings "Extra"
characterset "ASCII"
if _OPTIONS["dev-build"] then
defines "DEV_BUILD"
defines {"DEV_BUILD", 'BUILD_NAME="IW7_DEV"'}
else
defines {'BUILD_NAME="IW7"'}
end
if _OPTIONS["steam-overlay"] then

View File

@ -40,20 +40,41 @@ namespace branding
scheduler::once([]()
{
dvars::branding = game::Dvar_RegisterBool("branding", true, game::DvarFlags::DVAR_FLAG_SAVED, "Show branding in the top left corner");
dvars::branding = game::Dvar_RegisterBool("branding", true, game::DvarFlags::DVAR_FLAG_SAVED, "Show branding");
}, scheduler::pipeline::renderer);
#ifdef GIT_DIRTY
static char version_buffer[0x100]{};
sprintf_s(version_buffer, sizeof(version_buffer), "%s %s build %s %s %s", BUILD_NAME, VERSION, __DATE__, __TIME__, TARGET_ARCHITECTURE);
#endif
scheduler::loop([]()
{
if (dvars::branding && dvars::branding->current.enabled)
{
const auto font = game::R_RegisterFont("fonts/fira_mono_bold.ttf", 15);
if (font)
{
#ifdef GIT_DIRTY
static const auto font = game::R_RegisterFont("fonts/blender_pro_medium.ttf", 32);
if (!font) return;
static const auto offset_from_corner = 75.0f;
static float text_color[4] = { 0.4f, 0.69f, 1.0f, 0.69f };
const auto* placement = game::ScrPlace_GetViewPlacement();
const auto x = (placement->realViewportSize[0] - offset_from_corner) - (game::R_TextWidth(version_buffer, std::numeric_limits<int>::max(), font));
const auto height = (placement->realViewportSize[1] - offset_from_corner) + 5.0f; // remove some off the offset
game::R_AddCmdDrawText(version_buffer, std::numeric_limits<int>::max(), font, static_cast<float>(x),
height + static_cast<float>(font->pixelHeight),
1.0f, 1.0f, 0.0f, text_color, game::FONT_STYLE_SHADOW);
#else
const auto font = game::R_RegisterFont("fonts/fira_mono_regular.ttf", 16);
if (!font) return;
static float text_color[4] = { 0.860f, 0.459f, 0.925f, 0.400f };
game::R_AddCmdDrawText("iw7-mod: " VERSION, 0x7FFFFFFF, font, 10.f,
game::R_AddCmdDrawText("iw7-mod: " VERSION, std::numeric_limits<int>::max(), font, 10.f,
5.f + static_cast<float>(font->pixelHeight), 1.f, 1.f, 0.0f, text_color, 0);
}
#endif
}
}, scheduler::pipeline::renderer);

View File

@ -82,7 +82,7 @@ namespace logger
void com_init_pre()
{
console::info("%s %s build %s %s\n", "IW7", VERSION, "win64", __DATE__);
console::info("%s %s build %s %s\n", BUILD_NAME, VERSION, TARGET_ARCHITECTURE, __DATE__);
console::info("--- Common Initialization ---\n");
}

View File

@ -565,6 +565,26 @@ namespace game
CS_TIMESCALE = 3464,
};
enum FontStyle
{
FONT_STYLE_NONE = 0,
FONT_STYLE_SHADOW = 3,
FONT_STYLE_STRONG_SHADOW = 6,
FONT_STYLE_OUTLINE = 7,
FONT_STYLE_STRONG_OUTLINE = 8,
};
struct FontGlowStyle
{
float glowMinDistance;
float glowMaxDistance;
vec2_t glowUVOffset;
vec4_t glowColor;
float outlineGlowMinDistance;
float outlineGlowMaxDistance;
vec4_t outlineGlowColor;
};
namespace entity
{
enum connstate_t : std::uint32_t

View File

@ -185,13 +185,13 @@ namespace game
WEAK symbol<GfxFont* (const char* font, int size)> R_RegisterFont{ 0x140DFC670 };
WEAK symbol<int(const char* text, int maxChars, GfxFont* font)> R_TextWidth{ 0x140DFC770 };
WEAK symbol<int(void* font)> R_GetFontHeight{ 0x1412727B0 };
WEAK symbol<void* (int a1)> R_Font_GetLegacyFontStyle{ 0x140DFBD00 };
WEAK symbol<FontGlowStyle* (int style)> R_Font_GetLegacyFontStyle{ 0x140DFBD00 };
WEAK symbol<void()> R_SyncRenderThread{ 0x140E27EE0 };
WEAK symbol<void(float x, float y, float width, float height, float s0, float t0, float s1, float t1,
float* color, Material* material, int unk)> R_AddCmdDrawStretchPic{ 0x140E24DC0 };
WEAK symbol<void* (const char* text, int maxChars, void* font, int fontHeight, float x,
float y, float xScale, float yScale, float rotation, float* color,
int cursor_pos, char cursor_char, void* style_unk, int a14, int a15, int a16, int a17)> AddBaseDrawTextCmd{ 0x140E23D90 };
int cursorPos, char cursor, FontGlowStyle* glowStyle, int a14, int a15, int a16, int a17)> AddBaseDrawTextCmd{ 0x140E23D90 };
#define R_AddCmdDrawText(TXT, MC, F, X, Y, XS, YS, R, C, S) \
AddBaseDrawTextCmd(TXT, MC, F, game::R_GetFontHeight(F), X, Y, XS, YS, R, C,-1, 0, game::R_Font_GetLegacyFontStyle(S), 0, 0, 0, 0)
#define R_AddCmdDrawTextWithCursor(TXT, MC, F, UNK, X, Y, XS, YS, R, C, S, CP, CC) \

View File

@ -106,3 +106,19 @@ using namespace std::literals;
#define assert_offsetof(__ASSET__, __VARIABLE__, __OFFSET__) static_assert(offsetof(__ASSET__, __VARIABLE__) == __OFFSET__)
#define __FILENAME__ (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
#if defined(_WIN32) && defined(_WIN64)
#define TARGET_ARCHITECTURE "win64"
#elif defined(_WIN32)
#define TARGET_ARCHITECTURE "win32"
#elif defined(__linux__) && defined(__x86_64__)
#define TARGET_ARCHITECTURE "linux64"
#elif defined(__linux__) && defined(__i386__)
#define TARGET_ARCHITECTURE "linux32"
#elif defined(__APPLE__) && defined(__MACH__) && defined(__x86_64__)
#define TARGET_ARCHITECTURE "macos64"
#elif defined(__APPLE__) && defined(__MACH__) && defined(__i386__)
#define TARGET_ARCHITECTURE "macos32"
#else
#define TARGET_ARCHITECTURE "unknown"
#endif