コード例 #1
0
ファイル: ToolTipHud.cs プロジェクト: joshlatte/goarrow
		public ToolTipHud(HudManager manager)
		{
			mManager = manager;
			mBmp = new Bitmap(256, 22);
			gBmp = Graphics.FromImage(mBmp);
			mFormat = new StringFormat();
			mFormat.Trimming = StringTrimming.EllipsisCharacter;

			Manager.Heartbeat += new EventHandler(ToolTipHud_Heartbeat);
		}
コード例 #2
0
        public ArrowHud(HudManager manager)
        {
            mManager = manager;
            asyncLoadImageWorker.DoWork += new DoWorkEventHandler(asyncLoadImageWorker_DoWork);
            mManager.RegisterHud(this, true);

            mArrowZipFile  = new ZipFile(Util.FullPath(@"Huds\Arrows.zip"));
            mArrowZipIndex = new SortedList <string, SortedList <int, int> >(StringComparer.OrdinalIgnoreCase);
            Regex zipNameParser = new Regex(@"(.*)/arrow_f(\d+).png");

            foreach (ZipEntry entry in mArrowZipFile)
            {
                Match parsedName = zipNameParser.Match(entry.Name);
                if (parsedName.Success)
                {
                    string arrowName = parsedName.Groups[1].Value;
                    if (!mArrowZipIndex.ContainsKey(arrowName))
                    {
                        mArrowZipIndex[arrowName] = new SortedList <int, int>();
                    }
                    int index = int.Parse(parsedName.Groups[2].Value);
                    mArrowZipIndex[arrowName][index] = entry.ZipFileIndex;
                }
            }
            List <string> invalidArrows = new List <string>();

            foreach (KeyValuePair <string, SortedList <int, int> > kvp in mArrowZipIndex)
            {
                SortedList <int, int> images = kvp.Value;

                // Since this list is sorted and each key is unique, this checks that
                // there exists one image for every index in the range [1,n]
                if (!(images.IndexOfKey(1) == 0 && images.IndexOfKey(images.Count) == images.Count - 1))
                {
                    invalidArrows.Add(kvp.Key);
                }
            }
            foreach (string arrowName in invalidArrows)
            {
                mArrowZipIndex.Remove(arrowName);
            }

            mFontMeasure = Graphics.FromImage(mFontMeasureBitmap);
            UpdateFont();
        }
コード例 #3
0
ファイル: MapHud.cs プロジェクト: joshlatte/goarrow
		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);
		}
コード例 #4
0
ファイル: PluginCore.cs プロジェクト: joshlatte/goarrow
		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); }
		}
コード例 #5
0
ファイル: PluginCore.cs プロジェクト: joshlatte/goarrow
		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); }
		}
コード例 #6
0
ファイル: ArrowHud.cs プロジェクト: joshlatte/goarrow
		public ArrowHud(HudManager manager)
		{
			mManager = manager;
			asyncLoadImageWorker.DoWork += new DoWorkEventHandler(asyncLoadImageWorker_DoWork);
			mManager.RegisterHud(this, true);

			mArrowZipFile = new ZipFile(Util.FullPath(@"Huds\Arrows.zip"));
			mArrowZipIndex = new SortedList<string, SortedList<int, int>>(StringComparer.OrdinalIgnoreCase);
			Regex zipNameParser = new Regex(@"(.*)/arrow_f(\d+).png");
			foreach (ZipEntry entry in mArrowZipFile)
			{
				Match parsedName = zipNameParser.Match(entry.Name);
				if (parsedName.Success)
				{
					string arrowName = parsedName.Groups[1].Value;
					if (!mArrowZipIndex.ContainsKey(arrowName))
					{
						mArrowZipIndex[arrowName] = new SortedList<int, int>();
					}
					int index = int.Parse(parsedName.Groups[2].Value);
					mArrowZipIndex[arrowName][index] = entry.ZipFileIndex;
				}
			}
			List<string> invalidArrows = new List<string>();
			foreach (KeyValuePair<string, SortedList<int, int>> kvp in mArrowZipIndex)
			{
				SortedList<int, int> images = kvp.Value;

				// Since this list is sorted and each key is unique, this checks that 
				// there exists one image for every index in the range [1,n]
				if (!(images.IndexOfKey(1) == 0 && images.IndexOfKey(images.Count) == images.Count - 1))
				{
					invalidArrows.Add(kvp.Key);
				}
			}
			foreach (string arrowName in invalidArrows)
			{
				mArrowZipIndex.Remove(arrowName);
			}

			mFontMeasure = Graphics.FromImage(mFontMeasureBitmap);
			UpdateFont();
		}
コード例 #7
0
ファイル: DungeonHud.cs プロジェクト: joshlatte/goarrow
		public DungeonHud(HudManager manager)
			: base(DefaultRegion, "Dungeon Map", manager)
		{

			mDungeonCachePath = Util.FullPath(@"Dungeon Map Cache\");
			if (!Directory.Exists(mDungeonCachePath))
			{
				Directory.CreateDirectory(mDungeonCachePath);
			}
			mDungeonListPath = mDungeonCachePath + "dungeons.txt";

			DownloadDungeonList(true);

			mMapDownloader = new WebClient();
			mMapDownloader.CachePolicy = new RequestCachePolicy(RequestCacheLevel.Revalidate);
			mMapDownloader.DownloadFileCompleted += new AsyncCompletedEventHandler(MapDownloader_DownloadFileCompleted);

			ClientVisibleChanged += new EventHandler(DungeonHud_ClientVisibleChanged);

			ClientMouseDown += new EventHandler<HudMouseEventArgs>(DungeonHud_ClientMouseDown);
			ClientMouseUp += new EventHandler<HudMouseEventArgs>(DungeonHud_ClientMouseUp);
			ClientMouseDrag += new EventHandler<HudMouseDragEventArgs>(DungeonHud_ClientMouseDrag);
			ClientMouseWheel += new EventHandler<HudMouseEventArgs>(DungeonHud_ClientMouseWheel);
			ClientMouseDoubleClick += new EventHandler<HudMouseEventArgs>(DungeonHud_ClientMouseDoubleClick);

			ResizeDrawMode = HudResizeDrawMode.Repaint;
			SetAlphaFading(255, 128);

			Heartbeat += new EventHandler(DungeonHud_Heartbeat);
		}
コード例 #8
0
ファイル: WindowHud.cs プロジェクト: joshlatte/goarrow
		/// <summary>Creates a new instance of a WindowHud.</summary>
		/// <param name="region">The size and location of the entire window, 
		///		including the title bar.</param>
		/// <param name="title">The title of the window.</param>
		/// <param name="manager">The manager for this window.</param>
		public WindowHud(Rectangle region, string title, HudManager manager)
		{
			mRegion = ConstrainRegion(region);
			mClientRegion = CalculateClientRegion(mRegion);

			mClientImage = new Bitmap(mClientRegion.Width, mClientRegion.Height);

			mTitle = title;
			mManager = manager;

			mFaderTimer = new DecalTimer();
			mFaderTimer.Timeout += new Decal.Interop.Input.ITimerEvents_TimeoutEventHandler(FaderTimer_Timeout);

			// For fading
			MouseEnter += new EventHandler<HudMouseEventArgs>(FadeIn);
			MouseLeave += new EventHandler<HudMouseEventArgs>(FadeOut);

			// This will call RecreateHud()
			Manager.RegisterHud(this, false);
		}