From 0da1fd88430ff826079a48bac7be76087669e0d9 Mon Sep 17 00:00:00 2001 From: Waverunner Date: Sat, 17 Jan 2015 23:24:38 -0500 Subject: [PATCH 1/3] Added SuiBaseWindow class for common window tasks (height, titles, prompts) --- src/resources/sui/SuiBaseWindow.java | 28 ++++++++++++++++++++++++++++ src/resources/sui/SuiInputBox.java | 7 ++----- src/resources/sui/SuiListBox.java | 7 ++----- src/resources/sui/SuiMessageBox.java | 8 ++------ 4 files changed, 34 insertions(+), 16 deletions(-) create mode 100644 src/resources/sui/SuiBaseWindow.java diff --git a/src/resources/sui/SuiBaseWindow.java b/src/resources/sui/SuiBaseWindow.java new file mode 100644 index 000000000..20f6b5d3d --- /dev/null +++ b/src/resources/sui/SuiBaseWindow.java @@ -0,0 +1,28 @@ +package resources.sui; + +import resources.player.Player; + +public class SuiBaseWindow extends SuiWindow { + private String windowType; + + public SuiBaseWindow(String script, Player owner, String title, String prompt) { + super(script, owner); + windowType = script.replace("Script.", ""); + setTitle(title); + setPrompt(prompt); + } + + public void setSize(int x, int z) { + setProperty(windowType + ":Size", String.valueOf(x) + "," + String.valueOf(z)); + } + + public void setTitle(String title) { + if (title != null) + setProperty("bg.caption.lblTitle:Text", title); + } + + public void setPrompt(String prompt) { + if (prompt != null) + setProperty("Prompt.lblPrompt:Text", prompt); + } +} diff --git a/src/resources/sui/SuiInputBox.java b/src/resources/sui/SuiInputBox.java index 509763752..4ef0c1e74 100644 --- a/src/resources/sui/SuiInputBox.java +++ b/src/resources/sui/SuiInputBox.java @@ -5,13 +5,10 @@ import java.util.List; import resources.player.Player; -public class SuiInputBox extends SuiWindow { +public class SuiInputBox extends SuiBaseWindow { public SuiInputBox(Player owner, InputBoxType type, String title, String prompt) { - super("Script.inputBox", owner); - setProperty("bg.caption.lblTitle:Text", title); - setProperty("Prompt.lblPrompt:Text", prompt); - + super("Script.inputBox", owner, title, prompt); switch(type){ case OK: setProperty("btnOk:visible", "True"); diff --git a/src/resources/sui/SuiListBox.java b/src/resources/sui/SuiListBox.java index 19ba6c55d..12fb25a10 100644 --- a/src/resources/sui/SuiListBox.java +++ b/src/resources/sui/SuiListBox.java @@ -5,15 +5,12 @@ import java.util.List; import resources.player.Player; -public class SuiListBox extends SuiWindow { +public class SuiListBox extends SuiBaseWindow { private List list; public SuiListBox(Player owner, ListBoxType type, String title, String prompt) { - super("Script.listBox", owner); + super("Script.listBox", owner, title, prompt); list = new ArrayList(); - setProperty("bg.caption.lblTitle:Text", title); - setProperty("Prompt.lblPrompt:Text", prompt); - switch(type) { case OK: setProperty("btnOk:visible", "True"); diff --git a/src/resources/sui/SuiMessageBox.java b/src/resources/sui/SuiMessageBox.java index ef9f2d74b..f9689cd01 100644 --- a/src/resources/sui/SuiMessageBox.java +++ b/src/resources/sui/SuiMessageBox.java @@ -2,14 +2,10 @@ package resources.sui; import resources.player.Player; -public class SuiMessageBox extends SuiWindow { +public class SuiMessageBox extends SuiBaseWindow { public SuiMessageBox(Player owner, MessageBoxType type, String title, String prompt) { - super("Script.messageBox", owner); - - setProperty("bg.caption.lblTitle:Text", title); - setProperty("Prompt.lblPrompt:Text", prompt); - + super("Script.messageBox", owner, title, prompt); switch(type) { case OK: setProperty("btnOk:visible", "True"); From f8d5ff1196e7e60bbce0b5b0a17a37f12e47839d Mon Sep 17 00:00:00 2001 From: Waverunner Date: Sun, 18 Jan 2015 00:09:03 -0500 Subject: [PATCH 2/3] Added SuiTableWindow class --- src/resources/sui/SuiTableWindow.java | 99 +++++++++++++++++++++++++++ src/resources/sui/SuiWindow.java | 12 +++- 2 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 src/resources/sui/SuiTableWindow.java diff --git a/src/resources/sui/SuiTableWindow.java b/src/resources/sui/SuiTableWindow.java new file mode 100644 index 000000000..09fb0bab6 --- /dev/null +++ b/src/resources/sui/SuiTableWindow.java @@ -0,0 +1,99 @@ +package resources.sui; + +import java.util.ArrayList; +import java.util.List; + +import resources.player.Player; + +public class SuiTableWindow extends SuiBaseWindow { + + private List table; + + public SuiTableWindow(Player owner, String title, String prompt) { + super("Script.tablePage", owner, title, prompt); + table = new ArrayList(); + + if (prompt == null) + setProperty("comp.Prompt:Visible", "false"); + } + + public void addColumn(String columnName, String type) { + int index = table.size(); + + SuiTableColumn column = new SuiTableColumn(); + addTableDataSource("comp.TablePage.dataTable:Name", String.valueOf(index)); + setProperty("comp.TablePage.dataTable." + index + ":Label", columnName); + setProperty("comp.TablePage.dataTable." + index + ":Type", type); + + table.add(column); + } + + public void addCell(String cellName, long cellObjId, int columnIndex) { + SuiTableColumn column = table.get(columnIndex); + + if (column == null) + return; + + int cellIndex = column.getCells().size(); + + SuiTableCell cell = new SuiTableCell(cellName, cellObjId); + column.getCells().add(cell); + + addDataItem("comp.TablePage.dataTable." + columnIndex + ":Name", "data" + cellIndex); + setProperty("comp.TablePage.dataTable." + columnIndex + ".data" + cellIndex + ":Value", cellName); + } + + public void addCell(String cellName, int columnIndex) { + addCell(cellName, 0, columnIndex); + } + + public void showExportButton(boolean show) { + setProperty("btnExport:Visible", String.valueOf(show)); + } + + public void setScrollExtent(int x, int z) { + setProperty("comp.TablePage.header:ScrollExtent", String.valueOf(x) + "," + String.valueOf(z)); + } + + public long getCellId(int column, int row) { + SuiTableCell cell = table.get(column).getCells().get(row); + + if (cell == null) return 0; + else return cell.getId(); + } + + public String getCellValue(int column, int row) { + SuiTableCell cell = table.get(column).getCells().get(row); + + if (cell == null) return null; + else return cell.getValue(); + } + + private class SuiTableColumn { + + private List cells; + + public SuiTableColumn(List cells) { + this.cells = cells; + } + + public SuiTableColumn() { + this(new ArrayList()); + } + + public List getCells() { return this.cells; } + } + + private class SuiTableCell { + private String value; + private long id; + + public SuiTableCell(String value, long id) { + this.value = value; + this.id = id; + } + + public String getValue() { return this.value; } + public long getId() { return this.id; } + } +} diff --git a/src/resources/sui/SuiWindow.java b/src/resources/sui/SuiWindow.java index 858be2fb0..90e1b605a 100644 --- a/src/resources/sui/SuiWindow.java +++ b/src/resources/sui/SuiWindow.java @@ -89,7 +89,17 @@ public class SuiWindow { public final void clearDataSourceContainer(String dataSource) { SuiWindowComponent component = createComponent((byte) 7); - component.getNarrowParams().add(dataSource); + addNarrowParams(component, dataSource); + + components.add(component); + } + + public final void addTableDataSource(String dataSource, String value) { + SuiWindowComponent component = createComponent((byte) 8); + + addNarrowParams(component, dataSource); + + component.getWideParams().add(value); components.add(component); } From 241d26a8857a05364d3c1d741de94316b6666faa Mon Sep 17 00:00:00 2001 From: Waverunner Date: Sun, 18 Jan 2015 00:30:38 -0500 Subject: [PATCH 3/3] Added moods for spatial chat messages --- scripts/commands/generic/requestWaypointAtPosition.py | 5 ++++- scripts/commands/generic/spatialChatInternal.py | 4 ++-- src/intents/chat/SpatialChatIntent.java | 5 ++++- src/services/chat/ChatService.java | 6 ++---- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/scripts/commands/generic/requestWaypointAtPosition.py b/scripts/commands/generic/requestWaypointAtPosition.py index 494c2acb6..a1c13ca85 100644 --- a/scripts/commands/generic/requestWaypointAtPosition.py +++ b/scripts/commands/generic/requestWaypointAtPosition.py @@ -2,7 +2,10 @@ import sys #Args: color planet x y z def execute(objManager, player, target, args): - print(args) + #TODO: move content in placeHolder method to here + return + +def placeHolder(): cmdArgs = args.split(" ", 4) waypoint = objManager.createObject("object/waypoint/shared_waypoint.iff") diff --git a/scripts/commands/generic/spatialChatInternal.py b/scripts/commands/generic/spatialChatInternal.py index 5d7ba4db5..43ee099d1 100644 --- a/scripts/commands/generic/spatialChatInternal.py +++ b/scripts/commands/generic/spatialChatInternal.py @@ -3,8 +3,8 @@ import sys #Args: unkInt chatType moodId unkInt2 langId message def execute(objManager, player, target, args): + cmdArgs = args.split(' ', 5) #print ('unkInt=' + cmdArgs[0] + ' chatType=' + cmdArgs[1] + ' moodId=' + cmdArgs[2] + ' unkInt2=' + cmdArgs[3] + ' langId=' + cmdArgs[4]) - cmdArgs = args.split(' ', 5) - SpatialChatIntent(player, int(cmdArgs[1]), cmdArgs[5]).broadcast() + SpatialChatIntent(player, int(cmdArgs[1]), cmdArgs[5], int(cmdArgs[2])).broadcast() return \ No newline at end of file diff --git a/src/intents/chat/SpatialChatIntent.java b/src/intents/chat/SpatialChatIntent.java index df0034132..f7edb86ff 100644 --- a/src/intents/chat/SpatialChatIntent.java +++ b/src/intents/chat/SpatialChatIntent.java @@ -9,15 +9,18 @@ public class SpatialChatIntent extends Intent { private Player player; private String message; private int chatType; + private int moodId; - public SpatialChatIntent(Player player, int chatType, String message) { + public SpatialChatIntent(Player player, int chatType, String message, int moodId) { super(TYPE); this.player = player; this.message = message; this.chatType = chatType; + this.moodId = moodId; } public Player getPlayer() { return player; } public String getMessage() { return message; } public int getChatType() { return chatType; } + public int getMoodId() { return moodId; } } diff --git a/src/services/chat/ChatService.java b/src/services/chat/ChatService.java index f86d37c85..dad390b52 100644 --- a/src/services/chat/ChatService.java +++ b/src/services/chat/ChatService.java @@ -102,11 +102,9 @@ public class ChatService extends Service { // TODO: Moods and emotes, also figure out one of the unknown ints. Might be that "Player A says to Player B" is one of the unknowns. (targetId in SpatialChat packet) Player sender = i.getPlayer(); SWGObject actor = sender.getCreatureObject(); - String chatMsg = i.getMessage(); - int chatType = i.getChatType(); - + // Send to self - SpatialChat message = new SpatialChat(actor.getObjectId(), 0, chatMsg, chatType); + SpatialChat message = new SpatialChat(actor.getObjectId(), 0, i.getMessage(), i.getChatType(), i.getMoodId()); ObjectController controller = new ObjectController(244, actor.getObjectId(), message); sender.sendPacket(controller);