Ejemplo n.º 1
0
        private void CreateMarkers()
        {
            for (int i = 0; i < LocationDatabase.pointsOfInterestCount; i++)
            {
                PointOfInterestGroup pointOfInterestGroup = LocationDatabase.GetPointOfInterestGroup(i);

                for (int j = 0; j < pointOfInterestGroup.placeCollectionCount; j++)
                {
                    PlaceCollection placeCollection = pointOfInterestGroup.GetPlaceCollection(j);
                    if (placeCollection == null)
                    {
                        continue;
                    }

                    bool hasRooms = placeCollection.hasRooms;

                    Place place = placeCollection.GetPlace();
                    CreateMarker(place.thumbnail, place.displayedName, place.mapName, place.displayPosition, (hasRooms ? placeViewingBounds : ViewingBounds.Default), true, 1, 0);
                    // CreateMarker(place.thumbnail, place.displayedName, place.mapName, place.displayPosition, ViewingBounds.Default, 0);

                    if (!hasRooms)
                    {
                        continue;
                    }

                    int highestFloor = placeCollection.highestFloorLevel;

                    for (int k = 0; k < placeCollection.roomCount; k++)
                    {
                        Room room = placeCollection.GetRoom(k);
                        CreateMarker(null, room.displayedName, room.mapName, room.displayPosition, roomViewingBounds, true, highestFloor, room.floor);
                    }
                }
            }
        }
Ejemplo n.º 2
0
 public Location LandblockToLocation(int landblock, LocationDatabase locDb)
 {
     if (IsDungeon(landblock))
     {
         return(DungeonIdToLocation(GetDungeonId(landblock), locDb));
     }
     return(null);
 }
Ejemplo n.º 3
0
 void CloseDatabase()
 {
     locationDatabase = null;
     if (EditorPrefs.HasKey(editorPref))
     {
         EditorPrefs.DeleteKey(editorPref);
     }
 }
 private Place GetBuilding()
 {
     if (selectedLocation as Place)
     {
         return(selectedLocation as Place);
     }
     else
     {
         return(LocationDatabase.GetBuildingFromRoom(selectedLocation as Room));
     }
 }
Ejemplo n.º 5
0
        private void Initialize()
        {
            Place[] buildings = LocationDatabase.GetAllBuildings();
            CreateList(buildings);
            canvasGroup = GetComponent <CanvasGroup>();

            if (backButton != null)
            {
                backButton.onClick.AddListener(Close);
            }
        }
Ejemplo n.º 6
0
        private void OnSelect(int index)
        {
            Location       location = LocationDatabase.GetLocationFromSearch(index);
            LocationMarker marker   = new LocationMarker(location);

            if (marker == null)
            {
                return;
            }

            SetMarker(marker, currentContext);
        }
Ejemplo n.º 7
0
        public void LoadDestinationXml(XmlElement arrowNode, LocationDatabase locDb)
        {
            XmlElement  ele;
            Coordinates coords;

            if ((ele = (XmlElement)arrowNode.SelectSingleNode("route")) != null)
            {
                try
                {
                    int index;
                    int.TryParse(ele.GetAttribute("routeIndex"), out index);
                    Route route = Route.FromXml(ele, locDb);
                    if (route.Count > 0)
                    {
                        this.Route      = route;
                        this.RouteIndex = index;
                        return;
                    }
                }
                catch (Exception ex) { Util.HandleException(ex); }
            }

            if ((ele = (XmlElement)arrowNode.SelectSingleNode("object")) != null)
            {
                const System.Globalization.NumberStyles hex = System.Globalization.NumberStyles.HexNumber;
                int id, icon;
                if (int.TryParse(ele.GetAttribute("id"), hex, null, out id) &&
                    int.TryParse(ele.GetAttribute("icon"), hex, null, out icon) &&
                    Coordinates.TryParse(ele.GetAttribute("coords"), out coords))
                {
                    this.DestinationObject = new GameObject(id, ele.GetAttribute("name"), icon, Host.Actions, coords);
                    return;
                }
            }

            if ((ele = (XmlElement)arrowNode.SelectSingleNode("location")) != null)
            {
                int      locId;
                Location loc;
                if (int.TryParse(ele.GetAttribute("id"), out locId) && locDb.TryGet(locId, out loc))
                {
                    this.DestinationLocation = loc;
                    return;
                }
            }

            // No other methods succeeded
            if (Coordinates.TryParse(arrowNode.GetAttribute("coords"), out coords))
            {
                this.DestinationCoords = coords;
            }
        }
Ejemplo n.º 8
0
    LocationDatabase NewDatabase()
    {
        Debug.Log("New Location Database");
        LocationDatabase asset = ScriptableObject.CreateInstance <LocationDatabase>();

        string path = "Assets/Databases/" + editorPref + ".asset";

        AssetDatabase.CreateAsset(asset, path);
        asset.DB = new List <Location>();
        AssetDatabase.SaveAssets();

        EditorPrefs.SetString(editorPref, path);
        return(asset);
    }
Ejemplo n.º 9
0
    private void Awake()
    {
        // Dont destroy this object when a new scene is loaded, unless...
        DontDestroyOnLoad(this);

        // There can be only ONE!
        if (_instance == null)
        {
            _instance = this;
        }
        else if (_instance != this)
        {
            Destroy(this.gameObject);
        }
    }
        private void OnTextEdit(string text)
        {
            LocationDatabase.Search(text);

            bool hasText = !string.IsNullOrEmpty(text);

            if (clearButton != null)
            {
                clearButton.gameObject.SetActive(hasText);
            }

            if (searchIcon != null)
            {
                searchIcon.gameObject.SetActive(!hasText);
            }
        }
Ejemplo n.º 11
0
        private void OnResult(int count)
        {
            if (count == 0)
            {
                SearchMenu.SetContents(null);
                return;
            }

            MenuContent[] contents = new MenuContent[count];

            for (int i = 0; i < count; i++)
            {
                Location location = LocationDatabase.GetLocationFromSearch(i);
                contents[i] = new MenuContent(null, location.displayedName);
            }

            SearchMenu.SetContents(contents);
        }
Ejemplo n.º 12
0
    void OnEnable()
    {
        if (!AssetDatabase.IsValidFolder(locationPath))
        {
            AssetDatabase.CreateFolder("Assets/Databases", "Locations");
        }

        if (EditorPrefs.HasKey(editorPref))
        {
            string path = EditorPrefs.GetString(editorPref);
            locationDatabase = AssetDatabase.LoadAssetAtPath(path, typeof(LocationDatabase)) as LocationDatabase;
        }


        if (!EditorPrefs.HasKey(idPref))
        {
            EditorPrefs.SetInt(idPref, 1);
        }
    }
Ejemplo n.º 13
0
        public Location DungeonIdToLocation(int dungeonId, LocationDatabase locDb)
        {
            string name;

            mDungeonIdToName.TryGetValue(dungeonId, out name);

            Location nameMatch = null;

            foreach (Location loc in locDb.Locations.Values)
            {
                if (loc.DungeonId == dungeonId)
                {
                    return(loc);
                }
                if (nameMatch != null && StringComparer.OrdinalIgnoreCase.Equals(name, loc.Name))
                {
                    nameMatch = loc;
                }
            }
            return(nameMatch);
        }
