Private Messaging by: Ltfxguy
// Add This under your IRC stuff ( in client.cpp)
_________________________________________________
//PM window
// irc
vector<string> MessageHistoryLines(40);
string MessageEditLine;
vector<string> MessageLines(100);
int PM_Active=0;
int currentMessageAlpha=0;
int MessageHistoryLinesSize = MessageHistoryLines.size();
int MessageHistoryLinesPos = 0;
______________________________________________________________
// Add This under you menu border stuff ( in client.cpp)
__________________________________________________
void messageBorder(int x,int y,int w, int h)
{
oglSubtractive = true;
gEngfuncs.pfnFillRGBA( x-6, y-6, w+12, 1 , 0, 0, 0, 255 );
gEngfuncs.pfnFillRGBA( x-6, y-6, 1, h+12 , 0, 0, 0, 255 );
gEngfuncs.pfnFillRGBA( x-6, y+h+5, w+12, 1 , 0, 0, 0, 255 );
gEngfuncs.pfnFillRGBA( x-1, y-1, w+2, 1 , 0, 0, 0, 255 );
gEngfuncs.pfnFillRGBA( x-1, y-1, 1, h+2 , 0, 0, 0, 255 );
gEngfuncs.pfnFillRGBA( x-1, y+h+1, w+2, 1 , 0, 0, 0, 255 );
gEngfuncs.pfnFillRGBA( x-2, y-2, w+4, 1 , 64, 64, 64, 255 );
gEngfuncs.pfnFillRGBA( x-2, y-2, 1, h+4 , 64, 64, 64, 255 );
gEngfuncs.pfnFillRGBA( x-5, y+h+4, w+10, 1 , 64, 64, 64, 255 );
gEngfuncs.pfnFillRGBA( x-4, y-4, w+8, 2 , 128, 128, 128, 255 );
gEngfuncs.pfnFillRGBA( x-4, y-4, 2, h+8 , 128, 128, 128, 255 );
gEngfuncs.pfnFillRGBA( x-4, y+h+2, w+8, 2 , 128, 128, 128, 255 );
oglSubtractive = false;
gEngfuncs.pfnFillRGBA( x-5, y-5, w+10, 1 , 255, 255, 255, 255 );
gEngfuncs.pfnFillRGBA( x-5, y-5, 1, h+10 , 255, 255, 255, 255 );
gEngfuncs.pfnFillRGBA( x-2, y+h+1, w+8, 1 , 255, 255, 255, 255 );
oglSubtractive = true;
gEngfuncs.pfnFillRGBA( x+w+6, y-6, 1, h+12 , 0, 0, 0, 255 );
gEngfuncs.pfnFillRGBA( x+w+1, y-1, 1, h+2 , 0, 0, 0, 255 );
gEngfuncs.pfnFillRGBA( x+w+2, y-2, 1, h+4 , 64, 64, 64, 255 );
gEngfuncs.pfnFillRGBA( x+w+3, y-4, 2, h+6 , 128, 128, 128, 255 );
oglSubtractive = false;
gEngfuncs.pfnFillRGBA( x+w+5, y-5, 1, h+10 , 255, 255, 255, 255 );
}
__________________________________________________________________________
// Add This under you IRC_echo stuff ( in client.cpp)
______________________________________________________
void PMMessage(const char *fmt, ... )
{
RF_TRY
va_list va_alist;
char buffer[256];
va_start (va_alist, fmt);
_vsnprintf (buffer, sizeof(buffer), fmt, va_alist);
va_end (va_alist);
// echo + scroll up:
PM_Echo(buffer);
RF_CATCH(
}
void PM_Echo(const char* message)
{
for(int i=MessageLines.size()-1;i>0;i--)
{
MessageLines=MessageLines[i-1];
}
MessageLines[0] = message;
}
____________________________________________________________________________
// Add this somewhere in HudDrawInfoTexts
_____________________________________________________________
if(cvar.messenger)
{
PM_Echo(" ][:Private Messages:][ ");
PM_Echo(" ");
PM_Echo(gHudMessage5[indexRedirect[0]]);
PM_Echo(gHudMessage5[indexRedirect[1]]);
PM_Echo(gHudMessage5[indexRedirect[2]]);
PM_Echo(gHudMessage5[indexRedirect[3]]);
}
_______________________________________________________________
// Then Register the cvar
_______________________________________________________________________________
// Next Add This under your IRC console code
__________________________________________________
//============== PM Window ===============
void drawMessage()
{
// background with alpha fade effect
ColorEntry messageBackground = *colorList.get(21);
ColorEntry messageBord = *colorList.get(21);
ColorEntry* c1 = colorList.get(21); // 33
ColorEntry* c2 = colorList.get(21); // 34
if( currentMessageAlpha != messageBackground.a )
{
for(int i=0;i<cvar.con_fadespeed;i++)
{
if(currentMessageAlpha>messageBackground.a) --currentMessageAlpha;
else ++currentMessageAlpha;
}
}
messageBackground.a = currentMessageAlpha;
//tintArea(cvar.con_x,cvar.con_y,cvar.con_w,cvar.con_h,&conBackground);
tintArea2(cvar.mes_x,cvar.mes_y,cvar.mes_w,cvar.mes_h,c1,c2);
messageBorder(cvar.mes_x,cvar.mes_y,cvar.mes_w,cvar.mes_h);
int mesx = cvar.mes_x+3;
int mesy = cvar.mes_y+cvar.mes_h-14;
string messageString = (("[PM] "+MessageEditLine));
if(blinkPhase){ messageString+="|"; }
ColorEntry* clr;
clr = colorList.get(20); // "con_edit"
gEngfuncs.pfnDrawSetTextColor(clr->onebased_r,clr->onebased_g,clr->onebased_b);
gEngfuncs.pfnDrawConsoleString(mesx,mesy,const_cast<char*>(messageString.c_str()));
int currentMessageLine=0;
for(;
{
mesy-=14;
if(mesy<cvar.mes_y) break;
string& curMessageLine = MessageLines[currentMessageLine];
if( curMessageLine[0]==']' ) clr = colorList.get(19); // "con_text2"
else clr = colorList.get(1; // "con_text"
gEngfuncs.pfnDrawSetTextColor(colorTags[curColorTag].onebased_r,
colorTags[curColorTag].onebased_g,
colorTags[curColorTag].onebased_b);
gEngfuncs.pfnDrawConsoleString(mesx,mesy,const_cast<char*>(curMessageLine.c_str()));
currentMessageLine++;
if(currentMessageLine>=MessageLines.size()) break;
}
//SCREENINFO m_scrinfo;
}
______________________________________________________
// REgister all the cvars and stuff
______________________________________
// Then Search For
_____________________________
if (IRC_Active) { drawIRC (); }
______________________________________________________________
// Right under that put this
________________________________________
if (PM_Active) { drawMessage (); }
________________________________________________________________________________________
// Then after you do that Look for you func_getmessages code // replace with this and you will have the MSN sound on
__________________________________________________________________________________________________________________________
void func_getmessages()
{
char* value;
for(int ax=1;ax<32;ax++)
{
if( cvar.pm_ignoreme && ax==me.ent->index ) ax++;
value = (char*)gEngfuncs.PlayerInfo_ValueForKey( ax, "osh" );
if( value!=NULL && value[0]!=0 && cvar.pm_sound==1)
{
cmd.exec("play sounds//pm.wav");
}
if( value!=NULL && value[0]!=0)
{
char message[64];
message[0] = 0;
strcat( message , vPlayers[ax].entinfo.name );
strcat( message , ": " );
strcat( message , value );
gSetHudMessage5(message);
}
}
}
______________________________________________________________________________________________
// then under your // void CB_KeyManager_IRCType(char ch) \\ code // add this\\
____________________________________________________________________________________
void CB_KeyManager_MessageType(char ch)
{
switch(ch)
{
case -1: // backspace
if(MessageEditLine.size()) { MessageEditLine.erase(MessageEditLine.size()-1); }
break;
case -2: // uparrow
MessageEditLine = MessageHistoryLines[MessageHistoryLinesPos];
MessageHistoryLinesPos--;
if(MessageHistoryLinesPos<0)MessageHistoryLinesPos = MessageHistoryLinesSize-1;
break;
case -3: // downarrow
MessageHistoryLinesPos++;
if(MessageHistoryLinesPos>=MessageHistoryLinesSize) MessageHistoryLinesPos = 0;
MessageEditLine = MessageHistoryLines[MessageHistoryLinesPos];
break;
case '\n':{
if(!MessageEditLine.empty())
{
string MessagescrollUpString = ("] "+MessageEditLine);
PM_Echo( MessagescrollUpString.c_str() );
cmd.exec(const_cast<char*>( MessageEditLine.c_str() ) );
// submit command to history
MessageHistoryLinesPos++;
if(MessageHistoryLinesPos>=MessageHistoryLinesSize) MessageHistoryLinesPos = 0;
MessageHistoryLines[MessageHistoryLinesPos] = MessageEditLine;
MessageEditLine.erase();
}
}break;
default:
MessageEditLine += ch;
break;
}
}
___________________________________________________________________________________________________________________________
// Then in the // keybindmanager.callback\\ stuff add this
__________________________________________________________________________________
keyBindManager.CallBack_MessageType = CB_KeyManager_MessageType;
__________________________________________________________________
// Then under your // void func_irc_toggle \\ code // add this
_____________________________________________________________________
void func_pm_toggle()
{
MessageEditLine.erase();
PM_Active=!PM_Active;
if(!PM_Active) currentMessageAlpha=0;
}
_________________________________________________________________________________________
// Then in the // cmd.AddCommand \\ stuff put this
___________________________________________________________
cmd.AddCommand("pm_toggle",func_pm_toggle);
___________________________________________________________________________________________________________________
//\\//\\//\\ Now You Are Done With The Client.cpp //\\//\\//\\ Time To Move on to the Bind.cpp and Bind.h //\\//\\//\\
// In the bind.cpp look for this code // void IRCMessage(const char *fmt, ... ); \\ add this code below
_________________________________________________________________________________________________________________
extern int PM_Active;
void PMMessage(const char *fmt, ... );
___________________________________________
// Then after you are done adding that ( look for) ..
__________________________________
if( IRC_Active && down )
{
if( !name[1] && name[0]!='~' ) return true; // alpha-numeric keys
if( getConsoleExtraCode(scancode) ) return true; // extra keys
}
_____________________________________________
// Right Underneagh that put this
_________________________________________________________
if( PM_Active && down )
{
if( !name[1] && name[0]!='~' ) return true; // alpha-numeric keys
if( getConsoleExtraCode(scancode) ) return true; // extra keys
}
__________________________________________________________________________
// Then Look for // if( IRC_Active && down) \\ again ( and under that code ) ) put this (
_____________________________________________________________________________________________________
if( PM_Active && down)
{
if( !keyname [1] && keyname [0]!='~' )
{
int code = keyname [0];
if( GetAsyncKeyState(VK_SHIFT) )
{
code = shiftRemap[code];
}
if(CallBack_MessageType) CallBack_MessageType(code);
return;
} else {
switch(scancode)
{
case 127: // backspace
if(CallBack_MessageType) CallBack_MessageType(-1);
return;
case 13: // enter
if(CallBack_MessageType) CallBack_MessageType('\n');
return;
case 32: // space
if(CallBack_MessageType) CallBack_MessageType(' ');
return;
case 128: // uparrow
if(CallBack_MessageType) CallBack_MessageType(-2);
return;
case 129: // downarrow
if(CallBack_MessageType) CallBack_MessageType(-3);
return;
case 47: // '/'
if(CallBack_MessageType) CallBack_MessageType('/');
}
}
}
__________________________________________________________________________________________
// You Are now done with the bind.cpp // now time for the bind.h \\ YOUR ALMOST DONE !!
__________________________________________________________________________________________________________
// Ok the bind.h , there is really not much to add , just a couple of identifyers
________________________________________________________________________________________
// Look for // typedef void (*CallBack_IRCTypeFunc)(char c); \\ and right under that put this
___________________________________________________________________________________________________
typedef void (*CallBack_MessageTypeFunc)(char c);
____________________________________________________
// Then a few lines down you should see the irctypefunc again \\ this time right under that put this
________________________________________________________________________________________________________
CallBack_MessageTypeFunc CallBack_MessageType;