Skip to content

Commit

Permalink
Fix node selection, pitch and stretch setup
Browse files Browse the repository at this point in the history
fix: #89 by using `get_pitch_scale` instead of defining a get method for
the `pitch` property.
fix: #80 by changing the way `popochiu_plugin.gd` selects the
WalkToHelper and Baseline nodes.
fix: part of #96 by not overriding the setup made in the project
settings regarding those properties unless the game type is set to
"Pixel".
  • Loading branch information
mapedorr committed Oct 22, 2023
1 parent 1f70d40 commit 4b1317e
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func _play() -> void:
elif not stream_player.stream or\
stream_player.stream.resource_path != audio_cue.audio.resource_path:
stream_player.stream = audio_cue.audio
stream_player.pitch_scale = audio_cue.pitch
stream_player.pitch_scale = audio_cue.get_pitch_scale()
stream_player.volume_db = audio_cue.volume

if stream_player.is_playing():
Expand Down
2 changes: 1 addition & 1 deletion addons/popochiu/editor/main_dock/popochiu_dock.gd
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,6 @@ func _open_settings() -> void:
func _check_node(node: Node) -> void:
if node is PopochiuCharacter and node.get_parent() is Node2D:
# The node is a PopochiuCharacter in a room
node.name = 'Character%s *' % node.script_name
node.set_name.call_deferred('Character%s *' % node.script_name)
# TODO: Show something in the Inspector to alert devs about editing this
# node.
6 changes: 2 additions & 4 deletions addons/popochiu/editor/popups/setup/setup.gd
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ func appear(show_welcome := false) -> void:
_scale_message.text = _get_scale_message()

_game_type.selected = 0

if ProjectSettings.get_setting(PopochiuResources.STRETCH_MODE) == 'canvas_items'\
and ProjectSettings.get_setting(PopochiuResources.STRETCH_ASPECT) == 'keep':
_game_type.selected = 1
Expand Down Expand Up @@ -126,12 +127,9 @@ func _update_project_settings() -> void:
int(_test_height.value)
)

if _game_type.selected != 0:
if _game_type.selected == 1:
ProjectSettings.set_setting(PopochiuResources.STRETCH_MODE, 'canvas_items')
ProjectSettings.set_setting(PopochiuResources.STRETCH_ASPECT, 'keep')
else:
ProjectSettings.set_setting(PopochiuResources.STRETCH_MODE, 'disabled')
ProjectSettings.set_setting(PopochiuResources.STRETCH_ASPECT, 'ignore')

assert(\
ProjectSettings.save() == OK,\
Expand Down
4 changes: 2 additions & 2 deletions addons/popochiu/engine/audio_manager/audio_cue.gd
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class_name PopochiuAudioCue
@export var audio: AudioStream
@export var loop := false : set = set_loop
@export var is_2d := false
@export var pitch := 0.0 : get = get_pitch
@export var pitch := 1.0
@export var volume := 0.0
@export var rnd_pitch := Vector2.ZERO
@export var rnd_volume := Vector2.ZERO
Expand Down Expand Up @@ -102,7 +102,7 @@ func set_loop(value: bool) -> void:

# Returns the `pitch_scale` to apply to the audio stream player that will play
# the audio of this audio cue.
func get_pitch() -> float:
func get_pitch_scale() -> float:
var p := A.semitone_to_pitch(pitch)

if rnd_pitch != Vector2.ZERO:
Expand Down
4 changes: 2 additions & 2 deletions addons/popochiu/engine/audio_manager/audio_manager.gd
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ func _play(
return null

(player as AudioStreamPlayer2D).stream = cue.audio
(player as AudioStreamPlayer2D).pitch_scale = cue.pitch
(player as AudioStreamPlayer2D).pitch_scale = cue.get_pitch_scale()
(player as AudioStreamPlayer2D).volume_db = cue.volume
(player as AudioStreamPlayer2D).max_distance = cue.max_distance
(player as AudioStreamPlayer2D).position = position
Expand All @@ -219,7 +219,7 @@ func _play(
return null

(player as AudioStreamPlayer).stream = cue.audio
(player as AudioStreamPlayer).pitch_scale = cue.pitch
(player as AudioStreamPlayer).pitch_scale = cue.get_pitch_scale()
(player as AudioStreamPlayer).volume_db = cue.volume

var cue_name: String = cue.resource_name
Expand Down
20 changes: 16 additions & 4 deletions addons/popochiu/popochiu_plugin.gd
Original file line number Diff line number Diff line change
Expand Up @@ -391,23 +391,35 @@ func _select_walk_to() -> void:
_btn_baseline.set_pressed_no_signal(false)
_vsep.hide()

_editor_interface.get_selection().clear()

if _types_helper.is_prop(_selected_node)\
or _types_helper.is_hotspot(_selected_node):
_editor_interface.edit_node(_selected_node.get_node('WalkToHelper'))
_editor_interface.get_selection().add_node(
_selected_node.get_node("WalkToHelper")
)
else:
_editor_interface.edit_node(_selected_node.get_node('../WalkToHelper'))
_editor_interface.get_selection().add_node(
_selected_node.get_node("../WalkToHelper")
)


func _select_baseline() -> void:
_btn_baseline.set_pressed_no_signal(true)
_btn_walk_to.set_pressed_no_signal(false)
_vsep.show()

_editor_interface.get_selection().clear()

if _types_helper.is_prop(_selected_node)\
or _types_helper.is_hotspot(_selected_node):
_editor_interface.edit_node(_selected_node.get_node('BaselineHelper'))
_editor_interface.get_selection().add_node(
_selected_node.get_node("BaselineHelper")
)
else:
_editor_interface.edit_node(_selected_node.get_node('../BaselineHelper'))
_editor_interface.get_selection().add_node(
_selected_node.get_node("../BaselineHelper")
)


func _move_to_project(id: int) -> void:
Expand Down
2 changes: 2 additions & 0 deletions popochiu/rooms/house/props/toy_car/prop_toy_car.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ description = "Toy Car"
cursor = 1

[node name="BaselineHelper" type="Line2D" parent="."]
visible = false
points = PackedVector2Array(-10000, 0, 10000, 0)
width = 1.0

[node name="WalkToHelper" type="Marker2D" parent="."]
visible = false

[node name="ColorRect" type="ColorRect" parent="WalkToHelper"]
offset_left = -2.5
Expand Down
1 change: 1 addition & 0 deletions popochiu/rooms/house/room_house.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ position = Vector2(109, 112)

[node name="CharacterPopsy *" parent="Characters" instance=ExtResource("10_cxlhm")]
position = Vector2(221, 128)
popochiu_placeholder = null

[node name="Character01 *" parent="Characters" instance=ExtResource("10_pnj5o")]
position = Vector2(172, 156)
1 change: 1 addition & 0 deletions project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ window/size/viewport_height=180
window/size/window_width_override=640
window/size/window_height_override=360
window/stretch/mode="canvas_items"
window/stretch/aspect="expand"

[editor_plugins]

Expand Down

0 comments on commit 4b1317e

Please sign in to comment.