| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
#pragma once |
| 32 |
|
| 33 |
#include "editor/plugins/editor_plugin.h" |
| 34 |
#include "scene/audio/audio_stream_player.h" |
| 35 |
#include "scene/gui/color_rect.h" |
| 36 |
#include "scene/gui/dialogs.h" |
| 37 |
#include "scene/gui/spin_box.h" |
| 38 |
|
| 39 |
class CheckBox; |
| 40 |
|
| 41 |
class AudioStreamImportSettingsDialog : public ConfirmationDialog { |
| 42 |
GDCLASS(AudioStreamImportSettingsDialog, ConfirmationDialog); |
| 43 |
|
| 44 |
CheckBox *bpm_enabled = nullptr; |
| 45 |
SpinBox *bpm_edit = nullptr; |
| 46 |
CheckBox *beats_enabled = nullptr; |
| 47 |
SpinBox *beats_edit = nullptr; |
| 48 |
Label *bar_beats_label = nullptr; |
| 49 |
SpinBox *bar_beats_edit = nullptr; |
| 50 |
CheckBox *loop = nullptr; |
| 51 |
SpinBox *loop_offset = nullptr; |
| 52 |
ColorRect *color_rect = nullptr; |
| 53 |
Ref<AudioStream> stream; |
| 54 |
AudioStreamPlayer *_player = nullptr; |
| 55 |
ColorRect *_preview = nullptr; |
| 56 |
Control *_indicator = nullptr; |
| 57 |
Label *_current_label = nullptr; |
| 58 |
Label *_duration_label = nullptr; |
| 59 |
|
| 60 |
HScrollBar *zoom_bar = nullptr; |
| 61 |
Button *zoom_in = nullptr; |
| 62 |
Button *zoom_reset = nullptr; |
| 63 |
Button *zoom_out = nullptr; |
| 64 |
|
| 65 |
Button *_play_button = nullptr; |
| 66 |
Button *_stop_button = nullptr; |
| 67 |
|
| 68 |
bool updating_settings = false; |
| 69 |
|
| 70 |
float _current = 0; |
| 71 |
bool _dragging = false; |
| 72 |
bool _beat_len_dragging = false; |
| 73 |
bool _pausing = false; |
| 74 |
int _hovering_beat = -1; |
| 75 |
|
| 76 |
HashMap<StringName, Variant> params; |
| 77 |
String importer; |
| 78 |
String path; |
| 79 |
|
| 80 |
struct MasterState { |
| 81 |
bool mute = false; |
| 82 |
bool bypass = false; |
| 83 |
float volume = 0; |
| 84 |
} master_state; |
| 85 |
|
| 86 |
void _reset_master(); |
| 87 |
void _load_master_state(); |
| 88 |
|
| 89 |
void _audio_changed(); |
| 90 |
|
| 91 |
static AudioStreamImportSettingsDialog *singleton; |
| 92 |
|
| 93 |
void _settings_changed(); |
| 94 |
|
| 95 |
void _reimport(); |
| 96 |
|
| 97 |
protected: |
| 98 |
void _notification(int p_what); |
| 99 |
void _preview_changed(ObjectID p_which); |
| 100 |
void _preview_zoom_in(); |
| 101 |
void _preview_zoom_out(); |
| 102 |
void _preview_zoom_reset(); |
| 103 |
void _preview_zoom_offset_changed(double); |
| 104 |
|
| 105 |
void _play(); |
| 106 |
void _stop(); |
| 107 |
void _on_finished(); |
| 108 |
void _draw_preview(); |
| 109 |
void _draw_indicator(); |
| 110 |
void _on_input_indicator(Ref<InputEvent> p_event); |
| 111 |
void _seek_to(real_t p_x); |
| 112 |
void _set_beat_len_to(real_t p_x); |
| 113 |
void _on_indicator_mouse_exited(); |
| 114 |
int _get_beat_at_pos(real_t p_x); |
| 115 |
|
| 116 |
public: |
| 117 |
void edit(const String &p_path, const String &p_importer, const Ref<AudioStream> &p_stream); |
| 118 |
|
| 119 |
static AudioStreamImportSettingsDialog *get_singleton() { return singleton; } |
| 120 |
|
| 121 |
AudioStreamImportSettingsDialog(); |
| 122 |
}; |