Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add C&C Gold-style buttons (Fixes #919) #986

Merged
merged 2 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions common/graphicsviewport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -980,3 +980,22 @@ void GraphicViewPortClass::Draw_Rect(int x1_pixel, int y1_pixel, int x2_pixel, i
Draw_Line(x2_pixel, y1_pixel, x2_pixel, y2_pixel, color);
Unlock();
}

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)));
}
}
Unlock();
}
}
11 changes: 2 additions & 9 deletions common/graphicsviewport.h
Original file line number Diff line number Diff line change
Expand Up @@ -289,20 +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);

// PG_TO_FIX
// This seems to be missing. Might not be needed anyway since it looks like it's only used for UI drawing. ST -
// 12/17/2018 6:11PM
void Texture_Fill_Rect(int xpos,
int ypos,
int width,
int height,
void const* shape_pointer,
unsigned char* shape_pointer,
int source_width,
int source_height)
{
return;
}
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
Loading