mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2025-10-30 08:11:25 +00:00
work a bit on main menu
This commit is contained in:
parent
0bf31fb68c
commit
12fe2fc706
7 changed files with 50 additions and 99 deletions
BIN
data/ui/EngineSplash.png
Normal file
BIN
data/ui/EngineSplash.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 44 KiB |
BIN
data/ui/EngineSplashBG.jpg
Normal file
BIN
data/ui/EngineSplashBG.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 22 KiB |
BIN
data/ui/GG_Logo.png
Normal file
BIN
data/ui/GG_Logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 50 KiB |
BIN
data/ui/PoweredBy.png
Normal file
BIN
data/ui/PoweredBy.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 688 B |
BIN
data/ui/g.png
Normal file
BIN
data/ui/g.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
BIN
data/ui/logo.png
Normal file
BIN
data/ui/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 233 KiB |
|
|
@ -13,15 +13,7 @@ import src.Marbleland;
|
||||||
|
|
||||||
class MainMenuGui extends GuiImage {
|
class MainMenuGui extends GuiImage {
|
||||||
public function new() {
|
public function new() {
|
||||||
function chooseBg() {
|
var img = ResourceLoader.getImage('data/ui/EngineSplashBG.jpg');
|
||||||
var rand = Math.random();
|
|
||||||
if (rand >= 0 && rand <= 0.244)
|
|
||||||
return ResourceLoader.getImage('data/ui/backgrounds/gold/${cast (Math.floor(Util.lerp(1, 12, Math.random())), Int)}.jpg');
|
|
||||||
if (rand > 0.244 && rand <= 0.816)
|
|
||||||
return ResourceLoader.getImage('data/ui/backgrounds/platinum/${cast (Math.floor(Util.lerp(1, 28, Math.random())), Int)}.jpg');
|
|
||||||
return ResourceLoader.getImage('data/ui/backgrounds/ultra/${cast (Math.floor(Util.lerp(1, 9, Math.random())), Int)}.jpg');
|
|
||||||
}
|
|
||||||
var img = chooseBg();
|
|
||||||
super(img.resource.toTile());
|
super(img.resource.toTile());
|
||||||
var domcasual32fontdata = ResourceLoader.getFileEntry("data/font/DomCasualD.fnt");
|
var domcasual32fontdata = ResourceLoader.getFileEntry("data/font/DomCasualD.fnt");
|
||||||
var domcasual32b = new BitmapFont(domcasual32fontdata.entry);
|
var domcasual32b = new BitmapFont(domcasual32fontdata.entry);
|
||||||
|
|
@ -33,82 +25,43 @@ class MainMenuGui extends GuiImage {
|
||||||
this.position = new Vector();
|
this.position = new Vector();
|
||||||
this.extent = new Vector(640, 480);
|
this.extent = new Vector(640, 480);
|
||||||
|
|
||||||
var mainMenuContent = new GuiControl();
|
var scene2d = MarbleGame.canvas.scene2d;
|
||||||
mainMenuContent.horizSizing = Center;
|
|
||||||
mainMenuContent.vertSizing = Center;
|
|
||||||
mainMenuContent.position = new Vector(-130, -110);
|
|
||||||
mainMenuContent.extent = new Vector(900, 700);
|
|
||||||
|
|
||||||
function loadButtonImages(path:String) {
|
var offsetX = (scene2d.width - 1280) / 2;
|
||||||
var normal = ResourceLoader.getResource('${path}_n.png', ResourceLoader.getImage, this.imageResources).toTile();
|
var offsetY = (scene2d.height - 720) / 2;
|
||||||
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 siteButton = new GuiButton(loadButtonImages('data/ui/menu/site'));
|
var subX = 640 - (scene2d.width - offsetX) * 640 / scene2d.width;
|
||||||
siteButton.horizSizing = Right;
|
var subY = 480 - (scene2d.height - offsetY) * 480 / scene2d.height;
|
||||||
siteButton.vertSizing = Top;
|
|
||||||
siteButton.position = new Vector(363, 664);
|
|
||||||
siteButton.extent = new Vector(400, 30);
|
|
||||||
siteButton.pressedAction = (sender) -> {
|
|
||||||
#if sys
|
|
||||||
hxd.System.openURL("https://marbleblast.com");
|
|
||||||
#end
|
|
||||||
#if js
|
|
||||||
js.Browser.window.open("https://marbleblast.com");
|
|
||||||
#end
|
|
||||||
}
|
|
||||||
mainMenuContent.addChild(siteButton);
|
|
||||||
|
|
||||||
var motdButton = new GuiButton(loadButtonImages('data/ui/menu/changelog'));
|
var innerCtrl = new GuiControl();
|
||||||
motdButton.horizSizing = Left;
|
innerCtrl.position = new Vector(offsetX, offsetY);
|
||||||
motdButton.vertSizing = Top;
|
innerCtrl.extent = new Vector(640 - subX, 480 - subY);
|
||||||
motdButton.position = new Vector(706, 536);
|
innerCtrl.horizSizing = Width;
|
||||||
motdButton.extent = new Vector(191, 141);
|
innerCtrl.vertSizing = Height;
|
||||||
motdButton.pressedAction = (sender) -> {
|
this.addChild(innerCtrl);
|
||||||
MarbleGame.canvas.pushDialog(new VersionGui());
|
|
||||||
}
|
|
||||||
mainMenuContent.addChild(motdButton);
|
|
||||||
|
|
||||||
var playButton = new GuiButton(loadButtonImages("data/ui/menu/play"));
|
var logo = new GuiImage(ResourceLoader.getResource('data/ui/logo.png', ResourceLoader.getImage, this.imageResources).toTile());
|
||||||
playButton.position = new Vector(-5, -2);
|
logo.position = new Vector(200, 50);
|
||||||
playButton.extent = new Vector(247, 164);
|
logo.extent = new Vector(512, 400);
|
||||||
playButton.gamepadAccelerator = ["A"];
|
innerCtrl.addChild(logo);
|
||||||
playButton.pressedAction = (sender) -> {
|
|
||||||
|
var glogo = new GuiImage(ResourceLoader.getResource('data/ui/g.png', ResourceLoader.getImage, this.imageResources).toTile());
|
||||||
|
glogo.position = new Vector(240, 536);
|
||||||
|
glogo.extent = new Vector(128, 128);
|
||||||
|
innerCtrl.addChild(glogo);
|
||||||
|
|
||||||
|
var btnList = new GuiXboxList();
|
||||||
|
btnList.position = new Vector(70 - offsetX, 95);
|
||||||
|
btnList.horizSizing = Left;
|
||||||
|
btnList.extent = new Vector(502, 500);
|
||||||
|
innerCtrl.addChild(btnList);
|
||||||
|
|
||||||
|
btnList.addButton(0, "Single Player Game", (sender) -> {
|
||||||
cast(this.parent, Canvas).setContent(new PlayMissionGui());
|
cast(this.parent, Canvas).setContent(new PlayMissionGui());
|
||||||
}
|
});
|
||||||
mainMenuContent.addChild(playButton);
|
btnList.addButton(2, "Leaderboards", (e) -> {}, 20);
|
||||||
|
btnList.addButton(2, "Achievements", (e) -> {});
|
||||||
var lbButton = new GuiImage(ResourceLoader.getResource('data/ui/menu/online_i.png', ResourceLoader.getImage, this.imageResources).toTile());
|
btnList.addButton(3, "Replays", (sender) -> {
|
||||||
lbButton.position = new Vector(-5, 128);
|
|
||||||
lbButton.extent = new Vector(247, 164);
|
|
||||||
mainMenuContent.addChild(lbButton);
|
|
||||||
|
|
||||||
var optionsButton = new GuiButton(loadButtonImages("data/ui/menu/options"));
|
|
||||||
optionsButton.position = new Vector(-5, 258);
|
|
||||||
optionsButton.extent = new Vector(247, 164);
|
|
||||||
optionsButton.pressedAction = (sender) -> {
|
|
||||||
cast(this.parent, Canvas).setContent(new OptionsDlg());
|
|
||||||
}
|
|
||||||
mainMenuContent.addChild(optionsButton);
|
|
||||||
|
|
||||||
var exitButton = new GuiButton(loadButtonImages("data/ui/menu/quit"));
|
|
||||||
exitButton.position = new Vector(-5, 388);
|
|
||||||
exitButton.extent = new Vector(247, 164);
|
|
||||||
exitButton.pressedAction = (sender) -> {
|
|
||||||
#if hl
|
|
||||||
Sys.exit(0);
|
|
||||||
#end
|
|
||||||
};
|
|
||||||
mainMenuContent.addChild(exitButton);
|
|
||||||
|
|
||||||
var replButton = new GuiButton(loadButtonImages("data/ui/menu/replay"));
|
|
||||||
replButton.horizSizing = Left;
|
|
||||||
replButton.vertSizing = Top;
|
|
||||||
replButton.position = new Vector(552, 536);
|
|
||||||
replButton.extent = new Vector(191, 141);
|
|
||||||
replButton.pressedAction = (sender) -> {
|
|
||||||
#if hl
|
#if hl
|
||||||
MarbleGame.canvas.setContent(new ReplayCenterGui());
|
MarbleGame.canvas.setContent(new ReplayCenterGui());
|
||||||
#end
|
#end
|
||||||
|
|
@ -150,27 +103,25 @@ class MainMenuGui extends GuiImage {
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
#end
|
#end
|
||||||
};
|
});
|
||||||
mainMenuContent.addChild(replButton);
|
btnList.addButton(3, "Help & Options", (sender) -> {
|
||||||
|
cast(this.parent, Canvas).setContent(new OptionsDlg());
|
||||||
|
});
|
||||||
|
btnList.addButton(2, "Changelog", (sender) -> {
|
||||||
|
MarbleGame.canvas.pushDialog(new VersionGui());
|
||||||
|
});
|
||||||
|
btnList.addButton(4, "Return to Arcade", (sender) -> {
|
||||||
|
#if hl
|
||||||
|
Sys.exit(0);
|
||||||
|
#end
|
||||||
|
});
|
||||||
|
|
||||||
var helpButton = new GuiButton(loadButtonImages("data/ui/menu/help"));
|
function loadButtonImages(path:String) {
|
||||||
helpButton.horizSizing = Left;
|
var normal = ResourceLoader.getResource('${path}_n.png', ResourceLoader.getImage, this.imageResources).toTile();
|
||||||
helpButton.vertSizing = Top;
|
var hover = ResourceLoader.getResource('${path}_h.png', ResourceLoader.getImage, this.imageResources).toTile();
|
||||||
helpButton.position = new Vector(398, 536);
|
var pressed = ResourceLoader.getResource('${path}_d.png', ResourceLoader.getImage, this.imageResources).toTile();
|
||||||
helpButton.extent = new Vector(191, 141);
|
return [normal, hover, pressed];
|
||||||
helpButton.pressedAction = (sender) -> {
|
|
||||||
MarbleGame.canvas.setContent(new HelpCreditsGui());
|
|
||||||
}
|
}
|
||||||
mainMenuContent.addChild(helpButton);
|
|
||||||
|
|
||||||
this.addChild(mainMenuContent);
|
|
||||||
|
|
||||||
var mbp = new GuiImage(ResourceLoader.getResource("data/ui/menu/mbp.png", ResourceLoader.getImage, this.imageResources).toTile());
|
|
||||||
mbp.horizSizing = Left;
|
|
||||||
mbp.vertSizing = Bottom;
|
|
||||||
mbp.position = new Vector(476, 12);
|
|
||||||
mbp.extent = new Vector(153, 150);
|
|
||||||
this.addChild(mbp);
|
|
||||||
|
|
||||||
var versionText = new GuiMLText(domcasual32, null);
|
var versionText = new GuiMLText(domcasual32, null);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue