Skip to content

Commit

Permalink
debuged Logging system
Browse files Browse the repository at this point in the history
added preset saveing and loading functionality to gui settings
  • Loading branch information
IPdotSetAF committed Apr 4, 2024
1 parent c41bf3b commit 0fd0506
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
Binary file modified index.css
Binary file not shown.
36 changes: 28 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ window.onload = function () {
if (tags[0]['name'] > version)
Log("New release available: " + tags[0]['name']);
}

var gui;
var options = {
ui_rain_matrixSpeed: 24,
fpsInterval: calculateFpsInterval(24),
Expand All @@ -29,7 +29,23 @@ window.onload = function () {
ui_audio_audioResponsive: false,
ui_audio_audioSensetivity: 50,
ui_audio_silenceAnimation: true,
ui_audio_silenceTimeoutSeconds: 3
ui_audio_silenceTimeoutSeconds: 3,
Save() {
window.localStorage.setItem("preset", JSON.stringify(gui.save()));
Log("Saved preset.");
},
Load() {
let preset = JSON.parse(window.localStorage.getItem("preset"));
if (preset) {
gui.load(preset);
Log("Loaded preset.");
} else
Log("No preset found.");
},
Reset() {
gui.reset();
Log("Settings reset to default.");
}
}

if (window.wallpaperRegisterAudioListener)
Expand All @@ -40,8 +56,8 @@ window.onload = function () {
drawGui();

function drawGui() {
gui = new lil.GUI({ autoPlace: false });
gui = new lil.GUI({ autoPlace: false, width: 400 });

const rainFolder = gui.addFolder('Rain');
rainFolder.add(options, 'ui_rain_matrixSpeed').min(1).max(60).step(1).name('Matrix Speed').onChange(() => {
options.fpsInterval = calculateFpsInterval(options.ui_rain_matrixSpeed);
Expand Down Expand Up @@ -78,6 +94,10 @@ window.onload = function () {
fallAnimation();
});

gui.add(options, "Save");
gui.add(options, "Load");
gui.add(options, "Reset");

customContainer = document.getElementById('gui');
customContainer.appendChild(gui.domElement);
}
Expand Down Expand Up @@ -154,6 +174,8 @@ window.onload = function () {
updateMask();
updateCharSet();
updateFont();
if (gui)
options.Load();
startAnimating();

function updateCanvasSize() {
Expand Down Expand Up @@ -390,17 +412,15 @@ window.onload = function () {
return map(value, -1, 1, 0.05, -0.05);
}

function makeCodes(codesText){
function makeCodes(codesText) {
var codes = codesText.split(",")
codes.push("IP.AF");
return codes;
}

function Log(text) {
if (logs.length > 0)
if (logs[logs.length - 1] == text)
return;
debug.classList.remove("hide");
void debug.offsetWidth;
logs.push(text);
if (logs.length > 10)
logs.splice(0, 1);
Expand Down

0 comments on commit 0fd0506

Please sign in to comment.