run_instances_dialog.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /**************************************************************************/
  2. /* run_instances_dialog.h */
  3. /**************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /**************************************************************************/
  8. /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
  9. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /**************************************************************************/
  30. #ifndef RUN_INSTANCES_DIALOG_H
  31. #define RUN_INSTANCES_DIALOG_H
  32. #include "scene/gui/dialogs.h"
  33. class CheckBox;
  34. class LineEdit;
  35. class SpinBox;
  36. class Timer;
  37. class Tree;
  38. class TreeItem;
  39. class PopupMenu;
  40. class RunInstancesDialog : public AcceptDialog {
  41. GDCLASS(RunInstancesDialog, AcceptDialog);
  42. enum Columns {
  43. COLUMN_OVERRIDE_ARGS,
  44. COLUMN_LAUNCH_ARGUMENTS,
  45. COLUMN_OVERRIDE_FEATURES,
  46. COLUMN_FEATURE_TAGS,
  47. };
  48. struct InstanceData {
  49. TreeItem *item = nullptr;
  50. bool overrides_run_args() const;
  51. String get_launch_arguments() const;
  52. bool overrides_features() const;
  53. String get_feature_tags() const;
  54. };
  55. // Right-click popup menu.
  56. enum {
  57. CLEAR_ITEM,
  58. CLEAR_ALL,
  59. };
  60. inline static RunInstancesDialog *singleton = nullptr;
  61. TypedArray<Dictionary> stored_data;
  62. Vector<InstanceData> instances_data;
  63. Timer *main_apply_timer = nullptr;
  64. Timer *instance_apply_timer = nullptr;
  65. LineEdit *main_args_edit = nullptr;
  66. LineEdit *main_features_edit = nullptr;
  67. SpinBox *instance_count = nullptr;
  68. CheckBox *enable_multiple_instances_checkbox = nullptr;
  69. Tree *instance_tree = nullptr;
  70. PopupMenu *popup_menu = nullptr;
  71. void _fetch_main_args();
  72. // These 2 methods are necessary due to callable_mp() not supporting default arguments.
  73. void _start_main_timer();
  74. void _start_instance_timer();
  75. void _refresh_argument_count();
  76. void _create_instance(InstanceData &p_instance, const Dictionary &p_data, int p_idx);
  77. void _save_main_args();
  78. void _save_arguments();
  79. // Separates command line arguments without splitting up quoted strings.
  80. Vector<String> _split_cmdline_args(const String &p_arg_string) const;
  81. void _instance_menu_id_pressed(int p_option);
  82. void _instance_tree_rmb(const Vector2 &p_pos, MouseButton p_button);
  83. public:
  84. void popup_dialog();
  85. int get_instance_count() const;
  86. void get_argument_list_for_instance(int p_idx, List<String> &r_list) const;
  87. void apply_custom_features(int p_instance_idx);
  88. static RunInstancesDialog *get_singleton() { return singleton; }
  89. RunInstancesDialog();
  90. };
  91. #endif // RUN_INSTANCES_DIALOG_H