Add checkbox for midi wobble.

This commit is contained in:
iandoesallthethings 2024-05-06 22:31:31 -04:00
parent ab9dfe47cb
commit 67eb441484
7 changed files with 586 additions and 392 deletions

View file

@ -50,6 +50,7 @@ var updatePusherNode = null
var rand = RandomNumberGenerator.new()
func _ready():
spectrum = AudioServer.get_bus_effect_instance(1, 1)
@ -63,6 +64,7 @@ func _ready():
createMicrophone()
func createMicrophone():
var playa = AudioStreamPlayer.new()
var mic = AudioStreamMicrophone.new()
@ -79,6 +81,7 @@ func createMicrophone():
await get_tree().create_timer(0.25).timeout
createMicrophone()
func deleteAllMics():
for child in get_children():
child.queue_free()
@ -127,13 +130,10 @@ func _process(delta):
else:
RenderingServer.set_default_clear_color(Color.GRAY)
blinking()
scrollSprites()
if !main.fileSystemOpen:
if Input.is_action_just_pressed("refresh"):
refresh()
if Input.is_action_just_pressed("unlink"):
@ -145,7 +145,6 @@ func _process(delta):
func select(areas):
if main.fileSystemOpen:
return
@ -173,7 +172,7 @@ func select(areas):
var count = heldSprite.path.get_slice_count("/") - 1
var i1 = heldSprite.path.get_slice("/", count)
pushUpdate("Selected sprite \"" + i1 + "\"" + ".")
pushUpdate('Selected sprite "' + i1 + '"' + ".")
heldSprite.set_physics_process(true)
@ -191,6 +190,7 @@ func select(areas):
spriteEdit.setImage()
func linkSprite(sprite, newParent):
if sprite == newParent:
reparentMode = false
@ -220,11 +220,11 @@ func linkSprite(sprite,newParent):
count = newParent.path.get_slice_count("/") - 1
var i2 = newParent.path.get_slice("/", count)
pushUpdate("Linked sprite \"" + i1 + "\" to sprite \"" + i2 + "\".")
pushUpdate('Linked sprite "' + i1 + '" to sprite "' + i2 + '".')
newParent.set_physics_process(true)
func scrollSprites():
func scrollSprites():
if Input.is_action_pressed("control"):
return
@ -251,7 +251,6 @@ func scrollSprites():
if scroll == 0:
return
var obj = get_tree().get_nodes_in_group("saved")
if obj.size() <= 0:
@ -267,12 +266,13 @@ func scrollSprites():
var count = heldSprite.path.get_slice_count("/") - 1
var i1 = heldSprite.path.get_slice("/", count)
pushUpdate("Selected sprite \"" + i1 + "\"" + ".")
pushUpdate('Selected sprite "' + i1 + '"' + ".")
heldSprite.set_physics_process(true)
spriteEdit.setImage()
func blinking():
blinkTick += 1
if blinkTick == 0:
@ -285,6 +285,7 @@ func blinking():
blinkTick = -12
func epicFail(err):
print(fail)
if fail == null:
@ -311,6 +312,7 @@ func epicFail(err):
await get_tree().create_timer(2.5).timeout
fail.visible = false
func refresh():
var objs = get_tree().get_nodes_in_group("saved")
for object in objs:
@ -319,6 +321,7 @@ func refresh():
object.remadePolygon = false
pushUpdate("Refreshed all sprites.")
func unlinkSprite():
if heldSprite == null:
return
@ -338,6 +341,7 @@ func unlinkSprite():
Global.spriteList.updateData()
pushUpdate("Unlinked sprite.")
func saveImagesFromData():
var sprites = get_tree().get_nodes_in_group("saved")
if sprites.size() <= 0:
@ -352,6 +356,7 @@ func saveImagesFromData():
pushUpdate("Saved all avatar images to computer.")
func pushUpdate(text):
if is_instance_valid(updatePusherNode):
updatePusherNode.pushUpdate(text)

View file

