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

Public Member Functions

 ModItemList (int _catLength=0)
 
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)
 
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
 

Detailed Description

Type Constraints
T :Object 

Definition at line 5 of file ModItemList.cs.

Constructor & Destructor Documentation

◆ ModItemList()

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

Definition at line 15 of file ModItemList.cs.

16 {
17 catLength = _catLength;
18 }

References ModItemList< T >.catLength.

Member Function Documentation

◆ Add() [1/2]

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

Definition at line 85 of file ModItemList.cs.

86 {
87 Add(Path.GetFileNameWithoutExtension(prefix + ((fi != null) ? fi.Name : path)), fi, path);
88 }
void Add(FileInfo fi, string path=null, string prefix="")
Definition: ModItemList.cs:85

References ModItemList< T >.Add().

Referenced by ModItemList< T >.Add(), BaseModPackage.Parse(), and ModManager.ParseExtra().

◆ Add() [2/2]

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

Definition at line 90 of file ModItemList.cs.

91 {
92 if (dict.ContainsKey(id))
93 {
94 dict[id].Set(fi, path);
95 return;
96 }
97 list.Add(new ModItem<T>(fi, path, this, id));
98 dict.Add(id, list[list.Count - 1]);
99 }
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 61 of file ModItemList.cs.

62 {
63 ModItem<T> value = null;
64 if (dict.TryGetValue(id, out value))
65 {
66 return value;
67 }
68 if (!returnNull)
69 {
70 return list[0];
71 }
72 return null;
73 }

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 35 of file ModItemList.cs.

36 {
37 int num = IndexOf(currentId) + a;
38 if (num >= list.Count)
39 {
40 num = 0;
41 }
42 if (num < 0)
43 {
44 num = list.Count - 1;
45 }
46 return list[num].id;
47 }
int IndexOf(string id)
Definition: ModItemList.cs:49

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 75 of file ModItemList.cs.

76 {
77 ModItem<T> item = GetItem(id, returnNull: true);
78 if (item != null)
79 {
80 return item.GetObject();
81 }
82 return null;
83 }
ModItem< T > GetItem(string id, bool returnNull=false)
Definition: ModItemList.cs:61

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

Referenced by Portrait.SetPortrait().

◆ GetRandomID()

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

Definition at line 20 of file ModItemList.cs.

21 {
22 if (list.Count == 0)
23 {
24 return null;
25 }
26 ModItem<T> modItem;
27 do
28 {
29 modItem = list[Rand.rnd(list.Count)];
30 }
31 while (category != null && !(modItem.category == category));
32 return modItem.id;
33 }
string id
Definition: ModItem.cs:10
string category
Definition: ModItem.cs:8
Definition: Rand.cs:4
static int rnd(int max)
Definition: Rand.cs:52

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

◆ IndexOf()

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

Definition at line 49 of file ModItemList.cs.

50 {
51 for (int i = 0; i < list.Count; i++)
52 {
53 if (list[i].id == id)
54 {
55 return i;
56 }
57 }
58 return -1;
59 }

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


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