Ejemplo n.º 14
0
    void OpenDatabase()
    {
        string absPath = EditorUtility.OpenFilePanel("Select Database", "", "");

        Debug.Log(absPath);

        if (absPath.StartsWith(Application.dataPath))
        {
            string relPath = absPath.Substring(Application.dataPath.Length - "Assets".Length);
            locationDatabase = AssetDatabase.LoadAssetAtPath(relPath, typeof(LocationDatabase)) as LocationDatabase;
            if (locationDatabase.DB == null)
            {
                locationDatabase.DB = new List <Location>();
                EditorUtility.SetDirty(locationDatabase);
            }
            if (locationDatabase)
            {
                Debug.Log(relPath);
                EditorPrefs.SetString(editorPref, relPath);
            }
        }
    }
        private void OnContentClicked(int index)
        {
            if (!visible)
            {
                return;
            }

            Location location = LocationDatabase.GetLocationFromSearch(index);

            if (LocationSelectCallback != null)
            {
                LocationSelectCallback(location);
            }

            LocationSelectCallback = null;

            if (focusOnSelectedLocation)
            {
                FocusOnSelectedLocation(location);
            }

            Close();
        }
        private void OnResult(int count)
        {
            MenuContent[] contents = null;

            if (count > 0)
            {
                contents = new MenuContent[count];
                for (int i = 0; i < count; i++)
                {
                    Location location  = LocationDatabase.GetLocationFromSearch(i);
                    Sprite   thumbnail = null;

                    if (location is Place)
                    {
                        Place building = location as Place;
                        thumbnail = building.thumbnail;
                    }

                    contents[i] = new MenuContent(thumbnail, location.displayedName);
                }
            }

            SetContents(contents);
        }
Ejemplo n.º 17
0
		public Location ToLocation(LocationDatabase locDb)
		{
			Location loc;
			if (locDb.TryGet(mId, out loc))
				return loc;

			loc = new Location(mId, Name, LocationType._StartPoint, Coords, "");
			loc.Icon = mIcon;
			return loc;
		}
 private bool SelectedBuildingHasTrivia()
 {
     return(LocationDatabase.PlaceHasTrivia(GetBuilding()));
 }
Ejemplo n.º 19
0
		protected override void Startup()
		{
			try
			{
				Util.Initialize("GoArrow", Host, Core, base.Path);
				System.Threading.Thread.CurrentThread.CurrentCulture
					= new System.Globalization.CultureInfo("en-US", false);

				mSettingsLoaded = false;
				mLoggedIn = false;
				mLoginCompleted = false;

				FileInfo locationsFile = new FileInfo(Util.FullPath("locations.xml"));
				if (locationsFile.Exists)
				{
					mLocDb = new LocationDatabase(locationsFile.FullName);
				}
				else
				{
					// Load from resource
					XmlDocument locDoc = new XmlDocument();
					locDoc.LoadXml(RouteFinding.Data.LocationsDatabase);
					mLocDb = new LocationDatabase(locDoc);
				}

				mLastSpellId = 0;
				mLastSpellTarget = 0;
				mRecallingToLSBind = RecallStep.NotRecalling;
				mRecallingToLSTie = RecallStep.NotRecalling;
				mRecallingToBindstone = RecallStep.NotRecalling;

				mHudManager = new HudManager(Host, Core, DefaultView, delegate() { return mDefaultViewActive; }, false);
				mHudManager.ExceptionHandler += new EventHandler<ExceptionEventArgs>(HudManager_ExceptionHandler);
				GraphicsReset += new EventHandler(mHudManager.GraphicsReset);
				WindowMessage += new EventHandler<WindowMessageEventArgs>(mHudManager.DispatchWindowMessage);
				RegionChange3D += new EventHandler<RegionChange3DEventArgs>(mHudManager.DispatchRegionChange3D);

				mDungeonHud = new DungeonHud(mHudManager);

				mMapHud = new MapHud(mHudManager, this, mLocDb);

				mArrowHud = new ArrowHud(mHudManager);
				mArrowHud.AsyncLoadComplete += new RunWorkerCompletedEventHandler(ArrowHud_AsyncLoadComplete);
				mArrowHud.DestinationChanged += new EventHandler<DestinationChangedEventArgs>(mMapHud.ArrowHud_DestinationChanged);

				mToolbar = new ToolbarHud(mHudManager);
				mMainViewToolButton = mToolbar.AddButton(new ToolbarButton(Icons.Toolbar.Settings, "Settings"));
				mArrowToolButton = mToolbar.AddButton(new ToolbarButton(Icons.Toolbar.GoArrow, "Arrow"));
				mDerethToolButton = mToolbar.AddButton(new ToolbarButton(Icons.Toolbar.Dereth, "Dereth"));
				mDungeonToolButton = mToolbar.AddButton(new ToolbarButton(Icons.Toolbar.Dungeon, "Dungeon"));
				mMainViewToolButton.Click += new EventHandler(MainViewToolButton_Click);
				mArrowToolButton.Click += new EventHandler(ArrowToolButton_Click);
				mDerethToolButton.Click += new EventHandler(DerethToolButton_Click);
				mDungeonToolButton.Click += new EventHandler(DungeonToolButton_Click);

				mStartLocations = new SortedDictionary<string, RouteStart>(StringComparer.OrdinalIgnoreCase);

				// Load portal devices
				// Try to load from file. If that fails, load from resource
				XmlDocument portalDevicesDoc = new XmlDocument();
				string portalDevicesPath = Util.FullPath("PortalDevices.xml");
				if (File.Exists(portalDevicesPath))
				{
					portalDevicesDoc.Load(portalDevicesPath);
				}
				else
				{
					portalDevicesDoc.LoadXml(RouteFinding.Data.PortalDevices);
				}

				mPortalDevices = new SortedDictionary<string, PortalDevice>(StringComparer.OrdinalIgnoreCase);
				foreach (XmlElement portalDeviceEle in portalDevicesDoc.DocumentElement.GetElementsByTagName("device"))
				{
					PortalDevice device;
					if (PortalDevice.TryLoadXmlDefinition(portalDeviceEle, out device))
					{
						mPortalDevices[device.Name] = device;
					}
				}

				InitMainViewBeforeSettings();

				mRecallTimeout = new WindowsTimer();
				mRecallTimeout.Tick += new EventHandler(RecallTimeout_Tick);

				mLoginTime = DateTime.Now;

#if USING_D3D_CONTAINER
				RouteStart.Initialize(110011, "Digero", 220022, "DaBug", "DebugAccount");
				LoadSettings();
				InitMainViewAfterSettings();

				mHudManager.StartHeartbeat();
#endif
			}
			catch (Exception ex) { Util.HandleException(ex); }
		}
