PassOwnPtr<SVGAnimatedType> SVGAnimatedBooleanAnimator::constructFromString(const String& string) { OwnPtr<SVGAnimatedType> animtedType = SVGAnimatedType::createBoolean(new bool); animtedType->boolean() = isTrueString(string); return animtedType.release(); }
bool WallBrush::load(xmlNodePtr node, wxArrayString& warnings) { std::string strVal; int intVal; if(readXMLValue(node, "lookid", intVal)) { look_id = intVal; } if(readXMLValue(node, "server_lookid", intVal)) { look_id = item_db[intVal].clientID; } xmlNodePtr child = node->children; while(child) { if(xmlStrcmp(child->name,(const xmlChar*)"wall") == 0) { uint alignment; if(readXMLValue(child, "type", strVal)) { if(strVal == "vertical") { alignment = WALL_VERTICAL; } else if(strVal == "horizontal") { alignment = WALL_HORIZONTAL; } else if(strVal == "corner") { alignment = WALL_NORTHWEST_DIAGONAL; } else if(strVal == "pole") { alignment = WALL_POLE; } else if(strVal == "south end") { alignment = WALL_SOUTH_END; } else if(strVal == "east end") { alignment = WALL_EAST_END; } else if(strVal == "north end") { alignment = WALL_NORTH_END; } else if(strVal == "west end") { alignment = WALL_WEST_END; } else if(strVal == "south T") { alignment = WALL_SOUTH_T; } else if(strVal == "east T") { alignment = WALL_EAST_T; } else if(strVal == "west T") { alignment = WALL_WEST_T; } else if(strVal == "north T") { alignment = WALL_NORTH_T; } else if(strVal == "northwest diagonal") { alignment = WALL_NORTHWEST_DIAGONAL; } else if(strVal == "northeast diagonal") { alignment = WALL_NORTHEAST_DIAGONAL; } else if(strVal == "southwest diagonal") { alignment = WALL_SOUTHWEST_DIAGONAL; } else if(strVal == "southeast diagonal") { alignment = WALL_SOUTHEAST_DIAGONAL; } else if(strVal == "intersection") { alignment = WALL_INTERSECTION; } else if(strVal == "untouchable") { alignment = WALL_UNTOUCHABLE; } else { wxString warning; warning << wxT("Unknown wall alignment '") + wxstr(strVal) + wxT("'\n"); warnings.push_back(warning); child = child->next; continue; } } else { wxString warning; warning << wxT("Could not read type tag of wall node\n"); warnings.push_back(warning); child = child->next; continue; } xmlNodePtr subchild = child->children; while(subchild) { do { if(xmlStrcmp(subchild->name,(const xmlChar*)"item") == 0) { int id, chance = 0; if(!readXMLValue(subchild, "id", id)) { wxString warning; warning << wxT("Could not read id tag of item node\n"); warnings.push_back(warning); break; } readXMLValue(subchild, "chance", chance); ItemType& it = item_db[id]; if(it.id == 0) { wxString warning; warning << wxT("There is no itemtype with id ") << id; warnings.push_back(warning); return false; } if(it.brush != NULL && it.brush != this) { wxString warning; warning << wxT("Itemtype id ") << id << wxT(" already has a brush"); warnings.push_back(warning); return false; } it.isWall = true; it.brush = this; it.border_alignment = ::BorderType(alignment); WallType wt; wall_items[alignment].total_chance += chance; wt.chance = wall_items[alignment].total_chance; wt.id = uint16_t(id); wall_items[alignment].items.push_back(wt); } else if(xmlStrcmp(subchild->name,(const xmlChar*)"door") == 0) { std::string type; int id; int chance = 0; bool isOpen; bool hate = false; if(!readXMLValue(subchild, "id", id)) { wxString warning; warning << wxT("Could not read id tag of item node\n"); warnings.push_back(warning); break; } readXMLValue(subchild, "id", chance); if(readXMLValue(subchild, "type", strVal)) { type = strVal; if(readXMLValue(subchild, "open", strVal)) { isOpen = isTrueString(strVal); } else { isOpen = true; if(type != "window" && type != "any window" && type != "hatch window") { wxString warning; warning << wxT("Could not read open tag of item node\n"); warnings.push_back(warning); break; } } } else { wxString warning; warning << wxT("Could not read type tag of item node\n"); warnings.push_back(warning); break; } if(readXMLValue(subchild, "hate", strVal)) { hate = isTrueString(strVal); } ItemType& it = item_db[id]; if(it.id == 0) { wxString warning; warning << wxT("There is no itemtype with id ") << id; warnings.push_back(warning); return false; } if(it.brush != NULL && it.brush != this) { wxString warning; warning << wxT("Itemtype id ") << id << wxT(" already has a brush"); warnings.push_back(warning); return false; } it.isWall = true; it.brush = this; it.isBrushDoor = true; it.wall_hate_me = hate; it.isOpen = isOpen; it.border_alignment = ::BorderType(alignment); DoorType dt; bool all_windows = false; bool all_doors = false; if(type == "normal") { dt.type = WALL_DOOR_NORMAL; } else if(type == "locked") { dt.type = WALL_DOOR_LOCKED; } else if(type == "quest") { dt.type = WALL_DOOR_QUEST; } else if(type == "magic") { dt.type = WALL_DOOR_MAGIC; } else if(type == "archway") { dt.type = WALL_ARCHWAY; } else if(type == "window") { dt.type = WALL_WINDOW; } else if(type == "hatch_window" || type == "hatch window") { dt.type = WALL_HATCH_WINDOW; } else if(type == "any door") { all_doors = true; } else if(type == "any window") { all_windows = true; } else if(type == "any") { all_windows = true; all_doors = true; } else { wxString warning; warning << wxT("Unknown door type '") << wxstr(type) << wxT("'\n"); warnings.push_back(warning); break; } dt.id = id; if(all_windows) { dt.type = WALL_WINDOW; door_items[alignment].push_back(dt); dt.type = WALL_HATCH_WINDOW; door_items[alignment].push_back(dt); } if(all_doors) { dt.type = WALL_ARCHWAY; door_items[alignment].push_back(dt); dt.type = WALL_DOOR_NORMAL; door_items[alignment].push_back(dt); dt.type = WALL_DOOR_LOCKED; door_items[alignment].push_back(dt); dt.type = WALL_DOOR_QUEST; door_items[alignment].push_back(dt); dt.type = WALL_DOOR_MAGIC; door_items[alignment].push_back(dt); } if(!all_doors && !all_windows) { door_items[alignment].push_back(dt); } } } while(false); subchild = subchild->next; } } else if(xmlStrcmp(child->name,(const xmlChar*)"friend") == 0) { if(readXMLValue(child, "name", strVal)) { if(strVal == "all") { //friends.push_back(-1); } else { Brush* brush = brushes.getBrush(strVal); if(brush) { friends.push_back(brush->getID()); } else { wxString warning; warning << wxT("Brush '") + wxstr(strVal) + wxT("' is not defined."); warnings.push_back(warning); } if(readXMLValue(child, "redirect", strVal) && isTrueString(strVal)) { WallBrush* rd = dynamic_cast<WallBrush*>(brush); if(rd == NULL) { wxString warning; warning << wxT("Wall brush redirect link: '") + wxstr(strVal) + wxT("' is not a wall brush."); warnings.push_back(warning); } else if(redirect_to == NULL) { redirect_to = rd; } else { wxString warning; warning << wxT("Wall brush '") + wxstr(getName()) + wxT("' has more than one redirect link."); warnings.push_back(warning); } } } } } child = child->next; } return true; }