Mimicking Spincontrollex for Shutdown Options
#1
So I've got a pseudo spin control put together using buttons and slide animations, using Xeebo as an example to start from. What it is designed to do is offer the user the shutdown options that are available for their OS. The way I currently do the check is in the onfocus element. If the option is not valid, it will automatically go to the next option. It is all working as desired, I just wanted to make sure I'm doing it in an efficient manner. If anyone has some time to look over the below code and make any suggestions/double check my work it would be greatly appreciated.

Variables:
Code:
<variable name="ShutdownOption">
    <value condition="Stringcompare(Skin.String(ShutdownOption),2)">$LOCALIZE[13012]</value>
    <value condition="Stringcompare(Skin.String(ShutdownOption),3)">$LOCALIZE[13016]</value>
    <value condition="Stringcompare(Skin.String(ShutdownOption),4)">$LOCALIZE[13011]</value>
    <value condition="Stringcompare(Skin.String(ShutdownOption),5)">$LOCALIZE[13010]</value>
    <value condition="Stringcompare(Skin.String(ShutdownOption),6)">$LOCALIZE[13013]</value>
    <value>$LOCALIZE[13005] $LOCALIZE[33061] [$LOCALIZE[13278]]</value>
  </variable>
    <variable name="ShutdownCommand">
    <value condition="Stringcompare(Skin.String(ShutdownOption),2)">XBMC.Quit()</value>
    <value condition="Stringcompare(Skin.String(ShutdownOption),3)">XBMC.Powerdown()</value>
    <value condition="Stringcompare(Skin.String(ShutdownOption),4)">XBMC.Suspend()</value>
    <value condition="Stringcompare(Skin.String(ShutdownOption),5)">XBMC.Hibernate()</value>
    <value condition="Stringcompare(Skin.String(ShutdownOption),6)">XBMC.Reset()</value>
    <value>ActivateWindow(ShutdownMenu)</value>
  </variable>

