From eda2de7c8e9055061cf27217ef1da2f5c4027c33 Mon Sep 17 00:00:00 2001 From: TheCodeBoat Date: Fri, 28 Jun 2013 08:07:18 +0200 Subject: [PATCH] extend optionsettings, improve gamegui --- .../controls/PlayerMouseControl.java | 2 +- .../controls/PlayerShootControl.java | 2 +- .../WeaponProjectileCollisionControl.java | 2 +- .../controls/WeaponProjectileControl.java | 2 +- .../org/wyrez/shootingstars/gui/GameGUI.java | 26 +++---------------- .../wyrez/shootingstars/gui/LoadingGui.java | 2 ++ .../wyrez/shootingstars/gui/OptionsGUI.java | 17 +++++++++++- .../shootingstars/helper/ScreenHelper.java | 16 ++++++++++++ .../states/util/OptionSettings.java | 8 ++++++ 9 files changed, 49 insertions(+), 28 deletions(-) diff --git a/ShootingStars/src/org/wyrez/shootingstars/controls/PlayerMouseControl.java b/ShootingStars/src/org/wyrez/shootingstars/controls/PlayerMouseControl.java index d2fc7e2..68ee10c 100644 --- a/ShootingStars/src/org/wyrez/shootingstars/controls/PlayerMouseControl.java +++ b/ShootingStars/src/org/wyrez/shootingstars/controls/PlayerMouseControl.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013 Darth Affe and contributors + * Copyright (C) 2013 Snowsun and contributors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/ShootingStars/src/org/wyrez/shootingstars/controls/PlayerShootControl.java b/ShootingStars/src/org/wyrez/shootingstars/controls/PlayerShootControl.java index 011b51f..6f408ff 100644 --- a/ShootingStars/src/org/wyrez/shootingstars/controls/PlayerShootControl.java +++ b/ShootingStars/src/org/wyrez/shootingstars/controls/PlayerShootControl.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013 Darth Affe and contributors + * Copyright (C) 2013 Snowsun and contributors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/ShootingStars/src/org/wyrez/shootingstars/controls/WeaponProjectileCollisionControl.java b/ShootingStars/src/org/wyrez/shootingstars/controls/WeaponProjectileCollisionControl.java index f454c4f..350e265 100644 --- a/ShootingStars/src/org/wyrez/shootingstars/controls/WeaponProjectileCollisionControl.java +++ b/ShootingStars/src/org/wyrez/shootingstars/controls/WeaponProjectileCollisionControl.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013 Darth Affe and contributors + * Copyright (C) 2013 Snowsun and contributors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/ShootingStars/src/org/wyrez/shootingstars/controls/WeaponProjectileControl.java b/ShootingStars/src/org/wyrez/shootingstars/controls/WeaponProjectileControl.java index 67c2067..ee34340 100644 --- a/ShootingStars/src/org/wyrez/shootingstars/controls/WeaponProjectileControl.java +++ b/ShootingStars/src/org/wyrez/shootingstars/controls/WeaponProjectileControl.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013 Darth Affe and contributors + * Copyright (C) 2013 Snowsun and contributors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/ShootingStars/src/org/wyrez/shootingstars/gui/GameGUI.java b/ShootingStars/src/org/wyrez/shootingstars/gui/GameGUI.java index a88b716..14669b4 100644 --- a/ShootingStars/src/org/wyrez/shootingstars/gui/GameGUI.java +++ b/ShootingStars/src/org/wyrez/shootingstars/gui/GameGUI.java @@ -43,7 +43,6 @@ public class GameGUI extends Panel { private Button btnStart; private Button btnResume; private Button btnMenu; - private Picture picCrosshair; private Dial indOverheat; private AssetManager assetManager; private Spatial player; @@ -105,29 +104,16 @@ public class GameGUI extends Panel { btnMenu.setTextAlign(BitmapFont.Align.Center); btnMenu.setFontSize(labelFontSize); - picCrosshair = new Picture("Crosshair"); - picCrosshair.setWidth(screenHelper.calcX(50f)); - picCrosshair.setHeight(screenHelper.calcY(50f)); - picCrosshair.setImage(assetManager, "Textures/crosshair.png", true); - - Panel pnlCrosshair = new Panel(screen, new Vector2f(0f, 0f), new Vector2f(0f, 0f)); - pnlCrosshair.setIsVisible(false); - pnlCrosshair.setIgnoreMouse(true); - pnlCrosshair.attachChild(picCrosshair); - pnlCrosshair.centerToParent(); - picCrosshair.center(); - - indOverheat = new Dial(screen, pnlCrosshair.getPosition()) { + indOverheat = new Dial(screen, new Vector2f(0f, 0f)) { @Override public void onChange(int arg0, Object arg1) { } }; indOverheat.setGapStartAngle(60); indOverheat.setGapEndAngle(296); - indOverheat.setWidth(screenHelper.calcX(50f)); - indOverheat.setHeight(screenHelper.calcY(50f)); + indOverheat.setDimensions(screenHelper.calcX(50f), screenHelper.calcY(50f)); indOverheat.centerToParent(); - indOverheat.setDialImageBackground("Textures/empty.png"); + indOverheat.setDialImageBackground("Textures/crosshair.png"); indOverheat.setDialImageIndicator("Textures/heat_ind.png"); updateOverhead(0f); @@ -139,12 +125,10 @@ public class GameGUI extends Panel { this.addChild(btnResume); this.addChild(btnMenu); this.addChild(indOverheat); - this.addChild(pnlCrosshair); this.addChild(lblPoints); btnResume.hide(); btnMenu.hide(); - picCrosshair.setCullHint(CullHint.Always); indOverheat.hide(); lblPoints.hide(); } @@ -153,7 +137,6 @@ public class GameGUI extends Panel { btnStart.hide(); btnResume.hide(); btnMenu.hide(); - picCrosshair.setCullHint(CullHint.Inherit); indOverheat.show(); lblPoints.show(); } @@ -162,7 +145,6 @@ public class GameGUI extends Panel { btnStart.show(); btnResume.hide(); btnMenu.hide(); - picCrosshair.setCullHint(CullHint.Always); indOverheat.hide(); lblPoints.hide(); } @@ -171,7 +153,6 @@ public class GameGUI extends Panel { btnStart.hide(); btnResume.show(); btnMenu.show(); - picCrosshair.setCullHint(CullHint.Always); indOverheat.hide(); lblPoints.hide(); } @@ -180,7 +161,6 @@ public class GameGUI extends Panel { btnStart.hide(); btnResume.hide(); btnMenu.hide(); - picCrosshair.setCullHint(CullHint.Inherit); indOverheat.show(); lblPoints.show(); } diff --git a/ShootingStars/src/org/wyrez/shootingstars/gui/LoadingGui.java b/ShootingStars/src/org/wyrez/shootingstars/gui/LoadingGui.java index dce6724..4d9cc8f 100644 --- a/ShootingStars/src/org/wyrez/shootingstars/gui/LoadingGui.java +++ b/ShootingStars/src/org/wyrez/shootingstars/gui/LoadingGui.java @@ -50,6 +50,7 @@ public class LoadingGui extends Panel { float startPointx = screenHelper.calcX(537f); float startPointy = screenHelper.calcY(576f); float distancePogressbarLabely = screenHelper.calcY(36f); + float labelFontSize = screenHelper.calcX(20f); indProgress = new IndicatorBase(screen, new Vector2f(startPointx, startPointy), new Vector2f(screenHelper.calcX(200f), screenHelper.calcY(30f)), Indicator.Orientation.HORIZONTAL); @@ -59,6 +60,7 @@ public class LoadingGui extends Panel { lblStatus = new Label(screen, new Vector2f(startPointx, startPointy + distancePogressbarLabely), new Vector2f(screenHelper.calcX(200f), screenHelper.calcY(30f))); lblStatus.setTextAlign(BitmapFont.Align.Center); + lblStatus.setFontSize(labelFontSize); this.addChild(indProgress); this.addChild(lblStatus); diff --git a/ShootingStars/src/org/wyrez/shootingstars/gui/OptionsGUI.java b/ShootingStars/src/org/wyrez/shootingstars/gui/OptionsGUI.java index daa9b51..81be6ae 100644 --- a/ShootingStars/src/org/wyrez/shootingstars/gui/OptionsGUI.java +++ b/ShootingStars/src/org/wyrez/shootingstars/gui/OptionsGUI.java @@ -45,6 +45,7 @@ public class OptionsGUI extends Panel implements Gui { //General Controls private TextField txtPlayerName; + private CheckBox chkEnableAudioVisualization; //Video Controls private ComboBox cboResolution; @@ -119,6 +120,10 @@ public class OptionsGUI extends Panel implements Gui { float startPointx = screenHelper.calcX(64f); float startPointy = screenHelper.calcY(36f); float marginLeftControls = screenHelper.calcX(115.8f); + + float startPointAudioVisualx = screenHelper.calcX(464f); + float startPointAudioVisualy = screenHelper.calcY(36f); + float marginLeftAudioVisualControl = screenHelper.calcX(190f); Label lblPlayerName = new Label(screen, new Vector2f(startPointx, startPointy), new Vector2f(screenHelper.calcX(120f), screenHelper.calcY(40f))); lblPlayerName.setText("Player Name"); @@ -127,8 +132,16 @@ public class OptionsGUI extends Panel implements Gui { txtPlayerName = new TextField(screen, new Vector2f(startPointx + marginLeftControls, startPointy + screenHelper.calcY(7f)), new Vector2f(screenHelper.calcX(200f), screenHelper.calcY(30f))); txtPlayerName.setFontSize(labelFontSize); + Label lblEnableAudioVisualization = new Label(screen, new Vector2f(startPointAudioVisualx, startPointAudioVisualy), new Vector2f(screenHelper.calcX(200f), screenHelper.calcY(40f))); + lblEnableAudioVisualization.setText("Enable Audio Visualization"); + lblEnableAudioVisualization.setFontSize(labelFontSize); + + chkEnableAudioVisualization = new CheckBox(screen, new Vector2f(startPointAudioVisualx + marginLeftAudioVisualControl, startPointAudioVisualy + screenHelper.calcY(12f)), new Vector2f(screenHelper.calcX(20f), screenHelper.calcX(20f))); + this.addChild(lblPlayerName); this.addChild(txtPlayerName); + this.addChild(lblEnableAudioVisualization); + this.addChild(chkEnableAudioVisualization); } private void createVideo(float labelFontSize) { @@ -277,13 +290,14 @@ public class OptionsGUI extends Panel implements Gui { //General txtPlayerName.setText(settings.getUsername()); + chkEnableAudioVisualization.setIsChecked(settings.isAudioVisualizationEnabled()); //Video setComboBoxValue(cboResolution, resolution); setComboBoxValue(cboFrequency, String.valueOf(settings.getFrequency())); chkFullscreen.setIsChecked(settings.isFullscreenEnabled()); chkVSync.setIsChecked(settings.isVSyncEnabled()); - chkShowWeapon.setIsChecked(settings.isShowWeaponEnabled()); + chkShowWeapon.setIsChecked(settings.isShowWeaponEnabled()); sldParticleDensity.setSelectedIndex(settings.getParticleDensity()); //Audio @@ -303,6 +317,7 @@ public class OptionsGUI extends Panel implements Gui { private void saveControlValues() { //General settings.setUsername(txtPlayerName.getText()); + settings.setEnableAudioVisualization(chkEnableAudioVisualization.getIsChecked()); //Video String resolution[] = cboResolution.getSelectedListItem().getValue().toString().split(" x "); diff --git a/ShootingStars/src/org/wyrez/shootingstars/helper/ScreenHelper.java b/ShootingStars/src/org/wyrez/shootingstars/helper/ScreenHelper.java index 1c837dd..ef5c43f 100644 --- a/ShootingStars/src/org/wyrez/shootingstars/helper/ScreenHelper.java +++ b/ShootingStars/src/org/wyrez/shootingstars/helper/ScreenHelper.java @@ -1,3 +1,19 @@ +/* + * Copyright (C) 2013 Snowsun and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.wyrez.shootingstars.helper; import tonegod.gui.core.Screen; diff --git a/ShootingStars/src/org/wyrez/shootingstars/states/util/OptionSettings.java b/ShootingStars/src/org/wyrez/shootingstars/states/util/OptionSettings.java index 2291f51..744668c 100644 --- a/ShootingStars/src/org/wyrez/shootingstars/states/util/OptionSettings.java +++ b/ShootingStars/src/org/wyrez/shootingstars/states/util/OptionSettings.java @@ -104,6 +104,10 @@ public class OptionSettings { public void setShowWeapon(boolean enabled) { settings.putBoolean("ShowWeapon", enabled); } + + public void setEnableAudioVisualization(boolean enabled) { + settings.putBoolean("EnableAudioVisualization", enabled); + } public void setFullscreen(boolean enabled) { settings.setFullscreen(enabled); @@ -164,6 +168,10 @@ public class OptionSettings { public boolean isShowWeaponEnabled() { return settings.getBoolean("ShowWeapon"); } + + public boolean isAudioVisualizationEnabled() { + return settings.getBoolean("EnableAudioVisualization"); + } public boolean isFullscreenEnabled() { return settings.isFullscreen();