本文整理汇总了C++中CSelectedUnits类的典型用法代码示例。如果您正苦于以下问题:C++ CSelectedUnits类的具体用法?C++ CSelectedUnits怎么用?C++ CSelectedUnits使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CSelectedUnits类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PossibleCommandChange
void CSelectedUnits::PossibleCommandChange(CUnit* sender)
{
GML_RECMUTEX_LOCK(sel); // PossibleCommandChange
if (sender == NULL || selectedUnits.find(sender) != selectedUnits.end())
possibleCommandsChanged = true;
}
示例2: Draw
void CSelectedUnits::Draw()
{
glDisable(GL_DEPTH_TEST );
//glEnable(GL_BLEND);
//glColor4f(0,0.8f,0,0.4f);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glColor3f(0,1.0f,0);
set<CUnit*>::iterator ui;
glBegin(GL_QUADS);
if(selectedGroup!=-1){
for(ui=grouphandler->groups[selectedGroup]->units.begin();ui!=grouphandler->groups[selectedGroup]->units.end();++ui){
float3 pos((*ui)->pos+(*ui)->speed*gu->timeOffset);
glVertexf3(pos+float3((*ui)->xsize*4,0,(*ui)->ysize*4));
glVertexf3(pos+float3(-(*ui)->xsize*4,0,(*ui)->ysize*4));
glVertexf3(pos+float3(-(*ui)->xsize*4,0,-(*ui)->ysize*4));
glVertexf3(pos+float3((*ui)->xsize*4,0,-(*ui)->ysize*4));
}
} else {
for(ui=selectedUnits.begin();ui!=selectedUnits.end();++ui){
float3 pos((*ui)->pos+(*ui)->speed*gu->timeOffset);
glVertexf3(pos+float3((*ui)->xsize*4,0,(*ui)->ysize*4));
glVertexf3(pos+float3(-(*ui)->xsize*4,0,(*ui)->ysize*4));
glVertexf3(pos+float3(-(*ui)->xsize*4,0,-(*ui)->ysize*4));
glVertexf3(pos+float3((*ui)->xsize*4,0,-(*ui)->ysize*4));
}
}
glEnd();
glEnable(GL_DEPTH_TEST );
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
//glDisable(GL_BLEND);
}
示例3: DrawCommands
void CSelectedUnits::DrawCommands(void)
{
glDisable(GL_TEXTURE_2D);
glDisable(GL_DEPTH_TEST);
lineDrawer.Configure(cmdColors.UseColorRestarts(),
cmdColors.UseRestartColor(),
cmdColors.restart,
cmdColors.RestartAlpha());
glBlendFunc((GLenum)cmdColors.QueuedBlendSrc(),
(GLenum)cmdColors.QueuedBlendDst());
glEnable(GL_BLEND);
glLineWidth(cmdColors.QueuedLineWidth());
set<CUnit*>::iterator ui;
if(selectedGroup!=-1){
for(ui=grouphandler->groups[selectedGroup]->units.begin();ui!=grouphandler->groups[selectedGroup]->units.end();++ui){
(*ui)->commandAI->DrawCommands();
}
} else {
for(ui=selectedUnits.begin();ui!=selectedUnits.end();++ui){
(*ui)->commandAI->DrawCommands();
}
}
glLineWidth(1.0f);
glEnable(GL_DEPTH_TEST);
}
示例4: SetCommandPage
void CSelectedUnits::SetCommandPage(int page)
{
if(selectedGroup!=-1 && grouphandler->groups[selectedGroup]->ai){
grouphandler->groups[selectedGroup]->lastCommandPage=page;
}
if(!selectedUnits.empty())
(*selectedUnits.begin())->commandAI->lastSelectedCommandPage=page;
}
示例5: SetCommandPage
void CSelectedUnits::SetCommandPage(int page)
{
GML_RECMUTEX_LOCK(sel); // SetCommandPage - called from CGame::Draw --> RunLayoutCommand --> LayoutIcons --> RevertToCmdDesc
CUnitSet::iterator ui;
for (ui = selectedUnits.begin(); ui != selectedUnits.end(); ++ui) {
(*ui)->commandAI->lastSelectedCommandPage = page;
}
}
示例6: GetTooltip
std::string CSelectedUnits::GetTooltip(void)
{
std::string s;
if(selectedGroup!=-1 && grouphandler->groups[selectedGroup]->ai){
s="Group selected";
} else if(!selectedUnits.empty()){
// show the player name instead of unit name if it has FBI tag showPlayerName
if((*selectedUnits.begin())->unitDef->showPlayerName)
{
s=gs->players[gs->Team((*selectedUnits.begin())->team)->leader]->playerName.c_str();
} else {
s=(*selectedUnits.begin())->tooltip;
}
}
if(selectedUnits.empty()){
return s;
}
char tmp[500];
float maxHealth=0,curHealth=0,cost=0,exp=0,range=0,metalMake=0,metalUse=0,energyMake=0,energyUse=0,maxfuel=0,curfuel=0,numfuel=0;
for(set<CUnit*>::iterator ui=selectedUnits.begin();ui!=selectedUnits.end();++ui){
maxHealth+=(*ui)->maxHealth;
curHealth+=(*ui)->health;
exp+=(*ui)->experience;
cost+=(*ui)->metalCost+(*ui)->energyCost/60;
range+=(*ui)->maxRange;
metalMake+=(*ui)->metalMake;
metalUse+=(*ui)->metalUse;
energyMake+=(*ui)->energyMake;
energyUse+=(*ui)->energyUse;
maxfuel+=(*ui)->unitDef->maxFuel;
curfuel+=(*ui)->currentFuel;
if((*ui)->unitDef->maxFuel > 0)
numfuel++;
}
float num=selectedUnits.size();
sprintf(tmp,"\nHealth %.0f/%.0f",curHealth,maxHealth);
s+=tmp;
if(maxfuel>0){
sprintf(tmp," Fuel %.0f/%.0f",curfuel/numfuel,maxfuel/numfuel);
s+=tmp;
}
sprintf(tmp,"\nExperience %.2f Cost %.0f Range %.0f \n\xff\xd3\xdb\xffMetal: \xff\x50\xff\x50%.1f\xff\x90\x90\x90/\xff\xff\x50\x01-%.1f\xff\xd3\xdb\xff Energy: \xff\x50\xff\x50%.1f\xff\x90\x90\x90/\xff\xff\x50\x01-%.1f",
exp/num,cost,range/num, metalMake, metalUse, energyMake, energyUse);
s += tmp;
if (gs->cheatEnabled && (selectedUnits.size() == 1)) {
CUnit* unit = *selectedUnits.begin();
SNPRINTF(tmp, sizeof(tmp), "\xff\xc0\xc0\xff [TechLevel %i]",
unit->unitDef->techLevel);
s += tmp;
}
return s;
}
示例7: SendSelection
void CSelectedUnits::SendSelection(void)
{
// first, convert CUnit* to unit IDs.
std::vector<short> selectedUnitIDs(selectedUnits.size());
std::vector<short>::iterator i = selectedUnitIDs.begin();
CUnitSet::const_iterator ui = selectedUnits.begin();
for(; ui != selectedUnits.end(); ++i, ++ui) *i = (*ui)->id;
net->Send(CBaseNetProtocol::Get().SendSelect(gu->myPlayerNum, selectedUnitIDs));
selectionChanged=false;
}
示例8: SendSelection
void CSelectedUnits::SendSelection(void)
{
// first, convert CUnit* to unit IDs.
std::vector<short> selectedUnitIDs(selectedUnits.size());
std::vector<short>::iterator i = selectedUnitIDs.begin();
std::set<CUnit*>::const_iterator ui = selectedUnits.begin();
for(; ui != selectedUnits.end(); ++i, ++ui) *i = (*ui)->id;
net->SendSTLData<unsigned char, std::vector<short> >(NETMSG_SELECT, gu->myPlayerNum, selectedUnitIDs);
selectionChanged=false;
}
示例9: SetCommandPage
void CSelectedUnits::SetCommandPage(int page)
{
if(selectedGroup!=-1 && grouphandlers[gu->myTeam]->groups[selectedGroup]->ai){
grouphandlers[gu->myTeam]->groups[selectedGroup]->lastCommandPage=page;
}
CUnitSet::iterator ui;
for (ui = selectedUnits.begin(); ui != selectedUnits.end(); ++ui) {
(*ui)->commandAI->lastSelectedCommandPage = page;
}
}
示例10: ClearSelected
void CSelectedUnits::ClearSelected()
{
set<CUnit*>::iterator ui;
ENTER_MIXED;
for(ui=selectedUnits.begin();ui!=selectedUnits.end();++ui){
(*ui)->commandAI->selected=false;
DeleteDeathDependence(*ui);
}
ENTER_UNSYNCED;
selectedUnits.clear();
selectionChanged=true;
possibleCommandsChanged=true;
selectedGroup=-1;
}
示例11: ClearSelected
void CSelectedUnits::ClearSelected()
{
GML_RECMUTEX_LOCK(sel); // ClearSelected
CUnitSet::iterator ui;
for(ui=selectedUnits.begin();ui!=selectedUnits.end();++ui){
(*ui)->commandAI->selected=false;
DeleteDeathDependence(*ui);
}
selectedUnits.clear();
selectionChanged=true;
possibleCommandsChanged=true;
selectedGroup=-1;
}
示例12: AddUnit
void CSelectedUnits::AddUnit(CUnit* unit)
{
// if unit is being transported by eg. Hulk or Atlas
// then we should not be able to select it
if (unit->transporter != NULL && !unit->transporter->unitDef->isFirePlatform) {
return;
}
if (unit->noSelect) {
return;
}
selectedUnits.insert(unit);
AddDeathDependence(unit);
selectionChanged = true;
possibleCommandsChanged = true;
if (!(unit->group) || unit->group->id != selectedGroup)
selectedGroup = -1;
PUSH_CODE_MODE;
ENTER_MIXED;
unit->commandAI->selected = true;
POP_CODE_MODE;
}
示例13: AddUnit
void CSelectedUnits::AddUnit(CUnit* unit)
{
// if unit is being transported by eg. Hulk or Atlas
// then we should not be able to select it
CTransportUnit *trans=unit->GetTransporter();
if (trans != NULL && !trans->unitDef->isFirePlatform) {
return;
}
if (unit->noSelect) {
return;
}
GML_RECMUTEX_LOCK(sel); // AddUnit
selectedUnits.insert(unit);
AddDeathDependence(unit);
selectionChanged = true;
possibleCommandsChanged = true;
if (!(unit->group) || unit->group->id != selectedGroup)
selectedGroup = -1;
unit->commandAI->selected = true;
}
示例14: DrawCommands
void CSelectedUnits::DrawCommands(void)
{
glDisable(GL_TEXTURE_2D);
glDisable(GL_DEPTH_TEST);
set<CUnit*>::iterator ui;
if(selectedGroup!=-1){
for(ui=grouphandler->groups[selectedGroup]->units.begin();ui!=grouphandler->groups[selectedGroup]->units.end();++ui){
(*ui)->commandAI->DrawCommands();
}
} else {
for(ui=selectedUnits.begin();ui!=selectedUnits.end();++ui){
(*ui)->commandAI->DrawCommands();
}
}
glEnable(GL_DEPTH_TEST);
}
示例15: HandleSingleUnitClickSelection
void CSelectedUnits::HandleSingleUnitClickSelection(CUnit* unit, bool doInViewTest)
{
GML_RECMUTEX_LOCK(sel); // SelectUnits
//FIXME make modular?
const CMouseHandler::ButtonPressEvt& bp = mouse->buttons[SDL_BUTTON_LEFT];
if (unit == NULL)
return;
if (unit->team != gu->myTeam && !gu->spectatingFullSelect && !gs->godMode)
return;
if (bp.lastRelease < (gu->gameTime - mouse->doubleClickTime)) {
if (keyInput->IsKeyPressed(SDLK_LCTRL) && (selectedUnits.find(unit) != selectedUnits.end())) {
RemoveUnit(unit);
} else {
AddUnit(unit);
}
} else {
//double click, select all units of same type (on screen, unless CTRL is pressed)
int team, lastTeam;
if (gu->spectatingFullSelect || gs->godMode) {
team = 0;
lastTeam = teamHandler->ActiveTeams() - 1;
} else {
team = gu->myTeam;
lastTeam = gu->myTeam;
}
for (; team <= lastTeam; team++) {
CUnitSet::iterator ui;
CUnitSet& teamUnits = teamHandler->Team(team)->units;
for (ui = teamUnits.begin(); ui != teamUnits.end(); ++ui) {
if ((*ui)->unitDef->id == unit->unitDef->id) {
if (!doInViewTest || keyInput->IsKeyPressed(SDLK_LCTRL) || camera->InView((*ui)->midPos)) {
AddUnit(*ui);
}
}
}
}
}
#if (PLAY_SOUNDS == 1)
Channels::UnitReply.PlayRandomSample(unit->unitDef->sounds.select, unit);
#endif
}