Ejemplo n.º 20
0
		protected override void Shutdown()
		{
			try
			{
				mLoggedIn = false;
				mLoginCompleted = false;

				SaveSettings();

				Util.Dispose();
				DisposeMainView();

				if (mHudManager != null)
				{
					GraphicsReset -= mHudManager.GraphicsReset;
					WindowMessage -= mHudManager.DispatchWindowMessage;
					RegionChange3D -= mHudManager.DispatchRegionChange3D;
					mHudManager.Dispose();
					mHudManager = null;
				}

				mArrowHud = null;
				mMapHud = null;
				mDungeonHud = null;

				if (mRecallTimeout != null)
				{
					mRecallTimeout.Dispose();
					mRecallTimeout = null;
				}

				if (mDatabaseReminderDelay != null)
				{
					mDatabaseReminderDelay.Dispose();
					mDatabaseReminderDelay = null;
				}

				if (Core.HotkeySystem != null)
				{
					Core.HotkeySystem.Hotkey -= HotkeySystem_Hotkey;
				}

				mLocDb.Dispose();
				mLocDb = null;
			}
			catch (Exception ex) { Util.HandleException(ex); }
		}
Ejemplo n.º 21
0
		public Location LandblockToLocation(int landblock, LocationDatabase locDb)
		{
			if (IsDungeon(landblock))
			{
				return DungeonIdToLocation(GetDungeonId(landblock), locDb);
			}
			return null;
		}
Ejemplo n.º 22
0
 private void OnSearch(string text)
 {
     LocationDatabase.Search(text);
 }
