Search in sources :

Example 1 with PostProcessingPipeline

use of de.eskalon.commons.graphics.postproc.PostProcessingPipeline in project ProjektGG by eskalon.

the class GameMapScreen method create.

@Override
protected void create() {
    super.create();
    camera = new CameraWrapper(67, application.getWidth(), application.getHeight());
    camera.setPosition(application.getWidth() / 2, application.getHeight() / 2, 0);
    postProcessor = new PostProcessingPipeline(application.getWidth(), application.getHeight(), true);
    pausePostProcessingEffect = new ColorBlendEffect(application.getUICamera(), new Color(0.4F, 0.4F, 0.4F, 0.4F));
    gameRenderer = new GameRenderer(camera.getCamera(), fragmentShader.getString());
    selectionInputController = new MapSelectionInputController(application.getEventBus(), camera.getCamera());
    addInputProcessor(selectionInputController);
    movementInputController = new MapMovementInputController(camera, application.getSettings());
    addInputProcessor(movementInputController);
    gameSpeedInputProcessor = new GameSpeedInputProcessor(application.getSettings());
    addInputProcessor(gameSpeedInputProcessor);
    // CHARACTER DIALOG
    BasicDialog characterMenuDialog = new BasicDialog(Lang.get("screen.map.character_config"), skin, "big");
    ImageTextButton closeCharacterMenuButton = new ImageTextButton(Lang.get("ui.generic.close"), skin);
    closeCharacterMenuButton.addListener(new ButtonClickListener(application.getSoundManager()) {

        @Override
        protected void onClick() {
            characterMenuDialog.hide();
        }
    });
    Table characterMenuTable = new Table();
    Table changeableCharacterMenuTable = new Table();
    ImageTextButton characterMenuTab1Button = new ImageTextButton(Lang.get("screen.map.character_config.character"), skin);
    ImageTextButton characterMenuTab2Button = new ImageTextButton(Lang.get("screen.map.character_config.privileges"), skin);
    characterMenuTab1Button.addListener(new ButtonClickListener(application.getSoundManager()) {

        @Override
        protected void onClick() {
            // CHARACTER & FAMILY
            changeableCharacterMenuTable.clear();
            changeableCharacterMenuTable.add(new Label(Lang.get("screen.map.character_config.name"), skin, "dark")).padBottom(50).row();
            changeableCharacterMenuTable.add(new Label(Lang.get("screen.map.character_config.family"), skin, "dark")).row();
            changeableCharacterMenuTable.add(new Label(Lang.get("screen.map.character_config.find_so"), skin, "dark"));
        }
    });
    characterMenuTab2Button.addListener(new ButtonClickListener(application.getSoundManager()) {

        @Override
        protected void onClick() {
            // PRIVILEGES
            changeableCharacterMenuTable.clear();
            changeableCharacterMenuTable.add(new Label(Lang.get("screen.map.character_config.privileges_list"), skin, "dark")).row();
            if (application.getClient().getLocalPlayerCharacter().getPosition() != null) {
                // TODO Position privileges
                // TODO Impeachment
                ImageTextButton kickButton = new ImageTextButton(Lang.get("screen.map.character_config.privilege.impeach"), skin);
                kickButton.addListener(new ButtonClickListener(application.getSoundManager()) {

                    @Override
                    protected void onClick() {
                        short mayor = application.getClient().getSession().getWorld().getPosition(PositionType.MAYOR).getCurrentHolder();
                        if (mayor != -1)
                            application.getClient().getActionHandler().arrangeImpeachmentVote(mayor, (param) -> {
                                if ((Boolean) param == true) {
                                    SimpleTextDialog.createAndShow(stage, skin, Lang.get("screen.map.character_config.privilege.success"), Lang.get("ui.generic.wip"));
                                } else {
                                    SimpleTextDialog.createAndShow(stage, skin, Lang.get("ui.generic.error"), Lang.get("ui.generic.rmi_error"));
                                }
                            });
                    }
                });
                changeableCharacterMenuTable.add(kickButton);
            }
        }
    });
    Table characterMenuTabTable = new Table();
    characterMenuTabTable.add(characterMenuTab1Button).padRight(5);
    characterMenuTabTable.add(characterMenuTab2Button);
    characterMenuTable.add(characterMenuTabTable).padRight(30).padBottom(15).center().top().row();
    characterMenuTable.add(changeableCharacterMenuTable).padBottom(15).top().height(315).row();
    characterMenuTable.add(closeCharacterMenuButton).padRight(30).center().top();
    characterMenuDialog.add(characterMenuTable).pad(30);
    // PLAYER ICON
    iconButton = new ImageButton(skin.getDrawable(PlayerIcon.values()[0].getShieldDrawableName()));
    iconButton.addListener(new ButtonClickListener(application.getSoundManager()) {

        @Override
        protected void onClick() {
            characterMenuDialog.show(stage);
            characterMenuDialog.setPosition(0, 103);
        }
    });
    Table iconTable = new Table();
    iconTable.setBackground(skin.getDrawable("icon_background"));
    iconTable.add(iconButton).padLeft(8).padRight(10).padBottom(1);
    // INFO STUFF
    Table infoTable = new Table();
    // Gold
    Table goldTable = new Table();
    goldTable.setBackground(skin.getDrawable("info_background"));
    goldTable.add(new Image(skin.getDrawable("icon_gold_coin"))).left().top().padLeft(4).padBottom(2).padRight(4);
    goldTable.add(new Label("19 Gulden", skin, "dark")).padBottom(5).expandX().left().top();
    // Name
    Table nameTable = new Table();
    nameTable.setBackground(skin.getDrawable("info_background"));
    nameTable.add(new Label("Freiherr  Franz  von  Woyzeck", skin, "big_dark")).padBottom(2).expandX().left();
    // Notifications
    Table notificationTable = new Table();
    infoTable.add(goldTable).row();
    infoTable.add(nameTable).left().row();
    infoTable.add(notificationTable).left().padLeft(2).padTop(2).row();
    // DATE STUFF
    Table dateTimeTable = new Table();
    // Date
    Table dateTable = new Table();
    dateLabel = new Label("", skin, "dark");
    dateTable.setBackground(skin.getDrawable("date_background"));
    dateTable.add(dateLabel).padLeft(9).padBottom(5).expandX().left();
    // Clock
    Table clockTable = new Table();
    clockTable.setBackground(skin.getDrawable("clock_background"));
    dateTimeTable.add(dateTable).row();
    dateTimeTable.add(clockTable).right();
    // MISC
    Table miscTable = new Table();
    Table misc2Table = new Table();
    // Inventory
    ImageButton inventoryButton = new ImageButton(skin, "inventory");
    // Book
    ImageButton bookButton = new ImageButton(skin, "leaning_book");
    // Minimap
    Table minimapTable = new Table();
    minimapTable.setBackground(skin.getDrawable("minimap_test"));
    misc2Table.add(inventoryButton).padRight(2);
    misc2Table.add(bookButton).padTop(2).row();
    miscTable.add(misc2Table).right().row();
    miscTable.add(minimapTable);
    mainTable.setSkin(skin);
    mainTable.setFillParent(true);
    mainTable.add(iconTable).top().left();
    mainTable.add(infoTable).top().left();
    mainTable.add(dateTimeTable).right().expandX().row();
    mainTable.add("").fill();
    mainTable.add("").expand().fill();
    mainTable.add(miscTable).expandY().bottom().right();
    // PAUSE DIALOG
    pauseDialog = new BasicDialog("", skin) {

        @Override
        protected void result(Object object) {
            pauseShown = false;
            postProcessor.removeEffect(pausePostProcessingEffect);
            if (object == (Integer) 1) {
                application.getScreenManager().pushScreen("settings", "blendingTransition");
            } else {
                Log.info("Client", "Verbindung wird getrennt");
                final GameClient client = application.getClient();
                final GameServer server = application.getServer();
                // Set stuff to null to stop updates
                application.setClient(null);
                application.setServer(null);
                ThreadHandler.getInstance().executeRunnable(() -> {
                    client.disconnect();
                    if (server != null) {
                        server.stop();
                    }
                });
                DiscordGGHandler.getInstance().setMenuPresence();
                application.getScreenManager().pushScreen("main_menu", null);
            }
        }
    };
    pauseDialog.button(Lang.get("screen.map.pause.settings"), 1).button(Lang.get("screen.map.pause.disconnect"), 2);
    houseSelectionDialog = new BasicDialog("", skin);
    houseSelectionDialog.button("Test");
    stage.addListener(new InputListener() {

        @Override
        public boolean keyDown(InputEvent event, int keycode) {
            if (keycode == Keys.ESCAPE) {
                if (pauseShown) {
                    pauseDialog.hide();
                    postProcessor.removeEffect(pausePostProcessingEffect);
                } else {
                    pauseDialog.show(stage);
                    postProcessor.addEffect(pausePostProcessingEffect);
                }
                pauseShown = !pauseShown;
                return true;
            }
            return false;
        }
    });
}
Also used : InputListener(com.badlogic.gdx.scenes.scene2d.InputListener) ButtonClickListener(de.gg.game.input.ButtonClickListener) SimpleTextDialog(de.gg.game.ui.components.SimpleTextDialog) ThreadHandler(de.damios.guacamole.concurrent.ThreadHandler) BasicDialog(de.gg.game.ui.components.BasicDialog) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) Table(com.badlogic.gdx.scenes.scene2d.ui.Table) GameClient(de.gg.game.network.GameClient) MapSelectionInputController(de.gg.game.input.MapSelectionInputController) PlayerIcon(de.gg.game.model.types.PlayerIcon) Asset(de.eskalon.commons.asset.AnnotationAssetManager.Asset) Lang(de.eskalon.commons.lang.Lang) HouseSelectionEvent(de.gg.game.events.HouseSelectionEvent) GameSpeedInputProcessor(de.gg.game.input.GameSpeedInputProcessor) ImageTextButton(com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton) GameSession(de.gg.game.session.GameSession) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) Log(de.damios.guacamole.gdx.Log) Subscribe(com.google.common.eventbus.Subscribe) PositionType(de.gg.game.model.types.PositionType) GameServer(de.gg.game.network.GameServer) Image(com.badlogic.gdx.scenes.scene2d.ui.Image) ColorBlendEffect(de.eskalon.commons.graphics.postproc.impl.ColorBlendEffect) HouseEnterEvent(de.gg.game.events.HouseEnterEvent) World(de.gg.game.model.World) CameraWrapper(de.gg.engine.ui.rendering.CameraWrapper) GameRenderer(de.gg.game.ui.rendering.GameRenderer) FullHourEvent(de.gg.game.events.FullHourEvent) DiscordGGHandler(de.gg.game.misc.DiscordGGHandler) Color(com.badlogic.gdx.graphics.Color) Text(de.damios.guacamole.gdx.assets.Text) ProjektGGApplication(de.gg.game.core.ProjektGGApplication) GameClock(de.gg.game.misc.GameClock) PostProcessingPipeline(de.eskalon.commons.graphics.postproc.PostProcessingPipeline) Keys(com.badlogic.gdx.Input.Keys) MapMovementInputController(de.gg.game.input.MapMovementInputController) Player(de.gg.game.model.entities.Player) ImageButton(com.badlogic.gdx.scenes.scene2d.ui.ImageButton) ImageTextButton(com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton) GameClient(de.gg.game.network.GameClient) ColorBlendEffect(de.eskalon.commons.graphics.postproc.impl.ColorBlendEffect) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) Image(com.badlogic.gdx.scenes.scene2d.ui.Image) MapSelectionInputController(de.gg.game.input.MapSelectionInputController) ImageButton(com.badlogic.gdx.scenes.scene2d.ui.ImageButton) InputListener(com.badlogic.gdx.scenes.scene2d.InputListener) ButtonClickListener(de.gg.game.input.ButtonClickListener) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) GameServer(de.gg.game.network.GameServer) GameSpeedInputProcessor(de.gg.game.input.GameSpeedInputProcessor) BasicDialog(de.gg.game.ui.components.BasicDialog) CameraWrapper(de.gg.engine.ui.rendering.CameraWrapper) PostProcessingPipeline(de.eskalon.commons.graphics.postproc.PostProcessingPipeline) Table(com.badlogic.gdx.scenes.scene2d.ui.Table) MapMovementInputController(de.gg.game.input.MapMovementInputController) Color(com.badlogic.gdx.graphics.Color) GameRenderer(de.gg.game.ui.rendering.GameRenderer)

