Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/editor/run/run_instances_dialog.h
9896 views
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
31
#pragma once
32
33
#include "scene/gui/dialogs.h"
34
35
class CheckBox;
36
class LineEdit;
37
class SpinBox;
38
class Timer;
39
class Tree;
40
class TreeItem;
41
class PopupMenu;
42
43
class RunInstancesDialog : public AcceptDialog {
44
GDCLASS(RunInstancesDialog, AcceptDialog);
45
46
enum Columns {
47
COLUMN_OVERRIDE_ARGS,
48
COLUMN_LAUNCH_ARGUMENTS,
49
COLUMN_OVERRIDE_FEATURES,
50
COLUMN_FEATURE_TAGS,
51
};
52
53
struct InstanceData {
54
TreeItem *item = nullptr;
55
56
bool overrides_run_args() const;
57
String get_launch_arguments() const;
58
bool overrides_features() const;
59
String get_feature_tags() const;
60
};
61
62
// Right-click popup menu.
63
enum {
64
CLEAR_ITEM,
65
CLEAR_ALL,
66
};
67
68
inline static RunInstancesDialog *singleton = nullptr;
69
70
TypedArray<Dictionary> stored_data;
71
Vector<InstanceData> instances_data;
72
73
Timer *main_apply_timer = nullptr;
74
Timer *instance_apply_timer = nullptr;
75
76
LineEdit *main_args_edit = nullptr;
77
LineEdit *main_features_edit = nullptr;
78
SpinBox *instance_count = nullptr;
79
CheckBox *enable_multiple_instances_checkbox = nullptr;
80
Tree *instance_tree = nullptr;
81
PopupMenu *popup_menu = nullptr;
82
83
void _fetch_main_args();
84
// These 2 methods are necessary due to callable_mp() not supporting default arguments.
85
void _start_main_timer();
86
void _start_instance_timer();
87
88
void _refresh_argument_count();
89
void _create_instance(InstanceData &p_instance, const Dictionary &p_data, int p_idx);
90
void _save_main_args();
91
void _save_arguments();
92
// Separates command line arguments without splitting up quoted strings.
93
Vector<String> _split_cmdline_args(const String &p_arg_string) const;
94
void _instance_menu_id_pressed(int p_option);
95
void _instance_tree_rmb(const Vector2 &p_pos, MouseButton p_button);
96
97
public:
98
void popup_dialog();
99
int get_instance_count() const;
100
void get_argument_list_for_instance(int p_idx, List<String> &r_list) const;
101
void apply_custom_features(int p_instance_idx);
102
103
static RunInstancesDialog *get_singleton() { return singleton; }
104
RunInstancesDialog();
105
};
106
107