Ejemplo n.º 23
0
		public Location DungeonIdToLocation(int dungeonId, LocationDatabase locDb)
		{
			string name;
			mDungeonIdToName.TryGetValue(dungeonId, out name);

			Location nameMatch = null;
			foreach (Location loc in locDb.Locations.Values)
			{
				if (loc.DungeonId == dungeonId)
				{
					return loc;
				}
				if (nameMatch != null && StringComparer.OrdinalIgnoreCase.Equals(name, loc.Name))
				{
					nameMatch = loc;
				}
			}
			return nameMatch;
		}
Ejemplo n.º 24
0
    void OnGUI()
    {
        EditorGUILayout.BeginHorizontal();
        GUILayout.Label("Location Editor: ", EditorStyles.boldLabel);
        if (locationDatabase)
        {
            if (GUILayout.Button("Loaded"))
            {
                SelectDatabase();
            }
            if (GUILayout.Button("Close"))
            {
                CloseDatabase();
            }
        }
        else
        {
            if (GUILayout.Button("New"))
            {
                locationDatabase = NewDatabase();
            }
            if (GUILayout.Button("Load"))
            {
                OpenDatabase();
            }
        }
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.Space();

        //Edit fields for quest stuff.
        if (locationDatabase)
        {
            EditorGUILayout.BeginHorizontal();
            //List of Weapons
            EditorGUILayout.BeginVertical(EditorStyles.helpBox, GUILayout.Width(100));
            scrollPos = EditorGUILayout.BeginScrollView(scrollPos, EditorStyles.textArea, GUILayout.Width(100));

            for (int i = 0; i < locationDatabase.DB.Count; i++)
            {
                Location loc = locationDatabase.DB[i];
                if (GUILayout.Button(loc.name))
                {
                    //tempQuest.Clone(q);
                    selectedIndex   = i;
                    editingLocation = loc;
                }
            }



            EditorGUILayout.EndScrollView();
            if (GUILayout.Button("New"))
            {
                //Create a new TempQuest.
                selectedIndex = -1;
                CreateTempLocation();
                editingLocation = tempLocation;
            }
            EditorGUILayout.EndVertical();

            if (editingLocation)
            {
                //MAin Editor area
                EditorGUILayout.BeginVertical();
                EditorGUI.BeginChangeCheck();


                editingLocation.Name = EditorGUILayout.TextField("Location Name:", editingLocation.Name);
                EditorGUILayout.SelectableLabel(editingLocation.ID.ToString());
                editingLocation.MaxFloors = EditorGUILayout.IntField("Max Floor:", editingLocation.MaxFloors);

                int indexToDelete = -1;
                for (int i = 0; i < editingLocation.EncounterData.Count; i++)
                {
                    EncounterData ed = editingLocation.EncounterData[i];
                    EditorGUILayout.BeginVertical(EditorStyles.helpBox);

                    ed.Encounter = EditorGUILayout.ObjectField("Encounter:", ed.Encounter, typeof(Encounter), false) as Encounter;
                    //ed.MinFloor = EditorGUILayout.IntField("Main Floor:", ed.MainFloor);


                    //ed.MinFloor = Mathf.Floor(ed.MinFloor);
                    //ed.MaxFloor = Mathf.Floor(ed.MaxFloor);
                    EditorGUILayout.MinMaxSlider(ref ed.minFloor, ref ed.maxFloor, 1, editingLocation.MaxFloors);
                    EditorGUILayout.SelectableLabel("MinFloor: " + ed.MinFloor + ", MaxFloor: " + ed.MaxFloor); //TODO: Crash using the property?

                    ed.Probability = EditorGUILayout.IntField("Probability:", ed.Probability);

                    if (GUILayout.Button("Delete"))
                    {
                        indexToDelete = i;
                    }
                    EditorGUILayout.EndVertical();
                }
                if (indexToDelete > -1)
                {
                    editingLocation.EncounterData.RemoveAt(indexToDelete);
                }

                if (GUILayout.Button("Add empty encounter data"))
                {
                    editingLocation.EncounterData.Add(new EncounterData(null, 0, 0, editingLocation.MaxFloors));
                }

                /*
                 * editingLocation.LevelRequirement = EditorGUILayout.IntField("Required Level:", editingLocation.LevelRequirement);
                 * editingLocation.MinDamage = EditorGUILayout.IntField("Min Damage:", editingLocation.MinDamage);
                 * editingLocation.MaxDamage = EditorGUILayout.IntField("Max Damage:", editingLocation.MaxDamage);
                 * editingLocation.BlockClearModifier = EditorGUILayout.IntField("Clear Block Modifier:", editingLocation.BlockClearModifier);
                 * editingLocation.Attunement = (BlockColor)EditorGUILayout.EnumPopup("Atunement:", editingLocation.Attunement);
                 * editingLocation.Rarity = (ItemRarity)EditorGUILayout.ObjectField("Rarity", editingLocation.Rarity, typeof(ItemRarity), false);
                 * editingLocation.IconSprite = EditorGUILayout.ObjectField("Enemy Sprite:", editingLocation.IconSprite, typeof(Sprite), true) as Sprite;
                 */

                if (EditorGUI.EndChangeCheck())
                {
                    EditorUtility.SetDirty(editingLocation);
                }
                EditorGUILayout.EndVertical();

                //if (GUI.changed) EditorUtility.SetDirty(editingQuest);
            }
            EditorGUILayout.EndHorizontal();
        }

        //StatusBar
        EditorGUILayout.BeginHorizontal(EditorStyles.helpBox, GUILayout.Height(25));
        GUILayout.Label("Ready");
        if (tempLocation)
        {
            if (GUILayout.Button("Save"))
            {
                SaveNewAsset();
            }
            if (GUILayout.Button("Cancel"))
            {
                ClearTempLocation();
            }
        }

        if (selectedIndex > -1)
        {
            if (GUILayout.Button("Delete"))
            {
                if (EditorUtility.DisplayDialog("Delete Enemy?", "Are you sure you want to delete this?", "Delete"))
                {
                    string itemToBeDestroyed = AssetDatabase.GetAssetPath(locationDatabase.DB[selectedIndex]);
                    locationDatabase.DB.RemoveAt(selectedIndex);
                    EditorUtility.SetDirty(locationDatabase);
                    AssetDatabase.DeleteAsset(itemToBeDestroyed);
                    editingLocation = null;
                    selectedIndex   = -1;
                }
            }
        }

        EditorGUILayout.EndHorizontal();
    }
