From 5700e961c8f6261235b4a608b2c86e06f5623f99 Mon Sep 17 00:00:00 2001 From: y4my4my4m <8145020+y4my4my4m@users.noreply.github.com> Date: Wed, 31 May 2023 01:40:05 +0900 Subject: [PATCH] Random Colors hotkey in palette editor --- src/Home/PaletteEditor/Load.ZC | 1 + src/Home/PaletteEditor/PaletteEdit.ZC | 16 +++++--- src/Home/PaletteEditor/PaletteGod.ZC | 53 +++++++++++++++++---------- 3 files changed, 46 insertions(+), 24 deletions(-) diff --git a/src/Home/PaletteEditor/Load.ZC b/src/Home/PaletteEditor/Load.ZC index 812b6cab..7678cba0 100755 --- a/src/Home/PaletteEditor/Load.ZC +++ b/src/Home/PaletteEditor/Load.ZC @@ -1,4 +1,5 @@ Cd(__DIR__);; #define PALETTES_PATH "~/PaletteEditor/Palettes/" #include "PaletteSelect" +#include "PaletteGod" #include "PaletteEdit" \ No newline at end of file diff --git a/src/Home/PaletteEditor/PaletteEdit.ZC b/src/Home/PaletteEditor/PaletteEdit.ZC index 84713f59..5fda5cc7 100755 --- a/src/Home/PaletteEditor/PaletteEdit.ZC +++ b/src/Home/PaletteEditor/PaletteEdit.ZC @@ -38,14 +38,12 @@ U0 DrawCtrlSlider(CDC *dc, CCtrl *c) CSliderState *s = c->state; I64 size = (c->win_task->pix_width / 16), - border = size / 16, +// border = size / 16, size2 = (c->win_task->pix_height / 32), // slider_amount = 3, - i, k, j,// l, + i, pos, col, bias; - I64 rectSize = size / 16; // Size of each color rectangle - CBGR24 tempColor; /////////////////////// // CURRENT SELECTION // @@ -54,7 +52,7 @@ U0 DrawCtrlSlider(CDC *dc, CCtrl *c) // current color box preview dc->color = BLACK; GrPrint(dc, 10, 10, "Preview:"); - GrPrint(dc, 10, 26, "Current Color: #%d", selected_color); + GrPrint(dc, 10, 26, "Current Color: #%d", selected_color); if (selected_color == 15) dc->color = LTGRAY; @@ -428,6 +426,14 @@ public U0 PaletteEditor() current_palette = ""; current_palette = PaletteSelect; break; + case 'r': + gr_palette[selected_color] = ColorGod(FALSE, TRUE); + LFBFlush; + break; + case 'R': + gr_palette[selected_color] = PaletteGod(FALSE, TRUE); + LFBFlush; + break; case CH_CTRLI: PopUpOk("\n\n Use the arrows to select color\n\n # to manually input hex value","\n\n\n\t\tMade by y4my4m\n\n"); break; diff --git a/src/Home/PaletteEditor/PaletteGod.ZC b/src/Home/PaletteEditor/PaletteGod.ZC index be6c49c7..35cb3091 100755 --- a/src/Home/PaletteEditor/PaletteGod.ZC +++ b/src/Home/PaletteEditor/PaletteGod.ZC @@ -1,25 +1,40 @@ public U0 PaletteGod(Bool seedUse=TRUE, Bool instant=TRUE) { - // Instantly generate a random palette, seed-based or not + // Instantly generate a random palette, seed-based or not I64 i; - CBGR24 palette; - I32 color; + CBGR24 color; - if (seedUse) - Seed(GodPick); - for (i=0; i < 16; i++) - { - if (instant || seedUse) - { - color = RandI32; - palette = color & 0xFFFFFF; - } - else { - palette = GodPick & 0xFFFFFF; - } - gr_palette[i] = palette; - LFBFlush; - } + if (seedUse) + Seed(GodPick); + for (i=0; i < 16; i++) + { + if (instant || seedUse) + { + color = RandI32 & 0xFFFFFF; + } + else { + color = GodPick & 0xFFFFFF; + } + gr_palette[i] = color; + LFBFlush; + } } -PaletteGod; \ No newline at end of file +CBGR24 ColorGod(Bool seedUse=TRUE, Bool instant=TRUE) +{ + // Instantly generate a random color, seed-based or not + + if (seedUse) + Seed(GodPick); + if (instant || seedUse) + { + return RandI32 & 0xFFFFFF; + } + else { + return GodPick & 0xFFFFFF; + } + +} + + +// PaletteGod;