feat(ui): add close button
This commit is contained in:
@ -25,6 +25,7 @@ public class Assets {
|
|||||||
private static final HashMap<String, FileHandle> loadedFiles = new HashMap<>();
|
private static final HashMap<String, FileHandle> loadedFiles = new HashMap<>();
|
||||||
private static boolean startLoadAll = false;
|
private static boolean startLoadAll = false;
|
||||||
private static boolean loadedAll = false;
|
private static boolean loadedAll = false;
|
||||||
|
private static Thread loadingThread = null;
|
||||||
private static Texture textureWhite;
|
private static Texture textureWhite;
|
||||||
private static Texture textureBlack;
|
private static Texture textureBlack;
|
||||||
|
|
||||||
@ -119,8 +120,14 @@ public class Assets {
|
|||||||
assetManager.load("textures/ui/UI_Gcg_Icon_Close.png", Texture.class);
|
assetManager.load("textures/ui/UI_Gcg_Icon_Close.png", Texture.class);
|
||||||
assetManager.load("textures/ui/arrow-button-left.png", Texture.class);
|
assetManager.load("textures/ui/arrow-button-left.png", Texture.class);
|
||||||
assetManager.load("textures/ui/arrow-button-right.png", Texture.class);
|
assetManager.load("textures/ui/arrow-button-right.png", Texture.class);
|
||||||
|
assetManager.load("textures/ui/close.png", Texture.class);
|
||||||
|
assetManager.load("textures/ui/close_hover.png", Texture.class);
|
||||||
|
assetManager.load("textures/ui/close_clicked.png", Texture.class);
|
||||||
// "Load" unsupported file types as FileHandle
|
// "Load" unsupported file types as FileHandle
|
||||||
loadAny("videos/main_menu_background.webm");
|
loadingThread = new Thread(() -> {
|
||||||
|
loadAny("videos/main_menu_background.webm");
|
||||||
|
});
|
||||||
|
loadingThread.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isLoadedAll() {
|
public static boolean isLoadedAll() {
|
||||||
@ -133,6 +140,14 @@ public class Assets {
|
|||||||
|
|
||||||
public static void waitUntilLoaded() {
|
public static void waitUntilLoaded() {
|
||||||
assetManager.finishLoading();
|
assetManager.finishLoading();
|
||||||
|
if (loadingThread != null) {
|
||||||
|
try {
|
||||||
|
loadingThread.join();
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
}
|
||||||
|
loadingThread = null;
|
||||||
|
}
|
||||||
if (startLoadAll) {
|
if (startLoadAll) {
|
||||||
loadedAll = true;
|
loadedAll = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,7 +16,7 @@ import org.vibecoders.moongazer.Game;
|
|||||||
import org.vibecoders.moongazer.State;
|
import org.vibecoders.moongazer.State;
|
||||||
import org.vibecoders.moongazer.Settings;
|
import org.vibecoders.moongazer.Settings;
|
||||||
import org.vibecoders.moongazer.managers.Assets;
|
import org.vibecoders.moongazer.managers.Assets;
|
||||||
import org.vibecoders.moongazer.ui.UIImageButton;
|
import org.vibecoders.moongazer.ui.UICloseButton;
|
||||||
import org.vibecoders.moongazer.ui.UITextButton;
|
import org.vibecoders.moongazer.ui.UITextButton;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -102,7 +102,7 @@ public class SettingsScene extends Scene {
|
|||||||
mainPanel.row();
|
mainPanel.row();
|
||||||
|
|
||||||
// Back button
|
// Back button
|
||||||
UIImageButton backButton = new UIImageButton("textures/ui/UI_Gcg_Icon_Close.png");
|
UICloseButton backButton = new UICloseButton();
|
||||||
backButton.setSize(40, 40);
|
backButton.setSize(40, 40);
|
||||||
backButton.setPosition(Gdx.graphics.getWidth() - 80, Gdx.graphics.getHeight() - 80);
|
backButton.setPosition(Gdx.graphics.getWidth() - 80, Gdx.graphics.getHeight() - 80);
|
||||||
backButton.onClick(() -> {
|
backButton.onClick(() -> {
|
||||||
|
|||||||
@ -0,0 +1,24 @@
|
|||||||
|
package org.vibecoders.moongazer.ui;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.graphics.Texture;
|
||||||
|
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.ui.ImageButton;
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
|
||||||
|
import org.vibecoders.moongazer.managers.Assets;
|
||||||
|
|
||||||
|
public class UICloseButton extends UIButton {
|
||||||
|
public UICloseButton() {
|
||||||
|
Texture closeTexture = Assets.getAsset("textures/ui/close.png", Texture.class);
|
||||||
|
Texture closeHoverTexture = Assets.getAsset("textures/ui/close_hover.png", Texture.class);
|
||||||
|
Texture closeClickTexture = Assets.getAsset("textures/ui/close_clicked.png", Texture.class);
|
||||||
|
TextureRegionDrawable drawable = new TextureRegionDrawable(new TextureRegion(closeTexture));
|
||||||
|
TextureRegionDrawable hoverDrawable = new TextureRegionDrawable(new TextureRegion(closeHoverTexture));
|
||||||
|
TextureRegionDrawable clickDrawable = new TextureRegionDrawable(new TextureRegion(closeClickTexture));
|
||||||
|
ImageButton.ImageButtonStyle style = new ImageButton.ImageButtonStyle();
|
||||||
|
style.imageUp = drawable;
|
||||||
|
style.imageDown = clickDrawable;
|
||||||
|
style.imageOver = hoverDrawable;
|
||||||
|
this.button = new ImageButton(style);
|
||||||
|
this.actor = button;
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
app/src/main/resources/textures/ui/close.png
Normal file
BIN
app/src/main/resources/textures/ui/close.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.6 KiB |
BIN
app/src/main/resources/textures/ui/close_clicked.png
Normal file
BIN
app/src/main/resources/textures/ui/close_clicked.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.3 KiB |
BIN
app/src/main/resources/textures/ui/close_hover.png
Normal file
BIN
app/src/main/resources/textures/ui/close_hover.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.4 KiB |
Reference in New Issue
Block a user