Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quest SUI message boxes #1412

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,23 @@ public List<QuestTaskInfo> getTaskListInfos(String questName) {
Set<String> columns = new LinkedHashSet<>(set.getColumns());
String type = set.getText("attach_script");
String name = set.getText("task_name");
String commMessageText = set.getText("comm_message_text");
String npcAppearanceServerTemplate = set.getText("npc_appearance_server_template");
String commMessageText = null;
if (columns.contains("comm_message_text")) {
commMessageText = set.getText("comm_message_text");
}
String npcAppearanceServerTemplate = null;
if (columns.contains("npc_appearance_server_template")) {
npcAppearanceServerTemplate = set.getText("npc_appearance_server_template");
}
String targetServerTemplate = null;
if (columns.contains("target_server_template")) {
targetServerTemplate = set.getText("target_server_template");
}
String grantQuestOnComplete = set.getText("grant_quest_on_complete");
int count = (int) set.getInt("count");
int count = 0;
if (columns.contains("count")) {
count = (int) set.getInt("count");
}
int minTime = 0;
if (columns.contains("min_time")) {
minTime = (int) set.getInt("min_time");
Expand All @@ -77,6 +86,14 @@ public List<QuestTaskInfo> getTaskListInfos(String questName) {
maxTime = (int) set.getInt("max_time");
}
String[] nextTasksOnComplete = set.getText("tasks_on_complete").split(",");
String messageBoxTitle = null;
if (columns.contains("message_box_title")) {
messageBoxTitle = set.getText("message_box_title");
}
String messageBoxText = null;
if (columns.contains("message_box_text")) {
messageBoxText = set.getText("message_box_text");
}

QuestTaskInfo questTaskInfo = new QuestTaskInfo();

Expand All @@ -98,6 +115,8 @@ public List<QuestTaskInfo> getTaskListInfos(String questName) {
questTaskInfo.setCount(count);
questTaskInfo.setMinTime(minTime);
questTaskInfo.setMaxTime(maxTime);
questTaskInfo.setMessageBoxTitle(messageBoxTitle);
questTaskInfo.setMessageBoxText(messageBoxText);

questTaskInfos.add(questTaskInfo);
}
Expand Down Expand Up @@ -196,6 +215,8 @@ public static class QuestTaskInfo {
private String grantQuestOnComplete;
private int minTime;
private int maxTime;
private String messageBoxTitle;
private String messageBoxText;

private QuestTaskInfo() {
nextTasksOnComplete = new ArrayList<>();
Expand All @@ -204,7 +225,23 @@ private QuestTaskInfo() {
public int getMinTime() {
return minTime;
}


public String getMessageBoxTitle() {
return messageBoxTitle;
}

public void setMessageBoxTitle(String messageBoxTitle) {
this.messageBoxTitle = messageBoxTitle;
}

public String getMessageBoxText() {
return messageBoxText;
}

public void setMessageBoxText(String messageBoxText) {
this.messageBoxText = messageBoxText;
}

private void setMinTime(int minTime) {
this.minTime = minTime;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/***********************************************************************************
* Copyright (c) 2023 /// Project SWG /// www.projectswg.com *
* *
* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on *
* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. *
* Our goal is to create an emulator which will provide a server for players to *
* continue playing a game similar to the one they used to play. We are basing *
* it on the final publish of the game prior to end-game events. *
* *
* This file is part of Holocore. *
* *
* --------------------------------------------------------------------------------*
* *
* Holocore is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* Holocore is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Affero General Public License for more details. *
* *
* You should have received a copy of the GNU Affero General Public License *
* along with Holocore. If not, see <http://www.gnu.org/licenses/>. *
***********************************************************************************/
package com.projectswg.holocore.resources.support.global.commands.callbacks.admin

import com.projectswg.holocore.intents.gameplay.player.quest.GrantQuestIntent
import com.projectswg.holocore.intents.support.global.chat.SystemMessageIntent
import com.projectswg.holocore.resources.support.global.commands.ICmdCallback
import com.projectswg.holocore.resources.support.global.player.AccessLevel
import com.projectswg.holocore.resources.support.global.player.Player
import com.projectswg.holocore.resources.support.objects.swg.SWGObject

class CmdActivateQuest : ICmdCallback {
override fun execute(player: Player, target: SWGObject?, args: String) {
if (player.accessLevel == AccessLevel.PLAYER) {
SystemMessageIntent.broadcastPersonal(player, "Players cannot use this command :(")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:(

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:(

return
}

GrantQuestIntent.broadcast(player, args)
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/***********************************************************************************
* Copyright (c) 2021 /// Project SWG /// www.projectswg.com *
* Copyright (c) 2023 /// Project SWG /// www.projectswg.com *
* *
* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on *
* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. *
Expand Down Expand Up @@ -45,6 +45,8 @@
import com.projectswg.holocore.resources.support.data.server_info.loader.QuestLoader;
import com.projectswg.holocore.resources.support.data.server_info.loader.ServerData;
import com.projectswg.holocore.resources.support.global.player.Player;
import com.projectswg.holocore.resources.support.global.zone.sui.SuiButtons;
import com.projectswg.holocore.resources.support.global.zone.sui.SuiMessageBox;
import com.projectswg.holocore.resources.support.npc.spawn.Spawner;
import com.projectswg.holocore.resources.support.objects.swg.creature.CreatureObject;
import com.projectswg.holocore.resources.support.objects.swg.custom.AIObject;
Expand Down Expand Up @@ -247,10 +249,36 @@ private void handleTaskEvents(Player player, String questName, Collection<QuestL
handleTimer(player, questName, playerObject, currentTask);
break;
}
case "quest.task.ground.show_message_box": {
handleShowMessageBox(player, questName, playerObject, currentTask);
break;
}
}
}
}


private void handleShowMessageBox(Player player, String questName, PlayerObject playerObject, QuestLoader.QuestTaskInfo currentTask) {
String messageBoxTitle = currentTask.getMessageBoxTitle();
String messageBoxText = currentTask.getMessageBoxText();
SuiMessageBox sui = new SuiMessageBox(SuiButtons.OK, messageBoxTitle, messageBoxText);
sui.setSize(384, 256);
sui.setLocation(320, 256);
sui.display(player);

playerObject.removeActiveQuestTask(questName, currentTask.getIndex());
playerObject.addCompleteQuestTask(questName, currentTask.getIndex());

for (Integer taskIndex : currentTask.getNextTasksOnComplete()) {
playerObject.addActiveQuestTask(questName, taskIndex);
}

List<QuestLoader.QuestTaskInfo> taskListInfos = questLoader.getTaskListInfos(questName);
Collection<Integer> nextTasksOnComplete = currentTask.getNextTasksOnComplete();
List<QuestLoader.QuestTaskInfo> nextTasks = mapActiveTasks(nextTasksOnComplete, taskListInfos);

handleTaskEvents(player, questName, nextTasks);
}

private void handleCommPlayer(Player player, String questName, PlayerObject playerObject, QuestLoader.QuestTaskInfo currentTask) {
String commMessageText = currentTask.getCommMessageText();
OutOfBandPackage message = new OutOfBandPackage(new ProsePackage(new StringId(commMessageText)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ private void addAdminScripts() {
registerScriptCallback("cmdInvulnerable", CmdInvulnerable::new);
registerScriptCallback("cmdGrantSkill", CmdGrantSkill::new);
registerScriptCallback("cmdSetFaction", CmdSetFaction::new);
registerScriptCallback("cmdActivateQuest", CmdActivateQuest::new);
}

private void addChatScripts() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,18 @@ public void canLoadTargetServerTemplate() {
assertEquals("imperial_major", taskListInfos.get(1).getTargetServerTemplate());
}

@Test
public void canLoadMessageBoxTitle() {
List<QuestLoader.QuestTaskInfo> taskListInfos = ServerData.INSTANCE.getQuestLoader().getTaskListInfos("quest/c_newbie_start");
assertEquals("@quest/ground/c_newbie_start:task00_message_box_title", taskListInfos.get(0).getMessageBoxTitle());
}

@Test
public void canLoadMessageBoxText() {
List<QuestLoader.QuestTaskInfo> taskListInfos = ServerData.INSTANCE.getQuestLoader().getTaskListInfos("quest/c_newbie_start");
assertEquals("@quest/ground/c_newbie_start:task00_message_box_text", taskListInfos.get(0).getMessageBoxText());
}

@Test
public void canLoadNpcAppearanceServerTemplate() {
assertEquals("object/mobile/boba_fett.iff", taskListInfos.get(5).getNpcAppearanceServerTemplate());
Expand Down
Loading