void hrChatTextEntry(char *name, featom *atom) { char *string; ChatPacket temp; sdword width; fonthandle fhsave; char testwidth[MAX_CHATSTRING_LENGTH+40]; if (FEFIRSTCALL(atom)) { // initialize button here ChatTextEntryBox = (textentryhandle)atom->pData; uicTextEntryInit(ChatTextEntryBox,UICTE_NoLossOfFocus|UICTE_ChatTextEntry); uicTextBufferResize(ChatTextEntryBox,MAX_CHATSTRING_LENGTH-2); return; } switch (uicTextEntryMessage(atom)) { case CM_AcceptText : string = ((textentryhandle)atom->pData)->textBuffer; sendChatMessage(ALL_PLAYER_MASK^PLAYER_MASK(sigsPlayerIndex),string,(uword)sigsPlayerIndex); dbgMessagef("text entry: %s",string); strcpy(temp.message,string); temp.packetheader.frame = (uword)sigsPlayerIndex; hrProcessPacket((struct ChatPacket *)&temp); uicTextEntrySet(ChatTextEntryBox,"",0); break; case CM_KeyPressed : fhsave = fontMakeCurrent(((textentryhandle)atom->pData)->currentFont); //select the appropriate font sprintf(testwidth, "%s > %s", playerNames[sigsPlayerIndex], ((textentryhandle)atom->pData)->textBuffer); width = fontWidth(testwidth); fontMakeCurrent(fhsave); if (width > (atom->width-30)) { uicBackspaceCharacter((textentryhandle)atom->pData); } break; } }
/*----------------------------------------------------------------------------- Name : gpGameWindowInit Description : Inputs : Outputs : Return : ----------------------------------------------------------------------------*/ void gpGameWindowInit(char *name, featom *atom) { fonthandle oldfont; sdword index; if (FEFIRSTCALL(atom)) { if (strcmp(name,"FE_RecordedGameWindowInit") == 0) { SavedGamesPath = RecordedGamesPath; } else if (strcmp(name,"FE_TutorialGameWindowInit") == 0) { SavedGamesPath = TutorialSavedGamesPath; tutorial = TUTORIAL_ONLY; gpLoadTutorial = TRUE; gpLoadSinglePlayerGame = TRUE; } else { if (gameIsRunning) { if (singlePlayerGame) { gpLoadSinglePlayerGame = TRUE; } else { gpLoadSinglePlayerGame = FALSE; } gpLoadTutorial = (tutorial==TUTORIAL_ONLY) ? TRUE : FALSE; } else { if (mgRunning) { gpLoadSinglePlayerGame = FALSE; } else { gpLoadSinglePlayerGame = TRUE; } gpLoadTutorial = (tutorial==TUTORIAL_ONLY) ? TRUE : FALSE; } if (gpLoadSinglePlayerGame) { SavedGamesPath = gpLoadTutorial ? TutorialSavedGamesPath : SinglePlayerSavedGamesPath; } else { SavedGamesPath = MultiPlayerSavedGamesPath; } } gpTitleListLoad(); oldfont = fontMakeCurrent(gpListFont); gpGameListWindow = (listwindowhandle)atom->pData; uicListWindowInit(gpGameListWindow, NULL, // title draw, no title NULL, // title click process, no title 0, // title height, no title gpGameItemDraw, // item draw function fontHeight(" ")+GP_VertSpacing, // item height UICLW_CanSelect|UICLW_CanHaveFocus); for (index = 0; index < gpNumberGames; index++) { if (index == 0) { uicListAddItem(gpGameListWindow, (ubyte *)&gpGames[index], UICLI_CanSelect|UICLI_Selected, UICLW_AddToTail); gpCurrentSelected = 0; } else { uicListAddItem(gpGameListWindow, (ubyte *)&gpGames[index], UICLI_CanSelect, UICLW_AddToTail); } } fontMakeCurrent(oldfont); return; } else if (FELASTCALL(atom)) { gpGameListWindow = NULL; return; } else if (gpGameListWindow->message == CM_NewItemSelected) { if (gpNameEntryBox != NULL) { uicTextEntrySet(gpNameEntryBox, ((gpgame *)gpGameListWindow->CurLineSelected->data)->title,strlen(((gpgame *)gpGameListWindow->CurLineSelected->data)->title)); } } }
/*----------------------------------------------------------------------------- Name : gcInGameChatEntry Description : Handles the chat text entry box messages. Inputs : Outputs : Return : void ----------------------------------------------------------------------------*/ void gcInGameChatEntry(char *name, featom *atom) { sdword user; chathistory *chat; char temp[60]; sdword ruentered; if (MessageToAllies == GC_RUTransfer) { if (FEFIRSTCALL(atom)) { chatentrybox = (textentryhandle)atom->pData; uicTextEntryInit(chatentrybox,UICTE_NoTextures|UICTE_ChatTextEntry|UICTE_NumberEntry); bitSet(chatentrybox->reg.status, RSF_KeyCapture); keyBufferClear(); bitSet(chatentrybox->textflags, UICTE_DropShadow); chatentrybox->shadowColor = colBlack; uicTextBufferResize(chatentrybox,GC_MAXCHARACTERS); return; } switch (uicTextEntryMessage(atom)) { case CM_AcceptText : { ruentered = atol(chatentrybox->textBuffer); //sendRUTransfer((udword)PLAYER_MASK(RUTransferToPlayer), ruentered); clWrapRUTransfer(&universe.mainCommandLayer,sigsPlayerIndex,RUTransferToPlayer, ruentered,0); //universe.players[sigsPlayerIndex].resourceUnits-=ruentered; InChatMode = FALSE; feScreenDisappear(NULL,NULL); } break; case CM_RejectText : { InChatMode = FALSE; feScreenDisappear(NULL,NULL); } break; case CM_KeyPressed: { ruentered = atol(chatentrybox->textBuffer); if (ruentered > universe.players[sigsPlayerIndex].resourceUnits || ruentered <= 0) { //backspace if ru's entered are more than player has, or if they're less than or equal to 0 uicBackspaceCharacter(chatentrybox); } } break; } } else { if (FEFIRSTCALL(atom)) { chatentrybox = (textentryhandle)atom->pData; uicTextEntryInit(chatentrybox,UICTE_NoTextures|UICTE_ChatTextEntry); bitSet(chatentrybox->reg.status, RSF_KeyCapture); keyBufferClear(); bitSet(chatentrybox->textflags, UICTE_DropShadow); chatentrybox->shadowColor = colBlack; uicTextBufferResize(chatentrybox,GC_MAXCHARACTERS); return; } switch (uicTextEntryMessage(atom)) { case CM_AcceptText : chat = (chathistory *)memAlloc(sizeof(chathistory),"InGameChat",NonVolatile); if (MessageToAllies==GC_ChatToAllies) { sendChatMessage(universe.players[sigsPlayerIndex].Allies,chatentrybox->textBuffer,(uword)sigsPlayerIndex); strcpy(chat->chatstring, chatentrybox->textBuffer); chat->messageType = GC_WHISPEREDMESSAGE; } else { if ((user=gcParseChatEntry(chatentrybox->textBuffer))!=-1) { if (user!=sigsPlayerIndex) { sendChatMessage(PLAYER_MASK(user),chatentrybox->textBuffer+strlen(playerNames[user])+2,(uword)sigsPlayerIndex); strcpy(chat->chatstring, chatentrybox->textBuffer+strlen(playerNames[user])+2); chat->messageType = GC_WHISPEREDMESSAGE; #ifdef DEBUG_STOMP regVerify(chatdrawregion); #endif bitSet(chatdrawregion->status,RSF_DrawThisFrame); } } else { sendChatMessage(OTHER_PLAYERS_MASK,chatentrybox->textBuffer,(uword)sigsPlayerIndex); strcpy(chat->chatstring, chatentrybox->textBuffer+strlen(playerNames[user])); chat->messageType = GC_NORMALMESSAGE; #ifdef DEBUG_STOMP regVerify(chatdrawregion); #endif bitSet(chatdrawregion->status,RSF_DrawThisFrame); } } strcpy(chat->userName, utyName); chat->playerindex = sigsPlayerIndex; gcAddChatItemToList(chat); uicTextEntrySet(chatentrybox,"",0); InChatMode = FALSE; feScreenDisappear(NULL,NULL); break; case CM_RejectText : InChatMode = FALSE; feScreenDisappear(NULL,NULL); break; case CM_KeyPressed: { if ((user=gcParseChatEntry(chatentrybox->textBuffer))!=-1) { sprintf(temp, "/%s ", playerNames[user]); if (strlen(chatentrybox->textBuffer) < strlen(temp)) uicTextEntrySet(chatentrybox, temp, strlen(temp)); } } break; } } }