guiParticleGraphInspector_ScriptBinding.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2013 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. ConsoleMethodGroupBeginWithDocs(GuiParticleGraphInspector, GuiControl)
  23. /*! Sets the Particle Asset that will be used to draw graphs.
  24. @param ParticleAsset The target of the graphs.
  25. @return No return value.
  26. */
  27. ConsoleMethodWithDocs(GuiParticleGraphInspector, inspect, ConsoleVoid, 3, 3, "(ParticleAsset)")
  28. {
  29. ParticleAsset* target = dynamic_cast<ParticleAsset*>(Sim::findObject(argv[2]));
  30. if (!target)
  31. {
  32. if (dAtoi(argv[2]) > 0)
  33. Con::warnf("%s::inspect(): Object is not a ParticleAsset: %s", argv[0], argv[2]);
  34. return;
  35. }
  36. object->inspectObject(target);
  37. }
  38. /*! Sets the graph field to display.
  39. @param FieldName The name of the field that should be displayed.
  40. @param EmitterIndex If the field belongs to an emitter, include the index of the emitter to display.
  41. @return No return value.
  42. */
  43. ConsoleMethodWithDocs(GuiParticleGraphInspector, setDisplayField, ConsoleVoid, 3, 4, "(FieldName, [EmitterIndex])")
  44. {
  45. if (argc > 3)
  46. {
  47. object->setDisplayField(argv[2], dAtoi(argv[3]));
  48. }
  49. else
  50. {
  51. object->setDisplayField(argv[2]);
  52. }
  53. }
  54. /*! Sets the graph inspector to use to show variance.
  55. @param Inspector The GuiParticleGraphInspector that is tracking the variation.
  56. @return No return value.
  57. */
  58. ConsoleMethodWithDocs(GuiParticleGraphInspector, setVariationGraphInspector, ConsoleVoid, 3, 3, "(inspector)")
  59. {
  60. GuiParticleGraphInspector* inspector = dynamic_cast<GuiParticleGraphInspector*>(Sim::findObject(argv[2]));
  61. if (!inspector)
  62. {
  63. if (dAtoi(argv[2]) > 0)
  64. Con::warnf("%s::setVariationGraphInspector(): Object is not a GuiParticleGraphInspector: %s", argv[0], argv[2]);
  65. return;
  66. }
  67. object->setVariationGraphInspector(inspector);
  68. }
  69. /*! Sets the area that will be displayed on the graph.
  70. @param Area Four space-deliminated values representing left, bottom, right, top.
  71. @return No return value.
  72. */
  73. ConsoleMethodWithDocs(GuiParticleGraphInspector, setDisplayArea, ConsoleVoid, 3, 3, "(area (xMin / yMin / xMax / yMax))")
  74. {
  75. if (argc < 3)
  76. {
  77. Con::warnf("GuiParticleGraphInspector:setDisplayArea - Wrong number of arguments. Should be area(left / bottom / right / top).");
  78. return;
  79. }
  80. U32 count = Utility::mGetStringElementCount(argv[2]);
  81. if (count != 4)
  82. {
  83. Con::warnf("GuiParticleGraphInspector:setDisplayArea - Area does not have four values. Should be area(left / bottom / right / top).");
  84. return;
  85. }
  86. StringTableEntry s1 = StringTable->insert(Utility::mGetStringElement(argv[2], 0));
  87. StringTableEntry s2 = StringTable->insert(Utility::mGetStringElement(argv[2], 1));
  88. StringTableEntry s3 = StringTable->insert(Utility::mGetStringElement(argv[2], 2));
  89. StringTableEntry s4 = StringTable->insert(Utility::mGetStringElement(argv[2], 3));
  90. object->setDisplayArea(s1, s2, s3, s4);
  91. }
  92. /*! Sets the labels to display on the graph.
  93. @param LabelX The label that appears on the bottom of the graph.
  94. @param LabelY The label that appears on the left of the graph.
  95. @return No return value.
  96. */
  97. ConsoleMethodWithDocs(GuiParticleGraphInspector, setDisplayLabels, ConsoleVoid, 4, 4, "(LabelX, LabelY)")
  98. {
  99. if (argc < 4)
  100. {
  101. Con::warnf("GuiParticleGraphInspector:setDisplayLabels - Wrong number of arguments. Should be LabelX and LabelY.");
  102. return;
  103. }
  104. object->setDisplayLabels(argv[2], argv[3]);
  105. }
  106. ConsoleMethodGroupEndWithDocs(GuiParticleGraphInspector)