Skip to content

Commit e1507bd

Browse files
authored
Implement UI Theme change functionality
Added UI Theme change support to the hex editor interface.
1 parent ef01241 commit e1507bd

1 file changed

Lines changed: 20 additions & 16 deletions

File tree

src/main.cpp

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,10 @@
1717
#include <vector>
1818
#include "MoreOptionsMenu.h"
1919

20-
2120
APP_NAME("HexEditor")
2221
APP_DESCRIPTION("A simple hex editor. Can read and write byte, word and long. github.com/PyCSharp/CPHexEditor-For-HHK3")
2322
APP_AUTHOR("SnailMath, PyCSharp")
24-
APP_VERSION("2025.12.24")
23+
APP_VERSION("2025.12.24");
2524

2625
#define PIXEL(x, y) (vram[(x) + (y) * width])
2726
#define mem_ch(x) numToAscii[memory[x]]
@@ -177,6 +176,8 @@ void searchForText()
177176
}
178177

179178
int main() {
179+
CheckForDarkmode();
180+
180181
input[0] = '>';
181182
input[1] = '_';
182183
input[2] = 0;
@@ -270,7 +271,7 @@ int main() {
270271
unsigned int x = (unsigned int) event.data.touch_single.p1_x;
271272
unsigned int y = (unsigned int) event.data.touch_single.p1_y;
272273

273-
Debug_Printf(46, 2, false, 0, "%3d %3d", x, y);
274+
Debug_Printf(46, 2, isDarkmode, 0, "%3d %3d", x, y);
274275

275276
if (event.data.touch_single.direction == TOUCH_UP) {
276277
if (y >= 494 && y <= 524) {
@@ -428,20 +429,23 @@ int main() {
428429
}
429430

430431
void initscreen() {
431-
fillScreen(color(0, 0, 0));
432-
Debug_SetCursorPosition(1, 0);
432+
if (isDarkmode)
433+
fillScreen(color(0, 0, 0));
434+
else
435+
LCD_ClearScreen();
433436

437+
Debug_SetCursorPosition(1, 0);
434438

435-
Debug_PrintString("HexEditor PyCSharp", true);
436-
Debug_Printf(21, 1, true, 0, "github.com/");
437-
Debug_Printf(0, 4, true, 0, " 0 1 2 3 4 5 6 7");
439+
Debug_PrintString("HexEditor PyCSharp", isDarkmode);
440+
Debug_Printf(21, 1, isDarkmode, 0, "github.com/");
441+
Debug_Printf(0, 4, isDarkmode, 0, " 0 1 2 3 4 5 6 7");
438442
hexdump();
439-
Debug_Printf(40, 4, true, 0, "0x%08X", (unsigned int)(uintptr_t)memory);
440-
Debug_Printf(40, 6, true, 0, " < > ");
441-
Debug_Printf(1, 39, true, 0, "%8s", input);
442-
Debug_Printf(9, 40, true, 0, "0x%08X", (unsigned int)(uintptr_t)searchAddr);
443-
Debug_Printf(1, 42, true, 0, "Search: < > Goto Read Write ");
444-
Debug_Printf(36, 39, true, 0, "More Options");
443+
Debug_Printf(40, 4, isDarkmode, 0, "0x%08X", (unsigned int)(uintptr_t)memory);
444+
Debug_Printf(40, 6, isDarkmode, 0, " < > ");
445+
Debug_Printf(1, 39, isDarkmode, 0, "%8s", input);
446+
Debug_Printf(9, 40, isDarkmode, 0, "0x%08X", (unsigned int)(uintptr_t)searchAddr);
447+
Debug_Printf(1, 42, isDarkmode, 0, "Search: < > Goto Read Write ");
448+
Debug_Printf(36, 39, isDarkmode, 0, "More Options");
445449
Button(30, 30, 275, 62);
446450
Button(30, 30, 240, 62);
447451
Button(30, 30, 55, 494);
@@ -456,14 +460,14 @@ void hexdump() {
456460
if (!memory) return;
457461

458462
for (int i = 0; i < 16; i++) {
459-
Debug_Printf(1, 5 + (2 * i), true, 0,
463+
Debug_Printf(1, 5 + (2 * i), isDarkmode, 0,
460464
"%X %02X %02X %02X %02X %02X %02X %02X %02X %c%c%c%c %c%c%c%c", i,
461465
memory[0 + (16 * i)], memory[1 + (16 * i)], memory[2 + (16 * i)], memory[3 + (16 * i)],
462466
memory[4 + (16 * i)], memory[5 + (16 * i)], memory[6 + (16 * i)], memory[7 + (16 * i)],
463467
mem_ch(0 + (16 * i)), mem_ch(1 + (16 * i)), mem_ch(2 + (16 * i)), mem_ch(3 + (16 * i)),
464468
mem_ch(4 + (16 * i)), mem_ch(5 + (16 * i)), mem_ch(6 + (16 * i)), mem_ch(7 + (16 * i)));
465469

466-
Debug_Printf(1, 6 + (2 * i), true, 0,
470+
Debug_Printf(1, 6 + (2 * i), isDarkmode, 0,
467471
" %02X %02X %02X %02X %02X %02X %02X %02X %c%c%c%c %c%c%c%c",
468472
memory[8 + (16 * i)], memory[9 + (16 * i)], memory[10 + (16 * i)], memory[11 + (16 * i)],
469473
memory[12 + (16 * i)], memory[13 + (16 * i)], memory[14 + (16 * i)], memory[15 + (16 * i)],

0 commit comments

Comments
 (0)