Ejemplo n.º 25
0
		private void xmlConverterWorker_DoWork(object sender, DoWorkEventArgs e)
		{
			System.Threading.Thread.CurrentThread.CurrentCulture =
				   new System.Globalization.CultureInfo("en-US", false);

			Util.QueueAction(delegate()
			{
				txtDownloadStatusA.Text = "Converting... 0%";
				prgLocationsProgress.Value = 0;
				txtDownloadStatusB.Text = "";
			});

			LocationDatabase dbNew;
			if (choUpdateDatabaseType.Selected == UpdateDatabaseType.CrossroadsOfDereth)
			{
				dbNew = new LocationDatabase(DatabaseType.CrossroadsOfDereth);
			}
			else
			{
				dbNew = new LocationDatabase(DatabaseType.ACSpedia);
			}

			if (!chkUpdateOverwrite.Checked && dbNew.DatabaseType == mLocDb.DatabaseType)
			{
				foreach (Location loc in mLocDb.Locations.Values)
				{
					if (loc.IsCustomized)
						dbNew.Add(loc);
				}
			}

			if (choUpdateDatabaseType.Selected == UpdateDatabaseType.CrossroadsOfDereth)
			{
				XmlDocument codXml = new XmlDocument();
				try
				{
					codXml.Load(codLocationsXmlPath);
				}
				catch (Exception ex)
				{
					txtDownloadStatusA.Text = "Update failed!";
					Util.HandleException(ex, "Failed to open downloaded locations file; make sure "
						+ "you have the right database URL and type selected", false);

					try { File.Delete(codLocationsXmlPath); }
					catch { /* Ignore */ }
					e.Cancel = true;
					return;
				}

				XmlNodeList codNodes = codXml.DocumentElement.GetElementsByTagName("location");
				double total = codNodes.Count;
				int lastPct = 0;
				for (int i = 0; i < codNodes.Count; i++)
				{
					if (mXmlConverterWorker.CancellationPending)
					{
						e.Cancel = true;
						return;
					}

					int curPct = (int)Math.Round(100 * i / total);
					if (curPct > lastPct)
					{
						Util.QueueAction(delegate()
						{
							txtDownloadStatusA.Text = "Converting... " + curPct + "%";
							prgLocationsProgress.Value = curPct;
						});
						lastPct = curPct;
					}

					Location oldLoc;
					Location newLoc = Location.FromXmlWarcry((XmlElement)codNodes[i]);
					if (!newLoc.IsRetired && !dbNew.Contains(newLoc.Id))
					{
						if (dbNew.DatabaseType == mLocDb.DatabaseType && mLocDb.TryGet(newLoc.Id, out oldLoc))
							newLoc.IsFavorite = oldLoc.IsFavorite;
						dbNew.Add(newLoc);
					}
				}
			}
			else
			{ // ACSpedia Database
				string[] locations;
				try
				{
					using (StreamReader reader = new StreamReader(acsLocationsPath))
					{
						locations = reader.ReadToEnd().Split(new string[] { "\r\n!", "\n!" }, StringSplitOptions.RemoveEmptyEntries);
					}
				}
				catch (Exception ex)
				{
					txtDownloadStatusA.Text = "Update failed!";
					Util.Error("Failed to open downloaded locations file ("
						+ ex.GetType().Name + ": " + ex.Message + ")");

					try { File.Delete(acsLocationsPath); }
					catch { /* Ignore */ }
					e.Cancel = true;
					return;
				}
				// locations[0] is the number of locations
				// locations[1] is the header info
				// locations[2..n] are the locations
				int ct;
				if (!int.TryParse(locations[0], out ct) || ct != locations.Length - 2)
				{
					txtDownloadStatusA.Text = "Update failed!";
					Util.Error("The ACSpedia database format was not in the expected format.");

					try { File.Delete(acsLocationsPath); }
					catch { /* Ignore */ }
					e.Cancel = true;
					return;
				}

				double total = locations.Length;
				int lastPct = 0;
				for (int i = 2; i < locations.Length; i++)
				{
					if (mXmlConverterWorker.CancellationPending)
					{
						e.Cancel = true;
						return;
					}

					int curPct = (int)Math.Round(100 * i / total);
					if (curPct > lastPct)
					{
						Util.QueueAction(delegate()
						{
							txtDownloadStatusA.Text = "Converting... " + curPct + "%";
							prgLocationsProgress.Value = curPct;
						});
						lastPct = curPct;
					}

					Location oldLoc, newLoc;
					if (Location.TryParseACSpedia(locations[i], out newLoc) && !newLoc.IsRetired && !dbNew.Contains(newLoc.Id))
					{
						if (dbNew.DatabaseType == mLocDb.DatabaseType && mLocDb.TryGet(newLoc.Id, out oldLoc))
							newLoc.IsFavorite = oldLoc.IsFavorite;
						dbNew.Add(newLoc);
					}
				}
			}

			txtDownloadStatusA.Text = "Integrating...";
			e.Result = dbNew;
		}
