Elin Decompiled Documentation EA 23.351.2 Nightly
Loading...
Searching...
No Matches
ModItemList< T > Class Template Reference

Public Member Functions

 ModItemList (int _catLength=0)
 
 ModItemList (int _catLength, object _loadOption)
 
string GetRandomID (string category=null)
 
string GetNextID (string currentId, int a, bool ignoreCategory=true)
 
int IndexOf (string id)
 
ModItem< T > GetItem (string id, bool returnNull=false)
 
T GetObject (string id, object option=null)
 
void Add (FileInfo fi, string path=null, string prefix="")
 
void Add (string id, FileInfo fi, string path=null)
 

Public Attributes

ResourceCache< T > cache = new ResourceCache<T>()
 
List< ModItem< T > > list = new List<ModItem<T>>()
 
Dictionary< string, ModItem< T > > dict = new Dictionary<string, ModItem<T>>()
 
int catLength
 
object loadOption
 

Detailed Description

Type Constraints
T :Object 

Definition at line 5 of file ModItemList.cs.

Constructor & Destructor Documentation

◆ ModItemList() [1/2]

ModItemList< T >.ModItemList ( int  _catLength = 0)
inline

Definition at line 17 of file ModItemList.cs.

18 {
19 catLength = _catLength;
20 }

References ModItemList< T >.catLength.

◆ ModItemList() [2/2]

ModItemList< T >.ModItemList ( int  _catLength,
object  _loadOption 
)
inline

Definition at line 22 of file ModItemList.cs.

23 : this(_catLength)
24 {
25 loadOption = _loadOption;
26 }
object loadOption
Definition: ModItemList.cs:15

References ModItemList< T >.loadOption.

Member Function Documentation

◆ Add() [1/2]

void ModItemList< T >.Add ( FileInfo  fi,
string  path = null,
string  prefix = "" 
)
inline

Definition at line 93 of file ModItemList.cs.

94 {
95 Add(Path.GetFileNameWithoutExtension(prefix + ((fi != null) ? fi.Name : path)), fi, path);
96 }
void Add(FileInfo fi, string path=null, string prefix="")
Definition: ModItemList.cs:93

References ModItemList< T >.Add().

Referenced by ModItemList< T >.Add(), BaseModPackage.Parse(), and ModPackage.ParsePortrait().

◆ Add() [2/2]

void ModItemList< T >.Add ( string  id,
FileInfo  fi,
string  path = null 
)
inline

Definition at line 98 of file ModItemList.cs.

99 {
100 if (dict.ContainsKey(id))
101 {
102 dict[id].Set(fi, path);
103 return;
104 }
105 list.Add(new ModItem<T>(fi, path, this, id));
106 dict.Add(id, list[list.Count - 1]);
107 }
List< ModItem< T > > list
Definition: ModItemList.cs:9
Dictionary< string, ModItem< T > > dict
Definition: ModItemList.cs:11

References ModItemList< T >.dict, and ModItemList< T >.list.

◆ GetItem()

ModItem< T > ModItemList< T >.GetItem ( string  id,
bool  returnNull = false 
)
inline

Definition at line 69 of file ModItemList.cs.

70 {
71 ModItem<T> value = null;
72 if (dict.TryGetValue(id, out value))
73 {
74 return value;
75 }
76 if (!returnNull)
77 {
78 return list[0];
79 }
80 return null;
81 }

References ModItemList< T >.dict, and ModItemList< T >.list.

Referenced by ModItemList< T >.GetObject(), LayerNewspaper.RefreshNews(), WindowChara.RefreshStatic(), Portrait.SetChara(), and Portrait.SetPortrait().

◆ GetNextID()

string ModItemList< T >.GetNextID ( string  currentId,
int  a,
bool  ignoreCategory = true 
)
inline

Definition at line 43 of file ModItemList.cs.

44 {
45 int num = IndexOf(currentId) + a;
46 if (num >= list.Count)
47 {
48 num = 0;
49 }
50 if (num < 0)
51 {
52 num = list.Count - 1;
53 }
54 return list[num].id;
55 }
int IndexOf(string id)
Definition: ModItemList.cs:57

References ModItemList< T >.IndexOf(), and ModItemList< T >.list.

Referenced by WindowChara.SetPortraitBG(), and WindowChara.SetPortraitFrame().

◆ GetObject()

T ModItemList< T >.GetObject ( string  id,
object  option = null 
)
inline

Definition at line 83 of file ModItemList.cs.

84 {
85 ModItem<T> item = GetItem(id, returnNull: true);
86 if (item != null)
87 {
88 return item.GetObject();
89 }
90 return null;
91 }
ModItem< T > GetItem(string id, bool returnNull=false)
Definition: ModItemList.cs:69

References ModItemList< T >.GetItem(), and item.

Referenced by Portrait.SetPortrait().

◆ GetRandomID()

string ModItemList< T >.GetRandomID ( string  category = null)
inline

Definition at line 28 of file ModItemList.cs.

29 {
30 if (list.Count == 0)
31 {
32 return null;
33 }
34 ModItem<T> modItem;
35 do
36 {
37 modItem = list[Rand.rnd(list.Count)];
38 }
39 while (category != null && !(modItem.category == category));
40 return modItem.id;
41 }
string id
Definition: ModItem.cs:10
string category
Definition: ModItem.cs:8
Definition: Rand.cs:4
static int rnd(int max)
Definition: Rand.cs:59

References ModItem< T >.category, ModItem< T >.id, ModItemList< T >.list, and Rand.rnd().

◆ IndexOf()

int ModItemList< T >.IndexOf ( string  id)
inline

Definition at line 57 of file ModItemList.cs.

58 {
59 for (int i = 0; i < list.Count; i++)
60 {
61 if (list[i].id == id)
62 {
63 return i;
64 }
65 }
66 return -1;
67 }

References ModItemList< T >.list.

Referenced by ModItemList< T >.GetNextID().

Member Data Documentation

◆ cache

ResourceCache<T> ModItemList< T >.cache = new ResourceCache<T>()

Definition at line 7 of file ModItemList.cs.

◆ catLength

int ModItemList< T >.catLength

Definition at line 13 of file ModItemList.cs.

Referenced by ModItemList< T >.ModItemList().

◆ dict

Dictionary<string, ModItem<T> > ModItemList< T >.dict = new Dictionary<string, ModItem<T>>()

◆ list

◆ loadOption

object ModItemList< T >.loadOption

Definition at line 15 of file ModItemList.cs.

Referenced by ModItemList< T >.ModItemList().


The documentation for this class was generated from the following file: