1
0

timecontrol.m 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*---------------------------------------------------
  2. -----------------------------------------------------
  3. Filename: timecontrol.m
  4. Version: 1.0
  5. Type: maki
  6. Date: 29. Jun. 2007 - 00:13
  7. Author: Martin Poehlmann aka Deimos
  8. E-Mail: [email protected]
  9. Internet: www.skinconsortium.com
  10. www.martin.deimos.de.vu
  11. -----------------------------------------------------
  12. ---------------------------------------------------*/
  13. #include <lib/std.mi>
  14. #include <lib/config.mi>
  15. #include <lib/com/AutoRepeatButton.m>
  16. Function updateAttrib (int val);
  17. Global ConfigAttribute timeAttrib;
  18. Global text Display;
  19. Global AutoRepeatButton Increase, Decrease;
  20. Global float multiplier;
  21. Global int maxvalue, step;
  22. Global string suffix;
  23. Global boolean myChange;
  24. System.onScriptLoaded ()
  25. {
  26. AutoRepeat_Load();
  27. string param = getParam();
  28. string objects = getToken(param, "|", 0);
  29. group scriptGroup = getScriptGroup();
  30. Display = scriptGroup.findObject(getToken(objects, ";", 0));
  31. Decrease = scriptGroup.findObject(getToken(objects, ";", 1));
  32. Increase = scriptGroup.findObject(getToken(objects, ";", 2));
  33. objects = getToken(param, "|", 1);
  34. timeAttrib = config.getItemByGuid(getToken(objects, ";", 0)).getattribute(getToken(objects, ";", 1));
  35. step = stringToInteger(getToken(param, "|", 2));
  36. maxvalue = stringToInteger(getToken(param, "|", 3));
  37. multiplier = stringToFloat(getToken(param, "|", 4));
  38. suffix = getToken(param, "|", 5);
  39. AutoRepeat_SetInitalDelay(250);
  40. AutoRepeat_SetRepeatDelay(125);
  41. updateAttrib (0);
  42. }
  43. System.onScriptUnloading ()
  44. {
  45. AutoRepeat_Unload();
  46. }
  47. Increase.onLeftClick ()
  48. {
  49. if (!AutoRepeat_ClickType) return;
  50. updateAttrib (step);
  51. }
  52. Decrease.onLeftClick ()
  53. {
  54. if (!AutoRepeat_ClickType) return;
  55. updateAttrib (-step);
  56. }
  57. timeAttrib.onDataChanged ()
  58. {
  59. if (myChange) return;
  60. updateAttrib (0);
  61. }
  62. updateAttrib (int val)
  63. {
  64. float i = stringToInteger(timeAttrib.getData());
  65. i += val;
  66. if (i < 0 || i > maxvalue) return;
  67. myChange = 1;
  68. string s = integerToString(i);
  69. if (timeAttrib) timeAttrib.setData(s);
  70. i *= multiplier;
  71. s = floatToString(i,1);
  72. Display.setText(s + suffix);
  73. myChange = 0;
  74. }