📄 ui_comms.cpp
字号:
gametype=game->GetGameType();
switch(gametype)
{
case game_Dogfight:
CheckFlyButton();
theTree=DogfightGames;
break;
case game_TacticalEngagement:
GetPlayerInfo(q->SessionID);
TallyPlayerSquadrons();
theTree=TacticalGames;
break;
case game_Campaign:
GetPlayerInfo(q->SessionID);
TallyPlayerSquadrons();
theTree=CampaignGames;
break;
default:
theTree=NULL;
}
if(theTree)
{
// Add to Game's Window List
gamelist=StartTreeSearch(game->Id(),theTree->GetRoot(),theTree);
if(gamelist)
{
player=StartTreeSearch(session->Id(),gamelist,theTree);
if(player == NULL)
{
player=CreatePlayerButton(theTree,session);
theTree->AddChildItem(gamelist,player);
theTree->RecalcSize();
if(theTree->GetParent())
theTree->GetParent()->RefreshClient(theTree->GetClient());
}
}
/*
if(game == gCommsMgr->GetGame())
{
// Add to gCommsMgr game lists (if selected)
AddPlayerToGame(session);
}
*/
}
}
break;
case _Q_SESSION_REMOVE_:
UpdateLocalGameTree();
RemoveFromTree(DogfightGames,q->SessionID);
RemoveFromTree(TacticalGames,q->SessionID);
RemoveFromTree(CampaignGames,q->SessionID);
// Remove player from gCommsMgr game lists (if selected)
game=(FalconGameEntity*)gCommsMgr->GetGame();
if(game)
{
// if(game->Id() == q->GameID)
// RemovePlayerFromGame(q->SessionID);
if(game->GetGameType() == game_Campaign || game->GetGameType() == game_TacticalEngagement)
TallyPlayerSquadrons();
// else if(game->GetGameType() == game_Dogfight)
// {
// CheckFlyButton();
// }
}
break;
case _Q_SESSION_UPDATE_:
session=(FalconSessionEntity*)vuDatabase->Find(q->SessionID);
if(session)
{
CheckChatFilters(session);
if(gCommsMgr->GetGame() != vuPlayerPoolGroup)
{
if(gCommsMgr->GetGame())
{
if(gCommsMgr->GetGame()->Id() == q->GameID)
{
CheckForNewPlayer(session);
CheckPlayersFlight(session);
}
}
}
}
break;
}
q=gUICommsQ->Remove();
}
}
static void PeopleSelectCB(long,short hittype,C_Base *)
{
TREELIST *item;
C_Player *player;
if(hittype != C_TYPE_LMOUSEUP || !People)
return;
item=People->GetLastItem();
if(item->Type_ != C_TYPE_ITEM)
return;
player=(C_Player*)item->Item_;
if(!player)
return;
player->SetState(static_cast<short>(player->GetState()^1));
player->Refresh();
}
static void SelectChatFilterCB(long,short hittype,C_Base *control)
{
VuSessionsIterator sessionWalker(FalconLocalGame);
FalconSessionEntity *session;
if(hittype != C_TYPE_LMOUSEUP)
return;
PeopleChatType=static_cast<short>(control->GetCluster()); // 1=All,2=team,3=package,4=flight
session = (FalconSessionEntity*)sessionWalker.GetFirst();
while(session)
{
CheckChatFilters(session);
session = (FalconSessionEntity*)sessionWalker.GetNext();
}
}
void UI_Refresh (void)
{
if (!FalconLocalGame || !gCommsMgr || !gMainHandler)
return;
// Do UI Notification stuff
switch (FalconLocalGame->GetGameType())
{
case game_Dogfight:
PostMessage(FalconDisplay.appWin,FM_REFRESH_DOGFIGHT,0,0);
break;
case game_TacticalEngagement:
PostMessage(FalconDisplay.appWin,FM_REFRESH_TACTICAL,0,0);
break;
case game_Campaign:
PostMessage(FalconDisplay.appWin,FM_REFRESH_CAMPAIGN,0,0);
break;
default:
break;
}
}
void ViewRemoteLogbook(long playerID)
{
F4CSECTIONHANDLE *Leave;
C_Window *win;
RemoteLB *remlb;
IMAGE_RSC *pic,*pat;
win=gMainHandler->FindWindow(LOG_WIN);
if(win)
{
Leave=UI_Enter(win);
remlb=(RemoteLB*)gCommsMgr->GetRemoteLB(playerID);
if(remlb)
{
if(remlb->Pilot_.PictureResource)
{
pic=gImageMgr->GetImage(remlb->Pilot_.PictureResource);
}
else
{
pic=NULL;
}
if(remlb->Pilot_.PatchResource)
{
pat=gImageMgr->GetImage(remlb->Pilot_.PatchResource);
}
else
{
pat=NULL;
}
DisplayLogbook(&remlb->Pilot_,pic,pat,FALSE);
gMainHandler->ShowWindow(win);
gMainHandler->WindowToFront(win);
}
UI_Leave(Leave);
}
}
void SendTextToFlight()
{
VuSessionsIterator sessionWalker(FalconLocalGame);
FalconSessionEntity *session;
UI_SendChatMessage *chat;
session = (FalconSessionEntity*)sessionWalker.GetFirst();
while(session)
{
if(session->GetPlayerFlightID() == FalconLocalSession->GetPlayerFlightID())
{
chat=new UI_SendChatMessage(FalconNullId,session);
chat->dataBlock.from=FalconLocalSessionId;
chat->dataBlock.size=static_cast<short>((strlen(chatterStr)+1)*sizeof(char));
chat->dataBlock.message=new char[chat->dataBlock.size];
memcpy(chat->dataBlock.message,chatterStr,chat->dataBlock.size);
FalconSendMessage(chat,TRUE);
}
session = (FalconSessionEntity*)sessionWalker.GetNext();
}
}
void SendTextToPackage()
{
Flight flt;
Package pkg;
VU_ID MyPackageID;
VuSessionsIterator sessionWalker(FalconLocalGame);
FalconSessionEntity *session;
UI_SendChatMessage *chat;
flt=(Flight)vuDatabase->Find(FalconLocalSession->GetPlayerFlightID());
if(!flt)
return;
pkg=(Package)flt->GetUnitParent();
if(!pkg)
return;
MyPackageID=pkg->Id();
session = (FalconSessionEntity*)sessionWalker.GetFirst();
while(session)
{
flt=(Flight)vuDatabase->Find(session->GetPlayerFlightID());
if(flt)
{
pkg=(Package)flt->GetUnitParent();
if(pkg && pkg->Id() == MyPackageID)
{
chat=new UI_SendChatMessage(FalconNullId,session);
chat->dataBlock.from=FalconLocalSessionId;
chat->dataBlock.size=static_cast<short>((strlen(chatterStr)+1)*sizeof(char));
chat->dataBlock.message=new char[chat->dataBlock.size];
memcpy(chat->dataBlock.message,chatterStr,chat->dataBlock.size);
FalconSendMessage(chat,TRUE);
}
}
session = (FalconSessionEntity*)sessionWalker.GetNext();
}
}
void SendTextToRange()
{
VuSessionsIterator sessionWalker(FalconLocalGame);
FalconSessionEntity *session;
UI_SendChatMessage *chat;
float myx,sx,myy,sy,dx,dy,dist;
VuEntity *ent;
ent=FalconLocalSession->GetPlayerEntity();
if(!ent)
return;
myx=ent->XPos();
myy=ent->YPos();
session = (FalconSessionEntity*)sessionWalker.GetFirst();
while(session)
{
ent=session->GetPlayerEntity();
if(ent)
{
sx=ent->XPos();
sy=ent->YPos();
dx=myx-sx;
dy=myy-sy;
dist=static_cast<float>(sqrt(dx*dx+dy*dy) * FT_TO_NM);
if(dist <= 40.0f)
{
chat=new UI_SendChatMessage(FalconNullId,session);
chat->dataBlock.from=FalconLocalSessionId;
chat->dataBlock.size=static_cast<short>((strlen(chatterStr)+1)*sizeof(char));
chat->dataBlock.message=new char[chat->dataBlock.size];
memcpy(chat->dataBlock.message,chatterStr,chat->dataBlock.size);
FalconSendMessage(chat,TRUE);
}
}
session = (FalconSessionEntity*)sessionWalker.GetNext();
}
}
void SendTextToTeam()
{
VuSessionsIterator sessionWalker(FalconLocalGame);
FalconSessionEntity *session;
UI_SendChatMessage *chat;
session = (FalconSessionEntity*)sessionWalker.GetFirst();
while(session)
{
if(session->GetTeam() == FalconLocalSession->GetTeam())
{
chat=new UI_SendChatMessage(FalconNullId,session);
chat->dataBlock.from=FalconLocalSessionId;
chat->dataBlock.size=static_cast<short>((strlen(chatterStr)+1)*sizeof(char));
chat->dataBlock.message=new char[chat->dataBlock.size];
memcpy(chat->dataBlock.message,chatterStr,chat->dataBlock.size);
FalconSendMessage(chat,TRUE);
}
session = (FalconSessionEntity*)sessionWalker.GetNext();
}
}
void SendTextToEveryOne()
{
VuSessionsIterator sessionWalker(FalconLocalGame);
FalconSessionEntity *session;
UI_SendChatMessage *chat;
session = (FalconSessionEntity*)sessionWalker.GetFirst();
while(session)
{
chat=new UI_SendChatMessage(FalconNullId,session);
chat->dataBlock.from=FalconLocalSessionId;
chat->dataBlock.size=static_cast<short>((strlen(chatterStr)+1)*sizeof(char));
chat->dataBlock.message=new char[chat->dataBlock.size];
memcpy(chat->dataBlock.message,chatterStr,chat->dataBlock.size);
FalconSendMessage(chat,TRUE);
session = (FalconSessionEntity*)sessionWalker.GetNext();
}
}
void SendTextMessageToChannel()
{
int curChannel,curRadio;
if(VM)
{
curRadio=VM->Radio();
curChannel=VM->GetRadioFreq(curRadio);
switch(curChannel)
{
case rcfOff:
break;
case rcfFlight:
SendTextToFlight();
break;
case rcfPackage:
SendTextToPackage();
break;
case rcfFromPackage:
SendTextToPackage();
break;
case rcfProx: // 40nm range
SendTextToRange();
break;
case rcfTeam:
SendTextToTeam();
break;
case rcfAll:
SendTextToEveryOne();
break;
}
}
}
void SimOpenChatBox (unsigned long, int state, void *)
{
if ((state & KEY_DOWN))
{
CommandsKeyCombo = -2;
CommandsKeyComboMod = -2;
memset(chatterStr,0,sizeof(chatterStr));
chatterCount=0;
UseInputFn=SendTextMessageToChannel;
DiscardInputFn=NULL;
MaxInputLength=60;
AsciiAllowed=0; // All
OTWDriver.SetFrontTextFlags(OTWDriver.GetFrontTextFlags() | SHOW_CHATBOX);
}
}
static void HookupCommsControls(long ID)
{
C_Window *winme;
C_Button *ctrl;
C_EditBox *ebox;
C_TreeList *tree;
winme=gMainHandler->FindWindow(ID);
if(winme == NULL)
return;
// Hook up IDs here
// Hook up Close Button
ctrl=(C_Button *)winme->FindControl(CHAT_ALL);
if(ctrl)
ctrl->SetCallback(SelectChatFilterCB);
ctrl=(C_Button *)winme->FindControl(CHAT_TEAM);
if(ctrl)
ctrl->SetCallback(SelectChatFilterCB);
ctrl=(C_Button *)winme->FindControl(CHAT_PACKAGE);
if(ctrl)
ctrl->SetCallback(SelectChatFilterCB);
ctrl=(C_Button *)winme->FindControl(CHAT_FLIGHT);
if(ctrl)
ctrl->SetCallback(SelectChatFilterCB);
ctrl=(C_Button *)winme->FindControl(CHAT_DISCONNECT);
if(ctrl)
ctrl->SetCallback(DisconnectCommsCB);
ctrl=(C_Button *)winme->FindControl(CHAT_PBOOK);
if(ctrl)
ctrl->SetCallback(OpenPhoneBookCB);
ctrl=(C_Button *)winme->FindControl(CLOSE_WINDOW);
if(ctrl)
ctrl->SetCallback(CloseWindowCB);
ebox=(C_EditBox *)winme->FindControl(TEXT_OUT);
if(ebox)
ebox->SetCallback(SendChatStringCB);
ctrl=(C_Button *)winme->FindControl(PB_NEW);
if(ctrl)
ctrl->SetCallback(Phone_New_CB);
ctrl=(C_Button *)winme->FindControl(PB_APPLY);
if(ctrl)
ctrl->SetCallback(Phone_Apply_CB);
ctrl=(C_Button *)winme->FindControl(PB_REMOVE);
if(ctrl)
ctrl->SetCallback(Phone_Remove_CB);
ctrl=(C_Button *)winme->FindControl(PB_CONNECT);
if(ctrl)
ctrl->SetCallback(Phone_Connect_CB);
ctrl=(C_Button *)winme->FindControl(PB_CANCEL);
if(ctrl)
ctrl->SetCallback(CloseWindowCB);
ctrl=(C_Button *)winme->FindControl(CON_TYPE_MODEM);
if(ctrl)
ctrl->SetCallback(Phone_ConnectType_CB);
ctrl=(C_Button *)winme->FindControl(CON_TYPE_INTERNET);
if(ctrl)
ctrl->SetCallback(Phone_ConnectType_CB);
ctrl=(C_Button *)winme->FindControl(CON_TYPE_LAN);
if(ctrl)
ctrl->SetCallback(Phone_ConnectType_CB);
ctrl=(C_Button *)winme->FindControl(CON_TYPE_SERIAL);
if(ctrl)
ctrl->SetCallback(Phone_ConnectType_CB);
tree=(C_TreeList*)winme->FindControl(PEOPLE_TREE);
if(tree)
{
People=tree;
tree->SetCallback(PeopleSelectCB);
}
// Help GUIDE thing
ctrl=(C_Button*)winme->FindControl(UI_HELP_GUIDE);
if(ctrl)
ctrl->SetCallback(UI_Help_Guide_CB);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -