chore(settings): "properly" implement settings
This commit is contained in:
@ -94,6 +94,9 @@ public class Game extends ApplicationAdapter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
|
// Save settings
|
||||||
|
Settings.saveSettings();
|
||||||
|
// Dispose resources
|
||||||
introScene.dispose();
|
introScene.dispose();
|
||||||
mainMenuScene.dispose();
|
mainMenuScene.dispose();
|
||||||
Assets.dispose();
|
Assets.dispose();
|
||||||
|
|||||||
65
app/src/main/java/org/vibecoders/moongazer/Settings.java
Normal file
65
app/src/main/java/org/vibecoders/moongazer/Settings.java
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
package org.vibecoders.moongazer;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.Input;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
|
public class Settings {
|
||||||
|
private static final Logger log = org.slf4j.LoggerFactory.getLogger(Settings.class);
|
||||||
|
private static float masterVolume = 1.0f;
|
||||||
|
private static float musicVolume = 1.0f;
|
||||||
|
private static float sfxVolume = 1.0f;
|
||||||
|
public static HashMap<String, Integer> keybinds = new HashMap<>() {
|
||||||
|
{
|
||||||
|
put("p1_left", Input.Keys.LEFT);
|
||||||
|
put("p1_right", Input.Keys.RIGHT);
|
||||||
|
put("p2_left", Input.Keys.A);
|
||||||
|
put("p2_right", Input.Keys.D);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
public static int getKeybind(String action) {
|
||||||
|
return keybinds.getOrDefault(action, Input.Keys.UNKNOWN);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float getMasterVolume() {
|
||||||
|
return masterVolume;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float getMusicVolume() {
|
||||||
|
return musicVolume;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float getSfxVolume() {
|
||||||
|
return sfxVolume;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setKeybind(String action, int keycode) {
|
||||||
|
keybinds.put(action, keycode);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setMasterVolume(float volume) {
|
||||||
|
masterVolume = Math.max(0, Math.min(1, volume));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setMusicVolume(float volume) {
|
||||||
|
musicVolume = Math.max(0, Math.min(1, volume));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setSfxVolume(float volume) {
|
||||||
|
sfxVolume = Math.max(0, Math.min(1, volume));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void saveSettings() {
|
||||||
|
log.debug("Saving settings: Master Volume = {}, Music Volume = {}, SFX Volume = {}", masterVolume, musicVolume, sfxVolume);
|
||||||
|
for (java.util.Map.Entry<String, Integer> entry : keybinds.entrySet()) {
|
||||||
|
log.debug("Keybind: {} = {}", entry.getKey(), Input.Keys.toString(entry.getValue()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void loadSettings() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -31,7 +31,7 @@ public class Intro extends Scene {
|
|||||||
Assets.loadAll();
|
Assets.loadAll();
|
||||||
// Create scenes
|
// Create scenes
|
||||||
game.mainMenuScene = new MainMenu(game);
|
game.mainMenuScene = new MainMenu(game);
|
||||||
game.settingsScene = new Settings(game);
|
game.settingsScene = new SettingsScene(game);
|
||||||
game.gameScenes.add(game.mainMenuScene);
|
game.gameScenes.add(game.mainMenuScene);
|
||||||
game.gameScenes.add(game.settingsScene);
|
game.gameScenes.add(game.settingsScene);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,66 +14,53 @@ import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
|
|||||||
import com.badlogic.gdx.scenes.scene2d.utils.Drawable;
|
import com.badlogic.gdx.scenes.scene2d.utils.Drawable;
|
||||||
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
|
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
|
||||||
|
|
||||||
import static org.vibecoders.moongazer.Constants.*;
|
|
||||||
|
|
||||||
import org.vibecoders.moongazer.Game;
|
import org.vibecoders.moongazer.Game;
|
||||||
import org.vibecoders.moongazer.State;
|
import org.vibecoders.moongazer.State;
|
||||||
|
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.UIImageButton;
|
||||||
|
|
||||||
import static org.vibecoders.moongazer.Constants.WINDOW_HEIGHT;
|
import java.util.HashMap;
|
||||||
import static org.vibecoders.moongazer.Constants.WINDOW_WIDTH;
|
|
||||||
|
|
||||||
public class Settings extends Scene {
|
import static org.vibecoders.moongazer.Constants.*;
|
||||||
|
|
||||||
|
public class SettingsScene extends Scene {
|
||||||
|
|
||||||
private Table mainPanel;
|
private Table mainPanel;
|
||||||
private boolean isEditingKeybind = false;
|
private boolean isEditingKeybind = false;
|
||||||
private TextButton currentEditingButton = null;
|
private TextButton currentEditingButton = null;
|
||||||
private String currentKeybindAction = "";
|
private String currentKeybindAction = "";
|
||||||
|
|
||||||
private java.util.Map<String, Integer> keybinds = new java.util.HashMap<>();
|
private HashMap<String, TextButton> keybindButtons = new HashMap<>();
|
||||||
private java.util.Map<String, TextButton> keybindButtons = new java.util.HashMap<>();
|
|
||||||
|
|
||||||
public Settings(Game game) {
|
public SettingsScene(Game game) {
|
||||||
super(game);
|
super(game);
|
||||||
initializeDefaultKeybinds();
|
initUI();
|
||||||
setupUI();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initializeDefaultKeybinds() {
|
private void initUI() {
|
||||||
keybinds.put("player1_left", Input.Keys.LEFT);
|
|
||||||
keybinds.put("player1_right", Input.Keys.RIGHT);
|
|
||||||
keybinds.put("player2_left", Input.Keys.A);
|
|
||||||
keybinds.put("player2_right", Input.Keys.D);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setupUI() {
|
|
||||||
root.setFillParent(true);
|
root.setFillParent(true);
|
||||||
root.clear();
|
root.clear();
|
||||||
|
|
||||||
BitmapFont font = Assets.getFont("ui", 24);
|
BitmapFont font = Assets.getFont("ui", 24);
|
||||||
Label.LabelStyle labelStyle = new Label.LabelStyle(font, Color.WHITE);
|
Label.LabelStyle labelStyle = new Label.LabelStyle(font, Color.WHITE);
|
||||||
|
|
||||||
// 1. Create main panel
|
|
||||||
mainPanel = new Table();
|
mainPanel = new Table();
|
||||||
mainPanel.setSize(800, 600);
|
mainPanel.setSize(800, 600);
|
||||||
mainPanel.setPosition(
|
mainPanel.setPosition(
|
||||||
(Gdx.graphics.getWidth() - 800) / 2f,
|
(Gdx.graphics.getWidth() - 800) / 2f,
|
||||||
(Gdx.graphics.getHeight() - 600) / 2f
|
(Gdx.graphics.getHeight() - 600) / 2f);
|
||||||
);
|
|
||||||
|
|
||||||
// 2. Blurred rectangle background for rows
|
|
||||||
TextureRegionDrawable rowBgDrawable = new TextureRegionDrawable(Assets.getWhiteTexture());
|
TextureRegionDrawable rowBgDrawable = new TextureRegionDrawable(Assets.getWhiteTexture());
|
||||||
Color bgColor = new Color(0.2f, 0.2f, 0.2f, 0.3f);
|
Color bgColor = new Color(0.2f, 0.2f, 0.2f, 0.3f);
|
||||||
Drawable tintedBg = rowBgDrawable.tint(bgColor);
|
Drawable tintedBg = rowBgDrawable.tint(bgColor);
|
||||||
|
|
||||||
// 3. Add title "Settings"
|
|
||||||
Label titleLabel = new Label("Settings", new Label.LabelStyle(font, Color.WHITE));
|
Label titleLabel = new Label("Settings", new Label.LabelStyle(font, Color.WHITE));
|
||||||
mainPanel.add(titleLabel).colspan(2).padTop(60).padBottom(40);
|
mainPanel.add(titleLabel).colspan(2).padTop(60).padBottom(40);
|
||||||
mainPanel.row();
|
mainPanel.row();
|
||||||
|
|
||||||
// 4. Add volume sliders rows (WIP)
|
// TODO: Volume Sliders
|
||||||
String[] volumeLabels = {"Master Volume", "Music Volume", "SFX Volume"};
|
String[] volumeLabels = { "Master Volume", "Music Volume", "SFX Volume" };
|
||||||
for (String volumeLabel : volumeLabels) {
|
for (String volumeLabel : volumeLabels) {
|
||||||
Table volumeRow = new Table();
|
Table volumeRow = new Table();
|
||||||
volumeRow.setBackground(tintedBg);
|
volumeRow.setBackground(tintedBg);
|
||||||
@ -85,15 +72,13 @@ public class Settings extends Scene {
|
|||||||
mainPanel.row();
|
mainPanel.row();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5. Keybinds Section
|
|
||||||
Table keybindsSection = new Table();
|
Table keybindsSection = new Table();
|
||||||
keybindsSection.setBackground(tintedBg);
|
keybindsSection.setBackground(tintedBg);
|
||||||
|
|
||||||
// Keybinds title
|
keybindsSection.add(new Label("Keybinds", labelStyle)).colspan(2).expandX().left().padLeft(40).padTop(15)
|
||||||
keybindsSection.add(new Label("Keybinds", labelStyle)).colspan(2).expandX().left().padLeft(40).padTop(15).padBottom(10);
|
.padBottom(10);
|
||||||
keybindsSection.row();
|
keybindsSection.row();
|
||||||
|
|
||||||
// Normal keybinds
|
|
||||||
TextButton.TextButtonStyle textButtonStyle = new TextButton.TextButtonStyle();
|
TextButton.TextButtonStyle textButtonStyle = new TextButton.TextButtonStyle();
|
||||||
textButtonStyle.font = font;
|
textButtonStyle.font = font;
|
||||||
textButtonStyle.fontColor = Color.BLACK;
|
textButtonStyle.fontColor = Color.BLACK;
|
||||||
@ -101,50 +86,43 @@ public class Settings extends Scene {
|
|||||||
Color buttonColor = new Color(0.7f, 0.7f, 0.7f, 1.0f);
|
Color buttonColor = new Color(0.7f, 0.7f, 0.7f, 1.0f);
|
||||||
textButtonStyle.up = keybindBgDrawable.tint(buttonColor);
|
textButtonStyle.up = keybindBgDrawable.tint(buttonColor);
|
||||||
|
|
||||||
// Editing keybinds
|
|
||||||
TextButton.TextButtonStyle editingButtonStyle = new TextButton.TextButtonStyle();
|
TextButton.TextButtonStyle editingButtonStyle = new TextButton.TextButtonStyle();
|
||||||
editingButtonStyle.font = font;
|
editingButtonStyle.font = font;
|
||||||
editingButtonStyle.fontColor = Color.WHITE;
|
editingButtonStyle.fontColor = Color.WHITE;
|
||||||
Color editingColor = new Color(0.3f, 0.3f, 0.8f, 1.0f);
|
Color editingColor = new Color(0.3f, 0.3f, 0.8f, 1.0f);
|
||||||
editingButtonStyle.up = keybindBgDrawable.tint(editingColor);
|
editingButtonStyle.up = keybindBgDrawable.tint(editingColor);
|
||||||
|
|
||||||
// Player 1
|
|
||||||
keybindsSection.add(new Label(" Player 1", labelStyle)).colspan(2).left().padLeft(60).padBottom(8);
|
keybindsSection.add(new Label(" Player 1", labelStyle)).colspan(2).left().padLeft(60).padBottom(8);
|
||||||
keybindsSection.row();
|
keybindsSection.row();
|
||||||
|
|
||||||
// Move Left
|
|
||||||
keybindsSection.add(new Label(" Move Left", labelStyle)).left().padLeft(80);
|
keybindsSection.add(new Label(" Move Left", labelStyle)).left().padLeft(80);
|
||||||
TextButton player1LeftButton = new TextButton(getKeyName(keybinds.get("player1_left")), textButtonStyle);
|
TextButton player1LeftButton = new TextButton(getKeyName(Settings.keybinds.get("p1_left")), textButtonStyle);
|
||||||
setupKeybindButton(player1LeftButton, "player1_left", textButtonStyle, editingButtonStyle);
|
setupKeybindButton(player1LeftButton, "p1_left", textButtonStyle, editingButtonStyle);
|
||||||
keybindButtons.put("player1_left", player1LeftButton);
|
keybindButtons.put("p1_left", player1LeftButton);
|
||||||
keybindsSection.add(player1LeftButton).width(150).right().padRight(40).padBottom(5);
|
keybindsSection.add(player1LeftButton).width(150).right().padRight(40).padBottom(5);
|
||||||
keybindsSection.row();
|
keybindsSection.row();
|
||||||
|
|
||||||
// Move Right
|
|
||||||
keybindsSection.add(new Label(" Move Right", labelStyle)).left().padLeft(80);
|
keybindsSection.add(new Label(" Move Right", labelStyle)).left().padLeft(80);
|
||||||
TextButton player1RightButton = new TextButton(getKeyName(keybinds.get("player1_right")), textButtonStyle);
|
TextButton player1RightButton = new TextButton(getKeyName(Settings.keybinds.get("p1_right")), textButtonStyle);
|
||||||
setupKeybindButton(player1RightButton, "player1_right", textButtonStyle, editingButtonStyle);
|
setupKeybindButton(player1RightButton, "p1_right", textButtonStyle, editingButtonStyle);
|
||||||
keybindButtons.put("player1_right", player1RightButton);
|
keybindButtons.put("p1_right", player1RightButton);
|
||||||
keybindsSection.add(player1RightButton).width(150).right().padRight(40).padBottom(10);
|
keybindsSection.add(player1RightButton).width(150).right().padRight(40).padBottom(10);
|
||||||
keybindsSection.row();
|
keybindsSection.row();
|
||||||
|
|
||||||
// Player 2
|
|
||||||
keybindsSection.add(new Label(" Player 2", labelStyle)).colspan(2).left().padLeft(60).padTop(5).padBottom(8);
|
keybindsSection.add(new Label(" Player 2", labelStyle)).colspan(2).left().padLeft(60).padTop(5).padBottom(8);
|
||||||
keybindsSection.row();
|
keybindsSection.row();
|
||||||
|
|
||||||
// Player 2 Move Left
|
|
||||||
keybindsSection.add(new Label(" Move Left", labelStyle)).left().padLeft(80);
|
keybindsSection.add(new Label(" Move Left", labelStyle)).left().padLeft(80);
|
||||||
TextButton player2LeftButton = new TextButton(getKeyName(keybinds.get("player2_left")), textButtonStyle);
|
TextButton player2LeftButton = new TextButton(getKeyName(Settings.keybinds.get("p2_left")), textButtonStyle);
|
||||||
setupKeybindButton(player2LeftButton, "player2_left", textButtonStyle, editingButtonStyle);
|
setupKeybindButton(player2LeftButton, "p2_left", textButtonStyle, editingButtonStyle);
|
||||||
keybindButtons.put("player2_left", player2LeftButton);
|
keybindButtons.put("p2_left", player2LeftButton);
|
||||||
keybindsSection.add(player2LeftButton).width(150).right().padRight(40).padBottom(5);
|
keybindsSection.add(player2LeftButton).width(150).right().padRight(40).padBottom(5);
|
||||||
keybindsSection.row();
|
keybindsSection.row();
|
||||||
|
|
||||||
// Player 2 Move Right
|
|
||||||
keybindsSection.add(new Label(" Move Right", labelStyle)).left().padLeft(80);
|
keybindsSection.add(new Label(" Move Right", labelStyle)).left().padLeft(80);
|
||||||
TextButton player2RightButton = new TextButton(getKeyName(keybinds.get("player2_right")), textButtonStyle);
|
TextButton player2RightButton = new TextButton(getKeyName(Settings.keybinds.get("p2_right")), textButtonStyle);
|
||||||
setupKeybindButton(player2RightButton, "player2_right", textButtonStyle, editingButtonStyle);
|
setupKeybindButton(player2RightButton, "p2_right", textButtonStyle, editingButtonStyle);
|
||||||
keybindButtons.put("player2_right", player2RightButton);
|
keybindButtons.put("p2_right", player2RightButton);
|
||||||
keybindsSection.add(player2RightButton).width(150).right().padRight(40).padBottom(15);
|
keybindsSection.add(player2RightButton).width(150).right().padRight(40).padBottom(15);
|
||||||
keybindsSection.row();
|
keybindsSection.row();
|
||||||
|
|
||||||
@ -170,46 +148,55 @@ public class Settings extends Scene {
|
|||||||
game.stage.addListener(new InputListener() {
|
game.stage.addListener(new InputListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean keyDown(InputEvent event, int keycode) {
|
public boolean keyDown(InputEvent event, int keycode) {
|
||||||
if (isEditingKeybind && currentEditingButton != null) {
|
if (isEditingKeybind) {
|
||||||
// ESC not allowed, cancel editing
|
if (currentEditingButton != null) {
|
||||||
|
// ESC not allowed, cancel editing
|
||||||
|
if (keycode == Input.Keys.ESCAPE) {
|
||||||
|
cancelKeybindEdit();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if key is already used
|
||||||
|
if (isKeybindAlreadyUsed(keycode, currentKeybindAction)) {
|
||||||
|
// Error_msg
|
||||||
|
currentEditingButton.setText("Key in use!");
|
||||||
|
// Delay
|
||||||
|
new Thread(() -> {
|
||||||
|
try {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
Gdx.app.postRunnable(() -> {
|
||||||
|
if (isEditingKeybind && currentEditingButton != null) {
|
||||||
|
currentEditingButton.setText("Press Key...");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update keybind
|
||||||
|
Settings.keybinds.put(currentKeybindAction, keycode);
|
||||||
|
currentEditingButton.setText(getKeyName(keycode));
|
||||||
|
|
||||||
|
finishKeybindEdit();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
if (keycode == Input.Keys.ESCAPE) {
|
if (keycode == Input.Keys.ESCAPE) {
|
||||||
cancelKeybindEdit();
|
game.transition = new Transition(game, SettingsScene.this, game.mainMenuScene,
|
||||||
|
State.MAIN_MENU, 350);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if key is already used
|
|
||||||
if (isKeybindAlreadyUsed(keycode, currentKeybindAction)) {
|
|
||||||
//Error_msg
|
|
||||||
currentEditingButton.setText("Key in use!");
|
|
||||||
// Delay
|
|
||||||
new Thread(() -> {
|
|
||||||
try {
|
|
||||||
Thread.sleep(1000);
|
|
||||||
Gdx.app.postRunnable(() -> {
|
|
||||||
if (isEditingKeybind && currentEditingButton != null) {
|
|
||||||
currentEditingButton.setText("Press Key...");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
Thread.currentThread().interrupt();
|
|
||||||
}
|
|
||||||
}).start();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update keybind
|
|
||||||
keybinds.put(currentKeybindAction, keycode);
|
|
||||||
currentEditingButton.setText(getKeyName(keycode));
|
|
||||||
|
|
||||||
finishKeybindEdit();
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupKeybindButton(TextButton button, String action, TextButton.TextButtonStyle normalStyle, TextButton.TextButtonStyle editingStyle) {
|
private void setupKeybindButton(TextButton button, String action, TextButton.TextButtonStyle normalStyle,
|
||||||
|
TextButton.TextButtonStyle editingStyle) {
|
||||||
button.addListener(new ClickListener() {
|
button.addListener(new ClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void clicked(InputEvent event, float x, float y) {
|
public void clicked(InputEvent event, float x, float y) {
|
||||||
@ -251,43 +238,18 @@ public class Settings extends Scene {
|
|||||||
private void cancelKeybindEdit() {
|
private void cancelKeybindEdit() {
|
||||||
if (currentEditingButton != null) {
|
if (currentEditingButton != null) {
|
||||||
// Reset text
|
// Reset text
|
||||||
currentEditingButton.setText(getKeyName(keybinds.get(currentKeybindAction)));
|
currentEditingButton.setText(getKeyName(Settings.getKeybind(currentKeybindAction)));
|
||||||
}
|
}
|
||||||
finishKeybindEdit();
|
finishKeybindEdit();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getKeyName(int keycode) {
|
private String getKeyName(int keycode) {
|
||||||
switch (keycode) {
|
String keyName = Input.Keys.toString(keycode);
|
||||||
case Input.Keys.LEFT:
|
return keyName != null ? keyName.toUpperCase() : "Unknown";
|
||||||
return "Left Arrow";
|
|
||||||
case Input.Keys.RIGHT:
|
|
||||||
return "Right Arrow";
|
|
||||||
case Input.Keys.UP:
|
|
||||||
return "Up Arrow";
|
|
||||||
case Input.Keys.DOWN:
|
|
||||||
return "Down Arrow";
|
|
||||||
case Input.Keys.SPACE:
|
|
||||||
return "Space_Bar";
|
|
||||||
case Input.Keys.SHIFT_LEFT:
|
|
||||||
return "Left_Shift";
|
|
||||||
case Input.Keys.SHIFT_RIGHT:
|
|
||||||
return "Right_Shift";
|
|
||||||
case Input.Keys.CONTROL_LEFT:
|
|
||||||
return "Left_Ctrl";
|
|
||||||
case Input.Keys.CONTROL_RIGHT:
|
|
||||||
return "Right_Ctrl";
|
|
||||||
case Input.Keys.ALT_LEFT:
|
|
||||||
return "Left_Alt";
|
|
||||||
case Input.Keys.ALT_RIGHT:
|
|
||||||
return "Right_Alt";
|
|
||||||
default:
|
|
||||||
String keyName = Input.Keys.toString(keycode);
|
|
||||||
return keyName != null ? keyName.toUpperCase() : "Unknown";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isKeybindAlreadyUsed(int keycode, String currentAction) {
|
private boolean isKeybindAlreadyUsed(int keycode, String currentAction) {
|
||||||
for (java.util.Map.Entry<String, Integer> entry : keybinds.entrySet()) {
|
for (java.util.Map.Entry<String, Integer> entry : Settings.keybinds.entrySet()) {
|
||||||
if (!entry.getKey().equals(currentAction) && entry.getValue().equals(keycode)) {
|
if (!entry.getKey().equals(currentAction) && entry.getValue().equals(keycode)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -297,9 +259,7 @@ public class Settings extends Scene {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(SpriteBatch batch) {
|
public void render(SpriteBatch batch) {
|
||||||
if (game.mainMenuScene != null) {
|
game.mainMenuScene.render(batch);
|
||||||
game.mainMenuScene.render(batch);
|
|
||||||
}
|
|
||||||
batch.setColor(0, 0, 0, 0.8f);
|
batch.setColor(0, 0, 0, 0.8f);
|
||||||
batch.draw(Assets.getWhiteTexture(), 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT);
|
batch.draw(Assets.getWhiteTexture(), 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT);
|
||||||
batch.setColor(Color.WHITE);
|
batch.setColor(Color.WHITE);
|
||||||
Reference in New Issue
Block a user