Search in sources :

Example 11 with AbstractApplication

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;
        }
    }
}
Also used : ARApplication(gregtech.api.terminal.app.ARApplication) AbstractApplication(gregtech.api.terminal.app.AbstractApplication) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Example 12 with AbstractApplication

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;
}
Also used : VirtualTankRegistry(gregtech.api.util.VirtualTankRegistry) java.util(java.util) TerminalTheme(gregtech.api.terminal.os.TerminalTheme) TextTexture(gregtech.api.gui.resources.TextTexture) ImageWidget(gregtech.api.gui.widgets.ImageWidget) TankWidget(gregtech.api.gui.widgets.TankWidget) SearchComponent(gregtech.common.terminal.component.SearchComponent) Pair(org.apache.commons.lang3.tuple.Pair) Side(net.minecraftforge.fml.relauncher.Side) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) GTLog(gregtech.api.util.GTLog) WidgetGroup(gregtech.api.gui.widgets.WidgetGroup) LabelWidget(gregtech.api.gui.widgets.LabelWidget) DraggableScrollableWidgetGroup(gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup) Collectors(java.util.stream.Collectors) GuiTextures(gregtech.api.gui.GuiTextures) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) AbstractApplication(gregtech.api.terminal.app.AbstractApplication) Consumer(java.util.function.Consumer) RectButtonWidget(gregtech.api.terminal.gui.widgets.RectButtonWidget) IMenuComponent(gregtech.api.terminal.os.menu.IMenuComponent) FluidStack(net.minecraftforge.fluids.FluidStack) FluidTank(net.minecraftforge.fluids.FluidTank) IFluidTank(net.minecraftforge.fluids.IFluidTank) PacketBuffer(net.minecraft.network.PacketBuffer) DraggableScrollableWidgetGroup(gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup) LabelWidget(gregtech.api.gui.widgets.LabelWidget) TextTexture(gregtech.api.gui.resources.TextTexture) ImageWidget(gregtech.api.gui.widgets.ImageWidget) RectButtonWidget(gregtech.api.terminal.gui.widgets.RectButtonWidget)

Example 13 with AbstractApplication

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;
}
Also used : DraggableScrollableWidgetGroup(gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup) LabelWidget(gregtech.api.gui.widgets.LabelWidget) AbstractApplication(gregtech.api.terminal.app.AbstractApplication) ColorRectTexture(gregtech.api.gui.resources.ColorRectTexture) TextTexture(gregtech.api.gui.resources.TextTexture) ImageWidget(gregtech.api.gui.widgets.ImageWidget)

Example 14 with AbstractApplication

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;
}
Also used : ClickButtonWidget(gregtech.api.gui.widgets.ClickButtonWidget) SimpleTextWidget(gregtech.api.gui.widgets.SimpleTextWidget) Arrays(java.util.Arrays) ColorRectTexture(gregtech.api.gui.resources.ColorRectTexture) TerminalTheme(gregtech.api.terminal.os.TerminalTheme) PlayerWidget(gregtech.common.terminal.app.game.maze.widget.PlayerWidget) Keyboard(org.lwjgl.input.Keyboard) ClickButtonWidget(gregtech.api.gui.widgets.ClickButtonWidget) LabelWidget(gregtech.api.gui.widgets.LabelWidget) MazeWidget(gregtech.common.terminal.app.game.maze.widget.MazeWidget) EnemyWidget(gregtech.common.terminal.app.game.maze.widget.EnemyWidget) ImageWidget(gregtech.api.gui.widgets.ImageWidget) AbstractApplication(gregtech.api.terminal.app.AbstractApplication) ArrayList(java.util.ArrayList) List(java.util.List) Widget(gregtech.api.gui.Widget) LinkedList(java.util.LinkedList) PlayerWidget(gregtech.common.terminal.app.game.maze.widget.PlayerWidget) MazeWidget(gregtech.common.terminal.app.game.maze.widget.MazeWidget) LabelWidget(gregtech.api.gui.widgets.LabelWidget) ColorRectTexture(gregtech.api.gui.resources.ColorRectTexture) ImageWidget(gregtech.api.gui.widgets.ImageWidget) EnemyWidget(gregtech.common.terminal.app.game.maze.widget.EnemyWidget) SimpleTextWidget(gregtech.api.gui.widgets.SimpleTextWidget)

Aggregations

AbstractApplication (gregtech.api.terminal.app.AbstractApplication)14 ImageWidget (gregtech.api.gui.widgets.ImageWidget)5 LabelWidget (gregtech.api.gui.widgets.LabelWidget)5 RectButtonWidget (gregtech.api.terminal.gui.widgets.RectButtonWidget)5 ColorRectTexture (gregtech.api.gui.resources.ColorRectTexture)4 TerminalTheme (gregtech.api.terminal.os.TerminalTheme)4 IElectricItem (gregtech.api.capability.IElectricItem)3 IRenderContext (gregtech.api.gui.IRenderContext)3 WidgetGroup (gregtech.api.gui.widgets.WidgetGroup)3 ARApplication (gregtech.api.terminal.app.ARApplication)3 BatteryHardware (gregtech.common.terminal.hardware.BatteryHardware)3 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)3 GuiTextures (gregtech.api.gui.GuiTextures)2 Widget (gregtech.api.gui.Widget)2 ShaderTexture (gregtech.api.gui.resources.ShaderTexture)2 TextTexture (gregtech.api.gui.resources.TextTexture)2 TextureArea (gregtech.api.gui.resources.TextureArea)2 DraggableScrollableWidgetGroup (gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup)2 Hardware (gregtech.api.terminal.hardware.Hardware)2 TerminalDialogWidget (gregtech.api.terminal.os.TerminalDialogWidget)2