• You've discovered RedGuides, an EverQuest multi-boxing and scripting community 🧙‍♀️⚙️. We want you to play several EQ characters at once, come join us and say hello! 👋

  • A TLP without truebox has thawed (Very Vanilla ready)
    Frostreaver
Resource icon

Release MQ2Notepad

Cosmic

New member
Joined
Jun 21, 2005
RedCents
30¢
Someone requested a plugin that let you edit macros from within EQ ala the Notes window. I think this will fit the bill.

Zipped versions of the source+xml and dll+xml are attached for those averse to cut-n-paste.


Rich (BB code):
// MQ2Notepad.cpp : Defines the entry point for the DLL application.
//
//
// MQ2Notepad by Cosmic
// First release 10/20/2005
//
// known bugs:
// 1: Lines limited to 999 characters
// 2: Filesize limited to 64k
// 3: Path limited to 299 characters
// 4: exceeding any of these causes things to go boom
// 5: couldn't make horizontal scrollbars work, so words wrap. its annoying.
//
//
// Usage: (Don't forget to put the MQUI_NotepadWindow.xml in your UI directory
// /notepad dir - display current working directory
// /notepad dir <directoryname> - set current working directory
// /notepad <filename> - open file for editing
//


#include "../MQ2Plugin.h"


PreSetup("MQ2Notepad");

void SaveFile();

#define CWS_PASSWORDCHAR						0x20000
#define CWS_WANTRETURN							0x40000

class CNotepadWnd : public CCustomWnd 
{ 
public: 
   CNotepadWnd():CCustomWnd("NotepadWindow") 
   { 
      SaveButton = (CButtonWnd*)GetChildItem("NPWSave");               //Save Button 
	  NoteBox = (CTextEntryWnd*)GetChildItem("NPWInput");
	  NoteBox->WindowStyle|=CWS_WANTRETURN; 
      SetWndNotification(CNotepadWnd); 
   } 
    
   ~CNotepadWnd() 
   { 
   } 

   int WndNotification(CXWnd *pWnd, unsigned int Message, void *unknown) 
   {    
       //Save Button 
      if (pWnd==(CXWnd*)SaveButton) 
      { 
         if (Message==XWM_LCLICK) 
		 {
            SaveFile(); 
		 }
         else 
            DebugSpew("SaveButton message %Xh / %d",Message,Message); 
      } 
      return CSidlScreenWnd::WndNotification(pWnd,Message,unknown); 
   }; 
   CButtonWnd *SaveButton; 
   CTextEntryWnd *NoteBox;

}; 
CNotepadWnd *MyWnd = 0;

char Directory[1000]={0};
char FileName[1000]={0};

void ReadWindowINI(PCSIDLWND pWindow) 
{ 
   CHAR Buffer[MAX_STRING] = {0}; 
   pWindow->Location.top      = GetPrivateProfileInt("Settings","ChatTop",      357,INIFileName); 
   pWindow->Location.bottom   = GetPrivateProfileInt("Settings","ChatBottom",      620,INIFileName); 
   pWindow->Location.left      = GetPrivateProfileInt("Settings","ChatLeft",      164,INIFileName); 
   pWindow->Location.right    = GetPrivateProfileInt("Settings","ChatRight",      375,INIFileName); 
   pWindow->Locked             = GetPrivateProfileInt("Settings","Locked",         0,INIFileName); 
   pWindow->Fades             = GetPrivateProfileInt("Settings","Fades",         1,INIFileName); 
   pWindow->TimeMouseOver       = GetPrivateProfileInt("Settings","Delay",         2000,INIFileName); 
   pWindow->FadeDuration       = GetPrivateProfileInt("Settings","Duration",      500,INIFileName); 
   pWindow->Alpha            = GetPrivateProfileInt("Settings","Alpha",         255,INIFileName); 
   pWindow->FadeToAlpha      = GetPrivateProfileInt("Settings","FadeToAlpha",   255,INIFileName); 
   pWindow->BGType            = GetPrivateProfileInt("Settings","BGType",         1,INIFileName); 
   pWindow->BGColor.R         = GetPrivateProfileInt("Settings","BGTint.red",      255,INIFileName); 
   pWindow->BGColor.G         = GetPrivateProfileInt("Settings","BGTint.green",   255,INIFileName); 
   pWindow->BGColor.B         = GetPrivateProfileInt("Settings","BGTint.blue",   255,INIFileName); 
   GetPrivateProfileString("Settings","Directory","c:",Directory,999,INIFileName);
} 

