예제 #1
0
		public static void SetWindowPosition()
		{
			User32.RECT rect = new User32.RECT();

			User32.GetWindowRect(CoreManager.Current.Decal.Hwnd, ref rect);

			WindowPosition windowPosition = new WindowPosition(CoreManager.Current.CharacterFilter.Server, CoreManager.Current.CharacterFilter.AccountName, rect.Left, rect.Top);

			Settings.SettingsManager.Misc.SetWindowPosition(windowPosition);
		}
예제 #2
0
		void CharacterFilter_Login(object sender, Decal.Adapter.Wrappers.LoginEventArgs e)
		{
			try
			{
				WindowPosition windowPosition;

				if (GetWindowPositionForThisClient(out windowPosition))
				{
					User32.RECT rect = new User32.RECT();

					User32.GetWindowRect(CoreManager.Current.Decal.Hwnd, ref rect);

					User32.MoveWindow(CoreManager.Current.Decal.Hwnd, windowPosition.X, windowPosition.Y, rect.Right - rect.Left, rect.Bottom - rect.Top, true);
				}
			}
			catch (Exception ex) { Debug.LogException(ex); }
		}
예제 #3
0
		static void RemoveWindowFrame()
		{
			User32.RECT rect = new User32.RECT();

			User32.GetWindowRect(CoreManager.Current.Decal.Hwnd, ref rect);

			// 1686 1078 -> 1680 1050
			//Debug.WriteToChat((rect.Right - rect.Left) + " " + (rect.Bottom - rect.Top));

			const int GWL_STYLE = -16;
			const int WS_BORDER = 0x00800000; //window with border
			const int WS_DLGFRAME = 0x00400000; //window with double border but no title
			const int WS_CAPTION = WS_BORDER | WS_DLGFRAME; //window with a title bar

			int style = User32.GetWindowLong(CoreManager.Current.Decal.Hwnd, GWL_STYLE);

			User32.SetWindowLong(CoreManager.Current.Decal.Hwnd, GWL_STYLE, (style & ~WS_CAPTION));

			User32.MoveWindow(CoreManager.Current.Decal.Hwnd, rect.Left, rect.Top, (rect.Right - rect.Left) - TotalWindowFrameWidth, (rect.Bottom - rect.Top) - TotalWindowFrameHeight, true);
		}
