Search in sources :

Example 6 with DialogueNodeOld

use of com.lilithsthrone.game.dialogue.DialogueNodeOld in project liliths-throne-public by Innoxia.

the class Game method setContent.

public void setContent(Response response, boolean allowTimeProgress, Colour flashMessageColour, String flashMessageText) {
    DialogueNodeOld node = response.getNextDialogue();
    response.applyEffects();
    if (node == null) {
        return;
    }
    int currentPosition = 0;
    if (getCurrentDialogueNode() != null) {
        currentPosition = (int) Main.mainController.getWebEngine().executeScript("document.getElementById('content-block').scrollTop");
    }
    String headerContent = node.getHeaderContent();
    String content = node.getContent();
    boolean resetPointer = false;
    if (getMapDisplay() == MapDisplay.NORMAL) {
        initialPositionAnchor = positionAnchor;
    }
    // Add characters in this scene to the player's encountered characters list:
    if (started) {
        if (!getCharactersPresent().isEmpty()) {
            for (GameCharacter character : getCharactersPresent()) {
                if (character instanceof NPC) {
                    if (((NPC) character).isAddedToContacts()) {
                        Main.game.getPlayer().addCharacterEncountered(character);
                    }
                    if (!character.isRaceConcealed()) {
                        Main.getProperties().addRaceDiscovered(character.getRace());
                    }
                    ((NPC) character).setLastTimeEncountered(minutesPassed);
                }
            }
        }
    }
    if (currentDialogueNode != null) {
        if (node.isContinuesDialogue()) {
            if (!node.isNoTextForContinuesDialogue()) {
                if (Main.game.isInSex()) {
                    dialogueTitle = UtilText.parse(node.getLabel());
                }
                if (node.isDisplaysActionTitleOnContinuesDialogue()) {
                    if (currentDialogueNode.getMapDisplay() == MapDisplay.NORMAL) {
                        positionAnchor++;
                    }
                    pastDialogueSB.append(UtilText.parse("<hr id='position" + positionAnchor + "'><p class='option-disabled'>&gt " + currentDialogueNode.getLabel() + "</p>"));
                }
                pastDialogueSB.append(content);
            }
        } else {
            dialogueTitle = UtilText.parse(node.getLabel());
            if (currentDialogueNode.getMapDisplay() == MapDisplay.NORMAL)
                positionAnchor = 0;
            pastDialogueSB.setLength(0);
            pastDialogueSB.append(UtilText.parse("<b id='position" + positionAnchor + "'></b>" + textStartStringBuilder.toString() + content + textEndStringBuilder.toString()));
        }
    } else {
        dialogueTitle = UtilText.parse(node.getLabel());
        pastDialogueSB.setLength(0);
        pastDialogueSB.append(UtilText.parse(textStartStringBuilder.toString() + content + textEndStringBuilder.toString()));
    }
    if (node != currentDialogueNode) {
        responsePage = 0;
        currentDialogueNode = node;
        resetPointer = true;
    } else {
        currentDialogueNode = node;
        checkForResponsePage();
        resetPointer = false;
    }
    if (node.isContinuesDialogue()) {
        currentDialogue = "<body onLoad='scrollToElement()'>" + "<script>function scrollToElement() {document.getElementById('content-block').scrollTop = document.getElementById('position" + (positionAnchor) + "').offsetTop -64;}</script>" + "<div id='main-content'>" + getTitleDiv(dialogueTitle) + "<div class='div-center' id='content-block'>" + // + "<div class='inner-text-content'>"
        getMapDiv() + (headerContent != null ? "<div id='header-content' style='font-size:" + Main.getProperties().fontSize + "px; line-height:" + (Main.getProperties().fontSize + 6) + "px;-webkit-user-select: none;'>" + (currentDialogueNode.disableHeaderParsing() ? headerContent : UtilText.parse(headerContent)) + "</div>" : "") + (content != null ? "<div " + (Main.getProperties().fadeInText ? "id='text-content'" : "") + " style='font-size:" + Main.getProperties().fontSize + "px; line-height:" + (Main.getProperties().fontSize + 6) + "px;'>" + pastDialogueSB.toString() + "</div>" : "") + // + "</div>"
        "</div>" + "<div id='bottom-text'>Game saved!</div>" + getResponsesDiv(currentDialogueNode, resetPointer) + "</div>" + "</body>";
    } else {
        currentDialogue = "<body onLoad='scrollBack()'>" + "<script>function scrollBack() {document.getElementById('content-block').scrollTop = " + currentPosition + ";}</script>" + "<div id='main-content'>" + getTitleDiv(dialogueTitle) + "<span id='position" + positionAnchor + "'></span>" + "<div class='div-center' id='content-block'>" + // + "<div class='inner-text-content'>"
        getMapDiv() + (headerContent != null ? "<div id='header-content' style='font-size:" + Main.getProperties().fontSize + "px; line-height:" + (Main.getProperties().fontSize + 6) + "px;-webkit-user-select: none;'>" + (currentDialogueNode.disableHeaderParsing() ? headerContent : UtilText.parse(headerContent)) + "</div>" : "") + (content != null ? "<div " + (Main.getProperties().fadeInText ? "id='text-content'" : "") + " style='font-size:" + Main.getProperties().fontSize + "px; line-height:" + (Main.getProperties().fontSize + 6) + "px;'>" + pastDialogueSB.toString() + "</div>" : "") + // + "</div>"
        "</div>" + "<div id='bottom-text'>Game saved!</div>" + getResponsesDiv(currentDialogueNode, resetPointer) + "</div>" + "</body>";
    }
    Main.mainController.setFlashMessageColour(flashMessageColour);
    Main.mainController.setFlashMessageText(flashMessageText);
    // -------------------- MEMORY LEAK PROBLEM
    Main.mainController.setMainContent(currentDialogue);
    // --------------------
    textEndStringBuilder.setLength(0);
    textStartStringBuilder.setLength(0);
    // -------------------- MEMORY LEAK PROBLEM
    if (started) {
        if (allowTimeProgress) {
            Main.game.endTurn(getCurrentDialogueNode().getMinutesPassed());
        } else {
            Main.game.endTurn(0);
        }
    }
// --------------------
}
Also used : TestNPC(com.lilithsthrone.game.character.npc.dominion.TestNPC) NPC(com.lilithsthrone.game.character.npc.NPC) GenericFemaleNPC(com.lilithsthrone.game.character.npc.GenericFemaleNPC) GenericAndrogynousNPC(com.lilithsthrone.game.character.npc.GenericAndrogynousNPC) GenericMaleNPC(com.lilithsthrone.game.character.npc.GenericMaleNPC) DialogueNodeOld(com.lilithsthrone.game.dialogue.DialogueNodeOld) GameCharacter(com.lilithsthrone.game.character.GameCharacter)

