Added Guild Permissions List, Added setting of permissions via permissions list, minor SUI Table method changes

This commit is contained in:
Waverunner
2014-05-25 14:25:41 -04:00
parent 20302dd880
commit c85eb36eec
7 changed files with 433 additions and 84 deletions

View File

@@ -28,8 +28,9 @@ def createRadial(core, owner, target, radials):
# Guild Management
radials.add(RadialOptions(3, RadialOptions.serverGuildInfo, 3, '@guild:menu_info')) # Guild Information
#radials.add(RadialOptions(3, RadialOptions.serverGuildEnemies, 3, '@guild:menu_enemies')) # Guild Enemies
# TODO: Add Rank List
#radials.add(RadialOptions(3, 215, 3, '@guild:menu_rank_list')) # Rank List
# TODO: Add Rank Summary
radials.add(RadialOptions(3, 217, 3, '@guild:menu_permission_list')) # Permissions List
#if member.hasDisbandPermission():
#radials.add(RadialOptions(3, RadialOptions.serverGuildDisband, 3, '@guild:menu_disband')) # Disband Guild
@@ -71,6 +72,15 @@ def handleSelection(core, owner, target, option):
core.suiService.openSUIWindow(wndGuildInfo)
return
# - Rank List
elif option == 215:
return
# - Permissions List
elif option == 217:
core.guildService.handleViewPermissionsList(owner, guild)
return
# Member Management
# - Guild Members
@@ -87,11 +97,6 @@ def handleSelection(core, owner, target, option):
core.guildService.handleManageSponsoredPlayers(owner)
return
# - Permission List
elif option == RadialOptions.serverTerminalPermissions:
core.guildService.handleGuildPermissionList()
return
# - Transfer PA Leadership
elif option == 69:
return

View File

@@ -60,7 +60,7 @@ public class Guild extends Delta implements Serializable, Comparable<Guild> {
public Guild() { }
public GuildMember addMember(long objID) {
GuildMember member = new GuildMember();
GuildMember member = new GuildMember(objID);
members.put(objID, member);
return member;
}

View File

@@ -23,6 +23,7 @@ package resources.guild;
import java.util.HashMap;
import java.util.Map;
import java.util.Vector;
public class GuildMember {
private long objectId;
@@ -30,8 +31,11 @@ public class GuildMember {
private String profession;
private short level;
private String rank;
private String name;
// TODO: These might have to be moved to a new GuildRank class depending on how permissions worked for NGE
//this works for now... Lack of NGE Guild Rank guides makes re-creation difficult (Ranks introduced Game Update 8: http://swg.wikia.com/wiki/Game_Update_8)
private Vector<String> permissions = new Vector<String>();
private boolean mailPermission = false;
private boolean sponsorPermission = false;
private boolean titlePermission = false;
@@ -40,6 +44,10 @@ public class GuildMember {
private boolean warPermission = false;
private boolean changeNamePermission = false;
private boolean disbandPermission = false;
private boolean rankPermission = false;
private boolean warExcluded = false;
private boolean warExclusive = false;
public GuildMember() { }
@@ -49,25 +57,27 @@ public class GuildMember {
}
public void removeAllPermissions() {
this.mailPermission = false;
this.sponsorPermission = false;
this.titlePermission = false;
this.kickPermission = false;
this.acceptPermission = false;
this.warPermission = false;
this.changeNamePermission = false;
this.disbandPermission = false;
setMailPermission(false);
setSponsorPermission(false);
setTitlePermission(false);
setKickPermission(false);
setAcceptPermission(false);
setWarPermission(false);
setChangeNamePermission(false);
setDisbandPermission(false);
setRankPermission(false);
}
public void giveAllPermissions() {
this.mailPermission = true;
this.sponsorPermission = true;
this.titlePermission = true;
this.kickPermission = true;
this.acceptPermission = true;
this.warPermission = true;
this.changeNamePermission = true;
this.disbandPermission = true;
setMailPermission(true);
setSponsorPermission(true);
setTitlePermission(true);
setKickPermission(true);
setAcceptPermission(true);
setWarPermission(true);
setChangeNamePermission(true);
setDisbandPermission(true);
setRankPermission(true);
}
public long getObjectId() {
@@ -88,6 +98,11 @@ public class GuildMember {
return mailPermission;
}
public void setMailPermission(boolean mailPermission) {
if (mailPermission)
permissions.add("Mail");
else
permissions.remove("Mail");
this.mailPermission = mailPermission;
}
@@ -95,45 +110,116 @@ public class GuildMember {
return sponsorPermission;
}
public void setSponsorPermission(boolean sponsorPermission) {
if (sponsorPermission)
permissions.add("Sponsor");
else
permissions.remove("Sponsor");
this.sponsorPermission = sponsorPermission;
}
public boolean hasTitlePermission() {
return titlePermission;
}
public void setTitlePermission(boolean titlePermission) {
if (titlePermission)
permissions.add("Title");
else
permissions.remove("Title");
this.titlePermission = titlePermission;
}
public boolean hasKickPermission() {
return kickPermission;
}
public void setKickPermission(boolean kickPermission) {
if (kickPermission)
permissions.add("Kick");
else
permissions.remove("Kick");
this.kickPermission = kickPermission;
}
public boolean hasAcceptPermission() {
return acceptPermission;
}
public void setAcceptPermission(boolean acceptPermission) {
if (acceptPermission)
permissions.add("Accept");
else
permissions.remove("Accept");
this.acceptPermission = acceptPermission;
}
public boolean hasWarPermission() {
return warPermission;
}
public void setWarPermission(boolean warPermission) {
if (warPermission)
permissions.add("War");
else
permissions.remove("War");
this.warPermission = warPermission;
}
public boolean hasChangeNamePermission() {
return changeNamePermission;
}
public void setChangeNamePermission(boolean changeNamePermission) {
if (changeNamePermission)
permissions.add("Change Guild Name");
else
permissions.remove("Change Guild Name");
this.changeNamePermission = changeNamePermission;
}
public boolean hasDisbandPermission() {
return disbandPermission;
}
public void setDisbandPermission(boolean disbandPermission) {
if (disbandPermission)
permissions.add("Disband");
else
permissions.remove("Disband");
this.disbandPermission = disbandPermission;
}
public boolean hasRankPermission() {
return rankPermission;
}
public void setRankPermission(boolean rankPermission) {
if (rankPermission)
permissions.add("Rank");
else
permissions.remove("Rank");
this.rankPermission = rankPermission;
}
public boolean isWarExcluded() {
return warExcluded;
}
public void setWarExcluded(boolean warExcluded) {
if (warExcluded)
permissions.add("War Excluded");
else
permissions.remove("War Excluded");
this.warExcluded = warExcluded;
}
public boolean isWarExclusive() {
return warExclusive;
}
public void setWarExclusive(boolean warExclusive) {
if (warExclusive)
permissions.add("War Exclusive");
else
permissions.remove("War Exclusive");
this.warExclusive = warExclusive;
}
public String getProfession() {
return profession;
}
@@ -158,57 +244,80 @@ public class GuildMember {
this.rank = rank;
}
public Map<Long, String> getAllPermissions() {
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Map<Long, String> getAllPermissions(GuildMember requester) {
Map<Long, String> permissions = new HashMap<Long, String>();
permissions.put((long) 1, "@guild:permission_mail");
permissions.put((long) 3, "@guild:permission_sponsor");
permissions.put((long) 5, "@guild:permission_title");
permissions.put((long) 7, "@guild:permission_accept");
permissions.put((long) 9, "@guild:permission_kick");
permissions.put((long) 11, "@guild:permission_war");
permissions.put((long) 13, "@guild:permission_namechange");
permissions.put((long) 15, "@guild:permission_disband");
if (hasMailPermission())
permissions.put((long) 2, "@guild:permission_mail_yes");
else
permissions.put((long) 2, "@guild:permission_mail_no");
if (hasSponsorPermission())
permissions.put((long) 4, "@guild:permission_sponsor_yes");
else
permissions.put((long) 4, "@guild:permission_sponsor_no");
if (hasTitlePermission())
permissions.put((long) 6, "@guild:permission_title_yes");
else
permissions.put((long) 6, "@guild:permission_title_no");
if (hasAcceptPermission())
permissions.put((long) 8, "@guild:permission_accept_yes");
else
permissions.put((long) 8, "@guild:permission_accept_no");
if (hasKickPermission())
permissions.put((long) 10, "@guild:permission_kick_yes");
else
permissions.put((long) 10, "@guild:permission_kick_no");
if (hasWarPermission())
permissions.put((long) 12, "@guild:permission_war_yes");
else
permissions.put((long) 12, "@guild:permission_war_no");
if (hasChangeNamePermission())
permissions.put((long) 14, "@guild:permission_namechange_yes");
else
permissions.put((long) 14, "@guild:permission_namechange_no");
if (hasDisbandPermission())
permissions.put((long) 16, "@guild:permission_disband_yes");
else
permissions.put((long) 16, "@guild:permission_disband_no");
// Only allows requester to change permissions that they have (Ex. Can't change sponsor permission on a member if they don't have that permission)
// War Excluded and War Exclusive did not follow that rule
if (requester.getObjectId() != getObjectId()) {
if (requester.hasMailPermission()) {
if (hasMailPermission()) permissions.put((long) 1, "@guild:permission_mail_yes");
else permissions.put((long) 1, "@guild:permission_mail_no");
}
if (requester.hasSponsorPermission()) {
if (hasSponsorPermission()) permissions.put((long) 2, "@guild:permission_sponsor_yes");
else permissions.put((long) 2, "@guild:permission_sponsor_no");
}
if (requester.hasTitlePermission()) {
if (hasTitlePermission()) permissions.put((long) 3, "@guild:permission_title_yes");
else permissions.put((long) 3, "@guild:permission_title_no");
}
if (requester.hasAcceptPermission()) {
if (hasAcceptPermission()) permissions.put((long) 4, "@guild:permission_accept_yes");
else permissions.put((long) 4, "@guild:permission_accept_no");
}
if (requester.hasKickPermission()) {
if (hasKickPermission()) permissions.put((long) 5, "@guild:permission_kick_yes");
else permissions.put((long) 5, "@guild:permission_kick_no");
}
if (requester.hasWarPermission()) {
if (hasWarPermission()) permissions.put((long) 6, "@guild:permission_war_yes");
else permissions.put((long) 6, "@guild:permission_war_no");
}
if (requester.hasChangeNamePermission()) {
if (hasChangeNamePermission()) permissions.put((long) 7, "@guild:permission_namechange_yes");
else permissions.put((long) 7, "@guild:permission_namechange_no");
}
if (requester.hasDisbandPermission()) {
if (hasDisbandPermission()) permissions.put((long) 8, "@guild:permission_disband_yes");
else permissions.put((long) 8, "@guild:permission_disband_no");
}
if (requester.hasRankPermission()) {
if (hasRankPermission()) permissions.put((long) 9, "@guild:permission_rank_yes");
else permissions.put((long) 9, "@guild:permission_rank_no");
}
}
if (requester.hasWarPermission() || (requester.getObjectId() == getObjectId())) {
if (isWarExcluded()) permissions.put((long) 10, "+ War Excluded");
else permissions.put((long) 10, "- War Excluded");
if (isWarExclusive()) permissions.put((long) 11, "+ War Exclusive");
else permissions.put((long) 11, "- War Exclusive");
}
return permissions;
}
public Vector<String> getPermissions() {
return permissions;
}
public void setPermissions(Vector<String> permissions) {
this.permissions = permissions;
}
}

View File

@@ -41,6 +41,7 @@ import services.chat.Mail;
import services.sui.SUIService.InputBoxType;
import services.sui.SUIService.ListBoxType;
import services.sui.SUIService.MessageBoxType;
import services.sui.SUITableItem;
import services.sui.SUIWindow;
import services.sui.SUIWindow.Trigger;
import main.NGECore;
@@ -132,6 +133,7 @@ public class GuildService implements INetworkDispatch {
}
});
}
member.setName(joinee.getCustomName());
member.setLevel(joinee.getLevel());
if (joinee.getPlayerObject() != null) {
member.setProfession(core.playerService.getFormalProfessionName(joinee.getPlayerObject().getProfession()));
@@ -140,8 +142,144 @@ public class GuildService implements INetworkDispatch {
return member;
}
public void handleGuildPermissionList(CreatureObject actor, Guild guild) {
public void handleViewPermissionsList(CreatureObject actor, Guild guild) {
final SUIWindow window = core.suiService.createSUIWindow("Script.tablePage", actor, null, (float) 0);
window.setProperty("bg.caption.lblTitle:Text", "Permissions List");
window.setProperty("comp.Prompt:Visible", "False");
window.setProperty("btnExport:Visible", "False");
window.setProperty("tablePage:Size", "785,434");
window.setProperty("comp.TablePage.header:ScrollExtent", "444,30");
window.addTableColumn("Name", "text");
window.addTableColumn("Mail", "text");
window.addTableColumn("Sponsor", "text");
window.addTableColumn("Title", "text");
window.addTableColumn("Accept", "text");
window.addTableColumn("Kick", "text");
window.addTableColumn("War", "text");
window.addTableColumn("Change Guild Name", "text");
window.addTableColumn("Disband", "text");
window.addTableColumn("Rank", "text");
window.addTableColumn("War Excluded", "text");
window.addTableColumn("War Exclusive", "text");
Map<Long, GuildMember> members = guild.getMembers();
members.entrySet().forEach(e -> {
GuildMember member = e.getValue();
for (SUITableItem column : window.getTableItems()) {
if (column.getItemName().equals("Name")) {
window.addTableCell(member.getName(), e.getKey(), column.getIndex());
continue;
}
else if (member.getPermissions().contains(column.getItemName())) {
window.addTableCell("X", e.getKey(), column.getIndex());
continue;
} else
window.addTableCell("", e.getKey(), column.getIndex());
}
});
Vector<String> returnList = new Vector<String>();
returnList.add("comp.TablePage.table:SelectedRow");
window.addHandler(0, "", Trigger.TRIGGER_OK, returnList, (owner, eventType, resultList) -> {
int selectedRow = Integer.parseInt(resultList.get(0));
GuildMember selectedMember = guild.getMember(window.getTableObjIdByRow(selectedRow));
if (selectedMember == null)
return;
handleChangeMemberPermissions((CreatureObject) owner, guild, selectedMember, "PermissionsList");
});
core.suiService.openSUIWindow(window);
}
public void handleChangeMemberPermissions(CreatureObject actor, Guild guild, GuildMember target) { handleChangeMemberPermissions(actor, guild, target, "");
}
public void handleChangeMemberPermissions(CreatureObject actor, Guild guild, GuildMember target, String source) {
GuildMember requester = guild.getMember(actor.getObjectID());
if (requester == null)
return;
final SUIWindow window = core.suiService.createListBox(ListBoxType.LIST_BOX_OK_CANCEL, "\\#00FF00\\" + target.getName() + "\\#FFFFFF Guild Member Permissions",
new Stf("@guild:permissions_prompt").getStfValue().replace("%TU", "\\#00FF00\\" + target.getName() + "\\#.\\"), target.getAllPermissions(requester), actor, null, 0);
window.setProperty("listBox:Size", "487,316");
Vector<String> returnList = new Vector<String>();
returnList.add("List.lstList:SelectedRow");
if (!source.isEmpty() || !source.equals("")) {
window.setProperty("btnOther:Visible", "True");
window.setProperty("btnOther:Text", "Back");
window.addHandler(1, "", Trigger.TRIGGER_UPDATE, returnList, (owner, eventType, resultList) -> {
switch(source) {
case "PermissionsList":
handleViewPermissionsList(actor, guild);
break;
}
});
}
window.addHandler(0, "", Trigger.TRIGGER_OK, returnList, (owner, eventType, resultList) -> {
if (resultList.size() == 0)
return;
int selectedPermission = (int) (window.getObjectIdByIndex(Integer.parseInt(resultList.get(0))));
switch (selectedPermission) {
case 1: // Mail
if (target.hasMailPermission()) target.setMailPermission(false);
else target.setMailPermission(true);
break;
case 2: // Sponsor
if (target.hasSponsorPermission()) target.setSponsorPermission(false);
else target.setSponsorPermission(true);
break;
case 3: // Title
if (target.hasTitlePermission()) target.setTitlePermission(false);
else target.setTitlePermission(true);
break;
case 4: // Accept
if (target.hasAcceptPermission()) target.setAcceptPermission(false);
else target.setAcceptPermission(true);
break;
case 5: // Kick
if (target.hasKickPermission()) target.setKickPermission(false);
else target.setKickPermission(true);
break;
case 6: // War
if (target.hasWarPermission()) target.setWarPermission(false);
else target.setWarPermission(true);
break;
case 7: // Change Guild Name
if (target.hasChangeNamePermission()) target.setChangeNamePermission(false);
else target.setChangeNamePermission(true);
break;
case 8: // Disband
if (target.hasDisbandPermission()) target.setDisbandPermission(false);
else target.setDisbandPermission(true);
break;
case 9: // Rank
if (target.hasRankPermission()) target.setRankPermission(false);
else target.setRankPermission(true);
break;
case 10: // War Excluded
if (target.isWarExcluded()) target.setWarExcluded(false);
else target.setWarExcluded(true);
break;
case 11: // War Exclusive
if (target.isWarExclusive()) target.setWarExclusive(false);
else target.setWarExclusive(true);
break;
default: break;
}
handleChangeMemberPermissions(actor, guild, target, source);
});
core.suiService.openSUIWindow(window);
}
public void handleGuildSponsor(CreatureObject actor) {

View File

@@ -0,0 +1,58 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package services.sui;
public class SUITableCell {
private String name;
private long objectId;
private int cellId;
public SUITableCell(String name, long objectId, int cellId) {
this.name = name;
this.objectId = objectId;
this.cellId = cellId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public long getObjectId() {
return objectId;
}
public void setObjectId(long objectId) {
this.objectId = objectId;
}
public int getCellId() {
return cellId;
}
public void setCellId(int cellId) {
this.cellId = cellId;
}
}

View File

@@ -1,9 +1,30 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package services.sui;
import java.util.Vector;
public class SUITableItem {
private Vector<SUITableItem> children = new Vector<SUITableItem>();
private Vector<SUITableCell> cells = new Vector<SUITableCell>();
private String itemName;
private int index;
@@ -14,11 +35,11 @@ public class SUITableItem {
this.setIndex(index);
}
public Vector<SUITableItem> getChildren() {
return children;
public Vector<SUITableCell> getCells() {
return cells;
}
public void setChildren(Vector<SUITableItem> children) {
this.children = children;
public void setCells(Vector<SUITableCell> cells) {
this.cells = cells;
}
public String getItemName() {
return itemName;

View File

@@ -192,13 +192,15 @@ public class SUIWindow {
tableItems.add(item);
}
public void addTableRow(String itemName) {
public void addTableCell(String cellName, long cellObjId, int columnIndex) {
tableItems.forEach(column -> {
int index = column.getIndex();
SUITableItem item = new SUITableItem(itemName, index);
addDataItem("comp.TablePage.dataTable." + index + ":Name", "data" + index);
setProperty("comp.TablePage.dataTable." + index + ".data" + index + ":Value", itemName);
column.getChildren().add(item);
if (column.getIndex() == columnIndex) {
SUITableCell cell = new SUITableCell(cellName, cellObjId, column.getCells().size());
addDataItem("comp.TablePage.dataTable." + columnIndex + ":Name", "data" + cell.getCellId());
setProperty("comp.TablePage.dataTable." + columnIndex + ".data" + cell.getCellId() + ":Value", cellName);
column.getCells().add(cell);
}
});
}
@@ -270,6 +272,22 @@ public class SUIWindow {
return 0;
}
public long getTableObjIdByRow(int row) {
SUITableItem item = getTableItems().get(0);
if (item != null)
return item.getCells().get(row).getObjectId();
return 0;
}
public Vector<SUITableItem> getTableItems() {
return tableItems;
}
public void setTableItems(Vector<SUITableItem> tableItems) {
this.tableItems = tableItems;
}
public enum Trigger {;
public static byte TRIGGER_UPDATE = 4;