radar fixes and spectator ui (pc)

This commit is contained in:
RandomityGuy 2024-07-03 01:45:42 +05:30
parent 41f041f3f9
commit 2416a7119e
5 changed files with 133 additions and 8 deletions

View file

@ -127,10 +127,12 @@ class CameraController extends Object {
public function enableSpectate() {
spectate = true;
@:privateAccess this.level.playGui.setSpectateMenu(true);
}
public function stopSpectate() {
spectate = false;
@:privateAccess this.level.playGui.setSpectateMenu(false);
}
public function orbit(mouseX:Float, mouseY:Float, isTouch:Bool = false) {
@ -299,6 +301,7 @@ class CameraController extends Object {
var orientationQuat = level.getOrientationQuat(currentTime);
if (spectateMarbleIndex == -1) {
@:privateAccess level.playGui.setSpectateMenuText(0);
var up = new Vector(0, 0, 1);
up.transform(orientationQuat.toMatrix());
var directionVector = new Vector(1, 0, 0);
@ -362,6 +365,7 @@ class CameraController extends Object {
camera.up = up;
camera.target = camera.pos.add(directionVector);
} else {
@:privateAccess level.playGui.setSpectateMenuText(1);
if (Key.isPressed(Settings.controlsSettings.left)) {
spectateMarbleIndex = (spectateMarbleIndex - 1 + level.marbles.length) % level.marbles.length;
@:privateAccess while (level.marbles[spectateMarbleIndex].connection == null

View file

@ -1665,8 +1665,9 @@ class Marble extends GameObject {
this.collisionWorld.updateTransform(this.collider);
this.setPosition(1e8, 1e8, 1e8);
if (Net.clientSpectate && this.connection == null)
if (Net.clientSpectate && this.connection == null) {
this.camera.enableSpectate();
}
return;
}
}

View file

@ -384,7 +384,11 @@ class MarbleWorld extends Scheduler {
MarbleGame.canvas.clearContent();
if (this.endPad != null)
this.endPad.generateCollider();
this.playGui.formatGemCounter(this.gemCount, this.totalGems);
if (this.isMultiplayer) {
this.playGui.formatGemHuntCounter(0);
} else {
this.playGui.formatGemCounter(this.gemCount, this.totalGems);
}
Console.log("MISSION LOADED");
start();
});

View file

@ -193,11 +193,11 @@ class Radar {
function renderName(pos:Vector, marble:Marble, opacity:Float) {
if (!marbleNameTexts.exists(marble)) {
var arialb14fontdata = ResourceLoader.getFileEntry("data/font/Arial Bold.fnt");
var arialb14b = new BitmapFont(arialb14fontdata.entry);
@:privateAccess arialb14b.loader = ResourceLoader.loader;
var arialBold14 = arialb14b.toSdfFont(cast 16 * Settings.uiScale, MultiChannel);
var txt = new h2d.Text(arialBold14, scene2d);
var markerFelt32fontdata = ResourceLoader.getFileEntry("data/font/MarkerFelt.fnt");
var markerFelt32b = new BitmapFont(markerFelt32fontdata.entry);
@:privateAccess markerFelt32b.loader = ResourceLoader.loader;
var markerFelt18 = markerFelt32b.toSdfFont(cast 14 * Settings.uiScale, MultiChannel);
var txt = new h2d.Text(markerFelt18, scene2d);
marbleNameTexts.set(marble, txt);
txt.textColor = 0xFFFF00;
}
@ -209,7 +209,8 @@ class Radar {
function dontRenderName(marble:Marble) {
if (marbleNameTexts.exists(marble)) {
marbleNameTexts.get(marble).alpha = 0;
var el = marbleNameTexts.get(marble);
el.alpha = 0;
}
}
}

View file

@ -97,6 +97,9 @@ class PlayGui {
var playGuiCtrl:GuiControl;
var chatCtrl:ChatCtrl;
var spectatorCtrl:GuiControl;
var spectatorTxt:GuiMLText;
var spectatorTxtMode:Int = -1;
var resizeEv:Void->Void;
@ -124,6 +127,11 @@ class PlayGui {
chatCtrl = null;
}
if (spectatorCtrl != null) {
spectatorCtrl.dispose();
spectatorCtrl = null;
}
gemImageScene.dispose();
gemImageSceneTarget.dispose();
gemImageSceneTargetBitmap.remove();
@ -201,6 +209,8 @@ class PlayGui {
if (MarbleGame.instance.world.isMultiplayer) {
initPlayerList();
initChatHud();
if (Net.hostSpectate || Net.clientSpectate)
initSpectatorMenu();
}
if (Util.isTouchDevice()) {
@ -689,6 +699,111 @@ class PlayGui {
redrawPlayerList();
}
public function initSpectatorMenu() {
spectatorCtrl = new GuiControl();
spectatorCtrl.vertSizing = Top;
spectatorCtrl.position = new Vector(0, 330);
spectatorCtrl.extent = new Vector(302, 150);
var specWnd = new GuiImage(ResourceLoader.getResource("data/ui/mp/play/spectator.png", ResourceLoader.getImage, this.imageResources).toTile());
specWnd.horizSizing = Width;
specWnd.vertSizing = Top;
specWnd.position = new Vector(0, 0);
specWnd.extent = new Vector(302, 150);
spectatorCtrl.addChild(specWnd);
var domcasual24fontdata = ResourceLoader.getFileEntry("data/font/DomCasualD.fnt");
var domcasual24b = new BitmapFont(domcasual24fontdata.entry);
@:privateAccess domcasual24b.loader = ResourceLoader.loader;
var domcasual24 = domcasual24b.toSdfFont(cast 20 * Settings.uiScale, MultiChannel);
var domcasual32 = domcasual24b.toSdfFont(cast 26 * Settings.uiScale, MultiChannel);
var arial14fontdata = ResourceLoader.getFileEntry("data/font/arial.fnt");
var arial14b = new BitmapFont(arial14fontdata.entry);
@:privateAccess arial14b.loader = ResourceLoader.loader;
var arial14 = arial14b.toSdfFont(cast 12 * Settings.uiScale, MultiChannel);
var arialb14fontdata = ResourceLoader.getFileEntry("data/font/Arial Bold.fnt");
var arialb14b = new BitmapFont(arialb14fontdata.entry);
@:privateAccess arialb14b.loader = ResourceLoader.loader;
var arialBold14 = arialb14b.toSdfFont(cast 12 * Settings.uiScale, MultiChannel);
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);
function mlFontLoader(text:String) {
switch (text) {
case "DomCasual24":
return domcasual24;
case "Arial14":
return arial14;
case "ArialBold14":
return arialBold14;
case "MarkerFelt32":
return markerFelt32;
case "MarkerFelt24":
return markerFelt24;
case "MarkerFelt18":
return markerFelt18;
case "MarkerFelt20":
return markerFelt20;
case "MarkerFelt26":
return markerFelt26;
default:
return null;
}
}
spectatorTxt = new GuiMLText(markerFelt24, mlFontLoader);
spectatorTxt.position = new Vector(6, 9);
spectatorTxt.extent = new Vector(282, 14);
spectatorTxt.text.textColor = 0x000000;
specWnd.addChild(spectatorTxt);
playGuiCtrl.addChild(spectatorCtrl);
}
public function setSpectateMenu(enabled:Bool) {
if (enabled && spectatorCtrl == null) {
initSpectatorMenu();
playGuiCtrl.render(MarbleGame.canvas.scene2d);
blastFill.bmp.visible = false;
blastFrame.bmp.visible = false;
}
if (!enabled && spectatorCtrl != null) {
spectatorCtrl.dispose();
spectatorCtrl = null;
blastFill.bmp.visible = true;
blastFrame.bmp.visible = true;
spectatorTxtMode = -1;
}
}
public function setSpectateMenuText(mode:Int) {
if (spectatorTxtMode != mode) {
if (mode == 0) {
spectatorTxt.text.text = '<p align="center"><font face="MarkerFelt32">Spectator Info</font></p>
<font face="MarkerFelt24">Toggle Fly / Orbit: ${Util.getKeyForButton2(Settings.controlsSettings.blast)}</font>';
}
if (mode == 1) {
spectatorTxt.text.text = '<p align="center"><font face="MarkerFelt32">Spectator Info</font></p>
<font face="MarkerFelt24">Toggle Fly / Orbit: ${Util.getKeyForButton2(Settings.controlsSettings.blast)}
<br/>Prev Player: ${Util.getKeyForButton2(Settings.controlsSettings.left)}
<br/>Next Player: ${Util.getKeyForButton2(Settings.controlsSettings.right)}</font>';
}
spectatorTxtMode = mode;
}
}
public function setHelpTextOpacity(value:Float) {
@:privateAccess helpTextForeground.text._textColorVec.a = value;
@:privateAccess helpTextBackground.text._textColorVec.a = value;