Skip to content

Commit 921d6eb

Browse files
committed
Added a function for getting the text and color for yes/no toggles
1 parent 545c09d commit 921d6eb

File tree

2 files changed

+18
-32
lines changed

2 files changed

+18
-32
lines changed

ttyd-tools/rel/include/draw.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ void drawText(const char *text, int32_t x, int32_t y, uint8_t alpha,
2020

2121
uint16_t getMessageWidth(const char *text, float scale);
2222
void getOnOffTextAndColor(bool valueToCheck, const char **textOut, uint32_t *colorOut);
23+
void getYesNoTextAndColor(bool valueToCheck, const char **textOut, uint32_t *colorOut);
2324
uint32_t getSelectedTextColor(bool valueToCheck);
2425

2526
void drawTextWithWindow(const char *text, int32_t textPosX, int32_t textPosY, uint8_t alpha,

ttyd-tools/rel/source/draw.cpp

Lines changed: 17 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,20 @@ void getOnOffTextAndColor(bool valueToCheck, const char **textOut, uint32_t *col
297297
}
298298
}
299299

300+
void getYesNoTextAndColor(bool valueToCheck, const char **textOut, uint32_t *colorOut)
301+
{
302+
if (valueToCheck)
303+
{
304+
*textOut = "Yes";
305+
*colorOut = 0x1BBE23FF; // Green
306+
}
307+
else
308+
{
309+
*textOut = "No";
310+
*colorOut = 0xFF1414FF; // Red
311+
}
312+
}
313+
300314
uint32_t getSelectedTextColor(bool valueToCheck)
301315
{
302316
if (valueToCheck)
@@ -1467,17 +1481,7 @@ void drawMemoryModifyList()
14671481
{
14681482
// Draw the Yes/No text for whether the watch is shown as hex or not
14691483
const char *YesNoText;
1470-
if (MemoryWatch[tempMenuSelectedOption].ShowAsHex)
1471-
{
1472-
YesNoText = "Yes";
1473-
Color = 0x1BBE23FF;
1474-
}
1475-
else
1476-
{
1477-
YesNoText = "No";
1478-
Color = 0xFF1414FF;
1479-
}
1480-
1484+
getYesNoTextAndColor(MemoryWatch[tempMenuSelectedOption].ShowAsHex, &YesNoText, &Color);
14811485
drawText(YesNoText, PosX + PosX_Offset, PosY, Alpha, Color, Scale);
14821486
break;
14831487
}
@@ -3454,16 +3458,7 @@ void drawWarpByEventMenuDetails()
34543458

34553459
// Draw the text for whether the standard inventory should be kept or not
34563460
const char *String;
3457-
if (WarpByEvent.ShouldKeepInventory)
3458-
{
3459-
Color = 0x1BBE23FF;
3460-
String = "Yes";
3461-
}
3462-
else
3463-
{
3464-
Color = 0xFF1414FF;
3465-
String = "No";
3466-
}
3461+
getYesNoTextAndColor(WarpByEvent.ShouldKeepInventory, &String, &Color);
34673462

34683463
int32_t tempPosX = PosX + 147;
34693464

@@ -3475,17 +3470,7 @@ void drawWarpByEventMenuDetails()
34753470
PosY -= 20;
34763471

34773472
// Draw the text for whether specific flags should be set or not
3478-
if (WarpByEvent.ShouldSetFlags)
3479-
{
3480-
Color = 0x1BBE23FF;
3481-
String = "Yes";
3482-
}
3483-
else
3484-
{
3485-
Color = 0xFF1414FF;
3486-
String = "No";
3487-
}
3488-
3473+
getYesNoTextAndColor(WarpByEvent.ShouldSetFlags, &String, &Color);
34893474
drawText(String, tempPosX, PosY, Alpha, Color, Scale);
34903475
PosY -= 60;
34913476

0 commit comments

Comments
 (0)