186 lines
17 KiB
HTML
Executable File
186 lines
17 KiB
HTML
Executable File
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="generator" content="TempleOS V5.03">
|
|
<meta name="viewport" content="width=device-width">
|
|
<link rel="stylesheet" href="/style/templeos.css">
|
|
<script src="/script/templeos.js"></script>
|
|
<style type="text/css">
|
|
.cF0{color:#000000;background-color:#ffffff;}
|
|
.cF1{color:#0000aa;background-color:#ffffff;}
|
|
.cF2{color:#00aa00;background-color:#ffffff;}
|
|
.cF3{color:#00aaaa;background-color:#ffffff;}
|
|
.cF4{color:#aa0000;background-color:#ffffff;}
|
|
.cF5{color:#aa00aa;background-color:#ffffff;}
|
|
.cF6{color:#aa5500;background-color:#ffffff;}
|
|
.cF7{color:#aaaaaa;background-color:#ffffff;}
|
|
.cF8{color:#555555;background-color:#ffffff;}
|
|
.cF9{color:#5555ff;background-color:#ffffff;}
|
|
.cFA{color:#55ff55;background-color:#ffffff;}
|
|
.cFB{color:#55ffff;background-color:#ffffff;}
|
|
.cFC{color:#ff5555;background-color:#ffffff;}
|
|
.cFD{color:#ff55ff;background-color:#ffffff;}
|
|
.cFE{color:#ffff55;background-color:#ffffff;}
|
|
.cFF{color:#ffffff;background-color:#ffffff;}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<pre id="content">
|
|
<a name="l1"></a><span class=cF0>#</span><span class=cF1>define</span><span class=cF0> LASER_TEMP_MAX 30.0
|
|
<a name="l2"></a>#</span><span class=cF1>define</span><span class=cF0> LASER_THRESHOLD_TEMP 10.0
|
|
<a name="l3"></a>#</span><span class=cF1>define</span><span class=cF0> MASS_TEMP_MAX 5.0
|
|
<a name="l4"></a>
|
|
<a name="l5"></a></span><span class=cF1>class</span><span class=cF0> CtrlPanelState
|
|
<a name="l6"></a>{
|
|
<a name="l7"></a> </span><span class=cF9>I64</span><span class=cF0> shot_radius,fuse_time;
|
|
<a name="l8"></a> </span><span class=cF1>F64</span><span class=cF0> laser_temperature;
|
|
<a name="l9"></a> </span><span class=cF1>Bool</span><span class=cF0> spacewalk;
|
|
<a name="l10"></a>} ctrl_panel;
|
|
<a name="l11"></a>
|
|
<a name="l12"></a>#</span><span class=cF1>define</span><span class=cF0> CTRL_PANEL_SPACING 33
|
|
<a name="l13"></a>#</span><span class=cF1>define</span><span class=cF0> CTRL_PANEL_RANGE 30
|
|
<a name="l14"></a>#</span><span class=cF1>define</span><span class=cF0> CTRL_PANEL_BORDER 2
|
|
<a name="l15"></a>#</span><span class=cF1>define</span><span class=cF0> CTRL_PANEL_BTTN_SIZE 12
|
|
<a name="l16"></a>
|
|
<a name="l17"></a>#</span><span class=cF1>define</span><span class=cF0> TMP_Y (+2)
|
|
<a name="l18"></a>
|
|
<a name="l19"></a></span><span class=cF1>U0</span><span class=cF0> DrawCtrlPanelCtrl(</span><span class=cF9>CDC</span><span class=cF0> *dc,</span><span class=cF9>CCtrl</span><span class=cF0> *c)
|
|
<a name="l20"></a>{
|
|
<a name="l21"></a> CtrlPanelState *s=c->state;
|
|
<a name="l22"></a> </span><span class=cF1>F64</span><span class=cF0> d,d_range;
|
|
<a name="l23"></a>
|
|
<a name="l24"></a> dc->color=</span><span class=cF3>LTRED</span><span class=cF0>;
|
|
<a name="l25"></a> </span><span class=cF5>GrRect</span><span class=cF0>(dc, c->left,c->top,CTRL_PANEL_SPACING*3+2,
|
|
<a name="l26"></a> CTRL_PANEL_SPACING*2+CTRL_PANEL_RANGE+CTRL_PANEL_BTTN_SIZE);
|
|
<a name="l27"></a> dc->color=</span><span class=cF3>DKGRAY</span><span class=cF0>;
|
|
<a name="l28"></a> </span><span class=cF5>GrRect</span><span class=cF0>(dc, c->left+CTRL_PANEL_BORDER,c->top+CTRL_PANEL_BORDER,
|
|
<a name="l29"></a> CTRL_PANEL_SPACING*3+2-2*CTRL_PANEL_BORDER,
|
|
<a name="l30"></a> CTRL_PANEL_SPACING*2+CTRL_PANEL_RANGE+CTRL_PANEL_BTTN_SIZE
|
|
<a name="l31"></a> -2*CTRL_PANEL_BORDER);
|
|
<a name="l32"></a> dc->color=</span><span class=cF3>BLACK</span><span class=cF0>;
|
|
<a name="l33"></a> </span><span class=cF5>GrLine</span><span class=cF0>(dc,c->left+CTRL_PANEL_SPACING,</span><span class=cF7>(</span><span class=cF0>c->top+CTRL_PANEL_BTTN_SIZE</span><span class=cF7>)</span><span class=cF0>+
|
|
<a name="l34"></a> CTRL_PANEL_SPACING,c->left+CTRL_PANEL_SPACING,
|
|
<a name="l35"></a> </span><span class=cF7>(</span><span class=cF0>c->top+CTRL_PANEL_BTTN_SIZE</span><span class=cF7>)</span><span class=cF0>+CTRL_PANEL_SPACING+CTRL_PANEL_RANGE-1);
|
|
<a name="l36"></a> </span><span class=cF5>GrLine</span><span class=cF0>(dc,c->left+2*CTRL_PANEL_SPACING+1,</span><span class=cF7>(</span><span class=cF0>c->top+CTRL_PANEL_BTTN_SIZE</span><span class=cF7>)</span><span class=cF0>+
|
|
<a name="l37"></a> CTRL_PANEL_SPACING,c->left+2*CTRL_PANEL_SPACING+1,
|
|
<a name="l38"></a> </span><span class=cF7>(</span><span class=cF0>c->top+CTRL_PANEL_BTTN_SIZE</span><span class=cF7>)</span><span class=cF0>+CTRL_PANEL_SPACING+CTRL_PANEL_RANGE-1);
|
|
<a name="l39"></a>
|
|
<a name="l40"></a> dc->color=</span><span class=cF3>BLACK</span><span class=cF0>;
|
|
<a name="l41"></a> </span><span class=cF5>GrRect</span><span class=cF0>(dc,</span><span class=cF7>(</span><span class=cF0>c->left+c->right+1</span><span class=cF7>)</span><span class=cF0>/2-9*</span><span class=cF3>FONT_WIDTH</span><span class=cF0>/2-3,
|
|
<a name="l42"></a> c->top+CTRL_PANEL_BORDER+</span><span class=cF7>(</span><span class=cF0>CTRL_PANEL_SPACING-</span><span class=cF3>FONT_HEIGHT</span><span class=cF7>)</span><span class=cF0>/2,
|
|
<a name="l43"></a> 9*</span><span class=cF3>FONT_WIDTH</span><span class=cF0>+6,</span><span class=cF3>FONT_HEIGHT</span><span class=cF0>+6);
|
|
<a name="l44"></a>
|
|
<a name="l45"></a> </span><span class=cF1>if</span><span class=cF0> (s->spacewalk)
|
|
<a name="l46"></a> dc->color=</span><span class=cF3>YELLOW</span><span class=cF0>;
|
|
<a name="l47"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l48"></a> dc->color=</span><span class=cF3>DKGRAY</span><span class=cF0>;
|
|
<a name="l49"></a> </span><span class=cF5>GrRect</span><span class=cF0>(dc,</span><span class=cF7>(</span><span class=cF0>c->left+c->right+1</span><span class=cF7>)</span><span class=cF0>/2-9*</span><span class=cF3>FONT_WIDTH</span><span class=cF0>/2-2,
|
|
<a name="l50"></a> c->top+CTRL_PANEL_BORDER+1+</span><span class=cF7>(</span><span class=cF0>CTRL_PANEL_SPACING-</span><span class=cF3>FONT_HEIGHT</span><span class=cF7>)</span><span class=cF0>/2,
|
|
<a name="l51"></a> 9*</span><span class=cF3>FONT_WIDTH</span><span class=cF0>+4,</span><span class=cF3>FONT_HEIGHT</span><span class=cF0>+4);
|
|
<a name="l52"></a>
|
|
<a name="l53"></a> dc->color=</span><span class=cF3>RED</span><span class=cF0>;
|
|
<a name="l54"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc,</span><span class=cF7>(</span><span class=cF0>c->left+c->right+1</span><span class=cF7>)</span><span class=cF0>/2-9*</span><span class=cF3>FONT_WIDTH</span><span class=cF0>/2,
|
|
<a name="l55"></a> c->top+CTRL_PANEL_BORDER+3+
|
|
<a name="l56"></a> </span><span class=cF7>(</span><span class=cF0>CTRL_PANEL_SPACING-</span><span class=cF3>FONT_HEIGHT</span><span class=cF7>)</span><span class=cF0>/2,</span><span class=cF6>"SpaceWalk"</span><span class=cF0>);
|
|
<a name="l57"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc,c->left+CTRL_PANEL_SPACING-4*</span><span class=cF3>FONT_WIDTH</span><span class=cF0>/2,
|
|
<a name="l58"></a> </span><span class=cF7>(</span><span class=cF0>c->top+CTRL_PANEL_BTTN_SIZE</span><span class=cF7>)</span><span class=cF0>+
|
|
<a name="l59"></a> CTRL_PANEL_SPACING-</span><span class=cF3>FONT_HEIGHT</span><span class=cF0>-2,</span><span class=cF6>"Size"</span><span class=cF0>);
|
|
<a name="l60"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc,c->left+2*CTRL_PANEL_SPACING+1-4*</span><span class=cF3>FONT_WIDTH</span><span class=cF0>/2,
|
|
<a name="l61"></a> </span><span class=cF7>(</span><span class=cF0>c->top+CTRL_PANEL_BTTN_SIZE</span><span class=cF7>)</span><span class=cF0>+
|
|
<a name="l62"></a> CTRL_PANEL_SPACING-</span><span class=cF3>FONT_HEIGHT</span><span class=cF0>-2,</span><span class=cF6>"Fuse"</span><span class=cF0>);
|
|
<a name="l63"></a> dc->color=</span><span class=cF3>LTRED</span><span class=cF0>;
|
|
<a name="l64"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc,c->left+CTRL_PANEL_SPACING-</span><span class=cF3>FONT_WIDTH</span><span class=cF0>/2,
|
|
<a name="l65"></a> </span><span class=cF7>(</span><span class=cF0>c->top+CTRL_PANEL_BTTN_SIZE</span><span class=cF7>)</span><span class=cF0>+CTRL_PANEL_SPACING+CTRL_PANEL_RANGE+3,
|
|
<a name="l66"></a> </span><span class=cF6>"%d"</span><span class=cF0>,s->shot_radius*10/CTRL_PANEL_RANGE);
|
|
<a name="l67"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc,c->left+2*CTRL_PANEL_SPACING+1-</span><span class=cF3>FONT_WIDTH</span><span class=cF0>/2,
|
|
<a name="l68"></a> </span><span class=cF7>(</span><span class=cF0>c->top+CTRL_PANEL_BTTN_SIZE</span><span class=cF7>)</span><span class=cF0>+CTRL_PANEL_SPACING+CTRL_PANEL_RANGE+3,
|
|
<a name="l69"></a> </span><span class=cF6>"%d"</span><span class=cF0>,s->fuse_time*10/CTRL_PANEL_RANGE);
|
|
<a name="l70"></a> </span><span class=cF5>GrRect</span><span class=cF0>(dc,c->left+CTRL_PANEL_SPACING-3,
|
|
<a name="l71"></a> </span><span class=cF7>(</span><span class=cF0>c->top+CTRL_PANEL_BTTN_SIZE</span><span class=cF7>)</span><span class=cF0>+CTRL_PANEL_SPACING+
|
|
<a name="l72"></a> CTRL_PANEL_RANGE-1-s->shot_radius-2 ,7,5);
|
|
<a name="l73"></a> </span><span class=cF5>GrRect</span><span class=cF0>(dc,c->left+2*CTRL_PANEL_SPACING+1-3,
|
|
<a name="l74"></a> </span><span class=cF7>(</span><span class=cF0>c->top+CTRL_PANEL_BTTN_SIZE</span><span class=cF7>)</span><span class=cF0>+CTRL_PANEL_SPACING+
|
|
<a name="l75"></a> CTRL_PANEL_RANGE-1-s->fuse_time-2,7,5);
|
|
<a name="l76"></a> dc->color=</span><span class=cF3>YELLOW</span><span class=cF0>;
|
|
<a name="l77"></a> </span><span class=cF5>GrRect</span><span class=cF0>(dc,c->left+CTRL_PANEL_SPACING-2,
|
|
<a name="l78"></a> </span><span class=cF7>(</span><span class=cF0>c->top+CTRL_PANEL_BTTN_SIZE</span><span class=cF7>)</span><span class=cF0>+CTRL_PANEL_SPACING+
|
|
<a name="l79"></a> CTRL_PANEL_RANGE-1-s->shot_radius-1 ,5,3);
|
|
<a name="l80"></a> </span><span class=cF5>GrRect</span><span class=cF0>(dc,c->left+2*CTRL_PANEL_SPACING+1-2,
|
|
<a name="l81"></a> </span><span class=cF7>(</span><span class=cF0>c->top+CTRL_PANEL_BTTN_SIZE</span><span class=cF7>)</span><span class=cF0>+CTRL_PANEL_SPACING+
|
|
<a name="l82"></a> CTRL_PANEL_RANGE-1-s->fuse_time-1,5,3);
|
|
<a name="l83"></a>
|
|
<a name="l84"></a> d_range=c->right-c->left-5-5;
|
|
<a name="l85"></a> d=s->laser_temperature*d_range/LASER_TEMP_MAX;
|
|
<a name="l86"></a> dc->color=</span><span class=cF3>BLACK</span><span class=cF0>;
|
|
<a name="l87"></a> </span><span class=cF5>GrRect</span><span class=cF0>(dc,c->left+5-1,c->bottom+TMP_Y-2,d_range+2,2+1+1);
|
|
<a name="l88"></a> </span><span class=cF1>if</span><span class=cF0> (d>1.0) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l89"></a> dc->color=</span><span class=cF3>GREEN</span><span class=cF0>;
|
|
<a name="l90"></a> </span><span class=cF5>GrRect</span><span class=cF0>(dc,c->left+5,c->bottom+TMP_Y-1,</span><span class=cF5>Min</span><span class=cF7>(</span><span class=cF0>d,d_range/3</span><span class=cF7>)</span><span class=cF0>,2);
|
|
<a name="l91"></a> </span><span class=cF1>if</span><span class=cF0> (d>=d_range/3) {
|
|
<a name="l92"></a> dc->color=</span><span class=cF3>YELLOW</span><span class=cF0>;
|
|
<a name="l93"></a> </span><span class=cF5>GrRect</span><span class=cF0>(dc,c->left+5+d_range/3,c->bottom+TMP_Y-1,
|
|
<a name="l94"></a> </span><span class=cF5>Min</span><span class=cF7>(</span><span class=cF0>d,2*d_range/3</span><span class=cF7>)</span><span class=cF0>-d_range/3,2);
|
|
<a name="l95"></a> </span><span class=cF1>if</span><span class=cF0> (d>=2*d_range/3) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l96"></a> dc->color=</span><span class=cF3>RED</span><span class=cF0>;
|
|
<a name="l97"></a> </span><span class=cF5>GrRect</span><span class=cF0>(dc,c->left+5+2*d_range/3,c->bottom+TMP_Y-1,d-2*d_range/3,2);
|
|
<a name="l98"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l99"></a> }
|
|
<a name="l100"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l101"></a>}
|
|
<a name="l102"></a>
|
|
<a name="l103"></a></span><span class=cF1>U0</span><span class=cF0> UpdateDerivedCtrlPanelCtrl(</span><span class=cF9>CCtrl</span><span class=cF0> *c)
|
|
<a name="l104"></a>{
|
|
<a name="l105"></a> CtrlPanelState *s=c->state;
|
|
<a name="l106"></a> c->left=c->win_task->pix_width-(CTRL_PANEL_SPACING*3+2);
|
|
<a name="l107"></a> c->right=c->left+CTRL_PANEL_SPACING*3+2;
|
|
<a name="l108"></a> c->top=c->win_task->pix_height-(CTRL_PANEL_SPACING*2+
|
|
<a name="l109"></a> CTRL_PANEL_RANGE+CTRL_PANEL_BTTN_SIZE);
|
|
<a name="l110"></a> c->bottom=c->top+CTRL_PANEL_SPACING*2+CTRL_PANEL_RANGE;
|
|
<a name="l111"></a>
|
|
<a name="l112"></a> s->shot_radius=</span><span class=cF5>ClampI64</span><span class=cF0>(s->shot_radius,0,CTRL_PANEL_RANGE-1);
|
|
<a name="l113"></a> s->fuse_time=</span><span class=cF5>ClampI64</span><span class=cF0>(s->fuse_time,0,CTRL_PANEL_RANGE-1);
|
|
<a name="l114"></a>}
|
|
<a name="l115"></a>
|
|
<a name="l116"></a></span><span class=cF1>U0</span><span class=cF0> LeftClickCtrlPanel(</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="l117"></a>{
|
|
<a name="l118"></a> CtrlPanelState *s=c->state;
|
|
<a name="l119"></a> </span><span class=cF1>if</span><span class=cF0> (y<c->top+CTRL_PANEL_BORDER+</span><span class=cF7>(</span><span class=cF0>CTRL_PANEL_SPACING-</span><span class=cF3>FONT_HEIGHT</span><span class=cF7>)</span><span class=cF0>/2+
|
|
<a name="l120"></a> </span><span class=cF3>FONT_HEIGHT</span><span class=cF0>+6)
|
|
<a name="l121"></a> s->spacewalk=</span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l122"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l123"></a> </span><span class=cF1>if</span><span class=cF0> (x<</span><span class=cF7>(</span><span class=cF0>c->right+c->left</span><span class=cF7>)</span><span class=cF0>/2)
|
|
<a name="l124"></a> s->shot_radius=CTRL_PANEL_RANGE-1
|
|
<a name="l125"></a> -(y-</span><span class=cF7>(</span><span class=cF0>c->top+CTRL_PANEL_SPACING+CTRL_PANEL_BTTN_SIZE</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l126"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l127"></a> s->fuse_time=CTRL_PANEL_RANGE-1
|
|
<a name="l128"></a> -(y-</span><span class=cF7>(</span><span class=cF0>c->top+CTRL_PANEL_SPACING+CTRL_PANEL_BTTN_SIZE</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l129"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l130"></a> </span><span class=cF1>if</span><span class=cF0> (c->update_derived_vals)
|
|
<a name="l131"></a> (*c->update_derived_vals)(c);
|
|
<a name="l132"></a>}
|
|
<a name="l133"></a>
|
|
<a name="l134"></a></span><span class=cF9>CCtrl</span><span class=cF0> *CtrlPanelNew()
|
|
<a name="l135"></a>{
|
|
<a name="l136"></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="l137"></a> </span><span class=cF5>MemSet</span><span class=cF0>(&ctrl_panel,0,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>ctrl_panel</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l138"></a> c->win_task=</span><span class=cF5>Fs</span><span class=cF0>;
|
|
<a name="l139"></a> c->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="l140"></a> c->type=</span><span class=cF3>CTRLT_GENERIC</span><span class=cF0>;
|
|
<a name="l141"></a> c->state=&ctrl_panel;
|
|
<a name="l142"></a> c->draw_it=&DrawCtrlPanelCtrl;
|
|
<a name="l143"></a> c->left_click=&LeftClickCtrlPanel;
|
|
<a name="l144"></a> c->update_derived_vals=&UpdateDerivedCtrlPanelCtrl;
|
|
<a name="l145"></a> </span><span class=cF5>QueIns</span><span class=cF0>(c,</span><span class=cF5>Fs</span><span class=cF0>->last_ctrl);
|
|
<a name="l146"></a> </span><span class=cF5>TaskDerivedValsUpdate</span><span class=cF0>;
|
|
<a name="l147"></a> </span><span class=cF1>return</span><span class=cF0> c;
|
|
<a name="l148"></a>}
|
|
<a name="l149"></a>
|
|
<a name="l150"></a></span><span class=cF1>U0</span><span class=cF0> CtrlPanelDel(</span><span class=cF9>CCtrl</span><span class=cF0> *c)
|
|
<a name="l151"></a>{
|
|
<a name="l152"></a> </span><span class=cF5>QueRem</span><span class=cF0>(c);
|
|
<a name="l153"></a> </span><span class=cF5>Free</span><span class=cF0>(c);
|
|
<a name="l154"></a>}
|
|
</span></pre></body>
|
|
</html>
|