Skip to content

Commit

Permalink
TD: Selectable button style
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBarrett committed Mar 27, 2024
1 parent e01eda8 commit dae71dc
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 12 deletions.
13 changes: 13 additions & 0 deletions common/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ SettingsClass::SettingsClass()

void SettingsClass::Load(INIClass& ini)
{
char buf[128];

/*
** Mouse settings
*/
Expand Down Expand Up @@ -77,6 +79,15 @@ void SettingsClass::Load(INIClass& ini)
if (Video.Boxing || Mouse.RawInput || Mouse.ControllerEnabled) {
Video.HardwareCursor = false;
}

ini.Get_String("Video", "ButtonStyle", "Default", buf, sizeof(buf));
if (!stricmp(buf, "Gold")) {
Video.ButtonStyle = 1;
} else if (!stricmp(buf, "Classic") || !stricmp(buf, "DOS")) {
Video.ButtonStyle = 0;
} else {
Video.ButtonStyle = -1;
}
}

void SettingsClass::Save(INIClass& ini)
Expand Down Expand Up @@ -111,4 +122,6 @@ void SettingsClass::Save(INIClass& ini)
** VQA and WSA interpolation mode 0 = scanlines, 1 = vertical doubling, 2 = linear
*/
ini.Put_Int("Video", "InterpolationMode", Video.InterpolationMode);

ini.Put_String("Video", "ButtonStyle", Video.ButtonStyle == -1 ? "Default" : (Video.ButtonStyle == 1 ? "Gold" : "Classic"));
}
1 change: 1 addition & 0 deletions common/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class SettingsClass
int InterpolationMode;
bool HardwareCursor;
bool DOSMode;
int ButtonStyle;
std::string Scaler;
std::string Driver;
std::string PixelFormat;
Expand Down
39 changes: 27 additions & 12 deletions tiberiandawn/dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

#include "function.h"
#include "settings.h"

/***********************************************************************************************
* Dialog_Box -- draws a dialog background box *
Expand Down Expand Up @@ -93,10 +94,8 @@ extern void CC_Texture_Fill(void const* shapefile, int shapenum, int xpos, int y

void Draw_Box(int x, int y, int w, int h, BoxStyleEnum up, bool filled)
{
static BoxStyleType const ButtonColors[BOXSTYLE_COUNT] = {

static BoxStyleType const ButtonColorsClassic[BOXSTYLE_COUNT] = {
// Filler, Shadow, Hilite, Corner colors

{LTGREY, WHITE, DKGREY, LTGREY}, // 0 Button is down.
{LTGREY, DKGREY, WHITE, LTGREY}, // 1 Button is up w/border.
{LTBLUE, BLUE, LTCYAN, LTBLUE}, // 2 Raised blue.
Expand All @@ -105,29 +104,45 @@ void Draw_Box(int x, int y, int w, int h, BoxStyleEnum up, bool filled)
{LTGREY, DKGREY, WHITE, LTGREY}, // 5 Button is up w/arrows.
{CC_GREEN_BKGD, CC_LIGHT_GREEN, CC_GREEN_SHADOW, CC_GREEN_CORNERS}, // 6 Button is down.
{CC_GREEN_BKGD, CC_GREEN_SHADOW, CC_LIGHT_GREEN, CC_GREEN_CORNERS}, // 7 Button is up w/border.
// {CC_GREEN_BKGD, 14, 12, 13}, // 6 Button is down.
// {CC_GREEN_BKGD, 12, 14, 13}, // 7 Button is up w/border.
{DKGREY, WHITE, BLACK, DKGREY}, // 8 Button is disabled down.
{DKGREY, BLACK, LTGREY, DKGREY}, // 9 Button is disabled up.
{BLACK, CC_GREEN_BOX, CC_GREEN_BOX, BLACK}, // 10 List box.
{BLACK, CC_GREEN_BOX, CC_GREEN_BOX, BLACK}, // 11 Menu box.
// {BLACK, 14, 14, BLACK}, // 10 List box.
// {BLACK, 14, 14, BLACK}, // 11 Menu box.
};

static BoxStyleType const ButtonColorsGold[BOXSTYLE_COUNT] = {
// Filler, Shadow, Hilite, Corner colors
{LTGREY, WHITE, DKGREY, LTGREY}, // 0 Button is down.
{LTGREY, DKGREY, WHITE, LTGREY}, // 1 Button is up w/border.
{LTBLUE, BLUE, LTCYAN, LTBLUE}, // 2 Raised blue.
{DKGREY, WHITE, BLACK, DKGREY}, // 3 Button is disabled down.
{DKGREY, BLACK, WHITE, LTGREY}, // 4 Button is disabled up.
{LTGREY, DKGREY, WHITE, LTGREY}, // 5 Button is up w/arrows.
{CC_GREEN_BKGD, 14, 12, 13}, // 6 Button is down.
{CC_GREEN_BKGD, 12, 14, 13}, // 7 Button is up w/border.
{DKGREY, WHITE, BLACK, DKGREY}, // 8 Button is disabled down.
{DKGREY, BLACK, LTGREY, DKGREY}, // 9 Button is disabled up.
{BLACK, 14, 14, BLACK}, // 10 List box.
{BLACK, 14, 14, BLACK}, // 11 Menu box.
};

bool useGoldStyle;
if (Settings.Video.ButtonStyle == -1) {
useGoldStyle = !Settings.Video.DOSMode;
} else {
useGoldStyle = Settings.Video.ButtonStyle == 1;
}

w--;
h--;
BoxStyleType const& style = ButtonColors[up];
BoxStyleType const& style = useGoldStyle ? ButtonColorsGold[up] : ButtonColorsClassic[up];

if (filled) {
/*
if (style.Filler == CC_GREEN_BKGD) {
if (useGoldStyle && style.Filler == CC_GREEN_BKGD) {
CC_Texture_Fill(MFCD::Retrieve("BTEXTURE.SHP"), InMainLoop, x, y, w, h);
} else {
LogicPage->Fill_Rect(x, y, x + w, y + h, style.Filler);
}
*/
LogicPage->Fill_Rect(x, y, x + w, y + h, style.Filler);
}

switch (up) {
Expand Down

0 comments on commit dae71dc

Please sign in to comment.