Skip to content

Commit

Permalink
replace cg_centerMessageScale with cg_centerMessageSmallFont
Browse files Browse the repository at this point in the history
text would look awful at a lower scale
  • Loading branch information
siecvi committed Oct 25, 2024
1 parent beabe54 commit fdbe854
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 15 deletions.
9 changes: 7 additions & 2 deletions Resources/Locales/es/openspades.po
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,11 @@ msgctxt "Preferences"
msgid "NORMAL"
msgstr "Normal"

#: Resources/Scripts/Gui/Preferences.as:1176
msgctxt "Preferences"
msgid "SMALL"
msgstr "Pequeño/a"

#: Resources/Scripts/Gui/Preferences.as:650
msgctxt "Preferences"
msgid "Particles"
Expand Down Expand Up @@ -1651,8 +1656,8 @@ msgstr "Mensajes centrales"

#: Resources/Scripts/Gui/Preferences.as:634
msgctxt "Preferences"
msgid "Center Messages Scale"
msgstr "Escala de mensajes centrales"
msgid "Center Messages Size"
msgstr "Tamaño de mensajes centrales"

#: Resources/Scripts/Gui/Preferences.as:636
msgctxt "Preferences"
Expand Down
7 changes: 6 additions & 1 deletion Resources/Locales/pot/openspades.pot
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,11 @@ msgctxt "Preferences"
msgid "NORMAL"
msgstr ""

#: Resources/Scripts/Gui/Preferences.as:1176
msgctxt "Preferences"
msgid "SMALL"
msgstr ""

#: Resources/Scripts/Gui/Preferences.as:650
msgctxt "Preferences"
msgid "Particles"
Expand Down Expand Up @@ -1586,7 +1591,7 @@ msgstr ""

#: Resources/Scripts/Gui/Preferences.as:634
msgctxt "Preferences"
msgid "Center Messages Scale"
msgid "Center Messages Size"
msgstr ""

#: Resources/Scripts/Gui/Preferences.as:636
Expand Down
6 changes: 4 additions & 2 deletions Resources/Scripts/Gui/Preferences.as
Original file line number Diff line number Diff line change
Expand Up @@ -1171,8 +1171,10 @@ namespace spades {
array<string> = {_Tr("Preferences", "NORMAL"),
_Tr("Preferences", "LESS")},
array<int> = {2, 0});
layouter.AddSliderField(_Tr("Preferences", "Center Messages Scale"), "cg_centerMessageScale",
0.75, 1, 0.01, ConfigNumberFormatter(2, ""));
layouter.AddChoiceField(_Tr("Preferences", "Center Messages Size"), "cg_centerMessageSmallFont",
array<string> = {_Tr("Preferences", "NORMAL"),
_Tr("Preferences", "SMALL")},
array<int> = {0, 1}, not options.GameActive);
layouter.AddToggleField(_Tr("Preferences", "Ignore Chat Messages"), "cg_ignoreChatMessages");
layouter.AddToggleField(_Tr("Preferences", "Ignore Private Messages"), "cg_ignorePrivateMessages");
layouter.AddSliderField(_Tr("Preferences", "Master Volume"), "s_volume",
Expand Down
17 changes: 8 additions & 9 deletions Sources/Client/CenterMessageView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,10 @@
#include "Client.h"
#include "IFont.h"
#include "IRenderer.h"
#include <Core/Settings.h>
#include <Core/Debug.h>
#include <Core/Settings.h>

DEFINE_SPADES_SETTING(cg_centerMessageScale, "1");

SPADES_SETTING(cg_smallFont);
DEFINE_SPADES_SETTING(cg_centerMessageSmallFont, "0");

namespace spades {
namespace client {
Expand All @@ -52,7 +50,9 @@ namespace spades {
return l;
}

float CenterMessageView::GetLineHeight() { return cg_smallFont ? 24.0F : 34.0F; }
float CenterMessageView::GetLineHeight() {
return cg_centerMessageSmallFont ? 24.0F : 34.0F;
}

void CenterMessageView::AddMessage(const std::string& msg) {
SPADES_MARK_FUNCTION();
Expand Down Expand Up @@ -85,8 +85,7 @@ namespace spades {
SPADES_MARK_FUNCTION();

float sw = renderer.ScreenWidth();
float lh = GetLineHeight();
float scale = Clamp((float)cg_centerMessageScale, 0.75F, 1.0F);
float lh = GetLineHeight() + 4.0F;

for (const auto& ent : entries) {
const auto& msg = ent.msg;
Expand All @@ -95,15 +94,15 @@ namespace spades {
if (fade > 1.0F)
fade = 1.0F;

Vector2 size = font->Measure(msg) * scale;
Vector2 size = font->Measure(msg);

float x = (sw - size.x) * 0.5F;
float y = 100.0F + lh * (float)ent.line;

Vector4 shadow = {0, 0, 0, fade * 0.5F};
Vector4 color = {1, 1, 1, fade};

font->DrawShadow(msg, MakeVector2(x, y), scale, color, shadow);
font->DrawShadow(msg, MakeVector2(x, y), 1.0F, color, shadow);
}
}
} // namespace client
Expand Down
3 changes: 2 additions & 1 deletion Sources/Client/Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ DEFINE_SPADES_SETTING(cg_ignoreChatMessages, "0");
DEFINE_SPADES_SETTING(cg_smallFont, "0");

SPADES_SETTING(cg_playerName);
SPADES_SETTING(cg_centerMessageSmallFont);

namespace spades {
namespace client {
Expand Down Expand Up @@ -135,7 +136,7 @@ namespace spades {
renderer->SetFogDistance(128.0F);

auto* chatFont = cg_smallFont ? &fontManager->GetSmallFont() : &fontManager->GetGuiFont();
auto* centerFont = cg_smallFont ? &fontManager->GetMediumFont() : &fontManager->GetLargeFont();
auto* centerFont = cg_centerMessageSmallFont ? &fontManager->GetMediumFont() : &fontManager->GetLargeFont();

chatWindow = stmp::make_unique<ChatWindow>(this, &GetRenderer(), chatFont, false);
killfeedWindow = stmp::make_unique<ChatWindow>(this, &GetRenderer(), chatFont, true);
Expand Down

0 comments on commit fdbe854

Please sign in to comment.