PolycodeProps.h 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455
  1. /*
  2. Copyright (C) 2012 by Ivan Safrin
  3. Permission is hereby granted, free of charge, to any person obtaining a copy
  4. of this software and associated documentation files (the "Software"), to deal
  5. in the Software without restriction, including without limitation the rights
  6. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7. copies of the Software, and to permit persons to whom the Software is
  8. furnished to do so, subject to the following conditions:
  9. The above copyright notice and this permission notice shall be included in
  10. all copies or substantial portions of the Software.
  11. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  13. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  14. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  15. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  16. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  17. THE SOFTWARE.
  18. */
  19. #pragma once
  20. #include "PolycodeGlobals.h"
  21. #include "PolycodeUI.h"
  22. #include "Polycode.h"
  23. #include "OSBasics.h"
  24. using namespace Polycode;
  25. class PropProp : public UIElement {
  26. public:
  27. PropProp(String caption);
  28. ~PropProp();
  29. ScreenLabel *label;
  30. ScreenEntity *propContents;
  31. };
  32. class Vector2Prop : public PropProp {
  33. public:
  34. Vector2Prop(String caption);
  35. ~Vector2Prop();
  36. void handleEvent(Event *event);
  37. void set(Vector2 position);
  38. Vector2 get();
  39. UITextInput *positionX;
  40. UITextInput *positionY;
  41. };
  42. class SliderProp : public PropProp {
  43. public:
  44. SliderProp(String caption, Number min, Number max);
  45. ~SliderProp();
  46. void handleEvent(Event *event);
  47. void set(Number number);
  48. Number get();
  49. UIHSlider *slider;
  50. ScreenLabel *valueLabel;
  51. };
  52. class NumberProp : public PropProp {
  53. public:
  54. NumberProp(String caption);
  55. ~NumberProp();
  56. void handleEvent(Event *event);
  57. void set(Number number);
  58. Number get();
  59. UITextInput *numberEntry;
  60. };
  61. class StringProp : public PropProp {
  62. public:
  63. StringProp(String caption);
  64. ~StringProp();
  65. void handleEvent(Event *event);
  66. void set(String str);
  67. String get();
  68. UITextInput *stringEntry;
  69. };
  70. class ColorProp : public PropProp {
  71. public:
  72. ColorProp(String caption);
  73. ~ColorProp();
  74. void handleEvent(Event *event);
  75. void set(Color color);
  76. Color get();
  77. UIColorBox *colorEntry;
  78. };
  79. class ComboProp : public PropProp {
  80. public:
  81. ComboProp(String caption);
  82. ~ComboProp();
  83. void handleEvent(Event *event);
  84. void set(unsigned int index);
  85. unsigned int get();
  86. UIComboBox *comboEntry;
  87. };
  88. class BoolProp : public PropProp {
  89. public:
  90. BoolProp(String caption);
  91. ~BoolProp();
  92. void handleEvent(Event *event);
  93. void set(bool val);
  94. bool get();
  95. UICheckBox *checkEntry;
  96. };
  97. class SoundProp : public PropProp {
  98. public:
  99. SoundProp(String caption);
  100. ~SoundProp();
  101. void handleEvent(Event *event);
  102. void set(String soundPath);
  103. String get();
  104. Sound *previewSound;
  105. ScreenLabel *soundFile;
  106. UIButton *changeButton;
  107. UIButton *playButton;
  108. };
  109. class BezierRGBACurveProp : public PropProp {
  110. public:
  111. BezierRGBACurveProp(String caption);
  112. ~BezierRGBACurveProp();
  113. void handleEvent(Event *event);
  114. BezierCurve *curveR;
  115. BezierCurve *curveG;
  116. BezierCurve *curveB;
  117. BezierCurve *curveA;
  118. UIButton *changeButton;
  119. };
  120. class BezierCurveProp : public PropProp {
  121. public:
  122. BezierCurveProp(String caption, String curveName);
  123. ~BezierCurveProp();
  124. void handleEvent(Event *event);
  125. String curveName;
  126. BezierCurve *curve;
  127. UIButton *changeButton;
  128. };
  129. class TextureProp : public PropProp {
  130. public:
  131. TextureProp(String caption);
  132. ~TextureProp();
  133. void handleEvent(Event *event);
  134. void set(Texture *texture);
  135. Texture* get();
  136. ScreenShape *previewShape;
  137. UIButton *changeButton;
  138. };
  139. class ScreenSpriteProp : public PropProp {
  140. public:
  141. ScreenSpriteProp(String caption);
  142. ~ScreenSpriteProp();
  143. void handleEvent(Event *event);
  144. void set(String fileName);
  145. String get();
  146. ScreenSprite *previewSprite;
  147. UIButton *changeButton;
  148. };
  149. class ScreenEntityInstanceProp : public PropProp {
  150. public:
  151. ScreenEntityInstanceProp(String caption);
  152. ~ScreenEntityInstanceProp();
  153. void handleEvent(Event *event);
  154. void set(String fileName);
  155. String get();
  156. ScreenEntityInstance *previewInstance;
  157. UIButton *changeButton;
  158. };
  159. class PropSheet : public UIElement {
  160. public:
  161. PropSheet(String caption, String type);
  162. ~PropSheet();
  163. void Resize(Number width, Number height);
  164. void handleEvent(Event *event);
  165. void setCollapsed(bool val);
  166. void addProp(PropProp *prop);
  167. String caption;
  168. String type;
  169. Number propHeight;
  170. ScreenEntity *contents;
  171. ScreenShape *bg;
  172. UIImageButton *collapseButton;
  173. UIImageButton *expandButton;
  174. bool collapsed;
  175. std::vector<PropProp*> props;
  176. };
  177. class EntitySheet : public PropSheet {
  178. public:
  179. EntitySheet();
  180. ~EntitySheet();
  181. void handleEvent(Event *event);
  182. void Update();
  183. Entity *entity;
  184. Entity *lastEntity;
  185. StringProp *idProp;
  186. StringProp *tagProp;
  187. ColorProp *colorProp;
  188. ComboProp *blendingProp;
  189. };
  190. class ShapeSheet : public PropSheet {
  191. public:
  192. ShapeSheet();
  193. ~ShapeSheet();
  194. void handleEvent(Event *event);
  195. void Update();
  196. ScreenShape *shape;
  197. ComboProp *typeProp;
  198. Vector2Prop *shapeSize;
  199. BoolProp *strokeProp;
  200. ColorProp *strokeColorProp;
  201. NumberProp *strokeSize;
  202. bool lastStrokeVal;
  203. int lastShapeType;
  204. Vector2 lastShapeSize;
  205. Color lastStrokeColor;
  206. Number lastStrokeSize;
  207. };
  208. class ScreenLabelSheet : public PropSheet {
  209. public:
  210. ScreenLabelSheet();
  211. ~ScreenLabelSheet();
  212. void refreshFonts();
  213. void handleEvent(Event *event);
  214. void Update();
  215. ScreenLabel *label;
  216. int lastSize;
  217. String lastFont;
  218. StringProp *caption;
  219. NumberProp *size;
  220. ComboProp *font;
  221. BoolProp *enableAA;
  222. };
  223. class ScreenImageSheet : public PropSheet {
  224. public:
  225. ScreenImageSheet();
  226. ~ScreenImageSheet();
  227. void handleEvent(Event *event);
  228. void Update();
  229. ScreenImage *image;
  230. TextureProp *texture;
  231. };
  232. class ScreenSpriteSheet : public PropSheet {
  233. public:
  234. ScreenSpriteSheet();
  235. ~ScreenSpriteSheet();
  236. void handleEvent(Event *event);
  237. void Update();
  238. ScreenSprite *sprite;
  239. ScreenSpriteProp *spriteProp;
  240. ComboProp *defaultAnimationProp;
  241. ScreenSprite *lastAnimationCheck;
  242. };
  243. class ScreenEntityInstanceSheet : public PropSheet {
  244. public:
  245. ScreenEntityInstanceSheet();
  246. ~ScreenEntityInstanceSheet();
  247. void handleEvent(Event *event);
  248. void Update();
  249. ScreenEntityInstance *instance;
  250. ScreenEntityInstanceProp *instanceProp;
  251. };
  252. class SoundSheet : public PropSheet {
  253. public:
  254. SoundSheet();
  255. ~SoundSheet();
  256. void handleEvent(Event *event);
  257. void Update();
  258. ScreenSound *sound;
  259. SoundProp *soundProp;
  260. NumberProp *referenceDistance;
  261. NumberProp *maxDistance;
  262. NumberProp *volume;
  263. NumberProp *pitch;
  264. String lastSoundPath;
  265. Number lastReferenceDistance;
  266. Number lastMaxDistance;
  267. Number lastVolume;
  268. Number lastPitch;
  269. };
  270. class ScreenParticleSheet : public PropSheet {
  271. public:
  272. ScreenParticleSheet();
  273. ~ScreenParticleSheet();
  274. void handleEvent(Event *event);
  275. void Update();
  276. TextureProp *textureProp;
  277. ComboProp *blendingProp;
  278. NumberProp *numParticlesProp;
  279. NumberProp *lifespanProp;
  280. NumberProp *particleScaleProp;
  281. Vector2Prop *sizeProp;
  282. Vector2Prop *dirProp;
  283. Vector2Prop *gravProp;
  284. Vector2Prop *deviationProp;
  285. SliderProp *brightnessDeviationProp;
  286. BoolProp *perlinEnableProp;
  287. NumberProp *perlinModSizeProp;
  288. SliderProp *speedModProp;
  289. NumberProp *rotationSpeedProp;
  290. BoolProp *rotationFollowsPathProp;
  291. BoolProp *useScaleCurvesProp;
  292. BezierCurveProp *scaleCurveProp;
  293. BoolProp *useColorCurvesProp;
  294. BezierRGBACurveProp *colorCurveProp;
  295. Number lastParticleScale;
  296. Number lastRotationSpeed;
  297. Number lastNumParticles;
  298. Number lastLifespan;
  299. Vector3 lastSize;
  300. Vector3 lastDeviation;
  301. Vector3 lastDir;
  302. Vector3 lastGrav;
  303. Number lastBrightnessDeviation;
  304. bool lastEnableProp;
  305. Number lastPerlinSize;
  306. Number lastSpeedMod;
  307. bool lastRotationFollowsPath;
  308. bool lastUseScaleCurves;
  309. bool lastUseColorCurves;
  310. BezierCurve *lastScaleCurve;
  311. ScreenParticleEmitter *emitter;
  312. };
  313. class Transform2DSheet : public PropSheet {
  314. public:
  315. Transform2DSheet();
  316. ~Transform2DSheet();
  317. void handleEvent(Event *event);
  318. void Update();
  319. Vector2Prop *positionProp;
  320. Vector2Prop *scaleProp;
  321. NumberProp *rotationProp;
  322. BoolProp *topLeftProp;
  323. Vector2 lastPositon;
  324. Vector2 lastScale;
  325. Number lastRotation;
  326. int lastPositionMode;
  327. ScreenEntity *entity;
  328. };
  329. class PropList : public UIElement {
  330. public:
  331. PropList(String caption="PROPERTIES");
  332. ~PropList();
  333. void updateProps();
  334. void addPropSheet(PropSheet *sheet);
  335. void handleEvent(Event *event);
  336. void Resize(Number width, Number height);
  337. UIScrollContainer *scrollContainer;
  338. protected:
  339. ScreenEntity *propContents;
  340. std::vector<PropSheet*> props;
  341. ScreenShape *bg;
  342. ScreenShape *bg2;
  343. };