diff --git a/data/ui/game/CloudBG.jpg b/data/ui/game/CloudBG.jpg new file mode 100644 index 00000000..7e639aa3 Binary files /dev/null and b/data/ui/game/CloudBG.jpg differ diff --git a/data/ui/game/blastbar.png b/data/ui/game/blastbar.png deleted file mode 100644 index 114f8337..00000000 Binary files a/data/ui/game/blastbar.png and /dev/null differ diff --git a/data/ui/game/blastbar_bargray.png b/data/ui/game/blastbar_bargray.png deleted file mode 100644 index 374972fa..00000000 Binary files a/data/ui/game/blastbar_bargray.png and /dev/null differ diff --git a/data/ui/game/blastbar_bargreen.png b/data/ui/game/blastbar_bargreen.png deleted file mode 100644 index fb47b7ee..00000000 Binary files a/data/ui/game/blastbar_bargreen.png and /dev/null differ diff --git a/data/ui/game/blastbar_charged.png b/data/ui/game/blastbar_charged.png deleted file mode 100644 index 0159eab8..00000000 Binary files a/data/ui/game/blastbar_charged.png and /dev/null differ diff --git a/data/ui/game/go.png b/data/ui/game/go.png deleted file mode 100644 index 373172b9..00000000 Binary files a/data/ui/game/go.png and /dev/null differ diff --git a/data/ui/game/outofbounds.png b/data/ui/game/outofbounds.png deleted file mode 100644 index 7fc97a34..00000000 Binary files a/data/ui/game/outofbounds.png and /dev/null differ diff --git a/data/ui/game/ready.png b/data/ui/game/ready.png deleted file mode 100644 index cb98e9e4..00000000 Binary files a/data/ui/game/ready.png and /dev/null differ diff --git a/data/ui/game/set.png b/data/ui/game/set.png deleted file mode 100644 index 09a8d263..00000000 Binary files a/data/ui/game/set.png and /dev/null differ diff --git a/data/ui/game/transparency.png b/data/ui/game/transparency.png deleted file mode 100644 index c0890b5f..00000000 Binary files a/data/ui/game/transparency.png and /dev/null differ diff --git a/src/MarbleGame.hx b/src/MarbleGame.hx index 41359bab..3e85c933 100644 --- a/src/MarbleGame.hx +++ b/src/MarbleGame.hx @@ -1,5 +1,6 @@ package src; +import gui.LevelSelectGui; import gui.MainMenuGui; #if !js import gui.ReplayCenterGui; @@ -263,25 +264,26 @@ class MarbleGame { public function quitMission() { Console.log("Quitting mission"); + var watching = world.isWatching; + var missionType = world.mission.type; + var isNotCustom = !world.mission.isClaMission && !world.mission.isCustom; world.setCursorLock(false); + world.dispose(); + world = null; paused = false; - if (world.isWatching) { + if (watching) { #if !js canvas.setContent(new ReplayCenterGui()); #else canvas.setContent(new MainMenuGui()); #end } else { - if (!world.mission.isClaMission && !world.mission.isCustom) { - PlayMissionGui.currentCategoryStatic = world.mission.type; + if (isNotCustom) { + PlayMissionGui.currentCategoryStatic = missionType; } - var pmg = new PlayMissionGui(); - PlayMissionGui.currentSelectionStatic = world.mission.index; - PlayMissionGui.currentGameStatic = world.mission.game; + var pmg = new LevelSelectGui(LevelSelectGui.currentDifficultyStatic); canvas.setContent(pmg); } - world.dispose(); - world = null; Settings.save(); } diff --git a/src/MarbleWorld.hx b/src/MarbleWorld.hx index 0f77254a..f98fc2ea 100644 --- a/src/MarbleWorld.hx +++ b/src/MarbleWorld.hx @@ -1079,13 +1079,11 @@ class MarbleWorld extends Scheduler { func(() -> { lock = false; this._resourcesLoaded++; - this.loadingGui.setProgress((1 - resourceLoadFuncs.length / _loadingLength)); }); #end #if js func(() -> { lock = false; - this.loadingGui.setProgress((1 - resourceLoadFuncs.length / _loadingLength)); this._resourcesLoaded++; }); #end diff --git a/src/PreviewWorld.hx b/src/PreviewWorld.hx index 93c99360..e1b763d0 100644 --- a/src/PreviewWorld.hx +++ b/src/PreviewWorld.hx @@ -66,6 +66,8 @@ class PreviewWorld extends Scheduler { var sky:Sky; + var itrAddTime:Float = 0; + public function new(scene:Scene) { this.scene = scene; } @@ -183,8 +185,15 @@ class PreviewWorld extends Scheduler { var worker = new ResourceLoaderWorker(onFinish); worker.addTask(fwd -> addScenery(difficulty, fwd)); + itrAddTime = 0; for (elem in itrpaths) { - worker.addTask(fwd -> addInteriorFromMis(cast elem, fwd)); + worker.addTask(fwd -> { + var startTime = Sys.time(); + addInteriorFromMis(cast elem, () -> { + itrAddTime += Sys.time() - startTime; + fwd(); + }); + }); } for (elem in shapeDbs) { worker.addTask(fwd -> addStaticShape(cast elem, fwd)); @@ -192,6 +201,7 @@ class PreviewWorld extends Scheduler { worker.addTask(fwd -> { timeState.timeSinceLoad = 0; timeState.dt = 0; + Console.log('ITR ADD TIME: ' + itrAddTime); fwd(); }); worker.run(); @@ -238,6 +248,7 @@ class PreviewWorld extends Scheduler { } public function destroyAllObjects() { + currentMission = null; for (itr in interiors) { itr.dispose(); } diff --git a/src/Sky.hx b/src/Sky.hx index a5773991..268ef509 100644 --- a/src/Sky.hx +++ b/src/Sky.hx @@ -27,6 +27,8 @@ class Sky extends Object { var imageResources:Array> = []; + static var cubemapTextureCache:Map = []; + public function new() { super(); } @@ -111,68 +113,74 @@ class Sky extends Object { var noSkyTexture = element.useskytextures == "0"; var worker = new ResourceLoaderWorker(() -> { - var fnames = []; - for (i in 0...6) { - var line = StringTools.trim(lines[i]); - var filenames = ResourceLoader.getFullNamesOf(dmlDirectory + '/' + line); - if (filenames.length == 0 || noSkyTexture) { - var pixels = Texture.fromColor(skyColor.toColor()).capturePixels(0, 0); - skyboxImages.push(pixels); - // var tex = new h3d.mat.Texture(); - // skyboxImages.push(new BitmapData(128, 128)); - fnames.push(""); - Console.error("Skybox image " + filenames[0] + " does not exist"); - } else { - // var pixels = ResourceLoader.getTexture(filenames[0]).resource.capturePixels(0, 0); - fnames.push(filenames[0]); - var pixels = ResourceLoader.getImagePixels(filenames[0]); - skyboxImages.push(pixels); + var cubemaptexture:Texture = null; + if (cubemapTextureCache.exists(dmlPath)) + cubemaptexture = cubemapTextureCache.get(dmlPath); + else { + var fnames = []; + for (i in 0...6) { + var line = StringTools.trim(lines[i]); + var filenames = ResourceLoader.getFullNamesOf(dmlDirectory + '/' + line); + if (filenames.length == 0 || noSkyTexture) { + var pixels = Texture.fromColor(skyColor.toColor()).capturePixels(0, 0); + skyboxImages.push(pixels); + // var tex = new h3d.mat.Texture(); + // skyboxImages.push(new BitmapData(128, 128)); + fnames.push(""); + Console.error("Skybox image " + filenames[0] + " does not exist"); + } else { + // var pixels = ResourceLoader.getTexture(filenames[0]).resource.capturePixels(0, 0); + fnames.push(filenames[0]); + var pixels = ResourceLoader.getImagePixels(filenames[0]); + skyboxImages.push(pixels); + } + } + var maxwidth = 0; + var maxheight = 0; + for (texture in skyboxImages) { + if (texture.height > maxheight) + maxheight = texture.height; + if (texture.width > maxwidth) + maxwidth = texture.width; } - } - var maxwidth = 0; - var maxheight = 0; - for (texture in skyboxImages) { - if (texture.height > maxheight) - maxheight = texture.height; - if (texture.width > maxwidth) - maxwidth = texture.width; - } - // Handle the bmp files specially to flip y - if (StringTools.endsWith(fnames[0].toLowerCase(), ".bmp")) { - Util.flipImage(skyboxImages[0], true, true); - } else - Util.flipImage(skyboxImages[0], true, false); - if (StringTools.endsWith(fnames[4].toLowerCase(), ".bmp")) { - Util.flipImage(skyboxImages[4], true, true); - } else - Util.flipImage(skyboxImages[4], true, false); - Util.rotateImage(skyboxImages[5], Math.PI); - if (StringTools.endsWith(fnames[5].toLowerCase(), ".bmp")) { - Util.flipImage(skyboxImages[5], true, true); - } else - Util.flipImage(skyboxImages[5], true, false); - Util.rotateImage(skyboxImages[1], -Math.PI / 2); - if (StringTools.endsWith(fnames[1].toLowerCase(), ".bmp")) { - // Util.flipImage(skyboxImages[1], true, true); - } else - Util.flipImage(skyboxImages[1], true, false); - Util.rotateImage(skyboxImages[2], Math.PI); - if (StringTools.endsWith(fnames[2].toLowerCase(), ".bmp")) { - Util.flipImage(skyboxImages[2], true, true); - // Util.flipImage(skyboxImages[2], true, false); - } else - Util.flipImage(skyboxImages[2], true, false); - Util.rotateImage(skyboxImages[3], Math.PI / 2); - if (StringTools.endsWith(fnames[3].toLowerCase(), ".bmp")) { - // Util.flipImage(skyboxImages[3], true, false); - // Util.flipImage(skyboxImages[3], false, true); - } else - Util.flipImage(skyboxImages[3], true, false); + // Handle the bmp files specially to flip y + if (StringTools.endsWith(fnames[0].toLowerCase(), ".bmp")) { + Util.flipImage(skyboxImages[0], true, true); + } else + Util.flipImage(skyboxImages[0], true, false); + if (StringTools.endsWith(fnames[4].toLowerCase(), ".bmp")) { + Util.flipImage(skyboxImages[4], true, true); + } else + Util.flipImage(skyboxImages[4], true, false); + Util.rotateImage(skyboxImages[5], Math.PI); + if (StringTools.endsWith(fnames[5].toLowerCase(), ".bmp")) { + Util.flipImage(skyboxImages[5], true, true); + } else + Util.flipImage(skyboxImages[5], true, false); + Util.rotateImage(skyboxImages[1], -Math.PI / 2); + if (StringTools.endsWith(fnames[1].toLowerCase(), ".bmp")) { + // Util.flipImage(skyboxImages[1], true, true); + } else + Util.flipImage(skyboxImages[1], true, false); + Util.rotateImage(skyboxImages[2], Math.PI); + if (StringTools.endsWith(fnames[2].toLowerCase(), ".bmp")) { + Util.flipImage(skyboxImages[2], true, true); + // Util.flipImage(skyboxImages[2], true, false); + } else + Util.flipImage(skyboxImages[2], true, false); + Util.rotateImage(skyboxImages[3], Math.PI / 2); + if (StringTools.endsWith(fnames[3].toLowerCase(), ".bmp")) { + // Util.flipImage(skyboxImages[3], true, false); + // Util.flipImage(skyboxImages[3], false, true); + } else + Util.flipImage(skyboxImages[3], true, false); - var cubemaptexture = new Texture(maxheight, maxwidth, [Cube]); - for (i in 0...6) { - cubemaptexture.uploadPixels(skyboxImages[skyboxIndices[i]], 0, i); + cubemaptexture = new Texture(maxheight, maxwidth, [Cube]); + for (i in 0...6) { + cubemaptexture.uploadPixels(skyboxImages[skyboxIndices[i]], 0, i); + } + cubemapTextureCache.set(dmlPath, cubemaptexture); } onFinish(cubemaptexture); }); diff --git a/src/gui/ExitGameDlg.hx b/src/gui/ExitGameDlg.hx index 0e703071..9180e4ae 100644 --- a/src/gui/ExitGameDlg.hx +++ b/src/gui/ExitGameDlg.hx @@ -76,6 +76,9 @@ class ExitGameDlg extends GuiImage { btnList.addButton(3, "Help & Options", (evt) -> {}, 20); btnList.addButton(2, "Leaderboards", (evt) -> {}); btnList.addButton(2, "Achievements", (evt) -> {}); - btnList.addButton(4, "Main Menu", (evt) -> yesFunc(btnList)); + btnList.addButton(4, "Main Menu", (evt) -> { + yesFunc(btnList); + MarbleGame.canvas.setContent(new MainMenuGui()); + }); } } diff --git a/src/gui/GuiLoadAnim.hx b/src/gui/GuiLoadAnim.hx new file mode 100644 index 00000000..928516f1 --- /dev/null +++ b/src/gui/GuiLoadAnim.hx @@ -0,0 +1,19 @@ +package gui; + +import src.ResourceLoader; + +class GuiLoadAnim extends GuiAnim { + public function new() { + var img = ResourceLoader.getImage("data/ui/xbox/loadingAnimation.png").resource.toTile(); + var f1 = img.sub(0, 1, 63, 63); + var f2 = img.sub(64, 1, 63, 63); + var f3 = img.sub(0, 65, 63, 63); + var f4 = img.sub(64, 65, 63, 63); + var f5 = img.sub(0, 129, 63, 63); + var f6 = img.sub(64, 129, 63, 63); + var f7 = img.sub(0, 193, 63, 63); + super([f1, f2, f3, f4, f5, f6, f7]); + this.anim.loop = true; + this.anim.speed = 20; + } +} diff --git a/src/gui/GuiXboxOptionsList.hx b/src/gui/GuiXboxOptionsList.hx index f7c35a27..42866ea7 100644 --- a/src/gui/GuiXboxOptionsList.hx +++ b/src/gui/GuiXboxOptionsList.hx @@ -170,4 +170,9 @@ class GuiXboxOptionsList extends GuiControl { } super.update(dt, mouseState); } + + public function setCurrentOption(opt:Int) { + currentOption = opt; + optionText.text.text = options[currentOption]; + } } diff --git a/src/gui/LevelSelectGui.hx b/src/gui/LevelSelectGui.hx index 4ee3d752..be3eaac9 100644 --- a/src/gui/LevelSelectGui.hx +++ b/src/gui/LevelSelectGui.hx @@ -16,9 +16,50 @@ class LevelSelectGui extends GuiImage { static var currentDifficultyStatic:String = "beginner"; public function new(difficulty:String) { - var res = ResourceLoader.getImage("data/ui/xbox/BG_fadeOutSoftEdge.png").resource.toTile(); + var res = ResourceLoader.getImage("data/ui/game/CloudBG.jpg").resource.toTile(); super(res); + var arial14fontdata = ResourceLoader.getFileEntry("data/font/Arial Bold.fnt"); + var arial14b = new BitmapFont(arial14fontdata.entry); + @:privateAccess arial14b.loader = ResourceLoader.loader; + var arial14 = arial14b.toSdfFont(cast 21 * Settings.uiScale, h2d.Font.SDFChannel.MultiChannel); + function mlFontLoader(text:String) { + return arial14; + } + + var fadeEdge = new GuiImage(ResourceLoader.getResource("data/ui/xbox/BG_fadeOutSoftEdge.png", ResourceLoader.getImage, this.imageResources).toTile()); + fadeEdge.position = new Vector(0, 0); + fadeEdge.extent = new Vector(640, 480); + fadeEdge.vertSizing = Height; + fadeEdge.horizSizing = Width; + this.addChild(fadeEdge); + + var loadAnim = new GuiLoadAnim(); + loadAnim.position = new Vector(610, 253); + loadAnim.extent = new Vector(63, 63); + loadAnim.horizSizing = Center; + loadAnim.vertSizing = Bottom; + this.addChild(loadAnim); + + var loadTextBg = new GuiText(arial14); + loadTextBg.position = new Vector(608, 335); + loadTextBg.extent = new Vector(63, 40); + loadTextBg.horizSizing = Center; + loadTextBg.vertSizing = Bottom; + loadTextBg.justify = Center; + loadTextBg.text.text = "Loading"; + loadTextBg.text.textColor = 0; + this.addChild(loadTextBg); + + var loadText = new GuiText(arial14); + loadText.position = new Vector(610, 334); + loadText.extent = new Vector(63, 40); + loadText.horizSizing = Center; + loadText.vertSizing = Bottom; + loadText.justify = Center; + loadText.text.text = "Loading"; + this.addChild(loadText); + if (currentDifficultyStatic != difficulty) { currentSelectionStatic = 0; } @@ -32,6 +73,10 @@ class LevelSelectGui extends GuiImage { var misFile = Path.withoutExtension(Path.withoutDirectory(curMission.path)); MarbleGame.instance.setPreviewMission(misFile, () -> { lock = false; + this.bmp.visible = false; + loadAnim.anim.visible = false; + loadText.text.visible = false; + loadTextBg.text.visible = false; }); var domcasual32fontdata = ResourceLoader.getFileEntry("data/font/DomCasualD.fnt"); @@ -114,14 +159,6 @@ class LevelSelectGui extends GuiImage { statIcon.extent = new Vector(20, 20); levelWnd.addChild(statIcon); - var arial14fontdata = ResourceLoader.getFileEntry("data/font/Arial Bold.fnt"); - var arial14b = new BitmapFont(arial14fontdata.entry); - @:privateAccess arial14b.loader = ResourceLoader.loader; - var arial14 = arial14b.toSdfFont(cast 21 * Settings.uiScale, h2d.Font.SDFChannel.MultiChannel); - function mlFontLoader(text:String) { - return arial14; - } - var c0 = 0xEBEBEB; var c1 = 0x8DFF8D; var c2 = 0x88BCEE; @@ -151,12 +188,21 @@ class LevelSelectGui extends GuiImage { function setLevel(idx:Int) { if (lock) return false; + this.bmp.visible = true; + loadAnim.anim.visible = true; + loadText.text.visible = true; + loadTextBg.text.visible = true; lock = true; curMission = difficultyMissions[idx]; + currentSelectionStatic = idx; var misFile = Path.withoutExtension(Path.withoutDirectory(curMission.path)); var mis = difficultyMissions[idx]; MarbleGame.instance.setPreviewMission(misFile, () -> { lock = false; + this.bmp.visible = false; + loadAnim.anim.visible = false; + loadText.text.visible = false; + loadTextBg.text.visible = false; }); var myScore = Settings.getScores(mis.path); var scoreDisp = "None"; @@ -180,6 +226,7 @@ class LevelSelectGui extends GuiImage { levelSelectOpts.horizSizing = Right; levelSelectOpts.alwaysActive = true; levelSelectOpts.onChangeFunc = setLevel; + levelSelectOpts.setCurrentOption(currentSelectionStatic); innerCtrl.addChild(levelSelectOpts); } } diff --git a/src/gui/LoadingGui.hx b/src/gui/LoadingGui.hx index e75e190b..0273c0fc 100644 --- a/src/gui/LoadingGui.hx +++ b/src/gui/LoadingGui.hx @@ -8,77 +8,50 @@ import src.Settings; import src.Util; class LoadingGui extends GuiImage { - public var setProgress:Float->Void; - public function new(missionName:String, game:String) { - function chooseBg() { - if (game == "gold") - return ResourceLoader.getImage('data/ui/backgrounds/gold/${cast (Math.floor(Util.lerp(1, 12, Math.random())), Int)}.jpg'); - if (game == "platinum") - return ResourceLoader.getImage('data/ui/backgrounds/platinum/${cast (Math.floor(Util.lerp(1, 28, Math.random())), Int)}.jpg'); - if (game == "ultra") - return ResourceLoader.getImage('data/ui/backgrounds/ultra/${cast (Math.floor(Util.lerp(1, 9, Math.random())), Int)}.jpg'); - return ResourceLoader.getImage('data/ui/backgrounds/platinum/${cast (Math.floor(Util.lerp(1, 28, Math.random())), Int)}.jpg'); - } - - var img = chooseBg(); - super(img.resource.toTile()); + var res = ResourceLoader.getImage("data/ui/game/CloudBG.jpg").resource.toTile(); + super(res); + this.position = new Vector(); + this.extent = new Vector(640, 480); this.horizSizing = Width; this.vertSizing = Height; - this.extent = new Vector(640, 480); - this.position = new Vector(); - var loadingGui = new GuiImage(ResourceLoader.getResource("data/ui/loading/loadinggui.png", ResourceLoader.getImage, this.imageResources).toTile()); - loadingGui.horizSizing = Center; - loadingGui.vertSizing = Center; - loadingGui.position = new Vector(86, 77); - loadingGui.extent = new Vector(468, 325); + var fadeEdge = new GuiImage(ResourceLoader.getResource("data/ui/xbox/BG_fadeOutSoftEdge.png", ResourceLoader.getImage, this.imageResources).toTile()); + fadeEdge.position = new Vector(0, 0); + fadeEdge.extent = new Vector(640, 480); + fadeEdge.vertSizing = Height; + fadeEdge.horizSizing = Width; + this.addChild(fadeEdge); - function loadButtonImages(path:String) { - var normal = ResourceLoader.getResource('${path}_n.png', ResourceLoader.getImage, this.imageResources).toTile(); - var hover = ResourceLoader.getResource('${path}_h.png', ResourceLoader.getImage, this.imageResources).toTile(); - var pressed = ResourceLoader.getResource('${path}_d.png', ResourceLoader.getImage, this.imageResources).toTile(); - return [normal, hover, pressed]; - } + var arial14fontdata = ResourceLoader.getFileEntry("data/font/Arial Bold.fnt"); + var arial14b = new BitmapFont(arial14fontdata.entry); + @:privateAccess arial14b.loader = ResourceLoader.loader; + var arial14 = arial14b.toSdfFont(cast 21 * Settings.uiScale, h2d.Font.SDFChannel.MultiChannel); - var domcasual32fontdata = ResourceLoader.getFileEntry("data/font/DomCasualD.fnt"); - var domcasual32b = new BitmapFont(domcasual32fontdata.entry); - @:privateAccess domcasual32b.loader = ResourceLoader.loader; - var domcasual32 = domcasual32b.toSdfFont(cast 26 * Settings.uiScale, MultiChannel); + var loadAnim = new GuiLoadAnim(); + loadAnim.position = new Vector(610, 253); + loadAnim.extent = new Vector(63, 63); + loadAnim.horizSizing = Center; + loadAnim.vertSizing = Bottom; + this.addChild(loadAnim); - var mapName = new GuiText(domcasual32); - mapName.position = new Vector(6, 33); - mapName.extent = new Vector(456, 14); - mapName.text.text = missionName; - mapName.text.textColor = 0; - mapName.justify = Center; + var loadTextBg = new GuiText(arial14); + loadTextBg.position = new Vector(608, 335); + loadTextBg.extent = new Vector(63, 40); + loadTextBg.horizSizing = Center; + loadTextBg.vertSizing = Bottom; + loadTextBg.justify = Center; + loadTextBg.text.text = "Loading"; + loadTextBg.text.textColor = 0; + this.addChild(loadTextBg); - var progress = new GuiProgress(); - progress.vertSizing = Top; - progress.position = new Vector(194, 145); - progress.extent = new Vector(225, 56); - progress.progress = 0.5; - - setProgress = (progressPz) -> { - progress.progress = progressPz; - } - - var cancelButton = new GuiButton(loadButtonImages("data/ui/loading/cancel")); - cancelButton.position = new Vector(333, 243); - cancelButton.extent = new Vector(112, 59); - cancelButton.pressedAction = (sender) -> { - MarbleGame.instance.quitMission(); - } - - var overlay = new GuiImage(ResourceLoader.getResource("data/ui/loading/overlay.png", ResourceLoader.getImage, this.imageResources).toTile()); - overlay.position = new Vector(188, 139); - overlay.extent = new Vector(242, 75); - - loadingGui.addChild(mapName); - loadingGui.addChild(progress); - loadingGui.addChild(cancelButton); - loadingGui.addChild(overlay); - - this.addChild(loadingGui); + var loadText = new GuiText(arial14); + loadText.position = new Vector(610, 334); + loadText.extent = new Vector(63, 40); + loadText.horizSizing = Center; + loadText.vertSizing = Bottom; + loadText.justify = Center; + loadText.text.text = "Loading"; + this.addChild(loadText); } }