diff --git a/source/core/assets/images/ui/mouse_effect.png b/source/core/assets/images/ui/mouse_effect.png new file mode 100644 index 000000000..7653c4a2e Binary files /dev/null and b/source/core/assets/images/ui/mouse_effect.png differ diff --git a/source/core/src/main/com/csse3200/game/components/mainmenu/MainMenuDisplay.java b/source/core/src/main/com/csse3200/game/components/mainmenu/MainMenuDisplay.java index 1a39b08c2..6f6d6623d 100644 --- a/source/core/src/main/com/csse3200/game/components/mainmenu/MainMenuDisplay.java +++ b/source/core/src/main/com/csse3200/game/components/mainmenu/MainMenuDisplay.java @@ -1,6 +1,8 @@ package com.csse3200.game.components.mainmenu; import com.badlogic.gdx.Gdx; +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; @@ -8,15 +10,11 @@ import com.badlogic.gdx.scenes.scene2d.ui.Table; import com.badlogic.gdx.scenes.scene2d.ui.TextButton; import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener; -import com.csse3200.game.GdxGame; import com.csse3200.game.services.ServiceLocator; 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); @@ -24,31 +22,41 @@ public class MainMenuDisplay extends UIComponent { private Table table; private Table table1; - - - @Override public void create() { super.create(); addActors(); } - 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)); title.setWidth(Gdx.graphics.getWidth()); title.setHeight(Gdx.graphics.getHeight()); - title.setPosition(0,0); - - - + title.setPosition(0, 0); TextButton startBtn = new TextButton("Start", skin); TextButton loadBtn = new TextButton("Help", skin); @@ -87,13 +95,11 @@ public void changed(ChangeEvent changeEvent, Actor actor) { new ChangeListener() { @Override public void changed(ChangeEvent changeEvent, Actor actor) { - logger.debug("Exit button clicked"); entity.getEvents().trigger("exit"); } }); - table.add(title); table1.row(); table1.add(startBtn).padTop(30f); @@ -108,7 +114,6 @@ public void changed(ChangeEvent changeEvent, Actor actor) { stage.addActor(table1); } - @Override public void draw(SpriteBatch batch) { // draw is handled by the stage @@ -124,4 +129,4 @@ public void dispose() { table.clear(); super.dispose(); } -} \ No newline at end of file +}