Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'develop' of git@github.com:MovingBlocks/Terasology.git …

…into develop

Conflicts:
	src/main/java/org/terasology/componentSystem/controllers/LocalPlayerSystem.java
  • Loading branch information...
commit 7e63dd9462c6ca3f4180a8a2ac3ad3c6c7a3e503 2 parents 4643161 + aff2f2b
@immortius immortius authored
Showing with 5,020 additions and 4,667 deletions.
  1. +1 −0  .gitignore
  2. +7 −20 build.gradle
  3. +96 −7 config/checkstyle/checkstyle.xml
  4. +8 −0 config/checkstyle/suppressions.xml
  5. 0  src/{perfTest → dev}/java/org/terasology/world/ChunkCachePerformanceTest.java
  6. +2 −2 src/main/java/org/terasology/componentSystem/action/ReadBookAction.java
  7. +6 −1 src/main/java/org/terasology/componentSystem/controllers/DebugControlSystem.java
  8. +2 −2 src/main/java/org/terasology/componentSystem/controllers/LocalPlayerSystem.java
  9. +0 −7 src/main/java/org/terasology/game/modes/StateMainMenu.java
  10. +0 −4 src/main/java/org/terasology/game/modes/StateSinglePlayer.java
  11. +17 −46 src/main/java/org/terasology/logic/manager/GUIManager.java
  12. +36 −18 src/main/java/org/terasology/logic/manager/PostProcessingRenderer.java
  13. +3 −3 src/main/java/org/terasology/model/BuffIcon.java
  14. +3 −3 src/main/java/org/terasology/model/inventory/Icon.java
  15. +2 −2 src/main/java/org/terasology/mods/miniions/componentsystem/controllers/MinionSystem.java
  16. +6 −6 src/main/java/org/terasology/mods/miniions/rendering/gui/components/UIMessageQueue.java
  17. +7 −7 src/main/java/org/terasology/mods/miniions/rendering/gui/components/UIMinionBehaviourMenu.java
  18. +12 −19 src/main/java/org/terasology/mods/miniions/rendering/gui/components/UIMinionbar.java
  19. +0 −162 src/main/java/org/terasology/rendering/gui/components/UIButton.java
  20. +0 −191 src/main/java/org/terasology/rendering/gui/components/UIComboBox.java
  21. +0 −136 src/main/java/org/terasology/rendering/gui/components/UIDialogBox.java
  22. +0 −116 src/main/java/org/terasology/rendering/gui/components/UIHealthBar.java
  23. +0 −42 src/main/java/org/terasology/rendering/gui/components/UIImageOverlay.java
  24. +0 −338 src/main/java/org/terasology/rendering/gui/components/UIList.java
  25. +0 −76 src/main/java/org/terasology/rendering/gui/components/UIMessageBox.java
  26. +0 −40 src/main/java/org/terasology/rendering/gui/components/UIOpenBook.java
  27. +0 −95 src/main/java/org/terasology/rendering/gui/components/UIProgressBar.java
  28. +0 −387 src/main/java/org/terasology/rendering/gui/components/UIScrollBar.java
  29. +0 −80 src/main/java/org/terasology/rendering/gui/components/UIToolbar.java
  30. +0 −69 src/main/java/org/terasology/rendering/gui/components/UITransparentOverlay.java
  31. +0 −81 src/main/java/org/terasology/rendering/gui/components/UIWindowTitle.java
  32. +35 −33 src/main/java/org/terasology/rendering/gui/dialogs/UIDialogCreateNewWorld.java
  33. +382 −122 src/main/java/org/terasology/rendering/gui/framework/UIDisplayContainer.java
  34. +314 −0 src/main/java/org/terasology/rendering/gui/framework/UIDisplayContainerScrollable.java
  35. +559 −211 src/main/java/org/terasology/rendering/gui/framework/UIDisplayElement.java
  36. +17 −10 src/main/java/org/terasology/rendering/gui/framework/UIDisplayRenderer.java
  37. +0 −125 src/main/java/org/terasology/rendering/gui/framework/UIGraphicsElement.java
  38. +0 −199 src/main/java/org/terasology/rendering/gui/framework/UIScrollableDisplayContainer.java
  39. +1 −1  src/main/java/org/terasology/rendering/gui/framework/events/BindKeyListener.java
  40. +1 −1  src/main/java/org/terasology/rendering/gui/framework/events/ChangedListener.java
  41. +5 −5 src/main/java/org/terasology/rendering/gui/framework/events/ClickListener.java
  42. +4 −4 src/main/java/org/terasology/rendering/gui/framework/events/FocusListener.java
  43. +1 −1  src/main/java/org/terasology/rendering/gui/framework/events/KeyListener.java
  44. +11 −11 src/main/java/org/terasology/rendering/gui/framework/events/MouseButtonListener.java
  45. +23 −23 src/main/java/org/terasology/rendering/gui/framework/events/MouseMoveListener.java
  46. +1 −1  src/main/java/org/terasology/rendering/gui/framework/events/StateButtonAction.java
  47. +2 −2 src/main/java/org/terasology/rendering/gui/framework/events/WindowListener.java
  48. +0 −79 src/main/java/org/terasology/rendering/gui/framework/style/UIProperty.java
  49. +0 −129 src/main/java/org/terasology/rendering/gui/framework/style/UIPropertyBackground.java
  50. +0 −296 src/main/java/org/terasology/rendering/gui/framework/style/UIPropertyBorder.java
  51. +10 −70 src/main/java/org/terasology/rendering/gui/framework/style/UIStyle.java
  52. +21 −0 src/main/java/org/terasology/rendering/gui/framework/style/UIStyleBackgroundColor.java
  53. +24 −0 src/main/java/org/terasology/rendering/gui/framework/style/UIStyleBackgroundImage.java
  54. +12 −0 src/main/java/org/terasology/rendering/gui/framework/style/UIStyleBackgroundSplit.java
  55. +250 −0 src/main/java/org/terasology/rendering/gui/framework/style/UIStyleBorderImage.java
  56. +110 −0 src/main/java/org/terasology/rendering/gui/framework/style/UIStyleBorderSolid.java
  57. +390 −0 src/main/java/org/terasology/rendering/gui/layout/GridLayout.java
  58. +22 −0 src/main/java/org/terasology/rendering/gui/layout/Layout.java
  59. +9 −8 src/main/java/org/terasology/rendering/gui/{components → widgets}/UIBuff.java
  60. +234 −0 src/main/java/org/terasology/rendering/gui/widgets/UIButton.java
  61. +179 −0 src/main/java/org/terasology/rendering/gui/widgets/UIComboBox.java
  62. +69 −0 src/main/java/org/terasology/rendering/gui/widgets/UIComposite.java
  63. +212 −0 src/main/java/org/terasology/rendering/gui/widgets/UIDialogBox.java
  64. +234 −0 src/main/java/org/terasology/rendering/gui/widgets/UIImage.java
  65. +16 −8 src/main/java/org/terasology/rendering/gui/{components → widgets}/UIInput.java
  66. +109 −97 src/main/java/org/terasology/rendering/gui/{components → widgets}/UIItemCell.java
  67. +2 −2 src/main/java/org/terasology/rendering/gui/{components → widgets}/UIItemCellIcon.java
  68. +3 −2 src/main/java/org/terasology/rendering/gui/{components → widgets}/UIItemContainer.java
  69. +361 −0 src/main/java/org/terasology/rendering/gui/widgets/UIList.java
  70. +62 −0 src/main/java/org/terasology/rendering/gui/widgets/UIMessageBox.java
  71. +103 −0 src/main/java/org/terasology/rendering/gui/widgets/UIProgressBar.java
  72. +70 −75 src/main/java/org/terasology/rendering/gui/{components → widgets}/UISlider.java
  73. +55 −55 src/main/java/org/terasology/rendering/gui/{components → widgets}/UIStateButton.java
  74. +33 −47 src/main/java/org/terasology/rendering/gui/{components → widgets}/UIText.java
  75. +35 −42 src/main/java/org/terasology/rendering/gui/{components → widgets}/UITextWrap.java
  76. +69 −63 src/main/java/org/terasology/rendering/gui/{framework/UIDisplayWindow.java → widgets/UIWindow.java}
  77. +27 −48 src/main/java/org/terasology/rendering/gui/windows/UIMenuConfig.java
  78. +23 −42 src/main/java/org/terasology/rendering/gui/windows/UIMenuConfigAudio.java
  79. +158 −283 src/main/java/org/terasology/rendering/gui/windows/UIMenuConfigControls.java
  80. +20 −38 src/main/java/org/terasology/rendering/gui/windows/UIMenuConfigMods.java
  81. +137 −165 src/main/java/org/terasology/rendering/gui/windows/UIMenuConfigVideo.java
  82. +26 −46 src/main/java/org/terasology/rendering/gui/windows/UIMenuMain.java
  83. +31 −52 src/main/java/org/terasology/rendering/gui/windows/UIMenuPause.java
  84. +47 −71 src/main/java/org/terasology/rendering/gui/windows/UIMenuSelectWorld.java
  85. +11 −19 src/main/java/org/terasology/rendering/gui/windows/UIScreenBook.java
  86. +8 −7 src/main/java/org/terasology/rendering/gui/windows/UIScreenConsole.java
  87. +19 −18 src/main/java/org/terasology/rendering/gui/windows/UIScreenContainer.java
  88. +18 −42 src/main/java/org/terasology/rendering/gui/windows/UIScreenDeath.java
  89. +153 −82 src/main/java/org/terasology/rendering/gui/windows/UIScreenHUD.java
  90. +63 −42 src/main/java/org/terasology/rendering/gui/windows/UIScreenInventory.java
  91. +14 −23 src/main/java/org/terasology/rendering/gui/windows/UIScreenLoading.java
  92. +7 −7 src/main/java/org/terasology/rendering/gui/windows/UIScreenMetrics.java
  93. BIN  src/main/resources/org/terasology/data/textures/gui_menu.png
