fix slider and js settings

This commit is contained in:
RandomityGuy 2021-07-12 12:20:53 +05:30
parent 3cbd1066ad
commit 4cb5587ac5
4 changed files with 23 additions and 3 deletions

Binary file not shown.

View file

@ -107,7 +107,8 @@ class MarbleGame {
});
canvas.pushDialog(exitGameDlg);
} else {
canvas.popDialog(exitGameDlg);
if (exitGameDlg != null)
canvas.popDialog(exitGameDlg);
world.setCursorLock(true);
}
}

View file

@ -112,13 +112,29 @@ class Settings {
}
public static function save() {
var outputData = {
highScores: highScores,
var outputData:Dynamic = {
options: optionsSettings,
controls: controlsSettings,
progression: progression,
highscoreName: highscoreName
};
var scoreCount = 0;
for (key => value in highScores) {
scoreCount++;
}
#if hl
if (scoreCount != 0)
outputData.highScores = highScores;
else
outputData.highScores = {};
#end
#if js
var kvps:Array<Dynamic> = [];
for (key => value in highScores)
kvps.push([key, value]);
var jobj = js.lib.Object.fromEntries(kvps);
outputData.highScores = jobj;
#end
var json = Json.stringify(outputData);
#if hl
File.saveContent("settings.json", json);
@ -158,6 +174,8 @@ class Settings {
controlsSettings = json.controls;
progression = json.progression;
highscoreName = json.highscoreName;
} else {
save();
}
#if hl
Window.getInstance().vsync = optionsSettings.vsync;

View file

@ -25,6 +25,7 @@ class GuiSlider extends GuiImage {
slidingSound.pause = true;
super.update(dt, mouseState);
this.bmp.x = renderRect.position.x + renderRect.extent.x * sliderValue;
this.bmp.x = Util.clamp(this.bmp.x, renderRect.position.x, renderRect.position.x + renderRect.extent.x - bmp.width / 2);
this.bmp.width = this.bmp.tile.width;
}
}