Example 7 with DialogueNodeOld

use of com.lilithsthrone.game.dialogue.DialogueNodeOld in project liliths-throne-public by Innoxia.

the class MainController method moveNorth.

/**
 * Moves the player North.
 */
public void moveNorth() {
    if (Main.game.getPlayer().getLocation().getY() + 1 < Main.game.getActiveWorld().WORLD_HEIGHT) {
        if (Main.game.getActiveWorld().getCell(Main.game.getPlayer().getLocation().getX(), Main.game.getPlayer().getLocation().getY() + 1).getPlace().getPlaceType() != PlaceType.GENERIC_IMPASSABLE) {
            if (Main.game.getActiveWorld().getCell(Main.game.getPlayer().getLocation()).getPlace().isItemsDisappear()) {
                Main.game.getActiveWorld().getCell(Main.game.getPlayer().getLocation()).resetInventory(Util.newArrayListOfValues(new ListValue<>(Rarity.LEGENDARY)));
            }
            Main.game.getPlayer().setLocation(new Vector2i(Main.game.getPlayer().getLocation().getX(), Main.game.getPlayer().getLocation().getY() + 1));
            DialogueNodeOld dn = Main.game.getActiveWorld().getCell(Main.game.getPlayer().getLocation()).getPlace().getDialogue(true);
            Main.game.setContent(new Response("", "", dn));
        }
    }
}
Also used : Response(com.lilithsthrone.game.dialogue.responses.Response) ListValue(com.lilithsthrone.utils.Util.ListValue) DialogueNodeOld(com.lilithsthrone.game.dialogue.DialogueNodeOld) Vector2i(com.lilithsthrone.utils.Vector2i)

Example 8 with DialogueNodeOld

use of com.lilithsthrone.game.dialogue.DialogueNodeOld in project liliths-throne-public by Innoxia.

the class MainController method moveWest.

/**
 * Moves the player West.
 */
public void moveWest() {
    if (Main.game.getPlayer().getLocation().getX() - 1 >= 0) {
        if (Main.game.getActiveWorld().getCell(Main.game.getPlayer().getLocation().getX() - 1, Main.game.getPlayer().getLocation().getY()).getPlace().getPlaceType() != PlaceType.GENERIC_IMPASSABLE) {
            if (Main.game.getActiveWorld().getCell(Main.game.getPlayer().getLocation()).getPlace().isItemsDisappear()) {
                Main.game.getActiveWorld().getCell(Main.game.getPlayer().getLocation()).resetInventory(Util.newArrayListOfValues(new ListValue<>(Rarity.LEGENDARY)));
            }
            Main.game.getPlayer().setLocation(new Vector2i(Main.game.getPlayer().getLocation().getX() - 1, Main.game.getPlayer().getLocation().getY()));
            DialogueNodeOld dn = Main.game.getActiveWorld().getCell(Main.game.getPlayer().getLocation()).getPlace().getDialogue(true);
            Main.game.setContent(new Response("", "", dn));
        }
    }
}
Also used : Response(com.lilithsthrone.game.dialogue.responses.Response) ListValue(com.lilithsthrone.utils.Util.ListValue) DialogueNodeOld(com.lilithsthrone.game.dialogue.DialogueNodeOld) Vector2i(com.lilithsthrone.utils.Vector2i)

Example 9 with DialogueNodeOld

use of com.lilithsthrone.game.dialogue.DialogueNodeOld in project liliths-throne-public by Innoxia.

the class Game method setActiveWorld.

/**
 * @param world
 * @param location Location to set player to
 */
public void setActiveWorld(World world, Vector2i location, boolean setDefaultDialogue) {
    // activeWorld = world;
    player.setWorldLocation(world.getWorldType());
    player.setLocation(location);
    if (setDefaultDialogue) {
        DialogueNodeOld dn = Main.game.getActiveWorld().getCell(Main.game.getPlayer().getLocation()).getPlace().getDialogue(true);
        Main.game.setContent(new Response("", "", dn));
    }
    if (Main.game.started) {
        Main.saveGame("AutoSave_" + Main.game.getPlayer().getName(), true);
    }
}
Also used : Response(com.lilithsthrone.game.dialogue.responses.Response) DialogueNodeOld(com.lilithsthrone.game.dialogue.DialogueNodeOld)

Aggregations

DialogueNodeOld (com.lilithsthrone.game.dialogue.DialogueNodeOld)9 Response (com.lilithsthrone.game.dialogue.responses.Response)8 ListValue (com.lilithsthrone.utils.Util.ListValue)5 Vector2i (com.lilithsthrone.utils.Vector2i)5 NPC (com.lilithsthrone.game.character.npc.NPC)4 TestNPC (com.lilithsthrone.game.character.npc.dominion.TestNPC)4 GameCharacter (com.lilithsthrone.game.character.GameCharacter)3 GenericAndrogynousNPC (com.lilithsthrone.game.character.npc.GenericAndrogynousNPC)3 GenericFemaleNPC (com.lilithsthrone.game.character.npc.GenericFemaleNPC)3 GenericMaleNPC (com.lilithsthrone.game.character.npc.GenericMaleNPC)3 ResponseEffectsOnly (com.lilithsthrone.game.dialogue.responses.ResponseEffectsOnly)2 WorldType (com.lilithsthrone.world.WorldType)2 File (java.io.File)2 ArrayList (java.util.ArrayList)2 Document (org.w3c.dom.Document)2 EnchantmentEventListener (com.lilithsthrone.controller.eventListeners.EnchantmentEventListener)1 InventorySelectedItemEventListener (com.lilithsthrone.controller.eventListeners.InventorySelectedItemEventListener)1 InventoryTooltipEventListener (com.lilithsthrone.controller.eventListeners.InventoryTooltipEventListener)1 SetContentEventListener (com.lilithsthrone.controller.eventListeners.SetContentEventListener)1 TooltipHideEventListener (com.lilithsthrone.controller.eventListeners.TooltipHideEventListener)1