mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2025-10-30 08:11:25 +00:00
minor gui fixes
This commit is contained in:
parent
bac95e7881
commit
05b0b37e8c
7 changed files with 174 additions and 110 deletions
|
|
@ -190,6 +190,13 @@ class Console {
|
|||
MarbleGame.instance.world.rollback(t);
|
||||
} else if (cmdType == 'addDummy') {
|
||||
Net.addDummyConnection();
|
||||
} else if (cmdType == 'setfps') {
|
||||
var scale = Std.parseFloat(cmdSplit[1]);
|
||||
if (Math.isNaN(scale))
|
||||
scale = 1;
|
||||
MarbleGame.instance.fpsLimit = scale;
|
||||
MarbleGame.instance.limitingFps = true;
|
||||
log("Set FPS to " + scale);
|
||||
} else {
|
||||
error("Unknown command");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,6 +60,10 @@ class MarbleGame {
|
|||
var _mouseWheelDelta:Float;
|
||||
var _exitingToMenu:Bool = false;
|
||||
|
||||
var fpsLimit:Float = 60;
|
||||
var limitingFps:Bool = false;
|
||||
var fpsLimitAccum:Float = 0.0;
|
||||
|
||||
public function new(scene2d:h2d.Scene, scene:h3d.scene.Scene) {
|
||||
Console.log("Initializing the game...");
|
||||
canvas = new Canvas(scene2d, cast this);
|
||||
|
|
@ -189,6 +193,16 @@ class MarbleGame {
|
|||
|
||||
public function update(dt:Float) {
|
||||
MasterServerClient.process();
|
||||
|
||||
if (limitingFps) {
|
||||
fpsLimitAccum += dt;
|
||||
if (fpsLimitAccum < 1.0 / fpsLimit) {
|
||||
return;
|
||||
}
|
||||
fpsLimitAccum -= (1.0 / fpsLimit);
|
||||
dt = 1.0 / fpsLimit;
|
||||
}
|
||||
|
||||
if (world != null) {
|
||||
if (world._disposed) {
|
||||
world = null;
|
||||
|
|
|
|||
|
|
@ -26,14 +26,17 @@ class GuiXboxOptionsList extends GuiControl {
|
|||
var _prevMousePos:Vector;
|
||||
var usedGamepad:Bool = false;
|
||||
|
||||
var enableButtons:Bool = true;
|
||||
|
||||
public var selected:Bool = false;
|
||||
|
||||
public var list:GuiXboxOptionsListCollection;
|
||||
|
||||
public function new(icon:Int, name:String, values:Array<String>, midcolumn:Float = 0.3, textOff = 155.5) {
|
||||
public function new(icon:Int, name:String, values:Array<String>, midcolumn:Float = 0.3, textOff = 155.5, enableButtons:Bool = true) {
|
||||
super();
|
||||
|
||||
this.options = values;
|
||||
this.enableButtons = enableButtons;
|
||||
|
||||
var baseImage = ResourceLoader.getResource("data/ui/xbox/optionsCursorArray.png", ResourceLoader.getImage, this.imageResources).toTile();
|
||||
var inactiveImage = baseImage.sub(0, 2, 815, 94);
|
||||
|
|
@ -65,27 +68,29 @@ class GuiXboxOptionsList extends GuiControl {
|
|||
var rightShadeFilter = new h2d.filter.ColorMatrix(cmat);
|
||||
rightShadeFilter.enable = false;
|
||||
|
||||
leftButton = new GuiAnim([arrowButtonImage, arrowButtonImagePressed]);
|
||||
leftButton.position = new Vector(815 * midcolumn, 0);
|
||||
leftButton.extent = new Vector(114, 94);
|
||||
leftButton.anim.filter = leftShadeFilter;
|
||||
this.addChild(leftButton);
|
||||
if (enableButtons) {
|
||||
leftButton = new GuiAnim([arrowButtonImage, arrowButtonImagePressed]);
|
||||
leftButton.position = new Vector(815 * midcolumn, 0);
|
||||
leftButton.extent = new Vector(114, 94);
|
||||
leftButton.anim.filter = leftShadeFilter;
|
||||
this.addChild(leftButton);
|
||||
|
||||
var leftButtonIcon = new GuiAnim([leftArrow, leftArrowSelected]);
|
||||
leftButtonIcon.position = new Vector(39, 36);
|
||||
leftButtonIcon.extent = new Vector(22, 22);
|
||||
leftButton.addChild(leftButtonIcon);
|
||||
var leftButtonIcon = new GuiAnim([leftArrow, leftArrowSelected]);
|
||||
leftButtonIcon.position = new Vector(39, 36);
|
||||
leftButtonIcon.extent = new Vector(22, 22);
|
||||
leftButton.addChild(leftButtonIcon);
|
||||
|
||||
rightButton = new GuiAnim([arrowButtonImage, arrowButtonImagePressed]);
|
||||
rightButton.position = new Vector(815 * 0.8, 0);
|
||||
rightButton.extent = new Vector(114, 94);
|
||||
rightButton.anim.filter = rightShadeFilter;
|
||||
this.addChild(rightButton);
|
||||
rightButton = new GuiAnim([arrowButtonImage, arrowButtonImagePressed]);
|
||||
rightButton.position = new Vector(815 * 0.8, 0);
|
||||
rightButton.extent = new Vector(114, 94);
|
||||
rightButton.anim.filter = rightShadeFilter;
|
||||
this.addChild(rightButton);
|
||||
|
||||
var rightButtonIcon = new GuiAnim([rightArrow, rightArrowSelected]);
|
||||
rightButtonIcon.position = new Vector(52, 36);
|
||||
rightButtonIcon.extent = new Vector(22, 22);
|
||||
rightButton.addChild(rightButtonIcon);
|
||||
var rightButtonIcon = new GuiAnim([rightArrow, rightArrowSelected]);
|
||||
rightButtonIcon.position = new Vector(52, 36);
|
||||
rightButtonIcon.extent = new Vector(22, 22);
|
||||
rightButton.addChild(rightButtonIcon);
|
||||
}
|
||||
|
||||
var arial14fontdata = ResourceLoader.getFileEntry("data/font/Arial Bold.fnt");
|
||||
var arial14b = new BitmapFont(arial14fontdata.entry);
|
||||
|
|
@ -148,100 +153,102 @@ class GuiXboxOptionsList extends GuiControl {
|
|||
optionText.text.textColor = 0x787878;
|
||||
}
|
||||
}
|
||||
var leftBtnRect = leftButton.getHitTestRect();
|
||||
leftBtnRect.position = leftBtnRect.position.add(new Vector(15 * Settings.uiScale, 21 * Settings.uiScale));
|
||||
leftBtnRect.extent.set(83 * Settings.uiScale, 53 * Settings.uiScale);
|
||||
var rightBtnRect = rightButton.getHitTestRect();
|
||||
rightBtnRect.position = rightBtnRect.position.add(new Vector(15 * Settings.uiScale, 21 * Settings.uiScale));
|
||||
rightBtnRect.extent.set(83 * Settings.uiScale, 53 * Settings.uiScale);
|
||||
if (leftBtnRect.inRect(mouseState.position) || rightBtnRect.inRect(mouseState.position)) {
|
||||
if (Key.isPressed(Key.MOUSE_LEFT)) {
|
||||
AudioManager.playSound(ResourceLoader.getResource("data/sound/buttonpress.wav", ResourceLoader.getAudio, this.soundResources));
|
||||
if (enableButtons) {
|
||||
var leftBtnRect = leftButton.getHitTestRect();
|
||||
leftBtnRect.position = leftBtnRect.position.add(new Vector(15 * Settings.uiScale, 21 * Settings.uiScale));
|
||||
leftBtnRect.extent.set(83 * Settings.uiScale, 53 * Settings.uiScale);
|
||||
var rightBtnRect = rightButton.getHitTestRect();
|
||||
rightBtnRect.position = rightBtnRect.position.add(new Vector(15 * Settings.uiScale, 21 * Settings.uiScale));
|
||||
rightBtnRect.extent.set(83 * Settings.uiScale, 53 * Settings.uiScale);
|
||||
if (leftBtnRect.inRect(mouseState.position) || rightBtnRect.inRect(mouseState.position)) {
|
||||
if (Key.isPressed(Key.MOUSE_LEFT)) {
|
||||
AudioManager.playSound(ResourceLoader.getResource("data/sound/buttonpress.wav", ResourceLoader.getAudio, this.soundResources));
|
||||
}
|
||||
}
|
||||
}
|
||||
// Left Button
|
||||
if (leftBtnRect.inRect(mouseState.position)) {
|
||||
if (Key.isDown(Key.MOUSE_LEFT)) {
|
||||
leftButton.anim.currentFrame = 1;
|
||||
leftButton.anim.filter.enable = true;
|
||||
// Left Button
|
||||
if (leftBtnRect.inRect(mouseState.position)) {
|
||||
if (Key.isDown(Key.MOUSE_LEFT)) {
|
||||
leftButton.anim.currentFrame = 1;
|
||||
leftButton.anim.filter.enable = true;
|
||||
} else {
|
||||
leftButton.anim.currentFrame = 1;
|
||||
leftButton.anim.filter.enable = false;
|
||||
}
|
||||
if (Key.isReleased(Key.MOUSE_LEFT)) {
|
||||
var newOption = currentOption - 1;
|
||||
if (newOption < 0)
|
||||
newOption = options.length - 1;
|
||||
|
||||
var doChange = true;
|
||||
if (onChangeFunc != null)
|
||||
doChange = onChangeFunc(newOption);
|
||||
if (doChange) {
|
||||
currentOption = newOption;
|
||||
optionText.text.text = options[currentOption];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
leftButton.anim.currentFrame = 1;
|
||||
leftButton.anim.currentFrame = 0;
|
||||
leftButton.anim.filter.enable = false;
|
||||
}
|
||||
if (Key.isReleased(Key.MOUSE_LEFT)) {
|
||||
var newOption = currentOption - 1;
|
||||
if (newOption < 0)
|
||||
newOption = options.length - 1;
|
||||
|
||||
var doChange = true;
|
||||
if (onChangeFunc != null)
|
||||
doChange = onChangeFunc(newOption);
|
||||
if (doChange) {
|
||||
currentOption = newOption;
|
||||
optionText.text.text = options[currentOption];
|
||||
// Right Button
|
||||
if (rightBtnRect.inRect(mouseState.position)) {
|
||||
if (Key.isDown(Key.MOUSE_LEFT)) {
|
||||
rightButton.anim.currentFrame = 1;
|
||||
rightButton.anim.filter.enable = true;
|
||||
} else {
|
||||
rightButton.anim.currentFrame = 1;
|
||||
rightButton.anim.filter.enable = false;
|
||||
}
|
||||
if (Key.isReleased(Key.MOUSE_LEFT)) {
|
||||
var newOption = currentOption + 1;
|
||||
if (newOption >= options.length)
|
||||
newOption = 0;
|
||||
|
||||
var doChange = true;
|
||||
if (onChangeFunc != null)
|
||||
doChange = onChangeFunc(newOption);
|
||||
if (doChange) {
|
||||
currentOption = newOption;
|
||||
optionText.text.text = options[currentOption];
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
leftButton.anim.currentFrame = 0;
|
||||
leftButton.anim.filter.enable = false;
|
||||
}
|
||||
// Right Button
|
||||
if (rightBtnRect.inRect(mouseState.position)) {
|
||||
if (Key.isDown(Key.MOUSE_LEFT)) {
|
||||
rightButton.anim.currentFrame = 1;
|
||||
rightButton.anim.filter.enable = true;
|
||||
} else {
|
||||
rightButton.anim.currentFrame = 1;
|
||||
rightButton.anim.currentFrame = 0;
|
||||
rightButton.anim.filter.enable = false;
|
||||
}
|
||||
if (Key.isReleased(Key.MOUSE_LEFT)) {
|
||||
var newOption = currentOption + 1;
|
||||
if (newOption >= options.length)
|
||||
newOption = 0;
|
||||
if (selected || alwaysActive) {
|
||||
if (Key.isPressed(Key.LEFT) || Gamepad.isPressed(['dpadLeft']) || (Gamepad.getAxis('analogX') < -0.75 && !usedGamepad)) {
|
||||
var newOption = currentOption - 1;
|
||||
if (newOption < 0)
|
||||
newOption = options.length - 1;
|
||||
|
||||
var doChange = true;
|
||||
if (onChangeFunc != null)
|
||||
doChange = onChangeFunc(newOption);
|
||||
if (doChange) {
|
||||
currentOption = newOption;
|
||||
optionText.text.text = options[currentOption];
|
||||
var doChange = true;
|
||||
if (onChangeFunc != null)
|
||||
doChange = onChangeFunc(newOption);
|
||||
if (doChange) {
|
||||
currentOption = newOption;
|
||||
optionText.text.text = options[currentOption];
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
rightButton.anim.currentFrame = 0;
|
||||
rightButton.anim.filter.enable = false;
|
||||
}
|
||||
if (selected || alwaysActive) {
|
||||
if (Key.isPressed(Key.LEFT) || Gamepad.isPressed(['dpadLeft']) || (Gamepad.getAxis('analogX') < -0.75 && !usedGamepad)) {
|
||||
var newOption = currentOption - 1;
|
||||
if (newOption < 0)
|
||||
newOption = options.length - 1;
|
||||
if (Key.isPressed(Key.RIGHT) || Gamepad.isPressed(['dpadRight']) || (Gamepad.getAxis('analogX') > 0.75 && !usedGamepad)) {
|
||||
var newOption = currentOption + 1;
|
||||
if (newOption >= options.length)
|
||||
newOption = 0;
|
||||
|
||||
var doChange = true;
|
||||
if (onChangeFunc != null)
|
||||
doChange = onChangeFunc(newOption);
|
||||
if (doChange) {
|
||||
currentOption = newOption;
|
||||
optionText.text.text = options[currentOption];
|
||||
var doChange = true;
|
||||
if (onChangeFunc != null)
|
||||
doChange = onChangeFunc(newOption);
|
||||
if (doChange) {
|
||||
currentOption = newOption;
|
||||
optionText.text.text = options[currentOption];
|
||||
}
|
||||
}
|
||||
if (Math.abs(Gamepad.getAxis('analogX')) > 0.75)
|
||||
usedGamepad = true;
|
||||
else
|
||||
usedGamepad = false;
|
||||
}
|
||||
if (Key.isPressed(Key.RIGHT) || Gamepad.isPressed(['dpadRight']) || (Gamepad.getAxis('analogX') > 0.75 && !usedGamepad)) {
|
||||
var newOption = currentOption + 1;
|
||||
if (newOption >= options.length)
|
||||
newOption = 0;
|
||||
|
||||
var doChange = true;
|
||||
if (onChangeFunc != null)
|
||||
doChange = onChangeFunc(newOption);
|
||||
if (doChange) {
|
||||
currentOption = newOption;
|
||||
optionText.text.text = options[currentOption];
|
||||
}
|
||||
}
|
||||
if (Math.abs(Gamepad.getAxis('analogX')) > 0.75)
|
||||
usedGamepad = true;
|
||||
else
|
||||
usedGamepad = false;
|
||||
}
|
||||
super.update(dt, mouseState);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,10 +59,20 @@ class MPServerListGui extends GuiImage {
|
|||
|
||||
function imgLoader(path:String) {
|
||||
switch (path) {
|
||||
case "locked":
|
||||
return ResourceLoader.getResource("data/ui/xbox/DemoOutOfTimeIcon.png", ResourceLoader.getImage, this.imageResources).toTile();
|
||||
case "unlocked":
|
||||
case "ready":
|
||||
return ResourceLoader.getResource("data/ui/xbox/Ready.png", ResourceLoader.getImage, this.imageResources).toTile();
|
||||
case "notready":
|
||||
return ResourceLoader.getResource("data/ui/xbox/NotReady.png", ResourceLoader.getImage, this.imageResources).toTile();
|
||||
case "pc":
|
||||
return ResourceLoader.getResource("data/ui/xbox/platform_desktop.png", ResourceLoader.getImage, this.imageResources).toTile();
|
||||
case "mac":
|
||||
return ResourceLoader.getResource("data/ui/xbox/platform_mac.png", ResourceLoader.getImage, this.imageResources).toTile();
|
||||
case "web":
|
||||
return ResourceLoader.getResource("data/ui/xbox/platform_web.png", ResourceLoader.getImage, this.imageResources).toTile();
|
||||
case "android":
|
||||
return ResourceLoader.getResource("data/ui/xbox/platform_android.png", ResourceLoader.getImage, this.imageResources).toTile();
|
||||
case "unknown":
|
||||
return ResourceLoader.getResource("data/ui/xbox/platform_unknown.png", ResourceLoader.getImage, this.imageResources).toTile();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
@ -84,9 +94,10 @@ class MPServerListGui extends GuiImage {
|
|||
serverWnd.addChild(serverList);
|
||||
|
||||
var ourServerList:Array<RemoteServerInfo> = [];
|
||||
var platformToString = ["unknown", "pc", "mac", "web", "android"];
|
||||
|
||||
function updateServerListDisplay() {
|
||||
serverDisplays = ourServerList.map(x -> x.name);
|
||||
serverDisplays = ourServerList.map(x -> return '<img src="${platformToString[x.platform]}"></img><font color="#101010">${x.name}</font>');
|
||||
serverList.setTexts(serverDisplays);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -268,7 +268,7 @@ class MultiplayerLevelSelectGui extends GuiImage {
|
|||
levelWnd.addChild(levelInfoLeft);
|
||||
|
||||
var levelNames = difficultyMissions.map(x -> x.title);
|
||||
var levelSelectOpts = new GuiXboxOptionsList(6, "Level", levelNames);
|
||||
var levelSelectOpts = new GuiXboxOptionsList(6, "Level", levelNames, 0.3, 155.5, isHost);
|
||||
|
||||
function setLevel(idx:Int) {
|
||||
// if (lock)
|
||||
|
|
|
|||
|
|
@ -75,6 +75,8 @@ class PlayGui {
|
|||
var playerListContainer:GuiControl;
|
||||
var playerListCtrl:GuiMLTextListCtrl;
|
||||
var playerListScoresCtrl:GuiMLTextListCtrl;
|
||||
var playerListShadowCtrl:GuiMLTextListCtrl;
|
||||
var playerListScoresShadowCtrl:GuiMLTextListCtrl;
|
||||
var playerList:Array<PlayerInfo> = [];
|
||||
|
||||
var imageResources:Array<Resource<Image>> = [];
|
||||
|
|
@ -695,9 +697,25 @@ class PlayGui {
|
|||
// '<font color="#EBEBEB"><img src="them"></img>Player 2 2</font>'
|
||||
// ];
|
||||
|
||||
var ds = new h2d.filter.DropShadow(1.414, 0.785, 0x000000, 1, 0, 0.4, 1, true);
|
||||
// var ds = new h2d.filter.DropShadow(1.414, 0.785, 0x000000, 1, 0, 0.4, 1, true);
|
||||
|
||||
playerListCtrl = new GuiMLTextListCtrl(arial14, [], imgLoader, ds);
|
||||
playerListShadowCtrl = new GuiMLTextListCtrl(arial14, [], imgLoader);
|
||||
|
||||
playerListShadowCtrl.position = new Vector(28, 44);
|
||||
playerListShadowCtrl.extent = new Vector(392, 271);
|
||||
playerListShadowCtrl.scrollable = true;
|
||||
playerListShadowCtrl.onSelectedFunc = (sel) -> {}
|
||||
playerListContainer.addChild(playerListShadowCtrl);
|
||||
|
||||
playerListScoresShadowCtrl = new GuiMLTextListCtrl(arial14, [], imgLoader);
|
||||
|
||||
playerListScoresShadowCtrl.position = new Vector(278, 44);
|
||||
playerListScoresShadowCtrl.extent = new Vector(392, 271);
|
||||
playerListScoresShadowCtrl.scrollable = true;
|
||||
playerListScoresShadowCtrl.onSelectedFunc = (sel) -> {}
|
||||
playerListContainer.addChild(playerListScoresShadowCtrl);
|
||||
|
||||
playerListCtrl = new GuiMLTextListCtrl(arial14, [], imgLoader);
|
||||
|
||||
playerListCtrl.position = new Vector(27, 43);
|
||||
playerListCtrl.extent = new Vector(392, 271);
|
||||
|
|
@ -705,7 +723,7 @@ class PlayGui {
|
|||
playerListCtrl.onSelectedFunc = (sel) -> {}
|
||||
playerListContainer.addChild(playerListCtrl);
|
||||
|
||||
playerListScoresCtrl = new GuiMLTextListCtrl(arial14, [], imgLoader, ds);
|
||||
playerListScoresCtrl = new GuiMLTextListCtrl(arial14, [], imgLoader);
|
||||
|
||||
playerListScoresCtrl.position = new Vector(277, 43);
|
||||
playerListScoresCtrl.extent = new Vector(392, 271);
|
||||
|
|
@ -717,13 +735,19 @@ class PlayGui {
|
|||
public function redrawPlayerList() {
|
||||
var pl = [];
|
||||
var plScores = [];
|
||||
var plShadow = [];
|
||||
var plShadowScores = [];
|
||||
playerList.sort((a, b) -> a.score > b.score ? -1 : (a.score < b.score ? 1 : 0));
|
||||
for (item in playerList) {
|
||||
pl.push('<font color="#EBEBEB"><img src="${item.us ? "us" : "them"}"></img>${Util.rightPad(item.name, 25, 3)}</font>');
|
||||
plScores.push('<font color="#EBEBEB">${item.score}</font>');
|
||||
plShadow.push('<font color="#000000"><img src="them"></img>${Util.rightPad(item.name, 25, 3)}</font>');
|
||||
plShadowScores.push('<font color="#000000">${item.score}</font>');
|
||||
}
|
||||
playerListCtrl.setTexts(pl);
|
||||
playerListScoresCtrl.setTexts(plScores);
|
||||
playerListShadowCtrl.setTexts(plShadow);
|
||||
playerListScoresShadowCtrl.setTexts(plShadowScores);
|
||||
}
|
||||
|
||||
public function doMPEndGameMessage() {
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ typedef RemoteServerInfo = {
|
|||
name:String,
|
||||
players:Int,
|
||||
maxPlayers:Int,
|
||||
platform:String,
|
||||
platform:Int,
|
||||
}
|
||||
|
||||
class MasterServerClient {
|
||||
|
|
@ -78,7 +78,8 @@ class MasterServerClient {
|
|||
privateSlots: serverInfo.privateSlots,
|
||||
privateServer: serverInfo.privateServer,
|
||||
inviteCode: serverInfo.inviteCode,
|
||||
state: serverInfo.state
|
||||
state: serverInfo.state,
|
||||
platform: serverInfo.platform
|
||||
}));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue