Skip to content

Commit

Permalink
Merge pull request #1148 from space-syndicate/upstream-sync-new
Browse files Browse the repository at this point in the history
Upstream sync new
  • Loading branch information
Morb0 committed Jun 19, 2023
2 parents 763dd4c + ff4b64b commit 0306801
Show file tree
Hide file tree
Showing 2,025 changed files with 289,443 additions and 295,782 deletions.
3 changes: 3 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
if ! has nix_direnv_version || ! nix_direnv_version 2.3.0; then
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.3.0/direnvrc" "sha256-Dmd+j63L84wuzgyjITIfSxSD57Tx7v51DMxVZOsiUD8="
fi
use flake
2 changes: 1 addition & 1 deletion Content.Client/Actions/ActionsSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public void UnlinkAllActions()
public void LinkAllActions(ActionsComponent? actions = null)
{
var player = _playerManager.LocalPlayer?.ControlledEntity;
if (player == null || !Resolve(player.Value, ref actions))
if (player == null || !Resolve(player.Value, ref actions, false))
{
return;
}
Expand Down
126 changes: 59 additions & 67 deletions Content.Client/Arcade/BlockGameMenu.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
Expand All @@ -20,16 +21,16 @@ namespace Content.Client.Arcade
{
public sealed class BlockGameMenu : DefaultWindow
{
private static readonly Color OverlayBackgroundColor = new(74,74,81,180);
private static readonly Color OverlayShadowColor = new(0,0,0,83);
private static readonly Color OverlayBackgroundColor = new(74, 74, 81, 180);
private static readonly Color OverlayShadowColor = new(0, 0, 0, 83);

private static readonly Vector2 BlockSize = new(15,15);
private static readonly Vector2 BlockSize = new(15, 15);

private readonly BlockGameBoundUserInterface _owner;

private readonly PanelContainer _mainPanel;

private BoxContainer _gameRootContainer;
private readonly BoxContainer _gameRootContainer;
private GridContainer _gameGrid = default!;
private GridContainer _nextBlockGrid = default!;
private GridContainer _holdBlockGrid = default!;
Expand Down Expand Up @@ -82,7 +83,7 @@ public BlockGameMenu(BlockGameBoundUserInterface owner)
_gameRootContainer.AddChild(_levelLabel);
_gameRootContainer.AddChild(new Control
{
MinSize = new Vector2(1,5)
MinSize = new Vector2(1, 5)
});

_pointsLabel = new Label
Expand All @@ -93,7 +94,7 @@ public BlockGameMenu(BlockGameBoundUserInterface owner)
_gameRootContainer.AddChild(_pointsLabel);
_gameRootContainer.AddChild(new Control
{
MinSize = new Vector2(1,10)
MinSize = new Vector2(1, 10)
});

var gameBox = new BoxContainer
Expand All @@ -103,20 +104,20 @@ public BlockGameMenu(BlockGameBoundUserInterface owner)
gameBox.AddChild(SetupHoldBox(backgroundTexture));
gameBox.AddChild(new Control
{
MinSize = new Vector2(10,1)
MinSize = new Vector2(10, 1)
});
gameBox.AddChild(SetupGameGrid(backgroundTexture));
gameBox.AddChild(new Control
{
MinSize = new Vector2(10,1)
MinSize = new Vector2(10, 1)
});
gameBox.AddChild(SetupNextBox(backgroundTexture));

_gameRootContainer.AddChild(gameBox);

_gameRootContainer.AddChild(new Control
{
MinSize = new Vector2(1,10)
MinSize = new Vector2(1, 10)
});

_pauseButton = new Button
Expand Down Expand Up @@ -176,7 +177,7 @@ public BlockGameMenu(BlockGameBoundUserInterface owner)
_owner.SendAction(BlockGamePlayerAction.NewGame);
};
pauseMenuContainer.AddChild(_newGameButton);
pauseMenuContainer.AddChild(new Control{MinSize = new Vector2(1,10)});
pauseMenuContainer.AddChild(new Control { MinSize = new Vector2(1, 10) });

_scoreBoardButton = new Button
{
Expand All @@ -185,7 +186,7 @@ public BlockGameMenu(BlockGameBoundUserInterface owner)
};
_scoreBoardButton.OnPressed += (e) => _owner.SendAction(BlockGamePlayerAction.ShowHighscores);
pauseMenuContainer.AddChild(_scoreBoardButton);
_unpauseButtonMargin = new Control {MinSize = new Vector2(1, 10), Visible = false};
_unpauseButtonMargin = new Control { MinSize = new Vector2(1, 10), Visible = false };
pauseMenuContainer.AddChild(_unpauseButtonMargin);

_unpauseButton = new Button
Expand Down Expand Up @@ -239,13 +240,13 @@ public BlockGameMenu(BlockGameBoundUserInterface owner)
VerticalAlignment = VAlignment.Center
};

gameOverMenuContainer.AddChild(new Label{Text = Loc.GetString("blockgame-menu-msg-game-over"),Align = Label.AlignMode.Center});
gameOverMenuContainer.AddChild(new Control{MinSize = new Vector2(1,10)});
gameOverMenuContainer.AddChild(new Label { Text = Loc.GetString("blockgame-menu-msg-game-over"), Align = Label.AlignMode.Center });
gameOverMenuContainer.AddChild(new Control { MinSize = new Vector2(1, 10) });


_finalScoreLabel = new Label{Align = Label.AlignMode.Center};
_finalScoreLabel = new Label { Align = Label.AlignMode.Center };
gameOverMenuContainer.AddChild(_finalScoreLabel);
gameOverMenuContainer.AddChild(new Control{MinSize = new Vector2(1,10)});
gameOverMenuContainer.AddChild(new Control { MinSize = new Vector2(1, 10) });

_finalNewGameButton = new Button
{
Expand Down Expand Up @@ -275,7 +276,7 @@ public BlockGameMenu(BlockGameBoundUserInterface owner)
HorizontalAlignment = HAlignment.Center
};

var c = new Color(OverlayBackgroundColor.R,OverlayBackgroundColor.G,OverlayBackgroundColor.B,220);
var c = new Color(OverlayBackgroundColor.R, OverlayBackgroundColor.G, OverlayBackgroundColor.B, 220);
var innerBack = new StyleBoxTexture
{
Texture = backgroundTexture,
Expand All @@ -298,8 +299,8 @@ public BlockGameMenu(BlockGameBoundUserInterface owner)
VerticalAlignment = VAlignment.Center
};

menuContainer.AddChild(new Label{Text = Loc.GetString("blockgame-menu-label-highscores")});
menuContainer.AddChild(new Control{MinSize = new Vector2(1,10)});
menuContainer.AddChild(new Label { Text = Loc.GetString("blockgame-menu-label-highscores") });
menuContainer.AddChild(new Control { MinSize = new Vector2(1, 10) });

var highScoreBox = new BoxContainer
{
Expand All @@ -311,14 +312,14 @@ public BlockGameMenu(BlockGameBoundUserInterface owner)
Align = Label.AlignMode.Center
};
highScoreBox.AddChild(_localHighscoresLabel);
highScoreBox.AddChild(new Control{MinSize = new Vector2(40,1)});
highScoreBox.AddChild(new Control { MinSize = new Vector2(40, 1) });
_globalHighscoresLabel = new Label
{
Align = Label.AlignMode.Center
};
highScoreBox.AddChild(_globalHighscoresLabel);
menuContainer.AddChild(highScoreBox);
menuContainer.AddChild(new Control{MinSize = new Vector2(1,10)});
menuContainer.AddChild(new Control { MinSize = new Vector2(1, 10) });
_highscoreBackButton = new Button
{
Text = Loc.GetString("blockgame-menu-button-back"),
Expand Down Expand Up @@ -359,7 +360,7 @@ private Control SetupGameGrid(Texture panelTex)
HSeparationOverride = 1,
VSeparationOverride = 1
};
UpdateBlocks(new BlockGameBlock[0]);
UpdateBlocks(Array.Empty<BlockGameBlock>());

var back = new StyleBoxTexture
{
Expand All @@ -376,7 +377,7 @@ private Control SetupGameGrid(Texture panelTex)
};
var backgroundPanel = new PanelContainer
{
PanelOverride = new StyleBoxFlat{BackgroundColor = Color.FromHex("#86868d")}
PanelOverride = new StyleBoxFlat { BackgroundColor = Color.FromHex("#86868d") }
};
backgroundPanel.AddChild(_gameGrid);
gamePanel.AddChild(backgroundPanel);
Expand Down Expand Up @@ -416,7 +417,7 @@ private Control SetupNextBox(Texture panelTex)
nextBlockPanel.AddChild(nextCenterContainer);
grid.AddChild(nextBlockPanel);

grid.AddChild(new Label{Text = Loc.GetString("blockgame-menu-label-next"), Align = Label.AlignMode.Center});
grid.AddChild(new Label { Text = Loc.GetString("blockgame-menu-label-next"), Align = Label.AlignMode.Center });

return grid;
}
Expand Down Expand Up @@ -454,15 +455,17 @@ private Control SetupHoldBox(Texture panelTex)
holdBlockPanel.AddChild(holdCenterContainer);
grid.AddChild(holdBlockPanel);