Ejemplo n.º 26
0
 public static int GetUniqueLocationId()
 {
     return(LocationDatabase.GetUniqueId());
 }
Ejemplo n.º 27
0
		public void LoadDestinationXml(XmlElement arrowNode, LocationDatabase locDb)
		{
			XmlElement ele;
			Coordinates coords;
			if ((ele = (XmlElement)arrowNode.SelectSingleNode("route")) != null)
			{
				try
				{
					int index;
					int.TryParse(ele.GetAttribute("routeIndex"), out index);
					Route route = Route.FromXml(ele, locDb);
					if (route.Count > 0)
					{
						this.Route = route;
						this.RouteIndex = index;
						return;
					}
				}
				catch (Exception ex) { Util.HandleException(ex); }
			}

			if ((ele = (XmlElement)arrowNode.SelectSingleNode("object")) != null)
			{
				const System.Globalization.NumberStyles hex = System.Globalization.NumberStyles.HexNumber;
				int id, icon;
				if (int.TryParse(ele.GetAttribute("id"), hex, null, out id)
					&& int.TryParse(ele.GetAttribute("icon"), hex, null, out icon)
					&& Coordinates.TryParse(ele.GetAttribute("coords"), out coords))
				{
					this.DestinationObject = new GameObject(id, ele.GetAttribute("name"), icon, Host.Actions, coords);
					return;
				}
			}

			if ((ele = (XmlElement)arrowNode.SelectSingleNode("location")) != null)
			{
				int locId;
				Location loc;
				if (int.TryParse(ele.GetAttribute("id"), out locId) && locDb.TryGet(locId, out loc))
				{
					this.DestinationLocation = loc;
					return;
				}
			}

			// No other methods succeeded
			if (Coordinates.TryParse(arrowNode.GetAttribute("coords"), out coords))
			{
				this.DestinationCoords = coords;
			}
		}
