I made a plugin out of popup modifications pms originally posted on the mq2 forums
I shortened the commands to /pc and /pcecho, and included a color list in help syntax output. This allows you to do text overlay popups in various colors and durations.
I shortened the commands to /pc and /pcecho, and included a color list in help syntax output. This allows you to do text overlay popups in various colors and durations.
Rich (BB code):
// MQ2CustomPopup.cpp : Defines the entry point for the DLL application.
// Original code from pms
// Modified to standalone plugin form, shortened commands, and added color list - Sym 4/1/2012
// MQ2CustomPopup v1.0
#include "../MQ2Plugin.h"
void CustomPopup(char* szPopText, bool bPopOutput);
void PopupTextCustom(PSPAWNINFO pChar, char* szLine);
void PopupTextEcho(PSPAWNINFO pChar, char* szLine);
PreSetup("MQ2CustomPopup");
// Called once, when the plugin is to initialize
PLUGIN_API VOID InitializePlugin(VOID)
{
DebugSpewAlways("Initializing MQ2CustomPopup");
//Add commands, MQ2Data items, hooks, etc.
AddCommand("/pc",PopupTextCustom);
AddCommand("/pcecho",PopupTextEcho);
}
// Called once, when the plugin is to shutdown
PLUGIN_API VOID ShutdownPlugin(VOID)
{
DebugSpewAlways("Shutting down MQ2CustomPopup");
//Remove commands, MQ2Data items, hooks, etc.
RemoveCommand("/pc");
RemoveCommand("/pcecho");
}
// /pc
void PopupTextCustom(PSPAWNINFO pChar, char* szLine)
{
CustomPopup(szLine, false);
}
// /pcecho
void PopupTextEcho(PSPAWNINFO pChar, char* szLine)
{
CustomPopup(szLine, true);
}
void CustomDisplayOverlayText(PCHAR szText, DWORD dwColor, DWORD dwTransparency, DWORD msFadeIn, DWORD msFadeOut, DWORD msHold)
{
if (!pTextOverlay) {
WriteChatColor(szText,dwColor);
return;
}
DWORD dwAlpha = (DWORD)(dwTransparency*255/100);
if (dwAlpha>255) dwAlpha=255;
pTextOverlay->DisplayText(
szText,
dwColor,
10, // Always 10 in eqgame.exe,
// Doesn't seem to affect anything
// (tried 0,1,10,20,100,500)
dwAlpha,
msFadeIn,
msFadeOut,
msHold);
}
void CustomPopup(char* szPopText, bool bPopOutput)
{
int iArgNum = 1;
int iMsgColor = CONCOLOR_LIGHTBLUE;
int iMsgTime = 3000;
char szCurArg[MAX_STRING] = {0};
char szPopupMsg[MAX_STRING] = {0};
char szErrorCust[MAX_STRING] = "\awUsage: /pc [\agcolor\ax] [\agdisplaytime\ax(in seconds)] [\agmessage\ax]";
char szErrorEcho[MAX_STRING] = "\awUsage: /pcecho [\agcolor\ax] [\agdisplaytime\ax(in seconds)] [\agmessage\ax]";
GetArg(szCurArg, szPopText, iArgNum++);
if (!*szCurArg)
{
if (bPopOutput)
{
WriteChatf(szErrorEcho);
}
else
{
WriteChatf(szErrorCust);
}
WriteChatColor("Colors are:");
WriteChatColor("1: Dark Gray", COLOR_DARKGREY);
WriteChatColor("2: Light Green", CONCOLOR_GREEN);
WriteChatColor("4: Dark Blue", CONCOLOR_BLUE);
WriteChatColor("5: Purple", COLOR_PURPLE);
WriteChatColor("6: Light Gray", CONCOLOR_GREY);
WriteChatColor("10: White", CONCOLOR_WHITE);
WriteChatColor("13: Red", CONCOLOR_RED);
WriteChatf("\ag14: Bright Green\ax");
WriteChatColor("15: Yellow", CONCOLOR_YELLOW);
WriteChatColor("18: Cyan", CONCOLOR_LIGHTBLUE);
WriteChatColor("20: Black", COLOR_DEFAULT);
return;
}
else
{
if(isdigit(szCurArg[0]))
{
iMsgColor = atoi(szCurArg);
GetArg(szCurArg, szPopText, iArgNum++);
if(isdigit(szCurArg[0]))
{
iMsgTime = atoi(szCurArg) * 1000;
sprintf(szPopupMsg, "%s", GetNextArg(szPopText, 2, FALSE, 0));
}
else
{
sprintf(szPopupMsg, "%s", GetNextArg(szPopText, 1, FALSE, 0));
}
}
else
{
strcpy(szPopupMsg, szPopText);
}
}
CustomDisplayOverlayText(szPopupMsg, iMsgColor, 100, 500, 500, iMsgTime);
if (bPopOutput) WriteChatf("\ayPopup\aw:: %s", szPopupMsg);
}

