| 210 | } |
| 211 | |
| 212 | command_result df_createitem (color_ostream &out, vector<string> ¶meters) { |
| 213 | string item_str, material_str; |
| 214 | auto item_type = item_type::NONE; |
| 215 | int16_t item_subtype = -1; |
| 216 | int16_t mat_type = -1; |
| 217 | int32_t mat_index = -1; |
| 218 | int count = 1; |
| 219 | bool move_to_cursor = false; |
| 220 | |
| 221 | if (parameters.size() == 1) { |
| 222 | if (parameters[0] == "inspect") { |
| 223 | auto item = Gui::getSelectedItem(out); |
| 224 | if (!item) |
| 225 | return CR_FAILURE; |
| 226 | |
| 227 | ItemTypeInfo iinfo(item->getType(), item->getSubtype()); |
| 228 | MaterialInfo minfo(item->getMaterial(), item->getMaterialIndex()); |
| 229 | out.print("{} {}\n", iinfo.getToken(), minfo.getToken()); |
| 230 | return CR_OK; |
| 231 | } |
| 232 | else if (parameters[0] == "floor") { |
| 233 | dest_container = -1; |
| 234 | dest_building = -1; |
| 235 | out.print("Items created will be placed on the floor.\n"); |
| 236 | return CR_OK; |
| 237 | } |
| 238 | else if (parameters[0] == "item") { |
| 239 | dest_building = -1; |
| 240 | auto item = Gui::getSelectedItem(out); |
| 241 | if (!item) { |
| 242 | out.printerr("You must select a container!\n"); |
| 243 | return CR_FAILURE; |
| 244 | } |
| 245 | switch (item->getType()) |
| 246 | { using namespace df::enums::item_type; |
| 247 | case FLASK: |
| 248 | case BARREL: |
| 249 | case BUCKET: |
| 250 | case ANIMALTRAP: |
| 251 | case BOX: |
| 252 | case BAG: |
| 253 | case BIN: |
| 254 | case BACKPACK: |
| 255 | case QUIVER: |
| 256 | break; |
| 257 | case TOOL: |
| 258 | if (item->hasToolUse(tool_uses::LIQUID_CONTAINER) || |
| 259 | item->hasToolUse(tool_uses::FOOD_STORAGE) || |
| 260 | item->hasToolUse(tool_uses::SMALL_OBJECT_STORAGE) || |
| 261 | item->hasToolUse(tool_uses::TRACK_CART) |
| 262 | ) |
| 263 | break; |
| 264 | default: |
| 265 | out.printerr("The selected item cannot be used for item storage!\n"); |
| 266 | return CR_FAILURE; |
| 267 | } |
| 268 | dest_container = item->id; |
| 269 | string name; |
nothing calls this directly
no test coverage detected