00001 #ifndef COLOUR_H
00002 #define COLOUR_H
00003
00004
00005
00006
00007 enum element_type
00008 {
00009 ETC_FIRE = 32,
00010 ETC_ICE,
00011 ETC_EARTH,
00012 ETC_ELECTRICITY,
00013 ETC_AIR,
00014 ETC_POISON,
00015 ETC_WATER,
00016 ETC_MAGIC,
00017 ETC_MUTAGENIC,
00018 ETC_WARP,
00019 ETC_ENCHANT,
00020 ETC_HEAL,
00021 ETC_HOLY,
00022 ETC_DARK,
00023 ETC_DEATH,
00024 ETC_NECRO,
00025 ETC_UNHOLY,
00026 ETC_VEHUMET,
00027 ETC_BEOGH,
00028 ETC_CRYSTAL,
00029 ETC_BLOOD,
00030 ETC_SMOKE,
00031 ETC_SLIME,
00032 ETC_JEWEL,
00033 ETC_ELVEN,
00034 ETC_DWARVEN,
00035 ETC_ORCISH,
00036 ETC_GILA,
00037 ETC_KRAKEN,
00038 ETC_FLOOR,
00039 ETC_ROCK,
00040 ETC_STONE,
00041 ETC_MIST,
00042 ETC_SHIMMER_BLUE,
00043 ETC_DECAY,
00044 ETC_SILVER,
00045 ETC_GOLD,
00046 ETC_IRON,
00047 ETC_BONE,
00048 ETC_ELVEN_BRICK,
00049 ETC_WAVES,
00050 ETC_TREE,
00051 ETC_RANDOM,
00052 ETC_TORNADO,
00053 ETC_LIQUEFIED,
00054 ETC_SWAMP_TREE,
00055 ETC_FIRST_LUA = 96,
00056 };
00057
00058 typedef int (*element_colour_calculator)(int, const coord_def&);
00059
00060 struct element_colour_calc
00061 {
00062 element_type type;
00063 std::string name;
00064
00065 element_colour_calc(element_type _type, std::string _name,
00066 element_colour_calculator _calc)
00067 : type(_type), name(_name), calc(_calc)
00068 {};
00069
00070 virtual int get(const coord_def& loc = coord_def(),
00071 bool non_random = false);
00072
00073 virtual ~element_colour_calc() {};
00074
00075 protected:
00076 int rand(bool non_random);
00077
00078 element_colour_calculator calc;
00079 };
00080
00081 int str_to_colour(const std::string &str, int default_colour = -1,
00082 bool accept_number = true);
00083 const std::string colour_to_str(uint8_t colour);
00084 unsigned int str_to_tile_colour(std::string colour);
00085
00086 void init_element_colours();
00087 void add_element_colour(element_colour_calc *colour);
00088 void clear_colours_on_exit();
00089 uint8_t random_colour();
00090 uint8_t random_uncommon_colour();
00091 bool is_low_colour(uint8_t colour);
00092 bool is_high_colour(uint8_t colour);
00093 uint8_t make_low_colour(uint8_t colour);
00094 uint8_t make_high_colour(uint8_t colour);
00095 bool is_element_colour(int col);
00096 int element_colour(int element, bool no_random = false,
00097 const coord_def& loc = coord_def());
00098
00099 #if defined(TARGET_OS_WINDOWS) || defined(TARGET_OS_DOS) || defined(USE_TILE)
00100 unsigned short dos_brand(unsigned short colour,
00101 unsigned brand = CHATTR_REVERSE);
00102 #endif
00103
00104
00105 unsigned real_colour(unsigned raw_colour, const coord_def& loc = coord_def());
00106
00107 #endif