Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00012 #ifndef NEWGRF_CLASS_H
00013 #define NEWGRF_CLASS_H
00014
00015 #include "strings_type.h"
00016
00020 template <typename Tspec, typename Tid, Tid Tmax>
00021 struct NewGRFClass {
00022 private:
00023 uint count;
00024 uint ui_count;
00025 Tspec **spec;
00026
00032 static NewGRFClass<Tspec, Tid, Tmax> classes[Tmax];
00033
00034 void ResetClass();
00035
00037 static void InsertDefaults();
00038
00039 public:
00040 uint32 global_id;
00041 StringID name;
00042
00043 void Insert(Tspec *spec);
00044
00046 uint GetSpecCount() const { return this->count; }
00048 uint GetUISpecCount() const { return this->ui_count; }
00049 int GetUIFromIndex(int index) const;
00050 int GetIndexFromUI(int ui_index) const;
00051
00052 const Tspec *GetSpec(uint index) const;
00053
00055 bool IsUIAvailable(uint index) const;
00056
00057 static void Reset();
00058 static Tid Allocate(uint32 global_id);
00059 static void Assign(Tspec *spec);
00060 static uint GetClassCount();
00061 static uint GetUIClassCount();
00062 static Tid GetUIClass(uint index);
00063 static NewGRFClass *Get(Tid cls_id);
00064
00065 static const Tspec *GetByGrf(uint32 grfid, byte local_id, int *index);
00066 };
00067
00068 #endif