Search in sources :

Example 1 with ItemChoiceTableColumnsManager

use of delta.games.lotro.gui.items.ItemChoiceTableColumnsManager in project lotro-companion by dmorcellet.

the class CharacterPreferencesManager method getUserProperties.

/**
 * Get the preferences for a character.
 * @param toonFile Character file.
 * @param id Identifier of the preferences set.
 * @return Some properties or <code>null</code> if not managed.
 */
public static TypedProperties getUserProperties(CharacterFile toonFile, String id) {
    TypedProperties props = null;
    if (id.startsWith(ItemChoiceWindowController.ITEM_CHOOSER_PROPERTIES_ID)) {
        if (toonFile != null) {
            Preferences prefs = toonFile.getPreferences();
            props = prefs.getPreferences(id);
            List<String> columnIds = props.getStringList(ItemChoiceWindowController.COLUMNS_PROPERTY);
            if (columnIds == null) {
                String slotKey = id.substring(id.indexOf("#") + 1);
                EQUIMENT_SLOT slot = EQUIMENT_SLOT.valueOf(slotKey);
                CharacterClass characterClass = toonFile.getSummary().getCharacterClass();
                ItemChoiceTableColumnsManager mgr = new ItemChoiceTableColumnsManager();
                columnIds = mgr.getItemChoiceColumns(characterClass, slot);
                props.setStringList(ItemChoiceWindowController.COLUMNS_PROPERTY, columnIds);
                prefs.savePreferences(props);
            }
        }
    } else if (ItemChoiceWindowController.ESSENCE_CHOOSER_PROPERTIES_ID.equals(id)) {
        Preferences prefs = toonFile.getPreferences();
        props = prefs.getPreferences(id);
        List<String> columnIds = props.getStringList(ItemChoiceWindowController.COLUMNS_PROPERTY);
        if (columnIds == null) {
            CharacterClass characterClass = toonFile.getSummary().getCharacterClass();
            ItemChoiceTableColumnsManager mgr = new ItemChoiceTableColumnsManager();
            columnIds = mgr.getEssenceChoiceColumns(characterClass);
            props.setStringList(ItemChoiceWindowController.COLUMNS_PROPERTY, columnIds);
            prefs.savePreferences(props);
        }
    }
    return props;
}
Also used : EQUIMENT_SLOT(delta.games.lotro.character.CharacterEquipment.EQUIMENT_SLOT) ItemChoiceTableColumnsManager(delta.games.lotro.gui.items.ItemChoiceTableColumnsManager) List(java.util.List) TypedProperties(delta.common.utils.misc.TypedProperties) Preferences(delta.common.utils.misc.Preferences) CharacterClass(delta.games.lotro.common.CharacterClass)

Aggregations

Preferences (delta.common.utils.misc.Preferences)1 TypedProperties (delta.common.utils.misc.TypedProperties)1 EQUIMENT_SLOT (delta.games.lotro.character.CharacterEquipment.EQUIMENT_SLOT)1 CharacterClass (delta.games.lotro.common.CharacterClass)1 ItemChoiceTableColumnsManager (delta.games.lotro.gui.items.ItemChoiceTableColumnsManager)1 List (java.util.List)1