internal void LoadFromFile(string aMapFileName, TSynchronicity aSynchronicity) { iMapFileName = aMapFileName; iMapFile = MapFile.NewByHostMapFileName(aMapFileName); // iParser = new MapFileParser(this, aMapFileName, this); iParser.Tag = this; iParser.iObserver += new SymbianUtils.AsyncReaderBase.Observer(Parser_Observer); iParser.SymbolCreated += new MapFileParser.SymbolCreatedHandler(Parser_SymbolCreated); iParser.BaseAddressHandler += new MapFileParser.MapFileBaseAddressHandler(Parser_BaseAddressHandler); iParser.Read(aSynchronicity); }
private void importMAPFile(string fileName) { MapFileParser p = new MapFileParser(); if (p.loadMapFile(fileName)) { return; } MapFile map = p.getMapFile(); importMapFile(map); }
public void importBrushFromText(string textDef) { MapFileParser p = new MapFileParser(); if (p.loadBrushesFromText(textDef, "memory")) { return; } MapFile map = p.getMapFile(); importMapFile(map); }
private void viewMapFile(string mapName) { MapFileParser p = new MapFileParser(); try { if (p.loadMapFile(mapName)) { MessageBox.Show("Failed to load .map file '" + mapName + "'"); return; } } catch (System.IO.DirectoryNotFoundException ex) { MessageBox.Show("Failed to load .map file '" + mapName + "' - directory not found exception."); return; } map = p.getMapFile(); map.setTreeView(treeView1); /* * MapFileWriter w = new MapFileWriter(); * w.writeMapFile(map, mapName + "_textExport.map"); * */ treeView1.BeginUpdate(); treeView1.Nodes.Clear(); for (int i = 0; i < map.getNumEntities(); i++) { MapEntity entity = map.getEntity(i); TreeNode nodeEntity = new TreeNode("Entity " + i + " (" + entity.getClassName() + ")"); nodeEntity.Tag = entity; entity.setTreeViewNode(nodeEntity); TreeNode nodeKeyValues = new TreeNode("Variables"); KeyValuesList epairs = entity.getKeyValues(); nodeKeyValues.Tag = epairs; for (int j = 0; j < epairs.size(); j++) { TreeNode nodeKey = new TreeNode(epairs.getPairKey(j)); TreeNode nodeValue = new TreeNode(epairs.getPairValue(j)); // save the node so epairs can automatically update GUI epairs.setPairTreeNode(j, nodeKey); nodeKey.Tag = epairs; nodeValue.Tag = epairs; nodeKey.Nodes.Add(nodeValue); nodeKeyValues.Nodes.Add(nodeKey); } nodeEntity.Nodes.Add(nodeKeyValues); if (entity.getNumBrushes() != 0 || entity.getNumPatches() != 0) { TreeNode nodeGeometry = new TreeNode("Geometry"); if (entity.getNumBrushes() != 0) { TreeNode nodeBrushes = new TreeNode("Brushes"); for (int j = 0; j < entity.getNumBrushes(); j++) { MapBrushBase brBase = entity.getBrush(j); if (brBase.isOldBrush()) { MapBrushOld br = (MapBrushOld)brBase; TreeNode nodeBrush = new TreeNode("Brush (old format) " + j); nodeBrush.Tag = br; for (int k = 0; k < br.getNumSides(); k++) { MapBrushSideOld side = br.getSide(k); TreeNode nodeSide = new TreeNode("Side " + k); // plane points TreeNode nodePlanePoints = new TreeNode("Plane points"); nodePlanePoints.Nodes.Add(side.getPlanePointA().ToStringBraced() + " " + side.getPlanePointB().ToStringBraced() + " " + side.getPlanePointB().ToStringBraced()); nodeSide.Nodes.Add(nodePlanePoints); // material TreeNode nodeMaterial = new TreeNode("Material"); nodeMaterial.Nodes.Add(side.getMatName()); nodeSide.Nodes.Add(nodeMaterial); // tex scale TreeNode nodeTexScale = new TreeNode("TexScale"); nodeTexScale.Nodes.Add(side.getTexScale().ToString()); nodeSide.Nodes.Add(nodeTexScale); // tex shift TreeNode nodeTexShift = new TreeNode("TexShift"); nodeTexShift.Nodes.Add(side.getTexShift().ToString()); nodeSide.Nodes.Add(nodeTexShift); // tex rotation TreeNode nodeTexRotation = new TreeNode("TexRotation"); nodeTexRotation.Nodes.Add(side.getTexRotation().ToString()); nodeSide.Nodes.Add(nodeTexRotation); // contents (eg. detail) TreeNode nodeContentFlags = new TreeNode("ContentFlags"); nodeContentFlags.Nodes.Add(side.getContentFlags().ToString()); nodeSide.Nodes.Add(nodeContentFlags); nodeBrush.Nodes.Add(nodeSide); } nodeBrushes.Nodes.Add(nodeBrush); } else { MapBrushDef3 br = (MapBrushDef3)brBase; TreeNode nodeBrush = new TreeNode("Brush (Def3) " + j); nodeBrush.Tag = br; for (int k = 0; k < br.getNumSides(); k++) { MapBrushSide4 side = br.getSide(k); TreeNode nodeSide = new TreeNode("Side " + k); // plane points TreeNode nodePlanePoints = new TreeNode("Plane"); nodePlanePoints.Nodes.Add(side.getPlane().ToString()); nodeSide.Nodes.Add(nodePlanePoints); // material TreeNode nodeMaterial = new TreeNode("Material"); nodeMaterial.Nodes.Add(side.getMatName()); nodeSide.Nodes.Add(nodeMaterial); // tex matrix TreeNode nodeTexAxis0 = new TreeNode("TexAxis0"); nodeTexAxis0.Nodes.Add(side.getTextureAxis0().ToString()); nodeSide.Nodes.Add(nodeTexAxis0); TreeNode nodeTexAxis1 = new TreeNode("TexAxis1"); nodeTexAxis1.Nodes.Add(side.getTextureAxis1().ToString()); nodeSide.Nodes.Add(nodeTexAxis1); nodeBrush.Nodes.Add(nodeSide); } nodeBrushes.Nodes.Add(nodeBrush); } } nodeGeometry.Nodes.Add(nodeBrushes); } if (entity.getNumPatches() != 0) { TreeNode nodePatches = new TreeNode("Patches"); for (int j = 0; j < entity.getNumPatches(); j++) { MapPatch patch = entity.getPatch(j); TreeNode nodePatch = new TreeNode("Patch " + j); // material TreeNode nodeMaterial = new TreeNode("Material"); nodeMaterial.Nodes.Add(patch.getMatName()); nodePatch.Nodes.Add(nodeMaterial); // sizes TreeNode nodeSizes = new TreeNode("Size"); nodeSizes.Nodes.Add(patch.getSizeW().ToString() + " " + patch.getSizeH().ToString()); nodePatch.Nodes.Add(nodeSizes); // verts TreeNode nodeVerts = new TreeNode("Verts"); for (int k = 0; k < patch.getSizeH(); k++) { TreeNode nodeRowK = new TreeNode("Row " + k); for (int l = 0; l < patch.getSizeW(); l++) { TreeNode nodeVertex = new TreeNode("Vertex " + l + " (abs " + k + "/" + l + ")"); nodeVertex.Nodes.Add(patch.getVertex(l, k).ToString()); nodeRowK.Nodes.Add(nodeVertex); } nodeVerts.Nodes.Add(nodeRowK); } nodePatch.Nodes.Add(nodeVerts); nodePatches.Nodes.Add(nodePatch); } nodeGeometry.Nodes.Add(nodePatches); } nodeEntity.Nodes.Add(nodeGeometry); } treeView1.Nodes.Add(nodeEntity); treeView1.EndUpdate(); } }