| 1179 | } |
| 1180 | |
| 1181 | void makeLabel() |
| 1182 | { |
| 1183 | label = ""; |
| 1184 | |
| 1185 | typedef df::unit_preference::T_type T_type; |
| 1186 | auto &raws = world->raws; |
| 1187 | switch (pref.type) |
| 1188 | { |
| 1189 | case (T_type::LikeCreature): |
| 1190 | { |
| 1191 | label = "Creature :" + Units::getRaceNamePluralById(pref.creature_id); |
| 1192 | break; |
| 1193 | } |
| 1194 | |
| 1195 | case (T_type::HateCreature): |
| 1196 | { |
| 1197 | label = "Hates :" + Units::getRaceNamePluralById(pref.creature_id); |
| 1198 | break; |
| 1199 | } |
| 1200 | |
| 1201 | case (T_type::LikeItem): |
| 1202 | label = "Item :" + getItemLabel(); |
| 1203 | break; |
| 1204 | |
| 1205 | case (T_type::LikeFood): |
| 1206 | { |
| 1207 | label = "Food :"; |
| 1208 | if (pref.matindex < 0 || pref.item_type == item_type::MEAT) |
| 1209 | { |
| 1210 | auto index = (pref.item_type == item_type::FISH) ? pref.mattype : pref.matindex; |
| 1211 | if (index > 0) |
| 1212 | { |
| 1213 | auto creature = df::creature_raw::find(index); |
| 1214 | if (creature) |
| 1215 | label += creature->name[0]; |
| 1216 | } |
| 1217 | else |
| 1218 | { |
| 1219 | label += "Invalid"; |
| 1220 | } |
| 1221 | |
| 1222 | break; |
| 1223 | } |
| 1224 | } |
| 1225 | |
| 1226 | case (T_type::LikeMaterial): |
| 1227 | { |
| 1228 | if (label.length() == 0) |
| 1229 | label += "Material :"; |
| 1230 | MaterialInfo matinfo(pref.mattype, pref.matindex); |
| 1231 | if (pref.type == T_type::LikeFood && pref.item_type == item_type::PLANT) |
| 1232 | { |
| 1233 | label += matinfo.material->prefix; |
| 1234 | } |
| 1235 | else |
| 1236 | label += matinfo.toString(); |
| 1237 | |
| 1238 | break; |
no test coverage detected