public int replaceClassName(string findWhat, string replaceWith) { if (treeView != null) { // don't redraw treeView while editing treeView.BeginUpdate(); } int replaceCount = 0; for (int i = 0; i < entities.Count; i++) { MapEntity e = entities[i]; if (e.getClassName().Equals(findWhat, StringComparison.InvariantCultureIgnoreCase)) { e.setClassName(replaceWith); replaceCount++; } } if (treeView != null) { treeView.EndUpdate(); } return(replaceCount); }
public FormAddNewKeyValue(FormMapFileExplorer formMapFileExplorer, fileFormats.MapEntity lastClickedNodeMapEntity) { this.formMapFileExplorer = formMapFileExplorer; this.lastClickedNodeMapEntity = lastClickedNodeMapEntity; InitializeComponent(); }
private bool parseMapPatchDef(MapEntity e, bool bPatchDef3) { if (!p.isAtToken("{")) { showParseError("Expected '{' at the beginning of patchDef2 at line " + p.getCurrentLineNumber()); return(true); } // patch info string matName; if (p.readToken(out matName)) { showParseError("Failed to read material name of patchDef2 at line " + p.getCurrentLineNumber()); return(true); } int w, h; if (!p.isAtToken("(")) { showParseError("Expected '(' at the beginning of patchDef2 at line " + p.getCurrentLineNumber()); return(true); } if (p.readInt(out w)) { showParseError("Failed to read width of patchDef2 at line " + p.getCurrentLineNumber()); return(true); } if (p.readInt(out h)) { showParseError("Failed to read height of patchDef2 at line " + p.getCurrentLineNumber()); return(true); } int a, b, c; if (p.readInt(out a)) { showParseError("Failed to read third parm of patchDef2 at line " + p.getCurrentLineNumber()); return(true); } if (p.readInt(out b)) { showParseError("Failed to read 4th parm of patchDef2 at line " + p.getCurrentLineNumber()); return(true); } if (p.readInt(out c)) { showParseError("Failed to read 5th parm of patchDef2 at line " + p.getCurrentLineNumber()); return(true); } if (bPatchDef3) { int g, f; if (p.readInt(out f)) { showParseError("Failed to read 6th parm of patchDef2 at line " + p.getCurrentLineNumber()); return(true); } if (p.readInt(out g)) { showParseError("Failed to read 7th parm of patchDef2 at line " + p.getCurrentLineNumber()); return(true); } } while (true) { if (p.isAtToken("+surfaceParm")) { string parmName; p.readString(out parmName); } else if (p.isAtToken("subdivisions")) { float subdivisions; p.readFloat(out subdivisions); } else { break; } } if (!p.isAtToken(")")) { showParseError("Expected ')' after patchDef2 info block at line " + p.getCurrentLineNumber()); return(true); } if (!p.isAtToken("(")) { showParseError("Expected '(' at the beginning of patchDef2 vertices block at line " + p.getCurrentLineNumber()); return(true); } MapPatch patch = new MapPatch(); patch.setSizes(w, h); patch.setMatName(matName); for (int i = 0; i < w; i++) { if (!p.isAtToken("(")) { showParseError("Expected '(' at the beginning of patchDef2 vertices row " + i + " at line " + p.getCurrentLineNumber()); return(true); } for (int j = 0; j < h; j++) { if (!p.isAtToken("(")) { showParseError("Expected '(' at the beginning of patchDef2 vertex " + i + "/" + j + " at line " + p.getCurrentLineNumber()); return(true); } Vec3 position; if (p.readVec3(out position)) { showParseError("Failed to read position of patchDef2 vertex " + i + "/" + j + " at line " + p.getCurrentLineNumber()); return(true); } Vec2 texCoords; if (p.readVec2(out texCoords)) { showParseError("Failed to read texCoord of patchDef2 vertex " + i + "/" + j + " at line " + p.getCurrentLineNumber()); return(true); } if (!p.isAtToken(")")) { showParseError("Expected ')' at the end of patchDef2 vertex " + i + "/" + j + " at line " + p.getCurrentLineNumber()); return(true); } patch.setVertex(i, j, position, texCoords); } if (!p.isAtToken(")")) { showParseError("Expected ')' at the end of patchDef2 vertices row " + i + " at line " + p.getCurrentLineNumber()); return(true); } } if (!p.isAtToken(")")) { showParseError("Expected ')' after patchDef2 vertices block at line " + p.getCurrentLineNumber()); return(true); } if (!p.isAtToken("}")) { showParseError("Expected '}' at the end of patchDef2 block at line " + p.getCurrentLineNumber()); return(true); } if (!p.isAtToken("}")) { showParseError("Expected '}' at the end of patchDef2 block at line " + p.getCurrentLineNumber()); return(true); } e.addPatch(patch); return(false); }
private bool parseMapBrush(MapEntity e) { MapBrushOld br = new MapBrushOld(); while (p.isAtToken("}") == false) { Vec3 a, b, c; if (p.readBracedVec3(out a)) { showParseError("Failed to read point A of plane equation of brushside " + br.getNumSides() + " at line " + p.getCurrentLineNumber()); return(true); } if (p.readBracedVec3(out b)) { showParseError("Failed to read point B of plane equation of brushside " + br.getNumSides() + " at line " + p.getCurrentLineNumber()); return(true); } if (p.readBracedVec3(out c)) { showParseError("Failed to read point C of plane equation of brushside " + br.getNumSides() + " at line " + p.getCurrentLineNumber()); return(true); } string matName; if (p.readToken(out matName)) { showParseError("Failed to read material name of brushside " + br.getNumSides() + " at line " + p.getCurrentLineNumber()); return(true); } Vec2 texShift; if (p.readVec2(out texShift)) { showParseError("Failed to texture shift of brushside " + br.getNumSides() + " at line " + p.getCurrentLineNumber()); return(true); } float texRotation; if (p.readFloat(out texRotation)) { showParseError("Failed to texture rotation of brushside " + br.getNumSides() + " at line " + p.getCurrentLineNumber()); return(true); } Vec2 texScale; if (p.readVec2(out texScale)) { showParseError("Failed to texture scale of brushside " + br.getNumSides() + " at line " + p.getCurrentLineNumber()); return(true); } // used for detail flag, this is 0 for structural brushes // those tokens are missing in older map formats (check subterfuge.map, etc) int contents; if (p.isAtEOL() == false) { if (p.readInt(out contents)) { showParseError("Failed to contentFlags of brushside " + br.getNumSides() + " at line " + p.getCurrentLineNumber()); return(true); } } else { contents = 0; } // now texDef->flags and texDef->value p.skipToNextLine(); MapBrushSideOld bs = new MapBrushSideOld(); bs.setPlanePoints(a, b, c); bs.setMatName(matName); bs.setTexShift(texShift); bs.setTexScale(texScale); bs.setTexRotation(texRotation); bs.setContentFlags(contents); br.addSide(bs); } e.addBrush(br); return(false); }
public void addEntity(MapEntity ne) { entities.Add(ne); }
private bool parseMapEntity() { MapEntity e = new MapEntity(); while (p.isAtToken("}") == false) { if (p.isAtEOF()) { if (bParsingOnlyBrushesTextFragment) { break; } else { //should never happen showParseError("Unexpected EOF hit while parsing entity " + m.getNumEntities()); break; } } else if (p.isAtToken("{")) { if (p.isAtToken("patchDef2")) { #if false if (!p.isAtToken("{")) { return(true); } p.skipCurlyBracedBlock(); if (!p.isAtToken("}")) { return(true); } #else if (parseMapPatchDef(e, false)) { return(true); } #endif } else if (p.isAtToken("brushDef3")) { #if false if (!p.isAtToken("{")) { return(true); } p.skipCurlyBracedBlock(); if (!p.isAtToken("}")) { return(true); } #else if (parseMapBrushDef3(e)) { return(true); } #endif } else if (p.isAtToken("patchDef3")) { #if false if (!p.isAtToken("{")) { return(true); } p.skipCurlyBracedBlock(); if (!p.isAtToken("}")) { return(true); } #else if (parseMapPatchDef(e, true)) { return(true); } #endif } else if (p.isAtToken("terrainDef")) { if (!p.isAtToken("{")) { return(true); } p.skipCurlyBracedBlock(); if (!p.isAtToken("}")) { return(true); } } else { #if false p.skipCurlyBracedBlock(); #else if (parseMapBrush(e)) { return(true); } #endif } } else { string key, value; if (p.readQuotedString(out key)) { showParseError("Failed to read entity " + m.getNumEntities() + " epair key at line " + p.getCurrentLineNumber()); return(true); } if (p.readQuotedString(out value)) { showParseError("Failed to read entity " + m.getNumEntities() + " epair value at line " + p.getCurrentLineNumber()); return(true); } e.setKeyValue(key, value); } } e.setIndex(m.getNumEntities()); m.addEntity(e); return(false); }
private bool parseMapBrushDef3(MapEntity e) { if (!p.isAtToken("{")) { showParseError("Expected '{' at the beginning of brushDef3 at line " + p.getCurrentLineNumber()); return(true); } MapBrushDef3 br = new MapBrushDef3(); while (p.isAtToken("}") == false) { if (!p.isAtToken("(")) { showParseError("Expected '(' at the beginning of brushDef3 plane equation " + br.getNumSides() + " at line " + p.getCurrentLineNumber()); return(true); } Vec3 normal; if (p.readVec3(out normal)) { showParseError("Failed to read brushDef3 plane equation normal of side " + br.getNumSides() + " at line " + p.getCurrentLineNumber()); return(true); } float distance; if (p.readFloat(out distance)) { showParseError("Failed to read brushDef3 plane equation distance of side " + br.getNumSides() + " at line " + p.getCurrentLineNumber()); return(true); } Plane pl = new Plane(); pl.setDistance(distance); pl.setNormal(normal); if (!p.isAtToken(")")) { showParseError("Expected ')' after the brushDef3 plane equation " + br.getNumSides() + " at line " + p.getCurrentLineNumber()); return(true); } if (!p.isAtToken("(")) { showParseError("Expected '(' at the beginning of brushDef3 texture matrix " + br.getNumSides() + " at line " + p.getCurrentLineNumber()); return(true); } Vec3 texAxis0; if (p.readBracedVec3(out texAxis0)) { showParseError("Failed to read first vec3 of brushDef3 texture matrix " + br.getNumSides() + " at line " + p.getCurrentLineNumber()); return(true); } Vec3 texAxis1; if (p.readBracedVec3(out texAxis1)) { showParseError("Failed to read second vec3 of brushDef3 texture matrix " + br.getNumSides() + " at line " + p.getCurrentLineNumber()); return(true); } if (!p.isAtToken(")")) { showParseError("Expected ')' after the brushDef3 texture matrix " + br.getNumSides() + " at line " + p.getCurrentLineNumber()); return(true); } string matName; if (p.readToken(out matName)) { showParseError("Failed to read material name of brushDef3 side " + br.getNumSides() + " at line " + p.getCurrentLineNumber()); return(true); } MapBrushSide4 bs = new MapBrushSide4(); bs.setMatName(matName); bs.setPlane(pl); bs.setTextureMatrix(texAxis0, texAxis1); br.addSide(bs); p.skipToNextLine(); } if (!p.isAtToken("}")) { showParseError("Expected '}' at the end of brushDef3 at line " + p.getCurrentLineNumber()); return(true); } e.addBrush(br); return(false); }