diff --git a/marblegame.hl b/marblegame.hl index 9252b318..686f26dd 100644 Binary files a/marblegame.hl and b/marblegame.hl differ diff --git a/src/MarbleGame.hx b/src/MarbleGame.hx index 78ac4f8e..3dd13643 100644 --- a/src/MarbleGame.hx +++ b/src/MarbleGame.hx @@ -107,7 +107,8 @@ class MarbleGame { }); canvas.pushDialog(exitGameDlg); } else { - canvas.popDialog(exitGameDlg); + if (exitGameDlg != null) + canvas.popDialog(exitGameDlg); world.setCursorLock(true); } } diff --git a/src/Settings.hx b/src/Settings.hx index 0e246bf3..302c1d7c 100644 --- a/src/Settings.hx +++ b/src/Settings.hx @@ -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 = []; + 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; diff --git a/src/gui/GuiSlider.hx b/src/gui/GuiSlider.hx index 456be3a9..02e28c55 100644 --- a/src/gui/GuiSlider.hx +++ b/src/gui/GuiSlider.hx @@ -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; } }