mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2026-04-26 20:51:38 +00:00
impl progress import and export and fix minor things
This commit is contained in:
parent
22842e108a
commit
100bb6e27a
4 changed files with 108 additions and 25 deletions
|
|
@ -109,7 +109,6 @@ class Main extends hxd.App {
|
||||||
ResourceLoader.init(s2d, () -> {
|
ResourceLoader.init(s2d, () -> {
|
||||||
AudioManager.init();
|
AudioManager.init();
|
||||||
AudioManager.playShell();
|
AudioManager.playShell();
|
||||||
Marbleland.init();
|
|
||||||
marbleGame = new MarbleGame(s2d, s3d);
|
marbleGame = new MarbleGame(s2d, s3d);
|
||||||
MarbleGame.canvas.setContent(new MainMenuGui());
|
MarbleGame.canvas.setContent(new MainMenuGui());
|
||||||
VersionGui.checkVersion();
|
VersionGui.checkVersion();
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ class MainMenuGui extends GuiImage {
|
||||||
versionText.vertSizing = Top;
|
versionText.vertSizing = Top;
|
||||||
versionText.position = new Vector(289, 450);
|
versionText.position = new Vector(289, 450);
|
||||||
versionText.extent = new Vector(62, 18);
|
versionText.extent = new Vector(62, 18);
|
||||||
versionText.text.text = "1.1.12";
|
versionText.text.text = MarbleGame.currentVersion;
|
||||||
versionText.text.textColor = 0;
|
versionText.text.textColor = 0;
|
||||||
this.addChild(versionText);
|
this.addChild(versionText);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package gui;
|
package gui;
|
||||||
|
|
||||||
|
import haxe.DynamicAccess;
|
||||||
import gui.GuiControl.MouseState;
|
import gui.GuiControl.MouseState;
|
||||||
import src.AudioManager;
|
import src.AudioManager;
|
||||||
import hxd.Key;
|
import hxd.Key;
|
||||||
|
|
@ -148,14 +149,14 @@ class OptionsDlg extends GuiImage {
|
||||||
|
|
||||||
var vsyncLabel = new GuiText(domcasual32);
|
var vsyncLabel = new GuiText(domcasual32);
|
||||||
vsyncLabel.position = new Vector(12, 120);
|
vsyncLabel.position = new Vector(12, 120);
|
||||||
vsyncLabel.extent = new Vector(146, 261);
|
vsyncLabel.extent = new Vector(146, 271);
|
||||||
vsyncLabel.text.textColor = 0x000000;
|
vsyncLabel.text.textColor = 0x000000;
|
||||||
vsyncLabel.text.text = "VSync:";
|
vsyncLabel.text.text = "VSync:";
|
||||||
vsyncLabel.justify = Right;
|
vsyncLabel.justify = Right;
|
||||||
graphicsPane.addChild(vsyncLabel);
|
graphicsPane.addChild(vsyncLabel);
|
||||||
|
|
||||||
var vsyncButton = new GuiButton(loadButtonImages("data/ui/options/graf_chkbx"));
|
var vsyncButton = new GuiButton(loadButtonImages("data/ui/options/graf_chkbx"));
|
||||||
vsyncButton.position = new Vector(170, 100);
|
vsyncButton.position = new Vector(170, 110);
|
||||||
vsyncButton.extent = new Vector(46, 54);
|
vsyncButton.extent = new Vector(46, 54);
|
||||||
vsyncButton.buttonType = Toggle;
|
vsyncButton.buttonType = Toggle;
|
||||||
graphicsPane.addChild(vsyncButton);
|
graphicsPane.addChild(vsyncButton);
|
||||||
|
|
@ -164,7 +165,7 @@ class OptionsDlg extends GuiImage {
|
||||||
}
|
}
|
||||||
|
|
||||||
var fieldOfViewLabel = new GuiText(domcasual32);
|
var fieldOfViewLabel = new GuiText(domcasual32);
|
||||||
fieldOfViewLabel.position = new Vector(12, 170);
|
fieldOfViewLabel.position = new Vector(12, 180);
|
||||||
fieldOfViewLabel.extent = new Vector(146, 261);
|
fieldOfViewLabel.extent = new Vector(146, 261);
|
||||||
fieldOfViewLabel.text.textColor = 0x000000;
|
fieldOfViewLabel.text.textColor = 0x000000;
|
||||||
fieldOfViewLabel.text.text = "Field of View:";
|
fieldOfViewLabel.text.text = "Field of View:";
|
||||||
|
|
@ -172,12 +173,12 @@ class OptionsDlg extends GuiImage {
|
||||||
graphicsPane.addChild(fieldOfViewLabel);
|
graphicsPane.addChild(fieldOfViewLabel);
|
||||||
|
|
||||||
var fovSlide = new GuiImage(ResourceLoader.getResource("data/ui/options/slider.png", ResourceLoader.getImage, this.imageResources).toTile());
|
var fovSlide = new GuiImage(ResourceLoader.getResource("data/ui/options/slider.png", ResourceLoader.getImage, this.imageResources).toTile());
|
||||||
fovSlide.position = new Vector(170, 163);
|
fovSlide.position = new Vector(170, 173);
|
||||||
fovSlide.extent = new Vector(254, 34);
|
fovSlide.extent = new Vector(254, 34);
|
||||||
graphicsPane.addChild(fovSlide);
|
graphicsPane.addChild(fovSlide);
|
||||||
|
|
||||||
var fovSlider = new GuiSlider(ResourceLoader.getResource("data/ui/options/aud_mus_knb.png", ResourceLoader.getImage, this.imageResources).toTile());
|
var fovSlider = new GuiSlider(ResourceLoader.getResource("data/ui/options/aud_mus_knb.png", ResourceLoader.getImage, this.imageResources).toTile());
|
||||||
fovSlider.position = new Vector(170, 163);
|
fovSlider.position = new Vector(170, 173);
|
||||||
fovSlider.extent = new Vector(250, 34);
|
fovSlider.extent = new Vector(250, 34);
|
||||||
fovSlider.sliderValue = (Settings.optionsSettings.fovX - 60) / (140 - 60);
|
fovSlider.sliderValue = (Settings.optionsSettings.fovX - 60) / (140 - 60);
|
||||||
fovSlider.pressedAction = (sender) -> {
|
fovSlider.pressedAction = (sender) -> {
|
||||||
|
|
@ -872,26 +873,109 @@ Extensions: EAX 2.0, EAX 3.0, EAX Unified, and EAX-AC3";
|
||||||
rewindTabBtn.pressedAction = (sender) -> setTab("Rewind");
|
rewindTabBtn.pressedAction = (sender) -> setTab("Rewind");
|
||||||
mainPane.addChild(rewindTabBtn);
|
mainPane.addChild(rewindTabBtn);
|
||||||
|
|
||||||
// Touch Controls buttons???
|
// Import & Export
|
||||||
if (Util.isTouchDevice()) {
|
|
||||||
var touchControlsTxt = new GuiText(domcasual24);
|
|
||||||
touchControlsTxt.text.text = "Touch Controls:";
|
|
||||||
touchControlsTxt.text.color = new Vector(0, 0, 0);
|
|
||||||
touchControlsTxt.position = new Vector(200, 465);
|
|
||||||
touchControlsTxt.extent = new Vector(200, 40);
|
|
||||||
|
|
||||||
var touchControlsEdit = new GuiButtonText(loadButtonImages("data/ui/options/cntr_cam_dwn"), domcasual24);
|
var importPane = new GuiControl();
|
||||||
touchControlsEdit.position = new Vector(300, 455);
|
importPane.position = new Vector(60, 15);
|
||||||
touchControlsEdit.txtCtrl.text.text = "Edit";
|
importPane.extent = new Vector(520, 580);
|
||||||
touchControlsEdit.setExtent(new Vector(109, 39));
|
importPane.horizSizing = Center;
|
||||||
touchControlsEdit.pressedAction = (sender) -> {
|
importPane.vertSizing = Center;
|
||||||
MarbleGame.canvas.setContent(new TouchCtrlsEditGui());
|
this.addChild(importPane);
|
||||||
}
|
|
||||||
|
|
||||||
mainPane.addChild(touchControlsTxt);
|
var importTxt = new GuiText(domcasual24);
|
||||||
mainPane.addChild(touchControlsEdit);
|
importTxt.text.text = "Progress:";
|
||||||
|
importTxt.text.textColor = 0x000000;
|
||||||
|
importTxt.position = new Vector(180, 505);
|
||||||
|
importTxt.extent = new Vector(200, 40);
|
||||||
|
importTxt.horizSizing = Relative;
|
||||||
|
importTxt.vertSizing = Relative;
|
||||||
|
|
||||||
|
var importBtn = new GuiButtonText(loadButtonImages("data/ui/options/cntr_cam_dwn"), domcasual24);
|
||||||
|
importBtn.position = new Vector(280, 495);
|
||||||
|
importBtn.txtCtrl.text.text = "Import";
|
||||||
|
importBtn.setExtent(new Vector(109, 39));
|
||||||
|
importBtn.pressedAction = (sender) -> {
|
||||||
|
hxd.File.browse((sel) -> {
|
||||||
|
sel.load((data) -> {
|
||||||
|
try {
|
||||||
|
// convert to string
|
||||||
|
var jsonStr = data.toString();
|
||||||
|
// parse JSON
|
||||||
|
var json = haxe.Json.parse(jsonStr);
|
||||||
|
|
||||||
|
var highScoreData:DynamicAccess<Array<Score>> = json.highScores;
|
||||||
|
for (key => value in highScoreData) {
|
||||||
|
Settings.highScores.set(key, value);
|
||||||
|
}
|
||||||
|
var easterEggData:DynamicAccess<Float> = json.easterEggs;
|
||||||
|
if (easterEggData != null) {
|
||||||
|
for (key => value in easterEggData) {
|
||||||
|
Settings.easterEggs.set(key, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MarbleGame.canvas.pushDialog(new MessageBoxOkDlg("Progress data imported successfully!"));
|
||||||
|
Settings.save();
|
||||||
|
} catch (e) {
|
||||||
|
MarbleGame.canvas.pushDialog(new MessageBoxOkDlg("Failed to import progress data: " + e.message));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, {
|
||||||
|
title: "Select a progress file to import",
|
||||||
|
fileTypes: [
|
||||||
|
{name: "JSON files", extensions: ["json"]},
|
||||||
|
{name: "All files", extensions: ["*"]}
|
||||||
|
],
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var exportBtn = new GuiButtonText(loadButtonImages("data/ui/options/cntr_cam_dwn"), domcasual24);
|
||||||
|
exportBtn.position = new Vector(400, 495);
|
||||||
|
exportBtn.txtCtrl.text.text = "Export";
|
||||||
|
exportBtn.setExtent(new Vector(109, 39));
|
||||||
|
exportBtn.pressedAction = (sender) -> {
|
||||||
|
#if sys
|
||||||
|
#if MACOS_BUNDLE
|
||||||
|
// open the finder to that folder
|
||||||
|
Sys.command('open "${Settings.settingsDir}"');
|
||||||
|
#else
|
||||||
|
// Just open the folder in the explorer.exe
|
||||||
|
Sys.command('explorer.exe "${Settings.settingsDir}"');
|
||||||
|
#end
|
||||||
|
MarbleGame.canvas.pushDialog(new MessageBoxOkDlg("The settings.json file contains your progress data. You can copy it to another device or share it with others."));
|
||||||
|
#end
|
||||||
|
#if js
|
||||||
|
// Serialize Settings to JSON
|
||||||
|
var localStorage = js.Browser.getLocalStorage();
|
||||||
|
if (localStorage != null) {
|
||||||
|
var settingsData = localStorage.getItem("MBHaxeSettings");
|
||||||
|
if (settingsData != null) {
|
||||||
|
// Download this
|
||||||
|
var replayBytes = settingsData;
|
||||||
|
var blob = new js.html.Blob([haxe.io.Bytes.ofString(replayBytes).getData()], {
|
||||||
|
type: 'application/octet-stream'
|
||||||
|
});
|
||||||
|
var url = js.html.URL.createObjectURL(blob);
|
||||||
|
var fname = 'settings.json';
|
||||||
|
var element = js.Browser.document.createElement('a');
|
||||||
|
element.setAttribute('href', url);
|
||||||
|
element.setAttribute('download', fname);
|
||||||
|
|
||||||
|
element.style.display = 'none';
|
||||||
|
js.Browser.document.body.appendChild(element);
|
||||||
|
|
||||||
|
element.click();
|
||||||
|
|
||||||
|
js.Browser.document.body.removeChild(element);
|
||||||
|
js.html.URL.revokeObjectURL(url);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#end
|
||||||
|
}
|
||||||
|
|
||||||
|
importPane.addChild(importTxt);
|
||||||
|
importPane.addChild(importBtn);
|
||||||
|
importPane.addChild(exportBtn);
|
||||||
|
|
||||||
setTab = function(tab:String) {
|
setTab = function(tab:String) {
|
||||||
tabs.removeChild(audioTab);
|
tabs.removeChild(audioTab);
|
||||||
tabs.removeChild(controlsTab);
|
tabs.removeChild(controlsTab);
|
||||||
|
|
|
||||||
|
|
@ -100,8 +100,8 @@ class PlayMissionGui extends GuiImage {
|
||||||
tabCustom.position = new Vector(589, 91);
|
tabCustom.position = new Vector(589, 91);
|
||||||
tabCustom.extent = new Vector(52, 198);
|
tabCustom.extent = new Vector(52, 198);
|
||||||
tabCustom.pressedAction = (sender) -> {
|
tabCustom.pressedAction = (sender) -> {
|
||||||
#if (js || android || MACOS_BUNDLE)
|
#if (js || android)
|
||||||
var mbo = new MessageBoxYesNoDlg("The custom level browser is not available in this game.\n Please play Marble Blast Platinum to get access to 5000+ cummunity made customs of both Marble Blast Gold and Marble Blast Platinum. Visit download link?",
|
var mbo = new MessageBoxYesNoDlg("The custom level browser is not available in this game.\n Please play Marble Blast Platinum to get access to 7000+ cummunity made customs of both Marble Blast Gold and Marble Blast Platinum. Visit download link?",
|
||||||
() -> {
|
() -> {
|
||||||
#if sys
|
#if sys
|
||||||
hxd.System.openURL("https://github.com/RandomityGuy/MBHaxe");
|
hxd.System.openURL("https://github.com/RandomityGuy/MBHaxe");
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue