working level select and play
BIN
data/ui/game/CloudBG.jpg
Normal file
|
After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 4.3 KiB |
|
Before Width: | Height: | Size: 3.9 KiB |
|
Before Width: | Height: | Size: 3.9 KiB |
|
Before Width: | Height: | Size: 5.1 KiB |
|
Before Width: | Height: | Size: 6 KiB |
|
Before Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 6.8 KiB |
|
Before Width: | Height: | Size: 3 KiB |
|
|
@ -1,5 +1,6 @@
|
||||||
package src;
|
package src;
|
||||||
|
|
||||||
|
import gui.LevelSelectGui;
|
||||||
import gui.MainMenuGui;
|
import gui.MainMenuGui;
|
||||||
#if !js
|
#if !js
|
||||||
import gui.ReplayCenterGui;
|
import gui.ReplayCenterGui;
|
||||||
|
|
@ -263,25 +264,26 @@ class MarbleGame {
|
||||||
|
|
||||||
public function quitMission() {
|
public function quitMission() {
|
||||||
Console.log("Quitting mission");
|
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.setCursorLock(false);
|
||||||
|
world.dispose();
|
||||||
|
world = null;
|
||||||
paused = false;
|
paused = false;
|
||||||
if (world.isWatching) {
|
if (watching) {
|
||||||
#if !js
|
#if !js
|
||||||
canvas.setContent(new ReplayCenterGui());
|
canvas.setContent(new ReplayCenterGui());
|
||||||
#else
|
#else
|
||||||
canvas.setContent(new MainMenuGui());
|
canvas.setContent(new MainMenuGui());
|
||||||
#end
|
#end
|
||||||
} else {
|
} else {
|
||||||
if (!world.mission.isClaMission && !world.mission.isCustom) {
|
if (isNotCustom) {
|
||||||
PlayMissionGui.currentCategoryStatic = world.mission.type;
|
PlayMissionGui.currentCategoryStatic = missionType;
|
||||||
}
|
}
|
||||||
var pmg = new PlayMissionGui();
|
var pmg = new LevelSelectGui(LevelSelectGui.currentDifficultyStatic);
|
||||||
PlayMissionGui.currentSelectionStatic = world.mission.index;
|
|
||||||
PlayMissionGui.currentGameStatic = world.mission.game;
|
|
||||||
canvas.setContent(pmg);
|
canvas.setContent(pmg);
|
||||||
}
|
}
|
||||||
world.dispose();
|
|
||||||
world = null;
|
|
||||||
|
|
||||||
Settings.save();
|
Settings.save();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1079,13 +1079,11 @@ class MarbleWorld extends Scheduler {
|
||||||
func(() -> {
|
func(() -> {
|
||||||
lock = false;
|
lock = false;
|
||||||
this._resourcesLoaded++;
|
this._resourcesLoaded++;
|
||||||
this.loadingGui.setProgress((1 - resourceLoadFuncs.length / _loadingLength));
|
|
||||||
});
|
});
|
||||||
#end
|
#end
|
||||||
#if js
|
#if js
|
||||||
func(() -> {
|
func(() -> {
|
||||||
lock = false;
|
lock = false;
|
||||||
this.loadingGui.setProgress((1 - resourceLoadFuncs.length / _loadingLength));
|
|
||||||
this._resourcesLoaded++;
|
this._resourcesLoaded++;
|
||||||
});
|
});
|
||||||
#end
|
#end
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,8 @@ class PreviewWorld extends Scheduler {
|
||||||
|
|
||||||
var sky:Sky;
|
var sky:Sky;
|
||||||
|
|
||||||
|
var itrAddTime:Float = 0;
|
||||||
|
|
||||||
public function new(scene:Scene) {
|
public function new(scene:Scene) {
|
||||||
this.scene = scene;
|
this.scene = scene;
|
||||||
}
|
}
|
||||||
|
|
@ -183,8 +185,15 @@ class PreviewWorld extends Scheduler {
|
||||||
var worker = new ResourceLoaderWorker(onFinish);
|
var worker = new ResourceLoaderWorker(onFinish);
|
||||||
|
|
||||||
worker.addTask(fwd -> addScenery(difficulty, fwd));
|
worker.addTask(fwd -> addScenery(difficulty, fwd));
|
||||||
|
itrAddTime = 0;
|
||||||
for (elem in itrpaths) {
|
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) {
|
for (elem in shapeDbs) {
|
||||||
worker.addTask(fwd -> addStaticShape(cast elem, fwd));
|
worker.addTask(fwd -> addStaticShape(cast elem, fwd));
|
||||||
|
|
@ -192,6 +201,7 @@ class PreviewWorld extends Scheduler {
|
||||||
worker.addTask(fwd -> {
|
worker.addTask(fwd -> {
|
||||||
timeState.timeSinceLoad = 0;
|
timeState.timeSinceLoad = 0;
|
||||||
timeState.dt = 0;
|
timeState.dt = 0;
|
||||||
|
Console.log('ITR ADD TIME: ' + itrAddTime);
|
||||||
fwd();
|
fwd();
|
||||||
});
|
});
|
||||||
worker.run();
|
worker.run();
|
||||||
|
|
@ -238,6 +248,7 @@ class PreviewWorld extends Scheduler {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function destroyAllObjects() {
|
public function destroyAllObjects() {
|
||||||
|
currentMission = null;
|
||||||
for (itr in interiors) {
|
for (itr in interiors) {
|
||||||
itr.dispose();
|
itr.dispose();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
126
src/Sky.hx
|
|
@ -27,6 +27,8 @@ class Sky extends Object {
|
||||||
|
|
||||||
var imageResources:Array<Resource<Image>> = [];
|
var imageResources:Array<Resource<Image>> = [];
|
||||||
|
|
||||||
|
static var cubemapTextureCache:Map<String, Texture> = [];
|
||||||
|
|
||||||
public function new() {
|
public function new() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
@ -111,68 +113,74 @@ class Sky extends Object {
|
||||||
var noSkyTexture = element.useskytextures == "0";
|
var noSkyTexture = element.useskytextures == "0";
|
||||||
|
|
||||||
var worker = new ResourceLoaderWorker(() -> {
|
var worker = new ResourceLoaderWorker(() -> {
|
||||||
var fnames = [];
|
var cubemaptexture:Texture = null;
|
||||||
for (i in 0...6) {
|
if (cubemapTextureCache.exists(dmlPath))
|
||||||
var line = StringTools.trim(lines[i]);
|
cubemaptexture = cubemapTextureCache.get(dmlPath);
|
||||||
var filenames = ResourceLoader.getFullNamesOf(dmlDirectory + '/' + line);
|
else {
|
||||||
if (filenames.length == 0 || noSkyTexture) {
|
var fnames = [];
|
||||||
var pixels = Texture.fromColor(skyColor.toColor()).capturePixels(0, 0);
|
for (i in 0...6) {
|
||||||
skyboxImages.push(pixels);
|
var line = StringTools.trim(lines[i]);
|
||||||
// var tex = new h3d.mat.Texture();
|
var filenames = ResourceLoader.getFullNamesOf(dmlDirectory + '/' + line);
|
||||||
// skyboxImages.push(new BitmapData(128, 128));
|
if (filenames.length == 0 || noSkyTexture) {
|
||||||
fnames.push("");
|
var pixels = Texture.fromColor(skyColor.toColor()).capturePixels(0, 0);
|
||||||
Console.error("Skybox image " + filenames[0] + " does not exist");
|
skyboxImages.push(pixels);
|
||||||
} else {
|
// var tex = new h3d.mat.Texture();
|
||||||
// var pixels = ResourceLoader.getTexture(filenames[0]).resource.capturePixels(0, 0);
|
// skyboxImages.push(new BitmapData(128, 128));
|
||||||
fnames.push(filenames[0]);
|
fnames.push("");
|
||||||
var pixels = ResourceLoader.getImagePixels(filenames[0]);
|
Console.error("Skybox image " + filenames[0] + " does not exist");
|
||||||
skyboxImages.push(pixels);
|
} 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
|
// Handle the bmp files specially to flip y
|
||||||
if (StringTools.endsWith(fnames[0].toLowerCase(), ".bmp")) {
|
if (StringTools.endsWith(fnames[0].toLowerCase(), ".bmp")) {
|
||||||
Util.flipImage(skyboxImages[0], true, true);
|
Util.flipImage(skyboxImages[0], true, true);
|
||||||
} else
|
} else
|
||||||
Util.flipImage(skyboxImages[0], true, false);
|
Util.flipImage(skyboxImages[0], true, false);
|
||||||
if (StringTools.endsWith(fnames[4].toLowerCase(), ".bmp")) {
|
if (StringTools.endsWith(fnames[4].toLowerCase(), ".bmp")) {
|
||||||
Util.flipImage(skyboxImages[4], true, true);
|
Util.flipImage(skyboxImages[4], true, true);
|
||||||
} else
|
} else
|
||||||
Util.flipImage(skyboxImages[4], true, false);
|
Util.flipImage(skyboxImages[4], true, false);
|
||||||
Util.rotateImage(skyboxImages[5], Math.PI);
|
Util.rotateImage(skyboxImages[5], Math.PI);
|
||||||
if (StringTools.endsWith(fnames[5].toLowerCase(), ".bmp")) {
|
if (StringTools.endsWith(fnames[5].toLowerCase(), ".bmp")) {
|
||||||
Util.flipImage(skyboxImages[5], true, true);
|
Util.flipImage(skyboxImages[5], true, true);
|
||||||
} else
|
} else
|
||||||
Util.flipImage(skyboxImages[5], true, false);
|
Util.flipImage(skyboxImages[5], true, false);
|
||||||
Util.rotateImage(skyboxImages[1], -Math.PI / 2);
|
Util.rotateImage(skyboxImages[1], -Math.PI / 2);
|
||||||
if (StringTools.endsWith(fnames[1].toLowerCase(), ".bmp")) {
|
if (StringTools.endsWith(fnames[1].toLowerCase(), ".bmp")) {
|
||||||
// Util.flipImage(skyboxImages[1], true, true);
|
// Util.flipImage(skyboxImages[1], true, true);
|
||||||
} else
|
} else
|
||||||
Util.flipImage(skyboxImages[1], true, false);
|
Util.flipImage(skyboxImages[1], true, false);
|
||||||
Util.rotateImage(skyboxImages[2], Math.PI);
|
Util.rotateImage(skyboxImages[2], Math.PI);
|
||||||
if (StringTools.endsWith(fnames[2].toLowerCase(), ".bmp")) {
|
if (StringTools.endsWith(fnames[2].toLowerCase(), ".bmp")) {
|
||||||
Util.flipImage(skyboxImages[2], true, true);
|
Util.flipImage(skyboxImages[2], true, true);
|
||||||
// Util.flipImage(skyboxImages[2], true, false);
|
// Util.flipImage(skyboxImages[2], true, false);
|
||||||
} else
|
} else
|
||||||
Util.flipImage(skyboxImages[2], true, false);
|
Util.flipImage(skyboxImages[2], true, false);
|
||||||
Util.rotateImage(skyboxImages[3], Math.PI / 2);
|
Util.rotateImage(skyboxImages[3], Math.PI / 2);
|
||||||
if (StringTools.endsWith(fnames[3].toLowerCase(), ".bmp")) {
|
if (StringTools.endsWith(fnames[3].toLowerCase(), ".bmp")) {
|
||||||
// Util.flipImage(skyboxImages[3], true, false);
|
// Util.flipImage(skyboxImages[3], true, false);
|
||||||
// Util.flipImage(skyboxImages[3], false, true);
|
// Util.flipImage(skyboxImages[3], false, true);
|
||||||
} else
|
} else
|
||||||
Util.flipImage(skyboxImages[3], true, false);
|
Util.flipImage(skyboxImages[3], true, false);
|
||||||
|
|
||||||
var cubemaptexture = new Texture(maxheight, maxwidth, [Cube]);
|
cubemaptexture = new Texture(maxheight, maxwidth, [Cube]);
|
||||||
for (i in 0...6) {
|
for (i in 0...6) {
|
||||||
cubemaptexture.uploadPixels(skyboxImages[skyboxIndices[i]], 0, i);
|
cubemaptexture.uploadPixels(skyboxImages[skyboxIndices[i]], 0, i);
|
||||||
|
}
|
||||||
|
cubemapTextureCache.set(dmlPath, cubemaptexture);
|
||||||
}
|
}
|
||||||
onFinish(cubemaptexture);
|
onFinish(cubemaptexture);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -76,6 +76,9 @@ class ExitGameDlg extends GuiImage {
|
||||||
btnList.addButton(3, "Help & Options", (evt) -> {}, 20);
|
btnList.addButton(3, "Help & Options", (evt) -> {}, 20);
|
||||||
btnList.addButton(2, "Leaderboards", (evt) -> {});
|
btnList.addButton(2, "Leaderboards", (evt) -> {});
|
||||||
btnList.addButton(2, "Achievements", (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());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
19
src/gui/GuiLoadAnim.hx
Normal file
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -170,4 +170,9 @@ class GuiXboxOptionsList extends GuiControl {
|
||||||
}
|
}
|
||||||
super.update(dt, mouseState);
|
super.update(dt, mouseState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setCurrentOption(opt:Int) {
|
||||||
|
currentOption = opt;
|
||||||
|
optionText.text.text = options[currentOption];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,50 @@ class LevelSelectGui extends GuiImage {
|
||||||
static var currentDifficultyStatic:String = "beginner";
|
static var currentDifficultyStatic:String = "beginner";
|
||||||
|
|
||||||
public function new(difficulty:String) {
|
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);
|
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) {
|
if (currentDifficultyStatic != difficulty) {
|
||||||
currentSelectionStatic = 0;
|
currentSelectionStatic = 0;
|
||||||
}
|
}
|
||||||
|
|
@ -32,6 +73,10 @@ class LevelSelectGui extends GuiImage {
|
||||||
var misFile = Path.withoutExtension(Path.withoutDirectory(curMission.path));
|
var misFile = Path.withoutExtension(Path.withoutDirectory(curMission.path));
|
||||||
MarbleGame.instance.setPreviewMission(misFile, () -> {
|
MarbleGame.instance.setPreviewMission(misFile, () -> {
|
||||||
lock = false;
|
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");
|
var domcasual32fontdata = ResourceLoader.getFileEntry("data/font/DomCasualD.fnt");
|
||||||
|
|
@ -114,14 +159,6 @@ class LevelSelectGui extends GuiImage {
|
||||||
statIcon.extent = new Vector(20, 20);
|
statIcon.extent = new Vector(20, 20);
|
||||||
levelWnd.addChild(statIcon);
|
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 c0 = 0xEBEBEB;
|
||||||
var c1 = 0x8DFF8D;
|
var c1 = 0x8DFF8D;
|
||||||
var c2 = 0x88BCEE;
|
var c2 = 0x88BCEE;
|
||||||
|
|
@ -151,12 +188,21 @@ class LevelSelectGui extends GuiImage {
|
||||||
function setLevel(idx:Int) {
|
function setLevel(idx:Int) {
|
||||||
if (lock)
|
if (lock)
|
||||||
return false;
|
return false;
|
||||||
|
this.bmp.visible = true;
|
||||||
|
loadAnim.anim.visible = true;
|
||||||
|
loadText.text.visible = true;
|
||||||
|
loadTextBg.text.visible = true;
|
||||||
lock = true;
|
lock = true;
|
||||||
curMission = difficultyMissions[idx];
|
curMission = difficultyMissions[idx];
|
||||||
|
currentSelectionStatic = idx;
|
||||||
var misFile = Path.withoutExtension(Path.withoutDirectory(curMission.path));
|
var misFile = Path.withoutExtension(Path.withoutDirectory(curMission.path));
|
||||||
var mis = difficultyMissions[idx];
|
var mis = difficultyMissions[idx];
|
||||||
MarbleGame.instance.setPreviewMission(misFile, () -> {
|
MarbleGame.instance.setPreviewMission(misFile, () -> {
|
||||||
lock = false;
|
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 myScore = Settings.getScores(mis.path);
|
||||||
var scoreDisp = "None";
|
var scoreDisp = "None";
|
||||||
|
|
@ -180,6 +226,7 @@ class LevelSelectGui extends GuiImage {
|
||||||
levelSelectOpts.horizSizing = Right;
|
levelSelectOpts.horizSizing = Right;
|
||||||
levelSelectOpts.alwaysActive = true;
|
levelSelectOpts.alwaysActive = true;
|
||||||
levelSelectOpts.onChangeFunc = setLevel;
|
levelSelectOpts.onChangeFunc = setLevel;
|
||||||
|
levelSelectOpts.setCurrentOption(currentSelectionStatic);
|
||||||
innerCtrl.addChild(levelSelectOpts);
|
innerCtrl.addChild(levelSelectOpts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,77 +8,50 @@ import src.Settings;
|
||||||
import src.Util;
|
import src.Util;
|
||||||
|
|
||||||
class LoadingGui extends GuiImage {
|
class LoadingGui extends GuiImage {
|
||||||
public var setProgress:Float->Void;
|
|
||||||
|
|
||||||
public function new(missionName:String, game:String) {
|
public function new(missionName:String, game:String) {
|
||||||
function chooseBg() {
|
var res = ResourceLoader.getImage("data/ui/game/CloudBG.jpg").resource.toTile();
|
||||||
if (game == "gold")
|
super(res);
|
||||||
return ResourceLoader.getImage('data/ui/backgrounds/gold/${cast (Math.floor(Util.lerp(1, 12, Math.random())), Int)}.jpg');
|
this.position = new Vector();
|
||||||
if (game == "platinum")
|
this.extent = new Vector(640, 480);
|
||||||
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());
|
|
||||||
this.horizSizing = Width;
|
this.horizSizing = Width;
|
||||||
this.vertSizing = Height;
|
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());
|
var fadeEdge = new GuiImage(ResourceLoader.getResource("data/ui/xbox/BG_fadeOutSoftEdge.png", ResourceLoader.getImage, this.imageResources).toTile());
|
||||||
loadingGui.horizSizing = Center;
|
fadeEdge.position = new Vector(0, 0);
|
||||||
loadingGui.vertSizing = Center;
|
fadeEdge.extent = new Vector(640, 480);
|
||||||
loadingGui.position = new Vector(86, 77);
|
fadeEdge.vertSizing = Height;
|
||||||
loadingGui.extent = new Vector(468, 325);
|
fadeEdge.horizSizing = Width;
|
||||||
|
this.addChild(fadeEdge);
|
||||||
|
|
||||||
function loadButtonImages(path:String) {
|
var arial14fontdata = ResourceLoader.getFileEntry("data/font/Arial Bold.fnt");
|
||||||
var normal = ResourceLoader.getResource('${path}_n.png', ResourceLoader.getImage, this.imageResources).toTile();
|
var arial14b = new BitmapFont(arial14fontdata.entry);
|
||||||
var hover = ResourceLoader.getResource('${path}_h.png', ResourceLoader.getImage, this.imageResources).toTile();
|
@:privateAccess arial14b.loader = ResourceLoader.loader;
|
||||||
var pressed = ResourceLoader.getResource('${path}_d.png', ResourceLoader.getImage, this.imageResources).toTile();
|
var arial14 = arial14b.toSdfFont(cast 21 * Settings.uiScale, h2d.Font.SDFChannel.MultiChannel);
|
||||||
return [normal, hover, pressed];
|
|
||||||
}
|
|
||||||
|
|
||||||
var domcasual32fontdata = ResourceLoader.getFileEntry("data/font/DomCasualD.fnt");
|
var loadAnim = new GuiLoadAnim();
|
||||||
var domcasual32b = new BitmapFont(domcasual32fontdata.entry);
|
loadAnim.position = new Vector(610, 253);
|
||||||
@:privateAccess domcasual32b.loader = ResourceLoader.loader;
|
loadAnim.extent = new Vector(63, 63);
|
||||||
var domcasual32 = domcasual32b.toSdfFont(cast 26 * Settings.uiScale, MultiChannel);
|
loadAnim.horizSizing = Center;
|
||||||
|
loadAnim.vertSizing = Bottom;
|
||||||
|
this.addChild(loadAnim);
|
||||||
|
|
||||||
var mapName = new GuiText(domcasual32);
|
var loadTextBg = new GuiText(arial14);
|
||||||
mapName.position = new Vector(6, 33);
|
loadTextBg.position = new Vector(608, 335);
|
||||||
mapName.extent = new Vector(456, 14);
|
loadTextBg.extent = new Vector(63, 40);
|
||||||
mapName.text.text = missionName;
|
loadTextBg.horizSizing = Center;
|
||||||
mapName.text.textColor = 0;
|
loadTextBg.vertSizing = Bottom;
|
||||||
mapName.justify = Center;
|
loadTextBg.justify = Center;
|
||||||
|
loadTextBg.text.text = "Loading";
|
||||||
|
loadTextBg.text.textColor = 0;
|
||||||
|
this.addChild(loadTextBg);
|
||||||
|
|
||||||
var progress = new GuiProgress();
|
var loadText = new GuiText(arial14);
|
||||||
progress.vertSizing = Top;
|
loadText.position = new Vector(610, 334);
|
||||||
progress.position = new Vector(194, 145);
|
loadText.extent = new Vector(63, 40);
|
||||||
progress.extent = new Vector(225, 56);
|
loadText.horizSizing = Center;
|
||||||
progress.progress = 0.5;
|
loadText.vertSizing = Bottom;
|
||||||
|
loadText.justify = Center;
|
||||||
setProgress = (progressPz) -> {
|
loadText.text.text = "Loading";
|
||||||
progress.progress = progressPz;
|
this.addChild(loadText);
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||