private void AfterLoadMap(MapData mapData) { //同步可视化状态 foreach (var portal in mapData.Scene.Portals) { portal.View.IsEditorMode = this.patchVisibility.PortalInEditMode; } //同步UI this.renderEnv.Camera.WorldRect = mapData.VRect; StringResult sr; if (mapData.ID != null && this.StringLinker != null && StringLinker.StringMap.TryGetValue(mapData.ID.Value, out sr)) { this.ui.Minimap.StreetName = sr["streetName"]; this.ui.Minimap.MapName = sr["mapName"]; } else { this.ui.Minimap.StreetName = null; this.ui.Minimap.MapName = null; } if (mapData.MiniMap.MapMark != null) { this.ui.Minimap.MapMark = engine.Renderer.CreateTexture(mapData.MiniMap.MapMark); } else { this.ui.Minimap.MapMark = null; } if (mapData.MiniMap.Canvas != null) { this.ui.Minimap.MinimapCanvas = engine.Renderer.CreateTexture(mapData.MiniMap.Canvas); } else { this.ui.Minimap.MinimapCanvas = null; } this.ui.Minimap.Icons.Clear(); foreach (var portal in mapData.Scene.Portals) { switch (portal.Type) { case 2: case 7: object tooltip = portal.Tooltip; if (tooltip == null && portal.ToMap != null && portal.ToMap != 999999999 && StringLinker.StringMap.TryGetValue(portal.ToMap.Value, out sr)) { tooltip = sr["mapName"]; } this.ui.Minimap.Icons.Add(new UIMinimap2.MapIcon() { IconType = UIMinimap2.IconType.Portal, Tooltip = tooltip, WorldPosition = new EmptyKeys.UserInterface.PointF(portal.X, portal.Y) }); break; case 10: this.ui.Minimap.Icons.Add(new UIMinimap2.MapIcon() { IconType = UIMinimap2.IconType.Transport, Tooltip = portal.Tooltip, WorldPosition = new EmptyKeys.UserInterface.PointF(portal.X, portal.Y) }); break; } } if (mapData.MiniMap.Width > 0 && mapData.MiniMap.Height > 0) { this.ui.Minimap.MapRegion = new Rectangle(-mapData.MiniMap.CenterX, -mapData.MiniMap.CenterY, mapData.MiniMap.Width, mapData.MiniMap.Height).ToRect(); } else { this.ui.Minimap.MapRegion = mapData.VRect.ToRect(); } this.ui.WorldMap.CurrentMapID = mapData?.ID; }
private void AfterLoadMap(MapData mapData) { //同步可视化状态 foreach (var portal in mapData.Scene.Portals) { portal.View.IsEditorMode = this.patchVisibility.PortalInEditMode; } //同步UI this.renderEnv.Camera.WorldRect = mapData.VRect; StringResult sr; if (mapData.ID != null && this.StringLinker != null && StringLinker.StringMap.TryGetValue(mapData.ID.Value, out sr)) { this.ui.Minimap.StreetName = sr["streetName"]; this.ui.Minimap.MapName = sr["mapName"]; } else { this.ui.Minimap.StreetName = null; this.ui.Minimap.MapName = null; } if (mapData.MiniMap.MapMark != null) { this.ui.Minimap.MapMark = engine.Renderer.CreateTexture(mapData.MiniMap.MapMark); } else { this.ui.Minimap.MapMark = null; } if (mapData.MiniMap.Canvas != null) { this.ui.Minimap.MinimapCanvas = engine.Renderer.CreateTexture(mapData.MiniMap.Canvas); } else { this.ui.Minimap.MinimapCanvas = null; } this.ui.Minimap.Icons.Clear(); foreach (var portal in mapData.Scene.Portals) { switch (portal.Type) { case 2: case 7: object tooltip = portal.Tooltip; if (tooltip == null && portal.ToMap != null && portal.ToMap != 999999999 && StringLinker.StringMap.TryGetValue(portal.ToMap.Value, out sr)) { tooltip = sr["mapName"]; } this.ui.Minimap.Icons.Add(new UIMinimap2.MapIcon() { IconType = UIMinimap2.IconType.Portal, Tooltip = tooltip, WorldPosition = new EmptyKeys.UserInterface.PointF(portal.X, portal.Y) }); break; case 8: if (portal.ShownAtMinimap) { this.ui.Minimap.Icons.Add(new UIMinimap2.MapIcon() { IconType = UIMinimap2.IconType.HiddenPortal, Tooltip = portal.Tooltip, WorldPosition = new EmptyKeys.UserInterface.PointF(portal.X, portal.Y) }); } break; case 10: this.ui.Minimap.Icons.Add(new UIMinimap2.MapIcon() { IconType = portal.ToMap == mapData.ID ? UIMinimap2.IconType.ArrowUp : UIMinimap2.IconType.HiddenPortal, Tooltip = portal.Tooltip, WorldPosition = new EmptyKeys.UserInterface.PointF(portal.X, portal.Y) }); break; case 11: if (portal.ShownAtMinimap) { this.ui.Minimap.Icons.Add(new UIMinimap2.MapIcon() { IconType = UIMinimap2.IconType.HiddenPortal, Tooltip = portal.Tooltip, WorldPosition = new EmptyKeys.UserInterface.PointF(portal.X, portal.Y) }); } break; } } foreach (var npc in mapData.Scene.Npcs) { object tooltip = null; var npcNode = PluginManager.FindWz(string.Format("Npc/{0:D7}.img/info", npc.ID)); if ((npcNode?.Nodes["hide"].GetValueEx(0) ?? 0) != 0 || (npcNode?.Nodes["hideName"].GetValueEx(0) ?? 0) != 0) { continue; } if (StringLinker.StringNpc.TryGetValue(npc.ID, out sr)) { if (sr.Desc != null) { tooltip = new KeyValuePair <string, string>(sr.Name, sr.Desc); } else { tooltip = sr.Name; } } if (npc.ID == 9010022) { this.ui.Minimap.Icons.Add(new UIMinimap2.MapIcon() { IconType = UIMinimap2.IconType.Transport, Tooltip = tooltip, WorldPosition = new EmptyKeys.UserInterface.PointF(npc.X, npc.Y) }); } else if ((npcNode?.Nodes["shop"].GetValueEx(0) ?? 0) != 0) { this.ui.Minimap.Icons.Add(new UIMinimap2.MapIcon() { IconType = UIMinimap2.IconType.Shop, Tooltip = tooltip, WorldPosition = new EmptyKeys.UserInterface.PointF(npc.X, npc.Y) }); } else if (npc.ID / 10000 == 900 || npc.ID / 10000 == 901) { this.ui.Minimap.Icons.Add(new UIMinimap2.MapIcon() { IconType = UIMinimap2.IconType.EventNpc, Tooltip = tooltip, WorldPosition = new EmptyKeys.UserInterface.PointF(npc.X, npc.Y) }); } else if ((npcNode?.Nodes["trunkPut"].GetValueEx(0) ?? 0) != 0) { this.ui.Minimap.Icons.Add(new UIMinimap2.MapIcon() { IconType = UIMinimap2.IconType.Trunk, Tooltip = tooltip, WorldPosition = new EmptyKeys.UserInterface.PointF(npc.X, npc.Y) }); } else { this.ui.Minimap.Icons.Add(new UIMinimap2.MapIcon() { IconType = UIMinimap2.IconType.Npc, Tooltip = tooltip, WorldPosition = new EmptyKeys.UserInterface.PointF(npc.X, npc.Y) }); } } if (mapData.MiniMap.Width > 0 && mapData.MiniMap.Height > 0) { this.ui.Minimap.MapRegion = new Rectangle(-mapData.MiniMap.CenterX, -mapData.MiniMap.CenterY, mapData.MiniMap.Width, mapData.MiniMap.Height).ToRect(); } else { this.ui.Minimap.MapRegion = mapData.VRect.ToRect(); } this.ui.WorldMap.CurrentMapID = mapData?.ID; }