void WriteWindowINI(PCSIDLWND pWindow) 
{ 
   CHAR szTemp[MAX_STRING] = {0}; 
   if (pWindow->Minimized) 
   { 
      WritePrivateProfileString("Settings","ChatTop",      itoa(pWindow->OldLocation.top,      szTemp,10),INIFileName); 
      WritePrivateProfileString("Settings","ChatBottom",   itoa(pWindow->OldLocation.bottom,   szTemp,10),INIFileName); 
      WritePrivateProfileString("Settings","ChatLeft",   itoa(pWindow->OldLocation.left,      szTemp,10),INIFileName); 
      WritePrivateProfileString("Settings","ChatRight",   itoa(pWindow->OldLocation.right,   szTemp,10),INIFileName); 
   } 
   else 
   { 
      WritePrivateProfileString("Settings","ChatTop",      itoa(pWindow->Location.top,         szTemp,10),INIFileName); 
      WritePrivateProfileString("Settings","ChatBottom",   itoa(pWindow->Location.bottom,      szTemp,10),INIFileName); 
      WritePrivateProfileString("Settings","ChatLeft",   itoa(pWindow->Location.left,      szTemp,10),INIFileName); 
      WritePrivateProfileString("Settings","ChatRight",   itoa(pWindow->Location.right,      szTemp,10),INIFileName); 
   } 
   WritePrivateProfileString("Settings","Locked",      itoa(pWindow->Locked,         szTemp,10),INIFileName); 

   WritePrivateProfileString("Settings","Fades",      itoa(pWindow->Fades,            szTemp,10),INIFileName); 
   WritePrivateProfileString("Settings","Delay",      itoa(pWindow->MouseOver,         szTemp,10),INIFileName); 
   WritePrivateProfileString("Settings","Duration",   itoa(pWindow->FadeDuration,         szTemp,10),INIFileName); 
   WritePrivateProfileString("Settings","Alpha",      itoa(pWindow->Alpha,            szTemp,10),INIFileName); 
   WritePrivateProfileString("Settings","FadeToAlpha",   itoa(pWindow->FadeToAlpha,         szTemp,10),INIFileName); 
   WritePrivateProfileString("Settings","BGType",      itoa(pWindow->BGType,            szTemp,10),INIFileName); 
   WritePrivateProfileString("Settings","BGTint.red",   itoa(pWindow->BGColor.R,         szTemp,10),INIFileName); 
   WritePrivateProfileString("Settings","BGTint.green",   itoa(pWindow->BGColor.G,      szTemp,10),INIFileName); 
   WritePrivateProfileString("Settings","BGTint.blue",   itoa(pWindow->BGColor.B,         szTemp,10),INIFileName); 
   WritePrivateProfileString("Settings","Directory",Directory,INIFileName); 
} 

void StartEditor()
{
	// Destroy old window
    if (MyWnd) 
    { 
        delete MyWnd; 
        MyWnd=0; 
    } 

	char s[300]={0};
	char filename[300];
	sprintf(filename,"%s\\%s",Directory,FileName);

	FILE *f;
	f=fopen(filename,"r");
	if (f==NULL)
	{
		sprintf(s,"Notepad: File not found (%s)",filename);
		WriteChatColor(s,CONCOLOR_RED); 
		return;
	}

	//Build Window
	DebugTry(CScreenPieceTemplate *templ=pSidlMgr->FindScreenPieceTemplate("NotepadWindow")); 
    if (templ) 
	    MyWnd = new CNotepadWnd; 
	else
		return; //God forbid
    ReadWindowINI((PCSIDLWND) MyWnd); 
	sprintf(s,"Notepad - '%s'",FileName);
	SetCXStr(&(((PCSIDLWND)MyWnd)->WindowText),s);

	//Load File
	char buff[64000]={0};
	char line[1000]={0};
	while (!feof(f))
	{
		if (fgets(line,999,f)!=NULL)
			strcat(buff,line);
	}
	fclose(f);
	// strip tabs
	for (unsigned int i=0;i<strlen(buff);i++) if (buff=='\t') buff=' ';
	SetCXStr(&(PCXSTR)MyWnd->NoteBox->InputText,buff);

}

