make everything use a better performant drop shadow instead, add pre game support, more clientside fixes

This commit is contained in:
RandomityGuy 2024-06-20 18:24:10 +05:30
parent a817d0481b
commit cc57591342
21 changed files with 683 additions and 122 deletions

View file

@ -1,5 +1,6 @@
package src;
import gui.MPPreGameDlg;
import src.Radar;
import rewind.InputRecorder;
import net.NetPacket.ScoreboardPacket;
@ -550,6 +551,15 @@ class MarbleWorld extends Scheduler {
Net.serverInfo.state = "PLAYING";
MasterServerClient.instance.sendServerInfo(Net.serverInfo); // notify the server of the playing state
}
if (this.isMultiplayer) {
// Push the pre - game
showPreGame();
}
}
public function showPreGame() {
MarbleGame.canvas.pushDialog(new MPPreGameDlg());
this.setCursorLock(false);
}
public function addJoiningClient(cc:GameConnection, onAdded:() -> Void) {

View file

@ -96,6 +96,15 @@ typedef GamepadSettings = {
var rewind:Array<String>;
}
typedef ServerSettings = {
var name:String;
var description:String;
var maxPlayers:Int;
var password:String;
var forceSpectators:Bool;
var quickRespawn:Bool;
}
typedef PlayStatistics = {
var oobs:Int;
var respawns:Int;
@ -189,6 +198,15 @@ class Settings {
totalTime: 0,
}
public static var serverSettings:ServerSettings = {
name: "Multiplayer Server",
password: "",
maxPlayers: 8,
description: "My cool server",
forceSpectators: false,
quickRespawn: true
}
public static var levelStatistics:Map<String, PlayStatistics> = [];
public static var highscoreName = "";
@ -244,6 +262,7 @@ class Settings {
touch: touchSettings,
gamepad: gamepadSettings,
stats: playStatistics,
server: serverSettings,
highscoreName: highscoreName,
marbleIndex: optionsSettings.marbleIndex,
marbleSkin: optionsSettings.marbleSkin,
@ -379,6 +398,9 @@ class Settings {
levelStatistics.set(key, value);
}
}
if (json.serverSettings != null) {
serverSettings = json.serverSettings;
}
#if js
if (optionsSettings.marbleIndex == null) {
optionsSettings.marbleIndex = 0;

View file

@ -127,73 +127,133 @@ class EndGameGui extends GuiControl {
egResult.position = new Vector(313, 54);
egResult.extent = new Vector(244, 69);
egResult.text.text = '<font face="DomCasual64" color="#FFFFFF"><p align="right">${Util.formatTime(timeState.gameplayClock)}</p></font>';
egResult.text.filter = new DropShadow(1.414, 0.785, 0, 1, 0, 0.4, 1, true);
egResult.text.dropShadow = {
dx: 1,
dy: 1,
alpha: 0.5,
color: 0
};
pg.addChild(egResult);
var egFirstLine = new GuiMLText(domcasual24, mlFontLoader);
egFirstLine.position = new Vector(340, 150);
egFirstLine.extent = new Vector(210, 25);
egFirstLine.text.filter = new DropShadow(1.414, 0.785, 0x7777777F, 1, 0, 0.4, 1, true);
egFirstLine.text.dropShadow = {
dx: 1,
dy: 1,
alpha: 0.5,
color: 0x777777
};
pg.addChild(egFirstLine);
var egSecondLine = new GuiMLText(domcasual24, mlFontLoader);
egSecondLine.position = new Vector(341, 178);
egSecondLine.extent = new Vector(209, 25);
egSecondLine.text.filter = new DropShadow(1.414, 0.785, 0x7777777F, 1, 0, 0.4, 1, true);
egSecondLine.text.dropShadow = {
dx: 1,
dy: 1,
alpha: 0.5,
color: 0x777777
};
pg.addChild(egSecondLine);
var egThirdLine = new GuiMLText(domcasual24, mlFontLoader);
egThirdLine.position = new Vector(341, 206);
egThirdLine.extent = new Vector(209, 25);
egThirdLine.text.filter = new DropShadow(1.414, 0.785, 0x7777777F, 1, 0, 0.4, 1, true);
egThirdLine.text.dropShadow = {
dx: 1,
dy: 1,
alpha: 0.5,
color: 0x777777
};
pg.addChild(egThirdLine);
var egFourthLine = new GuiMLText(domcasual24, mlFontLoader);
egFourthLine.position = new Vector(341, 234);
egFourthLine.extent = new Vector(209, 25);
egFourthLine.text.filter = new DropShadow(1.414, 0.785, 0x7777777F, 1, 0, 0.4, 1, true);
egFourthLine.text.dropShadow = {
dx: 1,
dy: 1,
alpha: 0.5,
color: 0x777777
};
pg.addChild(egFourthLine);
var egFifthLine = new GuiMLText(domcasual24, mlFontLoader);
egFifthLine.position = new Vector(341, 262);
egFifthLine.extent = new Vector(209, 25);
egFifthLine.text.filter = new DropShadow(1.414, 0.785, 0x7777777F, 1, 0, 0.4, 1, true);
egFifthLine.text.dropShadow = {
dx: 1,
dy: 1,
alpha: 0.5,
color: 0x777777
};
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);
egFirstLineScore.text.dropShadow = {
dx: 1,
dy: 1,
alpha: 0.5,
color: 0x777777
};
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);
egSecondLineScore.text.dropShadow = {
dx: 1,
dy: 1,
alpha: 0.5,
color: 0x777777
};
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);
egThirdLineScore.text.dropShadow = {
dx: 1,
dy: 1,
alpha: 0.5,
color: 0x777777
};
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);
egFourthLineScore.text.dropShadow = {
dx: 1,
dy: 1,
alpha: 0.5,
color: 0x777777
};
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);
egFifthLineScore.text.dropShadow = {
dx: 1,
dy: 1,
alpha: 0.5,
color: 0x777777
};
pg.addChild(egFifthLineScore);
var egTitleText = new GuiMLText(expo50, mlFontLoader);
egTitleText.text.textColor = 0xffff00;
egTitleText.text.text = '<font color="#FFFFFF" face="DomCasual64">Your Time:</font>';
egTitleText.text.filter = new DropShadow(1.414, 0.785, 0, 1, 0, 0.4, 1, true);
egTitleText.text.dropShadow = {
dx: 1,
dy: 1,
alpha: 0.5,
color: 0
};
egTitleText.position = new Vector(34, 54);
egTitleText.extent = new Vector(247, 69);
pg.addChild(egTitleText);
@ -202,7 +262,12 @@ class EndGameGui extends GuiControl {
egTopThreeText.position = new Vector(341, 114);
egTopThreeText.extent = new Vector(209, 34);
egTopThreeText.text.text = '<font face="DomCasual32" color="#FFFFFF">Top 5 Times:</font>'; // Make toggleable 3-5
egTopThreeText.text.filter = new DropShadow(1.414, 0.785, 0, 1, 0, 0.4, 1, true);
egTopThreeText.text.dropShadow = {
dx: 1,
dy: 1,
alpha: 0.5,
color: 0
};
pg.addChild(egTopThreeText);
var text = '<font color="#FFFFFF" face="DomCasual32"><p align="center">';
@ -228,7 +293,12 @@ class EndGameGui extends GuiControl {
var finishMessage = new GuiMLText(expo32, mlFontLoader);
finishMessage.text.textColor = 0x00ff00;
finishMessage.text.text = text;
finishMessage.text.filter = new DropShadow(1, 0.785, 0, 1, 0, 0.4, 1, true);
finishMessage.text.dropShadow = {
dx: 1,
dy: 1,
alpha: 0.5,
color: 0
};
// finishMessage.justify = Center;
finishMessage.position = new Vector(25, 120);
finishMessage.extent = new Vector(293, 211);
@ -274,7 +344,12 @@ class EndGameGui extends GuiControl {
leftColumn.text.lineSpacing = 5;
leftColumn.text.textColor = 0xFFFFFF;
leftColumn.text.text = 'Par Time:<br/>${mission.game == "gold" || mission.game.toLowerCase() == "ultra" ? '<font color="#FFCC00">Gold Time:</font>' : '<font color="#CCCCCC">Platinum Time:</font>'}<br/>${mission.ultimateTime != 0 ? '<font color="#FFDD22">Ultimate Time:</font><br/>' : ''}<font face="Arial14"><br/></font><font color="#FFFFFF" face="DomCasual24">Time Passed:<br/>Clock Bonuses:</font>';
leftColumn.text.filter = new DropShadow(1.414, 0.785, 0x7777777F, 1, 0, 0.4, 1, true);
leftColumn.text.dropShadow = {
dx: 1,
dy: 1,
alpha: 0.5,
color: 0x777777
};
leftColumn.position = new Vector(25, 165);
leftColumn.extent = new Vector(293, 211);
pg.addChild(leftColumn);
@ -286,7 +361,12 @@ class EndGameGui extends GuiControl {
rightColumn.text.lineSpacing = 5;
rightColumn.text.textColor = 0xFFFFFF;
rightColumn.text.text = '${Util.formatTime(mission.qualifyTime == Math.POSITIVE_INFINITY ? 5999.999 : mission.qualifyTime)}<br/><font color="${mission.game == "gold" || mission.game.toLowerCase() == "ultra" ? '#FFCC00' : '#CCCCCC'}">${Util.formatTime(mission.goldTime)}</font><br/>${mission.ultimateTime != 0 ? '<font color="#FFDD22">${Util.formatTime(mission.ultimateTime)}</font><br/>' : ''}<font face="Arial14"><br/></font><font color="#FFFFFF" face="DomCasual24">${Util.formatTime(elapsedTime)}<br/>${Util.formatTime(bonusTime)}</font>';
rightColumn.text.filter = new DropShadow(1.414, 0.785, 0xffffff, 1, 0, 0.4, 1, true);
rightColumn.text.dropShadow = {
dx: 1,
dy: 1,
alpha: 0.5,
color: 0x777777
};
rightColumn.position = new Vector(235, 165);
rightColumn.extent = new Vector(293, 211);
pg.addChild(rightColumn);

View file

@ -87,7 +87,12 @@ class EnterNameDlg extends GuiControl {
var enterNameText = new GuiMLText(domcasual32, mlFontLoader);
enterNameText.text.textColor = 0xFFFFFF;
enterNameText.text.filter = new DropShadow(1.414, 0.785, 0x7777777F, 1, 0, 0.4, 1, true);
enterNameText.text.dropShadow = {
dx: 1,
dy: 1,
alpha: 0.5,
color: 0
};
enterNameText.position = new Vector(37, 23);
enterNameText.extent = new Vector(345, 85);
// enterNameText.justify = Center;

View file

@ -95,15 +95,11 @@ class JoinServerGui extends GuiImage {
});
});
var maxPlayers = 8;
var privateSlots = 0;
var privateGame = false;
var hostBtn = new GuiButton(loadButtonImages("data/ui/mp/join/host"));
hostBtn.position = new Vector(521, 379);
hostBtn.extent = new Vector(93, 45);
hostBtn.pressedAction = (e) -> {
Net.hostServer('${Settings.highscoreName}\'s Server', maxPlayers, privateSlots, privateGame, () -> {
Net.hostServer(Settings.serverSettings.name, Settings.serverSettings.description, Settings.serverSettings.maxPlayers, "", () -> {
MarbleGame.canvas.setContent(new MPPlayMissionGui(true));
});
}
@ -134,7 +130,7 @@ class JoinServerGui extends GuiImage {
// }
}
}, 15000);
Net.joinServer(ourServerList[curSelection].name, false, () -> {
Net.joinServer(ourServerList[curSelection].name, "", () -> {
failed = false;
Net.remoteServerInfo = ourServerList[curSelection];
});
@ -168,7 +164,12 @@ class JoinServerGui extends GuiImage {
titleText.extent = new Vector(647, 30);
titleText.justify = Center;
titleText.text.text = "Join Server";
titleText.text.filter = new DropShadow(1.414, 0.785, 0, 1, 0, 0.4, 1, true);
titleText.text.dropShadow = {
dx: 1,
dy: 1,
alpha: 0.5,
color: 0
};
titleText.text.textColor = 0xFFFFFF;
window.addChild(titleText);
@ -177,7 +178,12 @@ class JoinServerGui extends GuiImage {
serverInfoHeader.extent = new Vector(210, 166);
serverInfoHeader.justify = Center;
serverInfoHeader.text.text = "Select a Server";
serverInfoHeader.text.filter = new DropShadow(1.414, 0.785, 0, 1, 0, 0.4, 1, true);
serverInfoHeader.text.dropShadow = {
dx: 1,
dy: 1,
alpha: 0.5,
color: 0
};
serverInfoHeader.text.textColor = 0xFFFFFF;
window.addChild(serverInfoHeader);

View file

@ -50,7 +50,12 @@ class JukeboxDlg extends GuiImage {
var songTitle = new GuiMLText(markerFelt24, null);
songTitle.position = new Vector(61, 262);
songTitle.extent = new Vector(416, 22);
songTitle.text.filter = new DropShadow(1.414, 0.785, 0x0000007F, 1, 0, 0.4, 1, true);
songTitle.text.dropShadow = {
dx: 1,
dy: 1,
alpha: 0.5,
color: 0
};
songTitle.text.textColor = 0xFFFFFF;
songTitle.text.text = '<p align="center">Title: ${songList[selectedIdx]}</p>';
this.addChild(songTitle);
@ -58,7 +63,12 @@ class JukeboxDlg extends GuiImage {
var songStatus = new GuiMLText(markerFelt24, null);
songStatus.position = new Vector(56, 283);
songStatus.extent = new Vector(421, 22);
songStatus.text.filter = new DropShadow(1.414, 0.785, 0x0000007F, 1, 0, 0.4, 1, true);
songStatus.text.dropShadow = {
dx: 1,
dy: 1,
alpha: 0.5,
color: 0
};
songStatus.text.textColor = 0xFFFFFF;
songStatus.text.text = '<p align="center">${playing ? "Playing" : "Stopped"}</p>';
this.addChild(songStatus);

View file

@ -18,6 +18,13 @@ class MPExitGameDlg extends GuiControl {
this.extent = new Vector(640, 480);
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];
}
function loadButtonImagesExt(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();
@ -32,7 +39,7 @@ class MPExitGameDlg extends GuiControl {
dialogImg.extent = new Vector(347, 250);
this.addChild(dialogImg);
var partialRestart = new GuiButton(loadButtonImages("data/ui/mp/exit/partial"));
var partialRestart = new GuiButton(loadButtonImagesExt("data/ui/mp/exit/partial"));
partialRestart.position = new Vector(133, 80);
partialRestart.extent = new Vector(94, 45);
partialRestart.vertSizing = Top;
@ -55,7 +62,7 @@ class MPExitGameDlg extends GuiControl {
resumeBtn.pressedAction = (e) -> resumeFunc();
dialogImg.addChild(resumeBtn);
var serverSettingsBtn = new GuiButton(loadButtonImages("data/ui/mp/play/settings"));
var serverSettingsBtn = new GuiButton(loadButtonImagesExt("data/ui/mp/play/settings"));
serverSettingsBtn.position = new Vector(195, 184);
serverSettingsBtn.extent = new Vector(45, 45);
serverSettingsBtn.vertSizing = Top;
@ -67,7 +74,7 @@ class MPExitGameDlg extends GuiControl {
serverSettingsBtn.disabled = true;
}
var kickBtn = new GuiButton(loadButtonImages("data/ui/mp/play/kick"));
var kickBtn = new GuiButton(loadButtonImagesExt("data/ui/mp/play/kick"));
kickBtn.position = new Vector(108, 184);
kickBtn.extent = new Vector(45, 45);
kickBtn.vertSizing = Top;
@ -82,7 +89,7 @@ class MPExitGameDlg extends GuiControl {
quickspawnBtn.vertSizing = Top;
dialogImg.addChild(quickspawnBtn);
var completeRestart = new GuiButton(loadButtonImages("data/ui/mp/exit/complete"));
var completeRestart = new GuiButton(loadButtonImagesExt("data/ui/mp/exit/complete"));
completeRestart.position = new Vector(224, 80);
completeRestart.extent = new Vector(104, 45);
completeRestart.vertSizing = Top;
@ -102,7 +109,12 @@ class MPExitGameDlg extends GuiControl {
exitTitle.extent = new Vector(331, 30);
exitTitle.justify = Center;
exitTitle.text.text = "Ingame Options";
exitTitle.text.filter = new DropShadow(1.414, 0.785, 0x0000000F, 1, 0, 0.4, 1, true);
exitTitle.text.dropShadow = {
dx: 1,
dy: 1,
alpha: 0.5,
color: 0
};
dialogImg.addChild(exitTitle);
var restartTitle = new GuiText(markerFelt32);
@ -110,7 +122,12 @@ class MPExitGameDlg extends GuiControl {
restartTitle.extent = new Vector(114, 14);
restartTitle.justify = Center;
restartTitle.text.text = "Restart:";
restartTitle.text.filter = new DropShadow(1.414, 0.785, 0x0000000F, 1, 0, 0.4, 1, true);
restartTitle.text.dropShadow = {
dx: 1,
dy: 1,
alpha: 0.5,
color: 0
};
dialogImg.addChild(restartTitle);
var jukeboxButton = new GuiButton(loadButtonImages("data/ui/jukebox/jb_pausemenu"));

View file

@ -68,7 +68,12 @@ class MPMarbleSelectGui extends GuiImage {
var titleText = new GuiMLText(markerFelt28, null);
titleText.text.textColor = 0xFFFFFF;
titleText.text.filter = new DropShadow(1.414, 0.785, 0, 1, 0x0000007F, 0.4, 1, true);
titleText.text.dropShadow = {
dx: 1,
dy: 1,
alpha: 0.5,
color: 0
};
titleText.horizSizing = Center;
titleText.vertSizing = Bottom;
titleText.position = new Vector(140, 67);
@ -78,7 +83,12 @@ class MPMarbleSelectGui extends GuiImage {
var marbleText = new GuiMLText(markerFelt24, null);
marbleText.text.textColor = 0xFFFFFF;
marbleText.text.filter = new DropShadow(1.414, 0.785, 0, 1, 0x0000007F, 0.4, 1, true);
marbleText.text.dropShadow = {
dx: 1,
dy: 1,
alpha: 0.5,
color: 0
};
marbleText.horizSizing = Center;
marbleText.vertSizing = Bottom;
marbleText.position = new Vector(86, 243);

View file

@ -158,19 +158,22 @@ class MPPlayMissionGui extends GuiImage {
searchBtn.pressedAction = (e) -> {
MarbleGame.canvas.pushDialog(new MPSearchGui(false));
}
if (Net.isHost)
window.addChild(searchBtn);
var kickBtn = new GuiButton(loadButtonImages("data/ui/mp/play/kick"));
kickBtn.position = new Vector(304, 514);
kickBtn.extent = new Vector(44, 44);
if (Net.isHost)
window.addChild(kickBtn);
var serverSettingsBtn = new GuiButton(loadButtonImages("data/ui/mp/play/settings"));
var serverSettingsBtn = new GuiButton(loadButtonImagesExt("data/ui/mp/play/settings"));
serverSettingsBtn.position = new Vector(157, 514);
serverSettingsBtn.extent = new Vector(44, 44);
serverSettingsBtn.pressedAction = (e) -> {
MarbleGame.canvas.pushDialog(new MPServerDlg());
}
if (Net.isHost)
window.addChild(serverSettingsBtn);
var marbleSelectBtn = new GuiButton(loadButtonImages("data/ui/mp/play/marble"));
@ -213,6 +216,8 @@ class MPPlayMissionGui extends GuiImage {
difficultySelector.pressedAction = (e) -> {
MarbleGame.canvas.pushDialog(difficultyPopover);
};
else
difficultySelector.disabled = true;
window.addChild(difficultySelector);
var difficultyCloseButton = new GuiButton(loadButtonImages("data/ui/mp/play/difficultymenu"));
@ -305,14 +310,24 @@ class MPPlayMissionGui extends GuiImage {
var pmDesc = new GuiMLText(markerFelt18, mlFontLoader);
pmDesc.position = new Vector(0, 0);
pmDesc.extent = new Vector(427, 99);
pmDesc.text.filter = new DropShadow(1.414, 0.785, 0x0000000F, 1, 0, 0.4, 1, true);
pmDesc.text.dropShadow = {
dx: 1,
dy: 1,
alpha: 0.5,
color: 0
};
pmDesc.text.lineSpacing = -1;
pmDescContainer.addChild(pmDesc);
var parTime = new GuiMLText(markerFelt18, mlFontLoader);
parTime.position = new Vector(43, 190);
parTime.extent = new Vector(416, 44);
parTime.text.filter = new DropShadow(1.414, 0.785, 0x0000000F, 1, 0, 0.4, 1, true);
parTime.text.dropShadow = {
dx: 1,
dy: 1,
alpha: 0.5,
color: 0
};
parTime.text.lineSpacing = -1;
window.addChild(parTime);
@ -341,7 +356,12 @@ class MPPlayMissionGui extends GuiImage {
playerListTitle.text.text = "Players";
playerListTitle.text.textColor = 0xBDCFE4;
playerListTitle.justify = Center;
playerListTitle.text.filter = new DropShadow(1.414, 0.785, 0x0000000F, 1, 0, 0.4, 1, true);
playerListTitle.text.dropShadow = {
dx: 1,
dy: 1,
alpha: 0.5,
color: 0
};
playersBox.addChild(playerListTitle);
this.addChild(window);

200
src/gui/MPPreGameDlg.hx Normal file
View file

@ -0,0 +1,200 @@
package gui;
import h2d.filter.DropShadow;
import net.Net;
import src.MarbleGame;
import hxd.res.BitmapFont;
import h3d.Vector;
import src.ResourceLoader;
import src.Settings;
class MPPreGameDlg extends GuiControl {
public function new() {
super();
this.horizSizing = Width;
this.vertSizing = Height;
this.position = new Vector();
this.extent = new Vector(640, 480);
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];
}
function loadButtonImagesExt(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();
var disabled = ResourceLoader.getResource('${path}_i.png', ResourceLoader.getImage, this.imageResources).toTile();
return [normal, hover, pressed, disabled];
}
var markerFelt32fontdata = ResourceLoader.getFileEntry("data/font/MarkerFelt.fnt");
var markerFelt32b = new BitmapFont(markerFelt32fontdata.entry);
@:privateAccess markerFelt32b.loader = ResourceLoader.loader;
var markerFelt32 = markerFelt32b.toSdfFont(cast 26 * Settings.uiScale, MultiChannel);
var markerFelt24 = markerFelt32b.toSdfFont(cast 20 * Settings.uiScale, MultiChannel);
var markerFelt20 = markerFelt32b.toSdfFont(cast 18.5 * Settings.uiScale, MultiChannel);
var markerFelt18 = markerFelt32b.toSdfFont(cast 17 * Settings.uiScale, MultiChannel);
var markerFelt26 = markerFelt32b.toSdfFont(cast 22 * Settings.uiScale, MultiChannel);
var dialogImg = new GuiImage(ResourceLoader.getResource("data/ui/mp/pre/window.png", ResourceLoader.getImage, this.imageResources).toTile());
dialogImg.horizSizing = Center;
dialogImg.vertSizing = Center;
dialogImg.position = new Vector(0, 0);
dialogImg.extent = new Vector(640, 480);
this.addChild(dialogImg);
var leaveBtn = new GuiButton(loadButtonImages("/data/ui/mp/pre/leave"));
leaveBtn.horizSizing = Left;
leaveBtn.vertSizing = Top;
leaveBtn.position = new Vector(499, 388);
leaveBtn.extent = new Vector(94, 45);
dialogImg.addChild(leaveBtn);
var playBtn = new GuiButton(loadButtonImages("/data/ui/mp/pre/play"));
playBtn.horizSizing = Right;
playBtn.vertSizing = Top;
playBtn.position = new Vector(406, 388);
playBtn.extent = new Vector(94, 45);
playBtn.buttonType = Toggle;
dialogImg.addChild(playBtn);
var readyBtn = new GuiButton(loadButtonImages("/data/ui/mp/pre/ready"));
readyBtn.horizSizing = Right;
readyBtn.vertSizing = Top;
readyBtn.position = new Vector(53, 394);
readyBtn.extent = new Vector(133, 33);
readyBtn.buttonType = Toggle;
dialogImg.addChild(readyBtn);
var kickBtn = new GuiButton(loadButtonImages("/data/ui/mp/play/kick"));
kickBtn.horizSizing = Right;
kickBtn.vertSizing = Bottom;
kickBtn.position = new Vector(360, 388);
kickBtn.extent = new Vector(45, 45);
if (Net.isHost)
dialogImg.addChild(kickBtn);
var spectateBtn = new GuiButton(loadButtonImages("/data/ui/mp/pre/spectate"));
spectateBtn.horizSizing = Right;
spectateBtn.vertSizing = Top;
spectateBtn.position = new Vector(190, 394);
spectateBtn.extent = new Vector(127, 33);
dialogImg.addChild(spectateBtn);
var serverTitle = new GuiText(markerFelt24);
serverTitle.text.textColor = 0xFFFFFF;
serverTitle.position = new Vector(60, 59);
serverTitle.extent = new Vector(525, 30);
serverTitle.text.text = Net.isHost ? Settings.serverSettings.name : Net.connectedServerInfo.name;
serverTitle.text.dropShadow = {
dx: 1,
dy: 1,
alpha: 0.5,
color: 0
};
serverTitle.justify = Center;
dialogImg.addChild(serverTitle);
var serverDesc = new GuiText(markerFelt24);
serverDesc.text.textColor = 0xFFFFFF;
serverDesc.position = new Vector(60, 92);
serverDesc.extent = new Vector(525, 66);
serverDesc.text.text = Net.isHost ? Settings.serverSettings.description : Net.connectedServerInfo.description;
serverDesc.text.dropShadow = {
dx: 1,
dy: 1,
alpha: 0.5,
color: 0
};
serverDesc.justify = Center;
dialogImg.addChild(serverDesc);
var levelName = new GuiText(markerFelt24);
levelName.text.textColor = 0xFFFFFF;
levelName.position = new Vector(60, 158);
levelName.extent = new Vector(525, 22);
levelName.text.text = MarbleGame.instance.world.mission.title;
levelName.text.dropShadow = {
dx: 1,
dy: 1,
alpha: 0.5,
color: 0
};
dialogImg.addChild(levelName);
var levelDesc = new GuiText(markerFelt18);
levelDesc.text.textColor = 0xFFFFFF;
levelDesc.position = new Vector(60, 185);
levelDesc.extent = new Vector(516, 63);
levelDesc.text.text = MarbleGame.instance.world.mission.description;
levelDesc.text.dropShadow = {
dx: 1,
dy: 1,
alpha: 0.5,
color: 0
};
dialogImg.addChild(levelDesc);
var playerTitle = new GuiText(markerFelt18);
playerTitle.text.textColor = 0xDDDDEE;
playerTitle.position = new Vector(60, 263);
playerTitle.extent = new Vector(525, 14);
playerTitle.text.text = "Player Status";
playerTitle.text.dropShadow = {
dx: 1,
dy: 1,
alpha: 0.5,
color: 0
};
dialogImg.addChild(playerTitle);
var playerListContainer = new GuiScrollCtrl(ResourceLoader.getResource("data/ui/common/philscroll.png", ResourceLoader.getImage, this.imageResources)
.toTile());
playerListContainer.position = new Vector(57, 286);
playerListContainer.extent = new Vector(525, 99);
playerListContainer.childrenHandleScroll = true;
// playerList.maxScrollY = 394 * Settings.uiScale;
dialogImg.addChild(playerListContainer);
var playerListLeftShadow = new GuiTextListCtrl(markerFelt18, [
Settings.highscoreName,
Settings.highscoreName,
Settings.highscoreName,
Settings.highscoreName,
Settings.highscoreName,
Settings.highscoreName,
Settings.highscoreName,
Settings.highscoreName
], 0);
playerListLeftShadow.horizSizing = Width;
playerListLeftShadow.position = new Vector(0, 0);
playerListLeftShadow.extent = new Vector(525, 99);
playerListLeftShadow.scrollable = true;
playerListLeftShadow.textYOffset = -6;
playerListContainer.addChild(playerListLeftShadow);
var playerListLeft = new GuiTextListCtrl(markerFelt18, [
Settings.highscoreName,
Settings.highscoreName,
Settings.highscoreName,
Settings.highscoreName,
Settings.highscoreName,
Settings.highscoreName,
Settings.highscoreName,
Settings.highscoreName
], 0xFFFFFF);
playerListLeft.horizSizing = Width;
playerListLeft.position = new Vector(-1, -1);
playerListLeft.extent = new Vector(525, 99);
playerListLeft.scrollable = true;
playerListLeft.textYOffset = -6;
playerListContainer.addChild(playerListLeft);
playerListContainer.setScrollMax(playerListLeft.calculateFullHeight());
}
}

View file

@ -1,5 +1,7 @@
package gui;
import net.MasterServerClient;
import net.Net;
import h2d.filter.DropShadow;
import src.Marbleland;
import h2d.Tile;
@ -10,6 +12,7 @@ import h3d.Vector;
import src.ResourceLoader;
import src.Settings;
import src.MissionList;
import net.NetCommands;
class MPServerDlg extends GuiImage {
public function new() {
@ -57,7 +60,12 @@ class MPServerDlg extends GuiImage {
var title = new GuiText(markerFelt32);
title.text.text = "Server Settings";
title.text.textColor = 0xFFFFFF;
title.text.filter = new DropShadow(1.414, 0.785, 0x0000000F, 1, 0, 0.4, 1, true);
title.text.dropShadow = {
dx: 1,
dy: 1,
alpha: 0.5,
color: 0
};
title.justify = Center;
title.position = new Vector(11, 21);
title.extent = new Vector(418, 14);
@ -80,6 +88,33 @@ class MPServerDlg extends GuiImage {
// showPasswords.extent = new Vector(31, 31);
// this.addChild(showPasswords);
// State variables
var curServerName = Settings.serverSettings.name;
var curServerPassword = Settings.serverSettings.password;
var curServerDescription = Settings.serverSettings.description;
var curServerMaxPlayers = Settings.serverSettings.maxPlayers;
var curServerForceSpectators = Settings.serverSettings.forceSpectators;
var curServerQuickRespawn = Settings.serverSettings.quickRespawn;
saveBtn.pressedAction = (e) -> {
Settings.serverSettings.name = curServerName;
Settings.serverSettings.password = curServerPassword;
Settings.serverSettings.description = curServerDescription;
Settings.serverSettings.maxPlayers = curServerMaxPlayers;
Settings.serverSettings.forceSpectators = curServerForceSpectators;
Settings.serverSettings.quickRespawn = curServerQuickRespawn;
if (Net.isHost) {
Net.serverInfo.name = curServerName;
Net.serverInfo.description = curServerDescription;
Net.serverInfo.maxPlayers = curServerMaxPlayers;
Net.serverInfo.password = curServerPassword;
MasterServerClient.instance.sendServerInfo(Net.serverInfo); // Update data on master server
NetCommands.sendServerSettings(Settings.serverSettings.name, Settings.serverSettings.description, Settings.serverSettings.quickRespawn,
Settings.serverSettings.forceSpectators);
}
MarbleGame.canvas.popDialog(this);
}
var serverSettingsContainer = new GuiControl();
serverSettingsContainer.vertSizing = Height;
serverSettingsContainer.horizSizing = Left;
@ -90,7 +125,12 @@ class MPServerDlg extends GuiImage {
var serverName = new GuiText(markerFelt18);
serverName.text.text = "Server Name:";
serverName.text.textColor = 0xFFFFFF;
serverName.text.filter = new DropShadow(1.414, 0.785, 0x0000000F, 1, 0, 0.4, 1, true);
serverName.text.dropShadow = {
dx: 1,
dy: 1,
alpha: 0.5,
color: 0
};
serverName.position = new Vector(0, 0);
serverName.extent = new Vector(206, 14);
serverSettingsContainer.addChild(serverName);
@ -104,14 +144,29 @@ class MPServerDlg extends GuiImage {
var serverNameEdit = new GuiTextInput(markerFelt18);
serverNameEdit.position = new Vector(3, 3);
serverNameEdit.extent = new Vector(291, 29);
serverNameEdit.text.filter = new DropShadow(1.414, 0.785, 0x0000000F, 1, 0, 0.4, 1, true);
serverNameEdit.text.dropShadow = {
dx: 1,
dy: 1,
alpha: 0.5,
color: 0
};
serverNameEdit.horizSizing = Left;
serverNameEdit.text.textColor = 0;
serverNameEdit.text.text = curServerName;
serverNameEdit.onTextChange = (t) -> {
curServerName = t;
}
serverNameEditBg.addChild(serverNameEdit);
var password = new GuiText(markerFelt18);
password.text.text = "Password:";
password.text.textColor = 0xFFFFFF;
password.text.filter = new DropShadow(1.414, 0.785, 0x0000000F, 1, 0, 0.4, 1, true);
password.text.dropShadow = {
dx: 1,
dy: 1,
alpha: 0.5,
color: 0
};
password.position = new Vector(0, 39);
password.extent = new Vector(206, 14);
serverSettingsContainer.addChild(password);
@ -125,14 +180,29 @@ class MPServerDlg extends GuiImage {
var passwordEdit = new GuiTextInput(markerFelt18);
passwordEdit.position = new Vector(3, 3);
passwordEdit.extent = new Vector(291, 29);
passwordEdit.text.filter = new DropShadow(1.414, 0.785, 0x0000000F, 1, 0, 0.4, 1, true);
passwordEdit.text.dropShadow = {
dx: 1,
dy: 1,
alpha: 0.5,
color: 0
};
passwordEdit.horizSizing = Left;
passwordEdit.text.textColor = 0;
passwordEdit.text.text = curServerPassword;
passwordEdit.onTextChange = (t) -> {
curServerPassword = t;
}
passwordEditBg.addChild(passwordEdit);
var serverDescTitle = new GuiText(markerFelt18);
serverDescTitle.text.text = "Server Info:";
serverDescTitle.text.textColor = 0xFFFFFF;
serverDescTitle.text.filter = new DropShadow(1.414, 0.785, 0x0000000F, 1, 0, 0.4, 1, true);
serverDescTitle.text.dropShadow = {
dx: 1,
dy: 1,
alpha: 0.5,
color: 0
};
serverDescTitle.position = new Vector(0, 39 * 2);
serverDescTitle.extent = new Vector(206, 14);
serverSettingsContainer.addChild(serverDescTitle);
@ -146,14 +216,29 @@ class MPServerDlg extends GuiImage {
var serverDescEdit = new GuiTextInput(markerFelt18);
serverDescEdit.position = new Vector(3, 3);
serverDescEdit.extent = new Vector(291 + 93, 29);
serverDescEdit.text.filter = new DropShadow(1.414, 0.785, 0x0000000F, 1, 0, 0.4, 1, true);
serverDescEdit.text.dropShadow = {
dx: 1,
dy: 1,
alpha: 0.5,
color: 0
};
serverDescEdit.horizSizing = Left;
serverDescEdit.text.textColor = 0;
serverDescEdit.text.text = curServerDescription;
serverDescEdit.onTextChange = (t) -> {
curServerDescription = t;
}
serverDescEditBg.addChild(serverDescEdit);
var maxPlayers = new GuiText(markerFelt18);
maxPlayers.text.text = "Max Players: 8";
maxPlayers.text.text = "Max Players: " + curServerMaxPlayers;
maxPlayers.text.textColor = 0xFFFFFF;
maxPlayers.text.filter = new DropShadow(1.414, 0.785, 0x0000000F, 1, 0, 0.4, 1, true);
maxPlayers.text.dropShadow = {
dx: 1,
dy: 1,
alpha: 0.5,
color: 0
};
maxPlayers.position = new Vector(0, 39 * 4);
maxPlayers.extent = new Vector(206, 14);
serverSettingsContainer.addChild(maxPlayers);
@ -161,19 +246,30 @@ class MPServerDlg extends GuiImage {
var playerMinus = new GuiButton(loadButtonImages("data/ui/mp/settings/minus"));
playerMinus.position = new Vector(331, 9 + 29 * 5);
playerMinus.extent = new Vector(31, 31);
playerMinus.pressedAction = (sender) -> {};
playerMinus.pressedAction = (sender) -> {
curServerMaxPlayers = Std.int(Math.max(1, curServerMaxPlayers - 1));
maxPlayers.text.text = "Max Players: " + curServerMaxPlayers;
};
serverSettingsContainer.addChild(playerMinus);
var playerPlus = new GuiButton(loadButtonImages("data/ui/mp/settings/plus"));
playerPlus.position = new Vector(359, 9 + 29 * 5);
playerPlus.extent = new Vector(31, 31);
playerPlus.pressedAction = (sender) -> {};
playerPlus.pressedAction = (sender) -> {
Settings.serverSettings.maxPlayers = Std.int(Math.min(8, Settings.serverSettings.maxPlayers + 1));
maxPlayers.text.text = "Max Players: " + Settings.serverSettings.maxPlayers;
};
serverSettingsContainer.addChild(playerPlus);
var forceSpectators = new GuiText(markerFelt18);
forceSpectators.text.text = "Force Spectators:";
forceSpectators.text.textColor = 0xFFFFFF;
forceSpectators.text.filter = new DropShadow(1.414, 0.785, 0x0000000F, 1, 0, 0.4, 1, true);
forceSpectators.text.dropShadow = {
dx: 1,
dy: 1,
alpha: 0.5,
color: 0
};
forceSpectators.position = new Vector(0, 39 * 5);
forceSpectators.extent = new Vector(206, 14);
serverSettingsContainer.addChild(forceSpectators);
@ -182,13 +278,21 @@ class MPServerDlg extends GuiImage {
forceSpectatorsChk.position = new Vector(359, 9 * 2 + 29 * 6 + 2);
forceSpectatorsChk.extent = new Vector(31, 31);
forceSpectatorsChk.buttonType = Toggle;
forceSpectatorsChk.pressedAction = (sender) -> {};
forceSpectatorsChk.pressed = curServerForceSpectators;
forceSpectatorsChk.pressedAction = (sender) -> {
curServerForceSpectators = !curServerForceSpectators;
};
serverSettingsContainer.addChild(forceSpectatorsChk);
var quickRespawn = new GuiText(markerFelt18);
quickRespawn.text.text = "Allow Quick Respawn:";
quickRespawn.text.textColor = 0xFFFFFF;
quickRespawn.text.filter = new DropShadow(1.414, 0.785, 0x0000000F, 1, 0, 0.4, 1, true);
quickRespawn.text.dropShadow = {
dx: 1,
dy: 1,
alpha: 0.5,
color: 0
};
quickRespawn.position = new Vector(0, 39 * 6);
quickRespawn.extent = new Vector(206, 14);
serverSettingsContainer.addChild(quickRespawn);
@ -197,7 +301,10 @@ class MPServerDlg extends GuiImage {
quickRespawnChk.position = new Vector(359, 9 * 3 + 29 * 7 + 4);
quickRespawnChk.extent = new Vector(31, 31);
quickRespawnChk.buttonType = Toggle;
quickRespawnChk.pressedAction = (sender) -> {};
quickRespawnChk.pressed = curServerQuickRespawn;
quickRespawnChk.pressedAction = (sender) -> {
curServerQuickRespawn = !curServerQuickRespawn;
};
serverSettingsContainer.addChild(quickRespawnChk);
}
}

View file

@ -182,7 +182,12 @@ class MainMenuGui extends GuiImage {
versionText.position = new Vector(502, 61);
versionText.extent = new Vector(97, 72);
versionText.text.text = "<p align=\"center\">1.5.4</p>";
versionText.text.filter = new DropShadow(1.414, 0.785, 0x3333337F, 1, 0, 0.7, 1, true);
versionText.text.dropShadow = {
dx: 1,
dy: 1,
alpha: 0.5,
color: 0
};
this.addChild(versionText);
var kofi = new GuiButton(loadButtonImages("data/ui/kofi1"));

View file

@ -553,7 +553,12 @@ class MarbleSelectGui extends GuiImage {
var titleText = new GuiMLText(markerFelt28, null);
titleText.text.textColor = 0xFFFFFF;
titleText.text.filter = new DropShadow(1.414, 0.785, 0, 1, 0x0000007F, 0.4, 1, true);
titleText.text.dropShadow = {
dx: 1,
dy: 1,
alpha: 0.5,
color: 0
};
titleText.horizSizing = Center;
titleText.vertSizing = Bottom;
titleText.position = new Vector(140, 67);
@ -563,7 +568,12 @@ class MarbleSelectGui extends GuiImage {
var marbleText = new GuiMLText(markerFelt24, null);
marbleText.text.textColor = 0xFFFFFF;
marbleText.text.filter = new DropShadow(1.414, 0.785, 0, 1, 0x0000007F, 0.4, 1, true);
marbleText.text.dropShadow = {
dx: 1,
dy: 1,
alpha: 0.5,
color: 0
};
marbleText.horizSizing = Center;
marbleText.vertSizing = Bottom;
marbleText.position = new Vector(86, 243);

View file

@ -147,7 +147,12 @@ class OptionsDlg extends GuiImage {
textObj.extent = new Vector(212, 14);
textObj.text.text = text;
textObj.text.textColor = 0xFFFFFF;
textObj.text.filter = new DropShadow(1.414, 0.785, 0x0000000F, 1, 0, 0.4, 1, true);
textObj.text.dropShadow = {
dx: 1,
dy: 1,
alpha: 0.5,
color: 0
};
parent.addChild(textObj);
var optDropdownImg = new GuiImage(ResourceLoader.getResource('data/ui/options/dropdown-${size}.png', ResourceLoader.getImage, this.imageResources)
@ -220,7 +225,12 @@ class OptionsDlg extends GuiImage {
textObj.extent = new Vector(212, 14);
textObj.text.text = text;
textObj.text.textColor = 0xFFFFFF;
textObj.text.filter = new DropShadow(1.414, 0.785, 0x0000000F, 1, 0, 0.4, 1, true);
textObj.text.dropShadow = {
dx: 1,
dy: 1,
alpha: 0.5,
color: 0
};
parent.addChild(textObj);
var sliderBar = new GuiImage(ResourceLoader.getResource("data/ui/options/bar.png", ResourceLoader.getImage, this.imageResources).toTile());
@ -399,7 +409,12 @@ class OptionsDlg extends GuiImage {
textObj.extent = new Vector(212, 14);
textObj.text.text = text;
textObj.text.textColor = 0xFFFFFF;
textObj.text.filter = new DropShadow(1.414, 0.785, 0x0000000F, 1, 0, 0.4, 1, true);
textObj.text.dropShadow = {
dx: 1,
dy: 1,
alpha: 0.5,
color: 0
};
parent.addChild(textObj);
var remapBtn = new GuiButtonText(loadButtonImages("data/ui/options/bind"), markerFelt24);
@ -444,7 +459,12 @@ class OptionsDlg extends GuiImage {
textObj.extent = new Vector(212, 14);
textObj.text.text = "Touch Controls";
textObj.text.textColor = 0xFFFFFF;
textObj.text.filter = new DropShadow(1.414, 0.785, 0x0000000F, 1, 0, 0.4, 1, true);
textObj.text.dropShadow = {
dx: 1,
dy: 1,
alpha: 0.5,
color: 0
};
hotkeysPanel.addChild(textObj);
var remapBtn = new GuiButtonText(loadButtonImages("data/ui/options/bind"), markerFelt24);

View file

@ -887,7 +887,12 @@ class PlayGui {
middleMsg.text.text = text;
middleMsg.justify = Center;
middleMsg.text.textColor = color;
middleMsg.text.filter = new h2d.filter.DropShadow(1.414, 0.785, 0x000000F, 1, 0, 0.4, 1, true);
middleMsg.text.dropShadow = {
dx: 1,
dy: 1,
alpha: 0.5,
color: 0
}; // new h2d.filter.DropShadow(1.414, 0.785, 0x000000F, 1, 0, 0.4, 1, true);
this.playGuiCtrl.addChild(middleMsg);
middleMsg.render(scene2d);
middleMsg.text.y -= (25 / playGuiCtrl.extent.y) * scene2d.height;

View file

@ -892,8 +892,12 @@ class PlayMissionGui extends GuiImage {
setScoreHover = (isHover) -> {
var currentMission = currentList[currentSelection];
pmScoreText.text.filter = new DropShadow(1.414, 0.785, 0x0000000F, 1, 0, 0.4, 1, true);
pmScoreText.text.dropShadow = {
dx: 1,
dy: 1,
alpha: 0.5,
color: 0
};
var scoreTextTime = "";
var scoreData = Settings.getScores(currentMission.path);
if (scoreData.length == 0) {
@ -982,10 +986,20 @@ class PlayMissionGui extends GuiImage {
currentSelection = -1;
}
pmDescription.text.filter = new DropShadow(1.414, 0.785, 0x0000000F, 1, 0, 0.4, 1, true);
pmDescription.text.dropShadow = {
dx: 1,
dy: 1,
alpha: 0.5,
color: 0
};
pmDescription.text.lineSpacing = -1;
pmDescriptionRight.text.filter = new DropShadow(1.414, 0.785, 0x0000000F, 1, 0, 0.4, 1, true);
pmDescriptionRight.text.dropShadow = {
dx: 1,
dy: 1,
alpha: 0.5,
color: 0
};
pmDescriptionRight.text.lineSpacing = -1;
var descText = '<font color="#FDFEFE" face="MarkerFelt26"><p align="center">#${currentList.indexOf(currentMission) + 1}: ${currentMission.title}</p></font>';
@ -1025,8 +1039,18 @@ class PlayMissionGui extends GuiImage {
}
pmDescription.text.text = descText;
pmParText.text.filter = new DropShadow(1.414, 0.785, 0x0000000F, 1, 0, 0.4, 1, true);
pmParTextRight.text.filter = new DropShadow(1.414, 0.785, 0x0000000F, 1, 0, 0.4, 1, true);
pmParText.text.dropShadow = {
dx: 1,
dy: 1,
alpha: 0.5,
color: 0
};
pmParTextRight.text.dropShadow = {
dx: 1,
dy: 1,
alpha: 0.5,
color: 0
};
if (this.scoreShowing) {
if (currentMission.game == "platinum") {
pmParText.text.text = '<font color="#FFE3E3" face="MarkerFelt20">Platinum: <font color="#CCCCCC">${Util.formatTime(currentMission.goldTime)}</font></font>';

View file

@ -76,7 +76,6 @@ abstract class GameConnection {
var lobbyReady:Bool;
var platform:NetPlatform;
var marbleId:Int;
var isPrivate:Bool;
function new(id:Int) {
this.id = id;

View file

@ -9,17 +9,19 @@ import src.Console;
typedef RemoteServerInfo = {
name:String,
description:String,
players:Int,
maxPlayers:Int,
platform:Int,
version:String
version:String,
passworded:Bool
}
class MasterServerClient {
#if js
static var serverIp = "wss://mbomaster.randomityguy.me:8443";
#else
static var serverIp = "ws://89.58.58.191:8080";
static var serverIp = "ws://89.58.58.191:8084";
#end
public static var instance:MasterServerClient;
@ -208,32 +210,24 @@ class MasterServerClient {
queueMessage(Json.stringify({
type: "serverInfo",
name: serverInfo.name,
description: serverInfo.description,
players: serverInfo.players,
maxPlayers: serverInfo.maxPlayers,
privateSlots: serverInfo.privateSlots,
privateServer: serverInfo.privateServer,
inviteCode: serverInfo.inviteCode,
password: serverInfo.password,
state: serverInfo.state,
platform: serverInfo.platform,
version: "MBP" // MarbleGame.currentVersion
}));
}
public function sendConnectToServer(serverName:String, sdp:String, isInvite:Bool = false) {
if (!isInvite) {
public function sendConnectToServer(serverName:String, sdp:String, password:String) {
queueMessage(Json.stringify({
type: "connect",
serverName: serverName,
sdp: sdp
}));
} else {
queueMessage(Json.stringify({
type: "connectInvite",
sdp: sdp,
inviteCode: serverName
password: password
}));
}
}
public function getServerList(serverListCb:Array<RemoteServerInfo>->Void) {
this.serverListCb = serverListCb;
@ -269,20 +263,13 @@ class MasterServerClient {
}));
return;
}
var pubSlotsAvail = Net.serverInfo.maxPlayers - Net.serverInfo.privateSlots;
var privSlotsAvail = Net.serverInfo.privateSlots;
var pubCount = 1; // Self
var privCount = 0;
for (cid => cc in Net.clientIdMap) {
if (cc.isPrivate) {
privCount++;
} else {
pubCount++;
}
}
if (!joiningPrivate && pubCount >= pubSlotsAvail) {
if (!joiningPrivate && pubCount >= Net.serverInfo.maxPlayers) {
queueMessage(Json.stringify({
type: "connectFailed",
success: false,
@ -291,11 +278,7 @@ class MasterServerClient {
return;
}
if (joiningPrivate && privCount >= privSlotsAvail) {
joiningPrivate = false; // Join publicly
}
Net.addClientFromSdp(conts.sdp, joiningPrivate, (sdpReply) -> {
Net.addClientFromSdp(conts.sdp, (sdpReply) -> {
queueMessage(Json.stringify({
success: true,
type: "connectResponse",

View file

@ -40,26 +40,33 @@ enum abstract NetPacketType(Int) from Int to Int {
@:publicFields
class ServerInfo {
var name:String;
var description:String;
var players:Int;
var maxPlayers:Int;
var privateSlots:Int;
var privateServer:Bool;
var inviteCode:Int;
var password:String;
var state:String;
var platform:NetPlatform;
public function new(name:String, players:Int, maxPlayers:Int, privateSlots:Int, privateServer:Bool, inviteCode:Int, state:String, platform:NetPlatform) {
public function new(name:String, description:String, players:Int, maxPlayers:Int, password:String, state:String, platform:NetPlatform) {
this.name = name;
this.description = description;
this.players = players;
this.maxPlayers = maxPlayers;
this.privateSlots = privateSlots;
this.privateServer = privateServer;
this.inviteCode = inviteCode;
this.password = password;
this.state = state;
this.platform = platform;
}
}
@:publicFields
@:structInit
class ConnectedServerInfo {
var name:String;
var description:String;
var quickRespawn:Bool;
var forceSpectator:Bool;
}
class Net {
static var client:RTCPeerConnection;
static var clientDatachannel:RTCDataChannel;
@ -81,13 +88,14 @@ class Net {
public static var clientConnection:ClientConnection;
public static var serverInfo:ServerInfo;
public static var remoteServerInfo:RemoteServerInfo;
public static var connectedServerInfo:ConnectedServerInfo;
static var stunServers = ["stun:stun.l.google.com:19302"];
public static var turnServer:String = "";
public static function hostServer(name:String, maxPlayers:Int, privateSlots:Int, privateServer:Bool, onHosted:() -> Void) {
serverInfo = new ServerInfo(name, 1, maxPlayers, privateSlots, privateServer, Std.int(999999 * Math.random()), "LOBBY", getPlatform());
public static function hostServer(name:String, description:String, maxPlayers:Int, password:String, onHosted:() -> Void) {
serverInfo = new ServerInfo(name, description, 1, maxPlayers, password, "LOBBY", getPlatform());
MasterServerClient.connectToMasterServer(() -> {
isHost = true;
isClient = false;
@ -98,14 +106,14 @@ class Net {
});
}
public static function addClientFromSdp(sdpString:String, privateJoin:Bool, onFinishSdp:String->Void) {
public static function addClientFromSdp(sdpString:String, onFinishSdp:String->Void) {
var peer = new RTCPeerConnection(stunServers, "0.0.0.0");
var sdpObj = Json.parse(sdpString);
peer.setRemoteDescription(sdpObj.sdp, sdpObj.type);
addClient(peer, privateJoin, onFinishSdp);
addClient(peer, onFinishSdp);
}
static function addClient(peer:RTCPeerConnection, privateJoin:Bool, onFinishSdp:String->Void) {
static function addClient(peer:RTCPeerConnection, onFinishSdp:String->Void) {
var candidates = [];
peer.onLocalCandidate = (c) -> {
Console.log('Local candidate: ' + c);
@ -173,7 +181,7 @@ class Net {
}
}
if (reliable != null && unreliable != null)
onClientConnect(peer, reliable, unreliable, privateJoin);
onClientConnect(peer, reliable, unreliable);
}
}
@ -182,7 +190,7 @@ class Net {
clientIdMap[id] = ghost;
}
public static function joinServer(serverName:String, isInvite:Bool, connectedCb:() -> Void) {
public static function joinServer(serverName:String, password:String, connectedCb:() -> Void) {
MasterServerClient.connectToMasterServer(() -> {
client = new RTCPeerConnection(stunServers, "0.0.0.0");
var candidates = [];
@ -250,7 +258,7 @@ class Net {
MasterServerClient.instance.sendConnectToServer(serverName, Json.stringify({
sdp: sdpObj,
type: "offer"
}), isInvite);
}), password);
}
client.onGatheringStateChange = (s) -> {
@ -355,6 +363,7 @@ class Net {
Net.clientConnection = null;
Net.serverInfo = null;
Net.remoteServerInfo = null;
Net.connectedServerInfo = null;
Net.lobbyHostReady = false;
Net.lobbyClientReady = false;
Net.hostReady = false;
@ -375,6 +384,7 @@ class Net {
MasterServerClient.disconnectFromMasterServer();
Net.serverInfo = null;
Net.remoteServerInfo = null;
Net.connectedServerInfo = null;
Net.lobbyHostReady = false;
Net.lobbyClientReady = false;
Net.hostReady = false;
@ -444,7 +454,7 @@ class Net {
}
}
static function onClientConnect(c:RTCPeerConnection, dc:RTCDataChannel, dcu:RTCDataChannel, joiningPrivate:Bool) {
static function onClientConnect(c:RTCPeerConnection, dc:RTCDataChannel, dcu:RTCDataChannel) {
if (!Net.isMP) {
c.close();
return;
@ -456,7 +466,6 @@ class Net {
}
var cc = new ClientConnection(clientId, c, dc, dcu);
clients.set(c, cc);
cc.isPrivate = joiningPrivate;
clientIdMap[clientId] = clients[c];
cc.lastRecvTime = Console.time(); // So it doesnt get timed out
@ -569,6 +578,8 @@ class Net {
// if (MultiplayerLevelSelectGui.custSelected) {
// NetCommands.setLobbyCustLevelNameClient(conn, MultiplayerLevelSelectGui.custPath);
// } else {
NetCommands.sendServerSettingsClient(conn, Settings.serverSettings.name, Settings.serverSettings.description, Settings.serverSettings.quickRespawn,
Settings.serverSettings.forceSpectators);
NetCommands.setLobbyLevelIndexClient(conn, MPPlayMissionGui.currentCategoryStatic, MPPlayMissionGui.currentSelectionStatic);
// }

View file

@ -326,6 +326,15 @@ class NetCommands {
}
}
@:rpc(server) public static function sendServerSettings(name:String, desc:String, quickRespawn:Bool, forceSpectator:Bool) {
Net.connectedServerInfo = {
name: name,
description: desc,
quickRespawn: quickRespawn,
forceSpectator: forceSpectator
};
}
// @:rpc(client) public static function sendChatMessage(msg:String) {
// if (Net.isHost) {
// sendServerChatMessage(msg);

View file

@ -36,6 +36,14 @@ class RPCMacro {
serializeFns.push(macro stream.writeInt32($i{argName}));
}
case TPath({
name: 'Bool'
}): {
deserializeFns.push(macro var $argName = stream.readFlag());
callExprs.push(macro $i{argName});
serializeFns.push(macro stream.writeFlag($i{argName}));
}
case TPath({
name: 'Float'
}): {