Keybind (Controls) Page Implementation - UQdeco2800/2022-studio-2 GitHub Wiki

High Level Description

The keybinds or controls page is an additional semi-interactive help page that allows users to view the current actions and keybindings of the game.

Main Function Explanation

The implementation is split across the following files:

/core/assets/configs/keybinds.json

/core/src/main/com/deco2800/game/components/maingame/OpenKeyBinds.java

/core/src/main/com/deco2800/game/components/player/OpenPauseComponent.java

/core/src/main/com/deco2800/game/components/gamearea/GameAreaDisplay.java

/core/src/main/com/deco2800/game/services/ServiceLocator.java

The location of the different key level textures and key descriptions are located in the keybinds config file.

The OpenKeyBinds class constructs the KeyBind class entities through parsing the .json file, specifying their key, descriptive text and image texture paths.

This class is utilised by the OpenPauseCommponent.java class to enable screen management and visualisation in the GameAreaDisplay.java file. All keybinds displayed in this control menu are dynamically loaded based on the config file at compilation time.

How to view

To view, ensure game is full screen at 1920x1080p

(As of writing) Open the pause menu with the ESC key and click on the "Keybinds" button on the bottom left hand of the screen. Used the next key to cycle through the keybindings. Press ESC to exit.

Update UML Diagram

Updated UML diagram to properly reflect the relationship between finalised Sprint 4 polished OpenKeyBinds and OpenPauseComponent components.

image

UML Diagram

This is now out of date following the Sprint 4 code adjustments. UML_Keybinds

Current Implementation Pictures

Images taken as of commit https://github.com/UQdeco2800/2022-studio-2/commit/175022965dca5549aaf8683e7724468fa54f4293.

Level 1 Display image

Level 2 Display image

Known Bugs

Upon repeat usage of the NEXT key on the controls page the background screen darkens. This is only present when the controls menu is open and does not effect the pause menu. Bug fixed by removing slightly visible background.

Sprint 4 Polishing

Below are the various sprint 4 code improved files related to the implementation of the Keybind / Controls menu functionality. Each section will show the SonarCloud reports at the beginning and end of the sprint.

/core/src/main/com/deco2800/game/components/maingame/OpenKeyBinds.java

image

/core/src/main/com/deco2800/game/components/player/OpenPauseComponent.java

image

Improvements made to the OpenKeyBinds.java file were made in line with the changes outlined in the testing plan.

  • Alter the usage of static variables and functions to be more appropriate
  • Inclusion of new auxiliary variable return functions
  • Additional JUnit tests and modified JUnit tests

With these changes the SonarCloud report gives 100% code coverage, 0 code smells, and bugs.

image

The same was done to the OpenPauseComponent.java.

  • Alter the usage of static variables and functions to be more appropriate
  • Inclusion of new auxiliary variable return functions
  • Additional JUnit tests and modified JUnit tests

However beginning the initial polishing there were no JUnit tests, meaning all functionality required appropriate JUnit tests. Additionally a great deal of the code was adjusted to be simpler and feature less duplications.

As can be demonstrated by viewing the image below, the lines have been heavily reduced, with 100% code coverage, 0 duplications, and 0 code smells.

image

Who To Talk To?

Isaac Graham, (@The Master Craig#7285, IsaacGraham128)