ZealOS/docs/Home/PaletteEditor/PaletteEdit.CC.html
2021-11-30 17:24:57 -05:00

509 lines
50 KiB
HTML
Executable file

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=US-ASCII">
<meta name="generator" content="ZealOS V1.05">
<style type="text/css">
body {background-color:#1f1f1f;}
.cF0{color:#e3e3e3;background-color:#1f1f1f;}
.cF1{color:#4f84a6;background-color:#1f1f1f;}
.cF2{color:#73a255;background-color:#1f1f1f;}
.cF3{color:#297582;background-color:#1f1f1f;}
.cF4{color:#b34f4b;background-color:#1f1f1f;}
.cF5{color:#8a52c3;background-color:#1f1f1f;}
.cF6{color:#b7822f;background-color:#1f1f1f;}
.cF7{color:#444444;background-color:#1f1f1f;}
.cF8{color:#6d6d6d;background-color:#1f1f1f;}
.cF9{color:#94bfde;background-color:#1f1f1f;}
.cFA{color:#a1ce97;background-color:#1f1f1f;}
.cFB{color:#6db4be;background-color:#1f1f1f;}
.cFC{color:#e88e88;background-color:#1f1f1f;}
.cFD{color:#ca94e8;background-color:#1f1f1f;}
.cFE{color:#d4b475;background-color:#1f1f1f;}
.cFF{color:#1f1f1f;background-color:#1f1f1f;}
</style>
</head>
<body>
<pre style="font-family:monospace;font-size:12pt">
<a name="l1"></a><span class=cF0>#</span><span class=cF1>ifndef</span><span class=cF0> PALETTES_PATH
<a name="l2"></a></span><span class=cF5>Cd</span><span class=cF0>(</span><span class=cF3>__DIR__</span><span class=cF0>);;
<a name="l3"></a>#</span><span class=cF1>include</span><span class=cF0> </span><span class=cF6>&quot;Load&quot;</span><span class=cF0>
<a name="l4"></a>#</span><span class=cF1>endif</span><span class=cF0>
<a name="l5"></a>
<a name="l6"></a></span><span class=cF2>// FIXME: bug where holding CTRL for 5-ish seconds crashes program!</span><span class=cF0>
<a name="l7"></a></span><span class=cF2>// TODO: move to Demo/Graphics, make sprite link in Menu</span><span class=cF0>
<a name="l8"></a>
<a name="l9"></a>#</span><span class=cF1>define</span><span class=cF0> SLIDER_RANGE </span><span class=cFE>255</span><span class=cF0>
<a name="l10"></a>#</span><span class=cF1>define</span><span class=cF0> SLIDER_SPACING </span><span class=cFE>28</span><span class=cF0>
<a name="l11"></a>#</span><span class=cF1>define</span><span class=cF0> SLIDER_BORDER </span><span class=cFE>2</span><span class=cF0>
<a name="l12"></a>
<a name="l13"></a></span><span class=cF9>I64</span><span class=cF0> current_palette = </span><span class=cF6>&quot;*New Palette&quot;</span><span class=cF0>;
<a name="l14"></a></span><span class=cF9>I64</span><span class=cF0> selected_color = </span><span class=cFE>0</span><span class=cF0>;
<a name="l15"></a></span><span class=cF9>I64</span><span class=cF0> l, r, t, b;
<a name="l16"></a>
<a name="l17"></a></span><span class=cF1>U8</span><span class=cF0> *manual_value;
<a name="l18"></a>
<a name="l19"></a></span><span class=cF9>CBGR24</span><span class=cF0> gr_temp_palette[</span><span class=cF3>COLORS_NUM</span><span class=cF0>];
<a name="l20"></a>
<a name="l21"></a></span><span class=cF1>class</span><span class=cF0> CSliderState
<a name="l22"></a>{
<a name="l23"></a> </span><span class=cF9>I64</span><span class=cF0> left_pos;
<a name="l24"></a> </span><span class=cF9>I64</span><span class=cF0> middle_pos;
<a name="l25"></a> </span><span class=cF9>I64</span><span class=cF0> right_pos;
<a name="l26"></a> </span><span class=cF9>I64</span><span class=cF0> preview;
<a name="l27"></a> </span><span class=cF9>CBGR24</span><span class=cF0> color;
<a name="l28"></a>
<a name="l29"></a>} sld;
<a name="l30"></a>
<a name="l31"></a></span><span class=cF1>I0</span><span class=cF0> DrawPixel(</span><span class=cF9>I64</span><span class=cF0> x, </span><span class=cF9>I64</span><span class=cF0> y, </span><span class=cF9>CBGR24</span><span class=cF0> color)
<a name="l32"></a>{
<a name="l33"></a> </span><span class=cFB>text</span><span class=cF0>.fb_alias[x + y * </span><span class=cF3>GR_WIDTH</span><span class=cF0>] = color;
<a name="l34"></a>}
<a name="l35"></a>
<a name="l36"></a></span><span class=cF1>U0</span><span class=cF0> DrawCtrlSlider(</span><span class=cF9>CDC</span><span class=cF0> *dc, </span><span class=cF9>CCtrl</span><span class=cF0> *c)
<a name="l37"></a>{
<a name="l38"></a>
<a name="l39"></a> CSliderState *s = c-&gt;state;
<a name="l40"></a> </span><span class=cF9>I64</span><span class=cF0> size = (c-&gt;win_task-&gt;pix_width / </span><span class=cFE>16</span><span class=cF0>),
<a name="l41"></a> border = size / </span><span class=cFE>16</span><span class=cF0>,
<a name="l42"></a> size2 = (c-&gt;win_task-&gt;pix_height / </span><span class=cFE>32</span><span class=cF0>),
<a name="l43"></a></span><span class=cF2>//</span><span class=cF0> </span><span class=cF2>slider_amount = 3,</span><span class=cF0>
<a name="l44"></a> i, k, j,</span><span class=cF2>// l,</span><span class=cF0>
<a name="l45"></a> pos, col,
<a name="l46"></a> bias;
<a name="l47"></a> </span><span class=cF9>CBGR24</span><span class=cF0> tempColor;
<a name="l48"></a>
<a name="l49"></a> </span><span class=cF2>///////////////////////</span><span class=cF0>
<a name="l50"></a> </span><span class=cF2>// CURRENT SELECTION //</span><span class=cF0>
<a name="l51"></a> </span><span class=cF2>///////////////////////</span><span class=cF0>
<a name="l52"></a>
<a name="l53"></a> </span><span class=cF2>// current color box preview</span><span class=cF0>
<a name="l54"></a> dc-&gt;color = </span><span class=cF3>BLACK</span><span class=cF0>;
<a name="l55"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc, </span><span class=cFE>10</span><span class=cF0>, </span><span class=cFE>10</span><span class=cF0>, </span><span class=cF6>&quot;Preview:&quot;</span><span class=cF0>);
<a name="l56"></a>
<a name="l57"></a> </span><span class=cF2>// pixel loop for current color preview</span><span class=cF0>
<a name="l58"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i &lt;= </span><span class=cFE>12</span><span class=cF0>; i++)
<a name="l59"></a> </span><span class=cF1>for</span><span class=cF0> (j = </span><span class=cFE>0</span><span class=cF0>; j &lt;= </span><span class=cFE>12</span><span class=cF0>; j++)
<a name="l60"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l61"></a> tempColor = </span><span class=cFB>gr_palette</span><span class=cF0>[selected_color];
<a name="l62"></a> </span><span class=cF1>if</span><span class=cF0> (i &lt; border || i &gt; </span><span class=cFE>12</span><span class=cF0> - border || j &lt; border || j &gt; </span><span class=cFE>12</span><span class=cF0> - border)
<a name="l63"></a> tempColor = </span><span class=cFE>0x000000</span><span class=cF0>;
<a name="l64"></a> DrawPixel(c-&gt;win_task-&gt;pix_left + </span><span class=cFE>78</span><span class=cF0> + i, t + </span><span class=cFE>7</span><span class=cF0> + j, tempColor);
<a name="l65"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l66"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc, </span><span class=cFE>10</span><span class=cF0>, </span><span class=cFE>26</span><span class=cF0>, </span><span class=cF6>&quot;Current Color: #%d&quot;</span><span class=cF0>, selected_color + </span><span class=cFE>1</span><span class=cF0>);
<a name="l67"></a> </span><span class=cF1>if</span><span class=cF0> (selected_color == </span><span class=cFE>15</span><span class=cF0>)
<a name="l68"></a> dc-&gt;color = </span><span class=cF3>LTGRAY</span><span class=cF0>;
<a name="l69"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFB>gr_palette</span><span class=cF0>[selected_color] &gt; </span><span class=cFE>0xCCCCCC</span><span class=cF0>)
<a name="l70"></a> dc-&gt;color = </span><span class=cF3>DKGRAY</span><span class=cF0>;
<a name="l71"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l72"></a> dc-&gt;color = </span><span class=cFE>15</span><span class=cF0>;
<a name="l73"></a> </span><span class=cF5>GrRect</span><span class=cF0>(dc, </span><span class=cFE>94</span><span class=cF0>, </span><span class=cFE>8</span><span class=cF0>, </span><span class=cFE>58</span><span class=cF0>, </span><span class=cFE>12</span><span class=cF0>);
<a name="l74"></a>
<a name="l75"></a> dc-&gt;color = selected_color;
<a name="l76"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc, </span><span class=cFE>95</span><span class=cF0>, </span><span class=cFE>10</span><span class=cF0>, </span><span class=cF6>&quot;#%x%x%x&quot;</span><span class=cF0>, </span><span class=cFB>gr_palette</span><span class=cF0>[selected_color].r,
<a name="l77"></a> </span><span class=cFB>gr_palette</span><span class=cF0>[selected_color].g,
<a name="l78"></a> </span><span class=cFB>gr_palette</span><span class=cF0>[selected_color].b);
<a name="l79"></a>
<a name="l80"></a> </span><span class=cF2>// palette name</span><span class=cF0>
<a name="l81"></a> dc-&gt;color = </span><span class=cF3>BLACK</span><span class=cF0>;
<a name="l82"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc, </span><span class=cFE>10</span><span class=cF0>, </span><span class=cFE>43</span><span class=cF0>, </span><span class=cF6>&quot;Palette: %s&quot;</span><span class=cF0>, current_palette);
<a name="l83"></a>
<a name="l84"></a> </span><span class=cF2>////////////</span><span class=cF0>
<a name="l85"></a> </span><span class=cF2>// SLIDER //</span><span class=cF0>
<a name="l86"></a> </span><span class=cF2>////////////</span><span class=cF0>
<a name="l87"></a>
<a name="l88"></a> </span><span class=cF2>//box</span><span class=cF0>
<a name="l89"></a> dc-&gt;color = </span><span class=cF3>LTRED</span><span class=cF0>;
<a name="l90"></a> </span><span class=cF5>GrRect</span><span class=cF0>(dc, c-&gt;left,
<a name="l91"></a> c-&gt;top,
<a name="l92"></a> SLIDER_SPACING * </span><span class=cFE>4</span><span class=cF0> + </span><span class=cFE>2</span><span class=cF0>,
<a name="l93"></a> SLIDER_SPACING * </span><span class=cFE>2</span><span class=cF0> + SLIDER_RANGE);
<a name="l94"></a> dc-&gt;color = </span><span class=cF3>BLUE</span><span class=cF0>;
<a name="l95"></a> </span><span class=cF5>GrRect</span><span class=cF0>(dc, c-&gt;left + SLIDER_BORDER,
<a name="l96"></a> c-&gt;top + SLIDER_BORDER,
<a name="l97"></a> SLIDER_SPACING * </span><span class=cFE>4</span><span class=cF0> + </span><span class=cFE>2</span><span class=cF0> - </span><span class=cFE>2</span><span class=cF0> * SLIDER_BORDER,
<a name="l98"></a> SLIDER_SPACING * </span><span class=cFE>2</span><span class=cF0> + SLIDER_RANGE - </span><span class=cFE>2</span><span class=cF0> * SLIDER_BORDER);
<a name="l99"></a>
<a name="l100"></a> </span><span class=cF2>//slider</span><span class=cF0>
<a name="l101"></a> dc-&gt;color = </span><span class=cF3>BLACK</span><span class=cF0>;
<a name="l102"></a>
<a name="l103"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>1</span><span class=cF0>; i &lt;= </span><span class=cFE>3</span><span class=cF0>; i++)
<a name="l104"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l105"></a> </span><span class=cF5>GrLine</span><span class=cF0>(dc, c-&gt;left + i * SLIDER_SPACING + i - </span><span class=cFE>1</span><span class=cF0>,
<a name="l106"></a> c-&gt;top + SLIDER_SPACING,
<a name="l107"></a> c-&gt;left + i * SLIDER_SPACING + i - </span><span class=cFE>1</span><span class=cF0>,
<a name="l108"></a> c-&gt;top + SLIDER_SPACING + SLIDER_RANGE - </span><span class=cFE>1</span><span class=cF0>);
<a name="l109"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l110"></a>
<a name="l111"></a> </span><span class=cF2>//values</span><span class=cF0>
<a name="l112"></a> dc-&gt;color = </span><span class=cF3>LTRED</span><span class=cF0>;
<a name="l113"></a>
<a name="l114"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>1</span><span class=cF0>; i &lt;= </span><span class=cFE>3</span><span class=cF0>; i++)
<a name="l115"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l116"></a> </span><span class=cF1>switch</span><span class=cF0> (i)
<a name="l117"></a> {
<a name="l118"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cFE>1</span><span class=cF0>:
<a name="l119"></a> pos = s-&gt;left_pos;
<a name="l120"></a> col = </span><span class=cF6>&quot;R&quot;</span><span class=cF0>;
<a name="l121"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l122"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cFE>2</span><span class=cF0>:
<a name="l123"></a> pos = s-&gt;middle_pos;
<a name="l124"></a> col = </span><span class=cF6>&quot;G&quot;</span><span class=cF0>;
<a name="l125"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l126"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cFE>3</span><span class=cF0>:
<a name="l127"></a> pos = s-&gt;right_pos;
<a name="l128"></a> col = </span><span class=cF6>&quot;B&quot;</span><span class=cF0>;
<a name="l129"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l130"></a> }
<a name="l131"></a>
<a name="l132"></a> </span><span class=cF2>//values</span><span class=cF0>
<a name="l133"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc, c-&gt;left + i * SLIDER_SPACING + i - </span><span class=cF3>FONT_WIDTH</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF0>,
<a name="l134"></a> c-&gt;top + SLIDER_SPACING + SLIDER_RANGE + </span><span class=cFE>8</span><span class=cF0>,
<a name="l135"></a> </span><span class=cF6>&quot;%d&quot;</span><span class=cF0>, pos);
<a name="l136"></a> </span><span class=cF2>//RGB label</span><span class=cF0>
<a name="l137"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc, c-&gt;left + i * SLIDER_SPACING + </span><span class=cFE>3</span><span class=cF0> - </span><span class=cF3>FONT_WIDTH</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF0>,
<a name="l138"></a> c-&gt;top + </span><span class=cFE>14</span><span class=cF0>,
<a name="l139"></a> </span><span class=cF6>&quot;%s&quot;</span><span class=cF0>, col);
<a name="l140"></a> </span><span class=cF2>//knobs</span><span class=cF0>
<a name="l141"></a> </span><span class=cF5>GrRect</span><span class=cF0>(dc, c-&gt;left + i * SLIDER_SPACING + i - </span><span class=cFE>4</span><span class=cF0>,
<a name="l142"></a> c-&gt;top + SLIDER_SPACING + SLIDER_RANGE - </span><span class=cFE>1</span><span class=cF0> - pos - </span><span class=cFE>2</span><span class=cF0>,
<a name="l143"></a> </span><span class=cFE>7</span><span class=cF0>, </span><span class=cFE>5</span><span class=cF0>);
<a name="l144"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l145"></a>
<a name="l146"></a> </span><span class=cF2>////////////////////</span><span class=cF0>
<a name="l147"></a> </span><span class=cF2>// COLORS PREVIEW //</span><span class=cF0>
<a name="l148"></a> </span><span class=cF2>////////////////////</span><span class=cF0>
<a name="l149"></a>
<a name="l150"></a> dc-&gt;color = </span><span class=cFE>8</span><span class=cF0>;
<a name="l151"></a> </span><span class=cF5>GrRect</span><span class=cF0>(dc, </span><span class=cFE>0</span><span class=cF0>, c-&gt;win_task-&gt;pix_height + size * </span><span class=cFE>1</span><span class=cF0>.</span><span class=cFE>5</span><span class=cF0> - size * </span><span class=cFE>2</span><span class=cF0>, c-&gt;win_task-&gt;pix_width, size * </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>75</span><span class=cF0>);
<a name="l152"></a>
<a name="l153"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i &lt; </span><span class=cF3>COLORS_NUM</span><span class=cF0>; i++)
<a name="l154"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l155"></a> </span><span class=cF1>for</span><span class=cF0> (j = </span><span class=cFE>0</span><span class=cF0>; j &lt;= size; j++)
<a name="l156"></a> {
<a name="l157"></a> </span><span class=cF1>for</span><span class=cF0> (k = </span><span class=cFE>0</span><span class=cF0>; k &lt;= size; k++)
<a name="l158"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l159"></a> tempColor = </span><span class=cFB>gr_palette</span><span class=cF0>[i];
<a name="l160"></a> </span><span class=cF2>// black borders</span><span class=cF0>
<a name="l161"></a> </span><span class=cF1>if</span><span class=cF0> (k &lt; border || k &gt; size - border || j &lt; border || j &gt; size - border - </span><span class=cFE>1</span><span class=cF0>)
<a name="l162"></a> {
<a name="l163"></a> </span><span class=cF1>if</span><span class=cF0> (selected_color == i)
<a name="l164"></a> tempColor = </span><span class=cFE>0xFFFFFF</span><span class=cF0>;
<a name="l165"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l166"></a> tempColor = </span><span class=cFE>0x000000</span><span class=cF0>;
<a name="l167"></a> }
<a name="l168"></a> </span><span class=cF2>// color preview</span><span class=cF0>
<a name="l169"></a> DrawPixel(c-&gt;win_task-&gt;pix_left + j + </span><span class=cF7>(</span><span class=cF0>size * i</span><span class=cF7>)</span><span class=cF0>, c-&gt;win_task-&gt;pix_bottom - size * </span><span class=cFE>1</span><span class=cF0>.</span><span class=cFE>5</span><span class=cF0> + k, tempColor);
<a name="l170"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l171"></a> }
<a name="l172"></a> </span><span class=cF2>// color label and text preview</span><span class=cF0>
<a name="l173"></a> </span><span class=cF2>// TODO: THIS LOGIC DOESNT WORK ON LIGHT THEMES</span><span class=cF0>
<a name="l174"></a> </span><span class=cF2>// if color too light or too dark add bg</span><span class=cF0>
<a name="l175"></a>
<a name="l176"></a> </span><span class=cF1>if</span><span class=cF0> (i == </span><span class=cFE>15</span><span class=cF0>)
<a name="l177"></a> dc-&gt;color = </span><span class=cF3>LTGRAY</span><span class=cF0>;
<a name="l178"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFB>gr_palette</span><span class=cF0>[i] &lt; </span><span class=cFB>gr_palette</span><span class=cF0>[</span><span class=cFE>15</span><span class=cF0>])
<a name="l179"></a> dc-&gt;color = </span><span class=cF3>LTGRAY</span><span class=cF0>;
<a name="l180"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFB>gr_palette</span><span class=cF0>[i] &gt; </span><span class=cFB>gr_palette</span><span class=cF0>[</span><span class=cFE>0</span><span class=cF0>])
<a name="l181"></a> dc-&gt;color = </span><span class=cF3>DKGRAY</span><span class=cF0>;
<a name="l182"></a> </span><span class=cF2>/*else if (i == 7)</span><span class=cF0>
<a name="l183"></a> </span><span class=cF2>dc-&gt;color = LTRED;*/</span><span class=cF0>
<a name="l184"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l185"></a> dc-&gt;color = </span><span class=cFE>15</span><span class=cF0>;
<a name="l186"></a> </span><span class=cF1>if</span><span class=cF0> (i == selected_color)
<a name="l187"></a> dc-&gt;color = </span><span class=cFE>0</span><span class=cF0>;
<a name="l188"></a> </span><span class=cF5>GrRect</span><span class=cF0>(dc, </span><span class=cFE>6</span><span class=cF0>, </span><span class=cF7>(</span><span class=cF0>size2 * </span><span class=cFE>2</span><span class=cF7>)</span><span class=cF0> + </span><span class=cFE>65</span><span class=cF0> + </span><span class=cFE>16</span><span class=cF0> * i, </span><span class=cFE>80</span><span class=cF0>, </span><span class=cFE>18</span><span class=cF0>);
<a name="l189"></a> </span><span class=cF5>GrRect</span><span class=cF0>(dc, </span><span class=cF7>(</span><span class=cF0>size * i</span><span class=cF7>)</span><span class=cF0>, c-&gt;win_task-&gt;pix_height - </span><span class=cF7>(</span><span class=cF0>size - size / </span><span class=cFE>2</span><span class=cF7>)</span><span class=cF0>, size, size * </span><span class=cFE>1</span><span class=cF0>.</span><span class=cFE>5</span><span class=cF0>);
<a name="l190"></a>
<a name="l191"></a> </span><span class=cF5>GrRect</span><span class=cF0>(dc, </span><span class=cFE>6</span><span class=cF0>, </span><span class=cF7>(</span><span class=cF0>size2 * </span><span class=cFE>2</span><span class=cF7>)</span><span class=cF0> + </span><span class=cFE>65</span><span class=cF0> + </span><span class=cFE>16</span><span class=cF0> * i, </span><span class=cFE>80</span><span class=cF0>, </span><span class=cFE>18</span><span class=cF0>);
<a name="l192"></a>
<a name="l193"></a>
<a name="l194"></a> </span><span class=cF1>if</span><span class=cF0> (i == selected_color)
<a name="l195"></a> dc-&gt;color = </span><span class=cFE>15</span><span class=cF0>;
<a name="l196"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l197"></a> dc-&gt;color = i;
<a name="l198"></a> bias = (size / </span><span class=cFE>2</span><span class=cF0>) - </span><span class=cFE>4</span><span class=cF0>;
<a name="l199"></a> </span><span class=cF1>if</span><span class=cF0> (i &gt;= </span><span class=cFE>9</span><span class=cF0>)
<a name="l200"></a> bias = (size / </span><span class=cFE>2</span><span class=cF0>) - </span><span class=cFE>8</span><span class=cF0>;
<a name="l201"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc, bias + </span><span class=cF7>(</span><span class=cF0>i * size</span><span class=cF7>)</span><span class=cF0>, c-&gt;win_task-&gt;pix_height - </span><span class=cF7>(</span><span class=cF0>size * .</span><span class=cFE>6</span><span class=cF7>)</span><span class=cF0> + </span><span class=cF7>(</span><span class=cF0>size / </span><span class=cFE>4</span><span class=cF7>)</span><span class=cF0>, </span><span class=cF6>&quot;%d&quot;</span><span class=cF0>, i + </span><span class=cFE>1</span><span class=cF0>);
<a name="l202"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc, </span><span class=cFE>10</span><span class=cF0>, </span><span class=cF7>(</span><span class=cF0>size2 * </span><span class=cFE>2</span><span class=cF7>)</span><span class=cF0> + </span><span class=cFE>70</span><span class=cF0> + </span><span class=cFE>16</span><span class=cF0> * i, </span><span class=cF6>&quot;#%d: Test&quot;</span><span class=cF0>, i + </span><span class=cFE>1</span><span class=cF0>);
<a name="l203"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l204"></a>
<a name="l205"></a>
<a name="l206"></a> </span><span class=cF2>// Add Save/Load button?</span><span class=cF0>
<a name="l207"></a>
<a name="l208"></a>}
<a name="l209"></a>
<a name="l210"></a>
<a name="l211"></a>
<a name="l212"></a></span><span class=cF1>U0</span><span class=cF0> PESave(</span><span class=cF1>Bool</span><span class=cF0> prompt, </span><span class=cF9>CCtrl</span><span class=cF0> *c)
<a name="l213"></a>{
<a name="l214"></a> </span><span class=cF9>CDoc</span><span class=cF0> *doc = </span><span class=cF5>DocNew</span><span class=cF0>(PALETTES_PATH);
<a name="l215"></a> </span><span class=cF9>I64</span><span class=cF0> i;
<a name="l216"></a> </span><span class=cF1>no_warn</span><span class=cF0> c; </span><span class=cF2>// TODO remove param if not needed</span><span class=cF0>
<a name="l217"></a> </span><span class=cF1>U8</span><span class=cF0> *tmp1, *tmp2; </span><span class=cF2>// 1: lower, 2: Capital</span><span class=cF0>
<a name="l218"></a>
<a name="l219"></a> </span><span class=cF1>if</span><span class=cF0> (prompt)
<a name="l220"></a> </span><span class=cF5>DocForm</span><span class=cF0>(&amp;doc-&gt;filename);
<a name="l221"></a>
<a name="l222"></a> tmp1 = </span><span class=cF5>StrNew</span><span class=cF0>(&amp;doc-&gt;filename.name);
<a name="l223"></a> </span><span class=cF5>StrLastRemove</span><span class=cF0>(tmp1, </span><span class=cF6>&quot;/&quot;</span><span class=cF0>, tmp1);
<a name="l224"></a> </span><span class=cF5>StrReplace</span><span class=cF0>(tmp1, </span><span class=cF6>&quot;.CC&quot;</span><span class=cF0>, </span><span class=cF6>&quot;&quot;</span><span class=cF0>);
<a name="l225"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i &lt; </span><span class=cF5>StrLen</span><span class=cF7>(</span><span class=cF0>tmp1</span><span class=cF7>)</span><span class=cF0>; i++)
<a name="l226"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF6>'A'</span><span class=cF0> &lt;= tmp1[i] &lt;= </span><span class=cF6>'Z'</span><span class=cF0>)
<a name="l227"></a> tmp1[i] = tmp1[i] + </span><span class=cFE>32</span><span class=cF0>;
<a name="l228"></a>
<a name="l229"></a> tmp2 = </span><span class=cF5>StrNew</span><span class=cF0>(tmp1);
<a name="l230"></a> tmp2[</span><span class=cFE>0</span><span class=cF0>] = </span><span class=cF5>ToUpper</span><span class=cF0>(tmp2[</span><span class=cFE>0</span><span class=cF0>]);
<a name="l231"></a>
<a name="l232"></a> </span><span class=cF5>DocPrint</span><span class=cF0>(doc, </span><span class=cF6>&quot;public CBGR24 gr_palette_%s[COLORS_NUM] = {\n&quot;</span><span class=cF0>, tmp1);
<a name="l233"></a>
<a name="l234"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i &lt; </span><span class=cF3>COLORS_NUM</span><span class=cF0>; i++)
<a name="l235"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l236"></a> </span><span class=cF1>if</span><span class=cF0> (i == </span><span class=cF3>COLORS_NUM</span><span class=cF0> - </span><span class=cFE>1</span><span class=cF0>)
<a name="l237"></a> </span><span class=cF5>DocPrint</span><span class=cF0>(doc, </span><span class=cF6>&quot;0x%X&quot;</span><span class=cF0>, </span><span class=cFB>gr_palette</span><span class=cF0>[i]);
<a name="l238"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l239"></a> </span><span class=cF5>DocPrint</span><span class=cF0>(doc, </span><span class=cF6>&quot;0x%X, &quot;</span><span class=cF0>, </span><span class=cFB>gr_palette</span><span class=cF0>[i]);
<a name="l240"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l241"></a>
<a name="l242"></a> </span><span class=cF5>DocPrint</span><span class=cF0>(doc, </span><span class=cF6>&quot;\n};\npublic U0 PaletteSet%s(Bool persistent=TRUE)\n{\n&quot;</span><span class=cF0>
<a name="l243"></a> </span><span class=cF6>&quot;\tGrPaletteSet(gr_palette_%s);\n&quot;</span><span class=cF0>
<a name="l244"></a> </span><span class=cF6>&quot;\tLFBFlush;\n&quot;</span><span class=cF0>
<a name="l245"></a> </span><span class=cF6>&quot;\tif (persistent)\n&quot;</span><span class=cF0>
<a name="l246"></a> </span><span class=cF6>&quot;\t\tfp_set_std_palette = &amp;PaletteSet%s;\n}&quot;</span><span class=cF0>, tmp2, tmp1, tmp2);
<a name="l247"></a>
<a name="l248"></a> </span><span class=cF5>DocWrite</span><span class=cF0>(doc);
<a name="l249"></a> </span><span class=cF5>DocDel</span><span class=cF0>(doc);
<a name="l250"></a>}
<a name="l251"></a>
<a name="l252"></a>
<a name="l253"></a></span><span class=cF1>U0</span><span class=cF0> PaletteSetTemp(</span><span class=cF1>Bool</span><span class=cF0> persistent=</span><span class=cF3>TRUE</span><span class=cF0>)
<a name="l254"></a>{</span><span class=cF2>//Activate temp palette.</span><span class=cF0>
<a name="l255"></a> </span><span class=cF5>GrPaletteSet</span><span class=cF0>(</span><span class=cFB>gr_palette</span><span class=cF0>);
<a name="l256"></a> </span><span class=cF5>LFBFlush</span><span class=cF0>;
<a name="l257"></a> </span><span class=cF1>if</span><span class=cF0> (persistent)
<a name="l258"></a> </span><span class=cFB>fp_set_std_palette</span><span class=cF0> = &amp;PaletteSetTemp;
<a name="l259"></a>}
<a name="l260"></a>
<a name="l261"></a></span><span class=cF1>U0</span><span class=cF0> PalettePrint(){
<a name="l262"></a> </span><span class=cF9>I64</span><span class=cF0> i;
<a name="l263"></a>
<a name="l264"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i &lt; </span><span class=cF3>COLORS_NUM</span><span class=cF0>; i++)
<a name="l265"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l266"></a> </span><span class=cF6>&quot;%d: #%X\n&quot;</span><span class=cF0>, i, </span><span class=cFB>gr_palette</span><span class=cF0>[i];
<a name="l267"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l268"></a>}
<a name="l269"></a>
<a name="l270"></a></span><span class=cF1>U0</span><span class=cF0> SelectColor(</span><span class=cF9>I64</span><span class=cF0> color_number, </span><span class=cF9>CCtrl</span><span class=cF0> *c)
<a name="l271"></a>{
<a name="l272"></a> selected_color = color_number;
<a name="l273"></a> CSliderState *s = c-&gt;state;
<a name="l274"></a>
<a name="l275"></a> s-&gt;left_pos = </span><span class=cFB>gr_palette</span><span class=cF0>[selected_color].r;
<a name="l276"></a> s-&gt;middle_pos= </span><span class=cFB>gr_palette</span><span class=cF0>[selected_color].g;
<a name="l277"></a> s-&gt;right_pos = </span><span class=cFB>gr_palette</span><span class=cF0>[selected_color].b;
<a name="l278"></a>}
<a name="l279"></a>
<a name="l280"></a></span><span class=cF1>U0</span><span class=cF0> UpdateDerivedCtrlSlider(</span><span class=cF9>CCtrl</span><span class=cF0> *c)
<a name="l281"></a>{
<a name="l282"></a> CSliderState *s = c-&gt;state;
<a name="l283"></a>
<a name="l284"></a>
<a name="l285"></a> c-&gt;left = (c-&gt;win_task-&gt;pix_width / </span><span class=cFE>2</span><span class=cF0>) - (SLIDER_SPACING * </span><span class=cFE>3</span><span class=cF0> + </span><span class=cFE>2</span><span class=cF0>) / </span><span class=cFE>2</span><span class=cF0>;
<a name="l286"></a> c-&gt;right = c-&gt;left + </span><span class=cFE>3</span><span class=cF0> * SLIDER_SPACING + </span><span class=cFE>2</span><span class=cF0>;
<a name="l287"></a> c-&gt;top = c-&gt;win_task-&gt;pix_height / </span><span class=cFE>2</span><span class=cF0> - (SLIDER_SPACING * </span><span class=cFE>2</span><span class=cF0> + SLIDER_RANGE) / </span><span class=cFE>2</span><span class=cF0>;
<a name="l288"></a> c-&gt;bottom = c-&gt;top + SLIDER_SPACING * </span><span class=cFE>2</span><span class=cF0> + SLIDER_RANGE;
<a name="l289"></a>
<a name="l290"></a> </span><span class=cF2>// I used to clamp between 0 and 127 and do math but i changed it to 256 for now.</span><span class=cF0>
<a name="l291"></a> s-&gt;left_pos = </span><span class=cF5>ClampI64</span><span class=cF0>(s-&gt;left_pos, </span><span class=cFE>0</span><span class=cF0>, SLIDER_RANGE);
<a name="l292"></a> s-&gt;middle_pos = </span><span class=cF5>ClampI64</span><span class=cF0>(s-&gt;middle_pos, </span><span class=cFE>0</span><span class=cF0>, SLIDER_RANGE);
<a name="l293"></a> s-&gt;right_pos = </span><span class=cF5>ClampI64</span><span class=cF0>(s-&gt;right_pos, </span><span class=cFE>0</span><span class=cF0>, SLIDER_RANGE);
<a name="l294"></a>
<a name="l295"></a> </span><span class=cF2>// add the slider's RGB value to s-&gt;preview </span><span class=cF0> </span><span class=cF2>// opposite for BGR</span><span class=cF0>
<a name="l296"></a> s-&gt;preview = s-&gt;right_pos + s-&gt;middle_pos &lt;&lt; </span><span class=cFE>8</span><span class=cF0> + s-&gt;left_pos &lt;&lt; </span><span class=cFE>16</span><span class=cF0>; </span><span class=cF2>//s-&gt;left_pos + s-&gt;middle_pos &lt;&lt; 8 + s-&gt;right_pos &lt;&lt; 16;</span><span class=cF0>
<a name="l297"></a>
<a name="l298"></a> </span><span class=cF2>// cheap way to force redraw 32bit colors</span><span class=cF0>
<a name="l299"></a> </span><span class=cF2>// TODO: make this not stupid</span><span class=cF0>
<a name="l300"></a> </span><span class=cF2>// can I use *last_task?</span><span class=cF0>
<a name="l301"></a> </span><span class=cF1>if</span><span class=cF0> (c-&gt;win_task-&gt;pix_left != l ||
<a name="l302"></a> c-&gt;win_task-&gt;pix_right != r ||
<a name="l303"></a> c-&gt;win_task-&gt;pix_bottom != b ||
<a name="l304"></a> c-&gt;win_task-&gt;pix_top != t)
<a name="l305"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l306"></a> l = c-&gt;win_task-&gt;pix_left;
<a name="l307"></a> r = c-&gt;win_task-&gt;pix_right;
<a name="l308"></a> t = c-&gt;win_task-&gt;pix_top;
<a name="l309"></a> b = c-&gt;win_task-&gt;pix_bottom;
<a name="l310"></a> </span><span class=cF5>LFBFlush</span><span class=cF0>;
<a name="l311"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l312"></a>}
<a name="l313"></a>
<a name="l314"></a>
<a name="l315"></a></span><span class=cF1>U0</span><span class=cF0> LeftClickSlider(</span><span class=cF9>CCtrl</span><span class=cF0> *c, </span><span class=cF9>I64</span><span class=cF0> x, </span><span class=cF9>I64</span><span class=cF0> y, </span><span class=cF1>Bool</span><span class=cF0>)
<a name="l316"></a>{
<a name="l317"></a> CSliderState *s = c-&gt;state;
<a name="l318"></a>
<a name="l319"></a> </span><span class=cF1>if</span><span class=cF0> (x &lt; c-&gt;left + </span><span class=cFE>1</span><span class=cF0> * SLIDER_SPACING + </span><span class=cFE>0</span><span class=cF0> + SLIDER_SPACING / </span><span class=cFE>3</span><span class=cF0>)
<a name="l320"></a> s-&gt;left_pos = SLIDER_RANGE - </span><span class=cFE>1</span><span class=cF0> - (y - </span><span class=cF7>(</span><span class=cF0>c-&gt;top + SLIDER_SPACING</span><span class=cF7>)</span><span class=cF0>);
<a name="l321"></a>
<a name="l322"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (x &lt; c-&gt;left + </span><span class=cFE>2</span><span class=cF0> * SLIDER_SPACING + </span><span class=cFE>1</span><span class=cF0> + SLIDER_SPACING / </span><span class=cFE>3</span><span class=cF0>)
<a name="l323"></a> s-&gt;middle_pos = SLIDER_RANGE - </span><span class=cFE>1</span><span class=cF0> - (y - </span><span class=cF7>(</span><span class=cF0>c-&gt;top + SLIDER_SPACING</span><span class=cF7>)</span><span class=cF0>);
<a name="l324"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l325"></a> s-&gt;right_pos = SLIDER_RANGE - </span><span class=cFE>1</span><span class=cF0> - (y - </span><span class=cF7>(</span><span class=cF0>c-&gt;top + SLIDER_SPACING</span><span class=cF7>)</span><span class=cF0>);
<a name="l326"></a>
<a name="l327"></a> </span><span class=cF1>if</span><span class=cF0> (c-&gt;update_derived_vals)
<a name="l328"></a> (*c-&gt;update_derived_vals)(c);
<a name="l329"></a>
<a name="l330"></a> </span><span class=cF2>// set palette</span><span class=cF0>
<a name="l331"></a> </span><span class=cFB>gr_palette</span><span class=cF0>[selected_color] = s-&gt;preview;
<a name="l332"></a> PaletteSetTemp(</span><span class=cF3>FALSE</span><span class=cF0>);
<a name="l333"></a>
<a name="l334"></a> current_palette = </span><span class=cF6>&quot;*New Palette&quot;</span><span class=cF0>;
<a name="l335"></a>}
<a name="l336"></a>
<a name="l337"></a></span><span class=cF9>CCtrl</span><span class=cF0> *SliderNew()
<a name="l338"></a>{
<a name="l339"></a> </span><span class=cF9>CCtrl</span><span class=cF0> *c = </span><span class=cF5>CAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CCtrl</span><span class=cF7>)</span><span class=cF0>);
<a name="l340"></a> c-&gt;win_task = </span><span class=cF5>Fs</span><span class=cF0>;
<a name="l341"></a> c-&gt;flags = </span><span class=cF3>CTRLF_SHOW</span><span class=cF0> | </span><span class=cF3>CTRLF_CAPTURE_LEFT_MS</span><span class=cF0>;
<a name="l342"></a> c-&gt;type = </span><span class=cF3>CTRLT_GENERIC</span><span class=cF0>;
<a name="l343"></a> c-&gt;state = &amp;sld;
<a name="l344"></a> </span><span class=cF5>MemSet</span><span class=cF0>(&amp;sld,</span><span class=cFE>0</span><span class=cF0>,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>CSliderState</span><span class=cF7>)</span><span class=cF0>);
<a name="l345"></a> c-&gt;draw_it = &amp;DrawCtrlSlider;
<a name="l346"></a> c-&gt;left_click = &amp;LeftClickSlider;
<a name="l347"></a> c-&gt;update_derived_vals = &amp;UpdateDerivedCtrlSlider;
<a name="l348"></a> </span><span class=cF5>QueueInsert</span><span class=cF0>(c, </span><span class=cF5>Fs</span><span class=cF0>-&gt;last_ctrl);
<a name="l349"></a> </span><span class=cF5>TaskDerivedValsUpdate</span><span class=cF0>;
<a name="l350"></a> </span><span class=cF1>return</span><span class=cF0> c;
<a name="l351"></a>}
<a name="l352"></a>
<a name="l353"></a></span><span class=cF1>U0</span><span class=cF0> SliderDel(</span><span class=cF9>CCtrl</span><span class=cF0> *c)
<a name="l354"></a>{
<a name="l355"></a> </span><span class=cF5>QueueRemove</span><span class=cF0>(c);
<a name="l356"></a> </span><span class=cF5>Free</span><span class=cF0>(c);
<a name="l357"></a>}
<a name="l358"></a>
<a name="l359"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>U0</span><span class=cF0> PaletteEditor()
<a name="l360"></a>{
<a name="l361"></a>
<a name="l362"></a> </span><span class=cF5>SettingsPush</span><span class=cF0>;
<a name="l363"></a> </span><span class=cF5>MenuPush</span><span class=cF0>(
<a name="l364"></a> </span><span class=cF6>&quot;File {&quot;</span><span class=cF0>
<a name="l365"></a> </span><span class=cF6>&quot;</span><span class=cF0> </span><span class=cF6>Open(,CH_CTRLO);&quot;</span><span class=cF0>
<a name="l366"></a> </span><span class=cF6>&quot;</span><span class=cF0> </span><span class=cF6>SaveAs(,CH_CTRLA);&quot;</span><span class=cF0>
<a name="l367"></a> </span><span class=cF6>&quot;</span><span class=cF0> </span><span class=cF6>Abort(,CH_SHIFT_ESC);&quot;</span><span class=cF0>
<a name="l368"></a> </span><span class=cF6>&quot;</span><span class=cF0> </span><span class=cF6>Exit(,CH_ESC);&quot;</span><span class=cF0>
<a name="l369"></a> </span><span class=cF6>&quot;}&quot;</span><span class=cF0>
<a name="l370"></a> </span><span class=cF6>&quot;Edit {&quot;</span><span class=cF0>
<a name="l371"></a> </span><span class=cF6>&quot;</span><span class=cF0> </span><span class=cF6>Hex(,'#');&quot;</span><span class=cF0>
<a name="l372"></a> </span><span class=cF6>&quot;</span><span class=cF0> </span><span class=cF6>PreviousColor(,,SC_CURSOR_LEFT);&quot;</span><span class=cF0>
<a name="l373"></a> </span><span class=cF6>&quot;</span><span class=cF0> </span><span class=cF6>PreviousColor(,,SC_CURSOR_UP);&quot;</span><span class=cF0>
<a name="l374"></a> </span><span class=cF6>&quot;</span><span class=cF0> </span><span class=cF6>NextColor(,,SC_CURSOR_RIGHT);&quot;</span><span class=cF0>
<a name="l375"></a> </span><span class=cF6>&quot;</span><span class=cF0> </span><span class=cF6>NextColor(,,SC_CURSOR_DOWN);&quot;</span><span class=cF0>
<a name="l376"></a> </span><span class=cF6>&quot;}&quot;</span><span class=cF0>
<a name="l377"></a> </span><span class=cF6>&quot;About {&quot;</span><span class=cF0>
<a name="l378"></a> </span><span class=cF6>&quot;</span><span class=cF0> </span><span class=cF6>Info(,CH_CTRLI);&quot;</span><span class=cF0>
<a name="l379"></a> </span><span class=cF6>&quot;}&quot;</span><span class=cF0>
<a name="l380"></a> );
<a name="l381"></a> </span><span class=cF5>DocClear</span><span class=cF0>;
<a name="l382"></a> </span><span class=cF5>WinBorder</span><span class=cF0>(</span><span class=cF3>ON</span><span class=cF0>);
<a name="l383"></a>
<a name="l384"></a> </span><span class=cF9>CCtrl</span><span class=cF0> *c = SliderNew;
<a name="l385"></a> </span><span class=cF9>I64</span><span class=cF0> </span><span class=cF2>/*arg1, arg2,*/</span><span class=cF0> sc = </span><span class=cFE>0</span><span class=cF0>,
<a name="l386"></a> original_left, original_right, original_top, original_bottom;
<a name="l387"></a> </span><span class=cF1>Bool</span><span class=cF0> is_done = </span><span class=cF3>FALSE</span><span class=cF0>, keep_palette = </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l388"></a>
<a name="l389"></a> original_left = c-&gt;win_task-&gt;win_left;
<a name="l390"></a> original_right = c-&gt;win_task-&gt;win_right;
<a name="l391"></a> original_top = c-&gt;win_task-&gt;win_top;
<a name="l392"></a> original_bottom = c-&gt;win_task-&gt;win_bottom;
<a name="l393"></a>
<a name="l394"></a> </span><span class=cF2>// windowed</span><span class=cF0>
<a name="l395"></a> c-&gt;win_task-&gt;win_left = (</span><span class=cF3>GR_WIDTH</span><span class=cF0> / </span><span class=cFE>23</span><span class=cF0>);
<a name="l396"></a> c-&gt;win_task-&gt;win_right = (</span><span class=cF3>GR_WIDTH</span><span class=cF0> / </span><span class=cFE>13</span><span class=cF0>);
<a name="l397"></a> c-&gt;win_task-&gt;win_top = </span><span class=cF3>GR_HEIGHT</span><span class=cF0> / </span><span class=cFE>80</span><span class=cF0>;
<a name="l398"></a> c-&gt;win_task-&gt;win_bottom = </span><span class=cF3>GR_HEIGHT</span><span class=cF0> / </span><span class=cFE>10</span><span class=cF0>;
<a name="l399"></a>
<a name="l400"></a>
<a name="l401"></a> </span><span class=cF2>// init pos for 32bit redraw</span><span class=cF0>
<a name="l402"></a> l = c-&gt;win_task-&gt;pix_left;
<a name="l403"></a> r = c-&gt;win_task-&gt;pix_right;
<a name="l404"></a> t = c-&gt;win_task-&gt;pix_top;
<a name="l405"></a> b = c-&gt;win_task-&gt;pix_bottom;
<a name="l406"></a>
<a name="l407"></a>
<a name="l408"></a> SelectColor(</span><span class=cFE>0</span><span class=cF0>, c);
<a name="l409"></a>
<a name="l410"></a> </span><span class=cF1>try</span><span class=cF0>
<a name="l411"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l412"></a> </span><span class=cF1>while</span><span class=cF0> (!is_done)
<a name="l413"></a> {
<a name="l414"></a> </span><span class=cF1>switch</span><span class=cF0> (</span><span class=cF5>KeyGet</span><span class=cF7>(</span><span class=cF0>&amp;sc</span><span class=cF7>)</span><span class=cF0>)
<a name="l415"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l416"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'#'</span><span class=cF0>:
<a name="l417"></a> manual_value = </span><span class=cF5>StrGet</span><span class=cF0>(</span><span class=cF6>&quot; Hex Value: #&quot;</span><span class=cF0>);
<a name="l418"></a> </span><span class=cFB>gr_palette</span><span class=cF0>[selected_color] = </span><span class=cF5>Str2I64</span><span class=cF0>(manual_value, </span><span class=cFE>16</span><span class=cF0>);
<a name="l419"></a> </span><span class=cF5>Free</span><span class=cF0>(manual_value);
<a name="l420"></a> SelectColor(selected_color, c);
<a name="l421"></a> </span><span class=cF5>LFBFlush</span><span class=cF0>;
<a name="l422"></a> </span><span class=cF5>DocClear</span><span class=cF0>;
<a name="l423"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l424"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cFE>0</span><span class=cF0>:
<a name="l425"></a> </span><span class=cF1>switch</span><span class=cF0> (sc.u8[</span><span class=cFE>0</span><span class=cF0>])
<a name="l426"></a> {
<a name="l427"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_CURSOR_UP</span><span class=cF0>:
<a name="l428"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_CURSOR_LEFT</span><span class=cF0>:
<a name="l429"></a> </span><span class=cF1>if</span><span class=cF0> (selected_color == </span><span class=cFE>0</span><span class=cF0>)
<a name="l430"></a> selected_color = </span><span class=cFE>16</span><span class=cF0>;
<a name="l431"></a> SelectColor(selected_color - </span><span class=cFE>1</span><span class=cF0>, c);
<a name="l432"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l433"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_CURSOR_DOWN</span><span class=cF0>:
<a name="l434"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_CURSOR_RIGHT</span><span class=cF0>:
<a name="l435"></a> </span><span class=cF1>if</span><span class=cF0> (selected_color == </span><span class=cFE>15</span><span class=cF0>)
<a name="l436"></a> selected_color = -</span><span class=cFE>1</span><span class=cF0>;
<a name="l437"></a> SelectColor(selected_color + </span><span class=cFE>1</span><span class=cF0>, c);
<a name="l438"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l439"></a> }
<a name="l440"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l441"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_CTRLO</span><span class=cF0>:
<a name="l442"></a> current_palette = </span><span class=cF6>&quot;&quot;</span><span class=cF0>;
<a name="l443"></a> current_palette = PaletteSelect;
<a name="l444"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l445"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_CTRLI</span><span class=cF0>:
<a name="l446"></a> </span><span class=cF5>PopUpOk</span><span class=cF0>(</span><span class=cF6>&quot;\n\n Use the arrows to select color\n\n # to manually input hex value&quot;</span><span class=cF0>,</span><span class=cF6>&quot;\n\n\n\t\tMade by y4my4m\n\n&quot;</span><span class=cF0>);
<a name="l447"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l448"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_CTRLA</span><span class=cF0>:
<a name="l449"></a> PESave(</span><span class=cF3>TRUE</span><span class=cF0>, c);
<a name="l450"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l451"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_ESC</span><span class=cF0>:
<a name="l452"></a> </span><span class=cF5>MemCopy</span><span class=cF0>(&amp;gr_temp_palette, </span><span class=cFB>gr_palette</span><span class=cF0>, </span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CBGR24</span><span class=cF7>)</span><span class=cF0> * </span><span class=cF3>COLORS_NUM</span><span class=cF0>);
<a name="l453"></a> keep_palette = </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l454"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_SHIFT_ESC</span><span class=cF0>:
<a name="l455"></a> </span><span class=cF5>LFBFlush</span><span class=cF0>;
<a name="l456"></a> </span><span class=cF5>DocClear</span><span class=cF0>;
<a name="l457"></a> is_done = </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l458"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l459"></a> </span><span class=cF5>Refresh</span><span class=cF0>;
<a name="l460"></a> }
<a name="l461"></a>
<a name="l462"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l463"></a> </span><span class=cF1>catch</span><span class=cF0>
<a name="l464"></a> </span><span class=cF5>PutExcept</span><span class=cF0>;
<a name="l465"></a>
<a name="l466"></a> </span><span class=cF5>MenuPop</span><span class=cF0>;
<a name="l467"></a> </span><span class=cF5>SettingsPop</span><span class=cF0>;
<a name="l468"></a>
<a name="l469"></a> </span><span class=cF1>if</span><span class=cF0> (keep_palette)
<a name="l470"></a> </span><span class=cF5>GrPaletteSet</span><span class=cF0>(gr_temp_palette);
<a name="l471"></a>
<a name="l472"></a> SliderDel(c);
<a name="l473"></a> </span><span class=cF5>DocBottom</span><span class=cF0>;
<a name="l474"></a>
<a name="l475"></a>
<a name="l476"></a> c-&gt;win_task-&gt;win_left = original_left;
<a name="l477"></a> c-&gt;win_task-&gt;win_right = original_right;
<a name="l478"></a> c-&gt;win_task-&gt;win_top = original_top;
<a name="l479"></a> c-&gt;win_task-&gt;win_bottom = original_bottom;
<a name="l480"></a>}
</span></pre></body>
</html>