void SaveFile()
{
	char filename[300];
	sprintf(filename,"%s\\%s",Directory,FileName);
	char buff[64000]={0};
	GetCXStr((PCXSTR)MyWnd->NoteBox->InputText,buff,63999);
	FILE *f;
	f=fopen(filename,"w");
	if (f==NULL)
	{
		char s[300]={0};
		sprintf(s,"Notepad: Write Error (%s)",filename);
		WriteChatColor(s,CONCOLOR_RED); 
		return;
	}
	fputs(buff,f);
	fclose(f);
}

void Usage(void) 
{ 
   char str[MAX_STRING] = {0}; 
   WriteChatColor("Sytax: /notepad <filename> - edit a file",USERCOLOR_DEFAULT); 
   WriteChatColor("Sytax: /notepad dir <directory name> - set the directory",USERCOLOR_DEFAULT); 
} 

void Notepad(PSPAWNINFO pChar, PCHAR szLine)
{
   char Arg1[MAX_STRING] = {0}; 
   char Arg2[MAX_STRING] = {0}; 
    
   GetArg(Arg1,szLine,1); 
   GetArg(Arg2,szLine,2); 

   if (stricmp(Arg1,"dir")==0)
   {
	   if (strlen(Arg2)>0)
	   {
		   strcpy(Directory,Arg2);
		   WritePrivateProfileString("Settings","Directory",Directory,INIFileName); 
	   }
	   else
	   {
		   char s[300]={0};
		   GetPrivateProfileString("Settings","Directory","c:",Directory,999,INIFileName);
		   sprintf(s,"Notepad: Current Directory '%s'",Directory);
		   WriteChatColor(s,USERCOLOR_DEFAULT);
	   }
	   return;
   }
	if (strlen(Arg1)>0)
	{
		GetPrivateProfileString("Settings","Directory","c:",Directory,999,INIFileName);
		sprintf(FileName,"%s",Arg1);
		StartEditor();
	}
   else
	   Usage();

}

// Called once, when the plugin is to initialize
PLUGIN_API VOID InitializePlugin(VOID)
{
	DebugSpewAlways("Initializing MQ2Notepad");

	// Add commands, MQ2Data items, hooks, etc.
	AddCommand("/notepad",Notepad);
	AddXMLFile("MQUI_NotepadWindow.xml");
	// bmMyBenchmark=AddMQ2Benchmark("My Benchmark Name");
}

// Called once, when the plugin is to shutdown
PLUGIN_API VOID ShutdownPlugin(VOID)
{
	DebugSpewAlways("Shutting down MQ2Notepad");

	if (MyWnd) 
	{ 
		WriteWindowINI((PCSIDLWND)MyWnd); 
		delete MyWnd; 
		MyWnd=0; 
	} 
	// Remove commands, MQ2Data items, hooks, etc.
	// RemoveMQ2Benchmark(bmMyBenchmark);
	RemoveCommand("/notepad");
	RemoveXMLFile("MQUI_NotepadWindow.xml");
}

// Called once directly before shutdown of the new ui system, and also
// every time the game calls CDisplay::CleanGameUI()
PLUGIN_API VOID OnCleanUI(VOID)
{
	DebugSpewAlways("MQ2Notepad::OnCleanUI()");
	// destroy custom windows, etc
   if (MyWnd) 
   { 
      WriteWindowINI((PCSIDLWND)MyWnd); 
      delete MyWnd; 
      MyWnd=0; 
   } 
}


