diff --git a/src/Console.hx b/src/Console.hx index fdb7bb65..310e6d00 100644 --- a/src/Console.hx +++ b/src/Console.hx @@ -52,6 +52,10 @@ class Console { entries = []; } + public static function time() { + return haxe.Timer.stamp(); + } + function getTime() { return Std.int((haxe.Timer.stamp() - timeSinceStart) * 1000) / 1000; } diff --git a/src/DifBuilder.hx b/src/DifBuilder.hx index 7ff13c8b..80dd84a2 100644 --- a/src/DifBuilder.hx +++ b/src/DifBuilder.hx @@ -759,7 +759,7 @@ class DifBuilder { return vec; } if (makeCollideable) { - var time = Sys.time(); + var time = Console.time(); for (colliderSurface in colliderSurfaces) { var i = 0; while (i < colliderSurface.indices.length) { @@ -803,10 +803,10 @@ class DifBuilder { i += 3; } } - var interval = Sys.time() - time; + var interval = Console.time() - time; Console.log('Collision build time: ${interval}'); } - var time = Sys.time(); + var time = Console.time(); for (vtex => buckets in vertexBuckets) { for (i in 0...buckets.length) { var bucket = buckets[i]; @@ -845,7 +845,7 @@ class DifBuilder { mats.set(value.texture, [value]); } } - var interval = Sys.time() - time; + var interval = Console.time() - time; Console.log('Normal smoothing build time: ${interval}'); collider.difEdgeMap = difEdges; } @@ -906,14 +906,16 @@ class DifBuilder { loadtexs.push(tex(grp)); } } + #if hl var memStats = hl.Gc.stats(); trace('Interior: ${path} ${memStats.currentMemory} ${memStats.totalAllocated} ${memStats.allocationCount}'); + #end var worker = new ResourceLoaderWorker(() -> { var shaderWorker = new ResourceLoaderWorker(() -> { onFinish(); }); - var time = Sys.time(); + var time = Console.time(); for (grp => tris in mats) { var points = []; var normals = []; @@ -994,7 +996,7 @@ class DifBuilder { material.mainPass.wireframe = true; var mesh = new Mesh(prim, material, itr); } - var interval = Sys.time() - time; + var interval = Console.time() - time; Console.log('Geometry build time ${interval}'); shaderWorker.run(); diff --git a/src/DtsObject.hx b/src/DtsObject.hx index d13407af..6d50afa9 100644 --- a/src/DtsObject.hx +++ b/src/DtsObject.hx @@ -387,13 +387,29 @@ class DtsObject extends GameObject { function postProcessMaterial(matName:String, material:Material) {} + function getPreloadMaterials(dts:DtsFile) { + var texToLoad = []; + var directoryPath = Path.directory(this.dtsPath); + for (i in 0...dts.matNames.length) { + var matName = this.matNameOverride.exists(dts.matNames[i]) ? this.matNameOverride.get(dts.matNames[i]) : dts.matNames[i]; + if (matName.indexOf('/') != -1) + matName = matName.substring(matName.lastIndexOf('/') + 1); + var fullNames = ResourceLoader.getFullNamesOf(directoryPath + '/' + matName).filter(x -> haxe.io.Path.extension(x) != "dts"); + var fullName = fullNames.length > 0 ? fullNames[0] : null; + if (fullName != null) { + texToLoad.push(fullName); + } + } + return texToLoad; + } + function computeMaterials() { var environmentMaterial:Material = null; for (i in 0...dts.matNames.length) { var matName = matNameOverride.exists(dts.matNames[i]) ? matNameOverride.get(dts.matNames[i]) : this.dts.matNames[i]; if (matName.indexOf('/') != -1) - matName = matName.substring(matName.lastIndexOf('/')); + matName = matName.substring(matName.lastIndexOf('/') + 1); var flags = dts.matFlags[i]; var fullNames = ResourceLoader.getFullNamesOf(this.directoryPath + '/' + matName).filter(x -> Path.extension(x) != "dts"); var fullName = fullNames.length > 0 ? fullNames[0] : null; @@ -455,7 +471,7 @@ class DtsObject extends GameObject { #end // Apparently creating these bitmap datas dont work so we'll just get the snag a white texture in the filesystem #if js - var texture:Texture = ResourceLoader.getResource("data/shapes/pads/white.jpg", ResourceLoader.getTexture, this.textureResources); + var texture:Texture = ResourceLoader.getResource("data/shapes/hazards/null.png", ResourceLoader.getTexture, this.textureResources); texture.wrap = Wrap.Repeat; #end Console.warn('Unable to load ${matName}'); diff --git a/src/MarbleGame.hx b/src/MarbleGame.hx index 5362c238..e2c9a274 100644 --- a/src/MarbleGame.hx +++ b/src/MarbleGame.hx @@ -173,6 +173,7 @@ class MarbleGame { JSPlatform.initFullscreenEnforcer(); Window.getInstance().removeEventTarget(@:privateAccess Key.onEvent); + Window.getInstance().addResizeEvent(() -> {}); #end scene2d.addEventListener(e -> { _mouseWheelDelta = e.wheelDelta; diff --git a/src/MarbleWorld.hx b/src/MarbleWorld.hx index 66f402c4..42b965f8 100644 --- a/src/MarbleWorld.hx +++ b/src/MarbleWorld.hx @@ -362,6 +362,7 @@ class MarbleWorld extends Scheduler { var marblefiles = [ "particles/star.png", "particles/smoke.png", + "particles/burst.png", "sound/rolling_hard.wav", "sound/sliding.wav", "sound/use_gyrocopter.wav", @@ -374,11 +375,15 @@ class MarbleWorld extends Scheduler { "sound/bouncehard4.wav", "sound/spawn_alternate.wav", "sound/missinggems.wav", + "sound/level_text.wav", + "sound/level_finish.wav", + "sound/finish.wav", "shapes/images/helicopter.dts", "shapes/images/helicopter.jpg", // These irk us a lot because ifl shit "shapes/items/gem.dts", // Ew ew "shapes/items/gemshine.png", "shapes/items/enviro1.jpg", + "shapes/hazards/null.png" ]; if (this.game == "ultra") { marblefiles.push("shapes/balls/pack1/marble20.normal.png"); @@ -796,18 +801,7 @@ class MarbleWorld extends Scheduler { ResourceLoader.load(obj.dtsPath).entry.load(() -> { var dtsFile = ResourceLoader.loadDts(obj.dtsPath); - var directoryPath = haxe.io.Path.directory(obj.dtsPath); - var texToLoad = []; - for (i in 0...dtsFile.resource.matNames.length) { - var matName = obj.matNameOverride.exists(dtsFile.resource.matNames[i]) ? obj.matNameOverride.get(dtsFile.resource.matNames[i]) : dtsFile.resource.matNames[i]; - if (matName.indexOf('/') != -1) - matName = matName.substring(matName.lastIndexOf('/')); - var fullNames = ResourceLoader.getFullNamesOf(directoryPath + '/' + matName).filter(x -> haxe.io.Path.extension(x) != "dts"); - var fullName = fullNames.length > 0 ? fullNames[0] : null; - if (fullName != null) { - texToLoad.push(fullName); - } - } + var texToLoad = obj.getPreloadMaterials(dtsFile.resource); var worker = new ResourceLoaderWorker(() -> { obj.idInLevel = this.dtsObjects.length; // Set the id of the thing @@ -834,27 +828,7 @@ class MarbleWorld extends Scheduler { }); for (texPath in texToLoad) { - if (haxe.io.Path.extension(texPath) == "ifl") { - if (isTsStatic) - obj.useInstancing = false; - worker.addTask(fwd -> { - parseIfl(texPath, keyframes -> { - var innerWorker = new ResourceLoaderWorker(() -> { - fwd(); - }); - var loadedkf = []; - for (kf in keyframes) { - if (!loadedkf.contains(kf)) { - innerWorker.loadFile(directoryPath + '/' + kf); - loadedkf.push(kf); - } - } - innerWorker.run(); - }); - }); - } else { - worker.loadFile(texPath); - } + worker.loadFile(texPath); } worker.run(); diff --git a/src/MissionList.hx b/src/MissionList.hx index 8b855c1f..5bb5a6d6 100644 --- a/src/MissionList.hx +++ b/src/MissionList.hx @@ -35,30 +35,30 @@ class MissionList { #end var difficultyMissions = []; for (file in difficultyFiles) { - var subfiles = ResourceLoader.fileSystem.dir(file.path); - for (file in subfiles) { - if (file.extension == "mis") { - var misParser = new MisParser(file.getText()); - var mInfo = misParser.parseMissionInfo(); - var mission = Mission.fromMissionInfo(file.path, mInfo); - if (game != "custom") - mission.game = game; - else if (mInfo.game != null && mInfo.game != "") - mission.game = mInfo.game.toLowerCase(); - else - mission.game = game; // Last case scenario - if (game == "custom") - mission.isCustom = true; - // do egg thing - if (StringTools.contains(file.getText().toLowerCase(), 'datablock = "easteregg"')) { // Ew - mission.hasEgg = true; + if (file.isDirectory) + for (sfile in file) { + if (sfile.extension == "mis") { + var misParser = new MisParser(sfile.getText()); + var mInfo = misParser.parseMissionInfo(); + var mission = Mission.fromMissionInfo(sfile.path, mInfo); + if (game != "custom") + mission.game = game; + else if (mInfo.game != null && mInfo.game != "") + mission.game = mInfo.game.toLowerCase(); + else + mission.game = game; // Last case scenario + if (game == "custom") + mission.isCustom = true; + // do egg thing + if (StringTools.contains(sfile.getText().toLowerCase(), 'datablock = "easteregg"')) { // Ew + mission.hasEgg = true; + } + mission.difficultyIndex = difficultyIndex; + missions.set(sfile.path, mission); + missionsFilenameLookup.set(sfile.name.toLowerCase(), mission); + difficultyMissions.push(mission); } - mission.difficultyIndex = difficultyIndex; - missions.set(file.path, mission); - missionsFilenameLookup.set(file.name.toLowerCase(), mission); - difficultyMissions.push(mission); } - } } difficultyMissions.sort((a, b) -> Std.parseInt(a.missionInfo.level) - Std.parseInt(b.missionInfo.level)); diff --git a/src/PreviewWorld.hx b/src/PreviewWorld.hx index e1b763d0..c53c2c67 100644 --- a/src/PreviewWorld.hx +++ b/src/PreviewWorld.hx @@ -188,9 +188,9 @@ class PreviewWorld extends Scheduler { itrAddTime = 0; for (elem in itrpaths) { worker.addTask(fwd -> { - var startTime = Sys.time(); + var startTime = Console.time(); addInteriorFromMis(cast elem, () -> { - itrAddTime += Sys.time() - startTime; + itrAddTime += Console.time() - startTime; fwd(); }); }); @@ -436,18 +436,7 @@ class PreviewWorld extends Scheduler { ResourceLoader.load(obj.dtsPath).entry.load(() -> { var dtsFile = ResourceLoader.loadDts(obj.dtsPath); - var directoryPath = haxe.io.Path.directory(obj.dtsPath); - var texToLoad = []; - for (i in 0...dtsFile.resource.matNames.length) { - var matName = obj.matNameOverride.exists(dtsFile.resource.matNames[i]) ? obj.matNameOverride.get(dtsFile.resource.matNames[i]) : dtsFile.resource.matNames[i]; - if (matName.indexOf('/') != -1) - matName = matName.substring(matName.lastIndexOf('/')); - var fullNames = ResourceLoader.getFullNamesOf(directoryPath + '/' + matName).filter(x -> haxe.io.Path.extension(x) != "dts"); - var fullName = fullNames.length > 0 ? fullNames[0] : null; - if (fullName != null) { - texToLoad.push(fullName); - } - } + var texToLoad = obj.getPreloadMaterials(dtsFile.resource); var worker = new ResourceLoaderWorker(() -> { obj.isTSStatic = isTsStatic; @@ -464,27 +453,7 @@ class PreviewWorld extends Scheduler { }); for (texPath in texToLoad) { - if (haxe.io.Path.extension(texPath) == "ifl") { - if (isTsStatic) - obj.useInstancing = false; - worker.addTask(fwd -> { - parseIfl(texPath, keyframes -> { - var innerWorker = new ResourceLoaderWorker(() -> { - fwd(); - }); - var loadedkf = []; - for (kf in keyframes) { - if (!loadedkf.contains(kf)) { - innerWorker.loadFile(directoryPath + '/' + kf); - loadedkf.push(kf); - } - } - innerWorker.run(); - }); - }); - } else { - worker.loadFile(texPath); - } + worker.loadFile(texPath); } worker.run(); diff --git a/src/ResourceLoader.hx b/src/ResourceLoader.hx index cd9f9c9e..4a676459 100644 --- a/src/ResourceLoader.hx +++ b/src/ResourceLoader.hx @@ -172,6 +172,7 @@ class ResourceLoader { } } var worker = new ResourceLoaderWorker(onFinish); + worker.loadFile('englishStrings.inf'); for (file in toloadfiles) { worker.addTaskParallel((fwd) -> file.load(fwd)); } @@ -180,8 +181,7 @@ class ResourceLoader { static function preloadMusic(onFinish:Void->Void) { var worker = new ResourceLoaderWorker(onFinish); - worker.loadFile("sound/music/shell.ogg"); - worker.loadFile("sound/music/pianoforte.ogg"); + worker.loadFile("sound/music/Tim Trance.ogg"); worker.run(); } diff --git a/src/Settings.hx b/src/Settings.hx index 2da00feb..66927de5 100644 --- a/src/Settings.hx +++ b/src/Settings.hx @@ -367,6 +367,12 @@ class Settings { if (json.gamepad != null) { gamepadSettings = json.gamepad; } + if (gamepadSettings.respawn == null) { + gamepadSettings.respawn = ["back"]; + } + if (gamepadSettings.blast == null) { + gamepadSettings.blast = ["X", "LB", "RB"]; + } if (gamepadSettings.rewind == null) { gamepadSettings.rewind = ["Y"]; } diff --git a/src/shapes/AntiGravity.hx b/src/shapes/AntiGravity.hx index b752b1a9..647317d4 100644 --- a/src/shapes/AntiGravity.hx +++ b/src/shapes/AntiGravity.hx @@ -1,5 +1,6 @@ package shapes; +import dts.DtsFile; import src.ResourceLoader; import mis.MissionElement.MissionElementItem; import src.TimeState; @@ -50,6 +51,13 @@ class AntiGravity extends PowerUp { }); } + override function getPreloadMaterials(dts:dts.DtsFile) { + var mats = super.getPreloadMaterials(dts); + mats.push("data/shapes/items/antigrav_bump.png"); + mats.push("data/shapes/items/antigrav_glow.png"); + return mats; + } + override function postProcessMaterial(matName:String, material:h3d.mat.Material) { if (matName == "antigrav_skin") { var diffuseTex = ResourceLoader.getTexture("data/shapes/items/antigrav_skin.png").resource; diff --git a/src/shapes/Blast.hx b/src/shapes/Blast.hx index 98b3ffbb..56d65a79 100644 --- a/src/shapes/Blast.hx +++ b/src/shapes/Blast.hx @@ -35,6 +35,13 @@ class Blast extends PowerUp { this.level.blastAmount = 1.2; } + override function getPreloadMaterials(dts:dts.DtsFile) { + var mats = super.getPreloadMaterials(dts); + mats.push("data/shapes/images/blast_orbit_bump.png"); + mats.push("data/shapes/items/item_glow.png"); + return mats; + } + override function postProcessMaterial(matName:String, material:h3d.mat.Material) { if (matName == "blast_orbit_skin") { var diffuseTex = ResourceLoader.getTexture("data/shapes/images/blast_orbit_skin.png").resource; diff --git a/src/shapes/BlastWave.hx b/src/shapes/BlastWave.hx index 13fb35e5..1ae94305 100644 --- a/src/shapes/BlastWave.hx +++ b/src/shapes/BlastWave.hx @@ -24,6 +24,13 @@ class BlastWave extends DtsObject { super.update(timeState); } + override function getPreloadMaterials(dts:dts.DtsFile) { + var mats = super.getPreloadMaterials(dts); + mats.push("data/shapes/images/blast_glow.png"); + mats.push("data/shapes/pads/endpad_glow.png"); + return mats; + } + override function postProcessMaterial(matName:String, material:Material) { if (matName == "refract") { var diffuseTex = ResourceLoader.getTexture("data/shapes/images/blast_glow.png").resource; diff --git a/src/shapes/EasterEgg.hx b/src/shapes/EasterEgg.hx index 9b44a2c1..e1f64119 100644 --- a/src/shapes/EasterEgg.hx +++ b/src/shapes/EasterEgg.hx @@ -42,6 +42,12 @@ class EasterEgg extends PowerUp { public function use(timeState:src.TimeState) {} + override function getPreloadMaterials(dts:dts.DtsFile) { + var mats = super.getPreloadMaterials(dts); + mats.push("data/skies/gemCubemapUp.png"); + return mats; + } + override function postProcessMaterial(matName:String, material:h3d.mat.Material) { if (matName == "egg_skin") { var diffuseTex = ResourceLoader.getTexture("data/shapes/items/egg_skin.png").resource; diff --git a/src/shapes/Gem.hx b/src/shapes/Gem.hx index 2e379f5b..5e9b77fd 100644 --- a/src/shapes/Gem.hx +++ b/src/shapes/Gem.hx @@ -66,6 +66,12 @@ class Gem extends DtsObject { this.setOpacity(1); } + override function getPreloadMaterials(dts:dts.DtsFile) { + var mats = super.getPreloadMaterials(dts); + mats.push("data/skies/gemCubemapUp.png"); + return mats; + } + override function postProcessMaterial(matName:String, material:h3d.mat.Material) { if (matName == "red.gem") { var diffuseTex = ResourceLoader.getTexture('data/shapes/items/red.gem.png').resource; diff --git a/src/shapes/Glass.hx b/src/shapes/Glass.hx index c214b1f2..33c7d051 100644 --- a/src/shapes/Glass.hx +++ b/src/shapes/Glass.hx @@ -36,6 +36,14 @@ class Glass extends DtsObject { this.identifier = datablockLowercase; } + override function getPreloadMaterials(dts:dts.DtsFile) { + var mats = super.getPreloadMaterials(dts); + mats.push("data/shapes/structures/glass.png"); + mats.push("data/shapes/structures/glass2.png"); + mats.push("data/shapes/structures/glass.normal.png"); + return mats; + } + override function postProcessMaterial(matName:String, material:Material) { var refractTex = ResourceLoader.getTexture('data/shapes/structures/glass.png').resource; refractTex.wrap = Repeat; diff --git a/src/shapes/MegaMarble.hx b/src/shapes/MegaMarble.hx index b986f596..b96c09bb 100644 --- a/src/shapes/MegaMarble.hx +++ b/src/shapes/MegaMarble.hx @@ -27,6 +27,7 @@ class MegaMarble extends PowerUp { worker.loadFile("sound/mega_bouncehard3.wav"); worker.loadFile("sound/mega_bouncehard4.wav"); worker.loadFile("sound/mega_roll.wav"); + worker.loadFile("sound/MegaShrink.wav"); worker.loadFile("sound/use_mega.wav"); this.pickupSound = ResourceLoader.getResource("data/sound/mega_marble.wav", ResourceLoader.getAudio, this.soundResources); worker.run(); @@ -44,6 +45,13 @@ class MegaMarble extends PowerUp { AudioManager.playSound(ResourceLoader.getResource('data/sound/use_mega.wav', ResourceLoader.getAudio, this.soundResources)); } + override function getPreloadMaterials(dts:dts.DtsFile) { + var mats = super.getPreloadMaterials(dts); + mats.push("data/shapes/images/grow_bump.png"); + mats.push("data/shapes/images/grow_glow.png"); + return mats; + } + override function postProcessMaterial(matName:String, material:h3d.mat.Material) { if (matName == "grow") { var diffuseTex = ResourceLoader.getTexture("data/shapes/images/grow.png").resource; diff --git a/src/shapes/RoundBumper.hx b/src/shapes/RoundBumper.hx index 42d20633..3c85009b 100644 --- a/src/shapes/RoundBumper.hx +++ b/src/shapes/RoundBumper.hx @@ -16,6 +16,13 @@ class RoundBumper extends AbstractBumper { animateSubObjectOpacities = true; } + override function getPreloadMaterials(dts:dts.DtsFile) { + var mats = super.getPreloadMaterials(dts); + mats.push("data/shapes/items/antigrav_glow.png"); + mats.push("data/shapes/images/blastwave.png"); + return mats; + } + override function postProcessMaterial(matName:String, material:h3d.mat.Material) { if (matName == "bumper") { var diffuseTex = ResourceLoader.getTexture("data/shapes/bumpers/bumper.png").resource; diff --git a/src/shapes/SignPlain.hx b/src/shapes/SignPlain.hx index 6052aa01..aa6e4f57 100644 --- a/src/shapes/SignPlain.hx +++ b/src/shapes/SignPlain.hx @@ -25,6 +25,12 @@ class SignPlain extends DtsObject { this.identifier = "SignPlain" + direction; } + override function getPreloadMaterials(dts:dts.DtsFile) { + var mats = super.getPreloadMaterials(dts); + mats.push("data/shapes/signs/arrowsign_post_bump.png"); + return mats; + } + override function postProcessMaterial(matName:String, material:h3d.mat.Material) { if (matName == "arrowsign_arrow") { var diffuseTex = ResourceLoader.getTexture('data/shapes/signs/arrowsign_arrow.png').resource; @@ -133,7 +139,7 @@ class SignPlain extends DtsObject { var diffuseTex = ResourceLoader.getTexture('data/shapes/signs/arrowsign_post.png').resource; diffuseTex.wrap = Repeat; diffuseTex.mipMap = Nearest; - var normalTex = ResourceLoader.getTexture("data/shapes/items/arrowsign_post_bump.png").resource; + var normalTex = ResourceLoader.getTexture("data/shapes/signs/arrowsign_post_bump.png").resource; normalTex.wrap = Repeat; normalTex.mipMap = Nearest; var shader = new shaders.DefaultMaterial(diffuseTex, normalTex, 12, new h3d.Vector(0.8, 0.8, 0.6, 1), 1); diff --git a/src/shapes/StartPad.hx b/src/shapes/StartPad.hx index bcde7a98..62c2e0f8 100644 --- a/src/shapes/StartPad.hx +++ b/src/shapes/StartPad.hx @@ -22,6 +22,12 @@ class StartPad extends DtsObject { doSequenceOnceBeginTime = level.timeState.timeSinceLoad; } + override function getPreloadMaterials(dts:dts.DtsFile) { + var mats = super.getPreloadMaterials(dts); + mats.push("data/shapes/pads/ringnormal.png"); + return mats; + } + override function postProcessMaterial(matName:String, material:h3d.mat.Material) { if (matName == "ringglass") { var diffuseTex = ResourceLoader.getTexture("data/shapes/pads/ringglass.png").resource; diff --git a/src/shapes/SuperJump.hx b/src/shapes/SuperJump.hx index 402b1a12..c4b8f31d 100644 --- a/src/shapes/SuperJump.hx +++ b/src/shapes/SuperJump.hx @@ -79,6 +79,12 @@ class SuperJump extends PowerUp { this.level.deselectPowerUp(); } + override function getPreloadMaterials(dts:dts.DtsFile) { + var mats = super.getPreloadMaterials(dts); + mats.push("data/shapes/items/superjump_bump.png"); + return mats; + } + override function postProcessMaterial(matName:String, material:h3d.mat.Material) { if (matName == "superJump_skin") { var diffuseTex = ResourceLoader.getTexture("data/shapes/items/superjump_skin.png").resource; diff --git a/src/shapes/TimeTravel.hx b/src/shapes/TimeTravel.hx index 9aa2a816..402657d6 100644 --- a/src/shapes/TimeTravel.hx +++ b/src/shapes/TimeTravel.hx @@ -48,6 +48,13 @@ class TimeTravel extends PowerUp { level.addBonusTime(this.timeBonus); } + override function getPreloadMaterials(dts:dts.DtsFile) { + var mats = super.getPreloadMaterials(dts); + mats.push("data/shapes/structures/glass.png"); + mats.push("data/shapes/structures/time.normal.jpg"); + return mats; + } + override function postProcessMaterial(matName:String, material:h3d.mat.Material) { if (matName == "timeTravel_skin") { var diffuseTex = ResourceLoader.getTexture("data/shapes/items/timeTravel_skin.png").resource;