View
1  .gitignore
@@ -12,6 +12,7 @@ Terasology.iws
.classpath
.project
.settings
+.checkstyle
.gradle
bin
data/console/consolelog.json
View
27 build.gradle
@@ -86,11 +86,16 @@ sourceCompatibility = 1.6
compileJava.enabled = false
sourceSets.main.java.srcDirs.each { sourceSets.main.groovy.srcDirs it }
+sourceSets {
+ dev
+}
+
configurations {
compile {
exclude module: 'lwjgl-platform'
exclude module: 'jinput-platform'
}
+ devCompile.extendsFrom compile
}
dependencies {
@@ -108,6 +113,7 @@ dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
testCompile group: 'junit', name: 'junit', version: '4.10'
testCompile group: 'org.mockito', name: 'mockito-all', version: '1.9.0'
+ devCompile sourceSets.main.output
}
task createVersionInfoFile << {
@@ -164,6 +170,7 @@ test {
/* Check ------------------------------------------------------------------- */
checkstyle.ignoreFailures = true
+checkstyle.configProperties.samedir = checkstyle.configFile.parentFile
/* Optional check plugins
apply plugin: 'codenarc'
apply plugin: 'findbugs'
@@ -175,26 +182,6 @@ findbugs.ignoreFailures = true
pmd.ignoreFailures = true
*/
-/* perfTest ----------------------------------------------------------------- */
-sourceSets {
- perfTest
-}
-
-configurations {
- perfTestCompile.extendsFrom compile
-}
-
-dependencies {
- perfTestCompile sourceSets.main.output
-}
-
-task runChunkCachePerformanceTest(type:JavaExec) {
- description = "Run 'ChunkCachePerformanceTest'"
- main = 'org.terasology.world.ChunkCachePerformanceTest'
- classpath sourceSets.perfTest.runtimeClasspath
- jvmArgs '-Xms512m', '-Xmx1024m', '-XX:MaxPermSize=128m'
-}
-
/* Misc tasks ------------------------------------------------------------------- */
task assembleMainOutput(type:Sync) {
from sourceSets.main.output
View
103 config/checkstyle/checkstyle.xml
@@ -4,20 +4,109 @@
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<module name="Checker">
+ <module name="SuppressionFilter">
+ <property name="file" value="${samedir}/suppressions.xml"/>
+ </module>
+
<!-- Checks whether files end with a new line. -->
- <!-- See http://checkstyle.sf.net/config_misc.html#NewlineAtEndOfFile -->
+ <!-- See http://checkstyle.sourceforge.net/config_misc.html#NewlineAtEndOfFile -->
<module name="NewlineAtEndOfFile"/>
+ <!-- Checks that there are no tab characters ('\t') in the source code. -->
+ <!-- See http://checkstyle.sourceforge.net/config_whitespace.html#FileTabCharacter -->
+ <module name="FileTabCharacter"/>
+
<module name="TreeWalker">
+ <!-- Checks for Naming Conventions -->
+ <!-- See http://checkstyle.sourceforge.net/config_naming.html -->
+ <!-- ***************************** -->
+ <!-- constants (static, final fields) : ^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$ -->
+ <module name="ConstantName"/>
+ <!-- local, final variables, including catch parameters : ^[a-z][a-zA-Z0-9]*$ -->
+ <module name="LocalFinalVariableName"/>
+ <!-- local, non-final variables, including catch parameters : ^[a-z][a-zA-Z0-9]*$ -->
+ <module name="LocalVariableName"/>
+ <!-- non-static fields : ^[a-z][a-zA-Z0-9]*$ -->
+ <module name="MemberName"/>
+ <!-- methods : ^[a-z][a-zA-Z0-9]*$ -->
+ <module name="MethodName"/>
+ <!-- packages : ^[a-z]+(\.[a-zA-Z_][a-zA-Z0-9_]*)*$ -->
<module name="PackageName"/>
+ <!-- parameters : ^[a-z][a-zA-Z0-9]*$ -->
+ <module name="ParameterName"/>
+ <!-- static, non-final fields : ^[a-z][a-zA-Z0-9]*$ -->
+ <module name="StaticVariableName"/>
+ <!-- classes and interfaces : ^[A-Z][a-zA-Z0-9]*$ -->
<module name="TypeName"/>
- <!-- Checks for imports -->
- <!-- See http://checkstyle.sf.net/config_import.html -->
- <module name="AvoidStarImport"/>
- <module name="IllegalImport"/> <!-- defaults to sun.* packages -->
- <module name="RedundantImport"/>
- <module name="UnusedImports"/>
+ <!-- Checks for imports -->
+ <!-- ****************** -->
+ <!-- Checks that there are no import statements that use the * notation. -->
+ <!-- See http://checkstyle.sourceforge.net/config_imports.html#AvoidStarImport -->
+ <module name="AvoidStarImport">
+ <property name="severity" value="warning"/>
+ <property name="allowStaticMemberImports" value="true"/> <!-- allow starred static member imports -->
+ </module>
+ <!-- Checks for redundant import statements. -->
+ <!-- See http://checkstyle.sourceforge.net/config_imports.html#RedundantImport -->
+ <module name="RedundantImport">
+ <property name="severity" value="warning"/>
+ </module>
+ <!-- Checks for unused import statements. -->
+ <!-- See http://checkstyle.sourceforge.net/config_imports.html#UnusedImports -->
+ <module name="UnusedImports">
+ <property name="severity" value="warning"/>
+ </module>
+
+ <!-- Modifier Checks -->
+ <!-- *************** -->
+ <!-- Checks that the order of modifiers conforms to the suggestions in the Java Language specification -->
+ <!-- See http://checkstyle.sourceforge.net/config_modifier.html#ModifierOrder -->
+ <module name="ModifierOrder"/>
+ <!-- Checks for redundant modifiers -->
+ <!-- See http://checkstyle.sourceforge.net/config_modifier.html#RedundantModifier -->
+ <module name="RedundantModifier">
+ <property name="severity" value="warning"/>
+ </module>
+
+ <!-- Checks for blocks. You know, those {}'s -->
+ <!-- *************************************** -->
+ <!-- Finds nested blocks, i.e. blocks that are used freely in the code. -->
+ <!-- See http://checkstyle.sourceforge.net/config_blocks.html#AvoidNestedBlocks -->
+ <module name="AvoidNestedBlocks"/>
+ <!-- Checks for empty blocks. -->
+ <!-- See http://checkstyle.sourceforge.net/config_blocks.html#EmptyBlock -->
+ <module name="EmptyBlock">
+ <property name="severity" value="warning"/>
+ </module>
+ <!-- Checks for the placement of left curly braces ('{') for code blocks. Default: eol -->
+ <!-- See http://checkstyle.sourceforge.net/config_blocks.html#LeftCurly -->
+ <module name="LeftCurly"/>
+ <!-- Checks for braces around code blocks. -->
+ <!-- See http://checkstyle.sourceforge.net/config_blocks.html#NeedBraces -->
+ <module name="NeedBraces"/>
+ <!-- Checks the placement of right curly braces ('}') for else, try, and catch tokens. Default: same -->
+ <!-- See http://checkstyle.sourceforge.net/config_blocks.html#RightCurly -->
+ <module name="RightCurly"/>
+
+ <!-- Miscellaneous other checks. -->
+ <!-- *************************** -->
+ <!-- Checks the style of array type definitions. -->
+ <!-- See http://checkstyle.sourceforge.net/config_misc.html#ArrayTypeStyle -->
+ <module name="ArrayTypeStyle">
+ <property name="severity" value="warning"/>
+ </module>
+ <!-- Checks correct indentation of Java Code. -->
+ <!-- See http://checkstyle.sourceforge.net/config_misc.html#Indentation -->
+ <module name="Indentation">
+ <property name="severity" value="warning"/>
+ </module>
+ <!-- Checks that long constants are defined with an upper ell. That is ' L' and not 'l'. -->
+ <!-- See http://checkstyle.sourceforge.net/config_misc.html#UpperEll -->
+ <module name="UpperEll"/>
+ <!-- Checks that the outer type name and the file name match. -->
+ <!-- See http://checkstyle.sourceforge.net/config_misc.html#OuterTypeFilename -->
+ <module name="OuterTypeFilename"/>
</module>
</module>
View
8 config/checkstyle/suppressions.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0"?>
+<!DOCTYPE suppressions PUBLIC
+ "-//Puppy Crawl//DTD Suppressions 1.1//EN"
+ "http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">
+
+<suppressions>
+ <suppress checks="." files="org[\\/]terasology[\\/]protobuf[\\/].*"/>
+</suppressions>
View
0  ...logy/world/ChunkCachePerformanceTest.java → ...logy/world/ChunkCachePerformanceTest.java
File renamed without changes
View
4 src/main/java/org/terasology/componentSystem/action/ReadBookAction.java
@@ -22,7 +22,7 @@
import org.terasology.entitySystem.RegisterComponentSystem;
import org.terasology.events.ActivateEvent;
import org.terasology.logic.manager.GUIManager;
-import org.terasology.rendering.gui.framework.UIDisplayWindow;
+import org.terasology.rendering.gui.widgets.UIWindow;
import org.terasology.rendering.gui.windows.UIScreenBook;
@@ -34,7 +34,7 @@
@RegisterComponentSystem
public class ReadBookAction implements EventHandlerSystem {
- private UIDisplayWindow bookScreen;
+ private UIWindow bookScreen;
public void initialise() {
bookScreen = GUIManager.getInstance().addWindow(new UIScreenBook(), "engine:bookScreen");
View
7 src/main/java/org/terasology/componentSystem/controllers/DebugControlSystem.java
@@ -103,7 +103,12 @@ public void onKeyDown(KeyDownEvent event, EntityRef entity) {
entity.send(new DamageEvent(9999, null));
break;
case Keyboard.KEY_H:
- GUIManager.getInstance().getWindowById("engine:hud").setVisible(!GUIManager.getInstance().getWindowById("engine:hud").isVisible());
+ if (GUIManager.getInstance().getWindowById("engine:hud").isVisible()) {
+ GUIManager.getInstance().getWindowById("engine:hud").close();
+ } else {
+ GUIManager.getInstance().getWindowById("engine:hud").open();
+ }
+
event.consume();
break;
}
View
4 src/main/java/org/terasology/componentSystem/controllers/LocalPlayerSystem.java
@@ -20,6 +20,7 @@
import org.terasology.componentSystem.UpdateSubscriberSystem;
import org.terasology.components.*;
import org.terasology.math.Vector3i;
+import org.terasology.rendering.gui.widgets.UIImage;
import org.terasology.world.block.BlockComponent;
import org.terasology.world.block.BlockItemComponent;
import org.terasology.components.rendering.MeshComponent;
@@ -52,7 +53,6 @@
import org.terasology.physics.character.CharacterMovementComponent;
import org.terasology.rendering.AABBRenderer;
import org.terasology.rendering.cameras.DefaultCamera;
-import org.terasology.rendering.gui.framework.UIGraphicsElement;
import org.terasology.world.block.BlockRegionComponent;
import javax.vecmath.Quat4f;
@@ -369,7 +369,7 @@ public void onDropItem(DropItemButton event, EntityRef entity){
if (localPlayerComp.isDead) return;
- UIGraphicsElement crossHair = (UIGraphicsElement)GUIManager.getInstance().getWindowById("engine:hud").getElementById("crosshair");
+ UIImage crossHair = (UIImage)GUIManager.getInstance().getWindowById("engine:hud").getElementById("crosshair");
crossHair.getTextureSize().set(new Vector2f(22f / 256f, 22f / 256f));
View
7 src/main/java/org/terasology/game/modes/StateMainMenu.java
@@ -94,25 +94,18 @@ public void init(GameEngine gameEngine) {
//setup the GUI
_mainMenu = new UIMenuMain();
- _mainMenu.setVisible(true);
_selectWorldMenu = new UIMenuSelectWorld();
- _selectWorldMenu.setVisible(false);
_configMenu = new UIMenuConfig();
- _configMenu.setVisible(false);
_configMenuVideo = new UIMenuConfigVideo();
- _configMenuVideo.setVisible(false);
_configMenuAudio = new UIMenuConfigAudio();
- _configMenuAudio.setVisible(false);
_configMenuControls = new UIMenuConfigControls();
- _configMenuControls.setVisible(false);
_configMenuMods = new UIMenuConfigMods();
- _configMenuMods.setVisible(false);
GUIManager.getInstance().addWindow(_mainMenu, "menuMain");
GUIManager.getInstance().addWindow(_selectWorldMenu, "selectWorld");
View
4 src/main/java/org/terasology/game/modes/StateSinglePlayer.java
@@ -296,10 +296,6 @@ public void initWorld() {
prepareWorld();
}
- private boolean screenHasFocus() {
- return GUIManager.getInstance().getFocusedWindow() != null && GUIManager.getInstance().getFocusedWindow().isModal() && GUIManager.getInstance().getFocusedWindow().isVisible();
- }
-
private boolean shouldUpdateWorld() {
return !pauseGame;
}
View
63 src/main/java/org/terasology/logic/manager/GUIManager.java
@@ -30,14 +30,15 @@
import org.terasology.input.events.MouseYAxisEvent;
import org.terasology.input.BindButtonEvent;
import org.terasology.input.ButtonState;
-import org.terasology.rendering.gui.components.UIMessageBox;
-import org.terasology.rendering.gui.framework.UIDisplayElement;
import org.terasology.rendering.gui.framework.UIDisplayRenderer;
-import org.terasology.rendering.gui.framework.UIDisplayWindow;
+import org.terasology.rendering.gui.widgets.UIMessageBox;
+import org.terasology.rendering.gui.widgets.UIWindow;
import java.util.HashMap;
import java.util.List;
+import javax.vecmath.Vector2f;
+
/**
* First version of simple GUI manager.
* ToDo Init styles here
@@ -50,7 +51,7 @@
public class GUIManager implements EventHandlerSystem {
private static GUIManager instance;
- private HashMap<String, UIDisplayWindow> windowsById = new HashMap<String, UIDisplayWindow>();
+ private HashMap<String, UIWindow> windowsById = new HashMap<String, UIWindow>();
//renderer
private UIDisplayRenderer renderer;
@@ -78,25 +79,11 @@ public void render() {
/**
* Updates all visible display elements and their child's. Will update the layout if the display was resized.
*/
- public void update() {
- //TODO what should the following code do?
- /*
- if (_currentFocused == null) {
- int size = _renderer.getDisplayElements().size();
- if (size > 0) {
- //added this check to prevent the manager from ungrabbing the mouse when the minion behaviour menu pops up
- // TODO : better way to handle this? not link focus with grabbing / ungrabbing?
- UIDisplayWindow tempwindow = (UIDisplayWindow) _renderer.getDisplayElements().get(size - 1);
- if (!(tempwindow instanceof UIMinionBehaviourMenu)) {
- _currentFocused = tempwindow;
- }
- }
- }
- */
-
+ public void update() {
renderer.update();
if (Display.wasResized()) {
+ renderer.setSize(new Vector2f(Display.getWidth(), Display.getHeight()));
renderer.layout();
}
}
@@ -107,13 +94,8 @@ public void update() {
* @param windowId The id of the window, to access windows by id.
* @return Returns the added window.
*/
- public <T extends UIDisplayWindow> T addWindow(T window, String windowId) {
- if (window.isMaximized()) {
- renderer.addtDisplayElementToPosition(0, window);
- } else {
- renderer.addDisplayElement(window);
- }
-
+ public <T extends UIWindow> T addWindow(T window, String windowId) {
+ renderer.addDisplayElementToPosition(0, window);
windowsById.put(windowId, window);
if (windowsById.size() == 1) {
@@ -137,7 +119,7 @@ public void removeAllWindows() {
* Close the given window and remove it from the GUIManager. Therefore it won't be updated or rendered anymore.
* @param window The window by reference to remove.
*/
- public void removeWindow(UIDisplayWindow window) {
+ public void removeWindow(UIWindow window) {
if (window == null) {
return;
@@ -166,7 +148,7 @@ public void removeWindow(String windowId) {
* @param windowId The window id.
* @return Returns the reference of the window with the given id or null if there is none with this id.
*/
- public UIDisplayWindow getWindowById(String windowId) {
+ public UIWindow getWindowById(String windowId) {
if (windowsById.containsKey(windowId)) {
return windowsById.get(windowId);
} else {
@@ -178,7 +160,7 @@ public UIDisplayWindow getWindowById(String windowId) {
* Set the focus to the given window by its reference. The focused window will be set on the top of the layer.
* @param window The window reference.
*/
- public void setFocusedWindow(UIDisplayWindow window) {
+ public void setFocusedWindow(UIWindow window) {
renderer.setWindowFocus(window);
checkMouseMovement();
}
@@ -199,7 +181,7 @@ public void setFocusedWindow(String windowId) {
* Get the focused window.
* @return Returns the focused window.
*/
- public UIDisplayWindow getFocusedWindow() {
+ public UIWindow getFocusedWindow() {
return renderer.getWindowFocused();
}
@@ -228,9 +210,7 @@ public boolean isConsumingInput() {
* @param text The text of the dialog.
*/
public void showMessage(String title, String text) {
- UIDisplayWindow messageWindow = new UIMessageBox(title, text);
- messageWindow.setVisible(true);
- messageWindow.center();
+ UIWindow messageWindow = new UIMessageBox(title, text);
addWindow(messageWindow, "messageBox");
setFocusedWindow(messageWindow);
}
@@ -250,7 +230,7 @@ public void showMessage(String title, String text) {
*/
private void processMouseInput(int button, boolean state, int wheelMoved) {
if (renderer.getWindowFocused() != null) {
- renderer.getWindowFocused().processMouseInput(button, state, wheelMoved);
+ renderer.getWindowFocused().processMouseInput(button, state, wheelMoved, false);
}
}
@@ -259,17 +239,8 @@ private void processMouseInput(int button, boolean state, int wheelMoved) {
* @param event The event of the pressed key.
*/
private void processKeyboardInput(KeyEvent event) {
- if (renderer.getWindowFocused() != null && renderer.getWindowFocused().isModal() && renderer.getWindowFocused().isVisible()) { //TODO change this
+ if (renderer.getWindowFocused() != null && renderer.getWindowFocused().isModal() && renderer.getWindowFocused().isVisible()) {
renderer.getWindowFocused().processKeyboardInput(event);
- event.consume();
- return;
- }
-
- List<UIDisplayElement> screens = Lists.newArrayList(renderer.getDisplayElements());
- for (UIDisplayElement screen : screens) {
- if (!((UIDisplayWindow) screen).isModal()) {
- screen.processKeyboardInput(event);
- }
}
}
@@ -278,7 +249,7 @@ private void processKeyboardInput(KeyEvent event) {
* @param event The event of the bind button.
*/
private void processBindButton(BindButtonEvent event) {
- if (renderer.getWindowFocused() != null && renderer.getWindowFocused().isModal() && renderer.getWindowFocused().isVisible()) { //TODO change this
+ if (renderer.getWindowFocused() != null && renderer.getWindowFocused().isModal() && renderer.getWindowFocused().isVisible()) {
renderer.getWindowFocused().processBindButton(event);
}
}
View
54 src/main/java/org/terasology/logic/manager/PostProcessingRenderer.java
@@ -127,8 +127,9 @@ public static PostProcessingRenderer getInstance() {
public PostProcessingRenderer() {
_extensionsAvailable = GLContext.getCapabilities().GL_ARB_framebuffer_object;
- if (_extensionsAvailable)
+ if (_extensionsAvailable) {
initialize();
+ }
}
public void initialize() {
@@ -179,10 +180,12 @@ public FBO createFBO(String title, int width, int height, boolean hdr, boolean d
GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE);
GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE);
- if (hdr)
+ if (hdr) {
GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, ARBTextureFloat.GL_RGBA16F_ARB, width, height, 0, GL11.GL_RGBA, ARBHalfFloatPixel.GL_HALF_FLOAT_ARB, (java.nio.ByteBuffer) null);
- else
+ }
+ else {
GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, width, height, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, (java.nio.ByteBuffer) null);
+ }
if (depth) {
// Generate the depth texture
@@ -240,23 +243,28 @@ private void updateExposure() {
}
- if (_sceneLuminance > 0.0f) // No division by zero
+ if (_sceneLuminance > 0.0f) {// No division by zero
_exposure = (float) TeraMath.lerp(_exposure, TARGET_LUMINANCE / _sceneLuminance, ADJUSTMENT_SPEED);
+ }
float maxExposure = MAX_EXPOSURE;
- if (CoreRegistry.get(WorldRenderer.class).getSkysphere().getDaylight() == 0.0)
+ if (CoreRegistry.get(WorldRenderer.class).getSkysphere().getDaylight() == 0.0) {
maxExposure = MAX_EXPOSURE_NIGHT;
+ }
- if (_exposure > maxExposure)
+ if (_exposure > maxExposure) {
_exposure = maxExposure;
- if (_exposure < MIN_EXPOSURE)
+ }
+ if (_exposure < MIN_EXPOSURE) {
_exposure = MIN_EXPOSURE;
+ }
}
public void beginRenderScene() {
- if (!_extensionsAvailable)
+ if (!_extensionsAvailable) {
return;
+ }
getFBO("scene").bind();
@@ -264,8 +272,9 @@ public void beginRenderScene() {
}
public void beginRenderReflectedScene() {
- if (!_extensionsAvailable)
+ if (!_extensionsAvailable) {
return;
+ }
getFBO("sceneReflected").bind();
@@ -274,15 +283,17 @@ public void beginRenderReflectedScene() {
}
public void endRenderScene() {
- if (!_extensionsAvailable)
+ if (!_extensionsAvailable) {
return;
+ }
getFBO("scene").unbind();
}
public void endRenderReflectedScene() {
- if (!_extensionsAvailable)
+ if (!_extensionsAvailable) {
return;
+ }
getFBO("sceneReflected").unbind();
glViewport(0, 0, Display.getWidth(), Display.getHeight());
@@ -293,8 +304,9 @@ public void endRenderReflectedScene() {
* of the viewport changes.
*/
public void renderScene() {
- if (!_extensionsAvailable)
+ if (!_extensionsAvailable) {
return;
+ }
if (Config.getInstance().isEnablePostProcessingEffects()) {
generateDownsampledScene();
@@ -383,10 +395,12 @@ private void generateBlur(int id) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- if (id == 0)
+ if (id == 0) {
PostProcessingRenderer.getInstance().getFBO("sceneTonemapped").bindTexture();
- else
+ }
+ else {
PostProcessingRenderer.getInstance().getFBO("sceneBlur" + (id - 1)).bindTexture();
+ }
renderFullQuad();
@@ -406,10 +420,12 @@ private void generateBloom(int id) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- if (id == 0)
+ if (id == 0) {
PostProcessingRenderer.getInstance().getFBO("sceneHighPass").bindTexture();
- else
+ }
+ else {
PostProcessingRenderer.getInstance().getFBO("sceneBloom" + (id - 1)).bindTexture();
+ }
renderFullQuad();
@@ -433,10 +449,12 @@ private void generateDownsampledScene() {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- if (i == 4)
+ if (i == 4) {
PostProcessingRenderer.getInstance().getFBO("scene").bindTexture();
- else
+ }
+ else {
PostProcessingRenderer.getInstance().getFBO("scene" + sizePrev).bindTexture();
+ }
renderFullQuad();
View
6 src/main/java/org/terasology/model/BuffIcon.java
@@ -22,7 +22,7 @@
import javax.vecmath.Vector2f;
import org.terasology.asset.AssetManager;
-import org.terasology.rendering.gui.framework.UIGraphicsElement;
+import org.terasology.rendering.gui.widgets.UIImage;
/*
* @author bi0hax
@@ -30,12 +30,12 @@
*/
public class BuffIcon {
private static Map<String, BuffIcon> bufficons;
- private UIGraphicsElement _element;
+ private UIImage _element;
private int _x;
private int _y;
public BuffIcon() {
- _element = new UIGraphicsElement(AssetManager.loadTexture("engine:buffs"));
+ _element = new UIImage(AssetManager.loadTexture("engine:buffs"));
_element.setSize(new Vector2f(32, 32));
_element.getTextureSize().set(new Vector2f(0.0624f, 0.0624f));
_element.setVisible(true);
View
6 src/main/java/org/terasology/model/inventory/Icon.java
@@ -27,7 +27,7 @@
import org.lwjgl.opengl.GL11;
import org.terasology.asset.AssetManager;
import org.terasology.rendering.assets.Texture;
-import org.terasology.rendering.gui.framework.UIGraphicsElement;
+import org.terasology.rendering.gui.widgets.UIImage;
import org.terasology.world.block.Block;
import org.terasology.world.block.family.BlockFamily;
@@ -37,7 +37,7 @@
public class Icon {
private static Map<String, Icon> icons;
- private UIGraphicsElement _element;
+ private UIImage _element;
private BlockFamily _blockFamily;
private int _x;
private int _y;
@@ -59,7 +59,7 @@ public Icon(BlockFamily blockFamily) {
* Creates an Icon for a non-BlockFamily class
*/
public Icon() {
- _element = new UIGraphicsElement(AssetManager.loadTexture("engine:items"));
+ _element = new UIImage(AssetManager.loadTexture("engine:items"));
_blockFamily = null;
_element.setSize(new Vector2f(32, 32));
View
4 src/main/java/org/terasology/mods/miniions/componentsystem/controllers/MinionSystem.java
@@ -82,7 +82,7 @@ public void onToggleMinionMode(ToggleMinionModeButton event, EntityRef entity) {
MinionControllerComponent minionController = entity.getComponent(MinionControllerComponent.class);
minionController.minionMode = !minionController.minionMode;
if (!minionController.minionMode) {
- minionBehaviourMenu.setVisible(false);
+ minionBehaviourMenu.close();
}
entity.saveComponent(minionController);
event.consume();
@@ -146,7 +146,7 @@ public void onAttack(AttackButton event, EntityRef entity) {
//if(GUIManager.getInstance().getWindowById("container") != null){
// GUIManager.getInstance().setFocusedWindow("container");
//}
- minionBehaviourMenu.setVisible(false);
+ minionBehaviourMenu.close();
updateBehaviour(entity);
break;
}
View
12 src/main/java/org/terasology/mods/miniions/rendering/gui/components/UIMessageQueue.java
@@ -28,7 +28,7 @@
import org.terasology.mods.miniions.minionenum.MinionMessagePriority;
import org.terasology.mods.miniions.utilities.MinionMessage;
import org.terasology.rendering.gui.framework.UIDisplayContainer;
-import org.terasology.rendering.gui.framework.UIGraphicsElement;
+import org.terasology.rendering.gui.widgets.UIImage;
/**
* Created with IntelliJ IDEA.
@@ -42,12 +42,12 @@
private static final float ICON_SIZE = 32.0f;
private Queue<MinionMessage> messageQueue;
- private ArrayList<UIGraphicsElement> elements;
+ private ArrayList<UIImage> elements;
static int messageCounter = 0;
- private UIGraphicsElement _messageTex;
+ private UIImage _messageTex;
public UIMessageQueue() {
- elements = new ArrayList<UIGraphicsElement>();
+ elements = new ArrayList<UIImage>();
messageQueue = new PriorityQueue<MinionMessage>();
float height = Display.getHeight() / 2;
setSize(new Vector2f(ICON_SIZE, height));
@@ -74,8 +74,8 @@ public void addIconToQueue(MinionMessage minionmessage) {
}
}
- private UIGraphicsElement getMessageIcon(MinionMessagePriority minionMessagePriority, int counter) {
- UIGraphicsElement _messageTexture = new UIGraphicsElement(AssetManager.loadTexture("engine:items"));
+ private UIImage getMessageIcon(MinionMessagePriority minionMessagePriority, int counter) {
+ UIImage _messageTexture = new UIImage(AssetManager.loadTexture("engine:items"));
_messageTexture.getTextureSize().set(new Vector2f(16f / 256f, 16f / 256f));
float originStart = 0;
switch (minionMessagePriority) {
View
14 ...ain/java/org/terasology/mods/miniions/rendering/gui/components/UIMinionBehaviourMenu.java
@@ -25,8 +25,8 @@
import org.terasology.mods.miniions.components.MinionBarComponent;
import org.terasology.mods.miniions.components.MinionComponent;
import org.terasology.mods.miniions.components.MinionControllerComponent;
-import org.terasology.rendering.gui.framework.UIDisplayWindow;
-import org.terasology.rendering.gui.framework.UIGraphicsElement;
+import org.terasology.rendering.gui.widgets.UIImage;
+import org.terasology.rendering.gui.widgets.UIWindow;
/**
* Created with IntelliJ IDEA.
@@ -35,23 +35,23 @@
* Time: 20:25
* used as a dial menu without ungrabbing the mouse
*/
-public class UIMinionBehaviourMenu extends UIDisplayWindow {
+public class UIMinionBehaviourMenu extends UIWindow {
//private UIButton buttonMove;
- private final UIGraphicsElement background;
- private final UIGraphicsElement selectionrectangle;
+ private final UIImage background;
+ private final UIImage selectionrectangle;
public UIMinionBehaviourMenu() {
setSize(new Vector2f(60f, 180f));
- background = new UIGraphicsElement(AssetManager.loadTexture("engine:guiMinion"));
+ background = new UIImage(AssetManager.loadTexture("engine:guiMinion"));
background.getTextureSize().set(new Vector2f(60f / 256f, 180f / 256f));
background.getTextureOrigin().set(new Vector2f(30.0f / 256f, 20.0f / 256f));
background.setSize(getSize());
addDisplayElement(background);
background.setVisible(true);
- selectionrectangle = new UIGraphicsElement(AssetManager.loadTexture("engine:guiMinion"));
+ selectionrectangle = new UIImage(AssetManager.loadTexture("engine:guiMinion"));
selectionrectangle.getTextureSize().set(new Vector2f(60f / 256f, 20f / 256f));
selectionrectangle.getTextureOrigin().set(new Vector2f(30f / 256, 0.0f));
selectionrectangle.setSize(new Vector2f(60f, 20f));
View
31 src/main/java/org/terasology/mods/miniions/rendering/gui/components/UIMinionbar.java
@@ -24,7 +24,6 @@
import javax.vecmath.Vector2f;
-import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.GL11;
import org.terasology.asset.AssetManager;
import org.terasology.entitySystem.EntityRef;
@@ -34,10 +33,10 @@
import org.terasology.mods.miniions.components.MinionBarComponent;
import org.terasology.mods.miniions.components.MinionComponent;
import org.terasology.mods.miniions.components.MinionControllerComponent;
-import org.terasology.rendering.gui.components.UIText;
import org.terasology.rendering.gui.framework.UIDisplayContainer;
import org.terasology.rendering.gui.framework.UIDisplayElement;
-import org.terasology.rendering.gui.framework.UIGraphicsElement;
+import org.terasology.rendering.gui.widgets.UIImage;
+import org.terasology.rendering.gui.widgets.UIText;
/**
* A small toolbar placed at the right of the screen.
@@ -45,13 +44,13 @@
* @author Overdhose copied from toolbar
*/
public class UIMinionbar extends UIDisplayContainer {
- private final UIGraphicsElement backgroundTexture;
+ private final UIImage backgroundTexture;
private final UIMinionbarCell[] cells;
//private int prevSelected = 0;
private class UIMinionbarCell extends UIDisplayElement {
- private final UIGraphicsElement selectionRectangle;
+ private final UIImage selectionRectangle;
private final UIText label;
private int id;
@@ -62,9 +61,9 @@ public UIMinionbarCell(int id) {
setSize(new Vector2f(48f, 48f));
- selectionRectangle = new UIGraphicsElement(AssetManager.loadTexture("engine:gui"));
- selectionRectangle.getTextureSize().set(new Vector2f(24f / 256f, 24f / 256f));
- selectionRectangle.getTextureOrigin().set(new Vector2f(0.0f, 24f / 256f));
+ selectionRectangle = new UIImage(AssetManager.loadTexture("engine:gui"));
+ selectionRectangle.setTextureSize(new Vector2f(24f, 24f));
+ selectionRectangle.setTextureOrigin(new Vector2f(0.0f, 24f));
selectionRectangle.setSize(new Vector2f(48f, 48f));
label = new UIText();
@@ -156,11 +155,13 @@ public UIText getLabel() {
public UIMinionbar() {
setSize(new Vector2f(44f, 364f));
+ setHorizontalAlign(EHorizontalAlign.RIGHT);
+ setVerticalAlign(EVerticalAlign.CENTER);
- backgroundTexture = new UIGraphicsElement(AssetManager.loadTexture("engine:guiMinion"));
+ backgroundTexture = new UIImage(AssetManager.loadTexture("engine:guiMinion"));
backgroundTexture.setVisible(true);
- backgroundTexture.getTextureSize().set(new Vector2f(22f / 256f, 182f / 256f));
- backgroundTexture.getTextureOrigin().set(new Vector2f(0.0f, 0.0f));
+ backgroundTexture.setTextureSize(new Vector2f(22f, 182f));
+ backgroundTexture.setTextureOrigin(new Vector2f(0.0f, 0.0f));
backgroundTexture.setSize(getSize());
addDisplayElement(backgroundTexture);
@@ -183,14 +184,6 @@ public UIMinionbar() {
layout();
}
-
- @Override
- public void layout() {
- super.layout();
-
- centerVertically();
- getPosition().x = Display.getWidth() - getSize().x;
- }
/*
@Override
View
162 src/main/java/org/terasology/rendering/gui/components/UIButton.java
@@ -1,162 +0,0 @@
-/*
- * Copyright 2012 Benjamin Glatzel <benjamin.glatzel@me.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.terasology.rendering.gui.components;
-
-import javax.vecmath.Vector2f;
-
-import org.terasology.asset.AssetType;
-import org.terasology.asset.AssetUri;
-import org.terasology.logic.manager.AudioManager;
-import org.terasology.rendering.gui.framework.UIDisplayContainer;
-import org.terasology.rendering.gui.framework.UIDisplayElement;
-import org.terasology.rendering.gui.framework.events.ChangedListener;
-import org.terasology.rendering.gui.framework.events.MouseButtonListener;
-import org.terasology.rendering.gui.framework.events.MouseMoveListener;
-
-/**
- * A simple graphical button usable for creating user interface.
- *
- * @author Benjamin Glatzel <benjamin.glatzel@me.com>
- * @author Marcel Lehwald <marcel.lehwald@googlemail.com>
- */
-public class UIButton extends UIDisplayContainer {
-
- private final UIText _label;
-
- public enum eButtonType {NORMAL, TOGGLE};
- private boolean _toggleState = false;
- private eButtonType _buttonType;
-
- /**
- * Create a simple button, where 2 types are possible. The normal button and the toggle button.
- * @param size The size of the button.
- * @param buttonType The type of the button which can be normal or toggle.
- */
- public UIButton(Vector2f size, eButtonType buttonType) {
- setSize(size);
-
- _buttonType = buttonType;
-
- //TODO give user of the UIButton component more styling options. deliver these styles over the constructor?
- setClassStyle("button", "background-image: engine:gui_menu 256/512 30/512 0 0");
- setClassStyle("button-mouseover", "background-image: engine:gui_menu 256/512 30/512 0 30/512");
- setClassStyle("button-mouseclick", "background-image: engine:gui_menu 256/512 30/512 0 60/512");
- setClassStyle("button");
-
- addMouseMoveListener(new MouseMoveListener() {
- @Override
- public void leave(UIDisplayElement element) {
- if (_buttonType == eButtonType.TOGGLE) {
- if (_toggleState)
- setClassStyle("button-mouseclick");
- else
- setClassStyle("button");
- }
- else
- setClassStyle("button");
- }
-
- @Override
- public void hover(UIDisplayElement element) {
-
- }
-
- @Override
- public void enter(UIDisplayElement element) {
- AudioManager.play(new AssetUri(AssetType.SOUND, "engine:click"), 1.0f);
- if (_buttonType == eButtonType.NORMAL)
- setClassStyle("button-mouseover");
- }
-
- @Override
- public void move(UIDisplayElement element) {
-
- }
- });
-
- addMouseButtonListener(new MouseButtonListener() {
- @Override
- public void up(UIDisplayElement element, int button, boolean intersect) {
- if (_buttonType == eButtonType.NORMAL)
- setClassStyle("button");
- }
-
- @Override
- public void down(UIDisplayElement element, int button, boolean intersect) {
- if (intersect) {
- if (_buttonType == eButtonType.TOGGLE) {
- if (_toggleState) {
- setClassStyle("button");
- _toggleState = false;
- }
- else {
- setClassStyle("button-mouseclick");
- _toggleState = true;
- }
- }
- else
- setClassStyle("button-mouseclick");
- }
- }
-
- @Override
- public void wheel(UIDisplayElement element, int wheel, boolean intersect) {
-
- }
- });
-
- _label = new UIText("Untitled");
- _label.setVisible(true);
- _label.addChangedListener(new ChangedListener() {
- @Override
- public void changed(UIDisplayElement element) {
- layout();
- }
- });
-
- addDisplayElement(_label);
- }
-
- @Override
- public void layout() {
- super.layout();
-
- if (_label != null) {
- _label.setPosition(new Vector2f(getSize().x / 2 - getLabel().getTextWidth() / 2, getSize().y / 2 - getLabel().getTextHeight() / 2));
- }
- }
-
- public UIText getLabel() {
- return _label;
- }
-
- public boolean getToggleState() {
- return _toggleState;
- }
-
- /**
- * Set the state of the toggle button. Only has an affect if the button was created as an toggle button.
- * @param state True to set the pressed state.
- */
- public void setToggleState(boolean state) {
- _toggleState = state;
-
- if (_toggleState)
- setClassStyle("button-mouseclick");
- else
- setClassStyle("button");
- }
-}
View
191 src/main/java/org/terasology/rendering/gui/components/UIComboBox.java
@@ -1,191 +0,0 @@
-/*
- * Copyright 2012 Benjamin Glatzel <benjamin.glatzel@me.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.terasology.rendering.gui.components;
-
-import javax.vecmath.Vector2f;
-
-import org.lwjgl.input.Mouse;
-import org.lwjgl.opengl.Display;
-import org.terasology.asset.AssetType;
-import org.terasology.asset.AssetUri;
-import org.terasology.logic.manager.AudioManager;
-import org.terasology.rendering.gui.framework.UIDisplayContainer;
-import org.terasology.rendering.gui.framework.UIDisplayElement;
-import org.terasology.rendering.gui.framework.events.ChangedListener;
-import org.terasology.rendering.gui.framework.events.ClickListener;
-import org.terasology.rendering.gui.framework.events.MouseButtonListener;
-import org.terasology.rendering.gui.framework.events.MouseMoveListener;
-
-/**
- * A combo box.
- *
- */
-public class UIComboBox extends UIDisplayContainer {
- private UIInput _baseInput;
- private UIButton _baseButton;
- private UIList _baseList;
-
- private boolean _opened;
-
- /**
- * Creates a combo box with the given size.
- * @param size
- */
- public UIComboBox(Vector2f size){
- initBaseItems(size, new Vector2f(size.x - 2, size.x + size.x/2 - 2));
- }
-
- /**
- * Creates a combo box with the given size for the combo box size and the list size.
- * @param size The size of the combo box (without the list).
- * @param listSize The size of the list.
- */
- public UIComboBox(Vector2f size, Vector2f listSize){
- initBaseItems(size, listSize);
- }
-
- private void initBaseItems(Vector2f size, Vector2f listSize){
- setSize(size);
- _opened = false;
-
- addMouseButtonListener(new MouseButtonListener() {
- @Override
- public void wheel(UIDisplayElement element, int wheel, boolean intersect) {
-
- }
-
- @Override
- public void up(UIDisplayElement element, int button, boolean intersect) {
- if (intersect)
- _opened = !_opened;
- else if (!_baseList.intersects(new Vector2f(Mouse.getX(), Display.getHeight() - Mouse.getY())))
- _opened = false;
-
- _baseList.setVisible(_opened);
- _baseButton.setToggleState(_opened);
-
- if (!_opened) {
- _baseList.getScrollBarHorizontal().resetScrollPosition();
- _baseList.getScrollBarVertival().resetScrollPosition();
- }
- }
-
- @Override
- public void down(UIDisplayElement element, int button, boolean intersect) {
-
- }
- });
- addMouseMoveListener(new MouseMoveListener() {
- @Override
- public void leave(UIDisplayElement element) {
-
- }
-
- @Override
- public void hover(UIDisplayElement element) {
-
- }
-
- @Override
- public void enter(UIDisplayElement element) {
- AudioManager.play(new AssetUri(AssetType.SOUND, "engine:PlaceBlock"));
- }
-
- @Override
- public void move(UIDisplayElement element) {
-
- }
- });
-
- _baseInput = new UIInput(size);
- _baseInput.setVisible(true);
- _baseInput.setDisabled(true);
-
- _baseButton = new UIButton(new Vector2f(18f, 18f), UIButton.eButtonType.TOGGLE);
- _baseButton.setVisible(true);
- _baseButton.getPosition().x = size.x - _baseButton.getSize().x;
- _baseButton.getPosition().y = size.y/2 - _baseButton.getSize().y/2;
- _baseButton.getLabel().setText("");
- _baseButton.setClassStyle("button", "background-image: engine:gui_menu 18/512 18/512 432/512 0");
- _baseButton.setClassStyle("button-mouseover", "background-image: engine:gui_menu 18/512 18/512 432/512 0");
- _baseButton.setClassStyle("button-mouseclick", "background-image: engine:gui_menu 18/512 18/512 432/512 18/512");
-
- _baseList = new UIList(listSize);
- _baseList.getPosition().y = size.y + 2;
- _baseList.setVisible(false);
- _baseList.addClickListener(new ClickListener() {
- @Override
- public void click(UIDisplayElement element, int button) {
- _opened = !_opened;
- _baseList.setVisible(_opened);
- _baseButton.setToggleState(false);
- }
- });
- _baseList.addChangedListener(new ChangedListener() {
- @Override
- public void changed(UIDisplayElement element) {
- if (_baseList.getSelectedItem() != null)
- _baseInput.setValue(_baseList.getSelectedItem().getText());
- }
- });
-
- _baseList.setClassStyle("windowSkin", "border-image-top: engine:gui_menu 159/512 1/512 263/512 17/512 2");
- _baseList.setClassStyle("windowSkin", "border-image-right: engine:gui_menu 1/512 63/512 423/512 17/512 2");
- _baseList.setClassStyle("windowSkin", "border-image-bottom: engine:gui_menu 159/512 1/512 263/512 81/512 2");
- _baseList.setClassStyle("windowSkin", "border-image-left: engine:gui_menu 1/512 64/512 263/512 17/512 2");
-
- _baseList.setClassStyle("windowSkin", "border-corner-topleft: engine:gui_menu 263/512 0");
- _baseList.setClassStyle("windowSkin", "border-corner-topright: engine:gui_menu 423/512 0");
- _baseList.setClassStyle("windowSkin", "border-corner-bottomright: engine:gui_menu 423/512 81/512");
- _baseList.setClassStyle("windowSkin", "border-corner-bottomleft: engine:gui_menu 64/512 81/512");
- _baseList.setClassStyle("windowSkin", "background-image: engine:gui_menu 159/512 63/512 264/512 18/512");
- _baseList.setClassStyle("windowSkin");
-
- addDisplayElement(_baseInput);
- addDisplayElement(_baseButton);
- addDisplayElement(_baseList);
- }
-
- public void addItem(String text, Object value) {
- _baseList.addItem(text, value);
- }
-
- /**
- * Select an specific item in the list.
- * @param i The item to select.
- */
- public void setSelectedItemIndex(int i) {
- _baseList.setSelectedItemIndex(i);
- }
-
- /**
- * Get the selected item in the list.
- * @return Returns the selected item.
- */
- public int getSelectedItemIndex() {
- return _baseList.getSelectedItemIndex();
- }
-
- /**
- * Get the value of the selected item in the combo box list.
- * @return Returns the value of the selected item. If no data is attached to the list entry null will be returned.
- * @see UIList
- */
- public Object getValue() {
- return _baseList.getValue();
- }
-}
View
136 src/main/java/org/terasology/rendering/gui/components/UIDialogBox.java
@@ -1,136 +0,0 @@
-/*
- * Copyright 2012 Benjamin Glatzel <benjamin.glatzel@me.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.terasology.rendering.gui.components;
-
-import javax.vecmath.Vector2f;
-
-import org.lwjgl.input.Mouse;
-import org.lwjgl.opengl.Display;
-import org.terasology.rendering.gui.framework.UIDisplayElement;
-import org.terasology.rendering.gui.framework.UIDisplayWindow;
-import org.terasology.rendering.gui.framework.events.ClickListener;
-import org.terasology.rendering.gui.framework.events.MouseButtonListener;
-import org.terasology.rendering.gui.framework.events.MouseMoveListener;
-
-
-public class UIDialogBox extends UIDisplayWindow {
- private UIWindowTitle _title;
- private UIButton _close;
- private Vector2f _prevMousePos = null;
- private boolean _dragged = false;
-
- public UIDialogBox(String title, Vector2f size) {
- super();
- setSize(size);
-
- _title = new UIWindowTitle(new Vector2f(getSize().x * 0.55f, 19f), title);
- _title.setVisible(true);
- _title.getPosition().x = (getPosition().x + size.x / 2f) - _title.getSize().x / 2;
- _title.setTitle(title);
- _title.addMouseButtonListener(new MouseButtonListener() {
- @Override
- public void wheel(UIDisplayElement element, int wheel, boolean intersect) {
-
- }
-
- @Override
- public void up(UIDisplayElement element, int button, boolean intersect) {
- _dragged = false;
- _prevMousePos = null;
- }
-
- @Override
- public void down(UIDisplayElement element, int button, boolean intersect) {
- if (intersect) {
- _dragged = true;
- if (_prevMousePos == null) {
- _prevMousePos = new Vector2f(new Vector2f(Mouse.getX(), Display.getHeight() - Mouse.getY()));
- }
- }
- }
- });
- _title.addMouseMoveListener(new MouseMoveListener() {
- @Override
- public void move(UIDisplayElement element) {
- if (_dragged) {
- Vector2f mousePos = new Vector2f(Mouse.getX(), Display.getHeight() - Mouse.getY());
- drag(new Vector2f(_prevMousePos.x - mousePos.x, _prevMousePos.y - mousePos.y));
- _prevMousePos = new Vector2f(mousePos);
- }
- }
-
- @Override
- public void leave(UIDisplayElement element) {
-
- }
-
- @Override
- public void hover(UIDisplayElement element) {
-
- }
-
- @Override
- public void enter(UIDisplayElement element) {
-
- }
- });
-
- _close = new UIButton(new Vector2f(19f, 19f), UIButton.eButtonType.NORMAL);
- _close.getPosition().x = getSize().x - 25f;
- _close.setVisible(true);
- _close.getLabel().setText("");
-
- _close.addClickListener(new ClickListener() {
- @Override
- public void click(UIDisplayElement element, int button) {
- close(true);
- }
- });
-
- windowStyleSetup();
-
- addDisplayElement(_close);
- addDisplayElement(_title);
- }
-
- public void resize() {
- _title.setSize(new Vector2f(getSize().x * 0.55f, 19f));
- _title.getPosition().x = getSize().x / 2f - _title.getSize().x / 2;
- _title.resize();
- _style = null;
- _close.getPosition().x = getSize().x - 25f;
- windowStyleSetup();
- }
-
- public void windowStyleSetup() {
- setStyle("border-image-top", "engine:gui_menu 168/512 5/512 260/512 89/512 5");
- setStyle("border-image-right", "engine:gui_menu 4/512 81/512 428/512 94/512 4");
- setStyle("border-image-bottom", "engine:gui_menu 168/512 4/512 260/512 175/512 4");
- setStyle("border-image-left", "engine:gui_menu 4/512 81/512 256/512 94/512 4");
-
- setStyle("border-corner-topleft", "engine:gui_menu 256/512 89/512");
- setStyle("border-corner-topright", "engine:gui_menu 428/512 89/512");
- setStyle("border-corner-bottomright", "engine:gui_menu 428/512 175/512");
- setStyle("border-corner-bottomleft", "engine:gui_menu 256/512 175/512");
-
- setStyle("background-image", "engine:gui_menu 168/512 76/512 260/512 94/512");
-
- _close.setClassStyle("button", "background-image: engine:gui_menu 19/512 19/512 73/512 155/512");
- _close.setClassStyle("button-mouseover", "background-image: engine:gui_menu 19/512 19/512 54/512 155/512");
- _close.setClassStyle("button-mouseclick", "background-image: engine:gui_menu 19/512 19/512 92/512 155/512");
- }
-
-}
View
116 src/main/java/org/terasology/rendering/gui/components/UIHealthBar.java
@@ -1,116 +0,0 @@
-/*
- * Copyright 2012 Benjamin Glatzel <benjamin.glatzel@me.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.terasology.rendering.gui.components;
-
-import javax.vecmath.Vector2f;
-
-import org.terasology.asset.AssetManager;
-import org.terasology.components.CuredComponent;
-import org.terasology.components.HealthComponent;
-import org.terasology.components.LocalPlayerComponent;
-import org.terasology.components.PoisonedComponent;
-import org.terasology.entitySystem.EntityManager;
-import org.terasology.entitySystem.EntityRef;
-import org.terasology.entitySystem.EventHandlerSystem;
-import org.terasology.entitySystem.EventSystem;
-import org.terasology.entitySystem.ReceiveEvent;
-import org.terasology.events.HealthChangedEvent;
-import org.terasology.game.CoreRegistry;
-import org.terasology.logic.LocalPlayer;
-import org.terasology.rendering.gui.framework.UIDisplayContainer;
-import org.terasology.rendering.gui.framework.UIGraphicsElement;
-
-/**
- * Small health bar that visualizes the current amount of health points of the player
- * with ten small heart icons.
- *
- * @author Benjamin Glatzel <benjamin.glatzel@me.com>
- */
-public class UIHealthBar extends UIDisplayContainer implements EventHandlerSystem {
- private final UIGraphicsElement[] _hearts;
- protected EntityManager entityManager;
-
- public UIHealthBar() {
- setSize(new Vector2f(180f, 18f));
-
- _hearts = new UIGraphicsElement[10];
-
- // Create hearts
- for (int i = 0; i < 10; i++) {
- _hearts[i] = new UIGraphicsElement(AssetManager.loadTexture("engine:icons"));
- _hearts[i].setVisible(true);
- _hearts[i].getTextureSize().set(new Vector2f(9f / 256f, 9f / 256f));
- _hearts[i].getTextureOrigin().set(new Vector2f(52f / 256f, 0.0f)); //106f for poison
- _hearts[i].setSize(new Vector2f(18f, 18f));
- _hearts[i].setPosition(new Vector2f(18f * i, 18f));
-
- addDisplayElement(_hearts[i]);
- }
-
- CoreRegistry.get(EventSystem.class).registerEventHandler(this);
- }
-
- private void updateHealthBar(int currentHealth, int maxHealth) {
- float healthRatio = (float) currentHealth / maxHealth;
-
- // Show/Hide hearts relatively to the available health points of the player
- for (int i = 0; i < 10; i++) {
-
- if (i < healthRatio * 10f)
- _hearts[i].setVisible(true);
- else
- _hearts[i].setVisible(false);
-
- //Show Poisoned Status with Green Hearts:
- PoisonedComponent poisoned = CoreRegistry.get(LocalPlayer.class).getEntity().getComponent(PoisonedComponent.class);
- entityManager = CoreRegistry.get(EntityManager.class);
- for (EntityRef entity : entityManager.iteratorEntities(PoisonedComponent.class)) {
- if (poisoned.poisonDuration >= 1)
- _hearts[i].getTextureOrigin().set(new Vector2f(106f / 256f, 0.0f));
- else
- _hearts[i].getTextureOrigin().set(new Vector2f(52f / 256f, 0.0f));
- }
-
- for (EntityRef entity : entityManager.iteratorEntities(CuredComponent.class)) {
- //For fixing the Green > Red hearts when cured:
- CuredComponent cured = CoreRegistry.get(LocalPlayer.class).getEntity().getComponent(CuredComponent.class);
- entityManager = CoreRegistry.get(EntityManager.class);
- if (cured.cureDuration >= 1)
- _hearts[i].getTextureOrigin().set(new Vector2f(52f / 256f, 0.0f));
- else
- _hearts[i].getTextureOrigin().set(new Vector2f(52f / 256f, 0.0f));
- }
- }
- }
-
- @Override
- public void initialise() {
- entityManager = CoreRegistry.get(EntityManager.class);
- }
-
- @Override
- public void shutdown() {
-
- }
-
- @ReceiveEvent(components = {LocalPlayerComponent.class, HealthComponent.class})
- public void onHealthChange(HealthChangedEvent event, EntityRef entityref) {
- updateHealthBar(event.getCurrentHealth(), event.getMaxHealth());
- }
-}
-
-/*Blue Hearts:
-_hearts[i].getTextureOrigin().set(new Vector2f(70f / 256f, 0.0f)); */
View
42 src/main/java/org/terasology/rendering/gui/components/UIImageOverlay.java
@@ -1,42 +0,0 @@
-/*
- * Copyright 2012 Benjamin Glatzel <benjamin.glatzel@me.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.terasology.rendering.gui.components;
-
-import javax.vecmath.Vector2f;
-
-import org.lwjgl.opengl.Display;
-import org.terasology.rendering.assets.Texture;
-import org.terasology.rendering.gui.framework.UIGraphicsElement;
-
-/**
- * Transparent fullscreen overlay.
- *
- * @author Benjamin Glatzel <benjamin.glatzel@me.com>
- */
-public class UIImageOverlay extends UIGraphicsElement {
-
- public UIImageOverlay(Texture texture) {
- super(texture);
- layout();
- }
-
- @Override
- public void layout() {
- super.layout();
-
- setSize(new Vector2f((float) Display.getWidth(), (float) Display.getHeight()));
- }
-}
View
338 src/main/java/org/terasology/rendering/gui/components/UIList.java
@@ -1,338 +0,0 @@
-/*
- * Copyright 2012 Benjamin Glatzel <benjamin.glatzel@me.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.terasology.rendering.gui.components;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.vecmath.Vector2f;
-import javax.vecmath.Vector4f;
-
-import org.lwjgl.input.Mouse;
-import org.lwjgl.opengl.Display;
-import org.newdawn.slick.Color;
-import org.terasology.rendering.gui.framework.IInputDataElement;
-import org.terasology.rendering.gui.framework.UIDisplayContainer;
-import org.terasology.rendering.gui.framework.UIDisplayElement;
-import org.terasology.rendering.gui.framework.UIScrollableDisplayContainer;
-import org.terasology.rendering.gui.framework.events.ChangedListener;
-import org.terasology.rendering.gui.framework.events.ClickListener;
-import org.terasology.rendering.gui.framework.events.MouseMoveListener;
-
-/**
- * A simple graphical List
- *
- * @author Anton Kireev <adeon.k87@gmail.com>
- * @version 0.2
- */
-
-public class UIList extends UIScrollableDisplayContainer implements IInputDataElement {
-
- private UIListItem _selectedItem = null;
- private final ArrayList<ClickListener> _doubleClickListeners = new ArrayList<ClickListener>();
-
- //List items
- private final List<UIListItem> _items = new ArrayList<UIListItem>();
- private final List<ChangedListener> _changedListeners = new ArrayList<ChangedListener>();
-
- public class UIListItem extends UIDisplayContainer {
- private Object _value;
- private String _text;
- private boolean _isSelected;
- private Vector2f _padding = new Vector2f(5f, 15f);
-
- private final UIText _label;
-
- public UIListItem(Vector2f size, String text, Object value) {
- setSize(size);
- _text = text;
- _value = value;
-
- _label = new UIText();
- _label.setVisible(true);
- _label.setColor(Color.lightGray);
- _label.setPosition(new Vector2f((getPosition().x + _padding.x), (getPosition().y + _padding.y)));
- _label.setText(_text);
-
- if (getSize().x < _label.getTextWidth()) {
- setSize(new Vector2f(_label.getTextWidth(), getSize().y));
- }
-
- addMouseMoveListener(new MouseMoveListener() {
- @Override
- public void leave(UIDisplayElement element) {
- if(!_isSelected)
- _label.setColor(Color.lightGray);
- }
-
- @Override
- public void hover(UIDisplayElement element) {
-
- }
-
- @Override
- public void enter(UIDisplayElement element) {
- if(!_isSelected)
- _label.setColor(Color.orange);
- }
-
- @Override
- public void move(UIDisplayElement element) {
-
- }
- });
-
- addDisplayElement(_label);
-
- }
-
- public Object getValue() {
- return _value;
- }
-
- public void setValue(Object value) {
- _value = value;
- }
-
- public String getText() {
- return _text;
- }
-
- public void setText(String text) {
- _label.setText(_text);
- _text = text;
- }
-
- public boolean isSelected() {
- return _isSelected;
- }
-
- public void setSelected(boolean selected) {
- _isSelected = selected;
-
- if (_isSelected) {
- setStyle("background-color", "#e1ddd4 1");
- _label.setColor(Color.orange);
- } else {
- setStyle("background", "none");
- _label.setColor(Color.lightGray);
- }
- }
- }
-
- public UIList(Vector2f size) {
- setSize(size);
- setCrop(true);
- setScrollBarsPosition(getPosition(), getSize());
-
- //ToDo Create skin for UIList
- setClassStyle("screenSkin", "border-image-top: engine:gui_menu 159/512 18/512 264/512 0 18");
- setClassStyle("screenSkin", "border-image-right: engine:gui_menu 9/512 63/512 423/512 18/512 9");
- setClassStyle("screenSkin", "border-image-bottom: engine:gui_menu 159/512 9/512 264/512 81/512 9");
- setClassStyle("screenSkin", "border-image-left: engine:gui_menu 8/512 64/512 256/512 17/512 8");
-
- setClassStyle("screenSkin", "border-corner-topleft: engine:gui_menu 256/512 0");
- setClassStyle("screenSkin", "border-corner-topright: engine:gui_menu 423/512 0");
- setClassStyle("screenSkin", "border-corner-bottomright: engine:gui_menu 423/512 81/512");
- setClassStyle("screenSkin", "border-corner-bottomleft: engine:gui_menu 256/512 81/512");
- setClassStyle("screenSkin", "background-image: engine:gui_menu 159/512 63/512 264/512 18/512");
-
- setClassStyle("screenSkin");
-
- setCropMargin(new Vector4f(-15f, -15f, -15f, 0));
- }
-
- /*
- * Returns count of elements
- */
- public int size() {
- return _items.size();
- }
-
- public void addItem(String text, Object value) {
-
- final UIListItem newItem = new UIListItem(new Vector2f(getSize().x, (32f)), text, value);
-
- newItem.setVisible(true);
-
- if (_items.size() > 0) {
- newItem.setPosition(_items.get(0).getPosition());
- }
-
- newItem.getPosition().y += 32f * _items.size();
- newItem.setFixed(false);
- newItem.addClickListener(new ClickListener() {
- private long _lastTime = System.currentTimeMillis();
- private int _lastButton = -1;
-
- @Override
- public void click(UIDisplayElement element, int button) {
- Vector2f mousePos = new Vector2f(Mouse.getX(), Display.getHeight() - Mouse.getY());
- if (!getScrollBarHorizontal().intersects(mousePos) && !getScrollBarVertival().intersects(mousePos)) {
- //handle double click
- if ((System.currentTimeMillis() - _lastTime) < 200 && _lastButton == button) {
- notifyDoubleClickListeners();
- }
- _lastTime = System.currentTimeMillis();
- _lastButton = button;
-
- //select the clicked item
- UIListItem item = (UIListItem) element;
-
- if (item != _selectedItem) {
- if (_selectedItem != null)
- _selectedItem.setSelected(false);
-
- _selectedItem = item;
- _selectedItem.setSelected(true);
-
- notifyChangedListeners();
- }
- }
- }
- });
-
- _items.add(newItem);
- addDisplayElement(newItem);
- }
-
- /*
- * Remove selected item
- */
- public void removeSelectedItem() {
-
- if (_selectedItem == null) {
- return;
- }
-
- int index = getSelectedItemIndex();
- removeDisplayElement(_selectedItem);
- _items.remove(_selectedItem);
-
- for (int i = index; i < _items.size(); i++) {
- _items.get(i).getPosition().y -= 32f;
- }
-
- if (_items.size() > 0) {
- if (index <= _items.size() - 1)
- setSelectedItemIndex(index);
- else
- setSelectedItemIndex(_items.size() - 1);
-
- }
- else {
- _selectedItem = null;
- }
- }
-
- public void setSelectedItemIndex(int i) {
- if (_selectedItem != null)
- _selectedItem.setSelected(false);
-
- _selectedItem = _items.get(i);
- _selectedItem.setSelected(true);
-
- notifyChangedListeners();
- }
-
- public UIListItem getSelectedItem() {
- return _selectedItem;
- }
-
- public int getSelectedItemIndex() {
- for (int i = 0; i < _items.size(); i++) {
- if (_items.get(i) == _selectedItem)
- return i;
- }
-
- return -1;
- }
-
- /*
- * Remove all items
- */
- public void removeAll() {
- clearData();
- for (int i = (_items.size() - 1); i >= 0; i--) {
- removeDisplayElement(_items.get(i));
- _items.remove(i);
- }
- }
-
- /*
- * Remove item by index
- */
- public void removeItem(int index) {
- removeDisplayElement(_items.get(index));
- _items.remove(index);
- }
-
- /*
- * Returns the value of the selected item
- */
- public Object getValue() {
- return _selectedItem.getValue();
- }
-
- public UIListItem getItem(int index){
- if(!_items.isEmpty()){
- return _items.get(index);
- } else {
- return null;
- }
- }
-
- public boolean isEmpty(){
- return _items.isEmpty();
- }
-
- /*
- * Reset to selected element
- */
- public void clearData() {
- if (_selectedItem != null)
- _selectedItem.setSelected(false);
- _selectedItem = null;
- }
-
- private void notifyDoubleClickListeners() {
- for (int i = 0; i < _doubleClickListeners.size(); i++) {
- _doubleClickListeners.get(i).click(this, 0);
- }
- }
-
- public void addDoubleClickListener(ClickListener listener) {
- _doubleClickListeners.add(listener);
- }
-
- public void removeDoubleClickListener(ClickListener listener) {
- _doubleClickListeners.remove(listener);
- }
-
- private void notifyChangedListeners() {
- for (ChangedListener listener : _changedListeners) {
- listener.changed(this);
- }
- }
-
- public void addChangedListener(ChangedListener listener) {
- _changedListeners.add(listener);
- }
-
- public void removeChangedListener(ChangedListener listener) {
- _changedListeners.remove(listener);
- }
-}
View
76 src/main/java/org/terasology/rendering/gui/components/UIMessageBox.java
@@ -1,76 +0,0 @@
-/*
- * Copyright 2012 Benjamin Glatzel <benjamin.glatzel@me.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.terasology.rendering.gui.components;
-
-import javax.vecmath.Vector2f;
-
-import org.newdawn.slick.Color;
-import org.terasology.logic.manager.GUIManager;
-import org.terasology.rendering.gui.framework.UIDisplayElement;
-import org.terasology.rendering.gui.framework.events.ClickListener;
-
-public class UIMessageBox extends UIDialogBox {
- private UIText _text;
- private UIButton _buttonOk;
-
- private Vector2f _minSize = new Vector2f(384f, 128f);
-
- public UIMessageBox(String title, String text) {
- super(title, new Vector2f());
- setModal(true);
-
- float width = 0f;
- float heigh = 0f;
-
- _buttonOk = new UIButton(new Vector2f(128f, 32f), UIButton.eButtonType.NORMAL);
- _buttonOk.getLabel().setText("Ok");
- _buttonOk.setVisible(true);
-
- _text = new UIText(text);
- _text.setVisible(true);
- _text.setColor(Color.black);
-
- width = _text.getTextWidth() + 15f > _minSize.x ? _text.getTextWidth() + 15f : _minSize.x;
- heigh = _text.getTextHeight() + 75f > _minSize.y ? _text.getTextHeight() + 75f : _minSize.y;
- setSize(new Vector2f(width, heigh));
-
- _text.setPosition(new Vector2f(getSize().x / 2 - _text.getTextWidth() / 2, getSize().y / 2 - _text.getTextHeight() / 2));
- _buttonOk.setPosition(new Vector2f(getSize().x / 2 - _buttonOk.getSize().x / 2, getSize().y - _buttonOk.getSize().y - 10f));
-
- _buttonOk.addClickListener(new ClickListener() {
- @Override
- public void click(UIDisplayElement element, int button) {
- close(true);
- }
- });
-
- resize();
- windowStyleSetup();
-
- addDisplayElement(_text);
- addDisplayElement(_buttonOk, "buttonOk");
- }
-
- @Override
- /**
- * Close a window. This will remove the window from the GUIManager.
- */
- public void close(boolean clearInputControls) {
- super.close(clearInputControls);
-
- GUIManager.getInstance().removeWindow(this);
- }
-}
View
40 src/main/java/org/terasology/rendering/gui/components/UIOpenBook.java
@@ -1,40 +0,0 @@
-/*
- * Copyright 2012 Benjamin Glatzel <benjamin.glatzel@me.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.terasology.rendering.gui.components;
-
-import javax.vecmath.Vector2f;
-
-import org.terasology.asset.AssetManager;
-import org.terasology.rendering.gui.framework.UIDisplayContainer;
-import org.terasology.rendering.gui.framework.UIGraphicsElement;
-
-/**
- * TODO Get rid of this class. the gui components should be reduced to a minimum. move to hui.menus?
- */
-public class UIOpenBook extends UIDisplayContainer {
-
- private final UIGraphicsElement background;
-
- public UIOpenBook() {
- background = new UIGraphicsElement(AssetManager.loadTexture("engine:openbook"));
- background.setPosition(new Vector2f(-250, -200));
- background.setSize(new Vector2f(500, 300));
- addDisplayElement(background);
- background.setVisible(true);
- update();
- }
-}
-
View
95 src/main/java/org/terasology/rendering/gui/components/UIProgressBar.java
@@ -1,95 +0,0 @@
-/*
- * Copyright 2012 Benjamin Glatzel <benjamin.glatzel@me.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.terasology.rendering.gui.components;
-
-import javax.vecmath.Vector2f;
-import javax.vecmath.Vector4f;
-
-import org.newdawn.slick.Color;
-import org.terasology.rendering.gui.framework.UIDisplayContainer;
-
-/**
- * A simple graphical progressBar
- *
- * @author Anton Kireev <adeon.k87@gmail.com>
- * @version 0.23
- */
-public class UIProgressBar extends UIDisplayContainer {
-
- private UIText _label;
- private int _value;
- private UIProgressLine _progressLine;
-
- public UIProgressBar(Vector2f size) {
-
- _value = 50;
- setSize(size);
- setCrop(true);
- setStyle("background-image", "engine:gui_menu 256/512 15/512 0 175/512");
- setCropMargin(new Vector4f(0f, -(getSize().x - getSize().x * (_value / 100f)), 0f, 0f));