@ -5,7 +5,8 @@ var key = "creature"
var data = {}
var default = {
"0": {
"0":
{
"drag": 0,
"identification": 930245150,
"offset": "Vector2(0, 0)",
@ -16,12 +17,15 @@ var default = {
"showBlink": 0,
"showTalk": 0,
"type": "sprite",
"useMidiWobble": false,
"xAmp": 9,
"xFrq": 0.002,
"yAmp": 11,
"yFrq": 0.004,
"zindex": -1 },
"1": {
"zindex": -1
},
"1":
{
"drag": 1,
"identification": 456157398,
"offset": "Vector2(0, 0)",
@ -32,13 +36,147 @@ var default = {
"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", "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 } }
"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,
@ -61,6 +199,7 @@ var settings = {
var settingsPath = "user://settings.pngtp"
func _ready():
var datas = read_save(settingsPath)
if datas == null:
@ -68,19 +207,18 @@ func _ready():
else:
settings = datas.duplicate()
func _exit_tree():
write_settings(settingsPath)
func read_save(path):
if path == "default":
return DefaultAvatarData.data
if OS.has_feature('web'):
if OS.has_feature("web"):
var JSONstr = JavaScriptBridge.eval("window.localStorage.getItem('" + key + "');")
if (JSONstr):
if JSONstr:
return JSON.parse_string(JSONstr)
else:
return null
@ -92,14 +230,18 @@ func read_save(path):
file.close()
return newData
func write_save(path):
if OS.has_feature('web'):
JavaScriptBridge.eval("window.localStorage.setItem('" + key + "', '" + JSON.stringify(data) + "');")
if OS.has_feature("web"):
JavaScriptBridge.eval(
"window.localStorage.setItem('" + key + "', '" + JSON.stringify(data) + "');"
)
else:
var file = FileAccess.open(path, FileAccess.WRITE)
file.store_line(JSON.stringify(data))
file.close()
func write_settings(path):
var file = FileAccess.open(path, FileAccess.WRITE)
file.store_line(JSON.stringify(settings))
@ -107,10 +249,9 @@ func write_settings(path):
func clearSave():
if OS.has_feature('web'):
if OS.has_feature("web"):
var JSONstr = JavaScriptBridge.eval("window.localStorage.getItem('" + key + "');")
if (JSONstr):
if JSONstr:
JavaScriptBridge.eval("window.localStorage.removeItem('" + key + "');")
else:
return null
@ -123,14 +264,16 @@ func clearSave():
dir.remove(key + ".save")
data = {}
func open_site(url):
if OS.has_feature('web'):
JavaScriptBridge.eval("window.open(\"" + url + "\");")
if OS.has_feature("web"):
JavaScriptBridge.eval('window.open("' + url + '");')
else:
print("Could not open site " + url + " without an HTML5 build")
func switchToSite(url):
if OS.has_feature('web'):
JavaScriptBridge.eval("window.open(\"" + url + "\", \"_parent\");")
if OS.has_feature("web"):
JavaScriptBridge.eval('window.open("' + url + '", "_parent");')
else:
print("Could not switch to site " + url + " without an HTML5 build")

View file

@ -64,7 +64,7 @@ func _ready():
ElgatoStreamDeck.on_key_down.connect(changeCostumeStreamDeck)
OS.open_midi_inputs()
print(OS.get_connected_midi_inputs())
# print(OS.get_connected_midi_inputs())
if Saving.settings["newUser"]:
_on_load_dialog_file_selected("default")
@ -332,6 +332,7 @@ func _on_load_dialog_file_selected(path):
sprite.z = data[item]["zindex"]
sprite.dragSpeed = data[item]["drag"]
sprite.useMidiWobble = data[item]["useMidiWobble"]
sprite.xFrq = data[item]["xFrq"]
sprite.xAmp = data[item]["xAmp"]
sprite.yFrq = data[item]["yFrq"]
@ -402,6 +403,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
@ -487,6 +489,7 @@ func _on_duplicate_button_pressed():
sprite.showOnBlink = Global.heldSprite.showOnBlink
sprite.z = Global.heldSprite.z
sprite.useMidiWobble = Global.heldSprite.useMidiWobble
sprite.xFrq = Global.heldSprite.xFrq
sprite.xAmp = Global.heldSprite.xAmp
sprite.yFrq = Global.heldSprite.yFrq
@ -563,7 +566,7 @@ func moveSpriteMenu(delta):
var size = get_viewport().get_visible_rect().size
var windowLength = 1250 #1187
var windowLength = 1300 #1187
$ViewerArrows/Arrows.position.y = size.y - 25
@ -611,7 +614,6 @@ func _on_settings_buttons_pressed():
func _on_background_input_capture_bg_key_pressed(node, keys_pressed):
print("background key pressed")
var keyStrings = []
for i in keys_pressed:
@ -660,7 +662,6 @@ func _on_background_input_capture_bg_key_pressed(node, keys_pressed):
func bgInputSprite(node, keys_pressed):
print("bgInputSprite")
if fileSystemOpen:
return
var keyStrings = []

File diff suppressed because one or more lines are too long

View file

@ -48,8 +48,7 @@ var origTick = 0
var offset = Vector2.ZERO
#Wobble
var use_midi_wobble = true # TODO: Add to settings
var useMidiWobble = false
var xFrq = 0.0
var xAmp = 0.0
@ -163,7 +162,7 @@ func _ready():
func _input(event):
if use_midi_wobble and event is InputEventMIDI:
if self.useMidiWobble and event is InputEventMIDI:
match event.message:
MIDIMessage.MIDI_MESSAGE_START:
tick = 0
@ -222,7 +221,7 @@ func replaceSprite(pathNew):
func _process(delta):
if not use_midi_wobble:
if not self.useMidiWobble:
tick += 1
if Global.heldSprite == self:
@ -345,7 +344,7 @@ func drag(delta):
func wobble():
if use_midi_wobble:
if self.useMidiWobble:
midi_wobble()
else:
free_wobble()

View file

@ -7,13 +7,13 @@ extends Node2D
@onready var spriteRotDisplay = $RotationalLimits/RotBack/SpriteDisplay
@onready var coverCollider = $Area2D/CollisionShape2D
func _ready():
Global.spriteEdit = self
func setImage():
if Global.heldSprite == null:
return
@ -30,6 +30,8 @@ func setImage():
$Slider/Label.text = "drag: " + str(Global.heldSprite.dragSpeed)
$Slider/DragSlider.value = Global.heldSprite.dragSpeed
$WobbleControl/UseMidi.button_pressed = Global.heldSprite.useMidiWobble
$WobbleControl/xFrqLabel.text = "x frequency: " + str(Global.heldSprite.xFrq)
$WobbleControl/xAmpLabel.text = "x amplitude: " + str(Global.heldSprite.xAmp)
@ -67,7 +69,7 @@ func setImage():
$Animation/animFramesLabel.text = "sprite frames: " + str(Global.heldSprite.frames)
$Animation/animFrames.value = Global.heldSprite.frames
$VisToggle/setToggle/Label.text = "toggle: \"" + Global.heldSprite.toggle + "\""
$VisToggle/setToggle/Label.text = 'toggle: "' + Global.heldSprite.toggle + '"'
changeRotLimit()
@ -89,8 +91,8 @@ func setImage():
parentSpin.hframes = nodes[0].frames
parentSpin.visible = true
func _process(delta):
func _process(delta):
visible = Global.heldSprite != null
coverCollider.disabled = !visible
@ -101,8 +103,12 @@ func _process(delta):
spriteSpin.rotate_y(delta * 4.0)
parentSpin.rotate_y(delta * 4.0)
$Position/Label.text = "position X : "+str(obj.position.x)+" Y: " + str(obj.position.y)
$Position/Label2.text = "offset X : "+str(obj.offset.x)+" Y: " + str(obj.offset.y)
$Position/Label.text = (
"position X : " + str(obj.position.x) + " Y: " + str(obj.position.y)
)
$Position/Label2.text = (
"offset X : " + str(obj.offset.x) + " Y: " + str(obj.offset.y)
)
$Position/Label3.text = "layer : " + str(obj.z)
#Sprite Rotational Limit Display
@ -110,7 +116,9 @@ func _process(delta):
var size = Global.heldSprite.rLimitMax - Global.heldSprite.rLimitMin
var minimum = Global.heldSprite.rLimitMin
spriteRotDisplay.rotation_degrees = sin(Global.animationTick*0.05)*(size/2.0)+(minimum+(size/2.0))
spriteRotDisplay.rotation_degrees = (
sin(Global.animationTick * 0.05) * (size / 2.0) + (minimum + (size / 2.0))
)
$RotationalLimits/RotBack/RotLineDisplay3.rotation_degrees = spriteRotDisplay.rotation_degrees
@ -120,6 +128,11 @@ func _on_drag_slider_value_changed(value):
Global.heldSprite.dragSpeed = value
func _on_use_midi_toggled(value: bool):
# $WobbleControl/useMidi.button_pressed = value
Global.heldSprite.useMidiWobble = value
func _on_x_frq_value_changed(value):
$WobbleControl/xFrqLabel.text = "x frequency: " + str(value)
Global.heldSprite.xFrq = value
@ -134,6 +147,7 @@ func _on_y_frq_value_changed(value):
$WobbleControl/yFrqLabel.text = "y frequency: " + str(value)
Global.heldSprite.yFrq = value
func _on_y_amp_value_changed(value):
$WobbleControl/yAmpLabel.text = "y amplitude: " + str(value)
Global.heldSprite.yAmp = value
@ -166,6 +180,7 @@ func _on_trash_pressed():
Global.spriteList.updateData()
func _on_unlink_pressed():
if Global.heldSprite.parentId == null:
return
@ -179,19 +194,24 @@ func _on_rot_limit_min_value_changed(value):
changeRotLimit()
func _on_rot_limit_max_value_changed(value):
$RotationalLimits/RotLimitMax.text = "rotational limit max: " + str(value)
Global.heldSprite.rLimitMax = value
changeRotLimit()
func changeRotLimit():
$RotationalLimits/RotBack/rotLimitBar.value = Global.heldSprite.rLimitMax - Global.heldSprite.rLimitMin
$RotationalLimits/RotBack/rotLimitBar.value = (
Global.heldSprite.rLimitMax - Global.heldSprite.rLimitMin
)
$RotationalLimits/RotBack/rotLimitBar.rotation_degrees = Global.heldSprite.rLimitMin + 90
$RotationalLimits/RotBack/RotLineDisplay.rotation_degrees = Global.heldSprite.rLimitMin
$RotationalLimits/RotBack/RotLineDisplay2.rotation_degrees = Global.heldSprite.rLimitMax
func setLayerButtons():
var a = Global.heldSprite.costumeLayers.duplicate()
@ -216,7 +236,6 @@ func setLayerButtons():
sprite.changeCollision(false)
func _on_layer_button_1_pressed():
if Global.heldSprite.costumeLayers[0] == 0:
Global.heldSprite.costumeLayers[0] = 1
@ -256,6 +275,7 @@ func _on_layer_button_5_pressed():
Global.heldSprite.costumeLayers[4] = 0
setLayerButtons()
func _on_layer_button_6_pressed():
if Global.heldSprite.costumeLayers[5] == 0:
Global.heldSprite.costumeLayers[5] = 1
@ -263,6 +283,7 @@ func _on_layer_button_6_pressed():
Global.heldSprite.costumeLayers[5] = 0
setLayerButtons()
func _on_layer_button_7_pressed():
if Global.heldSprite.costumeLayers[6] == 0:
Global.heldSprite.costumeLayers[6] = 1
@ -270,6 +291,7 @@ func _on_layer_button_7_pressed():
Global.heldSprite.costumeLayers[6] = 0
setLayerButtons()
func _on_layer_button_8_pressed():
if Global.heldSprite.costumeLayers[7] == 0:
Global.heldSprite.costumeLayers[7] = 1
@ -277,6 +299,7 @@ func _on_layer_button_8_pressed():
Global.heldSprite.costumeLayers[7] = 0
setLayerButtons()
func _on_layer_button_9_pressed():
if Global.heldSprite.costumeLayers[8] == 0:
Global.heldSprite.costumeLayers[8] = 1
@ -284,6 +307,7 @@ func _on_layer_button_9_pressed():
Global.heldSprite.costumeLayers[8] = 0
setLayerButtons()
func _on_layer_button_10_pressed():
if Global.heldSprite.costumeLayers[9] == 0:
Global.heldSprite.costumeLayers[9] = 1
@ -291,6 +315,7 @@ func _on_layer_button_10_pressed():
Global.heldSprite.costumeLayers[9] = 0
setLayerButtons()
func layerSelected():
var newPos = Vector2.ZERO
match Global.main.costume:
@ -330,6 +355,7 @@ func _on_anim_speed_value_changed(value):
$Animation/animSpeedLabel.text = "animation speed: " + str(value)
Global.heldSprite.animSpeed = value
func _on_anim_frames_value_changed(value):
$Animation/animFramesLabel.text = "sprite frames: " + str(value)
Global.heldSprite.frames = value
@ -343,9 +369,10 @@ func _on_clip_linked_toggled(button_pressed):
func _on_delete_pressed():
Global.heldSprite.toggle = "null"
$VisToggle/setToggle/Label.text = "toggle: \"" + Global.heldSprite.toggle + "\""
$VisToggle/setToggle/Label.text = 'toggle: "' + Global.heldSprite.toggle + '"'
Global.heldSprite.makeVis()
func _on_set_toggle_pressed():
$VisToggle/setToggle/Label.text = "toggle: AWAITING INPUT"
await Global.main.fatfuckingballs
@ -353,4 +380,4 @@ func _on_set_toggle_pressed():
var keys = await Global.main.spriteVisToggles
var key = keys[0]
Global.heldSprite.toggle = key
$VisToggle/setToggle/Label.text = "toggle: \"" + Global.heldSprite.toggle + "\""
$VisToggle/setToggle/Label.text = 'toggle: "' + Global.heldSprite.toggle + '"'

File diff suppressed because one or more lines are too long