Page 1 of 8

How about people start making custom UI's for MQ?

Posted: Fri Nov 07, 2003 10:44 pm
by Plazmic
We need to get a standard on what Label EQType's are used for what.
And we need a new section of the readme.txt detailing these...
New forum for UIs: http://macroquest2.com/phpBB2/viewforum.php?f=27


UI file usage: If you don't know how to create a Label, learn or ask someone that does.. Current EQType's are in source or at http://macroquest2.com/phpBB2/viewtopic.php?t=3879


Offset (load from INI):
DWORD EQADDR_EQLABELS
GetLabelFromEQ=004F903B

Function below, add HookLabels(TRUE) with the rest of the HookXXX(TRUE); do the same for FALSE.

Code: Select all

// *************************************************************************** 
// Function:    GetLabelFromEQ_Detour 
// Description: Our UI label Hook 
// *************************************************************************** 
struct _ID_PMP
	{ DWORD ID;PCHAR PMP; }
Id_PMP[] = {
	// 1000-1999: $char() 
      {1000,   "$char(mana,cur)"}, 
      {1001,   "$char(mana,max)"}, 
      {1002,   "$char(state)"}, 
     {1003,   "$char(speed)"}, 
     {1004,   "$char(heading)"}, 
     {1005,   "$char(x)"}, 
     {1006,   "$char(y)"}, 
     {1007,   "$char(z)"}, 
     {1008,   "$char(dar)"}, 
     {1009,   "$char(cash)"}, 
     {1010,   "$char(cash,bank)"}, 
     {1011,   "$char(plat,bank)"}, 
     {1012,   "$char(plat,shared)"}, 
     {1013,   "$char(gold,bank)"}, 
     {1014,   "$char(silver,bank)"}, 
     {1015,   "$char(copper,bank)"}, 

      // 2000-2999: $target() 
      {2000,   "$target(level)"}, 
      {2001,   "$target(class)"}, 
      {2002,   "$target(race)"}, 
      {2003,   "$target(distance)"}, 
      {2004,   "$target(lastattacked)"}, 
      {2005,   "$target(state)"}, 
     {2006,   "$target(x)"}, 
     {2007,   "$target(y)"}, 
     {2008,   "$target(z)"}, 
     {2009,   "$target(heading)"}, 
     {2010,   "$target(speed)"}, 

      // 3000-3999: misc 
      {3000,   "$zone()"}, 
      {3001,   "$zone(zem)"}, 
      {3002,   "$zone(bound)"}, 
     {3003,   "$time()"}, 
     {3004,   "$time(h)"}, 
     {3005,   "$time(m)"}, 
     {3006,   "$time(s)"}, 
     {3007,   "$date()"}, 
     {3008,   "$date(y)"}, 
     {3009,   "$date(m)"}, 
     {3010,   "$date(d)"}, 
     {3011,   "$gm"}, 
     {3012,   "$freeinv(space)"},

	 // 9999: custom (ToolTipReference)
	  {9999,   "BrokenParser" },

	{-1,NULL}
};

class CLabel {
public:
	VOID Draw_Trampoline(VOID);
	VOID Draw_Detour(VOID)
	{
		PCSIDLWND pThisLabel = NULL;
		__asm mov [pThisLabel], ecx;
		Draw_Trampoline();

		CHAR Buffer[MAX_STRING] = {0};
		BOOL Found=FALSE;
		DWORD index;

		if (pThisLabel->SlotID==9999) {
			if (!pThisLabel->XMLToolTip) {
				strcpy(Buffer,"BadCustom");
				Found=TRUE;
			} else {
				strcpy(Buffer,&pThisLabel->XMLToolTip->Text[0]);
				ParseMacroParameter((*EQADDR_CHAR_INFO)->pSpawn,Buffer);
				Found=TRUE;
			}
		} else if (pThisLabel->SlotID>114) {
			for (index=0;Id_PMP[index].ID>0 && !Found;index++) {
				if (Id_PMP[index].ID==pThisLabel->SlotID) {
					strcpy(Buffer,Id_PMP[index].PMP);
					ParseMacroParameter((*EQADDR_CHAR_INFO)->pSpawn,Buffer);
					Found=TRUE;
				}
			}
		}
		if (Found) SetCXStr(&(pThisLabel->WindowText),Buffer);
	}
};


