Skip to content

Commit

Permalink
vsync is default, add hunt random seed option, add fast load option
Browse files Browse the repository at this point in the history
  • Loading branch information
RandomityGuy committed Jul 20, 2023
1 parent 9a76eec commit b0dc369
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 8 deletions.
15 changes: 10 additions & 5 deletions src/Settings.hx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ typedef OptionsSettings = {
var rewindTimescale:Float;
var reflectionDetail:Int;
var maxPixelRatio:Float;
var huntRandom:Bool;
var fastLoad:Bool;
}

typedef ControlsSettings = {
Expand Down Expand Up @@ -121,7 +123,7 @@ class Settings {
musicVolume: 1,
soundVolume: 0.7,
fovX: 90,
frameRateVis: true,
frameRateVis: false,
oobInsults: true,
marbleIndex: 0,
marbleCategoryIndex: 0,
Expand All @@ -132,10 +134,9 @@ class Settings {
rewindTimescale: 1,
reflectionDetail: 3,
maxPixelRatio: 1,
vsync: #if js true #end
#if hl
false
#end
vsync: true,
huntRandom: false,
fastLoad: false
};

public static var controlsSettings:ControlsSettings = {
Expand Down Expand Up @@ -366,6 +367,10 @@ class Settings {
optionsSettings.reflectionDetail = 2;
if (controlsSettings.controllerVerticalCenter == null)
controlsSettings.controllerVerticalCenter = true;
if (controlsSettings.huntRandom == null)
controlsSettings.huntRandom = false;
if (controlsSettings.fastLoad == null)
controlsSettings.fastLoad = false;
#end
if (optionsSettings.maxPixelRatio == 0 #if js || optionsSettings.maxPixelRatio == null #end)
optionsSettings.maxPixelRatio = 1;
Expand Down
47 changes: 46 additions & 1 deletion src/fs/TorqueFileSystem.hx
Original file line number Diff line number Diff line change
@@ -1,9 +1,54 @@
package fs;

import hxd.fs.LocalFileSystem;
import src.Settings;

class TorqueFileEntry extends LocalEntry {
override function load(?onReady:Void->Void):Void {
#if macro
onReady();
#else
if (Settings.optionsSettings.fastLoad)
onReady();
else {
if (onReady != null)
haxe.Timer.delay(onReady, 1);
}
#end
}
}

class TorqueFileSystem extends LocalFileSystem {
#if hl
public function new(dir:String, configuration:String) {
super(dir, configuration);
baseDir = dir;
if (configuration == null)
configuration = "default";

#if (macro && haxe_ver >= 4.0)
var exePath = null;
#elseif (haxe_ver >= 3.3)
var pr = Sys.programPath();
var exePath = pr == null ? null : pr.split("\\").join("/").split("/");
#else
var exePath = Sys.executablePath().split("\\").join("/").split("/");
#end

if (exePath != null)
exePath.pop();
var froot = exePath == null ? baseDir : sys.FileSystem.fullPath(exePath.join("/") + "/" + baseDir);
if (froot == null || !sys.FileSystem.exists(froot) || !sys.FileSystem.isDirectory(froot)) {
froot = sys.FileSystem.fullPath(baseDir);
if (froot == null || !sys.FileSystem.exists(froot) || !sys.FileSystem.isDirectory(froot))
throw "Could not find dir " + dir;
}
baseDir = froot.split("\\").join("/");
if (!StringTools.endsWith(baseDir, "/"))
baseDir += "/";
root = new TorqueFileEntry(this, "root", null, baseDir);
}

override function checkPath(path:String) {
// make sure the file is loaded with correct case !
var baseDir = new haxe.io.Path(path).dir;
Expand Down Expand Up @@ -37,7 +82,7 @@ class TorqueFileSystem extends LocalFileSystem {
return null;
f = f.split("\\").join("/");
if (!check || (sys.FileSystem.exists(f) && checkPath(f))) {
e = new LocalEntry(this, path.split("/").pop(), path, f);
e = new TorqueFileEntry(this, path.split("/").pop(), path, f);
convert.run(e);
if (e.file == null)
e = null;
Expand Down
14 changes: 14 additions & 0 deletions src/gui/MiscOptionsGui.hx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,20 @@ class MiscOptionsGui extends GuiImage {
}, 0.5, 118);
rsOpt.setCurrentOption(Std.int(Util.clamp(Math.floor(((Settings.optionsSettings.rewindTimescale - 0.1) / (1 - 0.1)) * 18), 0, 18)));

var sgOpt = optionCollection.addOption(1, "Seeded Gem Hunt", ["Disabled", "Enabled"], (idx) -> {
Settings.optionsSettings.huntRandom = (idx == 0);
return true;
}, 0.5, 118);
sgOpt.setCurrentOption(Settings.optionsSettings.huntRandom ? 0 : 1);

#if hl
var flOpt = optionCollection.addOption(1, "Fast Loading", ["Disabled", "Enabled"], (idx) -> {
Settings.optionsSettings.fastLoad = (idx == 1);
return true;
}, 0.5, 118);
flOpt.setCurrentOption(Settings.optionsSettings.fastLoad ? 1 : 0);
#end

var bottomBar = new GuiControl();
bottomBar.position = new Vector(0, 590);
bottomBar.extent = new Vector(640, 200);
Expand Down
11 changes: 9 additions & 2 deletions src/modes/HuntMode.hx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import src.Mission;
import mis.MissionElement.MissionElementSpawnSphere;
import src.AudioManager;
import src.ResourceLoader;
import src.Settings;

@:publicFields
class GemSpawnSphere {
Expand Down Expand Up @@ -218,6 +219,10 @@ class HuntMode extends NullMode {
override function onRestart() {
rng.setSeed(100);
rng2.setSeed(100);
if (Settings.optionsSettings.huntRandom) {
rng.setSeed(cast Math.random() * 10000);
rng2.setSeed(cast Math.random() * 10000);
}
setupGems();
points = 0;
@:privateAccess level.playGui.formatGemHuntCounter(points);
Expand Down Expand Up @@ -464,7 +469,9 @@ class HuntMode extends NullMode {
var gemBeam = gemToBeamMap.get(gem);
gemBeam.setHide(false);
}
rng.setSeed(s.rngState);
rng2.setSeed(s.rngState2);
if (!Settings.optionsSettings.huntRandom) {
rng.setSeed(s.rngState);
rng2.setSeed(s.rngState2);
}
}
}

0 comments on commit b0dc369

Please sign in to comment.