Ejemplo n.º 28
0
		public MapHud(HudManager manager, PluginCore pluginCore, LocationDatabase locationDatabase)
			: base(DefaultRegion, "Map of Dereth", manager)
		{

			mPluginCore = pluginCore;

			mZipFile = new ZipFile(Util.FullPath(@"Huds\DerethMap.zip"));

			using (StreamReader mapInfoReader = new StreamReader(mZipFile.GetInputStream(mZipFile.GetEntry("map.txt"))))
			{
				// File format has 3 lines: mapSize, tileSize, padding
				mMapSize = int.Parse(mapInfoReader.ReadLine());
				mTileSize = int.Parse(mapInfoReader.ReadLine());
				mTilePaddedSize = mTileSize + int.Parse(mapInfoReader.ReadLine());
				mMaxTile = (mMapSize - 1) / mTileSize;
				mPixPerClick = mMapSize / 204.1f;
			}

			mActualZoom = mZoomMultiplier;

			mCoordTickDelta = CalculateCoordTickDelta(Zoom);

			SetAlphaFading(255, 128);

			ClientMouseDown += new EventHandler<HudMouseEventArgs>(MapHud_ClientMouseDown);
			ClientMouseUp += new EventHandler<HudMouseEventArgs>(MapHud_ClientMouseUp);
			ClientMouseDrag += new EventHandler<HudMouseDragEventArgs>(MapHud_ClientMouseDrag);
			ClientMouseDoubleClick += new EventHandler<HudMouseEventArgs>(MapHud_ClientMouseDoubleClick);
			ClientMouseWheel += new EventHandler<HudMouseEventArgs>(MapHud_ClientMouseWheel);
			ClientMouseMove += new EventHandler<HudMouseEventArgs>(MapHud_ClientMouseMove);
			ClientMouseLeave += new EventHandler<HudMouseEventArgs>(MapHud_ClientMouseLeave);

			ResizeEnd += new EventHandler(MapHud_ResizeEnd);

			ClientVisibleChanged += new EventHandler(MapHud_ClientVisibleChanged);
			Moving += new EventHandler(MapHud_Moving);

			Heartbeat += new EventHandler(MapHud_Heartbeat);

			ResizeDrawMode = HudResizeDrawMode.Repaint;

			mLocDb = locationDatabase;

			WindowMessage += new EventHandler<WindowMessageEventArgs>(MapHud_WindowMessage);

			AlphaChanged += new EventHandler<AlphaChangedEventArgs>(MapHud_AlphaChanged);

			//MaxSize = new Size(1024, 1024);
		}
 private void Initialize()
 {
     Place[] buildings = LocationDatabase.GetAllBuildings();
     CreateList(buildings);
 }