mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2025-10-30 08:11:25 +00:00
fix some ui and game bugs
This commit is contained in:
parent
eaea583c2c
commit
a9149730d5
7 changed files with 47 additions and 19 deletions
|
|
@ -1724,6 +1724,13 @@ class Marble extends GameObject {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Net.isMP) {
|
||||||
|
if (m.jump && this.outOfBounds) {
|
||||||
|
this.level.cancel(this.oobSchedule);
|
||||||
|
this.level.restart(cast this);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MP Only Functions
|
// MP Only Functions
|
||||||
|
|
@ -1860,11 +1867,6 @@ class Marble extends GameObject {
|
||||||
playedSounds = [];
|
playedSounds = [];
|
||||||
advancePhysics(timeState, move.move, collisionWorld, pathedInteriors);
|
advancePhysics(timeState, move.move, collisionWorld, pathedInteriors);
|
||||||
physicsAccumulator = 0;
|
physicsAccumulator = 0;
|
||||||
|
|
||||||
if (move.move.jump && this.outOfBounds && Net.isHost) {
|
|
||||||
this.level.cancel(this.oobSchedule);
|
|
||||||
this.level.restart(cast this);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
physicsAccumulator = 0;
|
physicsAccumulator = 0;
|
||||||
newPos.load(oldPos);
|
newPos.load(oldPos);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
package src;
|
package src;
|
||||||
|
|
||||||
|
import haxe.io.Path;
|
||||||
|
import gui.MultiplayerGui;
|
||||||
import net.MasterServerClient;
|
import net.MasterServerClient;
|
||||||
import gui.MultiplayerLevelSelectGui;
|
import gui.MultiplayerLevelSelectGui;
|
||||||
import net.NetCommands;
|
import net.NetCommands;
|
||||||
|
|
@ -254,10 +256,10 @@ class MarbleGame {
|
||||||
quitMission();
|
quitMission();
|
||||||
}));
|
}));
|
||||||
} else {
|
} else {
|
||||||
|
quitMission(Net.isClient);
|
||||||
if (Net.isMP && Net.isClient) {
|
if (Net.isMP && Net.isClient) {
|
||||||
Net.disconnect();
|
Net.disconnect();
|
||||||
}
|
}
|
||||||
quitMission();
|
|
||||||
}
|
}
|
||||||
}, (sender) -> {
|
}, (sender) -> {
|
||||||
@:privateAccess world.playGui.setGuiVisibility(true);
|
@:privateAccess world.playGui.setGuiVisibility(true);
|
||||||
|
|
@ -303,7 +305,7 @@ class MarbleGame {
|
||||||
return world;
|
return world;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function quitMission() {
|
public function quitMission(weDisconnecting:Bool = false) {
|
||||||
Console.log("Quitting mission");
|
Console.log("Quitting mission");
|
||||||
if (Net.isMP) {
|
if (Net.isMP) {
|
||||||
if (Net.isHost) {
|
if (Net.isHost) {
|
||||||
|
|
@ -313,6 +315,7 @@ class MarbleGame {
|
||||||
var watching = world.isWatching;
|
var watching = world.isWatching;
|
||||||
var missionType = world.mission.type;
|
var missionType = world.mission.type;
|
||||||
var isNotCustom = !world.mission.isClaMission && !world.mission.isCustom;
|
var isNotCustom = !world.mission.isClaMission && !world.mission.isCustom;
|
||||||
|
var lastMis = Path.withoutExtension(Path.withoutDirectory(world.mission.path));
|
||||||
world.setCursorLock(false);
|
world.setCursorLock(false);
|
||||||
if (!Settings.levelStatistics.exists(world.mission.path)) {
|
if (!Settings.levelStatistics.exists(world.mission.path)) {
|
||||||
Settings.levelStatistics.set(world.mission.path, {
|
Settings.levelStatistics.set(world.mission.path, {
|
||||||
|
|
@ -335,8 +338,14 @@ class MarbleGame {
|
||||||
#end
|
#end
|
||||||
} else {
|
} else {
|
||||||
if (Net.isMP) {
|
if (Net.isMP) {
|
||||||
|
if (weDisconnecting) {
|
||||||
|
MarbleGame.instance.setPreviewMission(lastMis, () -> {
|
||||||
|
canvas.setContent(new MultiplayerGui());
|
||||||
|
});
|
||||||
|
} else {
|
||||||
var lobby = new MultiplayerLevelSelectGui(Net.isHost);
|
var lobby = new MultiplayerLevelSelectGui(Net.isHost);
|
||||||
canvas.setContent(lobby);
|
canvas.setContent(lobby);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
var pmg = new LevelSelectGui(LevelSelectGui.currentDifficultyStatic);
|
var pmg = new LevelSelectGui(LevelSelectGui.currentDifficultyStatic);
|
||||||
if (_exitingToMenu) {
|
if (_exitingToMenu) {
|
||||||
|
|
|
||||||
|
|
@ -733,7 +733,7 @@ class MarbleWorld extends Scheduler {
|
||||||
this.clearSchedule();
|
this.clearSchedule();
|
||||||
marble.outOfBounds = false;
|
marble.outOfBounds = false;
|
||||||
this.gameMode.onRespawn(marble);
|
this.gameMode.onRespawn(marble);
|
||||||
if (marble == this.marble)
|
if (marble == this.marble && @:privateAccess !marble.isNetUpdate)
|
||||||
AudioManager.playSound(ResourceLoader.getResource('data/sound/spawn_alternate.wav', ResourceLoader.getAudio, this.soundResources));
|
AudioManager.playSound(ResourceLoader.getResource('data/sound/spawn_alternate.wav', ResourceLoader.getAudio, this.soundResources));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -71,12 +71,18 @@ class CreateMatchGui extends GuiImage {
|
||||||
var privateGame = false;
|
var privateGame = false;
|
||||||
|
|
||||||
var playerOpt = optionCollection.addOption(1, "Max Players", ["2", "3", "4", "5", "6", "7", "8"], (idx) -> {
|
var playerOpt = optionCollection.addOption(1, "Max Players", ["2", "3", "4", "5", "6", "7", "8"], (idx) -> {
|
||||||
|
var newMaxPlayers = idx + 2;
|
||||||
|
if (privateSlots >= newMaxPlayers)
|
||||||
|
return false;
|
||||||
maxPlayers = idx + 2;
|
maxPlayers = idx + 2;
|
||||||
return true;
|
return true;
|
||||||
}, 0.5, 118);
|
}, 0.5, 118);
|
||||||
playerOpt.setCurrentOption(6);
|
playerOpt.setCurrentOption(6);
|
||||||
|
|
||||||
var privateOpt = optionCollection.addOption(1, "Private Slots", ["None", "1", "2", "3", "4", "5", "6", "7"], (idx) -> {
|
var privateOpt = optionCollection.addOption(1, "Private Slots", ["None", "1", "2", "3", "4", "5", "6", "7"], (idx) -> {
|
||||||
|
var newPrivateSlotCount = idx;
|
||||||
|
if (newPrivateSlotCount >= maxPlayers)
|
||||||
|
return false;
|
||||||
privateSlots = idx;
|
privateSlots = idx;
|
||||||
return true;
|
return true;
|
||||||
}, 0.5, 118);
|
}, 0.5, 118);
|
||||||
|
|
|
||||||
|
|
@ -80,6 +80,8 @@ class GuiXboxButton extends GuiControl {
|
||||||
|
|
||||||
public override function update(dt:Float, mouseState:MouseState) {
|
public override function update(dt:Float, mouseState:MouseState) {
|
||||||
var renderRect = getHitTestRect();
|
var renderRect = getHitTestRect();
|
||||||
|
renderRect.position = renderRect.position.add(new Vector(16, 22));
|
||||||
|
renderRect.extent = renderRect.extent.sub(new Vector(32, 44));
|
||||||
if (renderRect.inRect(mouseState.position) && !disabled) {
|
if (renderRect.inRect(mouseState.position) && !disabled) {
|
||||||
if (buttonSounds && Key.isPressed(Key.MOUSE_LEFT)) {
|
if (buttonSounds && Key.isPressed(Key.MOUSE_LEFT)) {
|
||||||
AudioManager.playSound(ResourceLoader.getResource("data/sound/buttonpress.wav", ResourceLoader.getAudio, this.soundResources));
|
AudioManager.playSound(ResourceLoader.getResource("data/sound/buttonpress.wav", ResourceLoader.getAudio, this.soundResources));
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package gui;
|
package gui;
|
||||||
|
|
||||||
|
import net.Net;
|
||||||
import hxd.res.BitmapFont;
|
import hxd.res.BitmapFont;
|
||||||
import h3d.Vector;
|
import h3d.Vector;
|
||||||
import src.ResourceLoader;
|
import src.ResourceLoader;
|
||||||
|
|
@ -13,6 +14,7 @@ class MultiplayerLoadingGui extends GuiImage {
|
||||||
var loadAnim:GuiLoadAnim;
|
var loadAnim:GuiLoadAnim;
|
||||||
var bottomBar:GuiControl;
|
var bottomBar:GuiControl;
|
||||||
var innerCtrl:GuiControl;
|
var innerCtrl:GuiControl;
|
||||||
|
var backButton:GuiXboxButton;
|
||||||
|
|
||||||
public function new(initialStatus:String) {
|
public function new(initialStatus:String) {
|
||||||
var res = ResourceLoader.getImage("data/ui/game/CloudBG.jpg").resource.toTile();
|
var res = ResourceLoader.getImage("data/ui/game/CloudBG.jpg").resource.toTile();
|
||||||
|
|
@ -81,6 +83,18 @@ class MultiplayerLoadingGui extends GuiImage {
|
||||||
bottomBar.horizSizing = Width;
|
bottomBar.horizSizing = Width;
|
||||||
bottomBar.vertSizing = Bottom;
|
bottomBar.vertSizing = Bottom;
|
||||||
innerCtrl.addChild(bottomBar);
|
innerCtrl.addChild(bottomBar);
|
||||||
|
|
||||||
|
backButton = new GuiXboxButton("Cancel", 160);
|
||||||
|
backButton.position = new Vector(960, 0);
|
||||||
|
backButton.vertSizing = Bottom;
|
||||||
|
backButton.horizSizing = Right;
|
||||||
|
backButton.gamepadAccelerator = ["A"];
|
||||||
|
backButton.accelerators = [hxd.Key.ENTER];
|
||||||
|
backButton.pressedAction = (e) -> {
|
||||||
|
Net.disconnect();
|
||||||
|
MarbleGame.canvas.setContent(new MultiplayerGui());
|
||||||
|
};
|
||||||
|
bottomBar.addChild(backButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setLoadingStatus(str:String) {
|
public function setLoadingStatus(str:String) {
|
||||||
|
|
@ -92,17 +106,11 @@ class MultiplayerLoadingGui extends GuiImage {
|
||||||
loadText.text.text = str;
|
loadText.text.text = str;
|
||||||
loadTextBg.text.text = str;
|
loadTextBg.text.text = str;
|
||||||
loadAnim.anim.visible = false;
|
loadAnim.anim.visible = false;
|
||||||
|
backButton.text.text.text = "Ok";
|
||||||
var backButton = new GuiXboxButton("Ok", 160);
|
|
||||||
backButton.position = new Vector(960, 0);
|
|
||||||
backButton.vertSizing = Bottom;
|
|
||||||
backButton.horizSizing = Right;
|
|
||||||
backButton.gamepadAccelerator = ["A"];
|
|
||||||
backButton.accelerators = [hxd.Key.ENTER];
|
|
||||||
backButton.pressedAction = (e) -> {
|
backButton.pressedAction = (e) -> {
|
||||||
MarbleGame.canvas.setContent(new MultiplayerGui());
|
MarbleGame.canvas.setContent(new MultiplayerGui());
|
||||||
};
|
};
|
||||||
bottomBar.addChild(backButton);
|
|
||||||
MarbleGame.canvas.render(MarbleGame.canvas.scene2d);
|
MarbleGame.canvas.render(MarbleGame.canvas.scene2d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -135,6 +135,7 @@ class MasterServerClient {
|
||||||
if (conts.type == "connectResponse") {
|
if (conts.type == "connectResponse") {
|
||||||
Console.log("Remote Description Received!");
|
Console.log("Remote Description Received!");
|
||||||
var sdpObj = Json.parse(conts.sdp);
|
var sdpObj = Json.parse(conts.sdp);
|
||||||
|
if (@:privateAccess Net.client != null)
|
||||||
@:privateAccess Net.client.setRemoteDescription(sdpObj.sdp, sdpObj.type);
|
@:privateAccess Net.client.setRemoteDescription(sdpObj.sdp, sdpObj.type);
|
||||||
}
|
}
|
||||||
if (conts.type == "connectFailed") {
|
if (conts.type == "connectFailed") {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue