Reworked storing key bindings.

This commit is contained in:
MobiusDev 2017-11-13 15:42:25 +00:00
parent d076494f9f
commit 65ff1ead8a
55 changed files with 175 additions and 4965 deletions

View File

@ -1,12 +0,0 @@
DROP TABLE IF EXISTS `character_ui_actions`;
CREATE TABLE IF NOT EXISTS `character_ui_actions` (
`charId` int(10) unsigned NOT NULL DEFAULT '0',
`cat` tinyint(4) NOT NULL,
`order` tinyint(4) NOT NULL,
`cmd` int(8) NOT NULL DEFAULT '0',
`key` int(8) NOT NULL,
`tgKey1` int(8) DEFAULT NULL,
`tgKey2` int(8) DEFAULT NULL,
`show` tinyint(4) NOT NULL,
PRIMARY KEY (`charId`,`cat`,`cmd`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

View File

@ -1,8 +0,0 @@
DROP TABLE IF EXISTS `character_ui_categories`;
CREATE TABLE IF NOT EXISTS `character_ui_categories` (
`charId` int(10) unsigned NOT NULL DEFAULT '0',
`catId` tinyint(4) NOT NULL,
`order` tinyint(4) NOT NULL,
`cmdId` int(8) NOT NULL DEFAULT '0',
PRIMARY KEY (`charId`,`catId`,`order`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

View File

@ -1,346 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../xsd/ui.xsd">
<category id="0">
<commands>
<cmd>71</cmd>
<cmd>65</cmd>
<cmd>77</cmd>
<cmd>73</cmd>
<cmd>78</cmd>
<cmd>71</cmd>
<cmd>83</cmd>
<cmd>84</cmd>
<cmd>65</cmd>
<cmd>84</cmd>
<cmd>69</cmd>
<cmd>83</cmd>
<cmd>72</cmd>
<cmd>79</cmd>
<cmd>82</cmd>
<cmd>84</cmd>
<cmd>67</cmd>
<cmd>85</cmd>
<cmd>84</cmd>
<cmd>0</cmd>
</commands>
<keys>
<key cmd="59" key="67" toggleKey1="18" />
<key cmd="60" key="66" toggleKey1="18" />
<key cmd="62" key="74" toggleKey1="18" />
<key cmd="63" key="78" toggleKey1="18" />
<key cmd="64" key="84" toggleKey1="18" />
<key cmd="65" key="72" toggleKey1="18" toggleKey2="16" />
<key cmd="66" key="86" toggleKey1="18" />
<key cmd="67" key="82" toggleKey1="18" />
<key cmd="68" key="75" toggleKey1="18" />
<key cmd="78" key="77" toggleKey1="18" toggleKey2="16" />
<key cmd="70" key="77" toggleKey1="18" />
<key cmd="71" key="79" toggleKey1="18" toggleKey2="16" />
<key cmd="72" key="80" toggleKey1="18" toggleKey2="16" />
<key cmd="73" key="85" toggleKey1="18" />
<key cmd="74" key="82" toggleKey1="18" toggleKey2="16" />
<key cmd="75" key="83" toggleKey1="18" toggleKey2="16" />
<key cmd="76" key="88" toggleKey1="18" />
<key cmd="77" key="73" toggleKey1="18" toggleKey2="16" />
<key cmd="79" key="190" toggleKey1="18" />
<key cmd="80" key="69" toggleKey1="18" toggleKey2="16" />
<key cmd="81" key="76" toggleKey1="18" />
<key cmd="1" key="33" toggleKey1="18" />
<key cmd="2" key="34" toggleKey1="18" />
<key cmd="3" key="27" />
<key cmd="4" key="13" />
<key cmd="5" key="9" />
<key cmd="6" key="72" toggleKey1="18" />
<key cmd="7" key="87" toggleKey1="18" />
<key cmd="10" key="70" toggleKey1="18" />
<key cmd="11" key="80" toggleKey1="18" />
<key cmd="12" key="89" toggleKey1="18" />
<key cmd="49" key="112" toggleKey1="18" />
<key cmd="50" key="113" toggleKey1="18" />
<key cmd="51" key="114" toggleKey1="18" />
<key cmd="52" key="115" toggleKey1="18" />
<key cmd="53" key="116" toggleKey1="18" />
<key cmd="54" key="117" toggleKey1="18" />
<key cmd="55" key="118" toggleKey1="18" />
<key cmd="56" key="119" toggleKey1="18" />
<key cmd="57" key="120" toggleKey1="18" />
<key cmd="58" key="121" toggleKey1="18" />
<key cmd="13" key="112" />
<key cmd="14" key="113" />
<key cmd="15" key="114" />
<key cmd="16" key="115" />
<key cmd="17" key="116" />
<key cmd="18" key="117" />
<key cmd="19" key="118" />
<key cmd="20" key="119" />
<key cmd="21" key="120" />
<key cmd="22" key="121" />
<key cmd="23" key="122" />
<key cmd="24" key="123" />
<key cmd="25" key="49" toggleKey1="18" />
<key cmd="26" key="50" toggleKey1="18" />
<key cmd="27" key="51" toggleKey1="18" />
<key cmd="28" key="52" toggleKey1="18" />
<key cmd="29" key="53" toggleKey1="18" />
<key cmd="30" key="54" toggleKey1="18" />
<key cmd="31" key="55" toggleKey1="18" />
<key cmd="32" key="56" toggleKey1="18" />
<key cmd="33" key="57" toggleKey1="18" />
<key cmd="34" key="48" toggleKey1="18" />
<key cmd="35" key="189" toggleKey1="18" />
<key cmd="36" key="187" toggleKey1="18" />
<key cmd="37" key="97" toggleKey1="18" />
<key cmd="38" key="98" toggleKey1="18" />
<key cmd="39" key="99" toggleKey1="18" />
<key cmd="40" key="100" toggleKey1="18" />
<key cmd="41" key="101" toggleKey1="18" />
<key cmd="42" key="102" toggleKey1="18" />
<key cmd="43" key="103" toggleKey1="18" />
<key cmd="44" key="104" toggleKey1="18" />
<key cmd="45" key="105" toggleKey1="18" />
<key cmd="46" key="96" toggleKey1="18" />
<key cmd="47" key="111" toggleKey1="18" />
<key cmd="48" key="106" toggleKey1="18" />
<key cmd="92" key="32" toggleKey1="18" />
<key cmd="93" key="33" />
<key cmd="94" key="34" />
<key cmd="95" key="36" />
<key cmd="89" key="35" />
<key cmd="86" key="46" />
</keys>
</category>
<category id="1">
<commands>
<cmd>71</cmd>
<cmd>65</cmd>
<cmd>77</cmd>
<cmd>73</cmd>
<cmd>78</cmd>
<cmd>71</cmd>
<cmd>83</cmd>
<cmd>84</cmd>
<cmd>65</cmd>
<cmd>84</cmd>
<cmd>69</cmd>
<cmd>0</cmd>
</commands>
<keys>
<key cmd="59" key="67" />
<key cmd="60" key="66" />
<key cmd="63" key="78" />
<key cmd="64" key="84" />
<key cmd="66" key="86" />
<key cmd="67" key="82" />
<key cmd="68" key="75" />
<key cmd="70" key="77" />
<key cmd="73" key="85" />
<key cmd="76" key="88" />
<key cmd="79" key="190" />
<key cmd="80" key="69" />
<key cmd="13" key="112" />
<key cmd="14" key="113" />
<key cmd="15" key="114" />
<key cmd="16" key="115" />
<key cmd="17" key="116" />
<key cmd="18" key="117" />
<key cmd="19" key="118" />
<key cmd="20" key="119" />
<key cmd="21" key="120" />
<key cmd="22" key="121" />
<key cmd="23" key="122" />
<key cmd="24" key="123" />
<key cmd="25" key="49" />
<key cmd="26" key="50" />
<key cmd="27" key="51" />
<key cmd="28" key="52" />
<key cmd="29" key="53" />
<key cmd="30" key="54" />
<key cmd="31" key="55" />
<key cmd="32" key="56" />
<key cmd="33" key="57" />
<key cmd="34" key="48" />
<key cmd="35" key="189" />
<key cmd="36" key="187" />
<key cmd="37" key="97" />
<key cmd="38" key="98" />
<key cmd="39" key="99" />
<key cmd="40" key="100" />
<key cmd="41" key="101" />
<key cmd="42" key="102" />
<key cmd="43" key="103" />
<key cmd="44" key="104" />
<key cmd="45" key="105" />
<key cmd="46" key="96" />
<key cmd="47" key="111" />
<key cmd="48" key="106" />
<key cmd="82" key="65" />
<key cmd="83" key="68" />
<key cmd="84" key="87" />
<key cmd="85" key="83" />
<key cmd="86" key="46" />
<key cmd="96" key="65" showType="3" />
<key cmd="97" key="68" showType="3" />
<key cmd="98" key="87" showType="3" />
<key cmd="99" key="83" showType="3" />
</keys>
</category>
<category id="2">
<commands>
<cmd>84</cmd>
<cmd>69</cmd>
<cmd>77</cmd>
<cmd>80</cmd>
<cmd>83</cmd>
<cmd>84</cmd>
<cmd>65</cmd>
<cmd>84</cmd>
<cmd>69</cmd>
<cmd>83</cmd>
<cmd>72</cmd>
<cmd>79</cmd>
<cmd>82</cmd>
<cmd>84</cmd>
<cmd>67</cmd>
<cmd>85</cmd>
<cmd>84</cmd>
<cmd>0</cmd>
</commands>
<keys>
<key cmd="59" key="67" />
<key cmd="60" key="66" />
<key cmd="63" key="78" />
<key cmd="64" key="84" />
<key cmd="66" key="86" />
<key cmd="67" key="82" />
<key cmd="68" key="75" />
<key cmd="70" key="77" />
<key cmd="73" key="85" />
<key cmd="76" key="88" />
<key cmd="79" key="190" />
<key cmd="128" key="49" />
<key cmd="129" key="50" />
<key cmd="130" key="51" />
<key cmd="131" key="52" />
<key cmd="132" key="53" />
<key cmd="133" key="54" />
<key cmd="134" key="55" />
<key cmd="135" key="56" />
<key cmd="136" key="57" />
<key cmd="137" key="48" />
<key cmd="138" key="189" />
<key cmd="139" key="187" />
<key cmd="140" key="32" />
<key cmd="86" key="46" />
<key cmd="82" key="65" />
<key cmd="83" key="68" />
<key cmd="84" key="87" />
<key cmd="152" key="83" />
<key cmd="143" key="69" />
<key cmd="144" key="81" />
<key cmd="96" key="65" showType="3" />
<key cmd="97" key="68" showType="3" />
<key cmd="98" key="87" showType="3" />
<key cmd="147" key="69" showType="3" />
<key cmd="148" key="81" showType="3" />
<key cmd="93" key="33" />
<key cmd="94" key="34" />
<key cmd="95" key="36" />
</keys>
</category>
<category id="3">
<keys>
<key cmd="59" key="67" />
<key cmd="60" key="66" />
<key cmd="63" key="78" />
<key cmd="64" key="84" />
<key cmd="66" key="86" />
<key cmd="67" key="82" />
<key cmd="68" key="75" />
<key cmd="70" key="77" />
<key cmd="73" key="85" />
<key cmd="76" key="88" />
<key cmd="79" key="190" />
<key cmd="116" key="49" />
<key cmd="117" key="50" />
<key cmd="118" key="51" />
<key cmd="119" key="52" />
<key cmd="120" key="53" />
<key cmd="121" key="54" />
<key cmd="122" key="55" />
<key cmd="123" key="56" />
<key cmd="124" key="57" />
<key cmd="125" key="48" />
<key cmd="126" key="189" />
<key cmd="127" key="187" />
<key cmd="140" key="32" />
<key cmd="86" key="46" />
<key cmd="145" key="106" />
<key cmd="82" key="65" />
<key cmd="83" key="68" />
<key cmd="84" key="87" />
<key cmd="151" key="83" />
<key cmd="141" key="69" />
<key cmd="142" key="81" />
<key cmd="96" key="65" showType="3" />
<key cmd="97" key="68" showType="3" />
<key cmd="98" key="87" showType="3" />
<key cmd="147" key="69" showType="3" />
<key cmd="148" key="81" showType="3" />
<key cmd="93" key="33" />
<key cmd="94" key="34" />
<key cmd="95" key="36" />
</keys>
</category>
<category id="4">
<commands>
<cmd>70</cmd>
<cmd>76</cmd>
<cmd>73</cmd>
<cmd>71</cmd>
<cmd>72</cmd>
<cmd>84</cmd>
<cmd>83</cmd>
<cmd>84</cmd>
<cmd>65</cmd>
<cmd>84</cmd>
<cmd>69</cmd>
<cmd>83</cmd>
<cmd>72</cmd>
<cmd>79</cmd>
<cmd>82</cmd>
<cmd>84</cmd>
<cmd>67</cmd>
<cmd>85</cmd>
<cmd>84</cmd>
<cmd>0</cmd>
</commands>
</category>
<category id="6">
<commands>
<cmd>70</cmd>
<cmd>76</cmd>
<cmd>73</cmd>
<cmd>71</cmd>
<cmd>72</cmd>
<cmd>84</cmd>
<cmd>84</cmd>
<cmd>82</cmd>
<cmd>65</cmd>
<cmd>78</cmd>
<cmd>83</cmd>
<cmd>70</cmd>
<cmd>79</cmd>
<cmd>82</cmd>
<cmd>77</cmd>
<cmd>83</cmd>
<cmd>72</cmd>
<cmd>79</cmd>
<cmd>82</cmd>
<cmd>84</cmd>
<cmd>67</cmd>
<cmd>85</cmd>
<cmd>84</cmd>
<cmd>0</cmd>
</commands>
</category>
</list>

View File

@ -1,38 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="list">
<xs:complexType>
<xs:sequence minOccurs="1" maxOccurs="1">
<xs:element name="category" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence minOccurs="1" maxOccurs="1">
<xs:element name="commands" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence minOccurs="1" maxOccurs="1">
<xs:element name="cmd" minOccurs="1" maxOccurs="unbounded" type="xs:nonNegativeInteger" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="keys" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence minOccurs="1" maxOccurs="1">
<xs:element name="key" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="cmd" type="xs:positiveInteger" use="required" />
<xs:attribute name="key" type="xs:positiveInteger" use="required" />
<xs:attribute name="toggleKey1" type="xs:nonNegativeInteger" />
<xs:attribute name="toggleKey2" type="xs:nonNegativeInteger" />
<xs:attribute name="showType" type="xs:positiveInteger" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:nonNegativeInteger" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

View File

@ -90,7 +90,6 @@ import com.l2jmobius.gameserver.data.xml.impl.SpawnsData;
import com.l2jmobius.gameserver.data.xml.impl.StaticObjectData;
import com.l2jmobius.gameserver.data.xml.impl.TeleportersData;
import com.l2jmobius.gameserver.data.xml.impl.TransformData;
import com.l2jmobius.gameserver.data.xml.impl.UIData;
import com.l2jmobius.gameserver.datatables.AugmentationData;
import com.l2jmobius.gameserver.datatables.BotReportTable;
import com.l2jmobius.gameserver.datatables.EventDroplist;
@ -307,7 +306,6 @@ public class GameServer
CrestTable.getInstance();
TeleportLocationTable.getInstance();
TeleportersData.getInstance();
UIData.getInstance();
MatchingRoomManager.getInstance();
PetitionManager.getInstance();
CursedWeaponsManager.getInstance();

View File

@ -1,194 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU 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
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.data.xml.impl;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.gameserver.model.ActionKey;
/**
* UI Data parser.
* @author Zoey76
*/
public class UIData implements IGameXmlReader
{
private static final Logger LOGGER = Logger.getLogger(UIData.class.getName());
private final Map<Integer, List<ActionKey>> _storedKeys = new HashMap<>();
private final Map<Integer, List<Integer>> _storedCategories = new HashMap<>();
protected UIData()
{
load();
}
@Override
public void load()
{
_storedKeys.clear();
_storedCategories.clear();
parseDatapackFile("data/ui/ui_en.xml");
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _storedKeys.size() + " keys " + _storedCategories.size() + " categories.");
}
@Override
public void parseDocument(Document doc, File f)
{
for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling())
{
if ("list".equalsIgnoreCase(n.getNodeName()))
{
for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
{
if ("category".equalsIgnoreCase(d.getNodeName()))
{
parseCategory(d);
}
}
}
}
}
private void parseCategory(Node n)
{
final int cat = parseInteger(n.getAttributes(), "id");
for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
{
if ("commands".equalsIgnoreCase(d.getNodeName()))
{
parseCommands(cat, d);
}
else if ("keys".equalsIgnoreCase(d.getNodeName()))
{
parseKeys(cat, d);
}
}
}
private void parseCommands(int cat, Node d)
{
for (Node c = d.getFirstChild(); c != null; c = c.getNextSibling())
{
if ("cmd".equalsIgnoreCase(c.getNodeName()))
{
addCategory(_storedCategories, cat, Integer.parseInt(c.getTextContent()));
}
}
}
private void parseKeys(int cat, Node d)
{
for (Node c = d.getFirstChild(); c != null; c = c.getNextSibling())
{
if ("key".equalsIgnoreCase(c.getNodeName()))
{
final ActionKey akey = new ActionKey(cat);
for (int i = 0; i < c.getAttributes().getLength(); i++)
{
final Node att = c.getAttributes().item(i);
final int val = Integer.parseInt(att.getNodeValue());
switch (att.getNodeName())
{
case "cmd":
{
akey.setCommandId(val);
break;
}
case "key":
{
akey.setKeyId(val);
break;
}
case "toggleKey1":
{
akey.setToogleKey1(val);
break;
}
case "toggleKey2":
{
akey.setToogleKey2(val);
break;
}
case "showType":
{
akey.setShowStatus(val);
break;
}
}
}
addKey(_storedKeys, cat, akey);
}
}
}
/**
* Add a category to the stored categories.
* @param map the map to store the category
* @param cat the category
* @param cmd the command
*/
public static void addCategory(Map<Integer, List<Integer>> map, int cat, int cmd)
{
map.computeIfAbsent(cat, k -> new ArrayList<>()).add(cmd);
}
/**
* Create and insert an Action Key into the stored keys.
* @param map the map to store the key
* @param cat the category
* @param akey the action key
*/
public static void addKey(Map<Integer, List<ActionKey>> map, int cat, ActionKey akey)
{
map.computeIfAbsent(cat, k -> new ArrayList<>()).add(akey);
}
/**
* @return the categories
*/
public Map<Integer, List<Integer>> getCategories()
{
return _storedCategories;
}
/**
* @return the keys
*/
public Map<Integer, List<ActionKey>> getKeys()
{
return _storedKeys;
}
public static UIData getInstance()
{
return SingletonHolder._instance;
}
private static class SingletonHolder
{
protected static final UIData _instance = new UIData();
}
}

View File

@ -55,8 +55,6 @@ public abstract class IdFactory
"SELECT charId FROM character_skills WHERE charId >= ? AND charId < ?",
"SELECT charId FROM character_skills_save WHERE charId >= ? AND charId < ?",
"SELECT charId FROM character_subclasses WHERE charId >= ? AND charId < ?",
"SELECT charId FROM character_ui_actions WHERE charId >= ? AND charId < ?",
"SELECT charId FROM character_ui_categories WHERE charId >= ? AND charId < ?",
"SELECT charId FROM characters WHERE charId >= ? AND charId < ?",
"SELECT clanid FROM characters WHERE clanid >= ? AND clanid < ?",
"SELECT clan_id FROM clan_data WHERE clan_id >= ? AND clan_id < ?",
@ -192,8 +190,6 @@ public abstract class IdFactory
cleanCount += stmt.executeUpdate("DELETE FROM character_skills_save WHERE character_skills_save.charId NOT IN (SELECT charId FROM characters);");
cleanCount += stmt.executeUpdate("DELETE FROM character_subclasses WHERE character_subclasses.charId NOT IN (SELECT charId FROM characters);");
cleanCount += stmt.executeUpdate("DELETE FROM character_instance_time WHERE character_instance_time.charId NOT IN (SELECT charId FROM characters);");
cleanCount += stmt.executeUpdate("DELETE FROM character_ui_actions WHERE character_ui_actions.charId NOT IN (SELECT charId FROM characters);");
cleanCount += stmt.executeUpdate("DELETE FROM character_ui_categories WHERE character_ui_categories.charId NOT IN (SELECT charId FROM characters);");
// Items
cleanCount += stmt.executeUpdate("DELETE FROM items WHERE items.owner_id NOT IN (SELECT charId FROM characters) AND items.owner_id NOT IN (SELECT clan_id FROM clan_data) AND items.owner_id != -1;");

View File

@ -1,213 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU 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
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.data.xml.impl.UIData;
/**
* UI Keys Settings class.
* @author mrTJO, Zoey76
*/
public class UIKeysSettings
{
private static final Logger _log = Logger.getLogger(UIKeysSettings.class.getName());
private final int _playerObjId;
private Map<Integer, List<ActionKey>> _storedKeys;
private Map<Integer, List<Integer>> _storedCategories;
private boolean _saved = true;
public UIKeysSettings(int playerObjId)
{
_playerObjId = playerObjId;
loadFromDB();
}
public void storeAll(Map<Integer, List<Integer>> catMap, Map<Integer, List<ActionKey>> keyMap)
{
_saved = false;
_storedCategories = catMap;
_storedKeys = keyMap;
}
public void storeCategories(Map<Integer, List<Integer>> catMap)
{
_saved = false;
_storedCategories = catMap;
}
public Map<Integer, List<Integer>> getCategories()
{
return _storedCategories;
}
public void storeKeys(Map<Integer, List<ActionKey>> keyMap)
{
_saved = false;
_storedKeys = keyMap;
}
public Map<Integer, List<ActionKey>> getKeys()
{
return _storedKeys;
}
public void loadFromDB()
{
getCatsFromDB();
getKeysFromDB();
}
/**
* Save Categories and Mapped Keys into GameServer DataBase
*/
public void saveInDB()
{
String query;
if (_saved)
{
return;
}
query = "REPLACE INTO character_ui_categories (`charId`, `catId`, `order`, `cmdId`) VALUES ";
for (int category : _storedCategories.keySet())
{
int order = 0;
for (int key : _storedCategories.get(category))
{
query += "(" + _playerObjId + ", " + category + ", " + (order++) + ", " + key + "),";
}
}
query = query.substring(0, query.length() - 1) + "; ";
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(query))
{
statement.execute();
}
catch (Exception e)
{
_log.log(Level.WARNING, "Exception: saveInDB(): " + e.getMessage(), e);
}
query = "REPLACE INTO character_ui_actions (`charId`, `cat`, `order`, `cmd`, `key`, `tgKey1`, `tgKey2`, `show`) VALUES";
for (List<ActionKey> keyLst : _storedKeys.values())
{
int order = 0;
for (ActionKey key : keyLst)
{
query += key.getSqlSaveString(_playerObjId, order++) + ",";
}
}
query = query.substring(0, query.length() - 1) + ";";
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(query))
{
statement.execute();
}
catch (Exception e)
{
_log.log(Level.WARNING, "Exception: saveInDB(): " + e.getMessage(), e);
}
_saved = true;
}
public void getCatsFromDB()
{
if (_storedCategories != null)
{
return;
}
_storedCategories = new HashMap<>();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement stmt = con.prepareStatement("SELECT * FROM character_ui_categories WHERE `charId` = ? ORDER BY `catId`, `order`"))
{
stmt.setInt(1, _playerObjId);
try (ResultSet rs = stmt.executeQuery())
{
while (rs.next())
{
UIData.addCategory(_storedCategories, rs.getInt("catId"), rs.getInt("cmdId"));
}
}
}
catch (Exception e)
{
_log.log(Level.WARNING, "Exception: getCatsFromDB(): " + e.getMessage(), e);
}
if (_storedCategories.isEmpty())
{
_storedCategories = UIData.getInstance().getCategories();
}
}
public void getKeysFromDB()
{
if (_storedKeys != null)
{
return;
}
_storedKeys = new HashMap<>();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement stmt = con.prepareStatement("SELECT * FROM character_ui_actions WHERE `charId` = ? ORDER BY `cat`, `order`"))
{
stmt.setInt(1, _playerObjId);
try (ResultSet rs = stmt.executeQuery())
{
while (rs.next())
{
final int cat = rs.getInt("cat");
final int cmd = rs.getInt("cmd");
final int key = rs.getInt("key");
final int tgKey1 = rs.getInt("tgKey1");
final int tgKey2 = rs.getInt("tgKey2");
final int show = rs.getInt("show");
UIData.addKey(_storedKeys, cat, new ActionKey(cat, cmd, key, tgKey1, tgKey2, show));
}
}
}
catch (Exception e)
{
_log.log(Level.WARNING, "Exception: getKeysFromDB(): " + e.getMessage(), e);
}
if (_storedKeys.isEmpty())
{
_storedKeys = UIData.getInstance().getKeys();
}
}
public boolean isSaved()
{
return _saved;
}
}

View File

@ -149,7 +149,6 @@ import com.l2jmobius.gameserver.model.TeleportBookmark;
import com.l2jmobius.gameserver.model.TeleportWhereType;
import com.l2jmobius.gameserver.model.TimeStamp;
import com.l2jmobius.gameserver.model.TradeList;
import com.l2jmobius.gameserver.model.UIKeysSettings;
import com.l2jmobius.gameserver.model.actor.L2Attackable;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Npc;
@ -846,9 +845,6 @@ public final class L2PcInstance extends L2Playable
_PvPRegTask = null;
}
// Character UI
private UIKeysSettings _uiKeySettings;
// Save responder name for log it
private String _lastPetitionGmName = null;
@ -6811,11 +6807,6 @@ public final class L2PcInstance extends L2Playable
player.restoreFriendList();
if (Config.STORE_UI_SETTINGS)
{
player.restoreUISettings();
}
player.loadRecommendations();
player.startRecoGiveTask();
player.startOnlineTimeUpdateTask();
@ -7093,10 +7084,6 @@ public final class L2PcInstance extends L2Playable
{
storeRecipeShopList();
}
if (Config.STORE_UI_SETTINGS)
{
storeUISettings();
}
final PlayerVariables vars = getScript(PlayerVariables.class);
if (vars != null)
@ -12682,29 +12669,6 @@ public final class L2PcInstance extends L2Playable
return super.isMovementDisabled() || (getMovieHolder() != null) || _fishing.isFishing();
}
private void restoreUISettings()
{
_uiKeySettings = new UIKeysSettings(getObjectId());
}
private void storeUISettings()
{
if (_uiKeySettings == null)
{
return;
}
if (!_uiKeySettings.isSaved())
{
_uiKeySettings.saveInDB();
}
}
public UIKeysSettings getUISettings()
{
return _uiKeySettings;
}
public String getHtmlPrefix()
{
if (!Config.MULTILANG_ENABLE)

View File

@ -16,64 +16,30 @@
*/
package com.l2jmobius.gameserver.network.clientpackets;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.l2jmobius.Config;
import com.l2jmobius.commons.network.PacketReader;
import com.l2jmobius.gameserver.data.xml.impl.UIData;
import com.l2jmobius.gameserver.model.ActionKey;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.ConnectionState;
import com.l2jmobius.gameserver.network.L2GameClient;
/**
* Request Save Key Mapping client packet.
* @author mrTJO, Zoey76
* @author Mobius
*/
public class RequestSaveKeyMapping implements IClientIncomingPacket
{
private final Map<Integer, List<ActionKey>> _keyMap = new HashMap<>();
private final Map<Integer, List<Integer>> _catMap = new HashMap<>();
public static final String UI_KEY_MAPPING_VAR = "UI_KEY_MAPPING";
public static final String SPLIT_VAR = " ";
private byte[] _uiKeyMapping;
@Override
public boolean read(L2GameClient client, PacketReader packet)
{
int category = 0;
packet.readD(); // Unknown
packet.readD(); // Unknown
final int _tabNum = packet.readD();
for (int i = 0; i < _tabNum; i++)
final int dataSize = packet.readD();
if (dataSize > 0)
{
final int cmd1Size = packet.readC();
for (int j = 0; j < cmd1Size; j++)
{
UIData.addCategory(_catMap, category, packet.readC());
}
category++;
final int cmd2Size = packet.readC();
for (int j = 0; j < cmd2Size; j++)
{
UIData.addCategory(_catMap, category, packet.readC());
}
category++;
final int cmdSize = packet.readD();
for (int j = 0; j < cmdSize; j++)
{
final int cmd = packet.readD();
final int key = packet.readD();
final int tgKey1 = packet.readD();
final int tgKey2 = packet.readD();
final int show = packet.readD();
UIData.addKey(_keyMap, i, new ActionKey(i, cmd, key, tgKey1, tgKey2, show));
}
_uiKeyMapping = packet.readB(dataSize);
}
packet.readD();
packet.readD();
return true;
}
@ -81,10 +47,19 @@ public class RequestSaveKeyMapping implements IClientIncomingPacket
public void run(L2GameClient client)
{
final L2PcInstance player = client.getActiveChar();
if (!Config.STORE_UI_SETTINGS || (player == null) || (client.getConnectionState() != ConnectionState.IN_GAME))
if (!Config.STORE_UI_SETTINGS || //
(player == null) || //
(_uiKeyMapping == null) || //
(client.getConnectionState() != ConnectionState.IN_GAME))
{
return;
}
player.getUISettings().storeAll(_catMap, _keyMap);
String uiKeyMapping = "";
for (Byte b : _uiKeyMapping)
{
uiKeyMapping += b + SPLIT_VAR;
}
player.getVariables().set(UI_KEY_MAPPING_VAR, uiKeyMapping);
}
}

View File

@ -16,124 +16,44 @@
*/
package com.l2jmobius.gameserver.network.serverpackets;
import java.util.List;
import com.l2jmobius.commons.network.PacketWriter;
import com.l2jmobius.gameserver.model.ActionKey;
import com.l2jmobius.gameserver.model.UIKeysSettings;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.OutgoingPackets;
/**
* @author mrTJO
* @author Mobius
*/
public class ExUISetting implements IClientOutgoingPacket
{
private final UIKeysSettings _uiSettings;
private int buffsize, categories;
public static final String UI_KEY_MAPPING_VAR = "UI_KEY_MAPPING";
public static final String SPLIT_VAR = " ";
private final byte[] _uiKeyMapping;
public ExUISetting(L2PcInstance player)
{
_uiSettings = player.getUISettings();
calcSize();
}
private void calcSize()
{
int size = 16; // initial header and footer
int category = 0;
final int numKeyCt = _uiSettings.getKeys().size();
for (int i = 0; i < numKeyCt; i++)
if (player.getVariables().hasVariable(UI_KEY_MAPPING_VAR))
{
size++;
if (_uiSettings.getCategories().containsKey(category))
{
final List<Integer> catElList1 = _uiSettings.getCategories().get(category);
size = size + catElList1.size();
}
category++;
size++;
if (_uiSettings.getCategories().containsKey(category))
{
final List<Integer> catElList2 = _uiSettings.getCategories().get(category);
size = size + catElList2.size();
}
category++;
size = size + 4;
if (_uiSettings.getKeys().containsKey(i))
{
final List<ActionKey> keyElList = _uiSettings.getKeys().get(i);
size = size + (keyElList.size() * 20);
}
_uiKeyMapping = player.getVariables().getByteArray(UI_KEY_MAPPING_VAR, SPLIT_VAR);
}
else
{
_uiKeyMapping = null;
}
buffsize = size;
categories = category;
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_UI_SETTING.writeId(packet);
packet.writeD(buffsize);
packet.writeD(categories);
int category = 0;
final int numKeyCt = _uiSettings.getKeys().size();
packet.writeD(numKeyCt);
for (int i = 0; i < numKeyCt; i++)
if (_uiKeyMapping != null)
{
if (_uiSettings.getCategories().containsKey(category))
{
final List<Integer> catElList1 = _uiSettings.getCategories().get(category);
packet.writeC(catElList1.size());
for (int cmd : catElList1)
{
packet.writeC(cmd);
}
}
else
{
packet.writeC(0x00);
}
category++;
if (_uiSettings.getCategories().containsKey(category))
{
final List<Integer> catElList2 = _uiSettings.getCategories().get(category);
packet.writeC(catElList2.size());
for (int cmd : catElList2)
{
packet.writeC(cmd);
}
}
else
{
packet.writeC(0x00);
}
category++;
if (_uiSettings.getKeys().containsKey(i))
{
final List<ActionKey> keyElList = _uiSettings.getKeys().get(i);
packet.writeD(keyElList.size());
for (ActionKey akey : keyElList)
{
packet.writeD(akey.getCommandId());
packet.writeD(akey.getKeyId());
packet.writeD(akey.getToogleKey1());
packet.writeD(akey.getToogleKey2());
packet.writeD(akey.getShowStatus());
}
}
else
{
packet.writeD(0x00);
}
packet.writeD(_uiKeyMapping.length);
packet.writeB(_uiKeyMapping);
}
else
{
packet.writeD(0);
}
packet.writeD(0x11);
packet.writeD(0x10);
return true;
}
}

View File

@ -1,12 +0,0 @@
DROP TABLE IF EXISTS `character_ui_actions`;
CREATE TABLE IF NOT EXISTS `character_ui_actions` (
`charId` int(10) unsigned NOT NULL DEFAULT '0',
`cat` tinyint(4) NOT NULL,
`order` tinyint(4) NOT NULL,
`cmd` int(8) NOT NULL DEFAULT '0',
`key` int(8) NOT NULL,
`tgKey1` int(8) DEFAULT NULL,
`tgKey2` int(8) DEFAULT NULL,
`show` tinyint(4) NOT NULL,
PRIMARY KEY (`charId`,`cat`,`cmd`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

View File

@ -1,8 +0,0 @@
DROP TABLE IF EXISTS `character_ui_categories`;
CREATE TABLE IF NOT EXISTS `character_ui_categories` (
`charId` int(10) unsigned NOT NULL DEFAULT '0',
`catId` tinyint(4) NOT NULL,
`order` tinyint(4) NOT NULL,
`cmdId` int(8) NOT NULL DEFAULT '0',
PRIMARY KEY (`charId`,`catId`,`order`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

View File

@ -1,346 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../xsd/ui.xsd">
<category id="0">
<commands>
<cmd>71</cmd>
<cmd>65</cmd>
<cmd>77</cmd>
<cmd>73</cmd>
<cmd>78</cmd>
<cmd>71</cmd>
<cmd>83</cmd>
<cmd>84</cmd>
<cmd>65</cmd>
<cmd>84</cmd>
<cmd>69</cmd>
<cmd>83</cmd>
<cmd>72</cmd>
<cmd>79</cmd>
<cmd>82</cmd>
<cmd>84</cmd>
<cmd>67</cmd>
<cmd>85</cmd>
<cmd>84</cmd>
<cmd>0</cmd>
</commands>
<keys>
<key cmd="59" key="67" toggleKey1="18" />
<key cmd="60" key="66" toggleKey1="18" />
<key cmd="62" key="74" toggleKey1="18" />
<key cmd="63" key="78" toggleKey1="18" />
<key cmd="64" key="84" toggleKey1="18" />
<key cmd="65" key="72" toggleKey1="18" toggleKey2="16" />
<key cmd="66" key="86" toggleKey1="18" />
<key cmd="67" key="82" toggleKey1="18" />
<key cmd="68" key="75" toggleKey1="18" />
<key cmd="78" key="77" toggleKey1="18" toggleKey2="16" />
<key cmd="70" key="77" toggleKey1="18" />
<key cmd="71" key="79" toggleKey1="18" toggleKey2="16" />
<key cmd="72" key="80" toggleKey1="18" toggleKey2="16" />
<key cmd="73" key="85" toggleKey1="18" />
<key cmd="74" key="82" toggleKey1="18" toggleKey2="16" />
<key cmd="75" key="83" toggleKey1="18" toggleKey2="16" />
<key cmd="76" key="88" toggleKey1="18" />
<key cmd="77" key="73" toggleKey1="18" toggleKey2="16" />
<key cmd="79" key="190" toggleKey1="18" />
<key cmd="80" key="69" toggleKey1="18" toggleKey2="16" />
<key cmd="81" key="76" toggleKey1="18" />
<key cmd="1" key="33" toggleKey1="18" />
<key cmd="2" key="34" toggleKey1="18" />
<key cmd="3" key="27" />
<key cmd="4" key="13" />
<key cmd="5" key="9" />
<key cmd="6" key="72" toggleKey1="18" />
<key cmd="7" key="87" toggleKey1="18" />
<key cmd="10" key="70" toggleKey1="18" />
<key cmd="11" key="80" toggleKey1="18" />
<key cmd="12" key="89" toggleKey1="18" />
<key cmd="49" key="112" toggleKey1="18" />
<key cmd="50" key="113" toggleKey1="18" />
<key cmd="51" key="114" toggleKey1="18" />
<key cmd="52" key="115" toggleKey1="18" />
<key cmd="53" key="116" toggleKey1="18" />
<key cmd="54" key="117" toggleKey1="18" />
<key cmd="55" key="118" toggleKey1="18" />
<key cmd="56" key="119" toggleKey1="18" />
<key cmd="57" key="120" toggleKey1="18" />
<key cmd="58" key="121" toggleKey1="18" />
<key cmd="13" key="112" />
<key cmd="14" key="113" />
<key cmd="15" key="114" />
<key cmd="16" key="115" />
<key cmd="17" key="116" />
<key cmd="18" key="117" />
<key cmd="19" key="118" />
<key cmd="20" key="119" />
<key cmd="21" key="120" />
<key cmd="22" key="121" />
<key cmd="23" key="122" />
<key cmd="24" key="123" />
<key cmd="25" key="49" toggleKey1="18" />
<key cmd="26" key="50" toggleKey1="18" />
<key cmd="27" key="51" toggleKey1="18" />
<key cmd="28" key="52" toggleKey1="18" />
<key cmd="29" key="53" toggleKey1="18" />
<key cmd="30" key="54" toggleKey1="18" />
<key cmd="31" key="55" toggleKey1="18" />
<key cmd="32" key="56" toggleKey1="18" />
<key cmd="33" key="57" toggleKey1="18" />
<key cmd="34" key="48" toggleKey1="18" />
<key cmd="35" key="189" toggleKey1="18" />
<key cmd="36" key="187" toggleKey1="18" />
<key cmd="37" key="97" toggleKey1="18" />
<key cmd="38" key="98" toggleKey1="18" />
<key cmd="39" key="99" toggleKey1="18" />
<key cmd="40" key="100" toggleKey1="18" />
<key cmd="41" key="101" toggleKey1="18" />
<key cmd="42" key="102" toggleKey1="18" />
<key cmd="43" key="103" toggleKey1="18" />
<key cmd="44" key="104" toggleKey1="18" />
<key cmd="45" key="105" toggleKey1="18" />
<key cmd="46" key="96" toggleKey1="18" />
<key cmd="47" key="111" toggleKey1="18" />
<key cmd="48" key="106" toggleKey1="18" />
<key cmd="92" key="32" toggleKey1="18" />
<key cmd="93" key="33" />
<key cmd="94" key="34" />
<key cmd="95" key="36" />
<key cmd="89" key="35" />
<key cmd="86" key="46" />
</keys>
</category>
<category id="1">
<commands>
<cmd>71</cmd>
<cmd>65</cmd>
<cmd>77</cmd>
<cmd>73</cmd>
<cmd>78</cmd>
<cmd>71</cmd>
<cmd>83</cmd>
<cmd>84</cmd>
<cmd>65</cmd>
<cmd>84</cmd>
<cmd>69</cmd>
<cmd>0</cmd>
</commands>
<keys>
<key cmd="59" key="67" />
<key cmd="60" key="66" />
<key cmd="63" key="78" />
<key cmd="64" key="84" />
<key cmd="66" key="86" />
<key cmd="67" key="82" />
<key cmd="68" key="75" />
<key cmd="70" key="77" />
<key cmd="73" key="85" />
<key cmd="76" key="88" />
<key cmd="79" key="190" />
<key cmd="80" key="69" />
<key cmd="13" key="112" />
<key cmd="14" key="113" />
<key cmd="15" key="114" />
<key cmd="16" key="115" />
<key cmd="17" key="116" />
<key cmd="18" key="117" />
<key cmd="19" key="118" />
<key cmd="20" key="119" />
<key cmd="21" key="120" />
<key cmd="22" key="121" />
<key cmd="23" key="122" />
<key cmd="24" key="123" />
<key cmd="25" key="49" />
<key cmd="26" key="50" />
<key cmd="27" key="51" />
<key cmd="28" key="52" />
<key cmd="29" key="53" />
<key cmd="30" key="54" />
<key cmd="31" key="55" />
<key cmd="32" key="56" />
<key cmd="33" key="57" />
<key cmd="34" key="48" />
<key cmd="35" key="189" />
<key cmd="36" key="187" />
<key cmd="37" key="97" />
<key cmd="38" key="98" />
<key cmd="39" key="99" />
<key cmd="40" key="100" />
<key cmd="41" key="101" />
<key cmd="42" key="102" />
<key cmd="43" key="103" />
<key cmd="44" key="104" />
<key cmd="45" key="105" />
<key cmd="46" key="96" />
<key cmd="47" key="111" />
<key cmd="48" key="106" />
<key cmd="82" key="65" />
<key cmd="83" key="68" />
<key cmd="84" key="87" />
<key cmd="85" key="83" />
<key cmd="86" key="46" />
<key cmd="96" key="65" showType="3" />
<key cmd="97" key="68" showType="3" />
<key cmd="98" key="87" showType="3" />
<key cmd="99" key="83" showType="3" />
</keys>
</category>
<category id="2">
<commands>
<cmd>84</cmd>
<cmd>69</cmd>
<cmd>77</cmd>
<cmd>80</cmd>
<cmd>83</cmd>
<cmd>84</cmd>
<cmd>65</cmd>
<cmd>84</cmd>
<cmd>69</cmd>
<cmd>83</cmd>
<cmd>72</cmd>
<cmd>79</cmd>
<cmd>82</cmd>
<cmd>84</cmd>
<cmd>67</cmd>
<cmd>85</cmd>
<cmd>84</cmd>
<cmd>0</cmd>
</commands>
<keys>
<key cmd="59" key="67" />
<key cmd="60" key="66" />
<key cmd="63" key="78" />
<key cmd="64" key="84" />
<key cmd="66" key="86" />
<key cmd="67" key="82" />
<key cmd="68" key="75" />
<key cmd="70" key="77" />
<key cmd="73" key="85" />
<key cmd="76" key="88" />
<key cmd="79" key="190" />
<key cmd="128" key="49" />
<key cmd="129" key="50" />
<key cmd="130" key="51" />
<key cmd="131" key="52" />
<key cmd="132" key="53" />
<key cmd="133" key="54" />
<key cmd="134" key="55" />
<key cmd="135" key="56" />
<key cmd="136" key="57" />
<key cmd="137" key="48" />
<key cmd="138" key="189" />
<key cmd="139" key="187" />
<key cmd="140" key="32" />
<key cmd="86" key="46" />
<key cmd="82" key="65" />
<key cmd="83" key="68" />
<key cmd="84" key="87" />
<key cmd="152" key="83" />
<key cmd="143" key="69" />
<key cmd="144" key="81" />
<key cmd="96" key="65" showType="3" />
<key cmd="97" key="68" showType="3" />
<key cmd="98" key="87" showType="3" />
<key cmd="147" key="69" showType="3" />
<key cmd="148" key="81" showType="3" />
<key cmd="93" key="33" />
<key cmd="94" key="34" />
<key cmd="95" key="36" />
</keys>
</category>
<category id="3">
<keys>
<key cmd="59" key="67" />
<key cmd="60" key="66" />
<key cmd="63" key="78" />
<key cmd="64" key="84" />
<key cmd="66" key="86" />
<key cmd="67" key="82" />
<key cmd="68" key="75" />
<key cmd="70" key="77" />
<key cmd="73" key="85" />
<key cmd="76" key="88" />
<key cmd="79" key="190" />
<key cmd="116" key="49" />
<key cmd="117" key="50" />
<key cmd="118" key="51" />
<key cmd="119" key="52" />
<key cmd="120" key="53" />
<key cmd="121" key="54" />
<key cmd="122" key="55" />
<key cmd="123" key="56" />
<key cmd="124" key="57" />
<key cmd="125" key="48" />
<key cmd="126" key="189" />
<key cmd="127" key="187" />
<key cmd="140" key="32" />
<key cmd="86" key="46" />
<key cmd="145" key="106" />
<key cmd="82" key="65" />
<key cmd="83" key="68" />
<key cmd="84" key="87" />
<key cmd="151" key="83" />
<key cmd="141" key="69" />
<key cmd="142" key="81" />
<key cmd="96" key="65" showType="3" />
<key cmd="97" key="68" showType="3" />
<key cmd="98" key="87" showType="3" />
<key cmd="147" key="69" showType="3" />
<key cmd="148" key="81" showType="3" />
<key cmd="93" key="33" />
<key cmd="94" key="34" />
<key cmd="95" key="36" />
</keys>
</category>
<category id="4">
<commands>
<cmd>70</cmd>
<cmd>76</cmd>
<cmd>73</cmd>
<cmd>71</cmd>
<cmd>72</cmd>
<cmd>84</cmd>
<cmd>83</cmd>
<cmd>84</cmd>
<cmd>65</cmd>
<cmd>84</cmd>
<cmd>69</cmd>
<cmd>83</cmd>
<cmd>72</cmd>
<cmd>79</cmd>
<cmd>82</cmd>
<cmd>84</cmd>
<cmd>67</cmd>
<cmd>85</cmd>
<cmd>84</cmd>
<cmd>0</cmd>
</commands>
</category>
<category id="6">
<commands>
<cmd>70</cmd>
<cmd>76</cmd>
<cmd>73</cmd>
<cmd>71</cmd>
<cmd>72</cmd>
<cmd>84</cmd>
<cmd>84</cmd>
<cmd>82</cmd>
<cmd>65</cmd>
<cmd>78</cmd>
<cmd>83</cmd>
<cmd>70</cmd>
<cmd>79</cmd>
<cmd>82</cmd>
<cmd>77</cmd>
<cmd>83</cmd>
<cmd>72</cmd>
<cmd>79</cmd>
<cmd>82</cmd>
<cmd>84</cmd>
<cmd>67</cmd>
<cmd>85</cmd>
<cmd>84</cmd>
<cmd>0</cmd>
</commands>
</category>
</list>

View File

@ -1,38 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="list">
<xs:complexType>
<xs:sequence minOccurs="1" maxOccurs="1">
<xs:element name="category" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence minOccurs="1" maxOccurs="1">
<xs:element name="commands" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence minOccurs="1" maxOccurs="1">
<xs:element name="cmd" minOccurs="1" maxOccurs="unbounded" type="xs:nonNegativeInteger" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="keys" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence minOccurs="1" maxOccurs="1">
<xs:element name="key" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="cmd" type="xs:positiveInteger" use="required" />
<xs:attribute name="key" type="xs:positiveInteger" use="required" />
<xs:attribute name="toggleKey1" type="xs:nonNegativeInteger" />
<xs:attribute name="toggleKey2" type="xs:nonNegativeInteger" />
<xs:attribute name="showType" type="xs:positiveInteger" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:nonNegativeInteger" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

View File

@ -92,7 +92,6 @@ import com.l2jmobius.gameserver.data.xml.impl.SpawnsData;
import com.l2jmobius.gameserver.data.xml.impl.StaticObjectData;
import com.l2jmobius.gameserver.data.xml.impl.TeleportersData;
import com.l2jmobius.gameserver.data.xml.impl.TransformData;
import com.l2jmobius.gameserver.data.xml.impl.UIData;
import com.l2jmobius.gameserver.datatables.AugmentationData;
import com.l2jmobius.gameserver.datatables.BotReportTable;
import com.l2jmobius.gameserver.datatables.EventDroplist;
@ -313,7 +312,6 @@ public class GameServer
CrestTable.getInstance();
TeleportLocationTable.getInstance();
TeleportersData.getInstance();
UIData.getInstance();
MatchingRoomManager.getInstance();
PetitionManager.getInstance();
CursedWeaponsManager.getInstance();

View File

@ -1,194 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU 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
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.data.xml.impl;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.gameserver.model.ActionKey;
/**
* UI Data parser.
* @author Zoey76
*/
public class UIData implements IGameXmlReader
{
private static final Logger LOGGER = Logger.getLogger(UIData.class.getName());
private final Map<Integer, List<ActionKey>> _storedKeys = new HashMap<>();
private final Map<Integer, List<Integer>> _storedCategories = new HashMap<>();
protected UIData()
{
load();
}
@Override
public void load()
{
_storedKeys.clear();
_storedCategories.clear();
parseDatapackFile("data/ui/ui_en.xml");
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _storedKeys.size() + " keys " + _storedCategories.size() + " categories.");
}
@Override
public void parseDocument(Document doc, File f)
{
for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling())
{
if ("list".equalsIgnoreCase(n.getNodeName()))
{
for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
{
if ("category".equalsIgnoreCase(d.getNodeName()))
{
parseCategory(d);
}
}
}
}
}
private void parseCategory(Node n)
{
final int cat = parseInteger(n.getAttributes(), "id");
for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
{
if ("commands".equalsIgnoreCase(d.getNodeName()))
{
parseCommands(cat, d);
}
else if ("keys".equalsIgnoreCase(d.getNodeName()))
{
parseKeys(cat, d);
}
}
}
private void parseCommands(int cat, Node d)
{
for (Node c = d.getFirstChild(); c != null; c = c.getNextSibling())
{
if ("cmd".equalsIgnoreCase(c.getNodeName()))
{
addCategory(_storedCategories, cat, Integer.parseInt(c.getTextContent()));
}
}
}
private void parseKeys(int cat, Node d)
{
for (Node c = d.getFirstChild(); c != null; c = c.getNextSibling())
{
if ("key".equalsIgnoreCase(c.getNodeName()))
{
final ActionKey akey = new ActionKey(cat);
for (int i = 0; i < c.getAttributes().getLength(); i++)
{
final Node att = c.getAttributes().item(i);
final int val = Integer.parseInt(att.getNodeValue());
switch (att.getNodeName())
{
case "cmd":
{
akey.setCommandId(val);
break;
}
case "key":
{
akey.setKeyId(val);
break;
}
case "toggleKey1":
{
akey.setToogleKey1(val);
break;
}
case "toggleKey2":
{
akey.setToogleKey2(val);
break;
}
case "showType":
{
akey.setShowStatus(val);
break;
}
}
}
addKey(_storedKeys, cat, akey);
}
}
}
/**
* Add a category to the stored categories.
* @param map the map to store the category
* @param cat the category
* @param cmd the command
*/
public static void addCategory(Map<Integer, List<Integer>> map, int cat, int cmd)
{
map.computeIfAbsent(cat, k -> new ArrayList<>()).add(cmd);
}
/**
* Create and insert an Action Key into the stored keys.
* @param map the map to store the key
* @param cat the category
* @param akey the action key
*/
public static void addKey(Map<Integer, List<ActionKey>> map, int cat, ActionKey akey)
{
map.computeIfAbsent(cat, k -> new ArrayList<>()).add(akey);
}
/**
* @return the categories
*/
public Map<Integer, List<Integer>> getCategories()
{
return _storedCategories;
}
/**
* @return the keys
*/
public Map<Integer, List<ActionKey>> getKeys()
{
return _storedKeys;
}
public static UIData getInstance()
{
return SingletonHolder._instance;
}
private static class SingletonHolder
{
protected static final UIData _instance = new UIData();
}
}

View File

@ -55,8 +55,6 @@ public abstract class IdFactory
"SELECT charId FROM character_skills WHERE charId >= ? AND charId < ?",
"SELECT charId FROM character_skills_save WHERE charId >= ? AND charId < ?",
"SELECT charId FROM character_subclasses WHERE charId >= ? AND charId < ?",
"SELECT charId FROM character_ui_actions WHERE charId >= ? AND charId < ?",
"SELECT charId FROM character_ui_categories WHERE charId >= ? AND charId < ?",
"SELECT charId FROM characters WHERE charId >= ? AND charId < ?",
"SELECT clanid FROM characters WHERE clanid >= ? AND clanid < ?",
"SELECT clan_id FROM clan_data WHERE clan_id >= ? AND clan_id < ?",
@ -192,8 +190,6 @@ public abstract class IdFactory
cleanCount += stmt.executeUpdate("DELETE FROM character_skills_save WHERE character_skills_save.charId NOT IN (SELECT charId FROM characters);");
cleanCount += stmt.executeUpdate("DELETE FROM character_subclasses WHERE character_subclasses.charId NOT IN (SELECT charId FROM characters);");
cleanCount += stmt.executeUpdate("DELETE FROM character_instance_time WHERE character_instance_time.charId NOT IN (SELECT charId FROM characters);");
cleanCount += stmt.executeUpdate("DELETE FROM character_ui_actions WHERE character_ui_actions.charId NOT IN (SELECT charId FROM characters);");
cleanCount += stmt.executeUpdate("DELETE FROM character_ui_categories WHERE character_ui_categories.charId NOT IN (SELECT charId FROM characters);");
// Items
cleanCount += stmt.executeUpdate("DELETE FROM items WHERE items.owner_id NOT IN (SELECT charId FROM characters) AND items.owner_id NOT IN (SELECT clan_id FROM clan_data) AND items.owner_id != -1;");

View File

@ -1,213 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU 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
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.data.xml.impl.UIData;
/**
* UI Keys Settings class.
* @author mrTJO, Zoey76
*/
public class UIKeysSettings
{
private static final Logger _log = Logger.getLogger(UIKeysSettings.class.getName());
private final int _playerObjId;
private Map<Integer, List<ActionKey>> _storedKeys;
private Map<Integer, List<Integer>> _storedCategories;
private boolean _saved = true;
public UIKeysSettings(int playerObjId)
{
_playerObjId = playerObjId;
loadFromDB();
}
public void storeAll(Map<Integer, List<Integer>> catMap, Map<Integer, List<ActionKey>> keyMap)
{
_saved = false;
_storedCategories = catMap;
_storedKeys = keyMap;
}
public void storeCategories(Map<Integer, List<Integer>> catMap)
{
_saved = false;
_storedCategories = catMap;
}
public Map<Integer, List<Integer>> getCategories()
{
return _storedCategories;
}
public void storeKeys(Map<Integer, List<ActionKey>> keyMap)
{
_saved = false;
_storedKeys = keyMap;
}
public Map<Integer, List<ActionKey>> getKeys()
{
return _storedKeys;
}
public void loadFromDB()
{
getCatsFromDB();
getKeysFromDB();
}
/**
* Save Categories and Mapped Keys into GameServer DataBase
*/
public void saveInDB()
{
String query;
if (_saved)
{
return;
}
query = "REPLACE INTO character_ui_categories (`charId`, `catId`, `order`, `cmdId`) VALUES ";
for (int category : _storedCategories.keySet())
{
int order = 0;
for (int key : _storedCategories.get(category))
{
query += "(" + _playerObjId + ", " + category + ", " + (order++) + ", " + key + "),";
}
}
query = query.substring(0, query.length() - 1) + "; ";
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(query))
{
statement.execute();
}
catch (Exception e)
{
_log.log(Level.WARNING, "Exception: saveInDB(): " + e.getMessage(), e);
}
query = "REPLACE INTO character_ui_actions (`charId`, `cat`, `order`, `cmd`, `key`, `tgKey1`, `tgKey2`, `show`) VALUES";
for (List<ActionKey> keyLst : _storedKeys.values())
{
int order = 0;
for (ActionKey key : keyLst)
{
query += key.getSqlSaveString(_playerObjId, order++) + ",";
}
}
query = query.substring(0, query.length() - 1) + ";";
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(query))
{
statement.execute();
}
catch (Exception e)
{
_log.log(Level.WARNING, "Exception: saveInDB(): " + e.getMessage(), e);
}
_saved = true;
}
public void getCatsFromDB()
{
if (_storedCategories != null)
{
return;
}
_storedCategories = new HashMap<>();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement stmt = con.prepareStatement("SELECT * FROM character_ui_categories WHERE `charId` = ? ORDER BY `catId`, `order`"))
{
stmt.setInt(1, _playerObjId);
try (ResultSet rs = stmt.executeQuery())
{
while (rs.next())
{
UIData.addCategory(_storedCategories, rs.getInt("catId"), rs.getInt("cmdId"));
}
}
}
catch (Exception e)
{
_log.log(Level.WARNING, "Exception: getCatsFromDB(): " + e.getMessage(), e);
}
if (_storedCategories.isEmpty())
{
_storedCategories = UIData.getInstance().getCategories();
}
}
public void getKeysFromDB()
{
if (_storedKeys != null)
{
return;
}
_storedKeys = new HashMap<>();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement stmt = con.prepareStatement("SELECT * FROM character_ui_actions WHERE `charId` = ? ORDER BY `cat`, `order`"))
{
stmt.setInt(1, _playerObjId);
try (ResultSet rs = stmt.executeQuery())
{
while (rs.next())
{
final int cat = rs.getInt("cat");
final int cmd = rs.getInt("cmd");
final int key = rs.getInt("key");
final int tgKey1 = rs.getInt("tgKey1");
final int tgKey2 = rs.getInt("tgKey2");
final int show = rs.getInt("show");
UIData.addKey(_storedKeys, cat, new ActionKey(cat, cmd, key, tgKey1, tgKey2, show));
}
}
}
catch (Exception e)
{
_log.log(Level.WARNING, "Exception: getKeysFromDB(): " + e.getMessage(), e);
}
if (_storedKeys.isEmpty())
{
_storedKeys = UIData.getInstance().getKeys();
}
}
public boolean isSaved()
{
return _saved;
}
}

View File

@ -148,7 +148,6 @@ import com.l2jmobius.gameserver.model.TeleportBookmark;
import com.l2jmobius.gameserver.model.TeleportWhereType;
import com.l2jmobius.gameserver.model.TimeStamp;
import com.l2jmobius.gameserver.model.TradeList;
import com.l2jmobius.gameserver.model.UIKeysSettings;
import com.l2jmobius.gameserver.model.actor.L2Attackable;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Npc;
@ -845,9 +844,6 @@ public final class L2PcInstance extends L2Playable
_PvPRegTask = null;
}
// Character UI
private UIKeysSettings _uiKeySettings;
// Save responder name for log it
private String _lastPetitionGmName = null;
@ -6811,11 +6807,6 @@ public final class L2PcInstance extends L2Playable
player.restoreFriendList();
if (Config.STORE_UI_SETTINGS)
{
player.restoreUISettings();
}
player.loadRecommendations();
player.startRecoGiveTask();
player.startOnlineTimeUpdateTask();
@ -7093,10 +7084,6 @@ public final class L2PcInstance extends L2Playable
{
storeRecipeShopList();
}
if (Config.STORE_UI_SETTINGS)
{
storeUISettings();
}
final PlayerVariables vars = getScript(PlayerVariables.class);
if (vars != null)
@ -12683,29 +12670,6 @@ public final class L2PcInstance extends L2Playable
return super.isMovementDisabled() || (getMovieHolder() != null) || _fishing.isFishing();
}
private void restoreUISettings()
{
_uiKeySettings = new UIKeysSettings(getObjectId());
}
private void storeUISettings()
{
if (_uiKeySettings == null)
{
return;
}
if (!_uiKeySettings.isSaved())
{
_uiKeySettings.saveInDB();
}
}
public UIKeysSettings getUISettings()
{
return _uiKeySettings;
}
public String getHtmlPrefix()
{
if (!Config.MULTILANG_ENABLE)

View File

@ -16,64 +16,30 @@
*/
package com.l2jmobius.gameserver.network.clientpackets;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.l2jmobius.Config;
import com.l2jmobius.commons.network.PacketReader;
import com.l2jmobius.gameserver.data.xml.impl.UIData;
import com.l2jmobius.gameserver.model.ActionKey;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.ConnectionState;
import com.l2jmobius.gameserver.network.L2GameClient;
/**
* Request Save Key Mapping client packet.
* @author mrTJO, Zoey76
* @author Mobius
*/
public class RequestSaveKeyMapping implements IClientIncomingPacket
{
private final Map<Integer, List<ActionKey>> _keyMap = new HashMap<>();
private final Map<Integer, List<Integer>> _catMap = new HashMap<>();
public static final String UI_KEY_MAPPING_VAR = "UI_KEY_MAPPING";
public static final String SPLIT_VAR = " ";
private byte[] _uiKeyMapping;
@Override
public boolean read(L2GameClient client, PacketReader packet)
{
int category = 0;
packet.readD(); // Unknown
packet.readD(); // Unknown
final int _tabNum = packet.readD();
for (int i = 0; i < _tabNum; i++)
final int dataSize = packet.readD();
if (dataSize > 0)
{
final int cmd1Size = packet.readC();
for (int j = 0; j < cmd1Size; j++)
{
UIData.addCategory(_catMap, category, packet.readC());
}
category++;
final int cmd2Size = packet.readC();
for (int j = 0; j < cmd2Size; j++)
{
UIData.addCategory(_catMap, category, packet.readC());
}
category++;
final int cmdSize = packet.readD();
for (int j = 0; j < cmdSize; j++)
{
final int cmd = packet.readD();
final int key = packet.readD();
final int tgKey1 = packet.readD();
final int tgKey2 = packet.readD();
final int show = packet.readD();
UIData.addKey(_keyMap, i, new ActionKey(i, cmd, key, tgKey1, tgKey2, show));
}
_uiKeyMapping = packet.readB(dataSize);
}
packet.readD();
packet.readD();
return true;
}
@ -81,10 +47,19 @@ public class RequestSaveKeyMapping implements IClientIncomingPacket
public void run(L2GameClient client)
{
final L2PcInstance player = client.getActiveChar();
if (!Config.STORE_UI_SETTINGS || (player == null) || (client.getConnectionState() != ConnectionState.IN_GAME))
if (!Config.STORE_UI_SETTINGS || //
(player == null) || //
(_uiKeyMapping == null) || //
(client.getConnectionState() != ConnectionState.IN_GAME))
{
return;
}
player.getUISettings().storeAll(_catMap, _keyMap);
String uiKeyMapping = "";
for (Byte b : _uiKeyMapping)
{
uiKeyMapping += b + SPLIT_VAR;
}
player.getVariables().set(UI_KEY_MAPPING_VAR, uiKeyMapping);
}
}

View File

@ -16,124 +16,44 @@
*/
package com.l2jmobius.gameserver.network.serverpackets;
import java.util.List;
import com.l2jmobius.commons.network.PacketWriter;
import com.l2jmobius.gameserver.model.ActionKey;
import com.l2jmobius.gameserver.model.UIKeysSettings;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.OutgoingPackets;
/**
* @author mrTJO
* @author Mobius
*/
public class ExUISetting implements IClientOutgoingPacket
{
private final UIKeysSettings _uiSettings;
private int buffsize, categories;
public static final String UI_KEY_MAPPING_VAR = "UI_KEY_MAPPING";
public static final String SPLIT_VAR = " ";
private final byte[] _uiKeyMapping;
public ExUISetting(L2PcInstance player)
{
_uiSettings = player.getUISettings();
calcSize();
}
private void calcSize()
{
int size = 16; // initial header and footer
int category = 0;
final int numKeyCt = _uiSettings.getKeys().size();
for (int i = 0; i < numKeyCt; i++)
if (player.getVariables().hasVariable(UI_KEY_MAPPING_VAR))
{
size++;
if (_uiSettings.getCategories().containsKey(category))
{
final List<Integer> catElList1 = _uiSettings.getCategories().get(category);
size = size + catElList1.size();
}
category++;
size++;
if (_uiSettings.getCategories().containsKey(category))
{
final List<Integer> catElList2 = _uiSettings.getCategories().get(category);
size = size + catElList2.size();
}
category++;
size = size + 4;
if (_uiSettings.getKeys().containsKey(i))
{
final List<ActionKey> keyElList = _uiSettings.getKeys().get(i);
size = size + (keyElList.size() * 20);
}
_uiKeyMapping = player.getVariables().getByteArray(UI_KEY_MAPPING_VAR, SPLIT_VAR);
}
else
{
_uiKeyMapping = null;
}
buffsize = size;
categories = category;
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_UI_SETTING.writeId(packet);
packet.writeD(buffsize);
packet.writeD(categories);
int category = 0;
final int numKeyCt = _uiSettings.getKeys().size();
packet.writeD(numKeyCt);
for (int i = 0; i < numKeyCt; i++)
if (_uiKeyMapping != null)
{
if (_uiSettings.getCategories().containsKey(category))
{
final List<Integer> catElList1 = _uiSettings.getCategories().get(category);
packet.writeC(catElList1.size());
for (int cmd : catElList1)
{
packet.writeC(cmd);
}
}
else
{
packet.writeC(0x00);
}
category++;
if (_uiSettings.getCategories().containsKey(category))
{
final List<Integer> catElList2 = _uiSettings.getCategories().get(category);
packet.writeC(catElList2.size());
for (int cmd : catElList2)
{
packet.writeC(cmd);
}
}
else
{
packet.writeC(0x00);
}
category++;
if (_uiSettings.getKeys().containsKey(i))
{
final List<ActionKey> keyElList = _uiSettings.getKeys().get(i);
packet.writeD(keyElList.size());
for (ActionKey akey : keyElList)
{
packet.writeD(akey.getCommandId());
packet.writeD(akey.getKeyId());
packet.writeD(akey.getToogleKey1());
packet.writeD(akey.getToogleKey2());
packet.writeD(akey.getShowStatus());
}
}
else
{
packet.writeD(0x00);
}
packet.writeD(_uiKeyMapping.length);
packet.writeB(_uiKeyMapping);
}
else
{
packet.writeD(0);
}
packet.writeD(0x11);
packet.writeD(0x10);
return true;
}
}

View File

@ -1,12 +0,0 @@
DROP TABLE IF EXISTS `character_ui_actions`;
CREATE TABLE IF NOT EXISTS `character_ui_actions` (
`charId` int(10) unsigned NOT NULL DEFAULT '0',
`cat` tinyint(4) NOT NULL,
`order` tinyint(4) NOT NULL,
`cmd` int(8) NOT NULL DEFAULT '0',
`key` int(8) NOT NULL,
`tgKey1` int(8) DEFAULT NULL,
`tgKey2` int(8) DEFAULT NULL,
`show` tinyint(4) NOT NULL,
PRIMARY KEY (`charId`,`cat`,`cmd`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

View File

@ -1,8 +0,0 @@
DROP TABLE IF EXISTS `character_ui_categories`;
CREATE TABLE IF NOT EXISTS `character_ui_categories` (
`charId` int(10) unsigned NOT NULL DEFAULT '0',
`catId` tinyint(4) NOT NULL,
`order` tinyint(4) NOT NULL,
`cmdId` int(8) NOT NULL DEFAULT '0',
PRIMARY KEY (`charId`,`catId`,`order`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

View File

@ -1,346 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../xsd/ui.xsd">
<category id="0">
<commands>
<cmd>71</cmd>
<cmd>65</cmd>
<cmd>77</cmd>
<cmd>73</cmd>
<cmd>78</cmd>
<cmd>71</cmd>
<cmd>83</cmd>
<cmd>84</cmd>
<cmd>65</cmd>
<cmd>84</cmd>
<cmd>69</cmd>
<cmd>83</cmd>
<cmd>72</cmd>
<cmd>79</cmd>
<cmd>82</cmd>
<cmd>84</cmd>
<cmd>67</cmd>
<cmd>85</cmd>
<cmd>84</cmd>
<cmd>0</cmd>
</commands>
<keys>
<key cmd="59" key="67" toggleKey1="18" />
<key cmd="60" key="66" toggleKey1="18" />
<key cmd="62" key="74" toggleKey1="18" />
<key cmd="63" key="78" toggleKey1="18" />
<key cmd="64" key="84" toggleKey1="18" />
<key cmd="65" key="72" toggleKey1="18" toggleKey2="16" />
<key cmd="66" key="86" toggleKey1="18" />
<key cmd="67" key="82" toggleKey1="18" />
<key cmd="68" key="75" toggleKey1="18" />
<key cmd="78" key="77" toggleKey1="18" toggleKey2="16" />
<key cmd="70" key="77" toggleKey1="18" />
<key cmd="71" key="79" toggleKey1="18" toggleKey2="16" />
<key cmd="72" key="80" toggleKey1="18" toggleKey2="16" />
<key cmd="73" key="85" toggleKey1="18" />
<key cmd="74" key="82" toggleKey1="18" toggleKey2="16" />
<key cmd="75" key="83" toggleKey1="18" toggleKey2="16" />
<key cmd="76" key="88" toggleKey1="18" />
<key cmd="77" key="73" toggleKey1="18" toggleKey2="16" />
<key cmd="79" key="190" toggleKey1="18" />
<key cmd="80" key="69" toggleKey1="18" toggleKey2="16" />
<key cmd="81" key="76" toggleKey1="18" />
<key cmd="1" key="33" toggleKey1="18" />
<key cmd="2" key="34" toggleKey1="18" />
<key cmd="3" key="27" />
<key cmd="4" key="13" />
<key cmd="5" key="9" />
<key cmd="6" key="72" toggleKey1="18" />
<key cmd="7" key="87" toggleKey1="18" />
<key cmd="10" key="70" toggleKey1="18" />
<key cmd="11" key="80" toggleKey1="18" />
<key cmd="12" key="89" toggleKey1="18" />
<key cmd="49" key="112" toggleKey1="18" />
<key cmd="50" key="113" toggleKey1="18" />
<key cmd="51" key="114" toggleKey1="18" />
<key cmd="52" key="115" toggleKey1="18" />
<key cmd="53" key="116" toggleKey1="18" />
<key cmd="54" key="117" toggleKey1="18" />
<key cmd="55" key="118" toggleKey1="18" />
<key cmd="56" key="119" toggleKey1="18" />
<key cmd="57" key="120" toggleKey1="18" />
<key cmd="58" key="121" toggleKey1="18" />
<key cmd="13" key="112" />
<key cmd="14" key="113" />
<key cmd="15" key="114" />
<key cmd="16" key="115" />
<key cmd="17" key="116" />
<key cmd="18" key="117" />
<key cmd="19" key="118" />
<key cmd="20" key="119" />
<key cmd="21" key="120" />
<key cmd="22" key="121" />
<key cmd="23" key="122" />
<key cmd="24" key="123" />
<key cmd="25" key="49" toggleKey1="18" />
<key cmd="26" key="50" toggleKey1="18" />
<key cmd="27" key="51" toggleKey1="18" />
<key cmd="28" key="52" toggleKey1="18" />
<key cmd="29" key="53" toggleKey1="18" />
<key cmd="30" key="54" toggleKey1="18" />
<key cmd="31" key="55" toggleKey1="18" />
<key cmd="32" key="56" toggleKey1="18" />
<key cmd="33" key="57" toggleKey1="18" />
<key cmd="34" key="48" toggleKey1="18" />
<key cmd="35" key="189" toggleKey1="18" />
<key cmd="36" key="187" toggleKey1="18" />
<key cmd="37" key="97" toggleKey1="18" />
<key cmd="38" key="98" toggleKey1="18" />
<key cmd="39" key="99" toggleKey1="18" />
<key cmd="40" key="100" toggleKey1="18" />
<key cmd="41" key="101" toggleKey1="18" />
<key cmd="42" key="102" toggleKey1="18" />
<key cmd="43" key="103" toggleKey1="18" />
<key cmd="44" key="104" toggleKey1="18" />
<key cmd="45" key="105" toggleKey1="18" />
<key cmd="46" key="96" toggleKey1="18" />
<key cmd="47" key="111" toggleKey1="18" />
<key cmd="48" key="106" toggleKey1="18" />
<key cmd="92" key="32" toggleKey1="18" />
<key cmd="93" key="33" />
<key cmd="94" key="34" />
<key cmd="95" key="36" />
<key cmd="89" key="35" />
<key cmd="86" key="46" />
</keys>
</category>
<category id="1">
<commands>
<cmd>71</cmd>
<cmd>65</cmd>
<cmd>77</cmd>
<cmd>73</cmd>
<cmd>78</cmd>
<cmd>71</cmd>
<cmd>83</cmd>
<cmd>84</cmd>
<cmd>65</cmd>
<cmd>84</cmd>
<cmd>69</cmd>
<cmd>0</cmd>
</commands>
<keys>
<key cmd="59" key="67" />
<key cmd="60" key="66" />
<key cmd="63" key="78" />
<key cmd="64" key="84" />
<key cmd="66" key="86" />
<key cmd="67" key="82" />
<key cmd="68" key="75" />
<key cmd="70" key="77" />
<key cmd="73" key="85" />
<key cmd="76" key="88" />
<key cmd="79" key="190" />
<key cmd="80" key="69" />
<key cmd="13" key="112" />
<key cmd="14" key="113" />
<key cmd="15" key="114" />
<key cmd="16" key="115" />
<key cmd="17" key="116" />
<key cmd="18" key="117" />
<key cmd="19" key="118" />
<key cmd="20" key="119" />
<key cmd="21" key="120" />
<key cmd="22" key="121" />
<key cmd="23" key="122" />
<key cmd="24" key="123" />
<key cmd="25" key="49" />
<key cmd="26" key="50" />
<key cmd="27" key="51" />
<key cmd="28" key="52" />
<key cmd="29" key="53" />
<key cmd="30" key="54" />
<key cmd="31" key="55" />
<key cmd="32" key="56" />
<key cmd="33" key="57" />
<key cmd="34" key="48" />
<key cmd="35" key="189" />
<key cmd="36" key="187" />
<key cmd="37" key="97" />
<key cmd="38" key="98" />
<key cmd="39" key="99" />
<key cmd="40" key="100" />
<key cmd="41" key="101" />
<key cmd="42" key="102" />
<key cmd="43" key="103" />
<key cmd="44" key="104" />
<key cmd="45" key="105" />
<key cmd="46" key="96" />
<key cmd="47" key="111" />
<key cmd="48" key="106" />
<key cmd="82" key="65" />
<key cmd="83" key="68" />
<key cmd="84" key="87" />
<key cmd="85" key="83" />
<key cmd="86" key="46" />
<key cmd="96" key="65" showType="3" />
<key cmd="97" key="68" showType="3" />
<key cmd="98" key="87" showType="3" />
<key cmd="99" key="83" showType="3" />
</keys>
</category>
<category id="2">
<commands>
<cmd>84</cmd>
<cmd>69</cmd>
<cmd>77</cmd>
<cmd>80</cmd>
<cmd>83</cmd>
<cmd>84</cmd>
<cmd>65</cmd>
<cmd>84</cmd>
<cmd>69</cmd>
<cmd>83</cmd>
<cmd>72</cmd>
<cmd>79</cmd>
<cmd>82</cmd>
<cmd>84</cmd>
<cmd>67</cmd>
<cmd>85</cmd>
<cmd>84</cmd>
<cmd>0</cmd>
</commands>
<keys>
<key cmd="59" key="67" />
<key cmd="60" key="66" />
<key cmd="63" key="78" />
<key cmd="64" key="84" />
<key cmd="66" key="86" />
<key cmd="67" key="82" />
<key cmd="68" key="75" />
<key cmd="70" key="77" />
<key cmd="73" key="85" />
<key cmd="76" key="88" />
<key cmd="79" key="190" />
<key cmd="128" key="49" />
<key cmd="129" key="50" />
<key cmd="130" key="51" />
<key cmd="131" key="52" />
<key cmd="132" key="53" />
<key cmd="133" key="54" />
<key cmd="134" key="55" />
<key cmd="135" key="56" />
<key cmd="136" key="57" />
<key cmd="137" key="48" />
<key cmd="138" key="189" />
<key cmd="139" key="187" />
<key cmd="140" key="32" />
<key cmd="86" key="46" />
<key cmd="82" key="65" />
<key cmd="83" key="68" />
<key cmd="84" key="87" />
<key cmd="152" key="83" />
<key cmd="143" key="69" />
<key cmd="144" key="81" />
<key cmd="96" key="65" showType="3" />
<key cmd="97" key="68" showType="3" />
<key cmd="98" key="87" showType="3" />
<key cmd="147" key="69" showType="3" />
<key cmd="148" key="81" showType="3" />
<key cmd="93" key="33" />
<key cmd="94" key="34" />
<key cmd="95" key="36" />
</keys>
</category>
<category id="3">
<keys>
<key cmd="59" key="67" />
<key cmd="60" key="66" />
<key cmd="63" key="78" />
<key cmd="64" key="84" />
<key cmd="66" key="86" />
<key cmd="67" key="82" />
<key cmd="68" key="75" />
<key cmd="70" key="77" />
<key cmd="73" key="85" />
<key cmd="76" key="88" />
<key cmd="79" key="190" />
<key cmd="116" key="49" />
<key cmd="117" key="50" />
<key cmd="118" key="51" />
<key cmd="119" key="52" />
<key cmd="120" key="53" />
<key cmd="121" key="54" />
<key cmd="122" key="55" />
<key cmd="123" key="56" />
<key cmd="124" key="57" />
<key cmd="125" key="48" />
<key cmd="126" key="189" />
<key cmd="127" key="187" />
<key cmd="140" key="32" />
<key cmd="86" key="46" />
<key cmd="145" key="106" />
<key cmd="82" key="65" />
<key cmd="83" key="68" />
<key cmd="84" key="87" />
<key cmd="151" key="83" />
<key cmd="141" key="69" />
<key cmd="142" key="81" />
<key cmd="96" key="65" showType="3" />
<key cmd="97" key="68" showType="3" />
<key cmd="98" key="87" showType="3" />
<key cmd="147" key="69" showType="3" />
<key cmd="148" key="81" showType="3" />
<key cmd="93" key="33" />
<key cmd="94" key="34" />
<key cmd="95" key="36" />
</keys>
</category>
<category id="4">
<commands>
<cmd>70</cmd>
<cmd>76</cmd>
<cmd>73</cmd>
<cmd>71</cmd>
<cmd>72</cmd>
<cmd>84</cmd>
<cmd>83</cmd>
<cmd>84</cmd>
<cmd>65</cmd>
<cmd>84</cmd>
<cmd>69</cmd>
<cmd>83</cmd>
<cmd>72</cmd>
<cmd>79</cmd>
<cmd>82</cmd>
<cmd>84</cmd>
<cmd>67</cmd>
<cmd>85</cmd>
<cmd>84</cmd>
<cmd>0</cmd>
</commands>
</category>
<category id="6">
<commands>
<cmd>70</cmd>
<cmd>76</cmd>
<cmd>73</cmd>
<cmd>71</cmd>
<cmd>72</cmd>
<cmd>84</cmd>
<cmd>84</cmd>
<cmd>82</cmd>
<cmd>65</cmd>
<cmd>78</cmd>
<cmd>83</cmd>
<cmd>70</cmd>
<cmd>79</cmd>
<cmd>82</cmd>
<cmd>77</cmd>
<cmd>83</cmd>
<cmd>72</cmd>
<cmd>79</cmd>
<cmd>82</cmd>
<cmd>84</cmd>
<cmd>67</cmd>
<cmd>85</cmd>
<cmd>84</cmd>
<cmd>0</cmd>
</commands>
</category>
</list>

View File

@ -1,38 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="list">
<xs:complexType>
<xs:sequence minOccurs="1" maxOccurs="1">
<xs:element name="category" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence minOccurs="1" maxOccurs="1">
<xs:element name="commands" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence minOccurs="1" maxOccurs="1">
<xs:element name="cmd" minOccurs="1" maxOccurs="unbounded" type="xs:nonNegativeInteger" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="keys" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence minOccurs="1" maxOccurs="1">
<xs:element name="key" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="cmd" type="xs:positiveInteger" use="required" />
<xs:attribute name="key" type="xs:positiveInteger" use="required" />
<xs:attribute name="toggleKey1" type="xs:nonNegativeInteger" />
<xs:attribute name="toggleKey2" type="xs:nonNegativeInteger" />
<xs:attribute name="showType" type="xs:positiveInteger" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:nonNegativeInteger" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

View File

@ -92,7 +92,6 @@ import com.l2jmobius.gameserver.data.xml.impl.SpawnsData;
import com.l2jmobius.gameserver.data.xml.impl.StaticObjectData;
import com.l2jmobius.gameserver.data.xml.impl.TeleportersData;
import com.l2jmobius.gameserver.data.xml.impl.TransformData;
import com.l2jmobius.gameserver.data.xml.impl.UIData;
import com.l2jmobius.gameserver.datatables.AugmentationData;
import com.l2jmobius.gameserver.datatables.BotReportTable;
import com.l2jmobius.gameserver.datatables.EventDroplist;
@ -313,7 +312,6 @@ public class GameServer
CrestTable.getInstance();
TeleportLocationTable.getInstance();
TeleportersData.getInstance();
UIData.getInstance();
MatchingRoomManager.getInstance();
PetitionManager.getInstance();
CursedWeaponsManager.getInstance();

View File

@ -1,194 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU 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
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.data.xml.impl;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.gameserver.model.ActionKey;
/**
* UI Data parser.
* @author Zoey76
*/
public class UIData implements IGameXmlReader
{
private static final Logger LOGGER = Logger.getLogger(UIData.class.getName());
private final Map<Integer, List<ActionKey>> _storedKeys = new HashMap<>();
private final Map<Integer, List<Integer>> _storedCategories = new HashMap<>();
protected UIData()
{
load();
}
@Override
public void load()
{
_storedKeys.clear();
_storedCategories.clear();
parseDatapackFile("data/ui/ui_en.xml");
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _storedKeys.size() + " keys " + _storedCategories.size() + " categories.");
}
@Override
public void parseDocument(Document doc, File f)
{
for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling())
{
if ("list".equalsIgnoreCase(n.getNodeName()))
{
for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
{
if ("category".equalsIgnoreCase(d.getNodeName()))
{
parseCategory(d);
}
}
}
}
}
private void parseCategory(Node n)
{
final int cat = parseInteger(n.getAttributes(), "id");
for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
{
if ("commands".equalsIgnoreCase(d.getNodeName()))
{
parseCommands(cat, d);
}
else if ("keys".equalsIgnoreCase(d.getNodeName()))
{
parseKeys(cat, d);
}
}
}
private void parseCommands(int cat, Node d)
{
for (Node c = d.getFirstChild(); c != null; c = c.getNextSibling())
{
if ("cmd".equalsIgnoreCase(c.getNodeName()))
{
addCategory(_storedCategories, cat, Integer.parseInt(c.getTextContent()));
}
}
}
private void parseKeys(int cat, Node d)
{
for (Node c = d.getFirstChild(); c != null; c = c.getNextSibling())
{
if ("key".equalsIgnoreCase(c.getNodeName()))
{
final ActionKey akey = new ActionKey(cat);
for (int i = 0; i < c.getAttributes().getLength(); i++)
{
final Node att = c.getAttributes().item(i);
final int val = Integer.parseInt(att.getNodeValue());
switch (att.getNodeName())
{
case "cmd":
{
akey.setCommandId(val);
break;
}
case "key":
{
akey.setKeyId(val);
break;
}
case "toggleKey1":
{
akey.setToogleKey1(val);
break;
}
case "toggleKey2":
{
akey.setToogleKey2(val);
break;
}
case "showType":
{
akey.setShowStatus(val);
break;
}
}
}
addKey(_storedKeys, cat, akey);
}
}
}
/**
* Add a category to the stored categories.
* @param map the map to store the category
* @param cat the category
* @param cmd the command
*/
public static void addCategory(Map<Integer, List<Integer>> map, int cat, int cmd)
{
map.computeIfAbsent(cat, k -> new ArrayList<>()).add(cmd);
}
/**
* Create and insert an Action Key into the stored keys.
* @param map the map to store the key
* @param cat the category
* @param akey the action key
*/
public static void addKey(Map<Integer, List<ActionKey>> map, int cat, ActionKey akey)
{
map.computeIfAbsent(cat, k -> new ArrayList<>()).add(akey);
}
/**
* @return the categories
*/
public Map<Integer, List<Integer>> getCategories()
{
return _storedCategories;
}
/**
* @return the keys
*/
public Map<Integer, List<ActionKey>> getKeys()
{
return _storedKeys;
}
public static UIData getInstance()
{
return SingletonHolder._instance;
}
private static class SingletonHolder
{
protected static final UIData _instance = new UIData();
}
}

View File

@ -55,8 +55,6 @@ public abstract class IdFactory
"SELECT charId FROM character_skills WHERE charId >= ? AND charId < ?",
"SELECT charId FROM character_skills_save WHERE charId >= ? AND charId < ?",
"SELECT charId FROM character_subclasses WHERE charId >= ? AND charId < ?",
"SELECT charId FROM character_ui_actions WHERE charId >= ? AND charId < ?",
"SELECT charId FROM character_ui_categories WHERE charId >= ? AND charId < ?",
"SELECT charId FROM characters WHERE charId >= ? AND charId < ?",
"SELECT clanid FROM characters WHERE clanid >= ? AND clanid < ?",
"SELECT clan_id FROM clan_data WHERE clan_id >= ? AND clan_id < ?",
@ -192,8 +190,6 @@ public abstract class IdFactory
cleanCount += stmt.executeUpdate("DELETE FROM character_skills_save WHERE character_skills_save.charId NOT IN (SELECT charId FROM characters);");
cleanCount += stmt.executeUpdate("DELETE FROM character_subclasses WHERE character_subclasses.charId NOT IN (SELECT charId FROM characters);");
cleanCount += stmt.executeUpdate("DELETE FROM character_instance_time WHERE character_instance_time.charId NOT IN (SELECT charId FROM characters);");
cleanCount += stmt.executeUpdate("DELETE FROM character_ui_actions WHERE character_ui_actions.charId NOT IN (SELECT charId FROM characters);");
cleanCount += stmt.executeUpdate("DELETE FROM character_ui_categories WHERE character_ui_categories.charId NOT IN (SELECT charId FROM characters);");
// Items
cleanCount += stmt.executeUpdate("DELETE FROM items WHERE items.owner_id NOT IN (SELECT charId FROM characters) AND items.owner_id NOT IN (SELECT clan_id FROM clan_data) AND items.owner_id != -1;");

View File

@ -1,213 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU 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
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.data.xml.impl.UIData;
/**
* UI Keys Settings class.
* @author mrTJO, Zoey76
*/
public class UIKeysSettings
{
private static final Logger _log = Logger.getLogger(UIKeysSettings.class.getName());
private final int _playerObjId;
private Map<Integer, List<ActionKey>> _storedKeys;
private Map<Integer, List<Integer>> _storedCategories;
private boolean _saved = true;
public UIKeysSettings(int playerObjId)
{
_playerObjId = playerObjId;
loadFromDB();
}
public void storeAll(Map<Integer, List<Integer>> catMap, Map<Integer, List<ActionKey>> keyMap)
{
_saved = false;
_storedCategories = catMap;
_storedKeys = keyMap;
}
public void storeCategories(Map<Integer, List<Integer>> catMap)
{
_saved = false;
_storedCategories = catMap;
}
public Map<Integer, List<Integer>> getCategories()
{
return _storedCategories;
}
public void storeKeys(Map<Integer, List<ActionKey>> keyMap)
{
_saved = false;
_storedKeys = keyMap;
}
public Map<Integer, List<ActionKey>> getKeys()
{
return _storedKeys;
}
public void loadFromDB()
{
getCatsFromDB();
getKeysFromDB();
}
/**
* Save Categories and Mapped Keys into GameServer DataBase
*/
public void saveInDB()
{
String query;
if (_saved)
{
return;
}
query = "REPLACE INTO character_ui_categories (`charId`, `catId`, `order`, `cmdId`) VALUES ";
for (int category : _storedCategories.keySet())
{
int order = 0;
for (int key : _storedCategories.get(category))
{
query += "(" + _playerObjId + ", " + category + ", " + (order++) + ", " + key + "),";
}
}
query = query.substring(0, query.length() - 1) + "; ";
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(query))
{
statement.execute();
}
catch (Exception e)
{
_log.log(Level.WARNING, "Exception: saveInDB(): " + e.getMessage(), e);
}
query = "REPLACE INTO character_ui_actions (`charId`, `cat`, `order`, `cmd`, `key`, `tgKey1`, `tgKey2`, `show`) VALUES";
for (List<ActionKey> keyLst : _storedKeys.values())
{
int order = 0;
for (ActionKey key : keyLst)
{
query += key.getSqlSaveString(_playerObjId, order++) + ",";
}
}
query = query.substring(0, query.length() - 1) + ";";
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(query))
{
statement.execute();
}
catch (Exception e)
{
_log.log(Level.WARNING, "Exception: saveInDB(): " + e.getMessage(), e);
}
_saved = true;
}
public void getCatsFromDB()
{
if (_storedCategories != null)
{
return;
}
_storedCategories = new HashMap<>();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement stmt = con.prepareStatement("SELECT * FROM character_ui_categories WHERE `charId` = ? ORDER BY `catId`, `order`"))
{
stmt.setInt(1, _playerObjId);
try (ResultSet rs = stmt.executeQuery())
{
while (rs.next())
{
UIData.addCategory(_storedCategories, rs.getInt("catId"), rs.getInt("cmdId"));
}
}
}
catch (Exception e)
{
_log.log(Level.WARNING, "Exception: getCatsFromDB(): " + e.getMessage(), e);
}
if (_storedCategories.isEmpty())
{
_storedCategories = UIData.getInstance().getCategories();
}
}
public void getKeysFromDB()
{
if (_storedKeys != null)
{
return;
}
_storedKeys = new HashMap<>();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement stmt = con.prepareStatement("SELECT * FROM character_ui_actions WHERE `charId` = ? ORDER BY `cat`, `order`"))
{
stmt.setInt(1, _playerObjId);
try (ResultSet rs = stmt.executeQuery())
{
while (rs.next())
{
final int cat = rs.getInt("cat");
final int cmd = rs.getInt("cmd");
final int key = rs.getInt("key");
final int tgKey1 = rs.getInt("tgKey1");
final int tgKey2 = rs.getInt("tgKey2");
final int show = rs.getInt("show");
UIData.addKey(_storedKeys, cat, new ActionKey(cat, cmd, key, tgKey1, tgKey2, show));
}
}
}
catch (Exception e)
{
_log.log(Level.WARNING, "Exception: getKeysFromDB(): " + e.getMessage(), e);
}
if (_storedKeys.isEmpty())
{
_storedKeys = UIData.getInstance().getKeys();
}
}
public boolean isSaved()
{
return _saved;
}
}

View File

@ -149,7 +149,6 @@ import com.l2jmobius.gameserver.model.TeleportBookmark;
import com.l2jmobius.gameserver.model.TeleportWhereType;
import com.l2jmobius.gameserver.model.TimeStamp;
import com.l2jmobius.gameserver.model.TradeList;
import com.l2jmobius.gameserver.model.UIKeysSettings;
import com.l2jmobius.gameserver.model.actor.L2Attackable;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Npc;
@ -847,9 +846,6 @@ public final class L2PcInstance extends L2Playable
_PvPRegTask = null;
}
// Character UI
private UIKeysSettings _uiKeySettings;
// Save responder name for log it
private String _lastPetitionGmName = null;
@ -6813,11 +6809,6 @@ public final class L2PcInstance extends L2Playable
player.restoreFriendList();
if (Config.STORE_UI_SETTINGS)
{
player.restoreUISettings();
}
player.loadRecommendations();
player.startRecoGiveTask();
player.startOnlineTimeUpdateTask();
@ -7095,10 +7086,6 @@ public final class L2PcInstance extends L2Playable
{
storeRecipeShopList();
}
if (Config.STORE_UI_SETTINGS)
{
storeUISettings();
}
final PlayerVariables vars = getScript(PlayerVariables.class);
if (vars != null)
@ -12693,29 +12680,6 @@ public final class L2PcInstance extends L2Playable
return super.isMovementDisabled() || (getMovieHolder() != null) || _fishing.isFishing();
}
private void restoreUISettings()
{
_uiKeySettings = new UIKeysSettings(getObjectId());
}
private void storeUISettings()
{
if (_uiKeySettings == null)
{
return;
}
if (!_uiKeySettings.isSaved())
{
_uiKeySettings.saveInDB();
}
}
public UIKeysSettings getUISettings()
{
return _uiKeySettings;
}
public String getHtmlPrefix()
{
if (!Config.MULTILANG_ENABLE)

View File

@ -16,64 +16,30 @@
*/
package com.l2jmobius.gameserver.network.clientpackets;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.l2jmobius.Config;
import com.l2jmobius.commons.network.PacketReader;
import com.l2jmobius.gameserver.data.xml.impl.UIData;
import com.l2jmobius.gameserver.model.ActionKey;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.ConnectionState;
import com.l2jmobius.gameserver.network.L2GameClient;
/**
* Request Save Key Mapping client packet.
* @author mrTJO, Zoey76
* @author Mobius
*/
public class RequestSaveKeyMapping implements IClientIncomingPacket
{
private final Map<Integer, List<ActionKey>> _keyMap = new HashMap<>();
private final Map<Integer, List<Integer>> _catMap = new HashMap<>();
public static final String UI_KEY_MAPPING_VAR = "UI_KEY_MAPPING";
public static final String SPLIT_VAR = " ";
private byte[] _uiKeyMapping;
@Override
public boolean read(L2GameClient client, PacketReader packet)
{
int category = 0;
packet.readD(); // Unknown
packet.readD(); // Unknown
final int _tabNum = packet.readD();
for (int i = 0; i < _tabNum; i++)
final int dataSize = packet.readD();
if (dataSize > 0)
{
final int cmd1Size = packet.readC();
for (int j = 0; j < cmd1Size; j++)
{
UIData.addCategory(_catMap, category, packet.readC());
}
category++;
final int cmd2Size = packet.readC();
for (int j = 0; j < cmd2Size; j++)
{
UIData.addCategory(_catMap, category, packet.readC());
}
category++;
final int cmdSize = packet.readD();
for (int j = 0; j < cmdSize; j++)
{
final int cmd = packet.readD();
final int key = packet.readD();
final int tgKey1 = packet.readD();
final int tgKey2 = packet.readD();
final int show = packet.readD();
UIData.addKey(_keyMap, i, new ActionKey(i, cmd, key, tgKey1, tgKey2, show));
}
_uiKeyMapping = packet.readB(dataSize);
}
packet.readD();
packet.readD();
return true;
}
@ -81,10 +47,19 @@ public class RequestSaveKeyMapping implements IClientIncomingPacket
public void run(L2GameClient client)
{
final L2PcInstance player = client.getActiveChar();
if (!Config.STORE_UI_SETTINGS || (player == null) || (client.getConnectionState() != ConnectionState.IN_GAME))
if (!Config.STORE_UI_SETTINGS || //
(player == null) || //
(_uiKeyMapping == null) || //
(client.getConnectionState() != ConnectionState.IN_GAME))
{
return;
}
player.getUISettings().storeAll(_catMap, _keyMap);
String uiKeyMapping = "";
for (Byte b : _uiKeyMapping)
{
uiKeyMapping += b + SPLIT_VAR;
}
player.getVariables().set(UI_KEY_MAPPING_VAR, uiKeyMapping);
}
}

View File

@ -16,124 +16,44 @@
*/
package com.l2jmobius.gameserver.network.serverpackets;
import java.util.List;
import com.l2jmobius.commons.network.PacketWriter;
import com.l2jmobius.gameserver.model.ActionKey;
import com.l2jmobius.gameserver.model.UIKeysSettings;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.OutgoingPackets;
/**
* @author mrTJO
* @author Mobius
*/
public class ExUISetting implements IClientOutgoingPacket
{
private final UIKeysSettings _uiSettings;
private int buffsize, categories;
public static final String UI_KEY_MAPPING_VAR = "UI_KEY_MAPPING";
public static final String SPLIT_VAR = " ";
private final byte[] _uiKeyMapping;
public ExUISetting(L2PcInstance player)
{
_uiSettings = player.getUISettings();
calcSize();
}
private void calcSize()
{
int size = 16; // initial header and footer
int category = 0;
final int numKeyCt = _uiSettings.getKeys().size();
for (int i = 0; i < numKeyCt; i++)
if (player.getVariables().hasVariable(UI_KEY_MAPPING_VAR))
{
size++;
if (_uiSettings.getCategories().containsKey(category))
{
final List<Integer> catElList1 = _uiSettings.getCategories().get(category);
size = size + catElList1.size();
}
category++;
size++;
if (_uiSettings.getCategories().containsKey(category))
{
final List<Integer> catElList2 = _uiSettings.getCategories().get(category);
size = size + catElList2.size();
}
category++;
size = size + 4;
if (_uiSettings.getKeys().containsKey(i))
{
final List<ActionKey> keyElList = _uiSettings.getKeys().get(i);
size = size + (keyElList.size() * 20);
}
_uiKeyMapping = player.getVariables().getByteArray(UI_KEY_MAPPING_VAR, SPLIT_VAR);
}
else
{
_uiKeyMapping = null;
}
buffsize = size;
categories = category;
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_UI_SETTING.writeId(packet);
packet.writeD(buffsize);
packet.writeD(categories);
int category = 0;
final int numKeyCt = _uiSettings.getKeys().size();
packet.writeD(numKeyCt);
for (int i = 0; i < numKeyCt; i++)
if (_uiKeyMapping != null)
{
if (_uiSettings.getCategories().containsKey(category))
{
final List<Integer> catElList1 = _uiSettings.getCategories().get(category);
packet.writeC(catElList1.size());
for (int cmd : catElList1)
{
packet.writeC(cmd);
}
}
else
{
packet.writeC(0x00);
}
category++;
if (_uiSettings.getCategories().containsKey(category))
{
final List<Integer> catElList2 = _uiSettings.getCategories().get(category);
packet.writeC(catElList2.size());
for (int cmd : catElList2)
{
packet.writeC(cmd);
}
}
else
{
packet.writeC(0x00);
}
category++;
if (_uiSettings.getKeys().containsKey(i))
{
final List<ActionKey> keyElList = _uiSettings.getKeys().get(i);
packet.writeD(keyElList.size());
for (ActionKey akey : keyElList)
{
packet.writeD(akey.getCommandId());
packet.writeD(akey.getKeyId());
packet.writeD(akey.getToogleKey1());
packet.writeD(akey.getToogleKey2());
packet.writeD(akey.getShowStatus());
}
}
else
{
packet.writeD(0x00);
}
packet.writeD(_uiKeyMapping.length);
packet.writeB(_uiKeyMapping);
}
else
{
packet.writeD(0);
}
packet.writeD(0x11);
packet.writeD(0x10);
return true;
}
}

View File

@ -1,12 +0,0 @@
DROP TABLE IF EXISTS `character_ui_actions`;
CREATE TABLE IF NOT EXISTS `character_ui_actions` (
`charId` int(10) unsigned NOT NULL DEFAULT '0',
`cat` tinyint(4) NOT NULL,
`order` tinyint(4) NOT NULL,
`cmd` int(8) NOT NULL DEFAULT '0',
`key` int(8) NOT NULL,
`tgKey1` int(8) DEFAULT NULL,
`tgKey2` int(8) DEFAULT NULL,
`show` tinyint(4) NOT NULL,
PRIMARY KEY (`charId`,`cat`,`cmd`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

View File

@ -1,8 +0,0 @@
DROP TABLE IF EXISTS `character_ui_categories`;
CREATE TABLE IF NOT EXISTS `character_ui_categories` (
`charId` int(10) unsigned NOT NULL DEFAULT '0',
`catId` tinyint(4) NOT NULL,
`order` tinyint(4) NOT NULL,
`cmdId` int(8) NOT NULL DEFAULT '0',
PRIMARY KEY (`charId`,`catId`,`order`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

View File

@ -1,346 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../xsd/ui.xsd">
<category id="0">
<commands>
<cmd>71</cmd>
<cmd>65</cmd>
<cmd>77</cmd>
<cmd>73</cmd>
<cmd>78</cmd>
<cmd>71</cmd>
<cmd>83</cmd>
<cmd>84</cmd>
<cmd>65</cmd>
<cmd>84</cmd>
<cmd>69</cmd>
<cmd>83</cmd>
<cmd>72</cmd>
<cmd>79</cmd>
<cmd>82</cmd>
<cmd>84</cmd>
<cmd>67</cmd>
<cmd>85</cmd>
<cmd>84</cmd>
<cmd>0</cmd>
</commands>
<keys>
<key cmd="59" key="67" toggleKey1="18" />
<key cmd="60" key="66" toggleKey1="18" />
<key cmd="62" key="74" toggleKey1="18" />
<key cmd="63" key="78" toggleKey1="18" />
<key cmd="64" key="84" toggleKey1="18" />
<key cmd="65" key="72" toggleKey1="18" toggleKey2="16" />
<key cmd="66" key="86" toggleKey1="18" />
<key cmd="67" key="82" toggleKey1="18" />
<key cmd="68" key="75" toggleKey1="18" />
<key cmd="78" key="77" toggleKey1="18" toggleKey2="16" />
<key cmd="70" key="77" toggleKey1="18" />
<key cmd="71" key="79" toggleKey1="18" toggleKey2="16" />
<key cmd="72" key="80" toggleKey1="18" toggleKey2="16" />
<key cmd="73" key="85" toggleKey1="18" />
<key cmd="74" key="82" toggleKey1="18" toggleKey2="16" />
<key cmd="75" key="83" toggleKey1="18" toggleKey2="16" />
<key cmd="76" key="88" toggleKey1="18" />
<key cmd="77" key="73" toggleKey1="18" toggleKey2="16" />
<key cmd="79" key="190" toggleKey1="18" />
<key cmd="80" key="69" toggleKey1="18" toggleKey2="16" />
<key cmd="81" key="76" toggleKey1="18" />
<key cmd="1" key="33" toggleKey1="18" />
<key cmd="2" key="34" toggleKey1="18" />
<key cmd="3" key="27" />
<key cmd="4" key="13" />
<key cmd="5" key="9" />
<key cmd="6" key="72" toggleKey1="18" />
<key cmd="7" key="87" toggleKey1="18" />
<key cmd="10" key="70" toggleKey1="18" />
<key cmd="11" key="80" toggleKey1="18" />
<key cmd="12" key="89" toggleKey1="18" />
<key cmd="49" key="112" toggleKey1="18" />
<key cmd="50" key="113" toggleKey1="18" />
<key cmd="51" key="114" toggleKey1="18" />
<key cmd="52" key="115" toggleKey1="18" />
<key cmd="53" key="116" toggleKey1="18" />
<key cmd="54" key="117" toggleKey1="18" />
<key cmd="55" key="118" toggleKey1="18" />
<key cmd="56" key="119" toggleKey1="18" />
<key cmd="57" key="120" toggleKey1="18" />
<key cmd="58" key="121" toggleKey1="18" />
<key cmd="13" key="112" />
<key cmd="14" key="113" />
<key cmd="15" key="114" />
<key cmd="16" key="115" />
<key cmd="17" key="116" />
<key cmd="18" key="117" />
<key cmd="19" key="118" />
<key cmd="20" key="119" />
<key cmd="21" key="120" />
<key cmd="22" key="121" />
<key cmd="23" key="122" />
<key cmd="24" key="123" />
<key cmd="25" key="49" toggleKey1="18" />
<key cmd="26" key="50" toggleKey1="18" />
<key cmd="27" key="51" toggleKey1="18" />
<key cmd="28" key="52" toggleKey1="18" />
<key cmd="29" key="53" toggleKey1="18" />
<key cmd="30" key="54" toggleKey1="18" />
<key cmd="31" key="55" toggleKey1="18" />
<key cmd="32" key="56" toggleKey1="18" />
<key cmd="33" key="57" toggleKey1="18" />
<key cmd="34" key="48" toggleKey1="18" />
<key cmd="35" key="189" toggleKey1="18" />
<key cmd="36" key="187" toggleKey1="18" />
<key cmd="37" key="97" toggleKey1="18" />
<key cmd="38" key="98" toggleKey1="18" />
<key cmd="39" key="99" toggleKey1="18" />
<key cmd="40" key="100" toggleKey1="18" />
<key cmd="41" key="101" toggleKey1="18" />
<key cmd="42" key="102" toggleKey1="18" />
<key cmd="43" key="103" toggleKey1="18" />
<key cmd="44" key="104" toggleKey1="18" />
<key cmd="45" key="105" toggleKey1="18" />
<key cmd="46" key="96" toggleKey1="18" />
<key cmd="47" key="111" toggleKey1="18" />
<key cmd="48" key="106" toggleKey1="18" />
<key cmd="92" key="32" toggleKey1="18" />
<key cmd="93" key="33" />
<key cmd="94" key="34" />
<key cmd="95" key="36" />
<key cmd="89" key="35" />
<key cmd="86" key="46" />
</keys>
</category>
<category id="1">
<commands>
<cmd>71</cmd>
<cmd>65</cmd>
<cmd>77</cmd>
<cmd>73</cmd>
<cmd>78</cmd>
<cmd>71</cmd>
<cmd>83</cmd>
<cmd>84</cmd>
<cmd>65</cmd>
<cmd>84</cmd>
<cmd>69</cmd>
<cmd>0</cmd>
</commands>
<keys>
<key cmd="59" key="67" />
<key cmd="60" key="66" />
<key cmd="63" key="78" />
<key cmd="64" key="84" />
<key cmd="66" key="86" />
<key cmd="67" key="82" />
<key cmd="68" key="75" />
<key cmd="70" key="77" />
<key cmd="73" key="85" />
<key cmd="76" key="88" />
<key cmd="79" key="190" />
<key cmd="80" key="69" />
<key cmd="13" key="112" />
<key cmd="14" key="113" />
<key cmd="15" key="114" />
<key cmd="16" key="115" />
<key cmd="17" key="116" />
<key cmd="18" key="117" />
<key cmd="19" key="118" />
<key cmd="20" key="119" />
<key cmd="21" key="120" />
<key cmd="22" key="121" />
<key cmd="23" key="122" />
<key cmd="24" key="123" />
<key cmd="25" key="49" />
<key cmd="26" key="50" />
<key cmd="27" key="51" />
<key cmd="28" key="52" />
<key cmd="29" key="53" />
<key cmd="30" key="54" />
<key cmd="31" key="55" />
<key cmd="32" key="56" />
<key cmd="33" key="57" />
<key cmd="34" key="48" />
<key cmd="35" key="189" />
<key cmd="36" key="187" />
<key cmd="37" key="97" />
<key cmd="38" key="98" />
<key cmd="39" key="99" />
<key cmd="40" key="100" />
<key cmd="41" key="101" />
<key cmd="42" key="102" />
<key cmd="43" key="103" />
<key cmd="44" key="104" />
<key cmd="45" key="105" />
<key cmd="46" key="96" />
<key cmd="47" key="111" />
<key cmd="48" key="106" />
<key cmd="82" key="65" />
<key cmd="83" key="68" />
<key cmd="84" key="87" />
<key cmd="85" key="83" />
<key cmd="86" key="46" />
<key cmd="96" key="65" showType="3" />
<key cmd="97" key="68" showType="3" />
<key cmd="98" key="87" showType="3" />
<key cmd="99" key="83" showType="3" />
</keys>
</category>
<category id="2">
<commands>
<cmd>84</cmd>
<cmd>69</cmd>
<cmd>77</cmd>
<cmd>80</cmd>
<cmd>83</cmd>
<cmd>84</cmd>
<cmd>65</cmd>
<cmd>84</cmd>
<cmd>69</cmd>
<cmd>83</cmd>
<cmd>72</cmd>
<cmd>79</cmd>
<cmd>82</cmd>
<cmd>84</cmd>
<cmd>67</cmd>
<cmd>85</cmd>
<cmd>84</cmd>
<cmd>0</cmd>
</commands>
<keys>
<key cmd="59" key="67" />
<key cmd="60" key="66" />
<key cmd="63" key="78" />
<key cmd="64" key="84" />
<key cmd="66" key="86" />
<key cmd="67" key="82" />
<key cmd="68" key="75" />
<key cmd="70" key="77" />
<key cmd="73" key="85" />
<key cmd="76" key="88" />
<key cmd="79" key="190" />
<key cmd="128" key="49" />
<key cmd="129" key="50" />
<key cmd="130" key="51" />
<key cmd="131" key="52" />
<key cmd="132" key="53" />
<key cmd="133" key="54" />
<key cmd="134" key="55" />
<key cmd="135" key="56" />
<key cmd="136" key="57" />
<key cmd="137" key="48" />
<key cmd="138" key="189" />
<key cmd="139" key="187" />
<key cmd="140" key="32" />
<key cmd="86" key="46" />
<key cmd="82" key="65" />
<key cmd="83" key="68" />
<key cmd="84" key="87" />
<key cmd="152" key="83" />
<key cmd="143" key="69" />
<key cmd="144" key="81" />
<key cmd="96" key="65" showType="3" />
<key cmd="97" key="68" showType="3" />
<key cmd="98" key="87" showType="3" />
<key cmd="147" key="69" showType="3" />
<key cmd="148" key="81" showType="3" />
<key cmd="93" key="33" />
<key cmd="94" key="34" />
<key cmd="95" key="36" />
</keys>
</category>
<category id="3">
<keys>
<key cmd="59" key="67" />
<key cmd="60" key="66" />
<key cmd="63" key="78" />
<key cmd="64" key="84" />
<key cmd="66" key="86" />
<key cmd="67" key="82" />
<key cmd="68" key="75" />
<key cmd="70" key="77" />
<key cmd="73" key="85" />
<key cmd="76" key="88" />
<key cmd="79" key="190" />
<key cmd="116" key="49" />
<key cmd="117" key="50" />
<key cmd="118" key="51" />
<key cmd="119" key="52" />
<key cmd="120" key="53" />
<key cmd="121" key="54" />
<key cmd="122" key="55" />
<key cmd="123" key="56" />
<key cmd="124" key="57" />
<key cmd="125" key="48" />
<key cmd="126" key="189" />
<key cmd="127" key="187" />
<key cmd="140" key="32" />
<key cmd="86" key="46" />
<key cmd="145" key="106" />
<key cmd="82" key="65" />
<key cmd="83" key="68" />
<key cmd="84" key="87" />
<key cmd="151" key="83" />
<key cmd="141" key="69" />
<key cmd="142" key="81" />
<key cmd="96" key="65" showType="3" />
<key cmd="97" key="68" showType="3" />
<key cmd="98" key="87" showType="3" />
<key cmd="147" key="69" showType="3" />
<key cmd="148" key="81" showType="3" />
<key cmd="93" key="33" />
<key cmd="94" key="34" />
<key cmd="95" key="36" />
</keys>
</category>
<category id="4">
<commands>
<cmd>70</cmd>
<cmd>76</cmd>
<cmd>73</cmd>
<cmd>71</cmd>
<cmd>72</cmd>
<cmd>84</cmd>
<cmd>83</cmd>
<cmd>84</cmd>
<cmd>65</cmd>
<cmd>84</cmd>
<cmd>69</cmd>
<cmd>83</cmd>
<cmd>72</cmd>
<cmd>79</cmd>
<cmd>82</cmd>
<cmd>84</cmd>
<cmd>67</cmd>
<cmd>85</cmd>
<cmd>84</cmd>
<cmd>0</cmd>
</commands>
</category>
<category id="6">
<commands>
<cmd>70</cmd>
<cmd>76</cmd>
<cmd>73</cmd>
<cmd>71</cmd>
<cmd>72</cmd>
<cmd>84</cmd>
<cmd>84</cmd>
<cmd>82</cmd>
<cmd>65</cmd>
<cmd>78</cmd>
<cmd>83</cmd>
<cmd>70</cmd>
<cmd>79</cmd>
<cmd>82</cmd>
<cmd>77</cmd>
<cmd>83</cmd>
<cmd>72</cmd>
<cmd>79</cmd>
<cmd>82</cmd>
<cmd>84</cmd>
<cmd>67</cmd>
<cmd>85</cmd>
<cmd>84</cmd>
<cmd>0</cmd>
</commands>
</category>
</list>

View File

@ -1,38 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="list">
<xs:complexType>
<xs:sequence minOccurs="1" maxOccurs="1">
<xs:element name="category" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence minOccurs="1" maxOccurs="1">
<xs:element name="commands" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence minOccurs="1" maxOccurs="1">
<xs:element name="cmd" minOccurs="1" maxOccurs="unbounded" type="xs:nonNegativeInteger" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="keys" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence minOccurs="1" maxOccurs="1">
<xs:element name="key" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="cmd" type="xs:positiveInteger" use="required" />
<xs:attribute name="key" type="xs:positiveInteger" use="required" />
<xs:attribute name="toggleKey1" type="xs:nonNegativeInteger" />
<xs:attribute name="toggleKey2" type="xs:nonNegativeInteger" />
<xs:attribute name="showType" type="xs:positiveInteger" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:nonNegativeInteger" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

View File

@ -92,7 +92,6 @@ import com.l2jmobius.gameserver.data.xml.impl.SpawnsData;
import com.l2jmobius.gameserver.data.xml.impl.StaticObjectData;
import com.l2jmobius.gameserver.data.xml.impl.TeleportersData;
import com.l2jmobius.gameserver.data.xml.impl.TransformData;
import com.l2jmobius.gameserver.data.xml.impl.UIData;
import com.l2jmobius.gameserver.datatables.AugmentationData;
import com.l2jmobius.gameserver.datatables.BotReportTable;
import com.l2jmobius.gameserver.datatables.EventDroplist;
@ -313,7 +312,6 @@ public class GameServer
CrestTable.getInstance();
TeleportLocationTable.getInstance();
TeleportersData.getInstance();
UIData.getInstance();
MatchingRoomManager.getInstance();
PetitionManager.getInstance();
CursedWeaponsManager.getInstance();

View File

@ -1,194 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU 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
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.data.xml.impl;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.gameserver.model.ActionKey;
/**
* UI Data parser.
* @author Zoey76
*/
public class UIData implements IGameXmlReader
{
private static final Logger LOGGER = Logger.getLogger(UIData.class.getName());
private final Map<Integer, List<ActionKey>> _storedKeys = new HashMap<>();
private final Map<Integer, List<Integer>> _storedCategories = new HashMap<>();
protected UIData()
{
load();
}
@Override
public void load()
{
_storedKeys.clear();
_storedCategories.clear();
parseDatapackFile("data/ui/ui_en.xml");
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _storedKeys.size() + " keys " + _storedCategories.size() + " categories.");
}
@Override
public void parseDocument(Document doc, File f)
{
for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling())
{
if ("list".equalsIgnoreCase(n.getNodeName()))
{
for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
{
if ("category".equalsIgnoreCase(d.getNodeName()))
{
parseCategory(d);
}
}
}
}
}
private void parseCategory(Node n)
{
final int cat = parseInteger(n.getAttributes(), "id");
for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
{
if ("commands".equalsIgnoreCase(d.getNodeName()))
{
parseCommands(cat, d);
}
else if ("keys".equalsIgnoreCase(d.getNodeName()))
{
parseKeys(cat, d);
}
}
}
private void parseCommands(int cat, Node d)
{
for (Node c = d.getFirstChild(); c != null; c = c.getNextSibling())
{
if ("cmd".equalsIgnoreCase(c.getNodeName()))
{
addCategory(_storedCategories, cat, Integer.parseInt(c.getTextContent()));
}
}
}
private void parseKeys(int cat, Node d)
{
for (Node c = d.getFirstChild(); c != null; c = c.getNextSibling())
{
if ("key".equalsIgnoreCase(c.getNodeName()))
{
final ActionKey akey = new ActionKey(cat);
for (int i = 0; i < c.getAttributes().getLength(); i++)
{
final Node att = c.getAttributes().item(i);
final int val = Integer.parseInt(att.getNodeValue());
switch (att.getNodeName())
{
case "cmd":
{
akey.setCommandId(val);
break;
}
case "key":
{
akey.setKeyId(val);
break;
}
case "toggleKey1":
{
akey.setToogleKey1(val);
break;
}
case "toggleKey2":
{
akey.setToogleKey2(val);
break;
}
case "showType":
{
akey.setShowStatus(val);
break;
}
}
}
addKey(_storedKeys, cat, akey);
}
}
}
/**
* Add a category to the stored categories.
* @param map the map to store the category
* @param cat the category
* @param cmd the command
*/
public static void addCategory(Map<Integer, List<Integer>> map, int cat, int cmd)
{
map.computeIfAbsent(cat, k -> new ArrayList<>()).add(cmd);
}
/**
* Create and insert an Action Key into the stored keys.
* @param map the map to store the key
* @param cat the category
* @param akey the action key
*/
public static void addKey(Map<Integer, List<ActionKey>> map, int cat, ActionKey akey)
{
map.computeIfAbsent(cat, k -> new ArrayList<>()).add(akey);
}
/**
* @return the categories
*/
public Map<Integer, List<Integer>> getCategories()
{
return _storedCategories;
}
/**
* @return the keys
*/
public Map<Integer, List<ActionKey>> getKeys()
{
return _storedKeys;
}
public static UIData getInstance()
{
return SingletonHolder._instance;
}
private static class SingletonHolder
{
protected static final UIData _instance = new UIData();
}
}

View File

@ -55,8 +55,6 @@ public abstract class IdFactory
"SELECT charId FROM character_skills WHERE charId >= ? AND charId < ?",
"SELECT charId FROM character_skills_save WHERE charId >= ? AND charId < ?",
"SELECT charId FROM character_subclasses WHERE charId >= ? AND charId < ?",
"SELECT charId FROM character_ui_actions WHERE charId >= ? AND charId < ?",
"SELECT charId FROM character_ui_categories WHERE charId >= ? AND charId < ?",
"SELECT charId FROM characters WHERE charId >= ? AND charId < ?",
"SELECT clanid FROM characters WHERE clanid >= ? AND clanid < ?",
"SELECT clan_id FROM clan_data WHERE clan_id >= ? AND clan_id < ?",
@ -192,8 +190,6 @@ public abstract class IdFactory
cleanCount += stmt.executeUpdate("DELETE FROM character_skills_save WHERE character_skills_save.charId NOT IN (SELECT charId FROM characters);");
cleanCount += stmt.executeUpdate("DELETE FROM character_subclasses WHERE character_subclasses.charId NOT IN (SELECT charId FROM characters);");
cleanCount += stmt.executeUpdate("DELETE FROM character_instance_time WHERE character_instance_time.charId NOT IN (SELECT charId FROM characters);");
cleanCount += stmt.executeUpdate("DELETE FROM character_ui_actions WHERE character_ui_actions.charId NOT IN (SELECT charId FROM characters);");
cleanCount += stmt.executeUpdate("DELETE FROM character_ui_categories WHERE character_ui_categories.charId NOT IN (SELECT charId FROM characters);");
// Items
cleanCount += stmt.executeUpdate("DELETE FROM items WHERE items.owner_id NOT IN (SELECT charId FROM characters) AND items.owner_id NOT IN (SELECT clan_id FROM clan_data) AND items.owner_id != -1;");

View File

@ -1,213 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU 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
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.data.xml.impl.UIData;
/**
* UI Keys Settings class.
* @author mrTJO, Zoey76
*/
public class UIKeysSettings
{
private static final Logger _log = Logger.getLogger(UIKeysSettings.class.getName());
private final int _playerObjId;
private Map<Integer, List<ActionKey>> _storedKeys;
private Map<Integer, List<Integer>> _storedCategories;
private boolean _saved = true;
public UIKeysSettings(int playerObjId)
{
_playerObjId = playerObjId;
loadFromDB();
}
public void storeAll(Map<Integer, List<Integer>> catMap, Map<Integer, List<ActionKey>> keyMap)
{
_saved = false;
_storedCategories = catMap;
_storedKeys = keyMap;
}
public void storeCategories(Map<Integer, List<Integer>> catMap)
{
_saved = false;
_storedCategories = catMap;
}
public Map<Integer, List<Integer>> getCategories()
{
return _storedCategories;
}
public void storeKeys(Map<Integer, List<ActionKey>> keyMap)
{
_saved = false;
_storedKeys = keyMap;
}
public Map<Integer, List<ActionKey>> getKeys()
{
return _storedKeys;
}
public void loadFromDB()
{
getCatsFromDB();
getKeysFromDB();
}
/**
* Save Categories and Mapped Keys into GameServer DataBase
*/
public void saveInDB()
{
String query;
if (_saved)
{
return;
}
query = "REPLACE INTO character_ui_categories (`charId`, `catId`, `order`, `cmdId`) VALUES ";
for (int category : _storedCategories.keySet())
{
int order = 0;
for (int key : _storedCategories.get(category))
{
query += "(" + _playerObjId + ", " + category + ", " + (order++) + ", " + key + "),";
}
}
query = query.substring(0, query.length() - 1) + "; ";
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(query))
{
statement.execute();
}
catch (Exception e)
{
_log.log(Level.WARNING, "Exception: saveInDB(): " + e.getMessage(), e);
}
query = "REPLACE INTO character_ui_actions (`charId`, `cat`, `order`, `cmd`, `key`, `tgKey1`, `tgKey2`, `show`) VALUES";
for (List<ActionKey> keyLst : _storedKeys.values())
{
int order = 0;
for (ActionKey key : keyLst)
{
query += key.getSqlSaveString(_playerObjId, order++) + ",";
}
}
query = query.substring(0, query.length() - 1) + ";";
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(query))
{
statement.execute();
}
catch (Exception e)
{
_log.log(Level.WARNING, "Exception: saveInDB(): " + e.getMessage(), e);
}
_saved = true;
}
public void getCatsFromDB()
{
if (_storedCategories != null)
{
return;
}
_storedCategories = new HashMap<>();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement stmt = con.prepareStatement("SELECT * FROM character_ui_categories WHERE `charId` = ? ORDER BY `catId`, `order`"))
{
stmt.setInt(1, _playerObjId);
try (ResultSet rs = stmt.executeQuery())
{
while (rs.next())
{
UIData.addCategory(_storedCategories, rs.getInt("catId"), rs.getInt("cmdId"));
}
}
}
catch (Exception e)
{
_log.log(Level.WARNING, "Exception: getCatsFromDB(): " + e.getMessage(), e);
}
if (_storedCategories.isEmpty())
{
_storedCategories = UIData.getInstance().getCategories();
}
}
public void getKeysFromDB()
{
if (_storedKeys != null)
{
return;
}
_storedKeys = new HashMap<>();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement stmt = con.prepareStatement("SELECT * FROM character_ui_actions WHERE `charId` = ? ORDER BY `cat`, `order`"))
{
stmt.setInt(1, _playerObjId);
try (ResultSet rs = stmt.executeQuery())
{
while (rs.next())
{
final int cat = rs.getInt("cat");
final int cmd = rs.getInt("cmd");
final int key = rs.getInt("key");
final int tgKey1 = rs.getInt("tgKey1");
final int tgKey2 = rs.getInt("tgKey2");
final int show = rs.getInt("show");
UIData.addKey(_storedKeys, cat, new ActionKey(cat, cmd, key, tgKey1, tgKey2, show));
}
}
}
catch (Exception e)
{
_log.log(Level.WARNING, "Exception: getKeysFromDB(): " + e.getMessage(), e);
}
if (_storedKeys.isEmpty())
{
_storedKeys = UIData.getInstance().getKeys();
}
}
public boolean isSaved()
{
return _saved;
}
}

View File

@ -150,7 +150,6 @@ import com.l2jmobius.gameserver.model.TeleportBookmark;
import com.l2jmobius.gameserver.model.TeleportWhereType;
import com.l2jmobius.gameserver.model.TimeStamp;
import com.l2jmobius.gameserver.model.TradeList;
import com.l2jmobius.gameserver.model.UIKeysSettings;
import com.l2jmobius.gameserver.model.actor.L2Attackable;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Npc;
@ -853,9 +852,6 @@ public final class L2PcInstance extends L2Playable
_PvPRegTask = null;
}
// Character UI
private UIKeysSettings _uiKeySettings;
// Monster Book variables
private final static String MONSTER_BOOK_KILLS_VAR = "MONSTER_BOOK_KILLS_";
private final static String MONSTER_BOOK_LEVEL_VAR = "MONSTER_BOOK_LEVEL_";
@ -6823,11 +6819,6 @@ public final class L2PcInstance extends L2Playable
player.restoreFriendList();
if (Config.STORE_UI_SETTINGS)
{
player.restoreUISettings();
}
player.loadRecommendations();
player.startRecoGiveTask();
player.startOnlineTimeUpdateTask();
@ -7105,10 +7096,6 @@ public final class L2PcInstance extends L2Playable
{
storeRecipeShopList();
}
if (Config.STORE_UI_SETTINGS)
{
storeUISettings();
}
final PlayerVariables vars = getScript(PlayerVariables.class);
if (vars != null)
@ -12703,29 +12690,6 @@ public final class L2PcInstance extends L2Playable
return super.isMovementDisabled() || (getMovieHolder() != null) || _fishing.isFishing();
}
private void restoreUISettings()
{
_uiKeySettings = new UIKeysSettings(getObjectId());
}
private void storeUISettings()
{
if (_uiKeySettings == null)
{
return;
}
if (!_uiKeySettings.isSaved())
{
_uiKeySettings.saveInDB();
}
}
public UIKeysSettings getUISettings()
{
return _uiKeySettings;
}
public String getHtmlPrefix()
{
if (!Config.MULTILANG_ENABLE)

View File

@ -16,64 +16,30 @@
*/
package com.l2jmobius.gameserver.network.clientpackets;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.l2jmobius.Config;
import com.l2jmobius.commons.network.PacketReader;
import com.l2jmobius.gameserver.data.xml.impl.UIData;
import com.l2jmobius.gameserver.model.ActionKey;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.ConnectionState;
import com.l2jmobius.gameserver.network.L2GameClient;
/**
* Request Save Key Mapping client packet.
* @author mrTJO, Zoey76
* @author Mobius
*/
public class RequestSaveKeyMapping implements IClientIncomingPacket
{
private final Map<Integer, List<ActionKey>> _keyMap = new HashMap<>();
private final Map<Integer, List<Integer>> _catMap = new HashMap<>();
public static final String UI_KEY_MAPPING_VAR = "UI_KEY_MAPPING";
public static final String SPLIT_VAR = " ";
private byte[] _uiKeyMapping;
@Override
public boolean read(L2GameClient client, PacketReader packet)
{
int category = 0;
packet.readD(); // Unknown
packet.readD(); // Unknown
final int _tabNum = packet.readD();
for (int i = 0; i < _tabNum; i++)
final int dataSize = packet.readD();
if (dataSize > 0)
{
final int cmd1Size = packet.readC();
for (int j = 0; j < cmd1Size; j++)
{
UIData.addCategory(_catMap, category, packet.readC());
}
category++;
final int cmd2Size = packet.readC();
for (int j = 0; j < cmd2Size; j++)
{
UIData.addCategory(_catMap, category, packet.readC());
}
category++;
final int cmdSize = packet.readD();
for (int j = 0; j < cmdSize; j++)
{
final int cmd = packet.readD();
final int key = packet.readD();
final int tgKey1 = packet.readD();
final int tgKey2 = packet.readD();
final int show = packet.readD();
UIData.addKey(_keyMap, i, new ActionKey(i, cmd, key, tgKey1, tgKey2, show));
}
_uiKeyMapping = packet.readB(dataSize);
}
packet.readD();
packet.readD();
return true;
}
@ -81,10 +47,19 @@ public class RequestSaveKeyMapping implements IClientIncomingPacket
public void run(L2GameClient client)
{
final L2PcInstance player = client.getActiveChar();
if (!Config.STORE_UI_SETTINGS || (player == null) || (client.getConnectionState() != ConnectionState.IN_GAME))
if (!Config.STORE_UI_SETTINGS || //
(player == null) || //
(_uiKeyMapping == null) || //
(client.getConnectionState() != ConnectionState.IN_GAME))
{
return;
}
player.getUISettings().storeAll(_catMap, _keyMap);
String uiKeyMapping = "";
for (Byte b : _uiKeyMapping)
{
uiKeyMapping += b + SPLIT_VAR;
}
player.getVariables().set(UI_KEY_MAPPING_VAR, uiKeyMapping);
}
}

View File

@ -16,124 +16,44 @@
*/
package com.l2jmobius.gameserver.network.serverpackets;
import java.util.List;
import com.l2jmobius.commons.network.PacketWriter;
import com.l2jmobius.gameserver.model.ActionKey;
import com.l2jmobius.gameserver.model.UIKeysSettings;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.OutgoingPackets;
/**
* @author mrTJO
* @author Mobius
*/
public class ExUISetting implements IClientOutgoingPacket
{
private final UIKeysSettings _uiSettings;
private int buffsize, categories;
public static final String UI_KEY_MAPPING_VAR = "UI_KEY_MAPPING";
public static final String SPLIT_VAR = " ";
private final byte[] _uiKeyMapping;
public ExUISetting(L2PcInstance player)
{
_uiSettings = player.getUISettings();
calcSize();
}
private void calcSize()
{
int size = 16; // initial header and footer
int category = 0;
final int numKeyCt = _uiSettings.getKeys().size();
for (int i = 0; i < numKeyCt; i++)
if (player.getVariables().hasVariable(UI_KEY_MAPPING_VAR))
{
size++;
if (_uiSettings.getCategories().containsKey(category))
{
final List<Integer> catElList1 = _uiSettings.getCategories().get(category);
size = size + catElList1.size();
}
category++;
size++;
if (_uiSettings.getCategories().containsKey(category))
{
final List<Integer> catElList2 = _uiSettings.getCategories().get(category);
size = size + catElList2.size();
}
category++;
size = size + 4;
if (_uiSettings.getKeys().containsKey(i))
{
final List<ActionKey> keyElList = _uiSettings.getKeys().get(i);
size = size + (keyElList.size() * 20);
}
_uiKeyMapping = player.getVariables().getByteArray(UI_KEY_MAPPING_VAR, SPLIT_VAR);
}
else
{
_uiKeyMapping = null;
}
buffsize = size;
categories = category;
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_UI_SETTING.writeId(packet);
packet.writeD(buffsize);
packet.writeD(categories);
int category = 0;
final int numKeyCt = _uiSettings.getKeys().size();
packet.writeD(numKeyCt);
for (int i = 0; i < numKeyCt; i++)
if (_uiKeyMapping != null)
{
if (_uiSettings.getCategories().containsKey(category))
{
final List<Integer> catElList1 = _uiSettings.getCategories().get(category);
packet.writeC(catElList1.size());
for (int cmd : catElList1)
{
packet.writeC(cmd);
}
}
else
{
packet.writeC(0x00);
}
category++;
if (_uiSettings.getCategories().containsKey(category))
{
final List<Integer> catElList2 = _uiSettings.getCategories().get(category);
packet.writeC(catElList2.size());
for (int cmd : catElList2)
{
packet.writeC(cmd);
}
}
else
{
packet.writeC(0x00);
}
category++;
if (_uiSettings.getKeys().containsKey(i))
{
final List<ActionKey> keyElList = _uiSettings.getKeys().get(i);
packet.writeD(keyElList.size());
for (ActionKey akey : keyElList)
{
packet.writeD(akey.getCommandId());
packet.writeD(akey.getKeyId());
packet.writeD(akey.getToogleKey1());
packet.writeD(akey.getToogleKey2());
packet.writeD(akey.getShowStatus());
}
}
else
{
packet.writeD(0x00);
}
packet.writeD(_uiKeyMapping.length);
packet.writeB(_uiKeyMapping);
}
else
{
packet.writeD(0);
}
packet.writeD(0x11);
packet.writeD(0x10);
return true;
}
}

View File

@ -1,12 +0,0 @@
DROP TABLE IF EXISTS `character_ui_actions`;
CREATE TABLE IF NOT EXISTS `character_ui_actions` (
`charId` int(10) unsigned NOT NULL DEFAULT '0',
`cat` tinyint(4) NOT NULL,
`order` tinyint(4) NOT NULL,
`cmd` int(8) NOT NULL DEFAULT '0',
`key` int(8) NOT NULL,
`tgKey1` int(8) DEFAULT NULL,
`tgKey2` int(8) DEFAULT NULL,
`show` tinyint(4) NOT NULL,
PRIMARY KEY (`charId`,`cat`,`cmd`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

View File

@ -1,8 +0,0 @@
DROP TABLE IF EXISTS `character_ui_categories`;
CREATE TABLE IF NOT EXISTS `character_ui_categories` (
`charId` int(10) unsigned NOT NULL DEFAULT '0',
`catId` tinyint(4) NOT NULL,
`order` tinyint(4) NOT NULL,
`cmdId` int(8) NOT NULL DEFAULT '0',
PRIMARY KEY (`charId`,`catId`,`order`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

View File

@ -1,346 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../xsd/ui.xsd">
<category id="0">
<commands>
<cmd>71</cmd>
<cmd>65</cmd>
<cmd>77</cmd>
<cmd>73</cmd>
<cmd>78</cmd>
<cmd>71</cmd>
<cmd>83</cmd>
<cmd>84</cmd>
<cmd>65</cmd>
<cmd>84</cmd>
<cmd>69</cmd>
<cmd>83</cmd>
<cmd>72</cmd>
<cmd>79</cmd>
<cmd>82</cmd>
<cmd>84</cmd>
<cmd>67</cmd>
<cmd>85</cmd>
<cmd>84</cmd>
<cmd>0</cmd>
</commands>
<keys>
<key cmd="59" key="67" toggleKey1="18" />
<key cmd="60" key="66" toggleKey1="18" />
<key cmd="62" key="74" toggleKey1="18" />
<key cmd="63" key="78" toggleKey1="18" />
<key cmd="64" key="84" toggleKey1="18" />
<key cmd="65" key="72" toggleKey1="18" toggleKey2="16" />
<key cmd="66" key="86" toggleKey1="18" />
<key cmd="67" key="82" toggleKey1="18" />
<key cmd="68" key="75" toggleKey1="18" />
<key cmd="78" key="77" toggleKey1="18" toggleKey2="16" />
<key cmd="70" key="77" toggleKey1="18" />
<key cmd="71" key="79" toggleKey1="18" toggleKey2="16" />
<key cmd="72" key="80" toggleKey1="18" toggleKey2="16" />
<key cmd="73" key="85" toggleKey1="18" />
<key cmd="74" key="82" toggleKey1="18" toggleKey2="16" />
<key cmd="75" key="83" toggleKey1="18" toggleKey2="16" />
<key cmd="76" key="88" toggleKey1="18" />
<key cmd="77" key="73" toggleKey1="18" toggleKey2="16" />
<key cmd="79" key="190" toggleKey1="18" />
<key cmd="80" key="69" toggleKey1="18" toggleKey2="16" />
<key cmd="81" key="76" toggleKey1="18" />
<key cmd="1" key="33" toggleKey1="18" />
<key cmd="2" key="34" toggleKey1="18" />
<key cmd="3" key="27" />
<key cmd="4" key="13" />
<key cmd="5" key="9" />
<key cmd="6" key="72" toggleKey1="18" />
<key cmd="7" key="87" toggleKey1="18" />
<key cmd="10" key="70" toggleKey1="18" />
<key cmd="11" key="80" toggleKey1="18" />
<key cmd="12" key="89" toggleKey1="18" />
<key cmd="49" key="112" toggleKey1="18" />
<key cmd="50" key="113" toggleKey1="18" />
<key cmd="51" key="114" toggleKey1="18" />
<key cmd="52" key="115" toggleKey1="18" />
<key cmd="53" key="116" toggleKey1="18" />
<key cmd="54" key="117" toggleKey1="18" />
<key cmd="55" key="118" toggleKey1="18" />
<key cmd="56" key="119" toggleKey1="18" />
<key cmd="57" key="120" toggleKey1="18" />
<key cmd="58" key="121" toggleKey1="18" />
<key cmd="13" key="112" />
<key cmd="14" key="113" />
<key cmd="15" key="114" />
<key cmd="16" key="115" />
<key cmd="17" key="116" />
<key cmd="18" key="117" />
<key cmd="19" key="118" />
<key cmd="20" key="119" />
<key cmd="21" key="120" />
<key cmd="22" key="121" />
<key cmd="23" key="122" />
<key cmd="24" key="123" />
<key cmd="25" key="49" toggleKey1="18" />
<key cmd="26" key="50" toggleKey1="18" />
<key cmd="27" key="51" toggleKey1="18" />
<key cmd="28" key="52" toggleKey1="18" />
<key cmd="29" key="53" toggleKey1="18" />
<key cmd="30" key="54" toggleKey1="18" />
<key cmd="31" key="55" toggleKey1="18" />
<key cmd="32" key="56" toggleKey1="18" />
<key cmd="33" key="57" toggleKey1="18" />
<key cmd="34" key="48" toggleKey1="18" />
<key cmd="35" key="189" toggleKey1="18" />
<key cmd="36" key="187" toggleKey1="18" />
<key cmd="37" key="97" toggleKey1="18" />
<key cmd="38" key="98" toggleKey1="18" />
<key cmd="39" key="99" toggleKey1="18" />
<key cmd="40" key="100" toggleKey1="18" />
<key cmd="41" key="101" toggleKey1="18" />
<key cmd="42" key="102" toggleKey1="18" />
<key cmd="43" key="103" toggleKey1="18" />
<key cmd="44" key="104" toggleKey1="18" />
<key cmd="45" key="105" toggleKey1="18" />
<key cmd="46" key="96" toggleKey1="18" />
<key cmd="47" key="111" toggleKey1="18" />
<key cmd="48" key="106" toggleKey1="18" />
<key cmd="92" key="32" toggleKey1="18" />
<key cmd="93" key="33" />
<key cmd="94" key="34" />
<key cmd="95" key="36" />
<key cmd="89" key="35" />
<key cmd="86" key="46" />
</keys>
</category>
<category id="1">
<commands>
<cmd>71</cmd>
<cmd>65</cmd>
<cmd>77</cmd>
<cmd>73</cmd>
<cmd>78</cmd>
<cmd>71</cmd>
<cmd>83</cmd>
<cmd>84</cmd>
<cmd>65</cmd>
<cmd>84</cmd>
<cmd>69</cmd>
<cmd>0</cmd>
</commands>
<keys>
<key cmd="59" key="67" />
<key cmd="60" key="66" />
<key cmd="63" key="78" />
<key cmd="64" key="84" />
<key cmd="66" key="86" />
<key cmd="67" key="82" />
<key cmd="68" key="75" />
<key cmd="70" key="77" />
<key cmd="73" key="85" />
<key cmd="76" key="88" />
<key cmd="79" key="190" />
<key cmd="80" key="69" />
<key cmd="13" key="112" />
<key cmd="14" key="113" />
<key cmd="15" key="114" />
<key cmd="16" key="115" />
<key cmd="17" key="116" />
<key cmd="18" key="117" />
<key cmd="19" key="118" />
<key cmd="20" key="119" />
<key cmd="21" key="120" />
<key cmd="22" key="121" />
<key cmd="23" key="122" />
<key cmd="24" key="123" />
<key cmd="25" key="49" />
<key cmd="26" key="50" />
<key cmd="27" key="51" />
<key cmd="28" key="52" />
<key cmd="29" key="53" />
<key cmd="30" key="54" />
<key cmd="31" key="55" />
<key cmd="32" key="56" />
<key cmd="33" key="57" />
<key cmd="34" key="48" />
<key cmd="35" key="189" />
<key cmd="36" key="187" />
<key cmd="37" key="97" />
<key cmd="38" key="98" />
<key cmd="39" key="99" />
<key cmd="40" key="100" />
<key cmd="41" key="101" />
<key cmd="42" key="102" />
<key cmd="43" key="103" />
<key cmd="44" key="104" />
<key cmd="45" key="105" />
<key cmd="46" key="96" />
<key cmd="47" key="111" />
<key cmd="48" key="106" />
<key cmd="82" key="65" />
<key cmd="83" key="68" />
<key cmd="84" key="87" />
<key cmd="85" key="83" />
<key cmd="86" key="46" />
<key cmd="96" key="65" showType="3" />
<key cmd="97" key="68" showType="3" />
<key cmd="98" key="87" showType="3" />
<key cmd="99" key="83" showType="3" />
</keys>
</category>
<category id="2">
<commands>
<cmd>84</cmd>
<cmd>69</cmd>
<cmd>77</cmd>
<cmd>80</cmd>
<cmd>83</cmd>
<cmd>84</cmd>
<cmd>65</cmd>
<cmd>84</cmd>
<cmd>69</cmd>
<cmd>83</cmd>
<cmd>72</cmd>
<cmd>79</cmd>
<cmd>82</cmd>
<cmd>84</cmd>
<cmd>67</cmd>
<cmd>85</cmd>
<cmd>84</cmd>
<cmd>0</cmd>
</commands>
<keys>
<key cmd="59" key="67" />
<key cmd="60" key="66" />
<key cmd="63" key="78" />
<key cmd="64" key="84" />
<key cmd="66" key="86" />
<key cmd="67" key="82" />
<key cmd="68" key="75" />
<key cmd="70" key="77" />
<key cmd="73" key="85" />
<key cmd="76" key="88" />
<key cmd="79" key="190" />
<key cmd="128" key="49" />
<key cmd="129" key="50" />
<key cmd="130" key="51" />
<key cmd="131" key="52" />
<key cmd="132" key="53" />
<key cmd="133" key="54" />
<key cmd="134" key="55" />
<key cmd="135" key="56" />
<key cmd="136" key="57" />
<key cmd="137" key="48" />
<key cmd="138" key="189" />
<key cmd="139" key="187" />
<key cmd="140" key="32" />
<key cmd="86" key="46" />
<key cmd="82" key="65" />
<key cmd="83" key="68" />
<key cmd="84" key="87" />
<key cmd="152" key="83" />
<key cmd="143" key="69" />
<key cmd="144" key="81" />
<key cmd="96" key="65" showType="3" />
<key cmd="97" key="68" showType="3" />
<key cmd="98" key="87" showType="3" />
<key cmd="147" key="69" showType="3" />
<key cmd="148" key="81" showType="3" />
<key cmd="93" key="33" />
<key cmd="94" key="34" />
<key cmd="95" key="36" />
</keys>
</category>
<category id="3">
<keys>
<key cmd="59" key="67" />
<key cmd="60" key="66" />
<key cmd="63" key="78" />
<key cmd="64" key="84" />
<key cmd="66" key="86" />
<key cmd="67" key="82" />
<key cmd="68" key="75" />
<key cmd="70" key="77" />
<key cmd="73" key="85" />
<key cmd="76" key="88" />
<key cmd="79" key="190" />
<key cmd="116" key="49" />
<key cmd="117" key="50" />
<key cmd="118" key="51" />
<key cmd="119" key="52" />
<key cmd="120" key="53" />
<key cmd="121" key="54" />
<key cmd="122" key="55" />
<key cmd="123" key="56" />
<key cmd="124" key="57" />
<key cmd="125" key="48" />
<key cmd="126" key="189" />
<key cmd="127" key="187" />
<key cmd="140" key="32" />
<key cmd="86" key="46" />
<key cmd="145" key="106" />
<key cmd="82" key="65" />
<key cmd="83" key="68" />
<key cmd="84" key="87" />
<key cmd="151" key="83" />
<key cmd="141" key="69" />
<key cmd="142" key="81" />
<key cmd="96" key="65" showType="3" />
<key cmd="97" key="68" showType="3" />
<key cmd="98" key="87" showType="3" />
<key cmd="147" key="69" showType="3" />
<key cmd="148" key="81" showType="3" />
<key cmd="93" key="33" />
<key cmd="94" key="34" />
<key cmd="95" key="36" />
</keys>
</category>
<category id="4">
<commands>
<cmd>70</cmd>
<cmd>76</cmd>
<cmd>73</cmd>
<cmd>71</cmd>
<cmd>72</cmd>
<cmd>84</cmd>
<cmd>83</cmd>
<cmd>84</cmd>
<cmd>65</cmd>
<cmd>84</cmd>
<cmd>69</cmd>
<cmd>83</cmd>
<cmd>72</cmd>
<cmd>79</cmd>
<cmd>82</cmd>
<cmd>84</cmd>
<cmd>67</cmd>
<cmd>85</cmd>
<cmd>84</cmd>
<cmd>0</cmd>
</commands>
</category>
<category id="6">
<commands>
<cmd>70</cmd>
<cmd>76</cmd>
<cmd>73</cmd>
<cmd>71</cmd>
<cmd>72</cmd>
<cmd>84</cmd>
<cmd>84</cmd>
<cmd>82</cmd>
<cmd>65</cmd>
<cmd>78</cmd>
<cmd>83</cmd>
<cmd>70</cmd>
<cmd>79</cmd>
<cmd>82</cmd>
<cmd>77</cmd>
<cmd>83</cmd>
<cmd>72</cmd>
<cmd>79</cmd>
<cmd>82</cmd>
<cmd>84</cmd>
<cmd>67</cmd>
<cmd>85</cmd>
<cmd>84</cmd>
<cmd>0</cmd>
</commands>
</category>
</list>

View File

@ -1,38 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="list">
<xs:complexType>
<xs:sequence minOccurs="1" maxOccurs="1">
<xs:element name="category" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence minOccurs="1" maxOccurs="1">
<xs:element name="commands" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence minOccurs="1" maxOccurs="1">
<xs:element name="cmd" minOccurs="1" maxOccurs="unbounded" type="xs:nonNegativeInteger" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="keys" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence minOccurs="1" maxOccurs="1">
<xs:element name="key" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="cmd" type="xs:positiveInteger" use="required" />
<xs:attribute name="key" type="xs:positiveInteger" use="required" />
<xs:attribute name="toggleKey1" type="xs:nonNegativeInteger" />
<xs:attribute name="toggleKey2" type="xs:nonNegativeInteger" />
<xs:attribute name="showType" type="xs:positiveInteger" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:nonNegativeInteger" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

View File

@ -92,7 +92,6 @@ import com.l2jmobius.gameserver.data.xml.impl.SpawnsData;
import com.l2jmobius.gameserver.data.xml.impl.StaticObjectData;
import com.l2jmobius.gameserver.data.xml.impl.TeleportersData;
import com.l2jmobius.gameserver.data.xml.impl.TransformData;
import com.l2jmobius.gameserver.data.xml.impl.UIData;
import com.l2jmobius.gameserver.datatables.AugmentationData;
import com.l2jmobius.gameserver.datatables.BotReportTable;
import com.l2jmobius.gameserver.datatables.EventDroplist;
@ -311,7 +310,6 @@ public class GameServer
CrestTable.getInstance();
TeleportLocationTable.getInstance();
TeleportersData.getInstance();
UIData.getInstance();
MatchingRoomManager.getInstance();
PetitionManager.getInstance();
CursedWeaponsManager.getInstance();

View File

@ -1,194 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU 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
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.data.xml.impl;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.gameserver.model.ActionKey;
/**
* UI Data parser.
* @author Zoey76
*/
public class UIData implements IGameXmlReader
{
private static final Logger LOGGER = Logger.getLogger(UIData.class.getName());
private final Map<Integer, List<ActionKey>> _storedKeys = new HashMap<>();
private final Map<Integer, List<Integer>> _storedCategories = new HashMap<>();
protected UIData()
{
load();
}
@Override
public void load()
{
_storedKeys.clear();
_storedCategories.clear();
parseDatapackFile("data/ui/ui_en.xml");
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _storedKeys.size() + " keys " + _storedCategories.size() + " categories.");
}
@Override
public void parseDocument(Document doc, File f)
{
for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling())
{
if ("list".equalsIgnoreCase(n.getNodeName()))
{
for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
{
if ("category".equalsIgnoreCase(d.getNodeName()))
{
parseCategory(d);
}
}
}
}
}
private void parseCategory(Node n)
{
final int cat = parseInteger(n.getAttributes(), "id");
for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
{
if ("commands".equalsIgnoreCase(d.getNodeName()))
{
parseCommands(cat, d);
}
else if ("keys".equalsIgnoreCase(d.getNodeName()))
{
parseKeys(cat, d);
}
}
}
private void parseCommands(int cat, Node d)
{
for (Node c = d.getFirstChild(); c != null; c = c.getNextSibling())
{
if ("cmd".equalsIgnoreCase(c.getNodeName()))
{
addCategory(_storedCategories, cat, Integer.parseInt(c.getTextContent()));
}
}
}
private void parseKeys(int cat, Node d)
{
for (Node c = d.getFirstChild(); c != null; c = c.getNextSibling())
{
if ("key".equalsIgnoreCase(c.getNodeName()))
{
final ActionKey akey = new ActionKey(cat);
for (int i = 0; i < c.getAttributes().getLength(); i++)
{
final Node att = c.getAttributes().item(i);
final int val = Integer.parseInt(att.getNodeValue());
switch (att.getNodeName())
{
case "cmd":
{
akey.setCommandId(val);
break;
}
case "key":
{
akey.setKeyId(val);
break;
}
case "toggleKey1":
{
akey.setToogleKey1(val);
break;
}
case "toggleKey2":
{
akey.setToogleKey2(val);
break;
}
case "showType":
{
akey.setShowStatus(val);
break;
}
}
}
addKey(_storedKeys, cat, akey);
}
}
}
/**
* Add a category to the stored categories.
* @param map the map to store the category
* @param cat the category
* @param cmd the command
*/
public static void addCategory(Map<Integer, List<Integer>> map, int cat, int cmd)
{
map.computeIfAbsent(cat, k -> new ArrayList<>()).add(cmd);
}
/**
* Create and insert an Action Key into the stored keys.
* @param map the map to store the key
* @param cat the category
* @param akey the action key
*/
public static void addKey(Map<Integer, List<ActionKey>> map, int cat, ActionKey akey)
{
map.computeIfAbsent(cat, k -> new ArrayList<>()).add(akey);
}
/**
* @return the categories
*/
public Map<Integer, List<Integer>> getCategories()
{
return _storedCategories;
}
/**
* @return the keys
*/
public Map<Integer, List<ActionKey>> getKeys()
{
return _storedKeys;
}
public static UIData getInstance()
{
return SingletonHolder._instance;
}
private static class SingletonHolder
{
protected static final UIData _instance = new UIData();
}
}

View File

@ -55,8 +55,6 @@ public abstract class IdFactory
"SELECT charId FROM character_skills WHERE charId >= ? AND charId < ?",
"SELECT charId FROM character_skills_save WHERE charId >= ? AND charId < ?",
"SELECT charId FROM character_subclasses WHERE charId >= ? AND charId < ?",
"SELECT charId FROM character_ui_actions WHERE charId >= ? AND charId < ?",
"SELECT charId FROM character_ui_categories WHERE charId >= ? AND charId < ?",
"SELECT charId FROM characters WHERE charId >= ? AND charId < ?",
"SELECT clanid FROM characters WHERE clanid >= ? AND clanid < ?",
"SELECT clan_id FROM clan_data WHERE clan_id >= ? AND clan_id < ?",
@ -192,8 +190,6 @@ public abstract class IdFactory
cleanCount += stmt.executeUpdate("DELETE FROM character_skills_save WHERE character_skills_save.charId NOT IN (SELECT charId FROM characters);");
cleanCount += stmt.executeUpdate("DELETE FROM character_subclasses WHERE character_subclasses.charId NOT IN (SELECT charId FROM characters);");
cleanCount += stmt.executeUpdate("DELETE FROM character_instance_time WHERE character_instance_time.charId NOT IN (SELECT charId FROM characters);");
cleanCount += stmt.executeUpdate("DELETE FROM character_ui_actions WHERE character_ui_actions.charId NOT IN (SELECT charId FROM characters);");
cleanCount += stmt.executeUpdate("DELETE FROM character_ui_categories WHERE character_ui_categories.charId NOT IN (SELECT charId FROM characters);");
// Items
cleanCount += stmt.executeUpdate("DELETE FROM items WHERE items.owner_id NOT IN (SELECT charId FROM characters) AND items.owner_id NOT IN (SELECT clan_id FROM clan_data) AND items.owner_id != -1;");

View File

@ -1,213 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU 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
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.data.xml.impl.UIData;
/**
* UI Keys Settings class.
* @author mrTJO, Zoey76
*/
public class UIKeysSettings
{
private static final Logger _log = Logger.getLogger(UIKeysSettings.class.getName());
private final int _playerObjId;
private Map<Integer, List<ActionKey>> _storedKeys;
private Map<Integer, List<Integer>> _storedCategories;
private boolean _saved = true;
public UIKeysSettings(int playerObjId)
{
_playerObjId = playerObjId;
loadFromDB();
}
public void storeAll(Map<Integer, List<Integer>> catMap, Map<Integer, List<ActionKey>> keyMap)
{
_saved = false;
_storedCategories = catMap;
_storedKeys = keyMap;
}
public void storeCategories(Map<Integer, List<Integer>> catMap)
{
_saved = false;
_storedCategories = catMap;
}
public Map<Integer, List<Integer>> getCategories()
{
return _storedCategories;
}
public void storeKeys(Map<Integer, List<ActionKey>> keyMap)
{
_saved = false;
_storedKeys = keyMap;
}
public Map<Integer, List<ActionKey>> getKeys()
{
return _storedKeys;
}
public void loadFromDB()
{
getCatsFromDB();
getKeysFromDB();
}
/**
* Save Categories and Mapped Keys into GameServer DataBase
*/
public void saveInDB()
{
String query;
if (_saved)
{
return;
}
query = "REPLACE INTO character_ui_categories (`charId`, `catId`, `order`, `cmdId`) VALUES ";
for (int category : _storedCategories.keySet())
{
int order = 0;
for (int key : _storedCategories.get(category))
{
query += "(" + _playerObjId + ", " + category + ", " + (order++) + ", " + key + "),";
}
}
query = query.substring(0, query.length() - 1) + "; ";
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(query))
{
statement.execute();
}
catch (Exception e)
{
_log.log(Level.WARNING, "Exception: saveInDB(): " + e.getMessage(), e);
}
query = "REPLACE INTO character_ui_actions (`charId`, `cat`, `order`, `cmd`, `key`, `tgKey1`, `tgKey2`, `show`) VALUES";
for (List<ActionKey> keyLst : _storedKeys.values())
{
int order = 0;
for (ActionKey key : keyLst)
{
query += key.getSqlSaveString(_playerObjId, order++) + ",";
}
}
query = query.substring(0, query.length() - 1) + ";";
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(query))
{
statement.execute();
}
catch (Exception e)
{
_log.log(Level.WARNING, "Exception: saveInDB(): " + e.getMessage(), e);
}
_saved = true;
}
public void getCatsFromDB()
{
if (_storedCategories != null)
{
return;
}
_storedCategories = new HashMap<>();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement stmt = con.prepareStatement("SELECT * FROM character_ui_categories WHERE `charId` = ? ORDER BY `catId`, `order`"))
{
stmt.setInt(1, _playerObjId);
try (ResultSet rs = stmt.executeQuery())
{
while (rs.next())
{
UIData.addCategory(_storedCategories, rs.getInt("catId"), rs.getInt("cmdId"));
}
}
}
catch (Exception e)
{
_log.log(Level.WARNING, "Exception: getCatsFromDB(): " + e.getMessage(), e);
}
if (_storedCategories.isEmpty())
{
_storedCategories = UIData.getInstance().getCategories();
}
}
public void getKeysFromDB()
{
if (_storedKeys != null)
{
return;
}
_storedKeys = new HashMap<>();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement stmt = con.prepareStatement("SELECT * FROM character_ui_actions WHERE `charId` = ? ORDER BY `cat`, `order`"))
{
stmt.setInt(1, _playerObjId);
try (ResultSet rs = stmt.executeQuery())
{
while (rs.next())
{
final int cat = rs.getInt("cat");
final int cmd = rs.getInt("cmd");
final int key = rs.getInt("key");
final int tgKey1 = rs.getInt("tgKey1");
final int tgKey2 = rs.getInt("tgKey2");
final int show = rs.getInt("show");
UIData.addKey(_storedKeys, cat, new ActionKey(cat, cmd, key, tgKey1, tgKey2, show));
}
}
}
catch (Exception e)
{
_log.log(Level.WARNING, "Exception: getKeysFromDB(): " + e.getMessage(), e);
}
if (_storedKeys.isEmpty())
{
_storedKeys = UIData.getInstance().getKeys();
}
}
public boolean isSaved()
{
return _saved;
}
}

