Skip to content

Commit

Permalink
Change CColor to be opaque (alpha=255) instead of transparent (alph…
Browse files Browse the repository at this point in the history
…a=0) by default.

It should fix issue with `VideoDrawChar` for some config.
  • Loading branch information
Jarod42 committed Feb 26, 2024
1 parent f584f2c commit 35df666
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/include/color.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ struct lua_State;
class CColor
{
public:
CColor() : R(0), G(0), B(0), A(0) {}
CColor() : R(0), G(0), B(0), A(255) {}
CColor(unsigned char r, unsigned char g, unsigned char b,
unsigned char a = 0) : R(r), G(g), B(b), A(a) {}
unsigned char a = 255) : R(r), G(g), B(b), A(a) {}
CColor(const CColor &color) = default;

void Parse(lua_State *l, int index = -1);
Expand Down
2 changes: 1 addition & 1 deletion src/include/font.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class CFont : public gcn::Font
class CFontColor
{
public:
explicit CFontColor(std::string ident) : Ident(std::move(ident)) {}
explicit CFontColor(std::string ident);

static CFontColor *New(const std::string &ident);
static CFontColor *Get(std::string_view ident);
Expand Down
2 changes: 1 addition & 1 deletion src/tolua/video.pkg
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public:

class CColor {
CColor(unsigned char r = 0, unsigned char g = 0, unsigned char b = 0,
unsigned char a = 0);
unsigned char a = 255);

unsigned char R;
unsigned char G;
Expand Down
10 changes: 10 additions & 0 deletions src/video/font.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -981,6 +981,16 @@ void ReloadFonts()
return font.get();
}

/**
* Constructor
*/
/* explicit */ CFontColor::CFontColor(std::string ident) : Ident(std::move(ident))
{
for (auto& color : Colors) {
color.a = SDL_ALPHA_OPAQUE;
}
}

/**
** Get a font
**
Expand Down

0 comments on commit 35df666

Please sign in to comment.