grid.AddChild(new Label{Text = Loc.GetString("blockgame-menu-label-hold"), Align = Label.AlignMode.Center});
grid.AddChild(new Label { Text = Loc.GetString("blockgame-menu-label-hold"), Align = Label.AlignMode.Center });

return grid;
}

protected override void KeyboardFocusExited()
{
if (!IsOpen) return;
if(_gameOver) return;
if (!IsOpen)
return;
if (_gameOver)
return;
TryPause();
}

Expand All @@ -480,7 +483,8 @@ public void SetStarted()

public void SetScreen(BlockGameMessages.BlockGameScreen screen)
{
if (_gameOver) return;
if (_gameOver)
return;

switch (screen)
{
Expand Down Expand Up @@ -512,9 +516,12 @@ public void SetScreen(BlockGameMessages.BlockGameScreen screen)

private void CloseMenus()
{
if(_mainPanel.Children.Contains(_menuRootContainer)) _mainPanel.RemoveChild(_menuRootContainer);
if(_mainPanel.Children.Contains(_gameOverRootContainer)) _mainPanel.RemoveChild(_gameOverRootContainer);
if(_mainPanel.Children.Contains(_highscoresRootContainer)) _mainPanel.RemoveChild(_highscoresRootContainer);
if (_mainPanel.Children.Contains(_menuRootContainer))
_mainPanel.RemoveChild(_menuRootContainer);
if (_mainPanel.Children.Contains(_gameOverRootContainer))
_mainPanel.RemoveChild(_gameOverRootContainer);
if (_mainPanel.Children.Contains(_highscoresRootContainer))
_mainPanel.RemoveChild(_highscoresRootContainer);
}

public void SetGameoverInfo(int amount, int? localPlacement, int? globalPlacement)
Expand Down Expand Up @@ -563,72 +570,56 @@ protected override void KeyBindDown(GUIBoundKeyEventArgs args)
{
base.KeyBindDown(args);

if(!_isPlayer || args.Handled) return;
if (!_isPlayer || args.Handled)
return;

if (args.Function == ContentKeyFunctions.ArcadeLeft)
{
else if (args.Function == ContentKeyFunctions.ArcadeLeft)
_owner.SendAction(BlockGamePlayerAction.StartLeft);
}
else if (args.Function == ContentKeyFunctions.ArcadeRight)
{
_owner.SendAction(BlockGamePlayerAction.StartRight);
}
else if (args.Function == ContentKeyFunctions.ArcadeUp)
{
_owner.SendAction(BlockGamePlayerAction.Rotate);
}
else if (args.Function == ContentKeyFunctions.Arcade3)
{
_owner.SendAction(BlockGamePlayerAction.CounterRotate);
}
else if (args.Function == ContentKeyFunctions.ArcadeDown)
{
_owner.SendAction(BlockGamePlayerAction.SoftdropStart);
}
else if (args.Function == ContentKeyFunctions.Arcade2)
{
_owner.SendAction(BlockGamePlayerAction.Hold);
}
else if (args.Function == ContentKeyFunctions.Arcade1)
{
_owner.SendAction(BlockGamePlayerAction.Harddrop);
}
}

protected override void KeyBindUp(GUIBoundKeyEventArgs args)
{
base.KeyBindUp(args);

if(!_isPlayer || args.Handled) return;
if (!_isPlayer || args.Handled)
return;

if (args.Function == ContentKeyFunctions.ArcadeLeft)
{
else if (args.Function == ContentKeyFunctions.ArcadeLeft)
_owner.SendAction(BlockGamePlayerAction.EndLeft);
}
else if (args.Function == ContentKeyFunctions.ArcadeRight)
{
_owner.SendAction(BlockGamePlayerAction.EndRight);
}else if (args.Function == ContentKeyFunctions.ArcadeDown)
{
else if (args.Function == ContentKeyFunctions.ArcadeDown)
_owner.SendAction(BlockGamePlayerAction.SoftdropEnd);
}
}

public void UpdateNextBlock(BlockGameBlock[] blocks)
{
_nextBlockGrid.RemoveAllChildren();
if (blocks.Length == 0) return;
if (blocks.Length == 0)
return;
var columnCount = blocks.Max(b => b.Position.X) + 1;
var rowCount = blocks.Max(b => b.Position.Y) + 1;
_nextBlockGrid.Columns = columnCount;
for (int y = 0; y < rowCount; y++)
for (var y = 0; y < rowCount; y++)
{
for (int x = 0; x < columnCount; x++)
for (var x = 0; x < columnCount; x++)
{
var c = GetColorForPosition(blocks, x, y);
_nextBlockGrid.AddChild(new PanelContainer
{
PanelOverride = new StyleBoxFlat {BackgroundColor = c},
PanelOverride = new StyleBoxFlat { BackgroundColor = c },
MinSize = BlockSize,
RectDrawClipMargin = 0
});
Expand All @@ -639,18 +630,19 @@ public void UpdateNextBlock(BlockGameBlock[] blocks)
public void UpdateHeldBlock(BlockGameBlock[] blocks)
{
_holdBlockGrid.RemoveAllChildren();
if (blocks.Length == 0) return;
if (blocks.Length == 0)
return;
var columnCount = blocks.Max(b => b.Position.X) + 1;
var rowCount = blocks.Max(b => b.Position.Y) + 1;
_holdBlockGrid.Columns = columnCount;
for (int y = 0; y < rowCount; y++)
for (var y = 0; y < rowCount; y++)
{
for (int x = 0; x < columnCount; x++)
for (var x = 0; x < columnCount; x++)
{
var c = GetColorForPosition(blocks, x, y);
_holdBlockGrid.AddChild(new PanelContainer
{
PanelOverride = new StyleBoxFlat {BackgroundColor = c},
PanelOverride = new StyleBoxFlat { BackgroundColor = c },
MinSize = BlockSize,
RectDrawClipMargin = 0
});
Expand All @@ -661,24 +653,24 @@ public void UpdateHeldBlock(BlockGameBlock[] blocks)
public void UpdateBlocks(BlockGameBlock[] blocks)
{
_gameGrid.RemoveAllChildren();
for (int y = 0; y < 20; y++)
for (var y = 0; y < 20; y++)
{
for (int x = 0; x < 10; x++)
for (var x = 0; x < 10; x++)
{
var c = GetColorForPosition(blocks, x, y);
_gameGrid.AddChild(new PanelContainer
{
PanelOverride = new StyleBoxFlat {BackgroundColor = c},
PanelOverride = new StyleBoxFlat { BackgroundColor = c },
MinSize = BlockSize,
RectDrawClipMargin = 0
});
}
}
}

private Color GetColorForPosition(BlockGameBlock[] blocks, int x, int y)
private static Color GetColorForPosition(BlockGameBlock[] blocks, int x, int y)
{
Color c = Color.Transparent;
var c = Color.Transparent;
var matchingBlock = blocks.FirstOrNull(b => b.Position.X == x && b.Position.Y == y);
if (matchingBlock.HasValue)
{
Expand Down
Loading

0 comments on commit 0306801

Please sign in to comment.