예제 #4
0
		public bool ProcessMTCommand(string mtCommand)
		{
			string lower = mtCommand.ToLower();

			if (lower.StartsWith("/mt test"))
			{
				//DecalProxy.DispatchChatToBoxWithPluginIntercept("/vt start");
				//void Current_ChatBoxMessage(object sender, ChatTextInterceptEventArgs e)
				/*CoreManager.Current.ChatBoxMessage += new EventHandler<ChatTextInterceptEventArgs>(Current_ChatBoxMessage);
				if (CoreManager.Current.ChatBoxMessage != null)
				{ // or the event-name for field-like events
					// or your own event-type in place of EventHandler
					foreach (EventHandler subscriber in field.GetInvocationList())
					{
						// etc
					}
				}*/

				return true;
			}

			if (lower.StartsWith("/mt logoff") || lower.StartsWith("/mt logout"))
			{
				CoreManager.Current.Actions.Logout();
				return true;
			}

			if (lower.StartsWith("/mt send "))
			{
				if (lower.StartsWith("/mt send enter")) PostMessageTools.SendEnter();
				else if (lower.StartsWith("/mt send pause")) PostMessageTools.SendPause();
				else if (lower.StartsWith("/mt send space")) PostMessageTools.SendSpace();
				else if (lower.StartsWith("/mt send cntrl+") && lower.Length >= 16) PostMessageTools.SendCntrl(mtCommand[15]);
				else if (lower.StartsWith("/mt send f4")) PostMessageTools.SendF4();
				else if (lower.StartsWith("/mt send f12")) PostMessageTools.SendF12();
				else if (lower.StartsWith("/mt send msg ") && lower.Length > 13) PostMessageTools.SendMsg(mtCommand.Substring(13, mtCommand.Length - 13));
				else return false;

				return true;
			}

			if (lower.StartsWith("/mt click "))
			{
				if (lower.StartsWith("/mt click ok")) PostMessageTools.ClickOK();
				else if (lower.StartsWith("/mt click yes")) PostMessageTools.ClickYes();
				else if (lower.StartsWith("/mt click no")) PostMessageTools.ClickNo();
				else if (lower.StartsWith("/mt click "))
				{
					string[] splits = lower.Split(' ');

					if (splits.Length >= 4)
					{
						int x;
						int y;

						if (!int.TryParse(splits[2], out x)) return false;
						if (!int.TryParse(splits[3], out y)) return false;

						PostMessageTools.SendMouseClick(x, y);
					}
				}

				return true;
			}

			if (lower.StartsWith("/mt get xy"))
			{
				Point p;
				if (User32.GetCursorPos(out p))
				{
					User32.RECT rct = new User32.RECT();

					if (User32.GetWindowRect(CoreManager.Current.Decal.Hwnd, ref rct))
						Debug.WriteToChat("Current cursor position: " + (p.X - rct.Left) + "," + (p.Y - rct.Top));
				}

				return true;
			}

			if (lower.StartsWith("/mt face "))
			{
				if (lower.Length > 9)
				{
					int heading;
					if (!int.TryParse(lower.Substring(9, lower.Length - 9), out heading))
						return false;

					CoreManager.Current.Actions.FaceHeading(heading, true);
				}

				return true;
			}

			if (lower.StartsWith("/mt jump") || lower.StartsWith("/mt sjump"))
			{
				int msToHoldDown = 0;
				bool addShift = lower.Contains("sjump");
				bool addW = lower.Contains("jumpw");
				bool addZ = lower.Contains("jumpz");
				bool addX = lower.Contains("jumpx");
				bool addC = lower.Contains("jumpc");

				string[] split = lower.Split(' ');
				if (split.Length == 3)
					int.TryParse(split[2], out msToHoldDown);

				PostMessageTools.SendSpace(msToHoldDown, addShift, addW, addZ, addX, addC);

				return true;
			}

			if (lower.StartsWith("/mt fellow "))
			{
				if (lower.StartsWith("/mt fellow create ") && lower.Length > 18)
				{
					string fellowName = lower.Substring(18, lower.Length - 18);

					PostMessageTools.SendF12();
					PostMessageTools.SendF4();

					Rectangle rect = Core.Actions.UIElementRegion(UIElementType.Panels);

					PostMessageTools.SendMouseClick(rect.X + 200, rect.Y + 240);
					PostMessageTools.SendMsg(fellowName);

					CoreManager.Current.RenderFrame += new EventHandler<EventArgs>(FellowCreate_Current_RenderFrame);
				}
				else if (lower.StartsWith("/mt fellow open")) Core.Actions.FellowshipSetOpen(true);
				else if (lower.StartsWith("/mt fellow close")) Core.Actions.FellowshipSetOpen(false);
				else if (lower.StartsWith("/mt fellow disband")) Core.Actions.FellowshipDisband();
				else if (lower.StartsWith("/mt fellow quit")) Core.Actions.FellowshipQuit();
				else if (lower.StartsWith("/mt fellow recruit ") && lower.Length > 19)
				{
					string player = lower.Substring(19, lower.Length - 19);

					WorldObject closest = Util.GetClosestObject(player);

					try
					{
						if (closest != null)
							Core.Actions.FellowshipRecruit(closest.Id);
					}
					catch (AccessViolationException) { } // Eat the decal error
				}
				else return false;

				return true;
			}

			if ((lower.StartsWith("/mt cast ") && lower.Length > 9) || (lower.StartsWith("/mt castp ") && lower.Length > 10))
			{
				bool partialMatch = lower.StartsWith("/mt castp ");
				int offset = partialMatch ? 10 : 9;

				int spellId;
				int objectId = 0;

				string[] splits = lower.Split(' ');

				if (splits.Length < 3)
					return false;

				int.TryParse(splits[2], out spellId);

				string spellName;
				string targetName = null;

				if (!lower.Contains(" on "))
					spellName = lower.Substring(offset, lower.Length - offset);
				else
				{
					spellName = lower.Substring(offset, lower.IndexOf(" on ", StringComparison.Ordinal) - offset);
					targetName = lower.Substring(lower.IndexOf(" on ", StringComparison.Ordinal) + 4, lower.Length - (lower.IndexOf(" on ", StringComparison.Ordinal) + 4));
				}

				if (spellId == 0)
				{
					FileService service = CoreManager.Current.Filter<FileService>();

					for (int i = 0; i < service.SpellTable.Length; i++)
					{
						Spell spell = service.SpellTable[i];

						if (String.Equals(spellName, spell.Name, StringComparison.OrdinalIgnoreCase) || (partialMatch && spell.Name.ToLower().Contains(spellName.ToLower())))
						{
							spellId = spell.Id;
							break;
						}
					}

					if (spellId == 0) return false;
				}

				if (targetName != null)
				{
					objectId = FindIdForName(targetName, false, false, true, partialMatch);
					if (objectId == -1) return false;
				}

				CoreManager.Current.Actions.CastSpell(spellId, objectId);
				return true;
			}

			if ((lower.StartsWith("/mt select ") && lower.Length > 11) || (lower.StartsWith("/mt selectp ") && lower.Length > 12))
			{
				bool partialMatch = lower.StartsWith("/mt selectp ");
				int offset = partialMatch ? 12 : 11;

				int objectId = FindIdForName(lower.Substring(offset, lower.Length - offset), true, true, true, partialMatch);

				if (objectId == -1) return false;
				CoreManager.Current.Actions.SelectItem(objectId);
				return true;
			}

			if ((lower.StartsWith("/mt use ") && lower.Length > 8) || (lower.StartsWith("/mt usep ") && lower.Length > 9) ||
				(lower.StartsWith("/mt usei ") && lower.Length > 9) || (lower.StartsWith("/mt useip ") && lower.Length > 10) ||
				(lower.StartsWith("/mt usel ") && lower.Length > 9) || (lower.StartsWith("/mt uselp ") && lower.Length > 10))
			{
				bool partialMatch = lower.StartsWith("/mt usep ") || lower.StartsWith("/mt useip ") || lower.StartsWith("/mt uselp ");
				int offset = lower.StartsWith("/mt use ") || lower.StartsWith("/mt usep ") ? (partialMatch ? 9 : 8) : (partialMatch ? 10 : 9);

				bool searchInventory = !lower.StartsWith("/mt usel");
				bool searchLandscape = !lower.StartsWith("/mt usei");

				int objectId;
				int useMethod = 0;

				if (!lower.Contains(" on "))
				{
					if (lower.Contains("closestnpc"))
					{
						WorldObject wo = Util.GetClosestObject(ObjectClass.Npc);
						if (wo == null) return false;
						objectId = wo.Id;
					}
					else if (lower.Contains("closestvendor"))
					{
						WorldObject wo = Util.GetClosestObject(ObjectClass.Vendor);
						if (wo == null) return false;
						objectId = wo.Id;
					}
					else if (lower.Contains("closestportal"))
					{
						WorldObject wo = Util.GetClosestObject(ObjectClass.Portal);
						if (wo == null) return false;
						objectId = wo.Id;
					}
					else
						objectId = FindIdForName(lower.Substring(offset, lower.Length - offset), searchInventory, false, searchLandscape, partialMatch);
				}
				else
				{
					string command = lower.Substring(offset, lower.Length - offset);
					string first = command.Substring(0, command.IndexOf(" on ", StringComparison.Ordinal));
					string second = command.Substring(first.Length + 4, command.Length - first.Length - 4);

					objectId = FindIdForName(first, searchInventory, false, false, partialMatch);
					useMethod = FindIdForName(second, searchInventory, false, searchLandscape, partialMatch, objectId);
				}

				if (objectId == -1 || useMethod == -1)
					return false;

				if (useMethod == 0)
					CoreManager.Current.Actions.UseItem(objectId, 0);
				else
				{
					CoreManager.Current.Actions.SelectItem(useMethod);
					CoreManager.Current.Actions.UseItem(objectId, 1, useMethod);
				}

				return true;
			}

			if ((lower.StartsWith("/mt give ") && lower.Contains(" to ")) || (lower.StartsWith("/mt givep ") && lower.Contains(" to ")))
			{
				bool partialMatch = lower.StartsWith("/mt givep ");
				int offset = partialMatch ? 10 : 9;

				string command = lower.Substring(offset, lower.Length - offset);
				string first = command.Substring(0, command.IndexOf(" to ", StringComparison.Ordinal));
				string second = command.Substring(first.Length + 4, command.Length - first.Length - 4);

				int objectId = FindIdForName(first, true, false, false, partialMatch);
				int destinationId = FindIdForName(second, false, false, true, partialMatch);

				if (objectId == -1 || destinationId == -1) return false;
				CoreManager.Current.Actions.GiveItem(objectId, destinationId);
				return true;
			}

			if ((lower.StartsWith("/mt loot ") && lower.Length > 9) || (lower.StartsWith("/mt lootp ") && lower.Length > 10))
			{
				bool partialMatch = lower.StartsWith("/mt lootp ");
				int offset = partialMatch ? 10 : 9;

				int objectId = FindIdForName(lower.Substring(offset, lower.Length - offset), false, true, false, partialMatch);

				if (objectId == -1) return false;
				CoreManager.Current.Actions.UseItem(objectId, 0);
				return true;
			}

			if ((lower.StartsWith("/mt drop ") && lower.Length > 9) || (lower.StartsWith("/mt dropp ") && lower.Length > 10))
			{
				bool partialMatch = lower.StartsWith("/mt dropp ");
				int offset = partialMatch ? 10 : 9;

				int objectId = FindIdForName(lower.Substring(offset, lower.Length - offset), true, false, false, partialMatch);

				if (objectId == -1) return false;
				CoreManager.Current.Actions.DropItem(objectId);
				return true;
			}

			if (lower.StartsWith("/mt combatstate ") && lower.Length > 16)
			{
				string state = lower.Substring(16, lower.Length - 16);

				if (state == "magic") CoreManager.Current.Actions.SetCombatMode(CombatState.Magic);
				else if (state == "melee") CoreManager.Current.Actions.SetCombatMode(CombatState.Melee);
				else if (state == "missile") CoreManager.Current.Actions.SetCombatMode(CombatState.Missile);
				else if (state == "peace") CoreManager.Current.Actions.SetCombatMode(CombatState.Peace);
				else return false;
				return true;
			}

			if ((lower.StartsWith("/mt trade add ") && lower.Length > 14) || (lower.StartsWith("/mt trade addp ") && lower.Length > 15))
			{
				bool partialMatch = lower.StartsWith("/mt trade addp ");
				int offset = partialMatch ? 15 : 14;

				int objectId = FindIdForName(lower.Substring(offset, lower.Length - offset), true, false, false, partialMatch);

				if (objectId == -1) return false;
				CoreManager.Current.Actions.TradeAdd(objectId);
				return true;
			}
			if (lower.StartsWith("/mt trade accept")) { CoreManager.Current.Actions.TradeAccept(); return true; }
			if (lower.StartsWith("/mt trade decline")) { CoreManager.Current.Actions.TradeDecline(); return true; }
			if (lower.StartsWith("/mt trade reset")) { CoreManager.Current.Actions.TradeReset(); return true; }
			if (lower.StartsWith("/mt trade end")) { CoreManager.Current.Actions.TradeEnd(); return true; }

			if (CoreManager.Current.Actions.VendorId != 0)
			{
				if ((lower.StartsWith("/mt vendor addbuy ") && lower.Length > 18) || (lower.StartsWith("/mt vendor addbuyp ") && lower.Length > 19))
				{
					bool partialMatch = lower.StartsWith("/mt vendor addbuyp ");
					int offset = partialMatch ? 19 : 18;

					int count;
					string itemName = lower.Substring(offset, lower.Length - offset);
					var splits = itemName.Split(' ');
					if (splits.Length > 1 && int.TryParse(splits[splits.Length - 1], out count))
						itemName = itemName.Substring(0, itemName.LastIndexOf(' '));
					else
						count = 1;

					int objectId = FindIdForName(itemName, true, false, false, partialMatch);

					if (objectId == -1) return false;
					CoreManager.Current.Actions.VendorAddBuyList(objectId, count);
					return true;
				}
				if ((lower.StartsWith("/mt vendor addsell ") && lower.Length > 19) || (lower.StartsWith("/mt vendor addsellp ") && lower.Length > 20))
				{
					bool partialMatch = lower.StartsWith("/mt vendor addsellp ");
					int offset = partialMatch ? 20 : 19;

					int objectId = FindIdForName(lower.Substring(offset, lower.Length - offset), true, false, false, partialMatch);

					if (objectId == -1) return false;
					CoreManager.Current.Actions.VendorAddSellList(objectId);
					return true;
				}
				if (lower.StartsWith("/mt vendor buy")) { CoreManager.Current.Actions.VendorBuyAll(); return true; }
				if (lower.StartsWith("/mt vendor clearbuy")) { CoreManager.Current.Actions.VendorClearBuyList(); return true; }
				if (lower.StartsWith("/mt vendor sell")) { CoreManager.Current.Actions.VendorSellAll(); return true; }
				if (lower.StartsWith("/mt vendor clearsell")) { CoreManager.Current.Actions.VendorClearSellList(); return true; }
			}

			if (lower.StartsWith("/mt autopack") && inventoryPacker != null) { inventoryPacker.Start(); return true; }

			if (lower.StartsWith("/mt dumpspells")) { Util.ExportSpells(@"c:\mt spelldump.txt"); return true; }

			return false;
		}
예제 #5
0
    public static void ClickNo()
    {
      User32.RECT rect = new User32.RECT();

      User32.GetWindowRect(CoreManager.Current.Decal.Hwnd, ref rect);

      SendMouseClick(rect.Width / 2 + 80, rect.Height / 2 + 31);
    }
예제 #6
0
    public static void ClickYes()
    {
      User32.RECT rect = new User32.RECT();

      User32.GetWindowRect(CoreManager.Current.Decal.Hwnd, ref rect);

      // 800x600 +32 works, +33 does not work on single/double/tripple line boxes
      // 1600x1200 +31 works, +32 does not work on single/double/tripple line boxes
      SendMouseClick(rect.Width / 2 - 80, rect.Height / 2 + 31);
    }