Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 5 additions & 5 deletions src/main/java/xyz/samiker/theendlessweave/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import xyz.samiker.theendlessweave.client.assets.ManifestAssetManager;
import xyz.samiker.theendlessweave.client.assets.ResourceManifest;
import xyz.samiker.theendlessweave.client.screens.LoadingScreen;
import xyz.samiker.theendlessweave.core.settings.SettingsEnum;
import xyz.samiker.theendlessweave.client.settings.ClientSettings;
import xyz.samiker.theendlessweave.core.settings.SettingsManager;

import java.io.IOException;
Expand Down Expand Up @@ -47,14 +47,14 @@ public ManifestAssetManager getAssetManager() {
}

public void applySettings() {
boolean isFullscreen = SettingsManager.getBoolean(SettingsEnum.FULLSCREEN);
boolean isBorderless = SettingsManager.getBoolean(SettingsEnum.BORDERLESS);
boolean isFullscreen = SettingsManager.getBoolean(ClientSettings.FULLSCREEN);
boolean isBorderless = SettingsManager.getBoolean(ClientSettings.BORDERLESS);

if (isFullscreen) {
Gdx.graphics.setFullscreenMode(Gdx.graphics.getDisplayMode());
} else {
int width = Integer.parseInt(SettingsManager.getString(SettingsEnum.RESOLUTION).split("x")[0]);
int height = Integer.parseInt(SettingsManager.getString(SettingsEnum.RESOLUTION).split("x")[1]);
int width = Integer.parseInt(SettingsManager.getString(ClientSettings.RESOLUTION).split("x")[0]);
int height = Integer.parseInt(SettingsManager.getString(ClientSettings.RESOLUTION).split("x")[1]);
Gdx.graphics.setWindowedMode(width, height);

if (isBorderless) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application;
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration;
import xyz.samiker.theendlessweave.Main;
import xyz.samiker.theendlessweave.core.settings.SettingsEnum;
import xyz.samiker.theendlessweave.client.settings.ClientSettings;
import xyz.samiker.theendlessweave.core.settings.SettingsManager;

import java.io.FileWriter;
Expand All @@ -17,14 +17,17 @@ public static void main(String[] args) {
Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration();
try {
SettingsManager.loadSettings();
String[] parts = SettingsManager.getString(SettingsEnum.RESOLUTION).split("x");
String[] parts = SettingsManager.getString(ClientSettings.RESOLUTION).split("x");

config.setWindowedMode(Integer.parseInt(parts[0]), Integer.parseInt(parts[1]));
if (!SettingsManager.getBoolean(SettingsEnum.VSYNC)) {
config.useVsync(SettingsManager.getBoolean(SettingsEnum.VSYNC));
config.setForegroundFPS(SettingsManager.getInt(SettingsEnum.FPS_LIMIT));
if (SettingsManager.getBoolean(ClientSettings.VSYNC)) {
config.useVsync(SettingsManager.getBoolean(ClientSettings.VSYNC));
} else {
config.setForegroundFPS(SettingsManager.getInt(ClientSettings.FPS_LIMIT));
}

config.setIdleFPS(15);

new Lwjgl3Application(new Main(), config);
} catch (Throwable t) {
logError(t);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@
import xyz.samiker.theendlessweave.core.logic.GameState;
import xyz.samiker.theendlessweave.core.logic.Loop;
import xyz.samiker.theendlessweave.core.network.packets.PacketLoginResponse;
import xyz.samiker.theendlessweave.core.settings.SettingsEnum;
import xyz.samiker.theendlessweave.client.settings.ClientSettings;
import xyz.samiker.theendlessweave.core.settings.SettingsManager;
import xyz.samiker.theendlessweave.server.ServerLauncher;

import java.io.IOException;

Expand All @@ -51,6 +52,7 @@ public class GameScreen implements Screen {

private Touchpad moveStick;
private Touchpad aimStick;
private TextButton attackBtn;
private boolean isMobile;

private Game gameLogic;
Expand All @@ -70,8 +72,8 @@ public GameScreen(Main mainApp) {
public void show() {
batch = new SpriteBatch();

float worldWidth = 1920;
float worldHeight = 1080;
float worldWidth = Gdx.graphics.getWidth();
float worldHeight = Gdx.graphics.getHeight();
gameCamera = new OrthographicCamera();
gameViewport = new ExtendViewport(worldWidth, worldHeight, gameCamera);

Expand Down Expand Up @@ -111,15 +113,14 @@ private void setupUI() {

uiStage.addActor(hudTable);

isMobile = SettingsManager.getString(SettingsEnum.CONTROL).equals("touch");// || Main.isMobile();
isMobile = !SettingsManager.getString(ClientSettings.CONTROL).equals("touch");// || Main.isMobile();
if (isMobile) {
setupMobileControls();
}

setupPauseMenu();

debugLabel = new Label("", skin);
debugLabel.setPosition(10, Gdx.graphics.getHeight() - 30);
debugLabel.setPosition(10, Gdx.graphics.getHeight() / 2f);
debugLabel.setAlignment(Align.left);
uiStage.addActor(debugLabel);
}
Expand All @@ -132,9 +133,9 @@ private void setupMobileControls() {

aimStick = new Touchpad(10, touchpadStyle);
aimStick.setBounds(Gdx.graphics.getWidth() - 250, 50, 200, 200);
TextButton attackBtn = new TextButton("ATK", skin);
attackBtn = new TextButton("ATK", skin);
attackBtn.setSize(100, 100);
attackBtn.setPosition(Gdx.graphics.getWidth() - 150, 300);
attackBtn.setPosition(Gdx.graphics.getWidth() - 150, Gdx.graphics.getHeight() - 300);
attackBtn.addListener(new ClickListener() {
@Override
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
Expand All @@ -152,6 +153,14 @@ public void touchUp(InputEvent event, float x, float y, int pointer, int button)
uiStage.addActor(attackBtn);
}

private void updateUI() {
debugLabel.setPosition(10, Gdx.graphics.getHeight() / 2f);
if (isMobile) {
aimStick.setBounds(Gdx.graphics.getWidth() - 250, 50, 200, 200);
attackBtn.setPosition(Gdx.graphics.getWidth() - 150, Gdx.graphics.getHeight() - 300);
}
}

private void setupPauseMenu() {
pauseMenuTable = new Table();
pauseMenuTable.setFillParent(true);
Expand Down Expand Up @@ -191,6 +200,11 @@ private void connectToServer() {
client = new GameClient();
new Thread(() -> {
try {
String[] args = new String[]{"--integrated"}; //TODO: я что-то хотел сделать с этим. ладно
ServerLauncher.main(args);
while (true) {
if (ServerLauncher.isStarted) break;
}
client.connect("127.0.0.1", (response) -> {
Gdx.app.postRunnable(() -> initializeGameSession(response));
});
Expand Down Expand Up @@ -285,9 +299,7 @@ public void render(float delta) {
public void resize(int width, int height) {
gameViewport.update(width, height, false);
uiStage.getViewport().update(width, height, true);
if (isMobile) {
setupMobileControls();
}
updateUI();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import com.badlogic.gdx.utils.ScreenUtils;
import com.badlogic.gdx.utils.viewport.ScreenViewport;
import xyz.samiker.theendlessweave.Main;
import xyz.samiker.theendlessweave.core.settings.SettingsManager;

public class LoadingScreen extends ScreenAdapter {
private final Main game;
Expand Down Expand Up @@ -39,7 +38,6 @@ public void show() {

table.add(statusLabel).padBottom(10).row();
table.add(progressBar).width(Gdx.graphics.getWidth() * 0.8f);
SettingsManager.loadSettings();
game.getAssetManager().queueAll();
assetsQueued = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import com.badlogic.gdx.utils.ScreenUtils;
import com.badlogic.gdx.utils.viewport.ScreenViewport;
import xyz.samiker.theendlessweave.Main;
import xyz.samiker.theendlessweave.core.settings.SettingsEnum;
import xyz.samiker.theendlessweave.client.settings.ClientSettings;
import xyz.samiker.theendlessweave.core.settings.SettingsManager;

public class SettingsScreen implements Screen {
Expand Down Expand Up @@ -100,7 +100,7 @@ private void showGeneralSettings() {
table.pad(20);

Label dirLabel = new Label("Mods Directory:", skin);
TextField modsDirField = new TextField(SettingsManager.getString(SettingsEnum.MODS_DIR), skin);
TextField modsDirField = new TextField(SettingsManager.getString(ClientSettings.MODS_DIR), skin);
TextButton chooseBtn = new TextButton("...", skin);
TextButton saveBtn = new TextButton("Save", skin);

Expand All @@ -119,7 +119,7 @@ public void clicked(InputEvent event, float x, float y) {
saveBtn.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
SettingsManager.set(SettingsEnum.MODS_DIR, modsDirField.getText());
SettingsManager.set(ClientSettings.MODS_DIR, modsDirField.getText());
SettingsManager.saveSettings();
System.out.println("General settings saved.");
}
Expand All @@ -143,26 +143,26 @@ private void showVideoSettings() {
table.add(new Label("Resolution:", skin));
SelectBox<String> resolutionSelect = new SelectBox<>(skin);
resolutionSelect.setItems("1920x1200", "1920x1080", "1600x900", "1366x768", "1280x720", "800x600");
resolutionSelect.setSelected(SettingsManager.getString(SettingsEnum.RESOLUTION));
resolutionSelect.setSelected(SettingsManager.getString(ClientSettings.RESOLUTION));
table.add(resolutionSelect).width(200).row();

CheckBox fullscreenCheck = new CheckBox(" Fullscreen", skin);
fullscreenCheck.setChecked(SettingsManager.getBoolean(SettingsEnum.FULLSCREEN));
fullscreenCheck.setChecked(SettingsManager.getBoolean(ClientSettings.FULLSCREEN));

CheckBox borderlessCheck = new CheckBox(" Borderless Window", skin);
borderlessCheck.setChecked(SettingsManager.getBoolean(SettingsEnum.BORDERLESS));
borderlessCheck.setChecked(SettingsManager.getBoolean(ClientSettings.BORDERLESS));

table.add(fullscreenCheck).colspan(2).row();
table.add(borderlessCheck).colspan(2).row();

CheckBox vsyncCheck = new CheckBox(" VSync", skin);
vsyncCheck.setChecked(SettingsManager.getBoolean(SettingsEnum.VSYNC));
vsyncCheck.setChecked(SettingsManager.getBoolean(ClientSettings.VSYNC));
table.add(vsyncCheck).colspan(2).row();

CheckBox fpsLimitCheck = new CheckBox(" Limit FPS", skin);
fpsLimitCheck.setChecked(SettingsManager.getBoolean(SettingsEnum.FPS_LIMIT_ENABLED));
fpsLimitCheck.setChecked(SettingsManager.getBoolean(ClientSettings.FPS_LIMIT_ENABLED));

TextField fpsField = new TextField(String.valueOf(SettingsManager.getInt(SettingsEnum.FPS_LIMIT)), skin);
TextField fpsField = new TextField(String.valueOf(SettingsManager.getInt(ClientSettings.FPS_LIMIT)), skin);
fpsField.setTextFieldFilter(new TextField.TextFieldFilter.DigitsOnlyFilter());
fpsField.setDisabled(!fpsLimitCheck.isChecked());

Expand All @@ -180,7 +180,7 @@ public void changed(ChangeEvent event, Actor actor) {

table.add(new Label("Brightness:", skin));
Slider brightnessSlider = new Slider(0, 100, 1, false, skin);
brightnessSlider.setValue((float) SettingsManager.getDouble(SettingsEnum.BRIGHTNESS));
brightnessSlider.setValue((float) SettingsManager.getDouble(ClientSettings.BRIGHTNESS));
Label brightnessValLabel = new Label((int)brightnessSlider.getValue() + "%", skin);

brightnessSlider.addListener(new ChangeListener() {
Expand All @@ -199,15 +199,15 @@ public void changed(ChangeEvent event, Actor actor) {
applyBtn.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
SettingsManager.set(SettingsEnum.RESOLUTION, resolutionSelect.getSelected());
SettingsManager.set(SettingsEnum.FULLSCREEN, fullscreenCheck.isChecked());
SettingsManager.set(SettingsEnum.BORDERLESS, borderlessCheck.isChecked());
SettingsManager.set(SettingsEnum.VSYNC, vsyncCheck.isChecked());
SettingsManager.set(SettingsEnum.FPS_LIMIT_ENABLED, fpsLimitCheck.isChecked());
SettingsManager.set(ClientSettings.RESOLUTION, resolutionSelect.getSelected());
SettingsManager.set(ClientSettings.FULLSCREEN, fullscreenCheck.isChecked());
SettingsManager.set(ClientSettings.BORDERLESS, borderlessCheck.isChecked());
SettingsManager.set(ClientSettings.VSYNC, vsyncCheck.isChecked());
SettingsManager.set(ClientSettings.FPS_LIMIT_ENABLED, fpsLimitCheck.isChecked());
try {
SettingsManager.set(SettingsEnum.FPS_LIMIT, Integer.parseInt(fpsField.getText()));
SettingsManager.set(ClientSettings.FPS_LIMIT, Integer.parseInt(fpsField.getText()));
} catch (NumberFormatException ignored) {}
SettingsManager.set(SettingsEnum.BRIGHTNESS, brightnessSlider.getValue());
SettingsManager.set(ClientSettings.BRIGHTNESS, brightnessSlider.getValue());
SettingsManager.saveSettings();

applyGraphicsSettings();
Expand All @@ -220,13 +220,13 @@ public void clicked(InputEvent event, float x, float y) {
}

private void applyGraphicsSettings() {
String resStr = SettingsManager.getString(SettingsEnum.RESOLUTION);
String resStr = SettingsManager.getString(ClientSettings.RESOLUTION);
String[] parts = resStr.split("x");
int width = Integer.parseInt(parts[0]);
int height = Integer.parseInt(parts[1]);
boolean isFullscreen = SettingsManager.getBoolean(SettingsEnum.FULLSCREEN);
boolean isBorderless = SettingsManager.getBoolean(SettingsEnum.BORDERLESS);
boolean vsync = SettingsManager.getBoolean(SettingsEnum.VSYNC);
boolean isFullscreen = SettingsManager.getBoolean(ClientSettings.FULLSCREEN);
boolean isBorderless = SettingsManager.getBoolean(ClientSettings.BORDERLESS);
boolean vsync = SettingsManager.getBoolean(ClientSettings.VSYNC);

Gdx.graphics.setVSync(vsync);

Expand All @@ -250,8 +250,8 @@ private void applyGraphicsSettings() {
}
}

if (SettingsManager.getBoolean(SettingsEnum.FPS_LIMIT_ENABLED)) {
Gdx.graphics.setForegroundFPS(SettingsManager.getInt(SettingsEnum.FPS_LIMIT));
if (SettingsManager.getBoolean(ClientSettings.FPS_LIMIT_ENABLED)) {
Gdx.graphics.setForegroundFPS(SettingsManager.getInt(ClientSettings.FPS_LIMIT));
} else {
Gdx.graphics.setForegroundFPS(0);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package xyz.samiker.theendlessweave.core.settings;
package xyz.samiker.theendlessweave.client.settings;

public enum SettingsEnum {
public enum ClientSettings {
RESOLUTION("video.resolution", "1280x720"),
FULLSCREEN("video.fullscreen", false),
BORDERLESS("video.borderless", false),
Expand All @@ -16,11 +16,10 @@ public enum SettingsEnum {
MUSIC_VOLUME("audio.music", 100),
SFX_VOLUME("audio.sfx", 100);


private final String key;
private final Object defaultValue;

SettingsEnum(String key, Object defaultValue) {
ClientSettings(String key, Object defaultValue) {
this.key = key;
this.defaultValue = defaultValue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class Game {
private final PerformanceMonitor profiler = new PerformanceMonitor();

private final Array<ISystem> logicSystems = new Array<>(5);
private final Array<ISystem> renderSystems = new Array<>(7);
private final Array<ISystem> renderSystems = new Array<>(10);
private final Array<Entity> entities = new Array<>(2048);
public final Array<Entity> queueAddEntities = new Array<>(512);
private int nextEntityId = 0;
Expand Down
Loading