This commit is contained in:
Ian 2024-10-22 11:27:29 -04:00 committed by GitHub
commit 1cd8579e31
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 390 additions and 227 deletions

1
.gitignore vendored
View file

@ -3,3 +3,4 @@
.export/
.itchio/
.steam/
.DS_Store

View file

@ -1,2 +1,2 @@
This is a Godot 4.1.2 stable project. Not sure if everything will work in future version.
This code is very bad so be warned this is a SLOP project
This is a Godot 4.2.2 stable project. Not sure if everything will work in future version.
This code is very ~~bad~~ good and cool so be warned this is a SLOP (Seriously Loved Outstanding Project) project

View file

@ -40,6 +40,9 @@ var volumeSensitivity = 0.0
var volumeLimit = 0.0
var senseLimit = 0.0
# Midi
var currentMidiDevices = []
#Speak Signals
signal startSpeaking
signal stopSpeaking

View file

@ -4,41 +4,17 @@ var key = "creature"
var data = {}
var default = {
"0": {
"drag": 0,
"identification": 930245150,
"offset": "Vector2(0, 0)",
"parentId": null,
"path": "user://defaultAvatar/body.png",
"pos": "Vector2(0, 0)",
"rotDrag": 0,
"showBlink": 0,
"showTalk": 0,
"type": "sprite",
"xAmp": 9,
"xFrq": 0.002,
"yAmp": 11,
"yFrq": 0.004,
"zindex": -1 },
"1": {
"drag": 1,
"identification": 456157398,
"offset": "Vector2(0, 0)",
"parentId": 930245150,
"path": "user://defaultAvatar/head.png",
"pos": "Vector2(0, 0)",
"rotDrag": 0,
"showBlink": 0,
"showTalk": 0,
"type": "sprite",
"xAmp": 0,
"xFrq": 0,
"yAmp": 0,
"yFrq": 0,
"zindex": 0 },
"2": { "drag": 4, "identification": 928082759, "offset": "Vector2(0, 0)", "parentId": 456157398, "path": "user://defaultAvatar/hair.png", "pos": "Vector2(0, 0)", "rotDrag": 0, "showBlink": 0, "showTalk": 0, "type": "sprite", "xAmp": 0, "xFrq": 0, "yAmp": 0, "yFrq": 0, "zindex": -2 }, "3": { "drag": 0, "identification": 346749260, "offset": "Vector2(0, 0)", "parentId": 456157398, "path": "user://defaultAvatar/mouth1.png", "pos": "Vector2(0, 0)", "rotDrag": 0, "showBlink": 0, "showTalk": 1, "type": "sprite", "xAmp": 0, "xFrq": 0, "yAmp": 0, "yFrq": 0, "zindex": 0 }, "4": { "drag": 0, "identification": 348929106, "offset": "Vector2(0, 0)", "parentId": 456157398, "path": "user://defaultAvatar/mouth2.png", "pos": "Vector2(0, 0)", "rotDrag": 0, "showBlink": 0, "showTalk": 2, "type": "sprite", "xAmp": 0, "xFrq": 0, "yAmp": 0, "yFrq": 0, "zindex": 0 }, "5": { "drag": 0, "identification": 66364456, "offset": "Vector2(0, 0)", "parentId": 456157398, "path": "user://defaultAvatar/eye1.png", "pos": "Vector2(0, 0)", "rotDrag": 0, "showBlink": 1, "showTalk": 2, "type": "sprite", "xAmp": 0, "xFrq": 0, "yAmp": 0, "yFrq": 0, "zindex": 0 }, "6": { "drag": 0, "identification": 261040117, "offset": "Vector2(0, 0)", "parentId": 456157398, "path": "user://defaultAvatar/eye2.png", "pos": "Vector2(0, 0)", "rotDrag": 0, "showBlink": 1, "showTalk": 1, "type": "sprite", "xAmp": 0, "xFrq": 0, "yAmp": 0, "yFrq": 0, "zindex": 0 }, "7": { "drag": 0, "identification": 291459997, "offset": "Vector2(0, 0)", "parentId": 456157398, "path": "user://defaultAvatar/eye3.png", "pos": "Vector2(0, 0)", "rotDrag": 0, "showBlink": 2, "showTalk": 0, "type": "sprite", "xAmp": 0, "xFrq": 0, "yAmp": 0, "yFrq": 0, "zindex": 0 }, "8": { "drag": 0, "identification": 148065686, "offset": "Vector2(-74, 92)", "parentId": 456157398, "path": "user://defaultAvatar/hat.png", "pos": "Vector2(72, -89)", "rotDrag": -2, "showBlink": 0, "showTalk": 0, "type": "sprite", "xAmp": 0, "xFrq": 0, "yAmp": 0, "yFrq": 0, "zindex": 2 } }
var default = {
"0": { "drag": 0, "identification": 930245150, "offset": "Vector2(0, 0)", "parentId": null, "path": "user://defaultAvatar/body.png", "pos": "Vector2(0, 0)", "rotDrag": 0, "showBlink": 0, "showTalk": 0, "type": "sprite", "useMidiWobble": false, "xAmp": 9, "xFrq": 0.002, "yAmp": 11, "yFrq": 0.004, "zindex": -1 },
"1": { "drag": 1, "identification": 456157398, "offset": "Vector2(0, 0)", "parentId": 930245150, "path": "user://defaultAvatar/head.png", "pos": "Vector2(0, 0)", "rotDrag": 0, "showBlink": 0, "showTalk": 0, "type": "sprite", "useMidiWobble": false, "xAmp": 0, "xFrq": 0, "yAmp": 0, "yFrq": 0, "zindex": 0 },
"2": { "drag": 4, "identification": 928082759, "offset": "Vector2(0, 0)", "parentId": 456157398, "path": "user://defaultAvatar/hair.png", "pos": "Vector2(0, 0)", "rotDrag": 0, "showBlink": 0, "showTalk": 0, "type": "sprite", "useMidiWobble": false, "xAmp": 0, "xFrq": 0, "yAmp": 0, "yFrq": 0, "zindex": -2 },
"3": { "drag": 0, "identification": 346749260, "offset": "Vector2(0, 0)", "parentId": 456157398, "path": "user://defaultAvatar/mouth1.png", "pos": "Vector2(0, 0)", "rotDrag": 0, "showBlink": 0, "showTalk": 1, "type": "sprite", "useMidiWobble": false, "xAmp": 0, "xFrq": 0, "yAmp": 0, "yFrq": 0, "zindex": 0 },
"4": { "drag": 0, "identification": 348929106, "offset": "Vector2(0, 0)", "parentId": 456157398, "path": "user://defaultAvatar/mouth2.png", "pos": "Vector2(0, 0)", "rotDrag": 0, "showBlink": 0, "showTalk": 2, "type": "sprite", "useMidiWobble": false, "xAmp": 0, "xFrq": 0, "yAmp": 0, "yFrq": 0, "zindex": 0 },
"5": { "drag": 0, "identification": 66364456, "offset": "Vector2(0, 0)", "parentId": 456157398, "path": "user://defaultAvatar/eye1.png", "pos": "Vector2(0, 0)", "rotDrag": 0, "showBlink": 1, "showTalk": 2, "type": "sprite", "useMidiWobble": false, "xAmp": 0, "xFrq": 0, "yAmp": 0, "yFrq": 0, "zindex": 0 },
"6": { "drag": 0, "identification": 261040117, "offset": "Vector2(0, 0)", "parentId": 456157398, "path": "user://defaultAvatar/eye2.png", "pos": "Vector2(0, 0)", "rotDrag": 0, "showBlink": 1, "showTalk": 1, "type": "sprite", "useMidiWobble": false, "xAmp": 0, "xFrq": 0, "yAmp": 0, "yFrq": 0, "zindex": 0 },
"7": { "drag": 0, "identification": 291459997, "offset": "Vector2(0, 0)", "parentId": 456157398, "path": "user://defaultAvatar/eye3.png", "pos": "Vector2(0, 0)", "rotDrag": 0, "showBlink": 2, "showTalk": 0, "type": "sprite", "useMidiWobble": false, "xAmp": 0, "xFrq": 0, "yAmp": 0, "yFrq": 0, "zindex": 0 },
"8": { "drag": 0, "identification": 148065686, "offset": "Vector2(-74, 92)", "parentId": 456157398, "path": "user://defaultAvatar/hat.png", "pos": "Vector2(72, -89)", "rotDrag": -2, "showBlink": 0, "showTalk": 0, "type": "sprite", "useMidiWobble": false, "xAmp": 0, "xFrq": 0, "yAmp": 0, "yFrq": 0, "zindex": 2 }
}
var settings = {
"newUser":true,

View file

@ -0,0 +1,40 @@
extends MenuButton
var popup = self.get_popup()
var available_devices = []
func _ready():
popup.hide_on_checkable_item_selection = false
popup.connect("index_pressed", toggle_checked)
available_devices = OS.get_connected_midi_inputs()
Global.currentMidiDevices = available_devices # Listen to all devices by default
func _on_about_to_popup():
popup.clear(true)
available_devices = OS.get_connected_midi_inputs() # update every open
for i in range(len(available_devices)):
popup.add_check_item(available_devices[i])
var already_checked = available_devices[i] in Global.currentMidiDevices
popup.set_item_checked(i, already_checked)
update_checked_items()
func toggle_checked(index: int):
popup.set_item_checked(index, not popup.is_item_checked(index))
update_checked_items()
func update_checked_items():
var checked_items = []
for i in range(popup.get_item_count()):
if popup.is_item_checked(i):
checked_items.append(popup.get_item_text(i))
Global.currentMidiDevices = checked_items

View file

@ -63,6 +63,9 @@ func _ready():
Global.connect("startSpeaking",onSpeak)
ElgatoStreamDeck.on_key_down.connect(changeCostumeStreamDeck)
OS.open_midi_inputs()
Global.currentMidiDevices = OS.get_connected_midi_inputs()
if Saving.settings["newUser"]:
_on_load_dialog_file_selected("default")
@ -318,6 +321,7 @@ func _on_load_dialog_file_selected(path):
sprite.offset = str_to_var(data[item]["offset"])
sprite.z = data[item]["zindex"]
sprite.dragSpeed = data[item]["drag"]
sprite.useMidiWobble = data[item]["useMidiWobble"] if data[item].has("useMidiWobble") else false
sprite.xFrq = data[item]["xFrq"]
sprite.xAmp = data[item]["xAmp"]
@ -389,6 +393,7 @@ func _on_save_dialog_file_selected(path):
data[id]["drag"] = child.dragSpeed
data[id]["useMidiWobble"] = child.useMidiWobble
data[id]["xFrq"] = child.xFrq
data[id]["xAmp"] = child.xAmp
data[id]["yFrq"] = child.yFrq
@ -535,7 +540,7 @@ func moveSpriteMenu(delta):
var size = get_viewport().get_visible_rect().size
var windowLength = 1250 #1187
var windowLength = 1275 #1187
$ViewerArrows/Arrows.position.y = size.y - 25

File diff suppressed because one or more lines are too long

4
midi.svg Normal file
View file

@ -0,0 +1,4 @@
<svg height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg" fill="white">
<path
d="m12 2a10 10 0 0 1 10 10 10 10 0 0 1 -10 10 10 10 0 0 1 -10-10 10 10 0 0 1 10-10m8.18 10c0-3.82-2.63-7.04-6.18-7.93v1.93h-4v-1.93c-3.55.89-6.18 4.11-6.18 7.93a8.18 8.18 0 0 0 8.18 8.18 8.18 8.18 0 0 0 8.18-8.18m-13.18-1.36a1.36 1.36 0 0 1 1.36 1.36 1.36 1.36 0 0 1 -1.36 1.36c-.75 0-1.36-.61-1.36-1.36s.61-1.36 1.36-1.36m10 0a1.36 1.36 0 0 1 1.36 1.36 1.36 1.36 0 0 1 -1.36 1.36 1.36 1.36 0 0 1 -1.36-1.36 1.36 1.36 0 0 1 1.36-1.36m-8.64 3.63a1.37 1.37 0 0 1 1.37 1.37c0 .75-.61 1.36-1.37 1.36a1.36 1.36 0 0 1 -1.36-1.36c0-.76.61-1.37 1.36-1.37m7.28 0c.75 0 1.36.61 1.36 1.37a1.36 1.36 0 0 1 -1.36 1.36c-.76 0-1.37-.61-1.37-1.36a1.37 1.37 0 0 1 1.37-1.37m-3.64 1.37a1.36 1.36 0 0 1 1.36 1.36 1.36 1.36 0 0 1 -1.36 1.36 1.36 1.36 0 0 1 -1.36-1.36 1.36 1.36 0 0 1 1.36-1.36z" />
</svg>

After

Width:  |  Height:  |  Size: 891 B

37
midi.svg.import Normal file
View file

@ -0,0 +1,37 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cauhghrw3sv2r"
path="res://.godot/imported/midi.svg-c263547cda7da4e037f0b6bf02e57d99.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://midi.svg"
dest_files=["res://.godot/imported/midi.svg-c263547cda7da4e037f0b6bf02e57d99.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false

View file

@ -12,7 +12,7 @@ config_version=5
config/name="PNGTuberPlus"
run/main_scene="res://main_scenes/main.tscn"
config/features=PackedStringArray("4.1", "GL Compatibility")
config/features=PackedStringArray("4.2", "GL Compatibility")
run/max_fps=60
boot_splash/bg_color=Color(0.0313726, 0.0313726, 0.0313726, 1)
boot_splash/image="res://splash.png"
@ -23,6 +23,7 @@ config/icon="res://icon.png"
[audio]
driver/enable_input=true
driver/mix_rate=48000
[autoload]

View file

@ -49,6 +49,7 @@ var origTick = 0
var offset = Vector2.ZERO
#Wobble
var useMidiWobble = false
var xFrq = 0.0
var xAmp = 0.0
@ -163,6 +164,20 @@ func _ready():
if Global.filtering:
sprite.texture_filter = 2
func _input(event):
if not self.useMidiWobble or not event is InputEventMIDI:
return
var device = OS.get_connected_midi_inputs()[event.device]
if device in Global.currentMidiDevices:
match event.message:
MIDIMessage.MIDI_MESSAGE_START:
tick = 0
MIDIMessage.MIDI_MESSAGE_STOP:
tick = 0
MIDIMessage.MIDI_MESSAGE_TIMING_CLOCK:
tick += 1
func replaceSprite(pathNew):
var img = Image.new()
var err = img.load(pathNew)
@ -213,7 +228,9 @@ func replaceSprite(pathNew):
remakePolygon()
func _process(delta):
tick += 1
if not self.useMidiWobble:
tick += 1
if Global.heldSprite == self:
grabArea.visible = true
@ -323,9 +340,25 @@ func drag(delta):
dragger.global_position = lerp(dragger.global_position,wob.global_position,1/dragSpeed)
dragOrigin.global_position = dragger.global_position
func wobble():
wob.position.x = sin(tick*xFrq)*xAmp
wob.position.y = sin(tick*yFrq)*yAmp
if self.useMidiWobble:
midi_wobble()
else:
free_wobble()
func free_wobble():
wob.position.x = sin(tick * xFrq) * xAmp
wob.position.y = sin(tick * yFrq) * yAmp
func midi_wobble():
var ppqn = 24
var progress = float(tick) / ppqn
var rads = progress * 2 * PI
wob.position.x = cos(rads * xFrq * 10) * xAmp
wob.position.y = cos(rads * yFrq * 10) * yAmp
func rotationalDrag(length,delta):
var yvel = (length * rdragStr)
@ -374,8 +407,8 @@ func remakePolygon():
remadePolygon = true
func setClip(toggle):
if toggle:
func setClip(should_clip):
if should_clip:
sprite.clip_children = CLIP_CHILDREN_AND_DRAW
for node in getAllLinkedSprites():
@ -385,7 +418,7 @@ func setClip(toggle):
else:
sprite.clip_children = CLIP_CHILDREN_DISABLED
clipped = toggle
clipped = should_clip
func getAllLinkedSprites():
var nodes = get_tree().get_nodes_in_group("saved")

View file

@ -29,14 +29,15 @@ func setImage():
$Slider/Label.text = "drag: " + str(Global.heldSprite.dragSpeed)
$Slider/DragSlider.value = Global.heldSprite.dragSpeed
$WobbleControl/xFrqLabel.text = "x frequency: " + str(Global.heldSprite.xFrq)
$WobbleControl/UseMidi.button_pressed = Global.heldSprite.useMidiWobble
$WobbleControl/xFrqLabel.text = "x frequency: " + get_scaled_frequency(Global.heldSprite.xFrq)
$WobbleControl/xAmpLabel.text = "x amplitude: " + str(Global.heldSprite.xAmp)
$WobbleControl/xFrq.value = Global.heldSprite.xFrq
$WobbleControl/xAmp.value = Global.heldSprite.xAmp
$WobbleControl/yFrqLabel.text = "y frequency: " + str(Global.heldSprite.yFrq)
$WobbleControl/yFrqLabel.text = "y frequency: " + get_scaled_frequency(Global.heldSprite.yFrq)
$WobbleControl/yAmpLabel.text = "y amplitude: " + str(Global.heldSprite.yAmp)
$WobbleControl/yFrq.value = Global.heldSprite.yFrq
@ -120,9 +121,34 @@ func _on_drag_slider_value_changed(value):
Global.heldSprite.dragSpeed = value
func _on_use_midi_toggled(value: bool):
Global.heldSprite.useMidiWobble = value
# Update label text
_on_x_frq_value_changed(Global.heldSprite.xFrq)
_on_y_frq_value_changed(Global.heldSprite.yFrq)
func get_scaled_frequency(value):
if Global.heldSprite.useMidiWobble:
return str(value * 1000) + "% BPM"
else:
return str(value)
# Create a 10 unit detant every 25 units
const DEAD_ZONE = 10
const SCALE_FACTOR = 1000.0
func snap_slider_to_detant(value):
var scaled_value = int(value * SCALE_FACTOR) # I guess you can only mod ints in gdscript?
var distance = scaled_value % 25
if distance > DEAD_ZONE: return value
return (scaled_value - distance) / SCALE_FACTOR
func _on_x_frq_value_changed(value):
$WobbleControl/xFrqLabel.text = "x frequency: " + str(value)
Global.heldSprite.xFrq = value
var snapped_value = snap_slider_to_detant(value) if Global.heldSprite.useMidiWobble else value
$WobbleControl/xFrqLabel.text = "x frequency: " + get_scaled_frequency(snapped_value)
Global.heldSprite.xFrq = snapped_value
func _on_x_amp_value_changed(value):
@ -131,8 +157,9 @@ func _on_x_amp_value_changed(value):
func _on_y_frq_value_changed(value):
$WobbleControl/yFrqLabel.text = "y frequency: " + str(value)
Global.heldSprite.yFrq = value
var snapped_value = snap_slider_to_detant(value) if Global.heldSprite.useMidiWobble else value
$WobbleControl/yFrqLabel.text = "y frequency: " + get_scaled_frequency(snapped_value)
Global.heldSprite.yFrq = snapped_value
func _on_y_amp_value_changed(value):
$WobbleControl/yAmpLabel.text = "y amplitude: " + str(value)

File diff suppressed because one or more lines are too long