fixed formatting stuff and added back missing code
parent
1cb8fc3f8c
commit
675526c874
|
@ -0,0 +1,66 @@
|
||||||
|
package com.github.hydos.ginger.engine.api;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
import com.github.hydos.ginger.engine.api.game.Game;
|
||||||
|
import com.github.hydos.ginger.engine.elements.buttons.TextureButton;
|
||||||
|
import com.github.hydos.ginger.engine.font.GUIText;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used if a game wants to access engine variables safely
|
||||||
|
*/
|
||||||
|
public class GingerRegister {
|
||||||
|
|
||||||
|
private static GingerRegister INSTANCE;
|
||||||
|
|
||||||
|
public List<GUIText> texts;
|
||||||
|
public List<TextureButton> guiButtons;
|
||||||
|
|
||||||
|
public Game game;
|
||||||
|
|
||||||
|
public GingerRegister() {
|
||||||
|
INSTANCE = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void registerText(GUIText guiText) {
|
||||||
|
if(texts == null) texts = new ArrayList<GUIText>();
|
||||||
|
texts.add(guiText);
|
||||||
|
}
|
||||||
|
|
||||||
|
public GUIText retrieveText(String string) {
|
||||||
|
GUIText lastText = null;
|
||||||
|
for(GUIText text: texts) {
|
||||||
|
lastText = text;
|
||||||
|
if(string.equalsIgnoreCase(string)) {
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeText(GUIText text) {
|
||||||
|
texts.remove(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void registerButton(TextureButton button) {
|
||||||
|
if(guiButtons == null) guiButtons = new ArrayList<TextureButton>();
|
||||||
|
guiButtons.add(button);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TextureButton retrieveButton(String string) {
|
||||||
|
for(TextureButton button: guiButtons) {
|
||||||
|
if(button.resourceLocation == string) {
|
||||||
|
return button;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static GingerRegister getInstance() {
|
||||||
|
return INSTANCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void registerGame(Game game) {this.game = game;}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -19,7 +19,10 @@ public class TextureButton{
|
||||||
|
|
||||||
private boolean isHovering = false;
|
private boolean isHovering = false;
|
||||||
|
|
||||||
|
public String resourceLocation;
|
||||||
|
|
||||||
public TextureButton(String texture, Vector2f position, Vector2f scale) {
|
public TextureButton(String texture, Vector2f position, Vector2f scale) {
|
||||||
|
resourceLocation = texture;
|
||||||
guiTexture = new GuiTexture(Loader.loadTextureDirectly(texture), position, scale);
|
guiTexture = new GuiTexture(Loader.loadTextureDirectly(texture), position, scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue