mirror of
https://github.com/hedge-dev/UnleashedRecomp
synced 2026-09-01 02:11:47 -04:00
Implement text skew, grayscale image, and marquee fade.
Marquee fade currently does not work with text shadow as the repeatedly drawn font accumulates its alpha.
This commit is contained in:
@@ -138,7 +138,9 @@ static void DrawHeaderContainer(const char* text)
|
||||
|
||||
DrawPauseHeaderContainer(g_upWindow.get(), min, max, alpha);
|
||||
|
||||
// TODO: skew this text and apply bevel.
|
||||
SetTextSkew((min.y + max.y) / 2.0f, Scale(3.0f));
|
||||
|
||||
// TODO: Apply bevel.
|
||||
DrawTextWithOutline<int>
|
||||
(
|
||||
g_fntNewRodinUB,
|
||||
@@ -149,6 +151,8 @@ static void DrawHeaderContainer(const char* text)
|
||||
3,
|
||||
IM_COL32(0, 0, 0, 255 * alpha)
|
||||
);
|
||||
|
||||
ResetTextSkew();
|
||||
}
|
||||
|
||||
static void DrawAchievement(int rowIndex, float yOffset, Achievement& achievement, bool isUnlocked)
|
||||
@@ -182,8 +186,10 @@ static void DrawAchievement(int rowIndex, float yOffset, Achievement& achievemen
|
||||
auto titleTextY = Scale(20);
|
||||
auto descTextY = Scale(52);
|
||||
|
||||
if (!isUnlocked)
|
||||
SetShaderModifier(IMGUI_SHADER_MODIFIER_GRAYSCALE);
|
||||
|
||||
// Draw achievement icon.
|
||||
// TODO: make icon greyscale if locked?
|
||||
drawList->AddImage
|
||||
(
|
||||
icon,
|
||||
@@ -194,6 +200,9 @@ static void DrawAchievement(int rowIndex, float yOffset, Achievement& achievemen
|
||||
IM_COL32(255, 255, 255, 255 * (isUnlocked ? 1 : 0.5f))
|
||||
);
|
||||
|
||||
if (!isUnlocked)
|
||||
SetShaderModifier(IMGUI_SHADER_MODIFIER_NONE);
|
||||
|
||||
drawList->PushClipRect(min, max, true);
|
||||
|
||||
auto colLockedText = IM_COL32(60, 60, 60, 29);
|
||||
@@ -219,13 +228,16 @@ static void DrawAchievement(int rowIndex, float yOffset, Achievement& achievemen
|
||||
|
||||
if (isSelected && textX + textSize.x >= max.x - Scale(10))
|
||||
{
|
||||
ImVec2 marqueeMin = { textMarqueeX, min.y };
|
||||
SetMarqueeFade(marqueeMin, max, Scale(32.0f));
|
||||
|
||||
// Draw achievement description with marquee.
|
||||
DrawTextWithMarqueeShadow
|
||||
(
|
||||
g_fntSeurat,
|
||||
fontSize,
|
||||
{ textX, min.y + descTextY },
|
||||
{ textMarqueeX, min.y },
|
||||
marqueeMin,
|
||||
max,
|
||||
isUnlocked ? IM_COL32(255, 255, 255, 255) : colLockedText,
|
||||
desc,
|
||||
@@ -236,6 +248,8 @@ static void DrawAchievement(int rowIndex, float yOffset, Achievement& achievemen
|
||||
0.4f,
|
||||
colTextShadow
|
||||
);
|
||||
|
||||
ResetMarqueeFade();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -16,10 +16,10 @@
|
||||
static void SetGradient(const ImVec2& min, const ImVec2& max, ImU32 top, ImU32 bottom)
|
||||
{
|
||||
auto callbackData = AddImGuiCallback(ImGuiCallback::SetGradient);
|
||||
callbackData->setGradient.gradientMin[0] = min.x;
|
||||
callbackData->setGradient.gradientMin[1] = min.y;
|
||||
callbackData->setGradient.gradientMax[0] = max.x;
|
||||
callbackData->setGradient.gradientMax[1] = max.y;
|
||||
callbackData->setGradient.boundsMin[0] = min.x;
|
||||
callbackData->setGradient.boundsMin[1] = min.y;
|
||||
callbackData->setGradient.boundsMax[0] = max.x;
|
||||
callbackData->setGradient.boundsMax[1] = max.y;
|
||||
callbackData->setGradient.gradientTop = top;
|
||||
callbackData->setGradient.gradientBottom = bottom;
|
||||
}
|
||||
@@ -50,6 +50,39 @@ static void SetScale(ImVec2 scale)
|
||||
callbackData->setScale.scale[1] = scale.y;
|
||||
}
|
||||
|
||||
static void SetTextSkew(float yCenter, float skewScale)
|
||||
{
|
||||
SetShaderModifier(IMGUI_SHADER_MODIFIER_TEXT_SKEW);
|
||||
SetOrigin({ 0.0f, yCenter });
|
||||
SetScale({ skewScale, 1.0f });
|
||||
}
|
||||
|
||||
static void ResetTextSkew()
|
||||
{
|
||||
SetShaderModifier(IMGUI_SHADER_MODIFIER_NONE);
|
||||
SetOrigin({ 0.0f, 0.0f });
|
||||
SetScale({ 1.0f, 1.0f });
|
||||
}
|
||||
|
||||
static void SetMarqueeFade(ImVec2 min, ImVec2 max, float fadeScale)
|
||||
{
|
||||
auto callbackData = AddImGuiCallback(ImGuiCallback::SetMarqueeFade);
|
||||
callbackData->setMarqueeFade.boundsMin[0] = min.x;
|
||||
callbackData->setMarqueeFade.boundsMin[1] = min.y;
|
||||
callbackData->setMarqueeFade.boundsMax[0] = max.x;
|
||||
callbackData->setMarqueeFade.boundsMax[1] = max.y;
|
||||
|
||||
SetShaderModifier(IMGUI_SHADER_MODIFIER_MARQUEE_FADE);
|
||||
SetScale({ fadeScale, 1.0f });
|
||||
}
|
||||
|
||||
static void ResetMarqueeFade()
|
||||
{
|
||||
ResetGradient();
|
||||
SetShaderModifier(IMGUI_SHADER_MODIFIER_NONE);
|
||||
SetScale({ 1.0f, 1.0f });
|
||||
}
|
||||
|
||||
// Aspect ratio aware.
|
||||
static float Scale(float size)
|
||||
{
|
||||
@@ -173,7 +206,10 @@ static void DrawTextWithOutline(const ImFont* font, float fontSize, const ImVec2
|
||||
for (int32_t i = -outlineSize + 1; i < outlineSize; i++)
|
||||
{
|
||||
for (int32_t j = -outlineSize + 1; j < outlineSize; j++)
|
||||
drawList->AddText(font, fontSize, { pos.x + i, pos.y + j }, outlineColor, text);
|
||||
{
|
||||
if (i != 0 && j != 0)
|
||||
drawList->AddText(font, fontSize, { pos.x + i, pos.y + j }, outlineColor, text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user