...


// ***************************************************************************
// Function:    HookLabels
// Description: Hook UI labels
// ***************************************************************************
DETOUR_TRAMPOLINE_EMPTY(VOID CLabel::Draw_Trampoline(VOID));

VOID HookLabels(BOOL Patch)
{
   FunctionEntry("HookLabels()");
   void (CLabel::*pfDetour)(VOID) = CLabel::Draw_Detour;
   void (CLabel::*pfTrampoline)(VOID) = CLabel::Draw_Trampoline;

   DebugSpewAlways("HookLabels - %satching",(Patch)?"P":"Unp");
   if (Patch) {
      AddOurDetour(EQADDR_EQLABELS);

      DetourFunctionWithEmptyTrampoline(*(PBYTE*)&pfTrampoline,
         (PBYTE)EQADDR_EQLABELS,
         *(PBYTE*)&pfDetour);
   } else {
      DetourRemove(*(PBYTE*)&pfTrampoline,
         *(PBYTE*)&pfDetour);
   }

   FunctionExit("HookLabels()");
}

Posted: Fri Nov 07, 2003 11:09 pm
by Lax
Velly nife 8)

Posted: Fri Nov 07, 2003 11:11 pm
by Plazmic
This thing was a bitch to get working... do all work before the EQ call or optimizations WILL fuck it up...
(and I found away around phpBB2 cuss filter ;)

Posted: Fri Nov 07, 2003 11:20 pm
by Lax
Going to CVS this in with minor changes

Posted: Fri Nov 07, 2003 11:30 pm
by MacroFiend
Converting the curse words to HTML ASCII equiv?

BTW, the UI label addition rocks.

Posted: Fri Nov 07, 2003 11:49 pm
by Lax
CVS and ZIP updated, lets see this get going :)
Definitions of labels/etc are in eqlib.h please look at it

Posted: Fri Nov 07, 2003 11:55 pm
by Teh_ish
I'll get to work on converting the appropriate stuff into the detours case statement.

Posted: Sat Nov 08, 2003 12:03 am
by MacroFiend
Possible enhancement to this ...

What if the elements were dynamic? i.e.
In MacroQuest.ini

Code: Select all

[UI Labels]
1000=$char(mana,cur)
1001=$char(mana,max)

2000=$target(level)
2001=$target(class)
2002=$target(race)
2003=$target(distance)
2004=$target(lasthit)
Since the labels already defined are macroparser commands, this might not be too hard to do ... but I could be wrong.

It's an idea for easy expansion/customization.

Posted: Sat Nov 08, 2003 12:11 am
by Teh_ish
I would recommend against that, honestly. Break it off into a seperate header file with #defines. But there really should be a standard that everyone uses.. Just my opinion.

*thump self*

Posted: Sat Nov 08, 2003 12:34 am
by Lax
Yeah I was going to plop the defines in another header file but adding files to solutions/projects/makefiles/whatever is a pita ;)

Posted: Sat Nov 08, 2003 12:45 am
by Teh_ish
I've gone ahead and done that. I'll post a diff file for all this stuff once I finish making additions.

Preliminary List:
Character
DAR
x-y-z
heading
speed
cash,bank
plat,shared
plat/gold/gold/copper,bank

Target
x-y-z
heading
speed
state
type


Misc
Zone: ZEM
Zone: Bound
Time: Full, h-m-s
Date: Full, d-m-y

Posted: Sat Nov 08, 2003 1:03 am
by Plazmic
The original code was more proof of concept ;)
I like the PMP idea...

Posted: Sat Nov 08, 2003 1:16 am
by Teh_ish
Good point. That's probably less of a pain then going in and writing case statements for everything we want. Saves me mucho typing :P

I'll toss the rest of it in and post a diff file. Very sexy stuff

Posted: Sat Nov 08, 2003 1:37 am
by Plazmic
First UI test post was moved to the new forum

Posted: Sat Nov 08, 2003 1:51 am
by Lax
Next order of business is see if we can make our own xml type that uses strings instead of numbers, so we can just parse the string directly with PMP...