public object DOMParse(XmlElement element, params object[] parameters) { GeoElement parsed = new GeoElement(element.Attributes["id"].Value); var oldDescriptionSystem = new Description(); parsed.Descriptions = new List <Description> (); foreach (var child in element.ChildNodes) { var node = child as XmlNode; switch (node.Name) { case "description": parsed.Descriptions.Add(DOMParserUtility.DOMParse <Description>(node, parameters)); break; case "name": oldDescriptionSystem.setName(node.InnerText); break; case "brief-description": oldDescriptionSystem.setDescription(node.InnerText); break; case "detailed-description": oldDescriptionSystem.setDetailedDescription(node.InnerText); break; case "geometries": parsed.Geometries = DOMParserUtility.DOMParse <GMLGeometry>(node.ChildNodes, parameters).DefaultIfEmpty(new GMLGeometry()).ToList(); break; case "geometry": parsed.Geometries = new List <GMLGeometry> { DOMParserUtility.DOMParse <GMLGeometry>(node, parameters) }; break; case "actions": parsed.Actions = ParseActions(node, parameters); break; case "resources": parsed.Resources = DOMParserUtility .DOMParse <ResourcesUni>(element.SelectNodes("resources"), parameters).DefaultIfEmpty(new ResourcesUni()).ToList(); break; } } if (parsed.Descriptions.Count == 0) { parsed.Descriptions.Add(oldDescriptionSystem); } return(parsed); }
public GeoElementDataControl(GeoElement geoElement) { this.geoElement = geoElement; this.resourcesList = geoElement.Resources; selectedResources = 0; // Add a new resource if the list is empty if (resourcesList.Count == 0) { resourcesList.Add(new ResourcesUni()); } // Create the subcontrollers resourcesDataControlList = new List <ResourcesDataControl>(); foreach (ResourcesUni resources in resourcesList) { resourcesDataControlList.Add(new ResourcesDataControl(resources, GEO_ELEMENT)); } descriptionController = new DescriptionsController(geoElement.Descriptions); geoActionDataControls = new ListDataControl <GeoElementDataControl, GeoActionDataControl>(this, geoElement.Actions, new [] { new ListDataControl <GeoElementDataControl, GeoActionDataControl> .ElementFactoryView { Titles = { { ENTER_ACTION, "Geo.Create.Title.EnterAction" }, { EXIT_ACTION, "Geo.Create.Title.ExitAction" }, { LOOK_TO_ACTION, "Geo.Create.Title.LookToAction" }, { INSPECT_ACTION, "Geo.Create.Title.InspectAction" } }, Messages = { { ENTER_ACTION, "Geo.Create.Message.EnterAction" }, { EXIT_ACTION, "Geo.Create.Message.ExitAction" }, { LOOK_TO_ACTION, "Geo.Create.Message.LookToAction" }, { INSPECT_ACTION, "Geo.Create.Message.InspectAction" } }, Errors = { { ENTER_ACTION, "Geo.Create.Error.EnterAction" }, { EXIT_ACTION, "Geo.Create.Error.ExitAction" }, { LOOK_TO_ACTION, "Geo.Create.Error.LookToAction" }, { INSPECT_ACTION, "Geo.Create.Error.InspectAction" } }, ElementFactory = new DefaultElementFactory <GeoActionDataControl>(new DefaultElementFactory <GeoActionDataControl> .ElementCreator() { TypeDescriptors = new [] { new TD { Type = ENTER_ACTION, ContentType = typeof(EnterAction) }, new TD { Type = EXIT_ACTION, ContentType = typeof(ExitAction) }, new TD { Type = LOOK_TO_ACTION, ContentType = typeof(InspectAction) }, new TD { Type = INSPECT_ACTION, ContentType = typeof(LookToAction) } }, CreateDataControl = action => new GeoActionDataControl(action as GeoAction), CreateElement = (type, id, _) => { switch (type) { case ENTER_ACTION: return(new GeoActionDataControl(new EnterAction())); case EXIT_ACTION: return(new GeoActionDataControl(new ExitAction())); case LOOK_TO_ACTION: return(new GeoActionDataControl(new LookToAction())); case INSPECT_ACTION: return(new GeoActionDataControl(new InspectAction())); default: return(null); } } }) } }); geometryDataControls = new ListDataControl <GeoElementDataControl, GMLGeometryDataControl>(this, geoElement.Geometries, new [] { new ListDataControl <GeoElementDataControl, GMLGeometryDataControl> .ElementFactoryView() { Titles = { { GEOMETRY, "Geo.Create.Title.Geometry" } }, Messages = { { GEOMETRY, "Geo.Create.Message.Geometry" } }, Errors = { { GEOMETRY, "Geo.Create.Error.Geometry" } }, ElementFactory = new DefaultElementFactory <GMLGeometryDataControl>(new DefaultElementFactory <GMLGeometryDataControl> .ElementCreator { CreateDataControl = geometry => new GMLGeometryDataControl(geometry as GMLGeometry), CreateElement = (type, id, _) => new GMLGeometryDataControl(new GMLGeometry()), TypeDescriptors = new [] { new DefaultElementFactory <GMLGeometryDataControl> .ElementCreator.TypeDescriptor { ContentType = typeof(GMLGeometry), Type = GEOMETRY } } }) } }); }
private void UpdateChapter() { if (Controller.Instance.SelectedChapterDataControl != null && lastSelectedChapterDataControl != Controller.Instance.SelectedChapterDataControl) { // Map scenes list manages only map scenes mapScenes = new ListDataControl <ChapterDataControl, MapSceneDataControl>( Controller.Instance.SelectedChapterDataControl, Controller.Instance.SelectedChapterDataControl.getObjects <MapScene>(), new ListDataControl <ChapterDataControl, MapSceneDataControl> .ElementFactoryView { Titles = { { 8923478, "Geo.Create.Title.MapScene" } }, DefaultIds = { { 8923478, "MapScene" } }, Errors = { { 8923478, "Geo.Create.Error.MapScene" } }, Messages = { { 8923478, "Geo.Create.Message.MapScene" } }, ElementFactory = new DefaultElementFactory <MapSceneDataControl>( new DefaultElementFactory <MapSceneDataControl> .ElementCreator() { CreateDataControl = ms => new MapSceneDataControl(ms as MapScene), CreateElement = (type, id, _) => new MapSceneDataControl(new MapScene(id)), TypeDescriptors = new[] { new DefaultElementFactory <MapSceneDataControl> .ElementCreator.TypeDescriptor { Type = 8923478, ContentType = typeof(MapScene), RequiresId = true } } }) }); Controller.Instance.SelectedChapterDataControl.RegisterExtraDataControl(mapScenes); SelectedMapScene = -1; // Geo Elements list manages only geo elements geoElements = new ListDataControl <ChapterDataControl, GeoElementDataControl>( Controller.Instance.SelectedChapterDataControl, Controller.Instance.SelectedChapterDataControl.getObjects <GeoElement>(), new ListDataControl <ChapterDataControl, GeoElementDataControl> .ElementFactoryView { Titles = { { 6493512, "Geo.Create.Title.GeoElement" } }, DefaultIds = { { 6493512, "GeoElement" } }, Errors = { { 6493512, "Geo.Create.Error.GeoElement" } }, Messages = { { 6493512, "Geo.Create.Message.GeoElement" } }, ElementFactory = new DefaultElementFactory <GeoElementDataControl>( new DefaultElementFactory <GeoElementDataControl> .ElementCreator() { CreateDataControl = g => new GeoElementDataControl(g as GeoElement), CreateElement = (type, id, extra) => { var geoElement = new GeoElement(id); var place = extra[0] as SearchData; if (place != null) { geoElement.Geometries[0].Type = GMLGeometry.GeometryType.Polygon; geoElement.Geometries[0].Points = place.boundingBox.ToPoints().Select(p => new Vector2d(p.y, p.x)).ToArray(); } return(new GeoElementDataControl(geoElement)); }, TypeDescriptors = new[] { new DefaultElementFactory <GeoElementDataControl> .ElementCreator.TypeDescriptor { Type = 6493512, ContentType = typeof(GeoElement), RequiresId = true, ExtraParameters = new Action <Action <object> > [] { callback => { ScriptableObject.CreateInstance <PlaceInputDialog>().Init(sd => callback(sd)); } } } } }) }); Controller.Instance.SelectedChapterDataControl.RegisterExtraDataControl(geoElements); SelectedGeoElement = -1; lastSelectedChapterDataControl = Controller.Instance.SelectedChapterDataControl; Controller.Instance.updateVarFlagSummary(); } }
public override void Draw(int aID) { if (selectedElement == -1) { GUILayout.Label("Nothing selected"); return; } element = Controller.Instance.SelectedChapterDataControl.getObjects <GeoElement>()[selectedElement]; actionsList.list = element.Actions; // Set geometries list reference map.Geometries = new List <GMLGeometry>() { element.Geometry }; selected = GUILayout.Toolbar(selected, menus); switch (selected) { case 0: // Map view { element.Geometry.Type = (GMLGeometry.GeometryType)EditorGUILayout.EnumPopup("Geometry type", element.Geometry.Type); EditorGUILayout.LabelField("Points: " + element.Geometry.Points.Count); element.Geometry.Influence = EditorGUILayout.FloatField("Influence Radius", element.Geometry.Influence); if (GUILayout.Button("Center") && element.Geometry.Points.Count > 0) { Center(element); } if (GUILayout.Button(!editing ? "Edit" : "Finish")) { editing = !editing; } EditorGUILayout.Separator(); placeSearcher.LayoutBegin(); // Location control location = EditorGUILayout.Vector2Field("Location", location); if (location != map.Center.ToVector2()) { map.Center = new Vector2d(location.x, location.y); } // Map drawing if (editing) { map.selectedGeometry = element.Geometry; } if (map.DrawMap(GUILayoutUtility.GetRect(0, 0, GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true))) && element != null && editing) { element.Geometry.AddPoint(map.GeoMousePosition); } location = map.Center.ToVector2(); if (placeSearcher.LayoutEnd()) { // If new Location is selected from the dropdown location = placeSearcher.LatLon.ToVector2(); Repaint(); } } break; case 1: { GUILayout.Label("Full description"); element.FullDescription = GUILayout.TextArea(element.FullDescription, GUILayout.Height(250)); element.Name = EditorGUILayout.TextField("Name", element.Name); element.BriefDescription = EditorGUILayout.TextField("Brief description", element.BriefDescription); element.DetailedDescription = EditorGUILayout.TextField("Detailed description", element.DetailedDescription); GUILayout.Label("Element image"); GUILayout.BeginHorizontal(); GUILayout.Box(element.Image, GUILayout.Width(0.78f * m_Rect.width)); if (GUILayout.Button(TC.get("Buttons.Select"), GUILayout.Width(0.2f * m_Rect.width))) { ShowAssetChooser(AssetType.Image); } GUILayout.EndHorizontal(); } break; case 2: { actionsList.list = element.Actions; actionsList.DoList(new Rect(0, 50, m_Rect.width * 0.99f, m_Rect.height)); } break; } }