sources » UnitClass » GetUIName
// returns a pointer to a Unicode string
wchar_t * UnitClass::GetUIName() {
if( this->IsDisguisedFriendly( PlayerHouse ) && this->GetDisguise( true ) ) { // former I don't understand, latter returns NULL if not disguised
if( !this->GetDisguiseHouse() ) {
return NULL;
}
return this->GetDisguise()->ptrCSF;
}
if( !this->HasMultipleTurrets() || !this->HasTurretTooltips() ) {
return this->ptrCSF;
}
wchar_t * tip;
TechnoClass *passenger = this->GetFirstPassenger();
if( !passenger || passenger->What_Am_I() != IS_INFANTRY ) {
tip = StringTable::LoadString("Tip:Rocket");
swprintf(this->Tooltip, "%s %s", tip, this->UnitType->ptrCSF);
return this->Tooltip;
}
bool UsesOwnName = passenger->InfantryType->UseOwnName;
int idxTurret = this->GetActiveTurretIndex();
if( !idxTurret ) {
tip = StringTable::LoadString("Tip:Rocket");
if( !tip ) {
tip = StringTable::LoadString("Tip:Rocket"); // oh my
}
swprintf(this->Tooltip, "%s %s", tip, this->UnitType->ptrCSF);
return this->Tooltip;
}
if( idxTurret == 1 && !UsesOwnName ) {
tip = StringTable::LoadString("Tip:MachineGun");
if( !tip ) {
tip = StringTable::LoadString("Tip:Rocket");
}
swprintf(this->Tooltip, "%s %s", tip, this->UnitType->ptrCSF);
return this->Tooltip;
} else {
if( idxTurret == 2 ) {
tip = StringTable::LoadString("Tip:Repair");
if( !tip ) {
tip = StringTable::LoadString("Tip:Rocket");
}
swprintf(this->Tooltip, "%s %s", tip, this->UnitType->ptrCSF);
return this->Tooltip;
}
if( idxTurret != 3 && !UsesOwnName ) {
tip = StringTable::LoadString("Tip:Rocket");
swprintf(this->Tooltip, "%s %s", tip, this->UnitType->ptrCSF);
return this->Tooltip;
}
}
tip = passenger->GetType()->ptrCSF;
if( !tip ) {
tip = StringTable::LoadString("Tip:Rocket");
}
swprintf(this->Tooltip, "%s %s", tip, this->UnitType->ptrCSF);
return this->Tooltip;
}