finish endgamedlg

This commit is contained in:
RandomityGuy 2022-11-19 12:11:55 +05:30
parent 84af2fa3fb
commit e2eafd3824
7 changed files with 141 additions and 12 deletions

View file

@ -224,6 +224,9 @@ class MarbleGame {
public function playMission(mission:Mission) { public function playMission(mission:Mission) {
canvas.clearContent(); canvas.clearContent();
if (world != null) {
world.dispose();
}
world = new MarbleWorld(scene, scene2d, mission, toRecord); world = new MarbleWorld(scene, scene2d, mission, toRecord);
toRecord = false; toRecord = false;
world.init(); world.init();

View file

@ -29,6 +29,8 @@ class Mission {
public var id:Int; public var id:Int;
public var isClaMission:Bool; public var isClaMission:Bool;
var next:Mission;
var imageResources:Array<Resource<Image>> = []; var imageResources:Array<Resource<Image>> = [];
var imgFileEntry:hxd.fs.FileEntry; var imgFileEntry:hxd.fs.FileEntry;
@ -72,6 +74,10 @@ class Mission {
return mission; return mission;
} }
public function getNextMission() {
return this.next;
}
public function getPreviewImage(onLoaded:h2d.Tile->Void) { public function getPreviewImage(onLoaded:h2d.Tile->Void) {
if (!this.isClaMission) { if (!this.isClaMission) {
var basename = haxe.io.Path.withoutExtension(this.path); var basename = haxe.io.Path.withoutExtension(this.path);

View file

@ -8,6 +8,7 @@ class MissionList {
static var beginnerMissions:Array<Mission>; static var beginnerMissions:Array<Mission>;
static var intermediateMissions:Array<Mission>; static var intermediateMissions:Array<Mission>;
static var advancedMissions:Array<Mission>; static var advancedMissions:Array<Mission>;
static var expertMissions:Array<Mission>;
static var customMissions:Array<Mission>; static var customMissions:Array<Mission>;
static var missions:Map<String, Mission>; static var missions:Map<String, Mission>;
@ -40,14 +41,24 @@ class MissionList {
} }
} }
difficultyMissions.sort((a, b) -> Std.parseInt(a.missionInfo.level) - Std.parseInt(b.missionInfo.level)); difficultyMissions.sort((a, b) -> Std.parseInt(a.missionInfo.level) - Std.parseInt(b.missionInfo.level));
for (i in 0...difficultyMissions.length - 1) {
@:privateAccess difficultyMissions[i].next = difficultyMissions[i + 1];
}
return difficultyMissions; return difficultyMissions;
} }
beginnerMissions = parseDifficulty("beginner"); beginnerMissions = parseDifficulty("beginner");
intermediateMissions = parseDifficulty("intermediate"); intermediateMissions = parseDifficulty("intermediate");
advancedMissions = parseDifficulty("advanced"); advancedMissions = parseDifficulty("advanced");
expertMissions = parseDifficulty("expert");
customMissions = parseDifficulty("expert"); customMissions = parseDifficulty("expert");
@:privateAccess beginnerMissions[beginnerMissions.length - 1].next = intermediateMissions[0];
@:privateAccess intermediateMissions[intermediateMissions.length - 1].next = advancedMissions[0];
@:privateAccess advancedMissions[advancedMissions.length - 1].next = expertMissions[0];
@:privateAccess expertMissions[expertMissions.length - 1].next = beginnerMissions[0];
// parseCLAList(); // parseCLAList();
_build = true; _build = true;

View file

@ -1,5 +1,7 @@
package gui; package gui;
import hxd.BitmapData;
import h2d.Tile;
import src.MarbleGame; import src.MarbleGame;
import src.Settings.Score; import src.Settings.Score;
import src.Settings.Settings; import src.Settings.Settings;
@ -55,23 +57,29 @@ class EndGameGui extends GuiControl {
nextLevel.position = new Vector(326, 307); nextLevel.position = new Vector(326, 307);
nextLevel.extent = new Vector(130, 110); nextLevel.extent = new Vector(130, 110);
var nextLevelPreview = new GuiImage(ResourceLoader.getResource('data/missions/beginner/LearnTheWall-Hit.png', ResourceLoader.getImage, var temprev = new BitmapData(1, 1);
this.imageResources) temprev.setPixel(0, 0, 0);
.toTile()); var tmpprevtile = Tile.fromBitmap(temprev);
var nextLevelPreview = new GuiImage(tmpprevtile);
nextLevelPreview.position = new Vector(-15, 0); nextLevelPreview.position = new Vector(-15, 0);
nextLevelPreview.extent = new Vector(160, 110); nextLevelPreview.extent = new Vector(160, 110);
nextLevel.addChild(nextLevelPreview); nextLevel.addChild(nextLevelPreview);
mission.getNextMission().getPreviewImage(t -> {
nextLevelPreview.bmp.tile = t;
});
var nextLevelBtn = new GuiButton(loadButtonImages('data/ui/endgame/level_window')); var nextLevelBtn = new GuiButton(loadButtonImages('data/ui/endgame/level_window'));
nextLevelBtn.horizSizing = Width; nextLevelBtn.horizSizing = Width;
nextLevelBtn.vertSizing = Height; nextLevelBtn.vertSizing = Height;
nextLevelBtn.position = new Vector(0, 0); nextLevelBtn.position = new Vector(0, 0);
nextLevelBtn.extent = new Vector(130, 110); nextLevelBtn.extent = new Vector(130, 110);
nextLevelBtn.pressedAction = function(self:GuiControl) { nextLevelBtn.pressedAction = function(self:GuiControl) {
// var nextMission = Mission.getNextMission(mission); var nextMission = mission.getNextMission();
// if (nextMission != null) { if (nextMission != null) {
// continueFunc(self); cast(this.parent, Canvas).marbleGame.playMission(nextMission);
// } }
}; };
nextLevel.addChild(nextLevelBtn); nextLevel.addChild(nextLevelBtn);
@ -147,6 +155,36 @@ class EndGameGui extends GuiControl {
egFifthLine.text.filter = new DropShadow(1.414, 0.785, 0x7777777F, 1, 0, 0.4, 1, true); egFifthLine.text.filter = new DropShadow(1.414, 0.785, 0x7777777F, 1, 0, 0.4, 1, true);
pg.addChild(egFifthLine); pg.addChild(egFifthLine);
var egFirstLineScore = new GuiMLText(domcasual24, mlFontLoader);
egFirstLineScore.position = new Vector(475, 150);
egFirstLineScore.extent = new Vector(210, 25);
egFirstLineScore.text.filter = new DropShadow(1.414, 0.785, 0x7777777F, 1, 0, 0.4, 1, true);
pg.addChild(egFirstLineScore);
var egSecondLineScore = new GuiMLText(domcasual24, mlFontLoader);
egSecondLineScore.position = new Vector(476, 178);
egSecondLineScore.extent = new Vector(209, 25);
egSecondLineScore.text.filter = new DropShadow(1.414, 0.785, 0x7777777F, 1, 0, 0.4, 1, true);
pg.addChild(egSecondLineScore);
var egThirdLineScore = new GuiMLText(domcasual24, mlFontLoader);
egThirdLineScore.position = new Vector(476, 206);
egThirdLineScore.extent = new Vector(209, 25);
egThirdLineScore.text.filter = new DropShadow(1.414, 0.785, 0x7777777F, 1, 0, 0.4, 1, true);
pg.addChild(egThirdLineScore);
var egFourthLineScore = new GuiMLText(domcasual24, mlFontLoader);
egFourthLineScore.position = new Vector(476, 234);
egFourthLineScore.extent = new Vector(209, 25);
egFourthLineScore.text.filter = new DropShadow(1.414, 0.785, 0x7777777F, 1, 0, 0.4, 1, true);
pg.addChild(egFourthLineScore);
var egFifthLineScore = new GuiMLText(domcasual24, mlFontLoader);
egFifthLineScore.position = new Vector(476, 262);
egFifthLineScore.extent = new Vector(209, 25);
egFifthLineScore.text.filter = new DropShadow(1.414, 0.785, 0x7777777F, 1, 0, 0.4, 1, true);
pg.addChild(egFifthLineScore);
var egTitleText = new GuiMLText(expo50, mlFontLoader); var egTitleText = new GuiMLText(expo50, mlFontLoader);
egTitleText.text.textColor = 0xffff00; egTitleText.text.textColor = 0xffff00;
egTitleText.text.text = '<font color="#FFFFFF" face="DomCasual64">Your Time:</font>'; egTitleText.text.text = '<font color="#FFFFFF" face="DomCasual64">Your Time:</font>';
@ -201,16 +239,22 @@ class EndGameGui extends GuiControl {
egFourthLine.text.text = '<p align="left"><font color="#A4A4A4">4. </font>${scoreData[3].name}</p>'; egFourthLine.text.text = '<p align="left"><font color="#A4A4A4">4. </font>${scoreData[3].name}</p>';
egFifthLine.text.text = '<p align="left"><font color="#949494">5. </font>${scoreData[4].name}</p>'; egFifthLine.text.text = '<p align="left"><font color="#949494">5. </font>${scoreData[4].name}</p>';
var lineelems = [egFirstLine, egSecondLine, egThirdLine, egFourthLine, egFifthLine]; var lineelems = [
egFirstLineScore,
egSecondLineScore,
egThirdLineScore,
egFourthLineScore,
egFifthLineScore
];
for (i in 0...5) { for (i in 0...5) {
if (scoreData[i].time < mission.ultimateTime) { if (scoreData[i].time < mission.ultimateTime) {
lineelems[i].text.text += '<p align="right"><font color="#FFDD22">${Util.formatTime(scoreData[i].time)}</font></p>'; lineelems[i].text.text = '<font color="#FFDD22">${Util.formatTime(scoreData[i].time)}</font>';
} else { } else {
if (scoreData[i].time < mission.goldTime) { if (scoreData[i].time < mission.goldTime) {
lineelems[i].text.text += '<p align="right"><font color="#CCCCCC">${Util.formatTime(scoreData[i].time)}</font></p>'; lineelems[i].text.text = '<font color="#CCCCCC">${Util.formatTime(scoreData[i].time)}</font>';
} else { } else {
lineelems[i].text.text += '<p align="right">${Util.formatTime(scoreData[i].time)}</p>'; lineelems[i].text.text = '${Util.formatTime(scoreData[i].time)}';
} }
} }
} }
@ -257,7 +301,7 @@ class EndGameGui extends GuiControl {
} }
Settings.save(); Settings.save();
if (idx <= 2) { if (idx <= 4) {
var end = new EnterNameDlg(idx, (name) -> { var end = new EnterNameDlg(idx, (name) -> {
if (scoreSubmitted) if (scoreSubmitted)
return; return;
@ -266,6 +310,24 @@ class EndGameGui extends GuiControl {
scoreData.push(myScore); scoreData.push(myScore);
scoreData.sort((a, b) -> a.time == b.time ? 0 : (a.time > b.time ? 1 : -1)); scoreData.sort((a, b) -> a.time == b.time ? 0 : (a.time > b.time ? 1 : -1));
egFirstLine.text.text = '<p align="left"><font color="#EEC884">1. </font>${scoreData[0].name}</p>';
egSecondLine.text.text = '<p align="left"><font color="#CDCDCD">2. </font>${scoreData[1].name}</p>';
egThirdLine.text.text = '<p align="left"><font color="#C9AFA0">3. </font>${scoreData[2].name}</p>';
egFourthLine.text.text = '<p align="left"><font color="#A4A4A4">4. </font>${scoreData[3].name}</p>';
egFifthLine.text.text = '<p align="left"><font color="#949494">5. </font>${scoreData[4].name}</p>';
for (i in 0...5) {
if (scoreData[i].time < mission.ultimateTime) {
lineelems[i].text.text = '<font color="#FFDD22">${Util.formatTime(scoreData[i].time)}</font>';
} else {
if (scoreData[i].time < mission.goldTime) {
lineelems[i].text.text = '<font color="#CCCCCC">${Util.formatTime(scoreData[i].time)}</font>';
} else {
lineelems[i].text.text = '${Util.formatTime(scoreData[i].time)}';
}
}
}
Settings.saveScore(mission.path, myScore); Settings.saveScore(mission.path, myScore);
scoreSubmitted = true; scoreSubmitted = true;

View file

@ -1,5 +1,7 @@
package gui; package gui;
import shaders.GuiClipFilter;
import h2d.filter.Mask;
import gui.GuiControl.MouseState; import gui.GuiControl.MouseState;
import h2d.Scene; import h2d.Scene;
import h2d.Tile; import h2d.Tile;
@ -12,6 +14,8 @@ class GuiImage extends GuiControl {
public var pressedAction:GuiControl->Void = null; public var pressedAction:GuiControl->Void = null;
public var doClipping:Bool = true;
public function new(texture:Tile) { public function new(texture:Tile) {
super(); super();
this.bmp = new Bitmap(texture); this.bmp = new Bitmap(texture);
@ -19,6 +23,16 @@ class GuiImage extends GuiControl {
public override function render(scene2d:Scene) { public override function render(scene2d:Scene) {
var renderRect = this.getRenderRectangle(); var renderRect = this.getRenderRectangle();
var hittestRect = this.getHitTestRect();
if (doClipping
&& (hittestRect.position.x > renderRect.position.x
|| hittestRect.position.y > renderRect.position.y
|| hittestRect.extent.x < renderRect.extent.x
|| hittestRect.extent.y < renderRect.extent.y)) {
if (bmp.filter == null) {
bmp.filter = new GuiClipFilter(hittestRect);
}
}
bmp.setPosition(Math.floor(renderRect.position.x), Math.floor(renderRect.position.y)); bmp.setPosition(Math.floor(renderRect.position.x), Math.floor(renderRect.position.y));
// bmp.scaleX = renderRect.extent.x / bmp.tile.width; // bmp.scaleX = renderRect.extent.x / bmp.tile.width;
// bmp.scaleY = renderRect.extent.y / bmp.tile.height; // bmp.scaleY = renderRect.extent.y / bmp.tile.height;

View file

@ -164,6 +164,7 @@ class PlayGui {
.toTile()); .toTile());
timerTransparency.position = new Vector(14, -7); timerTransparency.position = new Vector(14, -7);
timerTransparency.extent = new Vector(228, 71); timerTransparency.extent = new Vector(228, 71);
timerTransparency.doClipping = false;
timerCtrl.addChild(timerTransparency); timerCtrl.addChild(timerTransparency);
timerNumbers[0].position = new Vector(23, 0); timerNumbers[0].position = new Vector(23, 0);

View file

@ -0,0 +1,32 @@
package shaders;
import h3d.Vector;
import h2d.Mask;
import h2d.filter.Shader;
import h2d.Object;
import h2d.col.Bounds;
import h2d.col.Point;
import gui.Rect;
import h2d.RenderContext;
import h2d.filter.Filter;
class GuiClipFilter extends Filter {
public var renderRect:Rect;
public function new(rect:Rect) {
super();
this.renderRect = rect;
}
override function draw(ctx:RenderContext, t:h2d.Tile) {
var tout = ctx.textures.allocTileTarget("guiClip", t);
ctx.pushTarget(tout);
ctx.flush();
ctx.clipRenderZone(renderRect.position.x, renderRect.position.y, renderRect.extent.x, renderRect.extent.y);
h3d.pass.Copy.run(t.getTexture(), tout);
ctx.flush();
ctx.popRenderZone();
ctx.popTarget();
return h2d.Tile.fromTexture(tout);
}
}