1 | /**************************************************************************/ |
2 | /* editor_run_bar.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 | #ifndef EDITOR_RUN_BAR_H |
32 | #define EDITOR_RUN_BAR_H |
33 | |
34 | #include "editor/editor_run.h" |
35 | #include "editor/export/editor_export.h" |
36 | #include "scene/gui/margin_container.h" |
37 | |
38 | class Button; |
39 | class EditorRunNative; |
40 | class EditorQuickOpen; |
41 | class PanelContainer; |
42 | class HBoxContainer; |
43 | |
44 | class EditorRunBar : public MarginContainer { |
45 | GDCLASS(EditorRunBar, MarginContainer); |
46 | |
47 | static EditorRunBar *singleton; |
48 | |
49 | enum RunMode { |
50 | STOPPED = 0, |
51 | RUN_MAIN, |
52 | RUN_CURRENT, |
53 | RUN_CUSTOM, |
54 | }; |
55 | |
56 | PanelContainer *main_panel = nullptr; |
57 | HBoxContainer *main_hbox = nullptr; |
58 | |
59 | Button *play_button = nullptr; |
60 | Button *pause_button = nullptr; |
61 | Button *stop_button = nullptr; |
62 | Button *play_scene_button = nullptr; |
63 | Button *play_custom_scene_button = nullptr; |
64 | |
65 | EditorRun editor_run; |
66 | EditorRunNative *run_native = nullptr; |
67 | |
68 | PanelContainer *write_movie_panel = nullptr; |
69 | Button *write_movie_button = nullptr; |
70 | |
71 | EditorQuickOpen *quick_run = nullptr; |
72 | |
73 | RunMode current_mode = RunMode::STOPPED; |
74 | String run_custom_filename; |
75 | String run_current_filename; |
76 | |
77 | void _reset_play_buttons(); |
78 | void _update_play_buttons(); |
79 | |
80 | void _write_movie_toggled(bool p_enabled); |
81 | void _quick_run_selected(); |
82 | |
83 | void _play_current_pressed(); |
84 | void _play_custom_pressed(); |
85 | |
86 | void _run_scene(const String &p_scene_path = "" ); |
87 | void _run_native(const Ref<EditorExportPreset> &p_preset); |
88 | |
89 | protected: |
90 | void _notification(int p_what); |
91 | static void _bind_methods(); |
92 | |
93 | public: |
94 | static EditorRunBar *get_singleton() { return singleton; } |
95 | |
96 | void play_main_scene(bool p_from_native = false); |
97 | void play_current_scene(bool p_reload = false); |
98 | void play_custom_scene(const String &p_custom); |
99 | |
100 | void stop_playing(); |
101 | bool is_playing() const; |
102 | String get_playing_scene() const; |
103 | |
104 | Error start_native_device(int p_device_id); |
105 | |
106 | OS::ProcessID has_child_process(OS::ProcessID p_pid) const; |
107 | void stop_child_process(OS::ProcessID p_pid); |
108 | |
109 | void set_movie_maker_enabled(bool p_enabled); |
110 | bool is_movie_maker_enabled() const; |
111 | |
112 | Button *get_pause_button() { return pause_button; } |
113 | |
114 | HBoxContainer *get_buttons_container(); |
115 | |
116 | EditorRunBar(); |
117 | }; |
118 | |
119 | #endif // EDITOR_RUN_BAR_H |
120 | |