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 63aec19
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 19 deletions.
11 changes: 9 additions & 2 deletions common/graphicsviewport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -981,12 +981,19 @@ void GraphicViewPortClass::Draw_Rect(int x1_pixel, int y1_pixel, int x2_pixel, i
Unlock();
}

void GraphicViewPortClass::Texture_Fill_Rect(int xpos, int ypos, int width, int height, unsigned char* shape_pointer, int source_width, int source_height)
void GraphicViewPortClass::Texture_Fill_Rect(int xpos,
int ypos,
int width,
int height,
unsigned char* shape_pointer,
int source_width,
int source_height)
{
if (Lock()) {
for (int y = ypos; y < ypos + height; y++) {
for (int x = xpos; x < xpos + width; x++) {
LogicPage->Put_Pixel(x, y, *(shape_pointer + ((y % source_height) * source_width) + (x % source_width)));
LogicPage->Put_Pixel(
x, y, *(shape_pointer + ((y % source_height) * source_width) + (x % source_width)));
}
}
Unlock();
Expand Down
8 changes: 7 additions & 1 deletion common/graphicsviewport.h
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,13 @@ class GraphicViewPortClass
void Remap(int sx, int sy, int width, int height, void* remap);
void Remap(void* remap);
void Draw_Stamp(void const* icondata, int icon, int x_pixel, int y_pixel, void const* remap, int clip_window);
void Texture_Fill_Rect(int xpos, int ypos, int width, int height, unsigned char* shape_pointer, int source_width, int source_height);
void Texture_Fill_Rect(int xpos,
int ypos,
int width,
int height,
unsigned char* shape_pointer,
int source_width,
int source_height);

// This doesnt seem to exist anywhere?? - Steve T 9/26/95 6:05PM
// VOID Grey_Out_Region(int x, int y, int width, int height, int color);
Expand Down
15 changes: 15 additions & 0 deletions common/settings.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "wwstd.h"
#include "settings.h"
#include "ini.h"
#include "miscasm.h"
Expand Down Expand Up @@ -36,6 +37,8 @@ SettingsClass::SettingsClass()

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

/*
** Mouse settings
*/
Expand Down Expand Up @@ -77,6 +80,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 +123,7 @@ 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
47 changes: 31 additions & 16 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.
{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.
};

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 63aec19

Please sign in to comment.