run_instances_dialog.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 RunInstancesDialog : public AcceptDialog {
  40. GDCLASS(RunInstancesDialog, AcceptDialog);
  41. enum Columns {
  42. COLUMN_OVERRIDE_ARGS,
  43. COLUMN_LAUNCH_ARGUMENTS,
  44. COLUMN_OVERRIDE_FEATURES,
  45. COLUMN_FEATURE_TAGS,
  46. };
  47. struct InstanceData {
  48. TreeItem *item = nullptr;
  49. bool overrides_run_args() const;
  50. String get_launch_arguments() const;
  51. bool overrides_features() const;
  52. String get_feature_tags() const;
  53. };
  54. inline static RunInstancesDialog *singleton = nullptr;
  55. TypedArray<Dictionary> stored_data;
  56. Vector<InstanceData> instances_data;
  57. Timer *main_apply_timer = nullptr;
  58. Timer *instance_apply_timer = nullptr;
  59. LineEdit *main_args_edit = nullptr;
  60. LineEdit *main_features_edit = nullptr;
  61. SpinBox *instance_count = nullptr;
  62. CheckBox *enable_multiple_instances_checkbox = nullptr;
  63. Tree *instance_tree = nullptr;
  64. void _fetch_main_args();
  65. // These 2 methods are necessary due to callable_mp() not supporting default arguments.
  66. void _start_main_timer();
  67. void _start_instance_timer();
  68. void _refresh_argument_count();
  69. void _create_instance(InstanceData &p_instance, const Dictionary &p_data, int p_idx);
  70. void _save_main_args();
  71. void _save_arguments();
  72. // Separates command line arguments without splitting up quoted strings.
  73. Vector<String> _split_cmdline_args(const String &p_arg_string) const;
  74. public:
  75. void popup_dialog();
  76. int get_instance_count() const;
  77. void get_argument_list_for_instance(int p_idx, List<String> &r_list) const;
  78. void apply_custom_features(int p_instance_idx);
  79. static RunInstancesDialog *get_singleton() { return singleton; }
  80. RunInstancesDialog();
  81. };
  82. #endif // RUN_INSTANCES_DIALOG_H