guiParticleGraphInspector_ScriptBinding.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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 area that will be displayed on the graph.
  55. @param Area Four space-deliminated values representing left, bottom, right, top.
  56. @return No return value.
  57. */
  58. ConsoleMethodWithDocs(GuiParticleGraphInspector, setDisplayArea, ConsoleVoid, 3, 3, "(area (xMin / yMin / xMax / yMax))")
  59. {
  60. if (argc < 3)
  61. {
  62. Con::warnf("GuiParticleGraphInspector:setDisplayArea - Wrong number of arguments. Should be area(left / bottom / right / top).");
  63. return;
  64. }
  65. U32 count = Utility::mGetStringElementCount(argv[2]);
  66. if (count != 4)
  67. {
  68. Con::warnf("GuiParticleGraphInspector:setDisplayArea - Area does not have four values. Should be area(left / bottom / right / top).");
  69. return;
  70. }
  71. StringTableEntry s1 = StringTable->insert(Utility::mGetStringElement(argv[2], 0));
  72. StringTableEntry s2 = StringTable->insert(Utility::mGetStringElement(argv[2], 1));
  73. StringTableEntry s3 = StringTable->insert(Utility::mGetStringElement(argv[2], 2));
  74. StringTableEntry s4 = StringTable->insert(Utility::mGetStringElement(argv[2], 3));
  75. object->setDisplayArea(s1, s2, s3, s4);
  76. }
  77. /*! Sets the labels to display on the graph.
  78. @param LabelX The label that appears on the bottom of the graph.
  79. @param LabelY The label that appears on the left of the graph.
  80. @return No return value.
  81. */
  82. ConsoleMethodWithDocs(GuiParticleGraphInspector, setDisplayLabels, ConsoleVoid, 4, 4, "(LabelX, LabelY)")
  83. {
  84. if (argc < 4)
  85. {
  86. Con::warnf("GuiParticleGraphInspector:setDisplayLabels - Wrong number of arguments. Should be LabelX and LabelY.");
  87. return;
  88. }
  89. object->setDisplayLabels(argv[2], argv[3]);
  90. }
  91. ConsoleMethodGroupEndWithDocs(GuiParticleGraphInspector)