Skip to content

Commit

Permalink
Merge pull request #16 from AristurtleDev/ui/controller-support
Browse files Browse the repository at this point in the history
Update UI Elements for Controller Support
  • Loading branch information
AristurtleDev authored Oct 28, 2023
2 parents 911c84e + dbf2298 commit 31b6b1d
Show file tree
Hide file tree
Showing 12 changed files with 494 additions and 34 deletions.
Binary file added assets/images/help_menu.psd
Binary file not shown.
Binary file added assets/images/xbox-controller-dark-mode.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
181 changes: 181 additions & 0 deletions assets/images/xbox-controller-dark-mode.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/xbox-controller-light-mode.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
181 changes: 181 additions & 0 deletions assets/images/xbox-controller-light-mode.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"version": 1,
"isRoot": true,
"tools": {
"dotnet-mgcb": {
"version": "3.8.1.303",
"commands": [
"mgcb"
]
},
"dotnet-mgcb-editor": {
"version": "3.8.1.303",
"commands": [
"mgcb-editor"
]
},
"dotnet-mgcb-editor-linux": {
"version": "3.8.1.303",
"commands": [
"mgcb-editor-linux"
]
},
"dotnet-mgcb-editor-windows": {
"version": "3.8.1.303",
"commands": [
"mgcb-editor-windows"
]
},
"dotnet-mgcb-editor-mac": {
"version": "3.8.1.303",
"commands": [
"mgcb-editor-mac"
]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

/outputDir:bin/$(Platform)
/intermediateDir:obj/$(Platform)
/platform:Windows
/config:
/profile:Reach
/compress:False
Expand All @@ -12,7 +13,6 @@

#---------------------------------- Content ---------------------------------#


#begin blocks/tex_block_bank_back_blue.png
/importer:TextureImporter
/processor:TextureProcessor
Expand Down Expand Up @@ -753,7 +753,19 @@
/processorParam:TextureFormat=Color
/build:menus/tex_menu_class_red.png

#begin menus/tex_menu_help.png
#begin menus/tex_menu_help_gamepad.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:menus/tex_menu_help_gamepad.png

#begin menus/tex_menu_help_keyboard_mouse.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
Expand All @@ -763,7 +775,7 @@
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:menus/tex_menu_help.png
/build:menus/tex_menu_help_keyboard_mouse.png

#begin menus/tex_menu_loading.png
/importer:TextureImporter
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 27 additions & 11 deletions source/Infiniminer/Infiniminer.Client.Shared/Engines/InputEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,19 @@ public class InputEngine
public VirtualButton SayToAll { get; private set; }

///////////////////////////////////////////////////////////////////////////
/// Select Button (don't know what else to call this)
/// This is the command that was used by the ESC key to bring up
/// the screen asking if the player wanted to pixelcide or quite
/// This is only available for keyboards
/// Show Help Button
/// This is the command that brings up the overlay screen showing the
/// help information and keyboard/controller bindings
///////////////////////////////////////////////////////////////////////////
public VirtualButton ShowHelpButton { get; private set; }

///////////////////////////////////////////////////////////////////////////
/// Show Options Button
/// This is the command that brings up the overlay text showing the
/// options to quit or pixelcide. For Gamepad it also displays the
/// options for changing team or changing class.
///////////////////////////////////////////////////////////////////////////
public VirtualButton SelectButton { get; private set; }
public VirtualButton ShowOptionsButton { get; private set; }

///////////////////////////////////////////////////////////////////////////
/// Quit Button
Expand Down Expand Up @@ -274,12 +281,14 @@ public InputEngine()
//
ChangeTeam = new VirtualButton();
ChangeTeam.Nodes.Add(new VirtualButton.Keyboard.Key(Keys.N));
ChangeTeam.Nodes.Add(new VirtualButton.GamePad.Button(Buttons.X));

//
// Change Class
//
ChangeClass = new VirtualButton();
ChangeClass.Nodes.Add(new VirtualButton.Keyboard.Key(Keys.M));
ChangeClass.Nodes.Add(new VirtualButton.GamePad.Button(Buttons.A));

//
// Say To Team
Expand All @@ -294,11 +303,18 @@ public InputEngine()
SayToAll.Nodes.Add(new VirtualButton.Keyboard.Key(Keys.Y));

//
// Select Button
// Show Help Button
//
ShowHelpButton = new VirtualButton();
ShowHelpButton.Nodes.Add(new VirtualButton.Keyboard.Key(Keys.F1));
ShowHelpButton.Nodes.Add(new VirtualButton.GamePad.Button(Buttons.Back));

//
// Show Options Button
//
SelectButton = new VirtualButton();
SelectButton.Nodes.Add(new VirtualButton.Keyboard.Key(Keys.Escape));
SelectButton.Nodes.Add(new VirtualButton.GamePad.Button(Buttons.Back));
ShowOptionsButton = new VirtualButton();
ShowOptionsButton.Nodes.Add(new VirtualButton.Keyboard.Key(Keys.Escape));
ShowOptionsButton.Nodes.Add(new VirtualButton.GamePad.Button(Buttons.Start));

//
// Quit Button
Expand Down Expand Up @@ -401,7 +417,7 @@ public void Register()
ChangeClass.Register();
SayToTeam.Register();
SayToAll.Register();
SelectButton.Register();
ShowHelpButton.Register();
MenuUp.Register();
MenuDown.Register();
MenuLeft.Register();
Expand Down Expand Up @@ -429,7 +445,7 @@ public void Unregister()
ChangeClass.Unregister();
SayToTeam.Unregister();
SayToAll.Unregister();
SelectButton.Unregister();
ShowHelpButton.Unregister();
MenuUp.Unregister();
MenuDown.Unregister();
MenuLeft.Unregister();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class InterfaceEngine
SpriteFont uiFont, radarFont;
Rectangle drawRect;

Texture2D texCrosshairs, texBlank, texHelp;
Texture2D texCrosshairs, texBlank, texHelpKeyboardMouse, texHelpGamePad;
Texture2D texRadarBackground, texRadarForeground, texRadarPlayerSame, texRadarPlayerAbove, texRadarPlayerBelow, texRadarPlayerPing, texRadarNorth;
Texture2D texToolRadarRed, texToolRadarBlue, texToolRadarGold, texToolRadarDiamond, texToolRadarLED, texToolRadarPointer, texToolRadarFlash;
Texture2D texToolDetonatorDownRed, texToolDetonatorUpRed, texToolDetonatorDownBlue, texToolDetonatorUpBlue;
Expand All @@ -67,7 +67,8 @@ public InterfaceEngine(InfiniminerGame gameInstance)
texRadarPlayerBelow = gameInstance.Content.Load<Texture2D>("ui/tex_radar_player_below");
texRadarPlayerPing = gameInstance.Content.Load<Texture2D>("ui/tex_radar_player_ping");
texRadarNorth = gameInstance.Content.Load<Texture2D>("ui/tex_radar_north");
texHelp = gameInstance.Content.Load<Texture2D>("menus/tex_menu_help");
texHelpKeyboardMouse = gameInstance.Content.Load<Texture2D>("menus/tex_menu_help_keyboard_mouse");
texHelpGamePad = gameInstance.Content.Load<Texture2D>("menus/tex_menu_help_gamepad");

texToolRadarRed = gameInstance.Content.Load<Texture2D>("tools/tex_tool_radar_red");
texToolRadarBlue = gameInstance.Content.Load<Texture2D>("tools/tex_tool_radar_blue");
Expand Down Expand Up @@ -401,24 +402,35 @@ public void Render(GraphicsDevice graphicsDevice)
spriteBatch.Draw(texRadarForeground, new Vector2(10, 30), Color.White);

// Draw escape message.
if (_P.inputEngine.SelectButton.Check())
if (_P.inputEngine.ShowOptionsButton.Check())
{
string quitMessage = string.Empty;
string pixelcideMessage = string.Empty;
string changeTeamMessage = string.Empty;
string changeClassMessage = string.Empty;

if (_P.inputEngine.ControlType == ControlType.KeyboardMouse)
{
quitMessage = "PRESS Y TO CONFIRM THAT YOU WANT TO QUIT.";
pixelcideMessage = "PRESS K TO COMMIT PIXELCIDE.";
changeClassMessage = "PRESS M TO CHANGE CLASS";
changeTeamMessage = "PRESS N TO CHANGE TEAMS";
}
else
{
quitMessage = "PRESS (Y) Button TO CONFIRM THAT YOU WANT TO QUIT.";
pixelcideMessage = "PRESS (B) Button TO COMMIT PIXELCIDE.";
quitMessage = "PRESS (Y) BUTTON TO CONFIRM THAT YOU WANT TO QUIT.";
pixelcideMessage = "PRESS (B) BUTTON TO COMMIT PIXELCIDE.";
changeClassMessage = "PRESS (A) BUTTON TO CHANGE CLASS";
changeTeamMessage = "PRESS (X) BUTTON TO CHANGE TEAM";
}

RenderMessageCenter(spriteBatch, quitMessage, new Vector2(graphicsDevice.Viewport.Width / 2, graphicsDevice.Viewport.Height / 2 + 30), Color.White, Color.Black);
RenderMessageCenter(spriteBatch, pixelcideMessage, new Vector2(graphicsDevice.Viewport.Width / 2, graphicsDevice.Viewport.Height / 2 + 80), Color.White, Color.Black);
if (_P.inputEngine.ControlType == ControlType.GamePad)
{
RenderMessageCenter(spriteBatch, changeClassMessage, new Vector2(graphicsDevice.Viewport.Width / 2, graphicsDevice.Viewport.Height / 2 - 80), Color.White, Color.Black);
RenderMessageCenter(spriteBatch, changeTeamMessage, new Vector2(graphicsDevice.Viewport.Width / 2, graphicsDevice.Viewport.Height / 2 + 30), Color.White, Color.Black);
}
RenderMessageCenter(spriteBatch, pixelcideMessage, new Vector2(graphicsDevice.Viewport.Width / 2, graphicsDevice.Viewport.Height / 2 - 30), Color.White, Color.Black);
RenderMessageCenter(spriteBatch, quitMessage, new Vector2(graphicsDevice.Viewport.Width / 2, graphicsDevice.Viewport.Height / 2 + +80), Color.White, Color.Black);

}

Expand All @@ -430,7 +442,7 @@ public void Render(GraphicsDevice graphicsDevice)
if (_P.screenEffectCounter >= 2)
{
string deathMessage = string.Empty;
if(_P.inputEngine.ControlType == ControlType.KeyboardMouse)
if (_P.inputEngine.ControlType == ControlType.KeyboardMouse)
{
deathMessage = "You have died. Left click to respawn.";
}
Expand Down Expand Up @@ -458,10 +470,18 @@ public void Render(GraphicsDevice graphicsDevice)
}

// Draw the help screen.
if (Keyboard.GetState().IsKeyDown(Keys.F1))
if (_P.inputEngine.ShowHelpButton.Check())
{
spriteBatch.Draw(texBlank, new Rectangle(0, 0, graphicsDevice.Viewport.Width, graphicsDevice.Viewport.Height), Color.Black);
spriteBatch.Draw(texHelp, drawRect, Color.White);

if (_P.inputEngine.ControlType == ControlType.KeyboardMouse)
{
spriteBatch.Draw(texHelpKeyboardMouse, drawRect, Color.White);
}
else
{
spriteBatch.Draw(texHelpGamePad, drawRect, Color.White);
}
}

spriteBatch.End();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,12 +270,22 @@ public override string OnUpdate(GameTime gameTime, KeyboardState keyState, Mouse

///////////////////////////////////////////////////////////////////
/// Check if player wants to change class
/// (Keyboard only, gamepad check is during options section below)
///////////////////////////////////////////////////////////////////
if (_P.inputEngine.ChangeClass.Pressed())
if (_P.inputEngine.ChangeClass.Pressed() && _P.inputEngine.ControlType == ControlType.KeyboardMouse)
{
nextState = "Infiniminer.States.ClassSelectionState";
}

///////////////////////////////////////////////////////////////////
/// Check if player wants to change team
/// (Keyboard only, gamepad check is during options section below)
///////////////////////////////////////////////////////////////////
if (_P.inputEngine.ChangeTeam.Pressed() && _P.inputEngine.ControlType == ControlType.KeyboardMouse)
{
nextState = "Infiniminer.States.TeamSelectionState";
}

///////////////////////////////////////////////////////////////////
/// Check if player wants to enter a chat mode
///////////////////////////////////////////////////////////////////
Expand All @@ -292,7 +302,7 @@ public override string OnUpdate(GameTime gameTime, KeyboardState keyState, Mouse
///////////////////////////////////////////////////////////////////
/// Check if player want to quit match or commit pixelcide
///////////////////////////////////////////////////////////////////
if (_P.inputEngine.SelectButton.Check())
if (_P.inputEngine.ShowOptionsButton.Check())
{
if (_P.inputEngine.QuitButton.Pressed())
{
Expand All @@ -304,16 +314,20 @@ public override string OnUpdate(GameTime gameTime, KeyboardState keyState, Mouse
{
_P.KillPlayer("HAS COMMITTED PIXELCIDE!");
}
}

///////////////////////////////////////////////////////////////////
/// Check if player wants to change team
///////////////////////////////////////////////////////////////////
if (_P.inputEngine.ChangeTeam.Pressed())
{
nextState = "Infiniminer.States.TeamSelectionState";
if (_P.inputEngine.ChangeTeam.Pressed())
{
nextState = "Infiniminer.States.TeamSelectionState";
}

if (_P.inputEngine.ChangeClass.Pressed())
{
nextState = "Infiniminer.States.ClassSelectionState";
}
}



///////////////////////////////////////////////////////////////////
/// Update the players position
///////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -369,7 +383,7 @@ public override string OnUpdate(GameTime gameTime, KeyboardState keyState, Mouse
///////////////////////////////////////////////////////////////////
/// Player is dead, check for respawn
///////////////////////////////////////////////////////////////////
if(_P.screenEffectCounter > 2 && _P.inputEngine.UseTool.Pressed())
if (_P.screenEffectCounter > 2 && _P.inputEngine.UseTool.Pressed())
{
_P.inputEngine.UseTool.ConsumePress();
_P.RespawnPlayer();
Expand Down

0 comments on commit 31b6b1d

Please sign in to comment.