From 1b924174f2202161800eb328d71a5a8111776de4 Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Fri, 2 Feb 2024 01:53:20 +0100 Subject: [PATCH] config system --- config.gd | 34 ++++++++++++++++++++++++++++++++++ config.txt | 25 +++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 config.gd create mode 100644 config.txt diff --git a/config.gd b/config.gd new file mode 100644 index 0000000..483e6d2 --- /dev/null +++ b/config.gd @@ -0,0 +1,34 @@ +extends Node + +# load data from the file +var config = ConfigFile.new() +var err = config.load("config.txt") + +# Called when the node enters the scene tree for the first time. +func _ready(): + # if there is no config file, create it with default values + if err != OK: + config.set_value("spin", "spin_channel_1", 2) + config.set_value("spin", "spin_note_1", 10) + config.set_value("spin", "spin_channel_2", 2) + config.set_value("spin", "spin_note_2", 9) + config.set_value("jog", "jog_channel", 2) + config.set_value("jog", "jog_note", 8) + config.set_value("beat", "beat_channel", 3) + config.set_value("beat", "beat_note", 8) + config.set_value("inverted", "is_inverted", true) + config.save("config.txt") + +# fetch the config data +var spin_channel_1: int = config.get_value("spin", "spin_channel_1", 2) +var spin_note_1: int = config.get_value("spin", "spin_note_1", 10) +var spin_channel_2: int = config.get_value("spin", "spin_channel_2", 2) +var spin_note_2: int = config.get_value("spin", "spin_note_2", 9) +var jog_channel: int = config.get_value("jog", "jog_channel", 2) +var jog_note: int = config.get_value("jog", "jog_note", 8) +var beat_channel: int = config.get_value("beat", "beat_channel", 3) +var beat_note: int = config.get_value("beat", "beat_note", 8) +var is_inverted: bool = config.get_value("inverted", "is_inverted", true) + +func _process(_delta): + pass diff --git a/config.txt b/config.txt new file mode 100644 index 0000000..53215c7 --- /dev/null +++ b/config.txt @@ -0,0 +1,25 @@ +; here, put the same values as in game config +; the default config is for the inverted hercules djcontrol inpulse 200 + +[spin] +; ex. Ch 2 Note 10, so 2 and 10 +spin_channel_1=2 +spin_note_1=10 +; spin 2: Ch 2 Note 9, so 2 and 9 +; if you have no seconday spin, put the same values as the one above +spin_channel_2=2 +spin_note_2=9 + +[jog] +; ex. Ch 2 Note 8, so 2 and 8 +jog_channel=2 +jog_note=8 + +[beat] +; ex. Ch 3 Note 8, so 3 and 8 +beat_channel=3 +beat_note=8 + +[inverted] +; ex. true by default, false if your turntable is NOT inverted +is_inverted=true