summaryrefslogtreecommitdiff
path: root/NET/worlds/console/AttributeList.java
blob: 25292a7c1b021d00c17c493f302b248752c41412 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package NET.worlds.console;

import NET.worlds.core.IniFile;
import NET.worlds.scape.PropList;
import java.awt.List;
import java.util.Vector;

class AttributeList extends List {
   private static final long serialVersionUID = 4867320900648345562L;

   public AttributeList(int numVisibleRows) {
      super(numVisibleRows);
      Vector<String> sortOrder = new Vector<String>();
      int numUserPreferences = IniFile.gamma().getIniInt("PropertyOrderCount", -1);
      if (numUserPreferences >= 0) {
         sortOrder = new Vector<String>(numUserPreferences);

         for (int i = 0; i < numUserPreferences; i++) {
            sortOrder.addElement(IniFile.gamma().getIniString("PropertyOrder" + i, ""));
         }
      }

      for (int idx = 0; idx < sortOrder.size(); idx++) {
         String attToAdd = sortOrder.elementAt(idx);
         this.add(attToAdd);
      }
   }

   public void save() {
      int numProperties = this.getItemCount();
      PropList.setPreferences(this.getItems());
      IniFile.gamma().setIniInt("PropertyOrderCount", numProperties);

      for (int i = 0; i < numProperties; i++) {
         IniFile.gamma().setIniString("PropertyOrder" + i, this.getItem(i));
      }
   }
}