Permalink
Browse files

Still fighting with the UIOpenBook (openbook.png)

  • Loading branch information...
1 parent 8aab0b3 commit cb349c486544415ce8647840495d8fa0585893be @unknown0perator unknown0perator committed May 6, 2012
View
0 gradlew 100644 → 100755
File mode changed.
View
3 mods/core/prefabs/book.prefab
@@ -10,5 +10,6 @@
"type" : "WContents",
"page1" : "Hello",
"page2" : "World!"
- }
+ },
+ "ReadBookAction" : {}
}
View
15 src/main/java/org/terasology/componentSystem/action/ReadBookAction.java
@@ -5,25 +5,28 @@
import org.terasology.entitySystem.EventHandlerSystem;
import org.terasology.entitySystem.ReceiveEvent;
import org.terasology.events.ActivateEvent;
+import org.terasology.events.item.UseItemEvent;
import org.terasology.logic.manager.GUIManager;
import org.terasology.rendering.gui.components.UIOpenBook;
+import org.terasology.rendering.gui.framework.UIDisplayWindow;
import org.terasology.rendering.gui.menus.UIOpenBookScreen;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
/**
* Reading the Book calls the UI + Contents.
* @author bi0hax
*
*/
public class ReadBookAction implements EventHandlerSystem {
-
+ private Logger logger = Logger.getLogger(getClass().getName());
public void initialise() {
}
- private EntityRef book;
+ public EntityRef book;
@ReceiveEvent(components = {BookComponent.class})
- public void onActivate(ActivateEvent event, EntityRef entity) {
+ public void onActivate(ActivateEvent event, EntityRef book) {
GUIManager.getInstance().addWindow(new UIOpenBookScreen(), "openbook");
- //Content recalling not yet implemented:
- //BookComponent book = entity.getComponent(BookComponent.class);
-
+ logger.log(Level.WARNING, "ReadBookAction : This is being called and still doesn't work in game...");
}
}
View
3 src/main/java/org/terasology/game/modes/StateSinglePlayer.java
@@ -105,7 +105,6 @@
private UILoadingScreen _loadingScreen;
private UIStatusScreen _statusScreen;
private UIInventoryScreen _inventoryScreen;
- private UIOpenBookScreen _openbook;
/* RENDERING */
private WorldRenderer _worldRenderer;
@@ -212,7 +211,6 @@ public void init(GameEngine engine) {
_loadingScreen = new UILoadingScreen();
_statusScreen = new UIStatusScreen();
_inventoryScreen = new UIInventoryScreen();
- _openbook = new UIOpenBookScreen();
_metrics = new UIMetrics();
_metrics.setVisible(true);
@@ -222,7 +220,6 @@ public void init(GameEngine engine) {
_guiScreens.add(_pauseMenu);
_guiScreens.add(_loadingScreen);
_guiScreens.add(_inventoryScreen);
- _guiScreens.add(_openbook);
_guiScreens.add(_statusScreen);
}
View
27 src/main/java/org/terasology/rendering/gui/components/UIOpenBook.java
@@ -1,24 +1,33 @@
package org.terasology.rendering.gui.components;
+import org.terasology.entitySystem.EntityRef;
import org.terasology.rendering.gui.framework.UIDisplayContainer;
-import org.terasology.rendering.gui.framework.UIDisplayWindow; //Container or Window... hmmm??
+import org.terasology.rendering.gui.framework.UIDisplayWindow;
import org.terasology.rendering.gui.framework.UIGraphicsElement;
+
import javax.vecmath.Vector2f;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+/**
+ *
+ */
public class UIOpenBook extends UIDisplayContainer {
- private final UIGraphicsElement _background;
+ private Logger logger = Logger.getLogger(getClass().getName());
+
+ private final UIGraphicsElement background;
public UIOpenBook() {
- setSize(new Vector2f(256.0f * 2.5f, 256.0f * 2.5f));
+ background = new UIGraphicsElement("containerWindow");
+ background.getTextureSize().set(new Vector2f(256f / 256f, 231f / 256f));
+ background.getTextureOrigin().set(new Vector2f(0.0f, 0.0f));
+ addDisplayElement(background);
- _background = new UIGraphicsElement("openbook");
- _background.setSize(getSize());
- _background.getTextureSize().set(new Vector2f(256.0f / 256.0f, 256.0f / 256.0f));
- _background.getTextureOrigin().set(new Vector2f(0.0f, 0.0f));
- _background.setVisible(true);
+ background.setVisible(true);
- addDisplayElement(_background);
+ logger.log(Level.WARNING, "The Action calls the UIOpenBook");
+ update();
}
}
View
25 src/main/java/org/terasology/rendering/gui/menus/UIOpenBookScreen.java
@@ -1,26 +1,29 @@
package org.terasology.rendering.gui.menus;
-import org.terasology.entitySystem.EntityRef; //for Contents in a future?
import org.terasology.rendering.gui.components.UIOpenBook;
-import org.terasology.rendering.gui.framework.UIDisplayRenderer; //Not sure if it should be a Renderer instead of Window
+import org.terasology.rendering.gui.framework.UIDisplayRenderer;
import org.terasology.rendering.gui.framework.UIDisplayWindow;
-public class UIOpenBookScreen extends UIDisplayWindow{
+import java.util.logging.Level;
+import java.util.logging.Logger;
- private final UIOpenBook _openBook;
+public class UIOpenBookScreen extends UIDisplayWindow {
+ private Logger logger = Logger.getLogger(getClass().getName());
- public UIOpenBookScreen() {
+ private final UIOpenBook _openbook;
- _openBook = new UIOpenBook();
- _openBook.setVisible(true);
- addDisplayElement(_openBook);
+ public UIOpenBookScreen() {
+ maximaze();
+ _openbook = new UIOpenBook();
+ _openbook.setVisible(true);
+ addDisplayElement(_openbook);
+ logger.log(Level.WARNING, "It even calls UIOpenBookScreen");
update();
}
@Override
public void update() {
super.update();
- _openBook.center();
- _openBook.setVisible(true);
+ _openbook.center();
}
-}
+}

0 comments on commit cb349c4

Please sign in to comment.