mirror of
https://github.com/Zeal-Operating-System/ZealOS.git
synced 2024-12-25 15:10:28 +00:00
Merge pull request #107 from Zeal-Operating-System/palette-update
PaletteEditor update
This commit is contained in:
commit
c3aaa3e621
4 changed files with 54 additions and 49 deletions
|
@ -1,4 +1,5 @@
|
|||
Cd(__DIR__);;
|
||||
#define PALETTES_PATH "~/PaletteEditor/Palettes/"
|
||||
#include "PaletteSelect"
|
||||
#include "PaletteGod"
|
||||
#include "PaletteEdit"
|
|
@ -38,13 +38,10 @@ U0 DrawCtrlSlider(CDC *dc, CCtrl *c)
|
|||
|
||||
CSliderState *s = c->state;
|
||||
I64 size = (c->win_task->pix_width / 16),
|
||||
border = size / 16,
|
||||
size2 = (c->win_task->pix_height / 32),
|
||||
// slider_amount = 3,
|
||||
i, k, j,// l,
|
||||
i,
|
||||
pos, col,
|
||||
bias;
|
||||
CBGR24 tempColor;
|
||||
|
||||
///////////////////////
|
||||
// CURRENT SELECTION //
|
||||
|
@ -53,17 +50,8 @@ 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);
|
||||
|
||||
// pixel loop for current color preview
|
||||
for (i = 0; i <= 12; i++)
|
||||
for (j = 0; j <= 12; j++)
|
||||
{
|
||||
tempColor = gr_palette[selected_color];
|
||||
if (i < border || i > 12 - border || j < border || j > 12 - border)
|
||||
tempColor = 0x000000;
|
||||
DrawPixel(c->win_task->pix_left + 78 + i, t + 7 + j, tempColor);
|
||||
}
|
||||
GrPrint(dc, 10, 26, "Current Color: #%d", selected_color + 1);
|
||||
if (selected_color == 15)
|
||||
dc->color = LTGRAY;
|
||||
else if (gr_palette[selected_color] > 0xCCCCCC)
|
||||
|
@ -72,7 +60,9 @@ U0 DrawCtrlSlider(CDC *dc, CCtrl *c)
|
|||
dc->color = 15;
|
||||
GrRect(dc, 94, 8, 58, 12);
|
||||
|
||||
// #Hex value
|
||||
dc->color = selected_color;
|
||||
GrRect(dc, 78, 8, 12, 12);
|
||||
GrPrint(dc, 95, 10, "#%x%x%x", gr_palette[selected_color].r,
|
||||
gr_palette[selected_color].g,
|
||||
gr_palette[selected_color].b);
|
||||
|
@ -152,27 +142,10 @@ U0 DrawCtrlSlider(CDC *dc, CCtrl *c)
|
|||
|
||||
for (i = 0; i < COLORS_NUM; i++)
|
||||
{
|
||||
for (j = 0; j <= size; j++)
|
||||
{
|
||||
for (k = 0; k <= size; k++)
|
||||
{
|
||||
tempColor = gr_palette[i];
|
||||
// black borders
|
||||
if (k < border || k > size - border || j < border || j > size - border - 1)
|
||||
{
|
||||
if (selected_color == i)
|
||||
tempColor = 0xFFFFFF;
|
||||
else
|
||||
tempColor = 0x000000;
|
||||
}
|
||||
// color preview
|
||||
DrawPixel(c->win_task->pix_left + j + (size * i), c->win_task->pix_bottom - size * 1.5 + k, tempColor);
|
||||
}
|
||||
}
|
||||
// color label and text preview
|
||||
// TODO: THIS LOGIC DOESNT WORK ON LIGHT THEMES
|
||||
// if color too light or too dark add bg
|
||||
|
||||
|
||||
if (i == 15)
|
||||
dc->color = LTGRAY;
|
||||
else if (gr_palette[i] < gr_palette[15])
|
||||
|
@ -183,23 +156,31 @@ U0 DrawCtrlSlider(CDC *dc, CCtrl *c)
|
|||
dc->color = LTRED;*/
|
||||
else
|
||||
dc->color = 15;
|
||||
|
||||
if (i == selected_color)
|
||||
dc->color = 0;
|
||||
GrRect(dc, 6, (size2 * 2) + 65 + 16 * i, 80, 18);
|
||||
GrRect(dc, (size * i), c->win_task->pix_height - (size - size / 2), size, size * 1.5);
|
||||
|
||||
GrRect(dc, 6, (size2 * 2) + 65 + 16 * i, 80, 18);
|
||||
|
||||
|
||||
|
||||
if (i == selected_color)
|
||||
dc->color = 15;
|
||||
else
|
||||
dc->color = i;
|
||||
|
||||
bias = (size / 2) - 4;
|
||||
if (i >= 9)
|
||||
bias = (size / 2) - 8;
|
||||
GrPrint(dc, bias + (i * size), c->win_task->pix_height - (size * .6) + (size / 4), "%d", i + 1);
|
||||
GrPrint(dc, 10, (size2 * 2) + 70 + 16 * i, "#%d: Test", i + 1);
|
||||
|
||||
GrPrint(dc, bias + (i * size), c->win_task->pix_height - (size * .6) + (size / 4), "%d", i);
|
||||
GrPrint(dc, 10, (size2 * 2) + 70 + 16 * i, "#%d: Test", i);
|
||||
// Border for preview box
|
||||
GrRect(dc, (size * i)-2, c->win_task->pix_height - (size*1.5)-1, size+2, size+1);
|
||||
// preview box
|
||||
dc->color = i;
|
||||
GrRect(dc, (size * i), c->win_task->pix_height - (size*1.5), size, size);
|
||||
}
|
||||
|
||||
|
||||
|
@ -373,12 +354,15 @@ public U0 PaletteEditor()
|
|||
" PreviousColor(,,SC_CURSOR_UP);"
|
||||
" NextColor(,,SC_CURSOR_RIGHT);"
|
||||
" NextColor(,,SC_CURSOR_DOWN);"
|
||||
" RandomColor(,'r');"
|
||||
" RandomPalette(,'R');"
|
||||
"}"
|
||||
"About {"
|
||||
" Info(,CH_CTRLI);"
|
||||
"}"
|
||||
);
|
||||
DocClear;
|
||||
DocCursor(OFF);
|
||||
WinBorder(ON);
|
||||
|
||||
CCtrl *c = SliderNew;
|
||||
|
@ -435,13 +419,20 @@ public U0 PaletteEditor()
|
|||
if (selected_color == 15)
|
||||
selected_color = -1;
|
||||
SelectColor(selected_color + 1, c);
|
||||
break;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case CH_CTRLO:
|
||||
current_palette = "";
|
||||
current_palette = PaletteSelect;
|
||||
break;
|
||||
case 'r':
|
||||
gr_palette[selected_color] = ColorGod;
|
||||
LFBFlush;
|
||||
break;
|
||||
case 'R':
|
||||
PaletteGod;
|
||||
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;
|
||||
|
|
|
@ -1,15 +1,18 @@
|
|||
|
||||
public U0 PaletteGodGenerate()
|
||||
{
|
||||
I64 i;
|
||||
CBGR24 palette;
|
||||
|
||||
for (i = 0; i < 16; i++)
|
||||
{
|
||||
palette = GodPick & 0xFFFFFF;
|
||||
gr_palette[i] = palette;
|
||||
LFBFlush;
|
||||
}
|
||||
CBGR24 ColorGod(Bool instant=TRUE)
|
||||
{// Generate a random color, seed-based or not
|
||||
if (instant)
|
||||
return RandI32 & 0xFFFFFF;
|
||||
else
|
||||
return GodPick & 0xFFFFFF;
|
||||
}
|
||||
|
||||
PaletteGodGenerate;
|
||||
public U0 PaletteGod(Bool seedUse=FALSE, Bool instant=TRUE)
|
||||
{// Generate a random palette, seed-based or not
|
||||
I64 i;
|
||||
|
||||
if (seedUse) Seed(GodPick);
|
||||
|
||||
for (i=0; i < 16; i++)
|
||||
gr_palette[i] = ColorGod(instant);
|
||||
LFBFlush;
|
||||
}
|
||||
|
|
10
src/Home/PaletteEditor/Palettes/Tradition.ZC
Executable file
10
src/Home/PaletteEditor/Palettes/Tradition.ZC
Executable file
|
@ -0,0 +1,10 @@
|
|||
public CBGR24 gr_palette_tradition[COLORS_NUM] = {
|
||||
0xE8E8E9, 0x374B88, 0x4FBC2C, 0x29CACE, 0xDD0000, 0x8C33FF, 0x875721, 0x7F7A7C, 0x15171C, 0x2EA1FF, 0x4FFF00, 0xFFBB, 0x690000, 0x6E3FFC, 0xFFCC00, 0xC0F14
|
||||
};
|
||||
public U0 PaletteSetTradition(Bool persistent=TRUE)
|
||||
{
|
||||
GrPaletteSet(gr_palette_tradition);
|
||||
LFBFlush;
|
||||
if (persistent)
|
||||
fp_set_std_palette = &PaletteSetTradition;
|
||||
}
|
Loading…
Reference in a new issue