Skip to content
This repository has been archived by the owner on Dec 14, 2023. It is now read-only.

Commit

Permalink
More settings in menu
Browse files Browse the repository at this point in the history
Experiemental hiding of the palette
  • Loading branch information
nonperforming committed Apr 13, 2022
1 parent d3d6ec7 commit 94303db
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 46 deletions.
22 changes: 17 additions & 5 deletions Resources/Scripts/Gui/Preferences.as
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ namespace spades {
layouter.AddToggleField(_Tr("Preferences", "Blood"), "cg_blood");
layouter.AddToggleField(_Tr("Preferences", "Ejecting Brass"), "cg_ejectBrass");
//layouter.AddToggleField(_Tr("Preferences", "Ragdoll, "cg_ragdoll");
// todo: implement p_corpse
// TODO: implement p_corpse *properly*
layouter.AddToggleField(_Tr("Preferences", "Animations"), "cg_animations");
layouter.AddChoiceField(_Tr("Preferences", "Camera Shake"), "cg_shake",
array<string> = {_Tr("Preferences", "MORE"),
Expand All @@ -657,6 +657,7 @@ namespace spades {
_Tr("Preferences", "LESS"),
_Tr("Preferences", "OFF")},
array<int> = {2, 1, 0});
layouter.AddToggleField(_Tr("Preferences", "Show self tracers"), "cg_tracersFirstPerson");

layouter.AddHeading(_Tr("Preferences", "Feedbacks"));
layouter.AddVolumeSlider(_Tr("Preferences", "Chat Notify Sounds"), "cg_chatBeep");
Expand All @@ -668,30 +669,41 @@ namespace spades {
layouter.AddToggleField(_Tr("Preferences", "Allow Unicode"), "cg_unicode");
layouter.AddToggleField(_Tr("Preferences", "Server Alert"), "cg_serverAlert");

layouter.AddHeading(_Tr("Preferences", "Minimap"));
layouter.AddSliderField(_Tr("Preferences", "Size"), "cg_minimapSize", 0, 1024,
8, ConfigNumberFormatter(0, " px"));
layouter.AddToggleField(_TR("Preferences", "Player colors"), "cg_minimapPlayerColor");
layouter.AddToggleField(_TR("Preferences", "Player icons"), "cg_minimapPlayerIcon");

layouter.AddHeading(_Tr("Preferences", "Misc"));
layouter.AddSliderField(_Tr("Preferences", "Field of View"), "cg_fov", 1, 179, 1,
ConfigNumberFormatter(0, " deg"));
layouter.AddSliderField(_Tr("Preferences", "Minimap size"), "cg_minimapSize", 128, 256,
8, ConfigNumberFormatter(0, " px"));

layouter.AddToggleField(_Tr("Preferences", "Show Statistics"), "cg_stats");
layouter.AddToggleField(_Tr("Preferences", "Skip Spectating Dead Players"), "cg_skipDeadPlayersWhenDead");

layouter.AddHeading(_Tr("Preferences", "OpenSpades+"));
layouter.AddToggleField(_Tr("Preferences", "Viewmodel"), "p_viewmodel");
layouter.AddToggleField(_Tr("Preferences", "Show Custom Client Message"), "p_showCustomClientMessage");

ConfigField @clientField = layouter.AddInputField(
_Tr("Preferences", "Custom Client Message"), "p_customClientMessage", not options.GameActive);
clientField.MaxLength = 100;
clientField.DenyNonAscii = false;

layouter.AddToggleField(_Tr("Preferences", "Show IP (Stats)"), "p_showIP");
layouter.AddToggleField(_Tr("Preferences", "Accuracy (Stats)"), "p_showAccuracyInStats");
layouter.AddToggleField(_Tr("Preferences", "Accuracy (Map)"), "p_showAccuracyUnderMap");
layouter.AddToggleField(_Tr("Preferences", "Streamer Mode"), "p_streamer");
layouter.AddToggleField(_Tr("Preferences", "Damage Tint"), "p_hurtTint");
layouter.AddToggleField(_Tr("Preferences", "Damage Blood"), "p_hurtBlood");
layouter.AddToggleField(_Tr("Preferences", "Corpses"), "p_corpse");
layouter.AddToggleField(_Tr("Preferences", "Palette"), "p_hidePalette");

layouter.AddHeading(_Tr("Preferences", "PubOvl"));
layouter.AddToggleField(_Tr("Preferences", "Player names"), "po_names");
layouter.AddToggleField(_Tr("Preferences", "Aim tracers"), "po_tracers");
// TODO: implement
layouter.AddToggleField(_Tr("Preferences", "Wallhack"), "po_xray");


layouter.FinishLayout();
}
Expand Down
86 changes: 45 additions & 41 deletions Sources/Client/PaletteView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,47 +150,51 @@ namespace spades {

void PaletteView::Update() {}

void PaletteView::Draw() {
Handle<IImage> img = renderer.RegisterImage("Gfx/Palette.png");

int sel = GetSelectedIndex();

float scrW = renderer.ScreenWidth();
float scrH = renderer.ScreenHeight();

for (size_t phase = 0; phase < 2; phase++) {
for (size_t i = 0; i < colors.size(); i++) {
if ((sel == i) != (phase == 1))
continue;

int row = static_cast<int>(i / 8);
int col = static_cast<int>(i % 8);

bool selected = sel == i;

// draw color
IntVector3 icol = colors[i];
Vector4 cl;
cl.x = icol.x / 255.f;
cl.y = icol.y / 255.f;
cl.z = icol.z / 255.f;
cl.w = 1.f;

float x = scrW - 100.f + 10.f * col;
float y = scrH - 106.f + 10.f * row - 40.f;

renderer.SetColorAlphaPremultiplied(cl);
if (selected) {
renderer.DrawImage(img, MakeVector2(x, y), AABB2(0, 16, 16, 16));
} else {
renderer.DrawImage(img, MakeVector2(x, y), AABB2(0, 0, 16, 16));
}

renderer.SetColorAlphaPremultiplied(MakeVector4(1, 1, 1, 1));
if (selected) {
renderer.DrawImage(img, MakeVector2(x, y), AABB2(16, 16, 16, 16));
} else {
renderer.DrawImage(img, MakeVector2(x, y), AABB2(16, 0, 16, 16));
void PaletteView::Draw()
{
if (!p_hidePalette)
{
Handle<IImage> img = renderer.RegisterImage("Gfx/Palette.png");

int sel = GetSelectedIndex();

float scrW = renderer.ScreenWidth();
float scrH = renderer.ScreenHeight();

for (size_t phase = 0; phase < 2; phase++) {
for (size_t i = 0; i < colors.size(); i++) {
if ((sel == i) != (phase == 1))
continue;

int row = static_cast<int>(i / 8);
int col = static_cast<int>(i % 8);

bool selected = sel == i;

// draw color
IntVector3 icol = colors[i];
Vector4 cl;
cl.x = icol.x / 255.f;
cl.y = icol.y / 255.f;
cl.z = icol.z / 255.f;
cl.w = 1.f;

float x = scrW - 100.f + 10.f * col;
float y = scrH - 106.f + 10.f * row - 40.f;

renderer.SetColorAlphaPremultiplied(cl);
if (selected) {
renderer.DrawImage(img, MakeVector2(x, y), AABB2(0, 16, 16, 16));
} else {
renderer.DrawImage(img, MakeVector2(x, y), AABB2(0, 0, 16, 16));
}

renderer.SetColorAlphaPremultiplied(MakeVector4(1, 1, 1, 1));
if (selected) {
renderer.DrawImage(img, MakeVector2(x, y), AABB2(16, 16, 16, 16));
} else {
renderer.DrawImage(img, MakeVector2(x, y), AABB2(16, 0, 16, 16));
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions Sources/Plus/OpenSpadesPlus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ DEFINE_SPADES_SETTING(p_showAccuracyInStats, "1");
DEFINE_SPADES_SETTING(p_showAccuracyUnderMap, "0");
DEFINE_SPADES_SETTING(p_streamer, "0");
DEFINE_SPADES_SETTING(p_corpse, "0");
DEFINE_SPADES_SETTING(p_hidePalette, "0");

DEFINE_SPADES_SETTING(p_hurtTint, "1");
DEFINE_SPADES_SETTING(p_hurtBlood, "0");
Expand Down

0 comments on commit 94303db

Please sign in to comment.