Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

T3branch External UI #212

Merged
merged 38 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
5cb1b29
Added code for custom cursor
Death7Bed Sep 15, 2023
6ca65c1
Cursor added
Death7Bed Sep 16, 2023
cd34e9c
Created a method to implement different types of button universally
Moksh-Mehta7 Sep 17, 2023
f262c86
Added Cursor
Moksh-Mehta7 Sep 19, 2023
6fb4eee
Created asset loader
Gaganx0 Sep 19, 2023
a63f380
Main Menu Background 1/n
aadityayadav17 Sep 26, 2023
f64d364
Made ButtonFactory.java Static
Moksh-Mehta7 Sep 28, 2023
d3cf853
Made ButtonFactory.java Static
Moksh-Mehta7 Sep 28, 2023
307a417
Made ButtonFactory.java Static
Moksh-Mehta7 Sep 28, 2023
715c95a
Main Menu Background 2/n
aadityayadav17 Sep 28, 2023
3b8c1e9
Main Menu Background 3/n
aadityayadav17 Sep 28, 2023
7f6aae8
Main Menu Background 4/n
aadityayadav17 Sep 28, 2023
50fb285
Merge remote-tracking branch 'origin/Team-3' into Team-3
Moksh-Mehta7 Sep 28, 2023
5926f22
Made changes in ButtonFactory
Moksh-Mehta7 Sep 28, 2023
b81b406
Main Menu Background 5/n
aadityayadav17 Sep 28, 2023
fd12185
Merge remote-tracking branch 'origin/Team-3' into Team-3
aadityayadav17 Sep 28, 2023
507ece0
Help screen
Gaganx0 Sep 29, 2023
7586598
Main Menu, Help Screen
Gaganx0 Sep 29, 2023
0737e49
Settings Screen 1/m
aadityayadav17 Oct 2, 2023
91043de
Settings Screen 2/m
aadityayadav17 Oct 2, 2023
306a45e
Main Menu Background 6/n
aadityayadav17 Oct 2, 2023
7130634
Merge branch 'main' into t3branch
Moksh-Mehta7 Oct 2, 2023
0af96ee
merged main into t3 brach
Moksh-Mehta7 Oct 2, 2023
aba7640
Edited StoryScreen
Moksh-Mehta7 Oct 2, 2023
1bcf302
Settings Screen Issue Fixed
aadityayadav17 Oct 2, 2023
9f11505
Java Doc Added
aadityayadav17 Oct 2, 2023
9c43232
Java Doc Added
aadityayadav17 Oct 2, 2023
b26862b
Merge remote-tracking branch 'origin/t3branch' into t3branch
aadityayadav17 Oct 2, 2023
3ba68b1
HelpScreen, back button , button sound
Gaganx0 Oct 2, 2023
ba4b4a7
Merge remote-tracking branch 'origin/t3branch' into t3branch
Gaganx0 Oct 2, 2023
84bdc98
Added Java Doc
Moksh-Mehta7 Oct 2, 2023
1c5d278
Merge remote-tracking branch 'origin/t3branch' into t3branch
Moksh-Mehta7 Oct 2, 2023
5bddacf
merge
Gaganx0 Oct 3, 2023
783dea2
Merge branch 'main' into t3branch
aadityayadav17 Oct 3, 2023
8e06584
Merge branch 'main' of https://github.com/UQcsse3200/2023-studio-3 in…
Gaganx0 Oct 3, 2023
ff85e4a
merge from main
aadityayadav17 Oct 3, 2023
9512fd2
bug fix
Gaganx0 Oct 3, 2023
8d161fa
Merge branch 't3branch' of https://github.com/UQcsse3200/2023-studio-…
Gaganx0 Oct 3, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions source/core/assets/configs/text.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"com.badlogic.gdx.graphics.g2d.BitmapFont": {
"default": {
"file": "images/ui/font.fnt"
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
99 changes: 99 additions & 0 deletions source/core/assets/images/ui/font.fnt
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
info face="Times New Roman" size=-32 bold=0 italic=0 charset="" unicode=1 stretchH=100 smooth=0 aa=1 padding=0,0,0,0 spacing=0,0 outline=0
common lineHeight=37 base=29 scaleW=256 scaleH=128 pages=1 packed=0 alphaChnl=0 redChnl=4 greenChnl=4 blueChnl=4
page id=0 file="font.png"
chars count=95
char id=32 x=0 y=0 width=0 height=0 xoffset=0 yoffset=0 xadvance=8 page=0 chnl=15
char id=33 x=251 y=20 width=4 height=23 xoffset=4 yoffset=6 xadvance=12 page=0 chnl=15
char id=34 x=47 y=96 width=9 height=10 xoffset=2 yoffset=6 xadvance=13 page=0 chnl=15
char id=35 x=151 y=15 width=15 height=23 xoffset=1 yoffset=6 xadvance=17 page=0 chnl=15
char id=36 x=169 y=77 width=13 height=26 xoffset=2 yoffset=5 xadvance=17 page=0 chnl=15
char id=37 x=0 y=82 width=25 height=24 xoffset=1 yoffset=6 xadvance=27 page=0 chnl=15
char id=38 x=21 y=53 width=23 height=24 xoffset=1 yoffset=6 xadvance=25 page=0 chnl=15
char id=39 x=61 y=96 width=3 height=10 xoffset=1 yoffset=6 xadvance=5 page=0 chnl=15
char id=40 x=218 y=37 width=9 height=30 xoffset=1 yoffset=6 xadvance=10 page=0 chnl=15
char id=41 x=225 y=67 width=9 height=30 xoffset=0 yoffset=6 xadvance=10 page=0 chnl=15
char id=42 x=232 y=0 width=11 height=13 xoffset=2 yoffset=6 xadvance=15 page=0 chnl=15
char id=43 x=155 y=105 width=17 height=18 xoffset=1 yoffset=10 xadvance=19 page=0 chnl=15
char id=44 x=56 y=96 width=5 height=9 xoffset=1 yoffset=25 xadvance=8 page=0 chnl=15
char id=45 x=52 y=24 width=8 height=3 xoffset=1 yoffset=20 xadvance=10 page=0 chnl=15
char id=46 x=38 y=77 width=3 height=4 xoffset=2 yoffset=25 xadvance=7 page=0 chnl=15
char id=47 x=198 y=100 width=9 height=23 xoffset=0 yoffset=6 xadvance=9 page=0 chnl=15
char id=48 x=166 y=15 width=14 height=23 xoffset=1 yoffset=6 xadvance=16 page=0 chnl=15
char id=49 x=206 y=15 width=10 height=22 xoffset=3 yoffset=7 xadvance=16 page=0 chnl=15
char id=50 x=141 y=82 width=15 height=23 xoffset=1 yoffset=6 xadvance=16 page=0 chnl=15
char id=51 x=156 y=82 width=13 height=23 xoffset=1 yoffset=6 xadvance=16 page=0 chnl=15
char id=52 x=160 y=38 width=14 height=22 xoffset=1 yoffset=7 xadvance=16 page=0 chnl=15
char id=53 x=184 y=55 width=13 height=22 xoffset=2 yoffset=7 xadvance=16 page=0 chnl=15
char id=54 x=180 y=15 width=13 height=23 xoffset=1 yoffset=6 xadvance=16 page=0 chnl=15
char id=55 x=141 y=105 width=14 height=22 xoffset=1 yoffset=7 xadvance=16 page=0 chnl=15
char id=56 x=186 y=100 width=12 height=23 xoffset=2 yoffset=6 xadvance=16 page=0 chnl=15
char id=57 x=182 y=77 width=13 height=23 xoffset=1 yoffset=6 xadvance=16 page=0 chnl=15
char id=58 x=236 y=13 width=3 height=15 xoffset=3 yoffset=14 xadvance=9 page=0 chnl=15
char id=59 x=251 y=0 width=5 height=20 xoffset=2 yoffset=14 xadvance=9 page=0 chnl=15
char id=60 x=167 y=60 width=17 height=17 xoffset=1 yoffset=10 xadvance=19 page=0 chnl=15
char id=61 x=29 y=22 width=17 height=7 xoffset=1 yoffset=15 xadvance=19 page=0 chnl=15
char id=62 x=174 y=38 width=17 height=17 xoffset=1 yoffset=10 xadvance=19 page=0 chnl=15
char id=63 x=195 y=77 width=12 height=23 xoffset=1 yoffset=6 xadvance=14 page=0 chnl=15
char id=64 x=0 y=0 width=29 height=30 xoffset=1 yoffset=6 xadvance=30 page=0 chnl=15
char id=65 x=0 y=106 width=24 height=22 xoffset=-1 yoffset=7 xadvance=23 page=0 chnl=15
char id=66 x=71 y=95 width=20 height=22 xoffset=0 yoffset=7 xadvance=22 page=0 chnl=15
char id=67 x=70 y=71 width=20 height=24 xoffset=1 yoffset=6 xadvance=21 page=0 chnl=15
char id=68 x=47 y=74 width=23 height=22 xoffset=0 yoffset=7 xadvance=24 page=0 chnl=15
char id=69 x=90 y=71 width=20 height=22 xoffset=0 yoffset=7 xadvance=20 page=0 chnl=15
char id=70 x=111 y=44 width=17 height=22 xoffset=0 yoffset=7 xadvance=18 page=0 chnl=15
char id=71 x=25 y=82 width=22 height=24 xoffset=1 yoffset=6 xadvance=23 page=0 chnl=15
char id=72 x=48 y=106 width=23 height=22 xoffset=0 yoffset=7 xadvance=24 page=0 chnl=15
char id=73 x=216 y=15 width=10 height=22 xoffset=0 yoffset=7 xadvance=11 page=0 chnl=15
char id=74 x=197 y=53 width=12 height=23 xoffset=0 yoffset=7 xadvance=12 page=0 chnl=15
char id=75 x=24 y=106 width=24 height=22 xoffset=0 yoffset=7 xadvance=24 page=0 chnl=15
char id=76 x=91 y=46 width=20 height=22 xoffset=0 yoffset=7 xadvance=20 page=0 chnl=15
char id=77 x=29 y=0 width=28 height=22 xoffset=0 yoffset=7 xadvance=29 page=0 chnl=15
char id=78 x=57 y=0 width=24 height=22 xoffset=-1 yoffset=7 xadvance=23 page=0 chnl=15
char id=79 x=78 y=22 width=21 height=24 xoffset=1 yoffset=6 xadvance=23 page=0 chnl=15
char id=80 x=118 y=22 width=17 height=22 xoffset=0 yoffset=7 xadvance=18 page=0 chnl=15
char id=81 x=0 y=53 width=21 height=29 xoffset=1 yoffset=6 xadvance=23 page=0 chnl=15
char id=82 x=81 y=0 width=22 height=22 xoffset=0 yoffset=7 xadvance=21 page=0 chnl=15
char id=83 x=172 y=103 width=14 height=24 xoffset=2 yoffset=6 xadvance=18 page=0 chnl=15
char id=84 x=103 y=0 width=18 height=22 xoffset=1 yoffset=7 xadvance=19 page=0 chnl=15
char id=85 x=30 y=29 width=24 height=23 xoffset=-1 yoffset=7 xadvance=22 page=0 chnl=15
char id=86 x=44 y=52 width=24 height=22 xoffset=0 yoffset=7 xadvance=24 page=0 chnl=15
char id=87 x=0 y=30 width=30 height=23 xoffset=0 yoffset=7 xadvance=30 page=0 chnl=15
char id=88 x=54 y=27 width=24 height=22 xoffset=0 yoffset=7 xadvance=24 page=0 chnl=15
char id=89 x=68 y=49 width=23 height=22 xoffset=0 yoffset=7 xadvance=23 page=0 chnl=15
char id=90 x=99 y=22 width=19 height=22 xoffset=0 yoffset=7 xadvance=20 page=0 chnl=15
char id=91 x=227 y=30 width=8 height=29 xoffset=3 yoffset=7 xadvance=12 page=0 chnl=15
char id=92 x=209 y=53 width=9 height=23 xoffset=0 yoffset=6 xadvance=9 page=0 chnl=15
char id=93 x=234 y=59 width=8 height=29 xoffset=1 yoffset=7 xadvance=12 page=0 chnl=15
char id=94 x=91 y=116 width=15 height=12 xoffset=0 yoffset=6 xadvance=15 page=0 chnl=15
char id=95 x=52 y=22 width=17 height=2 xoffset=0 yoffset=35 xadvance=17 page=0 chnl=15
char id=96 x=46 y=22 width=6 height=6 xoffset=1 yoffset=6 xadvance=11 page=0 chnl=15
char id=97 x=195 y=0 width=13 height=15 xoffset=1 yoffset=14 xadvance=15 page=0 chnl=15
char id=98 x=128 y=44 width=16 height=23 xoffset=-1 yoffset=6 xadvance=16 page=0 chnl=15
char id=99 x=208 y=0 width=12 height=15 xoffset=1 yoffset=14 xadvance=14 page=0 chnl=15
char id=100 x=135 y=15 width=16 height=23 xoffset=1 yoffset=6 xadvance=16 page=0 chnl=15
char id=101 x=220 y=0 width=12 height=15 xoffset=1 yoffset=14 xadvance=14 page=0 chnl=15
char id=102 x=193 y=15 width=13 height=23 xoffset=1 yoffset=6 xadvance=10 page=0 chnl=15
char id=103 x=152 y=60 width=15 height=22 xoffset=1 yoffset=14 xadvance=16 page=0 chnl=15
char id=104 x=91 y=93 width=17 height=23 xoffset=0 yoffset=6 xadvance=16 page=0 chnl=15
char id=105 x=243 y=0 width=8 height=23 xoffset=0 yoffset=6 xadvance=9 page=0 chnl=15
char id=106 x=229 y=97 width=9 height=30 xoffset=-3 yoffset=6 xadvance=9 page=0 chnl=15
char id=107 x=108 y=93 width=17 height=23 xoffset=0 yoffset=6 xadvance=16 page=0 chnl=15
char id=108 x=235 y=30 width=9 height=23 xoffset=0 yoffset=6 xadvance=9 page=0 chnl=15
char id=109 x=110 y=68 width=25 height=15 xoffset=0 yoffset=14 xadvance=24 page=0 chnl=15
char id=110 x=145 y=0 width=17 height=15 xoffset=0 yoffset=14 xadvance=16 page=0 chnl=15
char id=111 x=191 y=38 width=14 height=15 xoffset=1 yoffset=14 xadvance=16 page=0 chnl=15
char id=112 x=125 y=83 width=16 height=22 xoffset=-1 yoffset=14 xadvance=16 page=0 chnl=15
char id=113 x=125 y=105 width=16 height=22 xoffset=1 yoffset=14 xadvance=16 page=0 chnl=15
char id=114 x=217 y=107 width=12 height=15 xoffset=0 yoffset=14 xadvance=11 page=0 chnl=15
char id=115 x=226 y=15 width=10 height=15 xoffset=2 yoffset=14 xadvance=13 page=0 chnl=15
char id=116 x=207 y=107 width=10 height=20 xoffset=0 yoffset=9 xadvance=10 page=0 chnl=15
char id=117 x=135 y=67 width=17 height=15 xoffset=-1 yoffset=14 xadvance=15 page=0 chnl=15
char id=118 x=162 y=0 width=17 height=15 xoffset=-1 yoffset=14 xadvance=16 page=0 chnl=15
char id=119 x=121 y=0 width=24 height=15 xoffset=0 yoffset=14 xadvance=23 page=0 chnl=15
char id=120 x=179 y=0 width=16 height=15 xoffset=0 yoffset=14 xadvance=16 page=0 chnl=15
char id=121 x=144 y=38 width=16 height=22 xoffset=0 yoffset=14 xadvance=16 page=0 chnl=15
char id=122 x=205 y=38 width=13 height=15 xoffset=1 yoffset=14 xadvance=15 page=0 chnl=15
char id=123 x=207 y=76 width=9 height=31 xoffset=4 yoffset=6 xadvance=15 page=0 chnl=15
char id=124 x=238 y=88 width=2 height=30 xoffset=2 yoffset=6 xadvance=7 page=0 chnl=15
char id=125 x=216 y=76 width=9 height=31 xoffset=3 yoffset=6 xadvance=16 page=0 chnl=15
char id=126 x=21 y=77 width=17 height=5 xoffset=1 yoffset=18 xadvance=18 page=0 chnl=15
Binary file added source/core/assets/images/ui/font.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 source/core/assets/images/ui/mouse_effect.png
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 source/core/assets/sounds/Modern4.ogg
Binary file not shown.
4 changes: 3 additions & 1 deletion source/core/src/main/com/csse3200/game/GdxGame.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,15 @@ private Screen newScreen(ScreenType screenType) {
return new LosingScreen(this);
case TURRET_SELECTION:
return new TurretSelectionScreen(this);
case HELP_SCREEN:
return new HelpScreen(this);
default:
return null;
}
}

public enum ScreenType {
MAIN_MENU, MAIN_GAME, SETTINGS, STORY_SCREEN, LEVEL_SELECT, TURRET_SELECTION, LOSING_SCREEN
MAIN_MENU, MAIN_GAME, SETTINGS, STORY_SCREEN, LEVEL_SELECT, TURRET_SELECTION, LOSING_SCREEN, HELP_SCREEN
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.csse3200.game.GdxGame;
import com.csse3200.game.components.Component;
import com.csse3200.game.screens.HelpScreen;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -20,7 +21,7 @@ public MainMenuActions(GdxGame game) {
@Override
public void create() {
entity.getEvents().addListener("start", this::onStart);
entity.getEvents().addListener("load", this::onLoad);
entity.getEvents().addListener("help", this::onHelp);
entity.getEvents().addListener("exit", this::onExit);
entity.getEvents().addListener("settings", this::onSettings);
}
Expand All @@ -34,12 +35,9 @@ private void onStart() {
// game.setScreen(GdxGame.ScreenType.LEVEL_SELECT);
}

/**
* Intended for loading a saved game state.
* Load functionality is not actually implemented.
*/
private void onLoad() {
logger.info("Load game");
private void onHelp() {
logger.info("Help Menu");
game.setScreen(GdxGame.ScreenType.HELP_SCREEN);
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package com.csse3200.game.components.mainmenu;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.audio.Sound;
import com.badlogic.gdx.graphics.Cursor;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.scenes.scene2d.Actor;
Expand All @@ -9,50 +12,71 @@
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import com.csse3200.game.services.ServiceLocator;
import com.csse3200.game.ui.ButtonFactory;
import com.csse3200.game.ui.UIComponent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* A ui component for displaying the Main menu.
*/
public class MainMenuDisplay extends UIComponent {

private static final Logger logger = LoggerFactory.getLogger(MainMenuDisplay.class);
private static final float Z_INDEX = 2f;
private Table table;
private Table table1;



private Sound clickSound;

@Override
public void create() {
super.create();
addActors();
loadSounds();
}
private void loadSounds() {
clickSound = Gdx.audio.newSound(Gdx.files.internal("sounds/Modern4.ogg"));
}


private void addActors() {
/**
* Loads a custom cursor image and sets it as the system cursor.
*
* This method loads an image file named "mouse_effect.png" from the "images/ui" directory
* and sets it as the system cursor. After setting the custom cursor, it disposes of the
* Pixmap object used for loading the cursor image to release system resources.
*
* @param none
* @return none
*/
// Load the custom cursor image
Pixmap cursorPixmap = new Pixmap(Gdx.files.internal("images/ui/mouse_effect.png"));
Cursor customCursor = Gdx.graphics.newCursor(cursorPixmap, 0, 0);
Gdx.graphics.setCursor(customCursor);
cursorPixmap.dispose(); // Dispose of the Pixmap to release resources

table = new Table();
table1=new Table();
table1 = new Table();
table.setFillParent(true);
table1.setFillParent(true);

Image title =
new Image(
ServiceLocator.getResourceService()
.getAsset("images/background/background1.png", Texture.class));
.getAsset("images/background/main_menu/main_menu_bg.png", Texture.class));
title.setWidth(Gdx.graphics.getWidth());
title.setHeight(Gdx.graphics.getHeight());
title.setPosition(0,0);
title.setPosition(0, 0);

// Create a "Start" TextButton using the default style
TextButton startBtn = ButtonFactory.createButton("Start");

// Create a "Help" TextButton using the default style
TextButton helpBtn = ButtonFactory.createButton("Help");

// Create a "Settings" TextButton with a custom image
TextButton settingsBtn =ButtonFactory.createButton("Settings");

// Create a "Quit" TextButton with a custom image
TextButton exitBtn = ButtonFactory.createButton("Quit");

TextButton startBtn = new TextButton("Start", skin);
TextButton loadBtn = new TextButton("Help", skin);
TextButton settingsBtn = new TextButton("Settings", skin);
TextButton exitBtn = new TextButton("Quit", skin);

// Triggers an event when the button is pressed
startBtn.addListener(
Expand All @@ -61,15 +85,17 @@ private void addActors() {
public void changed(ChangeEvent changeEvent, Actor actor) {
logger.debug("Start button clicked");
entity.getEvents().trigger("start");
clickSound.play();
}
});

loadBtn.addListener(
helpBtn.addListener(
new ChangeListener() {
@Override
public void changed(ChangeEvent changeEvent, Actor actor) {
logger.debug("Load button clicked");
entity.getEvents().trigger("load");
logger.debug("Help button clicked");
entity.getEvents().trigger("help");
clickSound.play();
}
});

Expand All @@ -79,35 +105,42 @@ public void changed(ChangeEvent changeEvent, Actor actor) {
public void changed(ChangeEvent changeEvent, Actor actor) {
logger.debug("Settings button clicked");
entity.getEvents().trigger("settings");
clickSound.play();
}
});

exitBtn.addListener(
new ChangeListener() {
@Override
public void changed(ChangeEvent changeEvent, Actor actor) {

logger.debug("Exit button clicked");
entity.getEvents().trigger("exit");
clickSound.play();
}
});

// Proportional padding values based on original screen or background dimensions
float originalScreenWidth = 1920; // Replace with the original width if different
float originalScreenHeight = 1080; // Replace with the original height if different

float padTopStartBtn = 260f / originalScreenHeight * Gdx.graphics.getHeight();
float padTopOtherBtns = 15f / originalScreenHeight * Gdx.graphics.getHeight();


table.add(title);
table1.row();
table1.add(startBtn).padTop(30f);
table1.add(startBtn).padTop(padTopStartBtn);
table1.row();
table1.add(loadBtn).padTop(15f);
table1.add(helpBtn).padTop(padTopOtherBtns);
table1.row();
table1.add(settingsBtn).padTop(15f);
table1.add(settingsBtn).padTop(padTopOtherBtns);
table1.row();
table1.add(exitBtn).padTop(15f);
table1.add(exitBtn).padTop(padTopOtherBtns);

stage.addActor(table);
stage.addActor(table1);
}


@Override
public void draw(SpriteBatch batch) {
// draw is handled by the stage
Expand All @@ -122,5 +155,6 @@ public float getZIndex() {
public void dispose() {
table.clear();
super.dispose();
clickSound.dispose();
}
}
}
Loading