@@ -1645,17 +1645,15 @@ char propValue[255] = "";
16451645void prop_edit_ui (pixel *vid_buf)
16461646{
16471647 pixel * o_vid_buf;
1648- int format;
1649- size_t propoffset;
1650- char *listitems[] = {" type" , " life" , " ctype" , " temp" , " tmp" , " tmp2" , " vy" , " vx" , " x" , " y" , " dcolour" , " flags" };
1651- int listitemscount = 12 ;
1648+ int format, propoffset = -1 ;
1649+ char *listitems[] = {" type" , " life" , " ctype" , " temp" , " tmp" , " tmp2" , " vy" , " vx" , " x" , " y" , " dcolour" , " flags" , " pavg0" , " pavg1" };
1650+ int listitemscount = 14 ;
16521651 int xsize = 244 ;
16531652 int ysize = 87 ;
16541653 int x0=(XRES -xsize)/2 ,y0=(YRES -MENUSIZE -ysize)/2 ,b=1 ,bq,mx,my;
16551654 ui_list ed;
16561655 ui_edit ed2;
16571656 PropTool* propTool = (PropTool*)GetToolFromIdentifier (" DEFAULT_UI_PROPERTY" );
1658- bool name = false ;
16591657
16601658 ed.x = x0+8 ;
16611659 ed.y = y0+25 ;
@@ -1731,60 +1729,18 @@ void prop_edit_ui(pixel *vid_buf)
17311729 }
17321730 }
17331731
1734- if (ed.selected != -1 )
1735- {
1736- if (!strcmp (ed.str , " type" )) {
1737- propoffset = offsetof (particle, type);
1738- format = 1 ;
1739- name = true ;
1740- } else if (!strcmp (ed.str ," life" )) {
1741- propoffset = offsetof (particle, life);
1742- format = 0 ;
1743- } else if (!strcmp (ed.str ," ctype" )) {
1744- propoffset = offsetof (particle, ctype);
1745- format = 1 ;
1746- } else if (!strcmp (ed.str ," temp" )) {
1747- propoffset = offsetof (particle, temp);
1748- format = 2 ;
1749- } else if (!strcmp (ed.str ," tmp" )) {
1750- propoffset = offsetof (particle, tmp);
1751- format = 0 ;
1752- } else if (!strcmp (ed.str ," tmp2" )) {
1753- propoffset = offsetof (particle, tmp2);
1754- format = 0 ;
1755- } else if (!strcmp (ed.str ," vy" )) {
1756- propoffset = offsetof (particle, vy);
1757- format = 2 ;
1758- } else if (!strcmp (ed.str ," vx" )) {
1759- propoffset = offsetof (particle, vx);
1760- format = 2 ;
1761- } else if (!strcmp (ed.str ," x" )) {
1762- propoffset = offsetof (particle, x);
1763- format = 2 ;
1764- } else if (!strcmp (ed.str ," y" )) {
1765- propoffset = offsetof (particle, y);
1766- format = 2 ;
1767- } else if (!strcmp (ed.str ," dcolour" )) {
1768- propoffset = offsetof (particle, dcolour);
1769- format = 3 ;
1770- } else if (!strcmp (ed.str ," flags" )) {
1771- propoffset = offsetof (particle, flags);
1772- format = 3 ;
1773- }
1774- } else {
1732+ if (ed.selected != -1 )
1733+ {
1734+ propoffset = luacon_particle_getproperty (ed.str , &format);
1735+ }
1736+ if (propoffset == -1 )
1737+ {
17751738 error_ui (vid_buf, 0 , " Invalid property" );
17761739 goto exit;
17771740 }
17781741
1779- propTool->propOffset = propoffset;
1780- if (format == 0 )
1781- {
1782- int value;
1783- sscanf (ed2.str , " %d" , &value);
1784- propTool->propValue .Integer = value;
1785- propTool->propType = Integer;
1786- }
1787- else if (format == 1 )
1742+ propTool->propOffset = (size_t )propoffset;
1743+ if (format == 2 || !strcmp (ed.str , " ctype" )) // ctype is special here
17881744 {
17891745 unsigned int value;
17901746 int isint = 1 ;
@@ -1809,15 +1765,22 @@ void prop_edit_ui(pixel *vid_buf)
18091765 goto exit;
18101766 }
18111767 }
1812- if (name && (value < 0 || value > PT_NUM || !ptypes[value].enabled ))
1768+ if (format == 2 && (value < 0 || value > PT_NUM || !ptypes[value].enabled ))
18131769 {
18141770 error_ui (vid_buf, 0 , " Invalid element number" );
18151771 goto exit;
18161772 }
18171773 propTool->propValue .UInteger = value;
18181774 propTool->propType = UInteger;
18191775 }
1820- else if (format == 2 )
1776+ else if (format == 0 )
1777+ {
1778+ int value;
1779+ sscanf (ed2.str , " %d" , &value);
1780+ propTool->propValue .Integer = value;
1781+ propTool->propType = Integer;
1782+ }
1783+ else if (format == 1 )
18211784 {
18221785 float value;
18231786 sscanf (ed2.str , " %f" , &value);
0 commit comments