Aggregations

Keys (com.badlogic.gdx.Input.Keys)1 Color (com.badlogic.gdx.graphics.Color)1 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)1 InputListener (com.badlogic.gdx.scenes.scene2d.InputListener)1 Image (com.badlogic.gdx.scenes.scene2d.ui.Image)1 ImageButton (com.badlogic.gdx.scenes.scene2d.ui.ImageButton)1 ImageTextButton (com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton)1 Label (com.badlogic.gdx.scenes.scene2d.ui.Label)1 Table (com.badlogic.gdx.scenes.scene2d.ui.Table)1 Subscribe (com.google.common.eventbus.Subscribe)1 ThreadHandler (de.damios.guacamole.concurrent.ThreadHandler)1 Log (de.damios.guacamole.gdx.Log)1 Text (de.damios.guacamole.gdx.assets.Text)1 Asset (de.eskalon.commons.asset.AnnotationAssetManager.Asset)1 PostProcessingPipeline (de.eskalon.commons.graphics.postproc.PostProcessingPipeline)1 ColorBlendEffect (de.eskalon.commons.graphics.postproc.impl.ColorBlendEffect)1 Lang (de.eskalon.commons.lang.Lang)1 CameraWrapper (de.gg.engine.ui.rendering.CameraWrapper)1 ProjektGGApplication (de.gg.game.core.ProjektGGApplication)1 FullHourEvent (de.gg.game.events.FullHourEvent)1