Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00013 #ifndef SCRIPT_LIST_HPP
00014 #define SCRIPT_LIST_HPP
00015
00016 #include "script_object.hpp"
00017 #include <map>
00018 #include <set>
00019
00020 class ScriptListSorter;
00021
00026 class ScriptList : public ScriptObject {
00027 public:
00029 enum SorterType {
00030 SORT_BY_VALUE,
00031 SORT_BY_ITEM,
00032 };
00033
00035 static const bool SORT_ASCENDING = true;
00037 static const bool SORT_DESCENDING = false;
00038
00039 private:
00040 ScriptListSorter *sorter;
00041 SorterType sorter_type;
00042 bool sort_ascending;
00043 bool initialized;
00044 int modifications;
00045
00046 public:
00047 typedef std::set<int32> AIItemList;
00048 typedef std::map<int32, AIItemList> ScriptListBucket;
00049 typedef std::map<int32, int32> ScriptListMap;
00050
00051 ScriptListMap items;
00052 ScriptListBucket buckets;
00053
00054 ScriptList();
00055 ~ScriptList();
00056
00063 void AddItem(int32 item, int32 value = 0);
00064
00069 void RemoveItem(int32 item);
00070
00074 void Clear();
00075
00081 bool HasItem(int32 item);
00082
00088 int32 Begin();
00089
00095 int32 Next();
00096
00101 bool IsEmpty();
00102
00108 bool IsEnd();
00109
00114 int32 Count();
00115
00121 int32 GetValue(int32 item);
00122
00131 bool SetValue(int32 item, int32 value);
00132
00140 void Sort(SorterType sorter, bool ascending);
00141
00150 void AddList(ScriptList *list);
00151
00156 void RemoveAboveValue(int32 value);
00157
00162 void RemoveBelowValue(int32 value);
00163
00169 void RemoveBetweenValue(int32 start, int32 end);
00170
00175 void RemoveValue(int32 value);
00176
00181 void RemoveTop(int32 count);
00182
00187 void RemoveBottom(int32 count);
00188
00194 void RemoveList(ScriptList *list);
00195
00200 void KeepAboveValue(int32 value);
00201
00206 void KeepBelowValue(int32 value);
00207
00213 void KeepBetweenValue(int32 start, int32 end);
00214
00219 void KeepValue(int32 value);
00220
00225 void KeepTop(int32 count);
00226
00231 void KeepBottom(int32 count);
00232
00238 void KeepList(ScriptList *list);
00239
00240 #ifndef DOXYGEN_API
00241
00244 SQInteger _get(HSQUIRRELVM vm);
00245
00249 SQInteger _set(HSQUIRRELVM vm);
00250
00254 SQInteger _nexti(HSQUIRRELVM vm);
00255
00259 SQInteger Valuate(HSQUIRRELVM vm);
00260 #else
00261
00280 void Valuate(void *valuator_function, int params, ...);
00281 #endif
00282 };
00283
00284 #endif