ScriptFormatter.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. * Copyright (C) 2022 The V-Gears Team
  3. *
  4. * This file is part of V-Gears
  5. *
  6. * V-Gears is free software: you can redistribute it and/or modify it under
  7. * terms of the GNU General Public License as published by the Free Software
  8. * Foundation, version 3.0 (GPLv3) of the License.
  9. *
  10. * V-Gears is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. */
  15. #pragma once
  16. #include <map>
  17. #include <vector>
  18. #include <string>
  19. #include "DecompilerException.h"
  20. class ScriptFormatter{
  21. public:
  22. virtual ~ScriptFormatter() = default;
  23. /**
  24. * Retrieves a friendly name for a variable.
  25. *
  26. * @param[in] bank Variable memory bank.
  27. * @param[in] addr Variable memory address.
  28. * @return Friendly name assigned to the variable, or an empty
  29. * string if there is none.
  30. */
  31. virtual std::string GetFriendlyVarName(unsigned int bank, unsigned int addr);
  32. /**
  33. * Retrieves a friendly name for an entity.
  34. *
  35. * @param[in] entity_name Name of the entity.
  36. * @return Friendly name assigned to the entity, or entity_name
  37. * if there is none.
  38. */
  39. virtual std::string GetFriendlyEntityName(const std::string& entity_name);
  40. /**
  41. * Retrieves a friendly name for an animation.
  42. *
  43. * @param[in] animation_id ID of the animation.
  44. * @param[in] id Unused.
  45. * @return Friendly name assigned to the animation. If there is
  46. * no one, the ID in string format.
  47. */
  48. virtual std::string GetFriendlyAnimationName(int animation_id, int id);
  49. /**
  50. * Retrieves the animation a model must play when its script doesn't set a default one.
  51. *
  52. * The engine plays the animation called "Idle" by default. Models that don't have one
  53. * show no animation at all, and they are not drawn.
  54. *
  55. * @param[in] char_id ID of the model, as given to the CHAR opcode.
  56. * @return Name of the animation to play, or an empty string if the model already has an
  57. * animation called "Idle", or there is no animation to choose.
  58. */
  59. virtual std::string GetDefaultAnimationName(int char_id);
  60. /**
  61. * Retrieves the animation a model plays when it walks or runs on its own.
  62. *
  63. * In the original game the second animation of a model is its walk, and the third its
  64. * run. Only some models have those called "Walk" and "Run".
  65. *
  66. * @param[in] char_id ID of the model, as given to the CHAR opcode.
  67. * @param[in] index 1 for the walk animation, 2 for the run animation.
  68. * @return Name of the animation, or an empty string if the model hasn't got it.
  69. */
  70. virtual std::string GetMoveAnimationName(int char_id, int index);
  71. /**
  72. * Retrieves a friendly name for a character.
  73. *
  74. * @param[in] char_id ID of the character.
  75. * @return Friendly name assigned to the character. If there is
  76. * no one, the ID in string format.
  77. */
  78. virtual std::string GetFriendlyCharName(int char_id);
  79. /**
  80. * Retrieves a friendly name for a function.
  81. *
  82. * @param[in] entity_name Name of the entity.
  83. * @param[in] function_name Name of the function.
  84. * @return Friendly name assigned to the entity, or
  85. * function_name if there is none.
  86. */
  87. virtual std::string GetFriendlyFunctionName(const std::string& entity_name, const std::string& function_name);
  88. /**
  89. * Retrieves the header comment for a function in an entity.
  90. *
  91. * @param[in] entity_name Name of the entity.
  92. * @param[in] function_name Name of the function.
  93. * @return The function comment. An empty string if the entity or
  94. * the function don't exist.
  95. */
  96. virtual std::string GetFunctionComment(const std::string& entity_name, const std::string& function_name);
  97. };