In the middle of it
BIN
default_avatars/hat_guy/eyes_closed.png
Normal file
After Width: | Height: | Size: 3.7 KiB |
34
default_avatars/hat_guy/eyes_closed.png.import
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://dsir4ejkj8puy"
|
||||||
|
path="res://.godot/imported/eyes_closed.png-12c4263a2a91a0534f989bc9275bbd7d.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://default_avatars/hat_guy/eyes_closed.png"
|
||||||
|
dest_files=["res://.godot/imported/eyes_closed.png-12c4263a2a91a0534f989bc9275bbd7d.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
|
BIN
default_avatars/hat_guy/eyes_open.png
Normal file
After Width: | Height: | Size: 6.2 KiB |
34
default_avatars/hat_guy/eyes_open.png.import
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://4x3v7t763j2w"
|
||||||
|
path="res://.godot/imported/eyes_open.png-b2522b2294c35a5797861e391ceb2ff8.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://default_avatars/hat_guy/eyes_open.png"
|
||||||
|
dest_files=["res://.godot/imported/eyes_open.png-b2522b2294c35a5797861e391ceb2ff8.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
|
BIN
default_avatars/hat_guy/eyes_open_speaking.png
Normal file
After Width: | Height: | Size: 6.5 KiB |
34
default_avatars/hat_guy/eyes_open_speaking.png.import
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://brvu2i85mnr65"
|
||||||
|
path="res://.godot/imported/eyes_open_speaking.png-6409987f612bc32d553abbf3f7cc6ff1.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://default_avatars/hat_guy/eyes_open_speaking.png"
|
||||||
|
dest_files=["res://.godot/imported/eyes_open_speaking.png-6409987f612bc32d553abbf3f7cc6ff1.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
|
BIN
default_avatars/hat_guy/hair.png
Normal file
After Width: | Height: | Size: 55 KiB |
34
default_avatars/hat_guy/hair.png.import
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://b7d05wfdvqbmo"
|
||||||
|
path="res://.godot/imported/hair.png-f53ac7b29afa34df1fea5a0fb7b9f2c9.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://default_avatars/hat_guy/hair.png"
|
||||||
|
dest_files=["res://.godot/imported/hair.png-f53ac7b29afa34df1fea5a0fb7b9f2c9.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
|
BIN
default_avatars/hat_guy/hat.png
Normal file
After Width: | Height: | Size: 43 KiB |
34
default_avatars/hat_guy/hat.png.import
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://uvf6v845pqtw"
|
||||||
|
path="res://.godot/imported/hat.png-ff3f9691c4c57fb49dc1f851fddd1b84.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://default_avatars/hat_guy/hat.png"
|
||||||
|
dest_files=["res://.godot/imported/hat.png-ff3f9691c4c57fb49dc1f851fddd1b84.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
|
9
default_avatars/hat_guy/hat_guy.tres
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
[gd_resource type="Resource" script_class="AvatarData" load_steps=3 format=3 uid="uid://b7ss481m4x0a4"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://b73on8ic2acsv" path="res://scripts/avatar_data.gd" id="1_re035"]
|
||||||
|
[ext_resource type="Script" uid="uid://b07e67yn4uh6d" path="res://scripts/sprite_data.gd" id="2_cjoo4"]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
script = ExtResource("1_re035")
|
||||||
|
sprites = Array[ExtResource("2_cjoo4")]([])
|
||||||
|
metadata/_custom_type_script = "uid://b73on8ic2acsv"
|
BIN
default_avatars/hat_guy/head.png
Normal file
After Width: | Height: | Size: 21 KiB |
34
default_avatars/hat_guy/head.png.import
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://kpb0f3fkimex"
|
||||||
|
path="res://.godot/imported/head.png-e2914718512a4a40501f60740e5be3e5.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://default_avatars/hat_guy/head.png"
|
||||||
|
dest_files=["res://.godot/imported/head.png-e2914718512a4a40501f60740e5be3e5.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
|
BIN
default_avatars/hat_guy/mouth_closed.png
Normal file
After Width: | Height: | Size: 3.4 KiB |
34
default_avatars/hat_guy/mouth_closed.png.import
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://bgomt0jm4rca3"
|
||||||
|
path="res://.godot/imported/mouth_closed.png-153cd499e9f8e1d7fedcfc4d6ff19f09.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://default_avatars/hat_guy/mouth_closed.png"
|
||||||
|
dest_files=["res://.godot/imported/mouth_closed.png-153cd499e9f8e1d7fedcfc4d6ff19f09.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
|
BIN
default_avatars/hat_guy/mouth_open.png
Normal file
After Width: | Height: | Size: 5.8 KiB |
34
default_avatars/hat_guy/mouth_open.png.import
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://jiw5ygsr5eus"
|
||||||
|
path="res://.godot/imported/mouth_open.png-18177d9c2351b894e0bd89033dcbd8bb.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://default_avatars/hat_guy/mouth_open.png"
|
||||||
|
dest_files=["res://.godot/imported/mouth_open.png-18177d9c2351b894e0bd89033dcbd8bb.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
|
BIN
default_avatars/hat_guy/torso.png
Normal file
After Width: | Height: | Size: 19 KiB |
34
default_avatars/hat_guy/torso.png.import
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://bse3li76fy8pi"
|
||||||
|
path="res://.godot/imported/torso.png-d468966dc8d74a1a04ac15ce2dcb5d59.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://default_avatars/hat_guy/torso.png"
|
||||||
|
dest_files=["res://.godot/imported/torso.png-d468966dc8d74a1a04ac15ce2dcb5d59.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
|
|
@ -1,6 +1,6 @@
|
||||||
[configuration]
|
[configuration]
|
||||||
entry_symbol = "gdext_rust_init"
|
entry_symbol = "gdext_rust_init"
|
||||||
compatibility_minimum = 4.4
|
compatibility_minimum = 4.1
|
||||||
reloadable = true
|
reloadable = true
|
||||||
|
|
||||||
[libraries]
|
[libraries]
|
||||||
|
|
|
@ -1,144 +1,169 @@
|
||||||
|
use std::collections::HashSet;
|
||||||
|
|
||||||
use device_query::{DeviceQuery, DeviceState, Keycode};
|
use device_query::{DeviceQuery, DeviceState, Keycode};
|
||||||
use godot::{global::Key, prelude::*};
|
use godot::{classes::Engine, global::Key, prelude::*};
|
||||||
|
|
||||||
struct MyExtension;
|
struct MyExtension;
|
||||||
|
|
||||||
|
const SINGLETON_NAME: &str = "BackgroundInputCapture";
|
||||||
|
|
||||||
#[gdextension]
|
#[gdextension]
|
||||||
unsafe impl ExtensionLibrary for MyExtension {}
|
unsafe impl ExtensionLibrary for MyExtension {
|
||||||
|
fn on_level_init(_level: InitLevel) {
|
||||||
|
Engine::singleton()
|
||||||
|
.register_singleton(SINGLETON_NAME, &BackgroundInputCapture::new_alloc());
|
||||||
|
}
|
||||||
|
|
||||||
|
fn on_level_deinit(_level: InitLevel) {
|
||||||
|
Engine::singleton().unregister_singleton(SINGLETON_NAME);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(GodotClass)]
|
#[derive(GodotClass)]
|
||||||
#[class(init, base = Node)]
|
#[class(init, base = Object)]
|
||||||
pub struct BackgroundInputCapture {
|
pub struct BackgroundInputCapture {
|
||||||
device_state: DeviceState,
|
device_state: DeviceState,
|
||||||
base: Base<Node>,
|
pressed_keys: HashSet<Keycode>,
|
||||||
|
base: Base<Object>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[godot_api]
|
#[godot_api]
|
||||||
impl BackgroundInputCapture {
|
impl BackgroundInputCapture {
|
||||||
#[func]
|
#[func]
|
||||||
pub fn get_keys(&mut self) -> Vec<i32> {
|
pub fn get_keys(&mut self) -> Dictionary {
|
||||||
self.device_state
|
let keys: HashSet<Keycode> = self.device_state.get_keys().into_iter().collect();
|
||||||
.get_keys()
|
let just_pressed = keys.difference(&self.pressed_keys);
|
||||||
|
let just_released = self.pressed_keys.difference(&keys);
|
||||||
|
let output = just_pressed
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter_map(|k| {
|
.filter_map(|k| Some((keycode_to_key(k)?, true)))
|
||||||
Some(
|
.chain(
|
||||||
match k {
|
just_released
|
||||||
Keycode::Key0 => Key::KEY_0,
|
.into_iter()
|
||||||
Keycode::Key1 => Key::KEY_1,
|
.filter_map(|k| Some((keycode_to_key(k)?, false))),
|
||||||
Keycode::Key2 => Key::KEY_2,
|
)
|
||||||
Keycode::Key3 => Key::KEY_3,
|
.collect();
|
||||||
Keycode::Key4 => Key::KEY_4,
|
self.pressed_keys = keys;
|
||||||
Keycode::Key5 => Key::KEY_5,
|
output
|
||||||
Keycode::Key6 => Key::KEY_6,
|
|
||||||
Keycode::Key7 => Key::KEY_7,
|
|
||||||
Keycode::Key8 => Key::KEY_8,
|
|
||||||
Keycode::Key9 => Key::KEY_9,
|
|
||||||
Keycode::A => Key::A,
|
|
||||||
Keycode::B => Key::B,
|
|
||||||
Keycode::C => Key::C,
|
|
||||||
Keycode::D => Key::D,
|
|
||||||
Keycode::E => Key::E,
|
|
||||||
Keycode::F => Key::F,
|
|
||||||
Keycode::G => Key::G,
|
|
||||||
Keycode::H => Key::H,
|
|
||||||
Keycode::I => Key::I,
|
|
||||||
Keycode::J => Key::J,
|
|
||||||
Keycode::K => Key::K,
|
|
||||||
Keycode::L => Key::L,
|
|
||||||
Keycode::M => Key::M,
|
|
||||||
Keycode::N => Key::N,
|
|
||||||
Keycode::O => Key::O,
|
|
||||||
Keycode::P => Key::P,
|
|
||||||
Keycode::Q => Key::Q,
|
|
||||||
Keycode::R => Key::R,
|
|
||||||
Keycode::S => Key::S,
|
|
||||||
Keycode::T => Key::T,
|
|
||||||
Keycode::U => Key::U,
|
|
||||||
Keycode::V => Key::V,
|
|
||||||
Keycode::W => Key::W,
|
|
||||||
Keycode::X => Key::X,
|
|
||||||
Keycode::Y => Key::Y,
|
|
||||||
Keycode::Z => Key::Z,
|
|
||||||
Keycode::F1 => Key::F1,
|
|
||||||
Keycode::F2 => Key::F2,
|
|
||||||
Keycode::F3 => Key::F3,
|
|
||||||
Keycode::F4 => Key::F4,
|
|
||||||
Keycode::F5 => Key::F5,
|
|
||||||
Keycode::F6 => Key::F6,
|
|
||||||
Keycode::F7 => Key::F7,
|
|
||||||
Keycode::F8 => Key::F8,
|
|
||||||
Keycode::F9 => Key::F9,
|
|
||||||
Keycode::F10 => Key::F10,
|
|
||||||
Keycode::F11 => Key::F11,
|
|
||||||
Keycode::F12 => Key::F12,
|
|
||||||
Keycode::F13 => Key::F13,
|
|
||||||
Keycode::F14 => Key::F14,
|
|
||||||
Keycode::F15 => Key::F15,
|
|
||||||
Keycode::F16 => Key::F16,
|
|
||||||
Keycode::F17 => Key::F17,
|
|
||||||
Keycode::F18 => Key::F18,
|
|
||||||
Keycode::F19 => Key::F19,
|
|
||||||
Keycode::F20 => Key::F20,
|
|
||||||
Keycode::Escape => Key::ESCAPE,
|
|
||||||
Keycode::Space => Key::SPACE,
|
|
||||||
Keycode::LControl => return None,
|
|
||||||
Keycode::RControl => return None,
|
|
||||||
Keycode::LShift => return None,
|
|
||||||
Keycode::RShift => return None,
|
|
||||||
Keycode::LAlt => return None,
|
|
||||||
Keycode::RAlt => return None,
|
|
||||||
Keycode::Command => return None,
|
|
||||||
Keycode::RCommand => return None,
|
|
||||||
Keycode::LOption => return None,
|
|
||||||
Keycode::ROption => return None,
|
|
||||||
Keycode::LMeta => return None,
|
|
||||||
Keycode::RMeta => return None,
|
|
||||||
Keycode::Enter => Key::ENTER,
|
|
||||||
Keycode::Up => Key::UP,
|
|
||||||
Keycode::Down => Key::DOWN,
|
|
||||||
Keycode::Left => Key::LEFT,
|
|
||||||
Keycode::Right => Key::RIGHT,
|
|
||||||
Keycode::Backspace => Key::BACKSPACE,
|
|
||||||
Keycode::CapsLock => Key::CAPSLOCK,
|
|
||||||
Keycode::Tab => Key::TAB,
|
|
||||||
Keycode::Home => Key::HOME,
|
|
||||||
Keycode::End => Key::END,
|
|
||||||
Keycode::PageUp => Key::PAGEUP,
|
|
||||||
Keycode::PageDown => Key::PAGEDOWN,
|
|
||||||
Keycode::Insert => Key::INSERT,
|
|
||||||
Keycode::Delete => Key::DELETE,
|
|
||||||
Keycode::Numpad0 => Key::KP_0,
|
|
||||||
Keycode::Numpad1 => Key::KP_1,
|
|
||||||
Keycode::Numpad2 => Key::KP_2,
|
|
||||||
Keycode::Numpad3 => Key::KP_3,
|
|
||||||
Keycode::Numpad4 => Key::KP_4,
|
|
||||||
Keycode::Numpad5 => Key::KP_5,
|
|
||||||
Keycode::Numpad6 => Key::KP_6,
|
|
||||||
Keycode::Numpad7 => Key::KP_7,
|
|
||||||
Keycode::Numpad8 => Key::KP_8,
|
|
||||||
Keycode::Numpad9 => Key::KP_9,
|
|
||||||
Keycode::NumpadSubtract => Key::KP_SUBTRACT,
|
|
||||||
Keycode::NumpadAdd => Key::KP_ADD,
|
|
||||||
Keycode::NumpadDivide => Key::KP_DIVIDE,
|
|
||||||
Keycode::NumpadMultiply => Key::KP_MULTIPLY,
|
|
||||||
Keycode::NumpadEquals => Key::EQUAL,
|
|
||||||
Keycode::NumpadEnter => Key::KP_ENTER,
|
|
||||||
Keycode::NumpadDecimal => Key::KP_PERIOD,
|
|
||||||
Keycode::Grave => Key::QUOTELEFT,
|
|
||||||
Keycode::Minus => Key::MINUS,
|
|
||||||
Keycode::Equal => Key::EQUAL,
|
|
||||||
Keycode::LeftBracket => Key::BRACKETLEFT,
|
|
||||||
Keycode::RightBracket => Key::BRACKETRIGHT,
|
|
||||||
Keycode::BackSlash => Key::BACKSLASH,
|
|
||||||
Keycode::Semicolon => Key::SEMICOLON,
|
|
||||||
Keycode::Apostrophe => Key::APOSTROPHE,
|
|
||||||
Keycode::Comma => Key::COMMA,
|
|
||||||
Keycode::Dot => Key::PERIOD,
|
|
||||||
Keycode::Slash => Key::SLASH,
|
|
||||||
}
|
|
||||||
.to_godot(),
|
|
||||||
)
|
|
||||||
})
|
|
||||||
.collect()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn keycode_to_key(key: &Keycode) -> Option<i32> {
|
||||||
|
Some(
|
||||||
|
match key {
|
||||||
|
Keycode::Key0 => Key::KEY_0,
|
||||||
|
Keycode::Key1 => Key::KEY_1,
|
||||||
|
Keycode::Key2 => Key::KEY_2,
|
||||||
|
Keycode::Key3 => Key::KEY_3,
|
||||||
|
Keycode::Key4 => Key::KEY_4,
|
||||||
|
Keycode::Key5 => Key::KEY_5,
|
||||||
|
Keycode::Key6 => Key::KEY_6,
|
||||||
|
Keycode::Key7 => Key::KEY_7,
|
||||||
|
Keycode::Key8 => Key::KEY_8,
|
||||||
|
Keycode::Key9 => Key::KEY_9,
|
||||||
|
Keycode::A => Key::A,
|
||||||
|
Keycode::B => Key::B,
|
||||||
|
Keycode::C => Key::C,
|
||||||
|
Keycode::D => Key::D,
|
||||||
|
Keycode::E => Key::E,
|
||||||
|
Keycode::F => Key::F,
|
||||||
|
Keycode::G => Key::G,
|
||||||
|
Keycode::H => Key::H,
|
||||||
|
Keycode::I => Key::I,
|
||||||
|
Keycode::J => Key::J,
|
||||||
|
Keycode::K => Key::K,
|
||||||
|
Keycode::L => Key::L,
|
||||||
|
Keycode::M => Key::M,
|
||||||
|
Keycode::N => Key::N,
|
||||||
|
Keycode::O => Key::O,
|
||||||
|
Keycode::P => Key::P,
|
||||||
|
Keycode::Q => Key::Q,
|
||||||
|
Keycode::R => Key::R,
|
||||||
|
Keycode::S => Key::S,
|
||||||
|
Keycode::T => Key::T,
|
||||||
|
Keycode::U => Key::U,
|
||||||
|
Keycode::V => Key::V,
|
||||||
|
Keycode::W => Key::W,
|
||||||
|
Keycode::X => Key::X,
|
||||||
|
Keycode::Y => Key::Y,
|
||||||
|
Keycode::Z => Key::Z,
|
||||||
|
Keycode::F1 => Key::F1,
|
||||||
|
Keycode::F2 => Key::F2,
|
||||||
|
Keycode::F3 => Key::F3,
|
||||||
|
Keycode::F4 => Key::F4,
|
||||||
|
Keycode::F5 => Key::F5,
|
||||||
|
Keycode::F6 => Key::F6,
|
||||||
|
Keycode::F7 => Key::F7,
|
||||||
|
Keycode::F8 => Key::F8,
|
||||||
|
Keycode::F9 => Key::F9,
|
||||||
|
Keycode::F10 => Key::F10,
|
||||||
|
Keycode::F11 => Key::F11,
|
||||||
|
Keycode::F12 => Key::F12,
|
||||||
|
Keycode::F13 => Key::F13,
|
||||||
|
Keycode::F14 => Key::F14,
|
||||||
|
Keycode::F15 => Key::F15,
|
||||||
|
Keycode::F16 => Key::F16,
|
||||||
|
Keycode::F17 => Key::F17,
|
||||||
|
Keycode::F18 => Key::F18,
|
||||||
|
Keycode::F19 => Key::F19,
|
||||||
|
Keycode::F20 => Key::F20,
|
||||||
|
Keycode::Escape => Key::ESCAPE,
|
||||||
|
Keycode::Space => Key::SPACE,
|
||||||
|
Keycode::LControl => return None,
|
||||||
|
Keycode::RControl => return None,
|
||||||
|
Keycode::LShift => return None,
|
||||||
|
Keycode::RShift => return None,
|
||||||
|
Keycode::LAlt => return None,
|
||||||
|
Keycode::RAlt => return None,
|
||||||
|
Keycode::Command => return None,
|
||||||
|
Keycode::RCommand => return None,
|
||||||
|
Keycode::LOption => return None,
|
||||||
|
Keycode::ROption => return None,
|
||||||
|
Keycode::LMeta => return None,
|
||||||
|
Keycode::RMeta => return None,
|
||||||
|
Keycode::Enter => Key::ENTER,
|
||||||
|
Keycode::Up => Key::UP,
|
||||||
|
Keycode::Down => Key::DOWN,
|
||||||
|
Keycode::Left => Key::LEFT,
|
||||||
|
Keycode::Right => Key::RIGHT,
|
||||||
|
Keycode::Backspace => Key::BACKSPACE,
|
||||||
|
Keycode::CapsLock => Key::CAPSLOCK,
|
||||||
|
Keycode::Tab => Key::TAB,
|
||||||
|
Keycode::Home => Key::HOME,
|
||||||
|
Keycode::End => Key::END,
|
||||||
|
Keycode::PageUp => Key::PAGEUP,
|
||||||
|
Keycode::PageDown => Key::PAGEDOWN,
|
||||||
|
Keycode::Insert => Key::INSERT,
|
||||||
|
Keycode::Delete => Key::DELETE,
|
||||||
|
Keycode::Numpad0 => Key::KP_0,
|
||||||
|
Keycode::Numpad1 => Key::KP_1,
|
||||||
|
Keycode::Numpad2 => Key::KP_2,
|
||||||
|
Keycode::Numpad3 => Key::KP_3,
|
||||||
|
Keycode::Numpad4 => Key::KP_4,
|
||||||
|
Keycode::Numpad5 => Key::KP_5,
|
||||||
|
Keycode::Numpad6 => Key::KP_6,
|
||||||
|
Keycode::Numpad7 => Key::KP_7,
|
||||||
|
Keycode::Numpad8 => Key::KP_8,
|
||||||
|
Keycode::Numpad9 => Key::KP_9,
|
||||||
|
Keycode::NumpadSubtract => Key::KP_SUBTRACT,
|
||||||
|
Keycode::NumpadAdd => Key::KP_ADD,
|
||||||
|
Keycode::NumpadDivide => Key::KP_DIVIDE,
|
||||||
|
Keycode::NumpadMultiply => Key::KP_MULTIPLY,
|
||||||
|
Keycode::NumpadEquals => Key::EQUAL,
|
||||||
|
Keycode::NumpadEnter => Key::KP_ENTER,
|
||||||
|
Keycode::NumpadDecimal => Key::KP_PERIOD,
|
||||||
|
Keycode::Grave => Key::QUOTELEFT,
|
||||||
|
Keycode::Minus => Key::MINUS,
|
||||||
|
Keycode::Equal => Key::EQUAL,
|
||||||
|
Keycode::LeftBracket => Key::BRACKETLEFT,
|
||||||
|
Keycode::RightBracket => Key::BRACKETRIGHT,
|
||||||
|
Keycode::BackSlash => Key::BACKSLASH,
|
||||||
|
Keycode::Semicolon => Key::SEMICOLON,
|
||||||
|
Keycode::Apostrophe => Key::APOSTROPHE,
|
||||||
|
Keycode::Comma => Key::COMMA,
|
||||||
|
Keycode::Dot => Key::PERIOD,
|
||||||
|
Keycode::Slash => Key::SLASH,
|
||||||
|
}
|
||||||
|
.to_godot(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
|
@ -48,13 +48,6 @@ var bounceChange = 0.0
|
||||||
#IMPORTANT
|
#IMPORTANT
|
||||||
var fileSystemOpen = false
|
var fileSystemOpen = false
|
||||||
|
|
||||||
#background input capture
|
|
||||||
signal emptiedCapture
|
|
||||||
signal pressedKey
|
|
||||||
var costumeKeys = ["1","2","3","4","5","6","7","8","9","0"]
|
|
||||||
signal spriteVisToggles(keysPressed:Array[String])
|
|
||||||
signal all_keys_released
|
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
Global.main = self
|
Global.main = self
|
||||||
Global.fail = $Failed
|
Global.fail = $Failed
|
||||||
|
@ -133,9 +126,6 @@ func _ready():
|
||||||
camera.position = origin.position
|
camera.position = origin.position
|
||||||
|
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
var keys = $BackgroundInputCapture.get_keys()
|
|
||||||
process_key_presses(keys)
|
|
||||||
bgInputSprite(keys)
|
|
||||||
var hold = origin.get_parent().position.y
|
var hold = origin.get_parent().position.y
|
||||||
|
|
||||||
origin.get_parent().position.y += yVel * 0.0166
|
origin.get_parent().position.y += yVel * 0.0166
|
||||||
|
@ -582,51 +572,3 @@ func _on_button_pressed():
|
||||||
|
|
||||||
func _on_settings_buttons_pressed():
|
func _on_settings_buttons_pressed():
|
||||||
settingsMenu.visible = !settingsMenu.visible
|
settingsMenu.visible = !settingsMenu.visible
|
||||||
|
|
||||||
|
|
||||||
func process_key_presses(keys_pressed):
|
|
||||||
var keyStrings = []
|
|
||||||
|
|
||||||
for i in keys_pressed:
|
|
||||||
keyStrings.append(OS.get_keycode_string(i) if !OS.get_keycode_string(i).strip_edges().is_empty() else "Keycode" + str(i))
|
|
||||||
|
|
||||||
if fileSystemOpen:
|
|
||||||
return
|
|
||||||
|
|
||||||
if keyStrings.size() <= 0:
|
|
||||||
emit_signal("emptiedCapture")
|
|
||||||
return
|
|
||||||
|
|
||||||
if settingsMenu.awaitingCostumeInput >= 0:
|
|
||||||
|
|
||||||
if keyStrings[0] == "Keycode1":
|
|
||||||
if !settingsMenu.hasMouse:
|
|
||||||
emit_signal("pressedKey")
|
|
||||||
return
|
|
||||||
|
|
||||||
var currentButton = costumeKeys[settingsMenu.awaitingCostumeInput]
|
|
||||||
costumeKeys[settingsMenu.awaitingCostumeInput] = keyStrings[0]
|
|
||||||
Saving.settings["costumeKeys"] = costumeKeys
|
|
||||||
Global.pushUpdate("Changed costume " + str(settingsMenu.awaitingCostumeInput+1) + " hotkey from \"" + currentButton + "\" to \"" + keyStrings[0] + "\"")
|
|
||||||
emit_signal("pressedKey")
|
|
||||||
|
|
||||||
for key in keyStrings:
|
|
||||||
var i = costumeKeys.find(key)
|
|
||||||
if i >= 0:
|
|
||||||
changeCostume(i+1)
|
|
||||||
|
|
||||||
|
|
||||||
# Handles background input for sprites
|
|
||||||
func bgInputSprite(keys_pressed: Array[Key]):
|
|
||||||
if fileSystemOpen:
|
|
||||||
return
|
|
||||||
|
|
||||||
if keys_pressed.size() <= 0:
|
|
||||||
emit_signal("all_keys_released")
|
|
||||||
return
|
|
||||||
|
|
||||||
spriteVisToggles.emit(
|
|
||||||
keys_pressed.map(
|
|
||||||
func(i) -> String: return OS.get_keycode_string(i) if !OS.get_keycode_string(i).strip_edges().is_empty() else "Keycode" + str(i)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
|
@ -619,8 +619,6 @@ texture = ExtResource("24_joqmn")
|
||||||
[node name="Camera2D" type="Camera2D" parent="."]
|
[node name="Camera2D" type="Camera2D" parent="."]
|
||||||
position = Vector2(360, 360)
|
position = Vector2(360, 360)
|
||||||
|
|
||||||
[node name="BackgroundInputCapture" type="BackgroundInputCapture" parent="."]
|
|
||||||
|
|
||||||
[node name="PushUpdates" parent="." instance=ExtResource("30_q43vl")]
|
[node name="PushUpdates" parent="." instance=ExtResource("30_q43vl")]
|
||||||
z_index = 4090
|
z_index = 4090
|
||||||
position = Vector2(0, 720)
|
position = Vector2(0, 720)
|
||||||
|
|
|
@ -26,10 +26,11 @@ driver/enable_input=true
|
||||||
|
|
||||||
[autoload]
|
[autoload]
|
||||||
|
|
||||||
Saving="*res://autoload/saving.gd"
|
Config="*res://scripts/autoload/config.gd"
|
||||||
Global="*res://autoload/global.gd"
|
Global="*res://scripts/autoload/global.gd"
|
||||||
ElgatoStreamDeck="*res://addons/godot-streamdeck-addon/singleton.gd"
|
ElgatoStreamDeck="*res://addons/godot-streamdeck-addon/singleton.gd"
|
||||||
DefaultAvatarData="*res://autoload/defaultAvatarData.gd"
|
DefaultAvatarData="*res://scripts/autoload/defaultAvatarData.gd"
|
||||||
|
InputHandler="*res://scripts/autoload/input_handler.gd"
|
||||||
|
|
||||||
[debug]
|
[debug]
|
||||||
|
|
||||||
|
|
|
@ -40,57 +40,22 @@ var default = {
|
||||||
"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 } }
|
"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 settings = {
|
var settings: Settings = Settings.new()
|
||||||
"newUser":true,
|
|
||||||
"lastAvatar":"",
|
|
||||||
"volume":0.185,
|
|
||||||
"sense":0.25,
|
|
||||||
"windowSize":Vector2i(1280,720),
|
|
||||||
"useStreamDeck":false,
|
|
||||||
"bounce":250,
|
|
||||||
"gravity":1000,
|
|
||||||
"maxFPS":60,
|
|
||||||
"secondsToMicReset":180,
|
|
||||||
"backgroundColor":var_to_str(Color(0.0,0.0,0.0,0.0)),
|
|
||||||
"filtering":false,
|
|
||||||
"costumeKeys":["1","2","3","4","5","6","7","8","9","0"],
|
|
||||||
"blinkSpeed":1.0,
|
|
||||||
"blinkChance":200,
|
|
||||||
"bounceOnCostumeChange":false,
|
|
||||||
}
|
|
||||||
|
|
||||||
var settingsPath = "user://settings.pngtp"
|
var settingsPath = "user://settings.pngtp"
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
var datas = read_save(settingsPath)
|
settings = load(settingsPath)
|
||||||
if datas == null:
|
|
||||||
return
|
|
||||||
else:
|
|
||||||
settings = datas.duplicate()
|
|
||||||
|
|
||||||
func _exit_tree():
|
func _exit_tree():
|
||||||
write_settings(settingsPath)
|
write_settings(settingsPath)
|
||||||
|
|
||||||
|
|
||||||
func read_save(path):
|
func read_save(path):
|
||||||
|
|
||||||
if path == "default":
|
if path == "default":
|
||||||
return DefaultAvatarData.data
|
return DefaultAvatarData.data
|
||||||
|
|
||||||
|
return load(path)
|
||||||
if OS.has_feature('web'):
|
|
||||||
var JSONstr = JavaScriptBridge.eval("window.localStorage.getItem('" + key + "');")
|
|
||||||
if (JSONstr):
|
|
||||||
return JSON.parse_string(JSONstr)
|
|
||||||
else:
|
|
||||||
return null
|
|
||||||
else:
|
|
||||||
var file = FileAccess.open(path, FileAccess.READ)
|
|
||||||
if not file:
|
|
||||||
return null
|
|
||||||
var newData = JSON.parse_string(file.get_as_text())
|
|
||||||
file.close()
|
|
||||||
return newData
|
|
||||||
|
|
||||||
func write_save(path):
|
func write_save(path):
|
||||||
if OS.has_feature('web'):
|
if OS.has_feature('web'):
|
77
scripts/autoload/input_handler.gd
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
# Handles background inputs (inputs when unfocused)
|
||||||
|
|
||||||
|
extends Node
|
||||||
|
|
||||||
|
signal key_pressed(key: Key)
|
||||||
|
signal key_released(key: Key)
|
||||||
|
signal all_keys_released
|
||||||
|
#background input capture
|
||||||
|
signal emptiedCapture
|
||||||
|
signal pressedKey
|
||||||
|
var costumeKeys = ["1","2","3","4","5","6","7","8","9","0"]
|
||||||
|
|
||||||
|
var pressed_keys: Array[Key] = []
|
||||||
|
|
||||||
|
func should_fire_signal() -> bool:
|
||||||
|
return get_viewport().gui_get_focus_owner() == null or not DisplayServer.window_is_focused()
|
||||||
|
|
||||||
|
func _process(_delta):
|
||||||
|
# This is a Dictionary[Key, bool] but I can't return typed dicts nor cast them
|
||||||
|
var keys = BackgroundInputCapture.get_keys()
|
||||||
|
for key in keys:
|
||||||
|
if keys[key]:
|
||||||
|
pressed_keys.append(key)
|
||||||
|
if should_fire_signal():
|
||||||
|
key_pressed.emit(key)
|
||||||
|
else:
|
||||||
|
pressed_keys.erase(key)
|
||||||
|
if should_fire_signal():
|
||||||
|
key_released.emit(key)
|
||||||
|
#process_key_presses(keys)
|
||||||
|
#bgInputSprite(keys)
|
||||||
|
#
|
||||||
|
#func process_key_presses(keys_pressed: Dictionary[Key, bool]):
|
||||||
|
#if Global.main.fileSystemOpen:
|
||||||
|
#return
|
||||||
|
#
|
||||||
|
#var keyStrings = keys_pressed.map(
|
||||||
|
#func(i) -> String: return OS.get_keycode_string(i) if !OS.get_keycode_string(i).strip_edges().is_empty() else "Keycode" + str(i)
|
||||||
|
#)
|
||||||
|
#
|
||||||
|
#if keyStrings.size() <= 0:
|
||||||
|
#emit_signal("emptiedCapture")
|
||||||
|
#return
|
||||||
|
#
|
||||||
|
#if settingsMenu.awaitingCostumeInput >= 0:
|
||||||
|
#
|
||||||
|
#if keyStrings[0] == "Keycode1":
|
||||||
|
#if !settingsMenu.hasMouse:
|
||||||
|
#emit_signal("pressedKey")
|
||||||
|
#return
|
||||||
|
#
|
||||||
|
#var currentButton = costumeKeys[settingsMenu.awaitingCostumeInput]
|
||||||
|
#costumeKeys[settingsMenu.awaitingCostumeInput] = keyStrings[0]
|
||||||
|
#Saving.settings["costumeKeys"] = costumeKeys
|
||||||
|
#Global.pushUpdate("Changed costume " + str(settingsMenu.awaitingCostumeInput+1) + " hotkey from \"" + currentButton + "\" to \"" + keyStrings[0] + "\"")
|
||||||
|
#emit_signal("pressedKey")
|
||||||
|
#
|
||||||
|
#for key in keyStrings:
|
||||||
|
#var i = costumeKeys.find(key)
|
||||||
|
#if i >= 0:
|
||||||
|
#changeCostume(i+1)
|
||||||
|
#
|
||||||
|
#
|
||||||
|
## Handles background input for sprites
|
||||||
|
#func bgInputSprite(keys_pressed: Dictionary[Key, bool]):
|
||||||
|
#if fileSystemOpen:
|
||||||
|
#return
|
||||||
|
#
|
||||||
|
#if keys_pressed.size() <= 0:
|
||||||
|
#emit_signal("all_keys_released")
|
||||||
|
#return
|
||||||
|
#
|
||||||
|
#spriteVisToggles.emit(
|
||||||
|
#keys_pressed.map(
|
||||||
|
#func(i) -> String: return OS.get_keycode_string(i) if !OS.get_keycode_string(i).strip_edges().is_empty() else "Keycode" + str(i)
|
||||||
|
#)
|
||||||
|
#)
|
1
scripts/autoload/input_handler.gd.uid
Normal file
|
@ -0,0 +1 @@
|
||||||
|
uid://y12b1vin2hpt
|
4
scripts/avatar_data.gd
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
extends Resource
|
||||||
|
class_name AvatarData
|
||||||
|
|
||||||
|
@export var sprites: Array[SpriteData] = []
|
1
scripts/avatar_data.gd.uid
Normal file
|
@ -0,0 +1 @@
|
||||||
|
uid://b73on8ic2acsv
|
18
scripts/settings.gd
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
extends Resource
|
||||||
|
class_name Settings
|
||||||
|
|
||||||
|
@export_global_file var lastAvatar: String = ""
|
||||||
|
@export_range(0, 1, 0.05) var volume: float = 0.185
|
||||||
|
@export_range(0, 1, 0.05) var sense = 0.25
|
||||||
|
@export var windowSize = Vector2i(1280, 720)
|
||||||
|
@export var useStreamDeck = false
|
||||||
|
@export var bounce = 250
|
||||||
|
@export var gravity = 1000
|
||||||
|
@export var maxFPS: int = 60
|
||||||
|
@export var secondsToMicReset: float = 180
|
||||||
|
@export var backgroundColor: Color = Color.TRANSPARENT
|
||||||
|
@export var filtering = false
|
||||||
|
@export var costumeKeys: Array[Key] = [KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, KEY_8, KEY_9, KEY_0]
|
||||||
|
@export var blinkSpeed: float = 1.0
|
||||||
|
@export var blinkChance = 200
|
||||||
|
@export var bounceOnCostumeChange = false
|
1
scripts/settings.gd.uid
Normal file
|
@ -0,0 +1 @@
|
||||||
|
uid://dmeqvexvccsav
|
26
scripts/sprite_data.gd
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
extends Resource
|
||||||
|
class_name SpriteData
|
||||||
|
|
||||||
|
@export var anim_speed = 0
|
||||||
|
@export var clipped = false
|
||||||
|
@export var costume_layers: Array[bool] = [true, true, true, true, true, true, true, true, true, true]
|
||||||
|
@export var drag = 0
|
||||||
|
@export var frames = 1
|
||||||
|
@export var ignore_bounce = false
|
||||||
|
@export var image: Texture
|
||||||
|
@export var offset = Vector2(0, 0)
|
||||||
|
@export_global_file var path = "user://defaultAvatar/body.png"
|
||||||
|
@export var pos = Vector2(0, 0)
|
||||||
|
@export var r_limit_max = 180
|
||||||
|
@export var r_limit_min = -180
|
||||||
|
@export var rot_drag = 0
|
||||||
|
@export var show_blink = 0
|
||||||
|
@export var show_talk = 0
|
||||||
|
@export var stretch_amount = 0.25
|
||||||
|
@export var type = "sprite"
|
||||||
|
@export var x_amp = 9
|
||||||
|
@export var x_frq = 0.004
|
||||||
|
@export var y_amp = 11
|
||||||
|
@export var y_frq = 0.008
|
||||||
|
@export var zindex = -1
|
||||||
|
@export var children: Array[SpriteData] = []
|
1
scripts/sprite_data.gd.uid
Normal file
|
@ -0,0 +1 @@
|
||||||
|
uid://b07e67yn4uh6d
|
|
@ -1,11 +0,0 @@
|
||||||
shader_type canvas_item;
|
|
||||||
|
|
||||||
uniform sampler2D noise_texture:repeat_enable;
|
|
||||||
uniform float distortion_strengh: hint_range(0, 0.1) = 1.0;
|
|
||||||
uniform float speed: hint_range(0.1, 10) = 1.0;
|
|
||||||
|
|
||||||
void fragment() {
|
|
||||||
vec4 noise_pixel = texture(noise_texture, UV + floor(TIME*speed)/3.0);
|
|
||||||
vec2 uv_offset = (noise_pixel.rg * 2.0 - 1.0) * distortion_strengh;
|
|
||||||
COLOR = texture(TEXTURE, UV + uv_offset);
|
|
||||||
}
|
|
|
@ -1 +0,0 @@
|
||||||
uid://ddgp8n4l7veuh
|
|
|
@ -81,11 +81,10 @@ var clipped = false
|
||||||
var tick = 0
|
var tick = 0
|
||||||
|
|
||||||
#Vis toggle
|
#Vis toggle
|
||||||
var toggle = "null"
|
var toggle: Key = KEY_NONE
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
|
InputHandler.key_pressed.connect(visToggle)
|
||||||
Global.main.spriteVisToggles.connect(visToggle)
|
|
||||||
|
|
||||||
var img = Image.new()
|
var img = Image.new()
|
||||||
var err = img.load(path)
|
var err = img.load(path)
|
||||||
|
@ -396,8 +395,8 @@ func getAllLinkedSprites():
|
||||||
linkedSprites.append(node)
|
linkedSprites.append(node)
|
||||||
return linkedSprites
|
return linkedSprites
|
||||||
|
|
||||||
func visToggle(keys):
|
func visToggle(key: Key):
|
||||||
if keys.has(toggle):
|
if key == toggle:
|
||||||
$WobbleOrigin/DragOrigin.visible = !$WobbleOrigin/DragOrigin.visible
|
$WobbleOrigin/DragOrigin.visible = !$WobbleOrigin/DragOrigin.visible
|
||||||
|
|
||||||
func makeVis():
|
func makeVis():
|
||||||
|
|
|
@ -342,15 +342,14 @@ func _on_clip_linked_toggled(button_pressed):
|
||||||
|
|
||||||
|
|
||||||
func _on_delete_pressed():
|
func _on_delete_pressed():
|
||||||
Global.heldSprite.toggle = "null"
|
Global.heldSprite.toggle = KEY_NONE
|
||||||
$VisToggle/setToggle/Label.text = "toggle: \"" + Global.heldSprite.toggle + "\""
|
$VisToggle/setToggle/Label.text = "toggle: \"%s\"" % OS.get_keycode_string(Global.heldSprite.toggle)
|
||||||
Global.heldSprite.makeVis()
|
Global.heldSprite.makeVis()
|
||||||
|
|
||||||
func _on_set_toggle_pressed():
|
func _on_set_toggle_pressed():
|
||||||
$VisToggle/setToggle/Label.text = "toggle: AWAITING INPUT"
|
$VisToggle/setToggle/Label.text = "toggle: AWAITING INPUT"
|
||||||
await Global.main.all_keys_released
|
await InputHandler.all_keys_released
|
||||||
|
|
||||||
var keys = await Global.main.spriteVisToggles
|
var key = await InputHandler.key_pressed
|
||||||
var key = keys[0]
|
|
||||||
Global.heldSprite.toggle = key
|
Global.heldSprite.toggle = key
|
||||||
$VisToggle/setToggle/Label.text = "toggle: \"" + Global.heldSprite.toggle + "\""
|
$VisToggle/setToggle/Label.text = "toggle: \"%s\"" % OS.get_keycode_string(Global.heldSprite.toggle)
|
||||||
|
|