📄 units.cpp
字号:
// _tcscat(buffer,_T(" "));
// ReadIndexedString(613, tmp, 79);
// _tcscat(buffer,tmp);
ForeignToUpper(buffer);
txt->SetText(buffer);
txt->Refresh();
}
bmp=(C_Bitmap*)win->FindControl(UNIT_ICON);
if(bmp)
{
bmp->Refresh();
if(urec->MapItem_ && urec->MapItem_->Icon)
{
bmp->SetImage(urec->MapItem_->Icon->GetImage());
bmp->SetFlagBitOff(C_BIT_INVISIBLE);
}
else
bmp->SetFlagBitOn(C_BIT_INVISIBLE);
bmp->Refresh();
}
txt=(C_Text*)win->FindControl(UNIT_NAME);
if(txt)
{
txt->Refresh();
div->GetName(buffer,40,FALSE);
txt->SetText(buffer);
txt->Refresh();
}
par=un->GetUnitParent();
txt=(C_Text*)win->FindControl(UNIT_PARENT);
if(txt)
{
txt->Refresh();
txt->SetFlagBitOn(C_BIT_INVISIBLE);
}
txt=(C_Text*)win->FindControl(UNIT_GRANDPARENT);
if(txt)
{
txt->Refresh();
txt->SetFlagBitOn(C_BIT_INVISIBLE);
}
/* KCK: Changed to text box
lbox=(C_ListBox*)win->FindControl(UNIT_OWNER);
if(lbox)
{
// Use flag to determine owner name to choose.
// This way TE works. Ideally, this would be a
// text box and we'd set it to the team name string
lbox->SetValue(TeamInfo[owner]->GetFlag()+1);
lbox->Refresh();
}
*/
txt=(C_Text*)win->FindControl(UNIT_OWNER);
if(txt)
{
txt->SetText(TeamInfo[owner]->GetName());
}
lbox=(C_ListBox*)win->FindControl(UNIT_EXPERIENCE);
if(lbox)
{
lbox->SetValue(CVTRange(TeamInfo[(DivID >> 24)]->groundExperience,100,5));
lbox->Refresh();
}
lbox=(C_ListBox*)win->FindControl(UNIT_SUPPLY);
if(lbox)
{
lbox->SetValue(CVTRange(Supply,100,4));
lbox->Refresh();
}
lbox=(C_ListBox*)win->FindControl(UNIT_MORALE);
if(lbox)
{
lbox->SetValue(CVTRange(Morale,100,4));
lbox->Refresh();
}
lbox=(C_ListBox*)win->FindControl(UNIT_FATIGUE);
if(lbox)
{
lbox->SetValue(CVTRange(Fatigue,100,4));
lbox->Refresh();
}
txt=(C_Text*)win->FindControl(UNIT_ETA);
if(txt)
{
txt->Refresh();
txt->SetText(gStringMgr->GetString(TXT_NONE));
txt->Refresh();
}
lbox=(C_ListBox*)win->FindControl(UNIT_ORDERS);
if(lbox)
{
lbox->SetValue(0);
lbox->Refresh();
}
lbox=(C_ListBox*)win->FindControl(UNIT_FORMATION);
if(lbox)
{
lbox->SetValue(0);
lbox->Refresh();
}
lbox=(C_ListBox*)win->FindControl(UNIT_TOE);
if(lbox)
{
lbox->SetValue(un->GetTeam()+1);
lbox->Refresh();
}
ebox=(C_EditBox*)win->FindControl(UNIT_OBJECTIVE);
if(ebox)
{
// Orders part (Get from the old list box)
int orders = un->GetUnitOrders();
lbox=(C_ListBox*)win->FindControl(UNIT_ORDERS);
if(lbox)
{
lbox->SetValue(orders+1);
_tcscpy(buffer,lbox->GetText());
}
// Objective name part
Objective obj=un->GetUnitObjective();
if(obj)
{
_TCHAR tmp[80];
obj->GetName(tmp,20,FALSE);
if (gLangIDNum >= F4LANG_SPANISH)
{
_tcscat(buffer,_T(" - "));
_tcscat(buffer,tmp);
}
else if (gLangIDNum == F4LANG_GERMAN)
{
_tcscat(buffer,_T(": "));
_tcscat(buffer,tmp);
}
else
{
_tcscat(buffer,_T(" "));
_tcscat(buffer,tmp);
}
}
ebox->SetText(gStringMgr->GetText(gStringMgr->AddText(buffer)));
ebox->Refresh();
}
line=(C_Line*)win->FindControl(UNIT_STRENGTH);
if(line)
{// Strength
line->Refresh();
h=line->GetUserNumber(C_STATE_1)*Strength/100;
y=line->GetUserNumber(C_STATE_0) + line->GetUserNumber(C_STATE_1)-h;
line->SetY(y);
line->SetH(h);
line->Refresh();
}
AddVehiclesToWindow(win,0);
gMainHandler->ShowWindow(win);
gMainHandler->WindowToFront(win);
UI_Leave(Leave);
}
static C_Base *priorpilot=NULL;
long ratingstr[]=
{
TXT_PILOT_RATE_0,
TXT_PILOT_RATE_1,
TXT_PILOT_RATE_2,
TXT_PILOT_RATE_3,
TXT_PILOT_RATE_4,
};
void PickPilotCB(long,short hittype,C_Base *control)
{
C_Bitmap *bmp;
C_Text *txt;
_TCHAR buffer[10];
F4CSECTIONHANDLE *Leave;
if(hittype != C_TYPE_LMOUSEUP)
return;
Leave=UI_Enter(control->Parent_);
bmp=(C_Bitmap*)control->Parent_->FindControl(UNIT_PICTURE);
if(bmp)
{
if(priorpilot)
{
priorpilot->SetState(0);
priorpilot->Refresh();
}
control->SetState(1);
control->Refresh();
bmp->Refresh();
if(control->GetUserNumber(C_STATE_0))
bmp->SetImage(control->GetUserNumber(C_STATE_0));
else
{ // Need to load a file
}
bmp->Refresh();
}
txt=(C_Text*)control->Parent_->FindControl(UNIT_NUM_MISSIONS);
if(txt)
{
_stprintf(buffer,"%1d",control->GetUserNumber(C_STATE_2));
txt->SetText(buffer);
txt->Refresh();
}
txt=(C_Text*)control->Parent_->FindControl(UNIT_AVG_RATING);
if(txt)
{
if(control->GetUserNumber(C_STATE_3))
txt->SetText(ratingstr[(short)(((float)control->GetUserNumber(C_STATE_3)/25.0f + 0.5f))%5]);
else
txt->SetText(TXT_NO_RATING);
txt->Refresh();
}
txt=(C_Text*)control->Parent_->FindControl(UNIT_A_A_KILLS);
if(txt)
{
txt->Refresh();
_stprintf(buffer,"%1d",control->GetUserNumber(C_STATE_4));
txt->SetText(buffer);
txt->Refresh();
}
txt=(C_Text*)control->Parent_->FindControl(UNIT_A_G_KILLS);
if(txt)
{
txt->Refresh();
_stprintf(buffer,"%1d",control->GetUserNumber(C_STATE_5));
txt->SetText(buffer);
txt->Refresh();
}
txt=(C_Text*)control->Parent_->FindControl(UNIT_NAVAL_KILLS);
if(txt)
{
txt->Refresh();
_stprintf(buffer,"%1d",control->GetUserNumber(C_STATE_6));
txt->SetText(buffer);
txt->Refresh();
}
txt=(C_Text*)control->Parent_->FindControl(UNIT_STATIC_KILLS);
if(txt)
{
txt->Refresh();
_stprintf(buffer,"%1d",control->GetUserNumber(C_STATE_7));
txt->SetText(buffer);
txt->Refresh();
}
UI_Leave(Leave);
priorpilot=control;
}
extern long gRanksTxt[NUM_RANKS];
long GetRank(_TCHAR *str)
{
_TCHAR *rnk;
long i;
i=0;
while(i < NUM_RANKS)
{
rnk=gStringMgr->GetString(gRanksTxt[i]);
if(rnk)
{
if(!_tcsncicmp(rnk,str,_tcsclen(rnk)))
return(i);
}
i++;
}
return(0);
}
void BuildPilotList(C_TreeList *tree,Squadron sqd)
{
C_Button *btn;
_TCHAR buffer[30];
short i;
long ID=1;
TREELIST *item;
RemoteLB *lbptr;
tree->DeleteBranch(tree->GetRoot());
priorpilot=NULL;
VuSessionsIterator sessionWalker(FalconLocalGame);
FalconSessionEntity *session;
session = (FalconSessionEntity*)sessionWalker.GetFirst();
while(session)
{
if(session->GetPlayerSquadronID() == sqd->Id())
{
btn=new C_Button;
if(btn)
{
btn->Setup(ID,C_TYPE_CUSTOM,0,0);
btn->SetText(C_STATE_0,gStringMgr->GetText(gStringMgr->AddText(session->GetPlayerName())));
btn->SetText(C_STATE_1,gStringMgr->GetText(gStringMgr->AddText(session->GetPlayerName())));
btn->SetColor(C_STATE_0,0xeeeeee);
btn->SetColor(C_STATE_1,0x00ff00);
btn->SetCallback(PickPilotCB);
if(session == FalconLocalSession)
{
if(LogBook.GetPictureResource()) // Temporary
btn->SetUserNumber(C_STATE_0,LogBook.GetPictureResource()); // Image ID goes here
else
{ // Need to load a file
btn->SetUserNumber(C_STATE_0,NOFACE); // Image ID goes here
}
}
else
{
lbptr=(RemoteLB*)gCommsMgr->GetRemoteLB(session->Id().creator_);
if(lbptr && lbptr->Pilot_.PictureResource)
{
btn->SetUserNumber(C_STATE_0,lbptr->Pilot_.PictureResource); // Image ID goes here
}
else
btn->SetUserNumber(C_STATE_0,NOFACE); // Image ID goes here
}
btn->SetUserNumber(C_STATE_2,session->GetMissions()); // Num Missions
btn->SetUserNumber(C_STATE_3,session->GetRating()); // Mission Rating
btn->SetUserNumber(C_STATE_4,session->GetKill(FalconSessionEntity::_AIR_KILLS_));
btn->SetUserNumber(C_STATE_5,session->GetKill(FalconSessionEntity::_GROUND_KILLS_));
btn->SetUserNumber(C_STATE_6,session->GetKill(FalconSessionEntity::_NAVAL_KILLS_));
btn->SetUserNumber(C_STATE_7,session->GetKill(FalconSessionEntity::_STATIC_KILLS_));
btn->SetUserNumber(20,GetRank(session->GetPlayerName()));
item=tree->CreateItem(ID,C_TYPE_ITEM,btn);
if(item)
tree->AddItem(tree->GetRoot(),item);
ID++;
}
}
session = (FalconSessionEntity*)sessionWalker.GetNext();
}
for(i=0;i<PILOTS_PER_SQUADRON;i++)
{
// if(sqd->GetPilotData(i)->pilot_status == PILOT_IN_USE || sqd->GetPilotData(i)->pilot_status == PILOT_AVAILABLE)
if(sqd->GetPilotData(i)->pilot_status != PILOT_KIA)
{
GetPilotName(sqd->GetPilotData(i)->pilot_id,buffer,25);
btn=new C_Button;
if(btn)
{
btn->Setup(ID,C_TYPE_CUSTOM,0,0);
btn->SetText(C_STATE_0,gStringMgr->GetText(gStringMgr->AddText(buffer)));
btn->SetText(C_STATE_1,gStringMgr->GetText(gStringMgr->AddText(buffer)));
btn->SetColor(C_STATE_0,0xeeeeee);
btn->SetColor(C_STATE_1,0x00ff00);
btn->SetCallback(PickPilotCB);
if(sqd->GetOwner() == FalconLocalSession->GetCountry())
btn->SetUserNumber(C_STATE_0,PilotImageIDs[PilotInfo[sqd->GetPilotData(i)->pilot_id].photo_id]); // Image ID goes here
else
btn->SetUserNumber(C_STATE_0,FlagImageID[TeamInfo[sqd->GetOwner()]->GetFlag()][BIG_HORIZ]); // Image ID goes here
btn->SetUserNumber(C_STATE_2,sqd->GetPilotData(i)->missions_flown); // Num Missions
btn->SetUserNumber(C_STATE_3,sqd->GetPilotData(i)->GetPilotRating()*25); // Mission Rating
btn->SetUserNumber(C_STATE_4,sqd->GetPilotData(i)->aa_kills);
btn->SetUserNumber(C_STATE_5,sqd->GetPilotData(i)->ag_kills);
btn->SetUserNumber(C_STATE_6,sqd->GetPilotData(i)->an_kills);
btn->SetUserNumber(C_STATE_7,sqd->GetPilotData(i)->as_kills);
btn->SetUserNumber(20,GetRank(buffer));
item=tree->CreateItem(ID,C_TYPE_ITEM,btn);
if(item)
tree->AddItem(tree->GetRoot(),item);
if(ID == 1)
PickPilotCB(ID,C_TYPE_LMOUSEUP,btn);
ID++;
}
}
}
tree->RecalcSize();
if(tree->Parent_)
tree->Parent_->RefreshClient(tree->GetClient());
}
void PickSquadronStatsCB(long,short hittype,C_Base *control)
{
C_Text *txt;
C_Bitmap *bmp;
_TCHAR buffer[10];
F4CSECTIONHANDLE *Leave;
if(hittype != C_TYPE_LMOUSEUP)
return;
Leave=UI_Enter(control->Parent_);
bmp=(C_Bitmap*)control->Parent_->FindControl(UNIT_PICTURE);
if(bmp)
{
bmp->SetImage(SquadronMatchIDs[control->GetUserNumber(10)][0]);
bmp->Refresh();
}
txt=(C_Text*)control->Parent_->FindControl(UNIT_NUM_MISSIONS);
if(txt)
{
_stprintf(buffer,"%1d",control->GetUserNumber(C_STATE_2));
txt->SetText(buffer);
txt->Refresh();
}
txt=(C_Text*)control->Parent_->FindControl(UNIT_AVG_RATING);
if(txt)
{
if(control->GetUserNumber(C_STATE_2))
txt->SetText(ratingstr[(short)(((float)control->GetUserNumber(C_STATE_3)/25.0f + 0.5f))%5]);
else
txt->SetText(TXT_NO_RATING);
txt->Refresh();
}
txt=(C_Text*)control->Parent_->FindControl(UNIT_A_A_KILLS);
if(txt)
{
_stprintf(buffer,"%1d",control->GetUserNumber(C_STATE_4));
txt->SetText(buffer);
txt->Refresh();
}
txt=(C_Text*)control->Parent_->FindControl(UNIT_A_G_KILLS);
if(txt)
{
_stprintf(buffer,"%1d",control->GetUserNumber(C_STATE_5));
txt->SetText(buffer);
txt->Refresh();
}
txt=(C_Text*)control->Parent_->FindControl(UNIT_NAVAL_KILLS);
if(txt)
{
_stprintf(buffer,"%1d",control->GetUserNumber(C_STATE_6));
txt->SetText(buffer);
txt->Refresh();
}
txt=(C_Text*)control->Parent_->FindControl(UNIT_STATIC_KILLS);
if(txt)
{
_stprintf(buffer,"%1d",control->GetUserNumber(C_STATE_7));
txt->SetText(buffer);
txt->Refresh();
}
UI_Leave(Leave);
}
void SquadronAirUnitCB(long ID,short hittype,C_Base *control)
{
if(hittype != C_TYPE_LMOUSEUP)
return;
if(control)
{
control->Parent_->DisableCluster(control->GetUserNumber(C_STATE_1));
PickSquadronStatsCB(ID,hittype,control);
control->Parent_->EnableCluster(control->GetUserNumber(C_STATE_0));
control->Parent_->RefreshWindow();
}
}
void PilotAirUnitCB(long,short hittype,C_Base *control)
{
C_TreeList *tree=NULL;
C_Button *btn=NULL;
if(hittype != C_TYPE_LMOUSEUP)
return;
if(control)
{
control->Parent_->DisableCluster(control->GetUserNumber(C_STATE_1));
tree=(C_TreeList*)control->Parent_->FindControl(UNIT_PILOTLIST);
if(tree)
{
if(tree->GetRoot())
btn=(C_Button*)tree->GetRoot()->Item_;
if(btn)
PickPilotCB(btn->GetID(),hittype,btn);
control->Parent_->EnableCluster(control->GetUserNumber(C_STATE_0));
tree->RecalcSize();
if(tree->Parent_)
tree->Parent_->RefreshClient(tree->GetClient());
}
control->Parent_->RefreshWindow();
}
}
void SquadronFindCB(long,short hittype,C_Base *)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -