home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Revista CD Expert 51
/
PCGamer51_17Demos.iso
/
games
/
CM
/
CyclingManagerDemoCangas.exe
/
CyclingManagerDemo
/
scripts
/
inrace
/
panel_inrace_chat.cnc
< prev
next >
Wrap
Text File
|
2001-07-05
|
9KB
|
329 lines
// Check box State func
func void Chat_TeamCheckbox (i32x _iComponentID,i32x _iState)
{
if(_iState & GUI_State_Enabled)
{
if(_iState & GUI_State_Checked)
SetContainerSprite(_iComponentID, 1, 0);
else
SetContainerSprite(_iComponentID, 0, 0);
}
else
{
SetContainerSprite(_iComponentID, 0, 0);
}
if(_iState & GUI_State_UnderMouse)
{
if(strcmp(GetContainerText(oPanelInraceChat.iHelp),oPanelInraceChat.szTeamHelp[GetContainerHelpIndex(_iComponentID)]) !=0 )
SetContainerText(oPanelInraceChat.iHelp,oPanelInraceChat.szTeamHelp[GetContainerHelpIndex(_iComponentID)]);
}
else
{
if(!strcmp(GetContainerText(oPanelInraceChat.iHelp),oPanelInraceChat.szTeamHelp[GetContainerHelpIndex(_iComponentID)]) )
{
SetContainerText(oPanelInraceChat.iHelp,"");
}
}
}
//panel inrace chat
func void Panel_Inrace_Chat_Create()
{
SetComponentNumber(56);
var i32x iID,bUser,boucle,iPosY,iPosX,iTeamID,iUserID;
var szx szTmp;
// Save context
oPanelInraceChat.pThis=GetParserComponent();
// Chat background
iID=Init_LibObject_FilledCadre(tCadreDialbox,500,300);
SetEvents(iID,GUI_NoEvent);
boucle=0;
iPosX = 15;
iPosY = 45;
iID = InitContainer(tFontArialItalique);
SetEvents(iID,GUI_NoEvent);
SetContainerText(iID,"");
SetComponentPosition(iID,5,235);
SetComponentSize(iID,430,16);
oPanelInraceChat.iHelp=iID;
//crΘation de la liste de toutes les Θquipes
while (boucle<20)
{
// TeamID ?
iTeamID = Join_GetIntFromSortedIndex(g_stInraceJoins.m_jTeam_iId,boucle);
// Team help string
iUserID = Join_GetIntFromKey(g_oMenuJoins.m_iTeam_iUserID,iTeamID);
if(iUserID > 0)
{
// Is user connected ?
if(Join_GetIntFromKey(g_oMenuJoins.m_jUser_iConnected,iUserID)==1)
{
// User connected
szTmp = Join_GetStringFromKey(g_oMenuJoins.m_jUser_szPseudo,iUserID);
szTmp = strcat("[",szTmp);
szTmp = strcat(szTmp,"]");
bUser = true;
oPanelInraceChat.szTeamHelp[boucle] = strcat(szTmp,Join_GetStringFromKey(g_oMenuJoins.m_iTeamName,iTeamID));
}
else
{
// User not connected
bUser = false;
oPanelInraceChat.szTeamHelp[boucle] = Join_GetStringFromKey(g_oMenuJoins.m_iTeamName,iTeamID);
}
}
else
{
// CPU team
bUser = false;
oPanelInraceChat.szTeamHelp[boucle] = Join_GetStringFromKey(g_oMenuJoins.m_iTeamName,iTeamID);
}
// Checkbox
iID=InitCheckBox(tBtnChat);
SetContainerStateFunc(iID,Chat_TeamCheckbox);
SetContainerHelpIndex(iID,boucle);
SetComponentPosition(iID,iPosX,iPosY);
oPanelInraceChat.iTeamButton[boucle]=iID;
SetContainerSize(iID,20,15);
SetEvents(iID,GetEvents(iID) | GUI_MouseDblClick);
SetStackEvents(iID,GUI_MouseDblClick);
SetCheckboxState(iID,1);
// team name
iID=InitContainer(tFontArial);
SetComponentPosition(iID,iPosX+20,iPosY);
SetContainerText(iID,Join_GetStringFromSortedIndex(g_stInraceJoins.m_jTeam_szAbrev,boucle));
SetContainerScale(iID,0.90,0.90);
oPanelInraceChat.iTeamName[boucle]=iID;
SetEvents(iID,GetEvents(iID) | GUI_MouseDblClick);
SetStackEvents(iID,GUI_MouseDblClick);
ResizeComponent(iID);
if(bUser)
SetContainerColor(iID,c_Red);
else
SetContainerColor(iID,c_White);
boucle=boucle+1;
if((boucle%3)==0)
{
iPosX = iPosX + 65;
iPosY = 45;
}
else
{
iPosY = iPosY + 15;
}
}
//set player team active
SetCheckboxState(oPanelInraceChat.iTeamButton[g_oUser.m_iMyInRaceTeamID],1);
// Slider background
iID=InitContainer(tCommonTableBorder);
SetContainerColor(iID,c_TitleList);
SetContainerSize(iID,20,98);
SetComponentPosition(iID,430-20,105);
//crΘation de la fenΩtre de chat
oPanelInraceChat.iChatWindow=InitList(
"Chat List", // List name
oPanelInraceChat.iMaxListItems, // Max item number
425,98, // Width, height
Chat_List_Item_Create,Chat_List_Item_Update,Chat_List_Item_Event, // Item oFunc
t_btn_slider, // Slider texture
NullButtonState); // State func for the slider
SetComponentPosition(oPanelInraceChat.iChatWindow,5,105);
// Border line
// Horizontal line
iID = InitContainer(tCommonTableBorder);
SetContainerSize(iID,425,1);
SetComponentPosition(iID,5,105);
iID = InitContainer(tCommonTableBorder);
SetContainerSize(iID,425,1);
SetComponentPosition(iID,5,105+98);
// Vertical line
iID = InitContainer(tCommonTableBorder);
SetContainerSize(iID,1,98);
SetComponentPosition(iID,5,105);
iID = InitContainer(tCommonTableBorder);
SetContainerSize(iID,1,98);
SetComponentPosition(iID,430-20,105);
iID = InitContainer(tCommonTableBorder);
SetContainerSize(iID,1,98);
SetComponentPosition(iID,430,105);
//crΘation de la ligne de commande
// background
iID = InitContainer(t_Common_Color_White);
SetContainerColor(iID,c_ListSelection);
SetContainerSize(iID,430,16);
SetComponentPosition(iID,5,215);
iID = InitEditBox(tFontArial,196);
SetContainerText(iID,"");
SetComponentPosition(iID,5,215);
SetComponentSize(iID,430,16);
oPanelInraceChat.iCommandLine=iID;
SetListNbItems(oPanelInraceChat.iChatWindow,oPanelInraceChat.iNbListItems);
SetSelectedComponent(oPanelInraceChat.iCommandLine);
SetObjectSize(450,230);
}
func void Panel_Inrace_Chat_InitMembers ()
{
oPanelInraceChat.iMaxListItems = 50;
oPanelInraceChat.iNbListItems = 0;
oPanelInraceChat.iCursor = 0;
oPanelInraceChat.oFunc.pcreate=Panel_Inrace_Chat_Create;
oPanelInraceChat.oFunc.pevent=Panel_Inrace_Chat_Event;
}
//ajout d'un message α la liste de tous les messages
func void Panel_Inrace_Chat_Update(szx szText)
{
if (oPanelInraceChat.iMaxListItems==0)
{
Panel_Inrace_Chat_InitMembers ();
}
oPanelInraceChat.szChatTab[oPanelInraceChat.iCursor] = szText;
oPanelInraceChat.iChatJustified[oPanelInraceChat.iCursor] = 0;
oPanelInraceChat.iCursor = oPanelInraceChat.iCursor + 1;
oPanelInraceChat.iCursor = oPanelInraceChat.iCursor%oPanelInraceChat.iMaxListItems;
if (oPanelInraceChat.iNbListItems<oPanelInraceChat.iMaxListItems)
{
oPanelInraceChat.iNbListItems=oPanelInraceChat.iNbListItems+1;
}
//update the list if the chat window is open
if(oRace.iChatWindow != ID_NOT_CREATED)
{
var component pold;
if(oPanelInraceChat.pThis != g_poNullComponent)
{
// Save current contex
pold=GetParserComponent();
// Set Chat window context
SetParserComponent(oPanelInraceChat.pThis);
// Update list
SetListNbItems(oPanelInraceChat.iChatWindow,oPanelInraceChat.iNbListItems);
SetListPosition(oPanelInraceChat.iChatWindow,oPanelInraceChat.iNbListItems-1);
//restore context
SetParserComponent(pold);
}
}
// Send chat event
oRaceChat.m_iNeedUpdate = true;
}
func i32x Panel_Inrace_Chat_Event(i32x _iComponentID, i32x _iEvent)
{
var i32x boucle,iBitField,iFlag;
if(_iEvent==GUI_COMPONENT_MOUSE_LDBLCLICK)
{
boucle=0;
while(boucle<20)
{
if(_iComponentID==oPanelInraceChat.iTeamName[boucle]|| _iComponentID==oPanelInraceChat.iTeamButton[boucle])
{
iFlag = GetCheckboxState(oPanelInraceChat.iTeamButton[boucle]);
}
boucle=boucle+1;
}
boucle=0;
while(boucle<20)
{
SetCheckboxState(oPanelInraceChat.iTeamButton[boucle],iFlag);
boucle=boucle+1;
}
}
if(_iEvent == GUI_EDITBOX_VALID )
{
if (strcmp(GetContainerText(oPanelInraceChat.iCommandLine),""))
{
iBitField=0;
boucle=0;
while(boucle<20)
{
iBitField=SetBit(iBitField,boucle,GetCheckboxState(oPanelInraceChat.iTeamButton[boucle]));
boucle=boucle+1;
}
g_oMenuServer.m_oServer << mGame_Chat(iBitField,GetContainerText(oPanelInraceChat.iCommandLine));
SetContainerText(oPanelInraceChat.iCommandLine,"");
}
}
if(_iEvent==GUI_COMPONENT_MOUSE_LDOWN)
{
boucle=0;
while(boucle<20)
{
if(_iComponentID==oPanelInraceChat.iTeamName[boucle])
{
if (GetCheckboxState(oPanelInraceChat.iTeamButton[boucle]))
SetCheckboxState(oPanelInraceChat.iTeamButton[boucle],0);
else
SetCheckboxState(oPanelInraceChat.iTeamButton[boucle],1);
}
boucle=boucle+1;
}
}
if(_iComponentID==-1)
{
if(_iEvent == GUI_COMPONENT_DESTRUCTOR)
{
oPanelInraceChat.pThis = g_poNullComponent;
}
}
return 1;
}
//----------------------------------------------------------------------------------------------------------------//
//----------------------------------------------------------------------------------------------------------------//
//SendChat func function called from the menuserver
//----------------------------------------------------------------------------------------------------------------//
//----------------------------------------------------------------------------------------------------------------//
func void CSendChat_Null(i32x _iTeamID,szx _szMessage)
{
}
func void CSendChat(i32x _iTeamID,szx _szMessage)
{
var szx szMsg;
szMsg=strcat("[",Join_GetStringFromSortedIndex(g_stInraceJoins.m_jTeam_szAbrev,_iTeamID));
szMsg=strcat(szMsg,"] ");
szMsg=strcat(szMsg,_szMessage);
Panel_Inrace_Chat_Update(szMsg);
}