and the UI file:
Rich (BB code):
<?xml version = "1.0"?>
<XML ID = "EQInterfaceDefinitionLanguage">
	<Schema xmlns = "EverQuestData" xmlns:dt = "EverQuestDataTypes"/>

	<Editbox item = "NPWInput">
		<ScreenID>NPWInput</ScreenID>
		<DrawTemplate>WDT_Inner</DrawTemplate>
		<Style_Transparent>false</Style_Transparent>
		<Style_VScroll>true</Style_VScroll>
		<RelativePosition>true</RelativePosition>
		<AutoStretch>true</AutoStretch>
		<LeftAnchorOffset>2</LeftAnchorOffset>
		<TopAnchorOffset>2</TopAnchorOffset>
		<RightAnchorOffset>2</RightAnchorOffset>
		<BottomAnchorOffset>30</BottomAnchorOffset>
		<TopAnchorToTop>true</TopAnchorToTop>
		<RightAnchorToLeft>false</RightAnchorToLeft>
		<BottomAnchorToTop>false</BottomAnchorToTop>
		<TextColor>
			<R>255</R>
			<G>255</G>
			<B>255</B>
		</TextColor>
		<Style_Border>true</Style_Border>
		<Style_Multiline>true</Style_Multiline>
	</Editbox>

	<Button item = "NPWSave">
		<ScreenID>NPWSave</ScreenID>
		<!--<Font>3</Font>-->
		<RelativePosition>true</RelativePosition>
		<AutoStretch>true</AutoStretch>
		<LeftAnchorOffset>68</LeftAnchorOffset>
		<TopAnchorOffset>26</TopAnchorOffset>
		<RightAnchorOffset>4</RightAnchorOffset>
		<BottomAnchorOffset>2</BottomAnchorOffset>
		<TopAnchorToTop>false</TopAnchorToTop>
		<BottomAnchorToTop>false</BottomAnchorToTop>
		<LeftAnchorToLeft>false</LeftAnchorToLeft>
		<RightAnchorToLeft>false</RightAnchorToLeft>
		<Style_Transparent>false</Style_Transparent>
		<TooltipReference>Save this file</TooltipReference>
		<Style_Checkbox>false</Style_Checkbox>
		<Text>Save</Text>
		<TextColor>
				<R>255</R>
				<G>255</G>
				<B>255</B>
		</TextColor>
		<ButtonDrawTemplate>
			<Normal>A_SmallBtnNormal</Normal>
			<Pressed>A_SmallBtnPressed</Pressed>
			<Flyby>A_SmallBtnFlyby</Flyby>
			<Disabled>A_SmallBtnDisabled</Disabled>
			<PressedFlyby>A_SmallBtnPressedFlyby</PressedFlyby>
		</ButtonDrawTemplate>
	</Button>
	
	<Screen item = "NotepadWindow">
		<RelativePosition>false</RelativePosition>
		<Location>
			<X>95</X>
			<Y>280</Y>
		</Location>
		<Size>
			<CX>421</CX>
			<CY>200</CY>
		</Size>
		<Style_VScroll>false</Style_VScroll>
		<Style_HScroll>false</Style_HScroll>
		<Style_Transparent>false</Style_Transparent>
		<DrawTemplate>WDT_Def2</DrawTemplate>
		<Style_Titlebar>true</Style_Titlebar>
		<Style_Closebox>true</Style_Closebox>
		<Style_Minimizebox>true</Style_Minimizebox>
		<Style_Border>true</Style_Border>
		<Style_Sizable>true</Style_Sizable>
		<Pieces>NPWInput</Pieces>
		<Pieces>NPWSave</Pieces>
	</Screen>

</XML>
 
Forgot to mention:

This will clobber any tabs in your file and replace them with a single space.

sorry.
 
Agreed. Only thing I'd worry about is using 3rd party XML's. Wherever that thing was read from, assuming it's not a joke, I'm really wary of putting anything in my XML folder since it's pretty easily looked over by SoE.

If you don't mind me stealing your code a bit Cosmic (provided I give you credit for pretty much writing the whole thing) I'm going to try and make this work using the actual /note window.
 
Its not a 3rd party XML...its my xml. Its trivial as well.

If you wanted to use the /note window, you could, but you would have to make the "save" button a command line option instead.

If you really want this feature, I'd prefer that you let me do it instead of building a competing plugin. Let me know how important it is to you. No need to have two versions.

-piggy
 
It wouldn't be competing but I understand. I'll remove it from my list of stuff I'm working on.
 
Not a bad idea here I'll give it a try :P If you can increase the Limit on lines and stuff, aswell as horizontal bars that would be the wins :P
 
To the best of my knowledge EQ doesn't actually support horizontal scrolling. I think there is only 1 UI file that has it turned on but I don't think it actually works in that file...I'll recheck tho.

As far as line limits, the goal was to be able to edit macros...you really have a macro that has lines 1000+ characters long or larger than 64k? Jeebus! even the AFKCleric is only 54K.

I'll see what I can do. I'll post another version by the end of the weekend that doesn't require an XML file and supports larger files (provided EQ supports it...Not much I can do if EQ doesn't support it).

-piggy
 
We have revived and updated an old plugin MQ2Notepad.
Thanks Sym for your help.
This plugin is a very simple in game file editor for small macro or ini files in your macro folder.

To use MQ2notepad
1. Copy MQUI_NotepadWindow.xml to your Everquest/uifiles/default or custom ui folder. - This file is included in the current compile in the Release/UIFiles folder.
2. /Plugin MQ2Notepad - This plugin is included in the current compile.

