use of gregtech.api.terminal.app.AbstractApplication in project GregTech by GregTechCEu.
the class TerminalARRenderer method onClientTick.
public static void onClientTick(TickEvent.ClientTickEvent event) {
if (event.phase == TickEvent.Phase.END) {
EntityPlayer player = Minecraft.getMinecraft().player;
if (player == null) {
if (APP != null) {
APP.onARClosed();
APP = null;
}
return;
}
HELD_HAND = EnumHand.MAIN_HAND;
NBTTagCompound tag = player.getHeldItem(EnumHand.MAIN_HAND).getSubCompound("terminal");
if (tag == null) {
tag = player.getHeldItem(EnumHand.OFF_HAND).getSubCompound("terminal");
HELD_HAND = EnumHand.OFF_HAND;
}
if (tag != null && tag.hasKey("_ar")) {
AbstractApplication app = TerminalRegistry.getApplication(tag.getString("_ar"));
if (app instanceof ARApplication) {
if (APP != app) {
if (APP != null) {
APP.onARClosed();
}
APP = (ARApplication) app;
APP.setAROpened(player.getHeldItem(HELD_HAND));
APP.onAROpened();
}
APP.tickAR(player);
return;
}
}
if (APP != null) {
APP.onARClosed();
APP = null;
}
}
}
use of gregtech.api.terminal.app.AbstractApplication in project GregTech by GregTechCEu.
the class VirtualTankApp method initApp.
@Override
public AbstractApplication initApp() {
this.addWidget(new ImageWidget(5, 5, 333 - 10, 232 - 10, TerminalTheme.COLOR_B_2));
this.addWidget(new LabelWidget(10, 10, "terminal.vtank_viewer.title", -1));
this.addWidget(new RectButtonWidget(216, 7, 110, 18).setClickListener(cd -> {
if (cd.isClient) {
reloadWidgets(cacheClient);
}
}).setIcon(new TextTexture("terminal.vtank_viewer.refresh", -1)).setFill(TerminalTheme.COLOR_B_2.getColor()));
widgetGroup = new DraggableScrollableWidgetGroup(10, 30, 313, 195).setDraggable(true).setYScrollBarWidth(3).setYBarStyle(null, TerminalTheme.COLOR_F_1);
if (isClient) {
cacheClient = new HashMap<>();
} else {
cacheServer = new HashMap<>();
}
this.addWidget(widgetGroup);
if (!isRemote()) {
refresh();
}
return this;
}
use of gregtech.api.terminal.app.AbstractApplication in project GregTech by GregTechCEu.
the class AppStoreApp method initApp.
@Override
public AbstractApplication initApp() {
DraggableScrollableWidgetGroup group = new DraggableScrollableWidgetGroup(0, 0, 333, 232);
this.addWidget(group);
int index = 0;
int yOffset = 50;
group.addWidget(new ImageWidget(0, 0, 333, 30, GuiTextures.UI_FRAME_SIDE_UP));
group.addWidget(new LabelWidget(333 / 2, 10, getUnlocalizedName(), -1).setShadow(true).setYCentered(true).setXCentered(true));
for (AbstractApplication app : TerminalRegistry.getAllApps()) {
group.addWidget(new AppCardWidget(5 + 110 * (index % 3), yOffset + 110 * (index / 3), app, this));
index++;
}
int y = yOffset + 110 * ((index + 2) / 3);
group.addWidget(new ImageWidget(0, y, 333, 30, new ColorRectTexture(TerminalTheme.COLOR_B_2.getColor())));
group.addWidget(new ImageWidget(0, y, 333, 30, new TextTexture("Copyright @2021-xxxx Gregicality Team XD", -1)));
loadLocalConfig(nbt -> this.darkMode = nbt.getBoolean("dark"));
return this;
}
use of gregtech.api.terminal.app.AbstractApplication in project GregTech by GregTechCEu.
the class MazeApp method initApp.
public AbstractApplication initApp() {
if (isClient) {
movementStore = new ArrayList<>();
FSM = new List[4];
FSM[0] = new LinkedList<>();
FSM[1] = new LinkedList<>();
FSM[2] = new LinkedList<>();
FSM[3] = new LinkedList<>();
this.setOs(os);
this.addWidget(new ImageWidget(5, 5, 333 - 10, 232 - 10, TerminalTheme.COLOR_B_2));
// enemy 0: Title
this.addWidget(new LabelWidget(333 / 2, 222 / 2 - 50, "Theseus's Escape", 0xFFFFFFFF).setXCentered(true), 0);
this.addWidget(new ClickButtonWidget(323 / 2 - 10, 222 / 2 - 10, 30, 30, "Play", (clickData -> {
this.setGameState(1);
this.resetGame();
})).setShouldClientCallback(true), 0);
// GameState 1: Play
this.setMaze(new MazeWidget());
this.setPlayer(new PlayerWidget(0, 0, this));
this.setEnemy(new EnemyWidget(-100, -100, this));
// GameState 2: Pause
this.addWidget(new ImageWidget(5, 5, 333 - 10, 232 - 10, new ColorRectTexture(0xFF000000)), 2, 3);
this.addWidget(new ClickButtonWidget(323 / 2 - 10, 222 / 2 - 10, 50, 20, "Continue", (clickData) -> this.setGameState(1)).setShouldClientCallback(true), 2);
this.addWidget(new LabelWidget(333 / 2, 222 / 2 - 50, "Game Paused", 0xFFFFFFFF).setXCentered(true), 2);
// GameState 3: Death
this.addWidget(new SimpleTextWidget(333 / 2, 232 / 2 - 40, "", 0xFFFFFFFF, () -> "Oh no! You were eaten by the Minotaur!", true), 3);
this.addWidget(new SimpleTextWidget(333 / 2, 232 / 2 - 28, "", 0xFFFFFFFF, () -> "You got through " + this.getMazesSolved() + " mazes before losing.", true), 3);
this.addWidget(new SimpleTextWidget(333 / 2, 232 / 2 - 16, "", 0xFFFFFFFF, () -> "Try again?", true), 3);
this.addWidget(new ClickButtonWidget(323 / 2 - 10, 222 / 2 + 10, 40, 20, "Retry", (clickData -> {
this.setGameState(1);
this.setMazesSolved(0);
MAZE_SIZE = 9;
speed = 25;
this.resetGame();
})).setShouldClientCallback(true), 3);
}
return this;
}
Aggregations