View File

@ -148,7 +148,6 @@ import com.l2jmobius.gameserver.model.TeleportBookmark;
import com.l2jmobius.gameserver.model.TeleportWhereType;
import com.l2jmobius.gameserver.model.TimeStamp;
import com.l2jmobius.gameserver.model.TradeList;
import com.l2jmobius.gameserver.model.UIKeysSettings;
import com.l2jmobius.gameserver.model.actor.L2Attackable;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Npc;
@ -842,9 +841,6 @@ public final class L2PcInstance extends L2Playable
_PvPRegTask = null;
}
// Character UI
private UIKeysSettings _uiKeySettings;
// Save responder name for log it
private String _lastPetitionGmName = null;
@ -6781,11 +6777,6 @@ public final class L2PcInstance extends L2Playable
player.restoreFriendList();
if (Config.STORE_UI_SETTINGS)
{
player.restoreUISettings();
}
player.loadRecommendations();
player.startRecoGiveTask();
player.startOnlineTimeUpdateTask();
@ -7063,10 +7054,6 @@ public final class L2PcInstance extends L2Playable
{
storeRecipeShopList();
}
if (Config.STORE_UI_SETTINGS)
{
storeUISettings();
}
final PlayerVariables vars = getScript(PlayerVariables.class);
if (vars != null)
@ -12616,29 +12603,6 @@ public final class L2PcInstance extends L2Playable
return super.isMovementDisabled() || (getMovieHolder() != null) || _fishing.isFishing();
}
private void restoreUISettings()
{
_uiKeySettings = new UIKeysSettings(getObjectId());
}
private void storeUISettings()
{
if (_uiKeySettings == null)
{
return;
}
if (!_uiKeySettings.isSaved())
{
_uiKeySettings.saveInDB();
}
}
public UIKeysSettings getUISettings()
{
return _uiKeySettings;
}
public String getHtmlPrefix()
{
if (!Config.MULTILANG_ENABLE)

View File

@ -16,64 +16,30 @@
*/
package com.l2jmobius.gameserver.network.clientpackets;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.l2jmobius.Config;
import com.l2jmobius.commons.network.PacketReader;
import com.l2jmobius.gameserver.data.xml.impl.UIData;
import com.l2jmobius.gameserver.model.ActionKey;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.ConnectionState;
import com.l2jmobius.gameserver.network.L2GameClient;
/**
* Request Save Key Mapping client packet.
* @author mrTJO, Zoey76
* @author Mobius
*/
public class RequestSaveKeyMapping implements IClientIncomingPacket
{
private final Map<Integer, List<ActionKey>> _keyMap = new HashMap<>();
private final Map<Integer, List<Integer>> _catMap = new HashMap<>();
public static final String UI_KEY_MAPPING_VAR = "UI_KEY_MAPPING";
public static final String SPLIT_VAR = " ";
private byte[] _uiKeyMapping;
@Override
public boolean read(L2GameClient client, PacketReader packet)
{
int category = 0;
packet.readD(); // Unknown
packet.readD(); // Unknown
final int _tabNum = packet.readD();
for (int i = 0; i < _tabNum; i++)
final int dataSize = packet.readD();
if (dataSize > 0)
{
final int cmd1Size = packet.readC();
for (int j = 0; j < cmd1Size; j++)
{
UIData.addCategory(_catMap, category, packet.readC());
}
category++;
final int cmd2Size = packet.readC();
for (int j = 0; j < cmd2Size; j++)
{
UIData.addCategory(_catMap, category, packet.readC());
}
category++;
final int cmdSize = packet.readD();
for (int j = 0; j < cmdSize; j++)
{
final int cmd = packet.readD();
final int key = packet.readD();
final int tgKey1 = packet.readD();
final int tgKey2 = packet.readD();
final int show = packet.readD();
UIData.addKey(_keyMap, i, new ActionKey(i, cmd, key, tgKey1, tgKey2, show));
}
_uiKeyMapping = packet.readB(dataSize);
}
packet.readD();
packet.readD();
return true;
}
@ -81,10 +47,19 @@ public class RequestSaveKeyMapping implements IClientIncomingPacket
public void run(L2GameClient client)
{
final L2PcInstance player = client.getActiveChar();
if (!Config.STORE_UI_SETTINGS || (player == null) || (client.getConnectionState() != ConnectionState.IN_GAME))
if (!Config.STORE_UI_SETTINGS || //
(player == null) || //
(_uiKeyMapping == null) || //
(client.getConnectionState() != ConnectionState.IN_GAME))
{
return;
}
player.getUISettings().storeAll(_catMap, _keyMap);
String uiKeyMapping = "";
for (Byte b : _uiKeyMapping)
{
uiKeyMapping += b + SPLIT_VAR;
}
player.getVariables().set(UI_KEY_MAPPING_VAR, uiKeyMapping);
}
}

View File

@ -16,124 +16,44 @@
*/
package com.l2jmobius.gameserver.network.serverpackets;
import java.util.List;
import com.l2jmobius.commons.network.PacketWriter;
import com.l2jmobius.gameserver.model.ActionKey;
import com.l2jmobius.gameserver.model.UIKeysSettings;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.OutgoingPackets;
/**
* @author mrTJO
* @author Mobius
*/
public class ExUISetting implements IClientOutgoingPacket
{
private final UIKeysSettings _uiSettings;
private int buffsize, categories;
public static final String UI_KEY_MAPPING_VAR = "UI_KEY_MAPPING";
public static final String SPLIT_VAR = " ";
private final byte[] _uiKeyMapping;
public ExUISetting(L2PcInstance player)
{
_uiSettings = player.getUISettings();
calcSize();
}
private void calcSize()
{
int size = 16; // initial header and footer
int category = 0;
final int numKeyCt = _uiSettings.getKeys().size();
for (int i = 0; i < numKeyCt; i++)
if (player.getVariables().hasVariable(UI_KEY_MAPPING_VAR))
{
size++;
if (_uiSettings.getCategories().containsKey(category))
{
final List<Integer> catElList1 = _uiSettings.getCategories().get(category);
size = size + catElList1.size();
}
category++;
size++;
if (_uiSettings.getCategories().containsKey(category))
{
final List<Integer> catElList2 = _uiSettings.getCategories().get(category);
size = size + catElList2.size();
}
category++;
size = size + 4;
if (_uiSettings.getKeys().containsKey(i))
{
final List<ActionKey> keyElList = _uiSettings.getKeys().get(i);
size = size + (keyElList.size() * 20);
}
_uiKeyMapping = player.getVariables().getByteArray(UI_KEY_MAPPING_VAR, SPLIT_VAR);
}
else
{
_uiKeyMapping = null;
}
buffsize = size;
categories = category;
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_UI_SETTING.writeId(packet);
packet.writeD(buffsize);
packet.writeD(categories);
int category = 0;
final int numKeyCt = _uiSettings.getKeys().size();
packet.writeD(numKeyCt);
for (int i = 0; i < numKeyCt; i++)
if (_uiKeyMapping != null)
{
if (_uiSettings.getCategories().containsKey(category))
{
final List<Integer> catElList1 = _uiSettings.getCategories().get(category);
packet.writeC(catElList1.size());
for (int cmd : catElList1)
{
packet.writeC(cmd);
}
}
else
{
packet.writeC(0x00);
}
category++;
if (_uiSettings.getCategories().containsKey(category))
{
final List<Integer> catElList2 = _uiSettings.getCategories().get(category);
packet.writeC(catElList2.size());
for (int cmd : catElList2)
{
packet.writeC(cmd);
}
}
else
{
packet.writeC(0x00);
}
category++;
if (_uiSettings.getKeys().containsKey(i))
{
final List<ActionKey> keyElList = _uiSettings.getKeys().get(i);
packet.writeD(keyElList.size());
for (ActionKey akey : keyElList)
{
packet.writeD(akey.getCommandId());
packet.writeD(akey.getKeyId());
packet.writeD(akey.getToogleKey1());
packet.writeD(akey.getToogleKey2());
packet.writeD(akey.getShowStatus());
}
}
else
{
packet.writeD(0x00);
}
packet.writeD(_uiKeyMapping.length);
packet.writeB(_uiKeyMapping);
}
else
{
packet.writeD(0);
}
packet.writeD(0x11);
packet.writeD(0x10);
return true;
}
}