Commands
Rich (BB code):
/notepad <filename> - open file for editing
KissAsisist will be using this plugin in ver 4.5.4 so you can edit your kiss ini file in game. If you load the plugin you can edit the file currently by making a hotkey.

Rich (BB code):
/notepad kissassist_${Me}.ini
 
Last edited by a moderator:
We have revived and updated an old plugin MQ2Notepad.
Thanks Sym for your help.
This plugin is a very simple in game file editor for small macro or ini files in your macro folder.

To use MQ2notepad
1. Copy MQUI_NotepadWindow.xml to your Everquest/uifiles/default or custom ui folder. - This file is included in the current compile in the Release/UIFiles folder.
2. /Plugin MQ2Notepad - This plugin is included in the current compile.

Commands
Rich (BB code):
/notepad <filename> - open file for editing
KissAsisist will be using this plugin in ver 4.5.4 so you can edit your kiss ini file in game. If you load the plugin you can edit the file currently by making a hotkey.

Rich (BB code):
/notepad kissassist_${Me}.ini
 
What could make /notepad not work? I"ve got it working fine on 2 of my comps but it won't work on a 3rd. Its loaded and I've got it set to the macro folder, but when I use the same command I use to edit my INI's on my other computers, nothing happens, no error msg it just doesn't display.
 
Did you put the ui xml file saved in you e EQ ui folder?

1. Copy MQUI_NotepadWindow.xml to your Everquest/uifiles/default or custom ui folder. - This file is included in the current compile in the Release/UIFiles folder.
 
The changes I am making in my Ini file through mq2notepad are not being saved when I close the notepad. What could I be doing wrong
 
Are you hitting the save button?

Check the file properties make sure it not read only
 
File is not read only. When I click save I am getting "Write Error" and the file location, which is correct.
 
Are you running MQ2 as admin?

Can you please post the full error message.
 
Yes I am running as admin. Even trying to change the .ini normally is now giving me the message that I cannot make changes because the file is being used by another process
 
here make you a hot key
/plugin mq2notepad unload
/plugin mq2notepad load
/loadskin yourui yourui= whatever your normal ui skin folder is like if you use default or if you use vert or whatever name, then that should fix it , this has been acting up for me for years but i guess im pretty much alone or its un fixable.
the reason you are getting that messege is your kiss ini is open in one of the processes of eq but you cant see it,
check to be sure you have the mq2Notepad.ini file is pointing to correct directory my example below.

[Settings]
ChatTop=150
ChatBottom=850
ChatLeft=1213
ChatRight=1913
Locked=0
Fades=1
Delay=2000
Duration=500
Alpha=255
FadeToAlpha=255
BGType=1
BGTint.alpha=255
BGTint.red=255
BGTint.green=255
BGTint.blue=255
Directory=C:\Release\Macros
 
Has this been updated for use with the new MacroQuest? or is there a step I need to do to make it work now?
 
Looks like it was added to Next about 6 months ago
I was running Next prior to Macroquest going live... it hasn't worked since. Wondering if something didn't populate across like maybe the UI file? it does show loaded if i try to reload, UI window doesn't show though. Even double checked the MQ Settings under plugins (same place as Easyfind) and didn't see there either.
 
Looks like it was added to Next about 6 months ago
What folder is the UI file suppose to be in for next?
It probably just got disconnected where it needs to look for the file.
 
Last edited:
Yeah, I looked, xml was just missing from the repo. Fixed now.
Sorry for delayed response getting back to this. I did find what was wrong... migrator from Legacy to NEXT didn't move the UIFiles to the NEXT UIFiles or at least not all of them, for me NEXT\resources\uifiles it was missing from. So just copied from the original UIfile to this one, unloaded, reloaded, and load UIskin and was back in business.
 
Update to last, it is working kind of, unfortunately it's the wrong file. The file I am seeing with /notepad is actually the original prior to migrating to NEXT. Not expecting anything quickly with this as I know you have hands full with the other issues going on. I am using the correct command... /notepad kissassist_${Me}.ini
 
On a quick look, that's going to be your directory setting in the ini. Open up the ini file and the line:
INI:
[Settings]
Directory=C:\MacroQuest\Config

Or use /notepad dir to change it
 
On a quick look, that's going to be your directory setting in the ini. Open up the ini file and the line:
BINGO, that worked, apparently when migrated from Old to NEXT it didn't update the directory link in the INI. Just with quick look it looks to be good, will know late tonight or tomorrow... It's FLUFFY time :dance:
 
Release MQ2Notepad

Users who are viewing this thread

Back
Top
Cart