mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2026-04-27 05:01:38 +00:00
fix slider and js settings
This commit is contained in:
parent
3cbd1066ad
commit
4cb5587ac5
4 changed files with 23 additions and 3 deletions
BIN
marblegame.hl
BIN
marblegame.hl
Binary file not shown.
|
|
@ -107,7 +107,8 @@ class MarbleGame {
|
||||||
});
|
});
|
||||||
canvas.pushDialog(exitGameDlg);
|
canvas.pushDialog(exitGameDlg);
|
||||||
} else {
|
} else {
|
||||||
canvas.popDialog(exitGameDlg);
|
if (exitGameDlg != null)
|
||||||
|
canvas.popDialog(exitGameDlg);
|
||||||
world.setCursorLock(true);
|
world.setCursorLock(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -112,13 +112,29 @@ class Settings {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function save() {
|
public static function save() {
|
||||||
var outputData = {
|
var outputData:Dynamic = {
|
||||||
highScores: highScores,
|
|
||||||
options: optionsSettings,
|
options: optionsSettings,
|
||||||
controls: controlsSettings,
|
controls: controlsSettings,
|
||||||
progression: progression,
|
progression: progression,
|
||||||
highscoreName: highscoreName
|
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);
|
var json = Json.stringify(outputData);
|
||||||
#if hl
|
#if hl
|
||||||
File.saveContent("settings.json", json);
|
File.saveContent("settings.json", json);
|
||||||
|
|
@ -158,6 +174,8 @@ class Settings {
|
||||||
controlsSettings = json.controls;
|
controlsSettings = json.controls;
|
||||||
progression = json.progression;
|
progression = json.progression;
|
||||||
highscoreName = json.highscoreName;
|
highscoreName = json.highscoreName;
|
||||||
|
} else {
|
||||||
|
save();
|
||||||
}
|
}
|
||||||
#if hl
|
#if hl
|
||||||
Window.getInstance().vsync = optionsSettings.vsync;
|
Window.getInstance().vsync = optionsSettings.vsync;
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ class GuiSlider extends GuiImage {
|
||||||
slidingSound.pause = true;
|
slidingSound.pause = true;
|
||||||
super.update(dt, mouseState);
|
super.update(dt, mouseState);
|
||||||
this.bmp.x = renderRect.position.x + renderRect.extent.x * sliderValue;
|
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;
|
this.bmp.width = this.bmp.tile.width;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue