diff --git a/assets/textures/DeliverFlag.jpg b/assets/textures/DeliverFlag.jpg new file mode 100644 index 00000000..9acefac1 Binary files /dev/null and b/assets/textures/DeliverFlag.jpg differ diff --git a/assets/textures/FetchFlag.png b/assets/textures/FetchFlag.png new file mode 100644 index 00000000..f4ec17a4 Binary files /dev/null and b/assets/textures/FetchFlag.png differ diff --git a/assets/textures/MagicFoolIcon.png b/assets/textures/MagicFoolIcon.png new file mode 100644 index 00000000..0f676f65 Binary files /dev/null and b/assets/textures/MagicFoolIcon.png differ diff --git a/assets/textures/OpenInventory.jpg b/assets/textures/OpenInventory.jpg new file mode 100644 index 00000000..0cceb4f6 Binary files /dev/null and b/assets/textures/OpenInventory.jpg differ diff --git a/assets/textures/OpenStatistics.jpg b/assets/textures/OpenStatistics.jpg new file mode 100644 index 00000000..b0507372 Binary files /dev/null and b/assets/textures/OpenStatistics.jpg differ diff --git a/module.txt b/module.txt index 25a378e8..0b63781a 100644 --- a/module.txt +++ b/module.txt @@ -49,6 +49,10 @@ { "id": "ItemRendering", "minVersion": "1.1.0" + }, + { + "id": "Journal", + "minVersion": "1.0.0" }, { "id": "LightAndShadowResources", diff --git a/overrides/Journal/ui/JournalWindow.ui b/overrides/Journal/ui/JournalWindow.ui new file mode 100644 index 00000000..5a62364b --- /dev/null +++ b/overrides/Journal/ui/JournalWindow.ui @@ -0,0 +1,101 @@ +{ + "type": "SetTutorialImages", + "skin": "Journal:journal", + "contents": { + "type": "rowLayout", + "contents": [ + { + "type": "relativeLayout", + "contents": [ + { + "type": "ScrollableArea", + "id": "entries", + "content": { + "type": "BrowserWidget", + "id": "journalList" + }, + "family": "journalList", + "layoutInfo": { + "width": 450, + "height": 600, + "position-horizontal-center": {}, + "position-vertical-center": {} + } + }, + { + "type": "ColumnLayout", + "id": "row", + "contents": [ + { + "type": "ColumnLayout", + "columns": 2, + "column-widths": [ + 0.5, + 0.5 + ], + "contents": [ + { + "type": "UIImage", + "id": "fetchFlag" + }, + { + "type": "UIImage", + "id": "deliverFlag" + } + ], + "horizontalSpacing": 10 + }, + { + "type": "ColumnLayout", + "columns": 2, + "column-widths": [ + 0.5, + 0.5 + ], + "contents": [ + { + "type": "UIImage", + "id": "openStatistics" + }, + { + "type": "UIImage", + "id": "openInventory" + } + ], + "horizontalSpacing": 10 + } + ], + "layoutInfo": { + "height": 400, + "position-horizontal-center": {}, + "position-top": { + "target": "TOP", + "widget": "entries" + }, + "width": 430, + "position-vertical-center": {} + } + }, + { + "type": "ScrollableArea", + "id": "chapters", + "content": { + "type": "UIList", + "id": "chapterList" + }, + "family": "chapterList", + "layoutInfo": { + "width": 80, + "height": 600, + "position-right": { + "target": "LEFT", + "widget": "entries" + }, + "position-vertical-center": {} + } + } + ] + } + ] + } +} \ No newline at end of file diff --git a/src/main/java/org/terasology/journal/integration/LASJournalIntegration.java b/src/main/java/org/terasology/journal/integration/LASJournalIntegration.java new file mode 100644 index 00000000..8ed21c6b --- /dev/null +++ b/src/main/java/org/terasology/journal/integration/LASJournalIntegration.java @@ -0,0 +1,81 @@ +/* + * Copyright 2017 MovingBlocks + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.terasology.journal.integration; + +import org.terasology.dialogs.ShowDialogEvent; +import org.terasology.engine.entitySystem.entity.EntityRef; +import org.terasology.engine.entitySystem.event.ReceiveEvent; +import org.terasology.engine.entitySystem.systems.BaseComponentSystem; +import org.terasology.engine.entitySystem.systems.RegisterMode; +import org.terasology.engine.entitySystem.systems.RegisterSystem; +import org.terasology.engine.network.ClientComponent; +import org.terasology.engine.registry.In; +import org.terasology.engine.rendering.nui.NUIManager; +import org.terasology.engine.utilities.Assets; +import org.terasology.journal.BrowserJournalChapterHandler; +import org.terasology.journal.DiscoveredNewJournalEntry; +import org.terasology.journal.JournalButton; +import org.terasology.journal.JournalManager; +import org.terasology.journal.NewJournalEntryDiscoveredEvent; + +import java.util.Arrays; + +@RegisterSystem(RegisterMode.AUTHORITY) +public class LASJournalIntegration extends BaseComponentSystem { + @In + private NUIManager nuiManager; + @In + private JournalManager journalManager; + private boolean entryReceived; + private String lasChapterId = "LightAndShadow"; + private SetTutorialImages window; + + @Override + public void preBegin() { + entryReceived = false; + BrowserJournalChapterHandler chapterHandler = new BrowserJournalChapterHandler(); + chapterHandler.registerJournalEntry("Instructions", Arrays.asList()); + journalManager.registerJournalChapter(lasChapterId, + Assets.getTextureRegion("LightAndShadow:MagicFoolIcon").get(), + "LightAndShadow", chapterHandler); + } + + @ReceiveEvent + public void onDialogActivated(ShowDialogEvent event, EntityRef player) { + player.send(new DiscoveredNewJournalEntry(lasChapterId, "Instructions")); + } + + @ReceiveEvent + public void onReceiveNewJournalEntry(NewJournalEntryDiscoveredEvent event, EntityRef character) { + entryReceived = true; + if (window == null) { + if (!nuiManager.isOpen("Journal:JournalWindow")) { + nuiManager.toggleScreen("Journal:JournalWindow"); + } + window = (SetTutorialImages) nuiManager.getScreen("Journal:JournalWindow"); + nuiManager.closeScreen("Journal:JournalWindow"); + } + } + + @ReceiveEvent + public void onLASJournalDiscover(JournalButton event, EntityRef character, + ClientComponent clientComponent) { + + if (entryReceived) { + window.setImages(); + } + } +} diff --git a/src/main/java/org/terasology/journal/integration/SetTutorialImages.java b/src/main/java/org/terasology/journal/integration/SetTutorialImages.java new file mode 100644 index 00000000..62f556d3 --- /dev/null +++ b/src/main/java/org/terasology/journal/integration/SetTutorialImages.java @@ -0,0 +1,44 @@ +// Copyright 2020 The Terasology Foundation +// SPDX-License-Identifier: Apache-2.0 +package org.terasology.journal.integration; + +import org.terasology.engine.registry.In; +import org.terasology.engine.rendering.assets.texture.Texture; +import org.terasology.gestalt.assets.management.AssetManager; +import org.terasology.journal.ui.JournalNUIWindow; +import org.terasology.nui.widgets.UIImage; + +public class SetTutorialImages extends JournalNUIWindow { + + @In + AssetManager assetManager; + private UIImage fetchFlag; + private UIImage deliverFlag; + private UIImage inventory; + private UIImage statistics; + + @Override + public void initialise() { + fetchFlag = find("fetchFlag", UIImage.class); + deliverFlag = find("deliverFlag", UIImage.class); + inventory = find("openInventory", UIImage.class); + statistics = find("openStatistics", UIImage.class); + super.initialise(); + } + + @Override + public void update(float delta) { + super.update(delta); + } + + public void setImages() { + Texture texture = assetManager.getAsset("LightAndShadow:FetchFlag", Texture.class).get(); + fetchFlag.setImage(texture); + texture = assetManager.getAsset("LightAndShadow:DeliverFlag", Texture.class).get(); + deliverFlag.setImage(texture); + texture = assetManager.getAsset("LightAndShadow:OpenStatistics", Texture.class).get(); + statistics.setImage(texture); + texture = assetManager.getAsset("LightAndShadow:OpenInventory", Texture.class).get(); + inventory.setImage(texture); + } +}