Add stamina and mana toggles. OSD scaling properly on any resolution

This commit is contained in:
2026-02-20 07:21:46 +01:00
parent 7129eb38f2
commit a9c5365a40

View File

@@ -21,6 +21,12 @@ uniform bool IgnoreHits_Enabled = false;
// Stealth
uniform bool OSD_ShowStealth = false;
uniform bool Stealth_Enabled = false;
// Stamina
uniform bool OSD_ShowStamina = false;
uniform bool Stamina_Enabled = false;
// Mana
uniform bool OSD_ShowMana = false;
uniform bool Mana_Enabled = false;
// --- Character arrays for labels ---
static const int ON_LENGTH = 2;
@@ -60,7 +66,7 @@ static float AI_CHARS[32] = {
// New labels
static const int GOD_LEN = 9;
static float GOD_CHARS[32] = {
71-32, 111-32, 100-32, 32-32, 77-32, 111-32, 100-32, 101-32, // God Mode
71-32, 111-32, 100-32, 32-32, 77-32, 111-32, 100-32, 101-32, // God Mode :
32 -32, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0
@@ -68,7 +74,7 @@ static float GOD_CHARS[32] = {
static const int INV_LEN = 12;
static float INV_CHARS[32] = {
73-32, 103-32, 110-32, 111-32, 114-32, 101-32, 32-32, 104-32, // "Ignore hits"
73-32, 103-32, 110-32, 111-32, 114-32, 101-32, 32-32, 104-32, // Ignore hits :
105-32, 116-32, 115-32, 32-32, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0
@@ -76,12 +82,28 @@ static float INV_CHARS[32] = {
static const int STEALTH_LEN = 13;
static float STEALTH_CHARS[32] = {
83-32, 116-32, 101-32, 97-32, 108-32, 116-32, 104-32, 32-32, // "Stealth Mode"
83-32, 116-32, 101-32, 97-32, 108-32, 116-32, 104-32, 32-32, // Stealth Mode :
77-32, 111-32, 100-32, 101-32, 32-32, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0
};
static const int STAMINA_LEN = 8;
static float STAMINA_CHARS[32] = {
83 - 32, 116 - 32, 97 - 32, 109 - 32, 105 - 32, 110 - 32, 97 - 32, 32 - 32, // Stamina
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0
};
static const int MANA_LEN = 5;
static float MANA_CHARS[32] = {
77 - 32, 97 - 32, 110 - 32, 97 - 32, 32 - 32, 0, 0, 0, // Mana :
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0
};
// --- SDF Rectangle ---
float sdRoundRect(float2 p, float2 b, float r) {
float2 q = abs(p) - b + r;
@@ -89,57 +111,67 @@ float sdRoundRect(float2 p, float2 b, float r) {
}
// --- Draw a character ---
float4 DrawChar(float2 uv, float2 pos, float2 charSize, float charIndex) {
float4 DrawChar(float2 uv, float2 posPx, float2 charSizePx, float charIndex) {
float2 pixelPos = uv * ReShade::ScreenSize;
float2 local = (pixelPos - posPx) / charSizePx;
if (local.x < 0 || local.x > 1 || local.y < 0 || local.y > 1)
return float4(0, 0, 0, 0);
float2 texSize = float2(14.0, 7.0);
float2 fontUV = float2(charIndex % texSize.x, floor(charIndex / texSize.x)) / texSize;
float2 fontUV = float2(charIndex - texSize.x * floor(charIndex / texSize.x),
floor(charIndex / texSize.x)) / texSize;
float2 fontUVSize = 1.0 / texSize;
float2 localUV = (uv - pos) / charSize;
float2 finalFontUV = fontUV + fontUVSize * localUV;
return tex2D(FontSampler, finalFontUV);
float2 finalUV = fontUV + local * fontUVSize;
return tex2D(FontSampler, finalUV);
}
// --- Draw text array ---
float4 DrawText(float2 uv, float2 startPos, float2 charSize, float chars[32], int length) {
float4 col = float4(0,0,0,0);
float4 DrawText(float2 uv, float2 startPosPx, float2 charSizePx, float chars[32], int length) {
float4 col = float4(0, 0, 0, 0);
[unroll]
for (int i = 0; i < 32; i++) {
if (i >= length) break;
float2 charPos = startPos + float2(i*charSize.x,0);
if (uv.x >= charPos.x && uv.x < charPos.x+charSize.x &&
uv.y >= charPos.y && uv.y < charPos.y+charSize.y) {
float4 glyph = DrawChar(uv,charPos,charSize,chars[i]);
col.rgb = lerp(col.rgb,glyph.rgb,glyph.a);
col.a = max(col.a,glyph.a);
}
float2 charPos = startPosPx + float2(i * charSizePx.x, 0);
float4 glyph = DrawChar(uv, charPos, charSizePx, chars[i]);
col.rgb = lerp(col.rgb, glyph.rgb, glyph.a);
col.a = max(col.a, glyph.a);
}
return col;
}
// --- Draw float number as text ---
float4 DrawFloat(float2 uv, float2 startPos, float2 charSize, float value) {
float4 col = float4(0,0,0,0);
float4 DrawFloat(float2 uv, float2 startPosPx, float2 charSizePx, float value) {
float4 col = float4(0, 0, 0, 0);
float v = abs(value);
int iv = (int)(v * 100.0 + 0.5);
int iv = (int) (v * 100.0 + 0.5);
int i0 = iv / 100;
int i1 = (iv / 10) % 10;
int i2 = iv % 10;
float chars[4];
chars[0] = i0 + 16; // '0'
chars[1] = 14; // '.'
chars[0] = i0 + 16;
chars[1] = 14;
chars[2] = i1 + 16;
chars[3] = i2 + 16;
//float chars[4] = { i0 + 16, 14, i1 + 16, i2 + 16 };
[unroll]
for (int i=0;i<4;i++) {
float2 pos = startPos + float2(i * charSize.x, 0);
if (uv.x >= pos.x && uv.x < pos.x+charSize.x &&
uv.y >= pos.y && uv.y < pos.y+charSize.y) {
float4 g = DrawChar(uv, pos, charSize, chars[i]);
col.rgb = lerp(col.rgb, g.rgb, g.a);
col.a = max(col.a, g.a);
}
for (int i = 0; i < 4; i++) {
float2 pos = startPosPx + float2(i * charSizePx.x, 0);
float4 g = DrawChar(uv, pos, charSizePx, chars[i]);
col.rgb = lerp(col.rgb, g.rgb, g.a);
col.a = max(col.a, g.a);
}
return col;
}
@@ -166,16 +198,19 @@ float4 DrawFlag(float2 uv, inout float2 pen, float2 charSize, const float label[
float4 PS_OSD(float4 pos : SV_Position, float2 uv : TEXCOORD) : SV_Target {
float4 col = tex2D(ReShade::BackBuffer, uv);
if (!OSD_ShowTD && !OSD_ShowGodMode && !OSD_ShowIgnoreHits && !OSD_ShowStealth)
if (!OSD_ShowTD && !OSD_ShowGodMode && !OSD_ShowIgnoreHits && !OSD_ShowStealth && !OSD_ShowStamina && !OSD_ShowMana)
return col;
float2 pixelPos = uv * ReShade::ScreenSize;
float margin_top = 20.0;
float2 center_uv = float2(0.5, margin_top / ReShade::ScreenSize.y + 0.01);
float2 p = uv - center_uv; p.x *= ReShade::AspectRatio;
float2 centerPx = float2(ReShade::ScreenSize.x * 0.5, margin_top);
float2 p = pixelPos - centerPx;
// --- Frame rect ---
float charAdvance = 0.003;
float2 charSize = float2(0.003, 0.02); // widht * height
float2 charSize = float2(14.0, 20.0); // pixels
float charAdvance = charSize.x;
float totalLen = 0;
float3 color;
if (TD_Enabled && OSD_ShowTD) {
@@ -210,19 +245,37 @@ if (!OSD_ShowTD && !OSD_ShowGodMode && !OSD_ShowIgnoreHits && !OSD_ShowStealth)
totalLen = STEALTH_LEN + OFF_LENGTH;
color = float3(1.0, 0.3, 0.3);
}
if (Stamina_Enabled && OSD_ShowStamina) {
totalLen = STAMINA_LEN + ON_LENGTH;
color = float3(0.3, 1.0, 0.3);
}
if (!Stamina_Enabled && OSD_ShowStamina) {
totalLen = STAMINA_LEN + OFF_LENGTH;
color = float3(1.0, 0.3, 0.3);
}
if (Mana_Enabled && OSD_ShowMana) {
totalLen = MANA_LEN + ON_LENGTH;
color = float3(0.3, 1.0, 0.3);
}
if (!Mana_Enabled && OSD_ShowMana) {
totalLen = MANA_LEN + OFF_LENGTH;
color = float3(1.0, 0.3, 0.3);
}
float2 size_uv = float2((totalLen* charAdvance * 0.5 + charAdvance * 1.0) * ReShade::AspectRatio, 20.0 / ReShade::ScreenSize.y);
float thickness_px = 1.0;
float thickness = thickness_px * ReShade::PixelSize.y;
float radius_px = 2.0;
float radius = radius_px * ReShade::PixelSize.y;
float d = sdRoundRect(p,size_uv,radius);
if (abs(d)<thickness) col.rgb = lerp(col.rgb, color, 0.85);
float verticalPadding = 6.0; // ajuste ici
float2 sizePx = float2(totalLen * charAdvance * 0.5 + charAdvance,
charSize.y * 0.5 + verticalPadding);
float thickness = 1.0;
float radius = 4.0;
float d = sdRoundRect(p, sizePx, radius);
if (abs(d) < thickness) col.rgb = lerp(col.rgb, color, 0.85);
// --- Draw all flags ---
float2 pen = center_uv;
float2 pen = centerPx;
pen.x -= totalLen * charAdvance * 0.5;
pen.y -= charSize.y * 0.5;
pen.y -= charSize.y * 0.45;
float4 combined = float4(0,0,0,0);
// Time Dilation
@@ -253,6 +306,12 @@ if (!OSD_ShowTD && !OSD_ShowGodMode && !OSD_ShowIgnoreHits && !OSD_ShowStealth)
if (OSD_ShowStealth)
AlphaBlend(combined, DrawFlag(uv, pen, charSize, STEALTH_CHARS, STEALTH_LEN, Stealth_Enabled));
if (OSD_ShowStamina)
AlphaBlend(combined, DrawFlag(uv, pen, charSize, STAMINA_CHARS, STAMINA_LEN, Stamina_Enabled));
if (OSD_ShowMana)
AlphaBlend(combined, DrawFlag(uv, pen, charSize, MANA_CHARS, MANA_LEN, Mana_Enabled));
combined.rgb *= color;
col.rgb = lerp(col.rgb, combined.rgb, combined.a);