SkinSettings:
Code:
<control type="label" id="497">
    <width>740</width>
    <height>45</height>
    <label>$LOCALIZE[13008]</label>
    <font>Font_Neon_20</font>
    <textoffsetx>15</textoffsetx>
    <textcolor>mainblue</textcolor>
    <shadowcolor>black</shadowcolor>
    <align>left</align>
    <aligny>center</aligny>
  </control>
  <control type="group" id="499">
    <width>798</width>
    <height>34</height>
    <control type="image">
      <colordiffuse>mainblue</colordiffuse>
      <texture>MenuItemNF.png</texture>
    </control>
    <control type="image">
      <visible>ControlGroup(182).HasFocus() | ControlGroup(190).HasFocus()</visible>
      <colordiffuse>mainblue</colordiffuse>
      <texture>mainmenu/home_bottom_white.png</texture>
    </control>
    <control type="image">
      <visible>[!ControlGroup(182).HasFocus() + ControlGroup(190).HasFocus()] | [!ControlGroup(182).HasFocus() + !ControlGroup(190).HasFocus()]</visible>
      <left>695</left>
      <top>-15</top>
      <colordiffuse>mainblue</colordiffuse>
      <width>48</width>
      <height>65</height>
      <texture>settings/spin-down.png</texture>
    </control>
    <control type="image">
      <visible>[ControlGroup(182).HasFocus() + !ControlGroup(190).HasFocus()] | [!ControlGroup(182).HasFocus() + !ControlGroup(190).HasFocus()]</visible>
      <left>743</left>
      <top>-15</top>
      <colordiffuse>mainblue</colordiffuse>
      <width>48</width>
      <height>65</height>
      <texture>settings/spin-up.png</texture>
    </control>
    <control type="image">
      <visible>ControlGroup(182).HasFocus() + !ControlGroup(190).HasFocus()</visible>
      <left>695</left>
      <top>-15</top>
      <colordiffuse>mainblue</colordiffuse>
      <width>48</width>
      <height>65</height>
      <texture>settings/spin-down-focus.png</texture>
    </control>
    <control type="image">
      <visible>!ControlGroup(182).HasFocus() + ControlGroup(190).HasFocus()</visible>
      <left>743</left>
      <top>-15</top>
      <colordiffuse>mainblue</colordiffuse>
      <width>48</width>
      <height>65</height>
      <texture>settings/spin-up-focus.png</texture>
    </control>
    <control type="label">
      <visible>ControlGroup(182).HasFocus() | ControlGroup(190).HasFocus()</visible>
      <width>600</width>
      <height>34</height>
      <textoffsetx>30</textoffsetx>
      <font>Font_Neon_25</font>
      <label>$VAR[ShutdownOption]</label>
      <textcolor>white</textcolor>
      <aligny>center</aligny>
    </control>
    <control type="label">
      <visible>!ControlGroup(182).HasFocus() + !ControlGroup(190).HasFocus()</visible>
      <width>600</width>
      <height>34</height>
      <textoffsetx>30</textoffsetx>
      <font>Font_Neon_25</font>
      <label>$VAR[ShutdownOption]</label>
      <textcolor>grey2</textcolor>
      <aligny>center</aligny>
    </control>
    <control type="group" id="182">
      <control type="button" id="183">
        <description>Menu Option</description>
        <left>1280</left>
        <top>0</top>
        <width>742</width>
        <height>34</height>
        <onleft>9000</onleft>
        <onright>193</onright>
        <onup>123</onup>
        <ondown>101</ondown>
        <texturefocus>-</texturefocus>
        <texturenofocus>-</texturenofocus>
        <onclick>Skin.SetString(ShutdownOption,2)</onclick>
        <onclick>SetFocus(184)</onclick>
        <animation effect="slide" start="0,0" end="-1280,0" condition="Stringcompare(Skin.String(ShutdownOption),1) | IsEmpty(Skin.String(ShutdownOption))">Conditional</animation>
      </control>
      <control type="button" id="184">
        <description>Exit Option</description>
        <left>1280</left>
        <top>0</top>
        <width>742</width>
        <height>34</height>
        <onleft>9000</onleft>
        <onright>194</onright>
        <onup>123</onup>
        <ondown>101</ondown>
        <texturefocus>-</texturefocus>
        <texturenofocus>-</texturenofocus>
        <onfocus condition="!System.ShowExitButton">Skin.SetString(ShutdownOption,3)</onfocus>
        <onfocus condition="!System.ShowExitButton">SetFocus(185)</onfocus>
        <onclick>Skin.SetString(ShutdownOption,3)</onclick>
        <onclick>SetFocus(185)</onclick>
        <animation effect="slide" start="0,0" end="-1280,0" condition="Stringcompare(Skin.String(ShutdownOption),2)">Conditional</animation>
      </control>
      <control type="button" id="185">
        <description>Shutdown System Option</description>
        <left>1280</left>
        <top>0</top>
        <width>742</width>
        <height>34</height>
        <onleft>9000</onleft>
        <onright>195</onright>
        <onup>123</onup>
        <ondown>101</ondown>
        <texturefocus>-</texturefocus>
        <texturenofocus>-</texturenofocus>
        <onfocus condition="!System.CanPowerDown">Skin.SetString(ShutdownOption,4)</onfocus>
        <onfocus condition="!System.CanPowerDown">SetFocus(186)</onfocus>
        <onclick>Skin.SetString(ShutdownOption,4)</onclick>
        <onclick>SetFocus(186)</onclick>
        <animation effect="slide" start="0,0" end="-1280,0" condition="Stringcompare(Skin.String(ShutdownOption),3)">Conditional</animation>
      </control>
      <control type="button" id="186">
        <description>Suspend System Option</description>
        <left>1280</left>
        <top>0</top>
        <width>742</width>
        <height>34</height>
        <onleft>9000</onleft>
        <onright>196</onright>
        <onup>123</onup>
        <ondown>101</ondown>
        <texturefocus>-</texturefocus>
        <texturenofocus>-</texturenofocus>
        <onfocus condition="!System.CanSuspend">Skin.SetString(ShutdownOption,5)</onfocus>
        <onfocus condition="!System.CanSuspend">SetFocus(187)</onfocus>
        <onclick>Skin.SetString(ShutdownOption,5)</onclick>
        <onclick>SetFocus(187)</onclick>
        <animation effect="slide" start="0,0" end="-1280,0" condition="Stringcompare(Skin.String(ShutdownOption),4)">Conditional</animation>
      </control>
      <control type="button" id="187">
        <description>Hibernate Option</description>
        <left>1280</left>
        <top>0</top>
        <width>742</width>
        <height>34</height>
        <onleft>9000</onleft>
        <onright>197</onright>
        <onup>123</onup>
        <ondown>101</ondown>
        <texturefocus>-</texturefocus>
        <texturenofocus>-</texturenofocus>
        <onfocus condition="!System.CanHibernate">Skin.SetString(ShutdownOption,6)</onfocus>
        <onfocus condition="!System.CanHibernate">SetFocus(188)</onfocus>
        <onclick>Skin.SetString(ShutdownOption,6)</onclick>
        <onclick>SetFocus(188)</onclick>
        <animation effect="slide" start="0,0" end="-1280,0" condition="Stringcompare(Skin.String(ShutdownOption),5)">Conditional</animation>
      </control>
      <control type="button" id="188">
        <description>Reboot System Option</description>
        <left>1280</left>
        <top>0</top>
        <width>742</width>
        <height>34</height>
        <onleft>9000</onleft>
        <onright>198</onright>
        <onup>123</onup>
        <ondown>101</ondown>
        <texturefocus>-</texturefocus>
        <texturenofocus>-</texturenofocus>
        <onfocus condition="!System.CanReboot">Skin.SetString(ShutdownOption,1)</onfocus>
        <onfocus condition="!System.CanReboot">SetFocus(183)</onfocus>
        <onclick>Skin.SetString(ShutdownOption,1)</onclick>
        <onclick>SetFocus(183)</onclick>
        <animation effect="slide" start="0,0" end="-1280,0" condition="Stringcompare(Skin.String(ShutdownOption),6)">Conditional</animation>
      </control>
    </control>
    <control type="group" id="190">
      <control type="button" id="193">
        <description>Menu Option</description>
        <left>2023</left>
        <top>0</top>
        <width>56</width>
        <height>34</height>
        <onleft>183</onleft>
        <onright>9000</onright>
        <onup>123</onup>
        <ondown>101</ondown>
        <texturefocus>-</texturefocus>
        <texturenofocus>-</texturenofocus>
        <onclick>Skin.SetString(ShutdownOption,6)</onclick>
        <onclick>SetFocus(198)</onclick>
        <animation effect="slide" start="0,0" end="-1280,0" condition="Stringcompare(Skin.String(ShutdownOption),1) | IsEmpty(Skin.String(ShutdownOption))">Conditional</animation>
      </control>
      <control type="button" id="194">
        <description>Exit Option</description>
        <left>2023</left>
        <top>0</top>
        <width>56</width>
        <height>34</height>
        <onleft>184</onleft>
        <onright>9000</onright>
        <onup>123</onup>
        <ondown>101</ondown>
        <texturefocus>-</texturefocus>
        <texturenofocus>-</texturenofocus>
        <onfocus condition="!System.ShowExitButton">Skin.SetString(ShutdownOption,1)</onfocus>
        <onfocus condition="!System.ShowExitButton">SetFocus(193)</onfocus>
        <onclick>Skin.SetString(ShutdownOption,1)</onclick>
        <onclick>SetFocus(193)</onclick>
        <animation effect="slide" start="0,0" end="-1280,0" condition="Stringcompare(Skin.String(ShutdownOption),2)">Conditional</animation>
      </control>
      <control type="button" id="195">
        <description>Shutdown System Option</description>
        <left>2023</left>
        <top>0</top>
        <width>56</width>
        <height>34</height>
        <onleft>185</onleft>
        <onright>9000</onright>
        <onup>123</onup>
        <ondown>101</ondown>
        <texturefocus>-</texturefocus>
        <texturenofocus>-</texturenofocus>
        <onfocus condition="!System.CanPowerDown">Skin.SetString(ShutdownOption,2)</onfocus>
        <onfocus condition="!System.CanPowerDown">SetFocus(194)</onfocus>
        <onclick>Skin.SetString(ShutdownOption,2)</onclick>
        <onclick>SetFocus(194)</onclick>
        <animation effect="slide" start="0,0" end="-1280,0" condition="Stringcompare(Skin.String(ShutdownOption),3)">Conditional</animation>
      </control>
      <control type="button" id="196">
        <description>Suspend System Option</description>
        <left>2023</left>
        <top>0</top>
        <width>56</width>
        <height>34</height>
        <onleft>186</onleft>
        <onright>9000</onright>
        <onup>123</onup>
        <ondown>101</ondown>
        <texturefocus>-</texturefocus>
        <texturenofocus>-</texturenofocus>
        <onfocus condition="!System.CanSuspend">Skin.SetString(ShutdownOption,3)</onfocus>
        <onfocus condition="!System.CanSuspend">SetFocus(195)</onfocus>
        <onclick>Skin.SetString(ShutdownOption,3)</onclick>
        <onclick>SetFocus(195)</onclick>
        <animation effect="slide" start="0,0" end="-1280,0" condition="Stringcompare(Skin.String(ShutdownOption),4)">Conditional</animation>
      </control>
      <control type="button" id="197">
        <description>Hibernate Option</description>
        <left>2023</left>
        <top>0</top>
        <width>56</width>
        <height>34</height>
        <onleft>187</onleft>
        <onright>9000</onright>
        <onup>123</onup>
        <ondown>101</ondown>
        <texturefocus>-</texturefocus>
        <texturenofocus>-</texturenofocus>
        <onfocus condition="!System.CanHibernate">Skin.SetString(ShutdownOption,4)</onfocus>
        <onfocus condition="!System.CanHibernate">SetFocus(196)</onfocus>
        <onclick>Skin.SetString(ShutdownOption,4)</onclick>
        <onclick>SetFocus(196)</onclick>
        <animation effect="slide" start="0,0" end="-1280,0" condition="Stringcompare(Skin.String(ShutdownOption),5)">Conditional</animation>
      </control>
      <control type="button" id="198">
        <description>Reboot System Option</description>
        <left>2023</left>
        <top>0</top>
        <width>56</width>
        <height>34</height>
        <onleft>188</onleft>
        <onright>9000</onright>
        <onup>123</onup>
        <ondown>101</ondown>
        <texturefocus>-</texturefocus>
        <texturenofocus>-</texturenofocus>
        <onfocus condition="!System.CanReboot">Skin.SetString(ShutdownOption,5)</onfocus>
        <onfocus condition="!System.CanReboot">SetFocus(197)</onfocus>
        <onclick>Skin.SetString(ShutdownOption,5)</onclick>
        <onclick>SetFocus(197)</onclick>
        <animation effect="slide" start="0,0" end="-1280,0" condition="Stringcompare(Skin.String(ShutdownOption),6)">Conditional</animation>
      </control>
    </control>
  </control>
Reply
#2
There's a number of ways to fake it but if this works I wouldn't worry about efficiency.

Would be nice to fill a spincontrol with content though.
Reply

Logout Mark Read Team Forum Stats Members Help
Mimicking Spincontrollex for Shutdown Options0