Skip to content

Commit 5ccfe4b

Browse files
committed
Update ColorScheme & MessageListClass
- Deprecate superfluous/potentially inaccurate hardcoded color scheme index enum and update PrintMessage to have non-hardcoded default color
1 parent 781e598 commit 5ccfe4b

File tree

2 files changed

+21
-14
lines changed

2 files changed

+21
-14
lines changed

ColorScheme.h

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,19 @@ class LightConvertClass;
1515
class ColorScheme
1616
{
1717
public:
18-
enum {
18+
19+
enum [[deprecated("Only valid for vanilla color scheme configuration and should not be used.")]]
20+
{
1921
//ColorScheme indices, since they are hardcoded all over the exe, why shan't we do it as well?
20-
Yellow = 3,
21-
White = 5,
22-
Grey = 7,
23-
Red = 11,
24-
Orange = 13,
25-
Pink = 15,
26-
Purple = 17,
27-
Blue = 21,
28-
Green = 29,
22+
Yellow = 3,
23+
White = 5,
24+
Grey = 7,
25+
Red = 11,
26+
Orange = 13,
27+
Pink = 15,
28+
Purple = 17,
29+
Blue = 21,
30+
Green = 29,
2931
};
3032

3133
//global array

MessageListClass.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,17 @@ class MessageListClass
8080

8181
// if pLabel is given, the message will be {$pLabel}:{$pMessage}
8282
// else it will be just {$pMessage}
83-
void PrintMessage(const wchar_t* pMessage, int durationFrames = 0x96, int nColorSchemeIndex = ColorScheme::White, bool bSilent = false)
84-
{ this->AddMessage(nullptr, 0, pMessage, nColorSchemeIndex, static_cast<TextPrintType>(0x4046), durationFrames, bSilent); }
83+
// nColorSchemeIndex = -1 will use LightGrey color scheme to print the message, or if it fails to find that color scheme index 0.
84+
void PrintMessage(const wchar_t* pMessage, int durationFrames = 0x96, int nColorSchemeIndex = -1, bool bSilent = false)
85+
{
86+
if (nColorSchemeIndex < 0 )
87+
nColorSchemeIndex = Math::max(ColorScheme::FindIndex("LightGrey", 53), 0);
8588

86-
void PrintMessage(const wchar_t* pMessage, double durationMinutes, int nColorSchemeIndex = ColorScheme::White, bool bSilent = false)
87-
{ this->AddMessage(nullptr, 0, pMessage, nColorSchemeIndex, static_cast<TextPrintType>(0x4046), static_cast<int>(durationMinutes * 900), bSilent); }
89+
this->AddMessage(nullptr, 0, pMessage, nColorSchemeIndex, static_cast<TextPrintType>(0x4046), durationFrames, bSilent);
90+
}
8891

92+
void PrintMessage(const wchar_t* pMessage, double durationMinutes, int nColorSchemeIndex = -1, bool bSilent = false)
93+
{ PrintMessage(pMessage, static_cast<int>(durationMinutes * 900), nColorSchemeIndex, bSilent); }
8994

9095
TextLabelClass* MessageList;
9196
Point2D MessagePos;

0 commit comments

Comments
 (0)