diff --git a/addons/gdfxr/editor/EditSlider.gd b/addons/gdfxr/editor/EditSlider.gd index 5a6adee..a00df37 100644 --- a/addons/gdfxr/editor/EditSlider.gd +++ b/addons/gdfxr/editor/EditSlider.gd @@ -162,9 +162,9 @@ func _drag_motion(motion: InputEventMouseMotion) -> void: var v := factor * (max_value - min_value) + min_value var snap := motion.is_command_or_control_pressed() or motion.shift_pressed if snap and not (is_equal_approx(v, min_value) or is_equal_approx(v, max_value)): - if motion.shift and motion.command: + if motion.shift_pressed and motion.is_command_or_control_pressed(): v = round(v * 1000.0) * 0.001 - elif motion.shift: + elif motion.shift_pressed: v = round(v * 100.0) * 0.01 else: v = round(v * 10.0) * 0.1 @@ -179,7 +179,7 @@ func _show_text_edit() -> void: _line_edit.text = str(value) _line_edit.set_position(gr.position) _line_edit.set_size(gr.size) - _line_edit.show_modal() + _line_edit.show() # FIXME: no suitable solution for `show_modal` yet _line_edit.select_all() _line_edit.grab_focus() _line_edit.focus_next = find_next_valid_focus().get_path() diff --git a/addons/gdfxr/editor/Editor.tscn b/addons/gdfxr/editor/Editor.tscn index 8eeae81..b4e74d8 100644 --- a/addons/gdfxr/editor/Editor.tscn +++ b/addons/gdfxr/editor/Editor.tscn @@ -18,12 +18,10 @@ script = ExtResource("2") [node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."] [node name="Toolbar" type="HBoxContainer" parent="."] -layout_mode = 2 offset_right = 1152.0 offset_bottom = 31.0 [node name="New" type="Button" parent="Toolbar"] -layout_mode = 2 offset_right = 8.0 offset_bottom = 31.0 tooltip_text = "New" @@ -31,7 +29,6 @@ script = ExtResource("1") icon_name = "New" [node name="Load" type="Button" parent="Toolbar"] -layout_mode = 2 offset_left = 12.0 offset_right = 20.0 offset_bottom = 31.0 @@ -40,7 +37,6 @@ script = ExtResource("1") icon_name = "Load" [node name="Save" type="Button" parent="Toolbar"] -layout_mode = 2 offset_left = 24.0 offset_right = 32.0 offset_bottom = 31.0 @@ -49,7 +45,6 @@ script = ExtResource("1") icon_name = "Save" [node name="Extra" type="MenuButton" parent="Toolbar"] -layout_mode = 2 offset_left = 36.0 offset_right = 44.0 offset_bottom = 31.0 @@ -58,13 +53,11 @@ script = ExtResource("1") icon_name = "GuiTabMenuHl" [node name="VSeparator" type="VSeparator" parent="Toolbar"] -layout_mode = 2 offset_left = 48.0 offset_right = 52.0 offset_bottom = 31.0 [node name="Play" type="Button" parent="Toolbar"] -layout_mode = 2 offset_left = 56.0 offset_right = 97.0 offset_bottom = 31.0 @@ -74,7 +67,6 @@ script = ExtResource("1") icon_name = "Play" [node name="Restore" type="Button" parent="Toolbar"] -layout_mode = 2 offset_left = 101.0 offset_right = 169.0 offset_bottom = 31.0 @@ -85,13 +77,11 @@ script = ExtResource("1") icon_name = "Reload" [node name="VSeparator2" type="VSeparator" parent="Toolbar"] -layout_mode = 2 offset_left = 173.0 offset_right = 177.0 offset_bottom = 31.0 [node name="Filename" type="Label" parent="Toolbar"] -layout_mode = 2 offset_left = 181.0 offset_top = 2.0 offset_right = 1148.0 @@ -101,7 +91,6 @@ text = "Unsaved sound" clip_text = true [node name="VersionButton" parent="Toolbar" instance=ExtResource("6")] -layout_mode = 2 offset_left = 1152.0 offset_top = 15.0 offset_right = 1152.0 @@ -109,79 +98,67 @@ offset_bottom = 15.0 website = "https://github.com/timothyqiu/gdfxr" [node name="HSeparator" type="HSeparator" parent="."] -layout_mode = 2 offset_top = 35.0 offset_right = 1152.0 offset_bottom = 39.0 [node name="Editor" type="HBoxContainer" parent="."] -layout_mode = 2 offset_top = 43.0 offset_right = 1152.0 offset_bottom = 648.0 size_flags_vertical = 3 [node name="Generators" type="VBoxContainer" parent="Editor"] -layout_mode = 2 offset_right = 101.0 offset_bottom = 605.0 [node name="Button" type="Button" parent="Editor/Generators"] -layout_mode = 2 offset_right = 101.0 offset_bottom = 31.0 text = "Pickup/Coin" [node name="Button2" type="Button" parent="Editor/Generators"] -layout_mode = 2 offset_top = 35.0 offset_right = 101.0 offset_bottom = 66.0 text = "Laser/Shoot" [node name="Button3" type="Button" parent="Editor/Generators"] -layout_mode = 2 offset_top = 70.0 offset_right = 101.0 offset_bottom = 101.0 text = "Explosion" [node name="Button4" type="Button" parent="Editor/Generators"] -layout_mode = 2 offset_top = 105.0 offset_right = 101.0 offset_bottom = 136.0 text = "Powerup" [node name="Button5" type="Button" parent="Editor/Generators"] -layout_mode = 2 offset_top = 140.0 offset_right = 101.0 offset_bottom = 171.0 text = "Hit/Hurt" [node name="Button6" type="Button" parent="Editor/Generators"] -layout_mode = 2 offset_top = 175.0 offset_right = 101.0 offset_bottom = 206.0 text = "Jump" [node name="Button7" type="Button" parent="Editor/Generators"] -layout_mode = 2 offset_top = 210.0 offset_right = 101.0 offset_bottom = 241.0 text = "Blip/Select" [node name="HSeparator" type="HSeparator" parent="Editor/Generators"] -layout_mode = 2 offset_top = 245.0 offset_right = 101.0 offset_bottom = 249.0 [node name="Button8" type="Button" parent="Editor/Generators"] -layout_mode = 2 offset_top = 253.0 offset_right = 101.0 offset_bottom = 284.0 @@ -189,7 +166,6 @@ size_flags_horizontal = 3 text = "Mutate" [node name="Button9" type="Button" parent="Editor/Generators"] -layout_mode = 2 offset_top = 288.0 offset_right = 101.0 offset_bottom = 319.0 @@ -197,14 +173,12 @@ size_flags_horizontal = 3 text = "Randomize" [node name="ScrollContainer" type="ScrollContainer" parent="Editor"] -layout_mode = 2 offset_left = 105.0 offset_right = 1152.0 offset_bottom = 605.0 size_flags_horizontal = 3 [node name="Params" type="HBoxContainer" parent="Editor/ScrollContainer"] -layout_mode = 2 offset_left = 17.0 offset_top = 182.0 offset_right = 1029.0 @@ -213,19 +187,16 @@ size_flags_horizontal = 6 size_flags_vertical = 6 [node name="Envolope" type="VBoxContainer" parent="Editor/ScrollContainer/Params"] -layout_mode = 2 offset_right = 246.0 offset_bottom = 241.0 [node name="ParamSlider" parent="Editor/ScrollContainer/Params/Envolope" instance=ExtResource("3")] -layout_mode = 2 offset_right = 246.0 offset_bottom = 31.0 label = "Attack Time" parameter = "p_env_attack" [node name="ParamSlider2" parent="Editor/ScrollContainer/Params/Envolope" instance=ExtResource("3")] -layout_mode = 2 offset_top = 35.0 offset_right = 246.0 offset_bottom = 66.0 @@ -233,7 +204,6 @@ label = "Sustain Time" parameter = "p_env_sustain" [node name="ParamSlider3" parent="Editor/ScrollContainer/Params/Envolope" instance=ExtResource("3")] -layout_mode = 2 offset_top = 70.0 offset_right = 246.0 offset_bottom = 101.0 @@ -241,7 +211,6 @@ label = "Sustain Punch" parameter = "p_env_punch" [node name="ParamSlider4" parent="Editor/ScrollContainer/Params/Envolope" instance=ExtResource("3")] -layout_mode = 2 offset_top = 105.0 offset_right = 246.0 offset_bottom = 136.0 @@ -249,7 +218,6 @@ label = "Decay Time" parameter = "p_env_decay" [node name="ParamSlider5" parent="Editor/ScrollContainer/Params/Envolope" instance=ExtResource("3")] -layout_mode = 2 offset_top = 140.0 offset_right = 246.0 offset_bottom = 171.0 @@ -258,7 +226,6 @@ parameter = "p_arp_mod" bipolar = true [node name="ParamSlider6" parent="Editor/ScrollContainer/Params/Envolope" instance=ExtResource("3")] -layout_mode = 2 offset_top = 175.0 offset_right = 246.0 offset_bottom = 206.0 @@ -266,7 +233,6 @@ label = "Change Speed" parameter = "p_arp_speed" [node name="ParamSlider7" parent="Editor/ScrollContainer/Params/Envolope" instance=ExtResource("3")] -layout_mode = 2 offset_top = 210.0 offset_right = 246.0 offset_bottom = 241.0 @@ -274,20 +240,17 @@ label = "Volume" parameter = "sound_vol" [node name="Frequency" type="VBoxContainer" parent="Editor/ScrollContainer/Params"] -layout_mode = 2 offset_left = 250.0 offset_right = 494.0 offset_bottom = 241.0 [node name="ParamSlider" parent="Editor/ScrollContainer/Params/Frequency" instance=ExtResource("3")] -layout_mode = 2 offset_right = 244.0 offset_bottom = 31.0 label = "Start Frequency" parameter = "p_base_freq" [node name="ParamSlider2" parent="Editor/ScrollContainer/Params/Frequency" instance=ExtResource("3")] -layout_mode = 2 offset_top = 35.0 offset_right = 244.0 offset_bottom = 66.0 @@ -295,7 +258,6 @@ label = "Min Frequency" parameter = "p_freq_limit" [node name="ParamSlider3" parent="Editor/ScrollContainer/Params/Frequency" instance=ExtResource("3")] -layout_mode = 2 offset_top = 70.0 offset_right = 244.0 offset_bottom = 101.0 @@ -304,7 +266,6 @@ parameter = "p_freq_ramp" bipolar = true [node name="ParamSlider4" parent="Editor/ScrollContainer/Params/Frequency" instance=ExtResource("3")] -layout_mode = 2 offset_top = 105.0 offset_right = 244.0 offset_bottom = 136.0 @@ -313,7 +274,6 @@ parameter = "p_freq_dramp" bipolar = true [node name="ParamSlider5" parent="Editor/ScrollContainer/Params/Frequency" instance=ExtResource("3")] -layout_mode = 2 offset_top = 140.0 offset_right = 244.0 offset_bottom = 171.0 @@ -321,7 +281,6 @@ label = "Vibrato Depth" parameter = "p_vib_strength" [node name="ParamSlider6" parent="Editor/ScrollContainer/Params/Frequency" instance=ExtResource("3")] -layout_mode = 2 offset_top = 175.0 offset_right = 244.0 offset_bottom = 206.0 @@ -329,7 +288,6 @@ label = "Vibrato Speed" parameter = "p_vib_speed" [node name="ParamSlider7" parent="Editor/ScrollContainer/Params/Frequency" instance=ExtResource("3")] -layout_mode = 2 offset_top = 210.0 offset_right = 244.0 offset_bottom = 241.0 @@ -337,20 +295,17 @@ label = "Repeat Speed" parameter = "p_repeat_speed" [node name="Waveform" type="VBoxContainer" parent="Editor/ScrollContainer/Params"] -layout_mode = 2 offset_left = 498.0 offset_right = 727.0 offset_bottom = 241.0 [node name="WaveformOption" parent="Editor/ScrollContainer/Params/Waveform" instance=ExtResource("4")] -layout_mode = 2 offset_right = 229.0 offset_bottom = 31.0 options = ["Square", "Sawtooth", "Sine", "Noise"] parameter = "wave_type" [node name="ParamSlider" parent="Editor/ScrollContainer/Params/Waveform" instance=ExtResource("3")] -layout_mode = 2 offset_top = 35.0 offset_right = 229.0 offset_bottom = 66.0 @@ -358,7 +313,6 @@ label = "Square Duty" parameter = "p_duty" [node name="ParamSlider2" parent="Editor/ScrollContainer/Params/Waveform" instance=ExtResource("3")] -layout_mode = 2 offset_top = 70.0 offset_right = 229.0 offset_bottom = 101.0 @@ -367,7 +321,6 @@ parameter = "p_duty_ramp" bipolar = true [node name="ParamSlider5" parent="Editor/ScrollContainer/Params/Waveform" instance=ExtResource("3")] -layout_mode = 2 offset_top = 105.0 offset_right = 229.0 offset_bottom = 136.0 @@ -376,7 +329,6 @@ parameter = "p_pha_offset" bipolar = true [node name="ParamSlider3" parent="Editor/ScrollContainer/Params/Waveform" instance=ExtResource("3")] -layout_mode = 2 offset_top = 140.0 offset_right = 229.0 offset_bottom = 171.0 @@ -385,20 +337,17 @@ parameter = "p_pha_ramp" bipolar = true [node name="Filter" type="VBoxContainer" parent="Editor/ScrollContainer/Params"] -layout_mode = 2 offset_left = 731.0 offset_right = 1012.0 offset_bottom = 241.0 [node name="ParamSlider" parent="Editor/ScrollContainer/Params/Filter" instance=ExtResource("3")] -layout_mode = 2 offset_right = 281.0 offset_bottom = 31.0 label = "Low-pass Cutoff" parameter = "p_lpf_freq" [node name="ParamSlider2" parent="Editor/ScrollContainer/Params/Filter" instance=ExtResource("3")] -layout_mode = 2 offset_top = 35.0 offset_right = 281.0 offset_bottom = 66.0 @@ -407,7 +356,6 @@ parameter = "p_lpf_ramp" bipolar = true [node name="ParamSlider5" parent="Editor/ScrollContainer/Params/Filter" instance=ExtResource("3")] -layout_mode = 2 offset_top = 70.0 offset_right = 281.0 offset_bottom = 101.0 @@ -415,7 +363,6 @@ label = "Low-pass Resonance" parameter = "p_lpf_resonance" [node name="ParamSlider3" parent="Editor/ScrollContainer/Params/Filter" instance=ExtResource("3")] -layout_mode = 2 offset_top = 105.0 offset_right = 281.0 offset_bottom = 136.0 @@ -423,7 +370,6 @@ label = "High-pass Cutoff" parameter = "p_hpf_freq" [node name="ParamSlider4" parent="Editor/ScrollContainer/Params/Filter" instance=ExtResource("3")] -layout_mode = 2 offset_top = 140.0 offset_right = 281.0 offset_bottom = 171.0 diff --git a/example/Example.gd b/example/Example.gd new file mode 100644 index 0000000..c8ed340 --- /dev/null +++ b/example/Example.gd @@ -0,0 +1,7 @@ +extends CenterContainer + +func _ready() -> void: + var audio := load("res://example/example.sfxr") as AudioStreamSample + print(audio) + audio.save_to_wav("/home/timothy/Desktop/foo.wav") + $AudioStreamPlayer.stream = audio