GLWTankTip.cpp

Go to the documentation of this file.
00001 ////////////////////////////////////////////////////////////////////////////////
00002 //    Scorched3D (c) 2000-2009
00003 //
00004 //    This file is part of Scorched3D.
00005 //
00006 //    Scorched3D is free software; you can redistribute it and/or modify
00007 //    it under the terms of the GNU General Public License as published by
00008 //    the Free Software Foundation; either version 2 of the License, or
00009 //    (at your option) any later version.
00010 //
00011 //    Scorched3D is distributed in the hope that it will be useful,
00012 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //    GNU General Public License for more details.
00015 //
00016 //    You should have received a copy of the GNU General Public License
00017 //    along with Scorched3D; if not, write to the Free Software
00018 //    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 ////////////////////////////////////////////////////////////////////////////////
00020 
00021 #include <GLW/GLWTankTip.h>
00022 #include <tankgraph/TankKeyboardControlUtil.h>
00023 #include <tank/TankPosition.h>
00024 #include <tank/TankAccessories.h>
00025 #include <tank/TankState.h>
00026 #include <tank/TankScore.h>
00027 #include <target/TargetLife.h>
00028 #include <target/TargetShield.h>
00029 #include <target/TargetParachute.h>
00030 #include <weapons/Weapon.h>
00031 #include <weapons/Shield.h>
00032 #include <weapons/AccessoryStore.h>
00033 #include <landscape/Landscape.h>
00034 #include <landscapemap/LandscapeMaps.h>
00035 #include <client/ScorchedClient.h>
00036 #include <client/ClientState.h>
00037 #include <common/Defines.h>
00038 #include <graph/OptionsDisplay.h>
00039 #include <lang/LangResource.h>
00040 
00041 TankUndoMenu::TankUndoMenu(Tank *tank) :
00042         tank_(tank)
00043 {
00044 }
00045 
00046 TankUndoMenu::~TankUndoMenu()
00047 {
00048 }
00049 
00050 void TankUndoMenu::showItems(float x, float y)
00051 {
00052         static ToolTip useTip(ToolTip::ToolTipHelp, 
00053                 LANG_RESOURCE("UNDO", "Undo"), 
00054                 LANG_RESOURCE("UNDO_TOOLTIP", "Reverts back to the selected rotation,\n"
00055                 "elevtaion and power."));
00056 
00057         std::list<GLWSelectorEntry> entries;
00058         std::vector<TankPosition::ShotEntry> &oldShots =
00059                 tank_->getPosition().getOldShots();
00060         for (int i=0; i<(int) oldShots.size(); i++)
00061         {
00062                 char buffer[128];
00063                 snprintf(buffer, 128, "%s%i: Pwr:%.1f Ele:%.1f Rot:%.1f",
00064                         (oldShots[i].current?"* ":"  "),
00065                         i, oldShots[i].power.asFloat(), oldShots[i].ele.asFloat(),
00066                         (360.0f - oldShots[i].rot.asFloat()));
00067                 entries.push_back(
00068                         GLWSelectorEntry(LANG_STRING(buffer), &useTip, 0, 0, (void *) 
00069                                 ((unsigned int) (oldShots.size() - 1 - i))));
00070         }
00071 
00072         GLWSelector::instance()->showSelector(
00073                 this, x, y, entries,
00074                 ClientState::StatePlaying);
00075 }
00076 
00077 void TankUndoMenu::itemSelected(GLWSelectorEntry *entry, int position)
00078 {
00079         tank_->getPosition().revertSettings((unsigned long) entry->getUserData());
00080 }
00081 
00082 TankFuelTip::TankFuelTip(Tank *tank) : 
00083         tank_(tank)
00084 {
00085 }
00086 
00087 TankFuelTip::~TankFuelTip()
00088 {
00089 }
00090 
00091 void TankFuelTip::populate()
00092 {
00093         LangString fuelCount = LANG_RESOURCE("OFF", "Off");
00094         Accessory *weapon = tank_->getAccessories().getWeapons().getCurrent();
00095         if (weapon &&
00096                 weapon->getPositionSelect() == Accessory::ePositionSelectFuel)
00097         {
00098                  fuelCount = tank_->getAccessories().getAccessoryAndCountString(weapon);
00099         }
00100 
00101         setText(ToolTip::ToolTipHelp, 
00102                 LANG_RESOURCE("FUEL", "Fuel"), 
00103                 LANG_RESOURCE("FUEL_TOOLTIP",
00104                 "Allows the tank to move.\n"
00105                 "Click to toggle movement mode.\n"
00106                 "Current Fuel : ") + fuelCount);
00107 }
00108 
00109 void TankFuelTip::showItems(float x, float y)
00110 {
00111         static ToolTip offTip(ToolTip::ToolTipHelp, 
00112                 LANG_RESOURCE("FUEL_OFF", "Fuel Off"), 
00113                 LANG_RESOURCE("FUEL_OFF_TOOLTIP", 
00114                 "Don't select fuel or\n"
00115                 "turn off any fuel."));
00116 
00117         std::list<GLWSelectorEntry> entries;
00118         std::list<Accessory *> &fuels =
00119                 tank_->getAccessories().getAllAccessoriesByGroup("fuel");
00120         ScorchedClient::instance()->getAccessoryStore().sortList(
00121                 fuels,
00122                 OptionsDisplay::instance()->getAccessorySortKey());
00123         std::list<Accessory *>::iterator itor;
00124         for (itor = fuels.begin();
00125                 itor != fuels.end();
00126                 itor++)
00127         {
00128                 Accessory *current = (*itor);
00129                 if (tank_->getAccessories().canUse(current))
00130                 {
00131                         entries.push_back(GLWSelectorEntry(
00132                                 tank_->getAccessories().getAccessoryAndCountString(current), 
00133                                 &current->getToolTip(), 
00134                                 (tank_->getAccessories().getWeapons().getCurrent() == current), 
00135                                 current->getTexture(), current));
00136                 }
00137         }
00138         entries.push_back(GLWSelectorEntry(LANG_RESOURCE("OFF", "Off"), &offTip, 0, 0, 0));
00139         GLWSelector::instance()->showSelector(this, x, y, entries,
00140                 ClientState::StatePlaying);
00141 }
00142 
00143 void TankFuelTip::itemSelected(GLWSelectorEntry *entry, int position)
00144 {
00145         Accessory *accessory = ((Accessory *)entry->getUserData());
00146         if (accessory)
00147         {
00148                 tank_->getAccessories().getWeapons().setWeapon(accessory);
00149         }
00150         else
00151         {
00152                 std::list<Accessory *> &entries =
00153                         tank_->getAccessories().getAllAccessoriesByGroup("weapon");
00154                 if (!entries.empty())
00155                 {
00156                         tank_->getAccessories().getWeapons().setWeapon(entries.front());
00157                 }
00158                 else
00159                 {
00160                         tank_->getAccessories().getWeapons().setWeapon(0);
00161                 }
00162         }
00163 }
00164 
00165 TankBatteryTip::TankBatteryTip(Tank *tank) : 
00166         tank_(tank)
00167 {
00168 }
00169 
00170 TankBatteryTip::~TankBatteryTip()
00171 {
00172 }
00173 
00174 void TankBatteryTip::populate()
00175 {
00176         LangString batteryCount = LANG_RESOURCE("INF", "Inf");
00177 
00178         int count = tank_->getAccessories().getBatteries().getNoBatteries();
00179         if (count >= 0)
00180         {
00181                 batteryCount = LANG_STRING(S3D::formatStringBuffer("%i", count));
00182         }
00183 
00184         setText(ToolTip::ToolTipHelp, 
00185                 LANG_RESOURCE("BATTERIES", "Batteries"),
00186                 LANG_RESOURCE("BATTERIES_TOOLTIP", 
00187                 "Can be used to recharge life.\n"
00188                 "Each battery gives back 10 life.\n"
00189                 "Click to use some battery(s).\n"
00190                 "Batteries : ") + batteryCount);
00191 }
00192 
00193 void TankBatteryTip::showItems(float x, float y)
00194 {
00195         static ToolTip useTip(ToolTip::ToolTipHelp, 
00196                 LANG_RESOURCE("BATTERY", "Battery"), 
00197                 LANG_RESOURCE("BATTERY_TOOLTIP", "Use some batteries"));
00198         static ToolTip offTip(ToolTip::ToolTipHelp, 
00199                 LANG_RESOURCE("BATTERY_CANCEL", "Battery Cancel"), 
00200                 LANG_RESOURCE("BATTERY_CANCEL_TOOLTIP", "Don't use any batteries"));
00201         
00202         int count = tank_->getAccessories().getBatteries().getNoBatteries();
00203         if (count == -1) count = 10;
00204 
00205         std::list<GLWSelectorEntry> entries;
00206         if (tank_->getAccessories().getBatteries().canUse())
00207         {
00208                 for (int i=1; i<=MIN(count,10); i++)
00209                 {
00210                         entries.push_back(GLWSelectorEntry(
00211                                 LANG_RESOURCE_1("USE_I", "Use {0}", S3D::formatStringBuffer("%i", i)), 
00212                                 &useTip, 0, 0, (void *) i));
00213                 }
00214         }
00215         entries.push_back(GLWSelectorEntry(LANG_RESOURCE("CANCEL", "Cancel"), &offTip, 0, 0, (void *) 0));
00216         GLWSelector::instance()->showSelector(this, x, y, entries,
00217                 ClientState::StatePlaying);             
00218 }
00219 
00220 void TankBatteryTip::itemSelected(GLWSelectorEntry *entry, int position)
00221 {
00222         for (int i=1; i<=(long) entry->getUserData(); i++)
00223         {
00224                 if (tank_->getLife().getLife() < 
00225                         tank_->getLife().getMaxLife())
00226                 {
00227                         std::list<Accessory *> &entries =
00228                                 tank_->getAccessories().getAllAccessoriesByType(
00229                                         AccessoryPart::AccessoryBattery);
00230                         if (!entries.empty())
00231                         {
00232 
00233                                 TankKeyboardControlUtil::useBattery(tank_,
00234                                         entries.front()->getAccessoryId());
00235                         }
00236                 }
00237         }
00238 }
00239 
00240 TankShieldTip::TankShieldTip(Tank *tank) : 
00241         tank_(tank)
00242 {
00243 }
00244 
00245 TankShieldTip::~TankShieldTip()
00246 {
00247 }
00248 
00249 void TankShieldTip::showItems(float x, float y)
00250 {
00251         static ToolTip offTip(ToolTip::ToolTipHelp, 
00252                 LANG_RESOURCE("SHIELD_OFF", "Shield Off"), 
00253                 LANG_RESOURCE("SHIELD_OFF_TOOLTIP", 
00254                 "Don't select a shield or\n"
00255                 "turn off any current shield"));
00256 
00257         Accessory *currentShield = 
00258                 tank_->getShield().getCurrentShield();
00259         std::list<GLWSelectorEntry> entries;
00260         std::list<Accessory *> &shields = 
00261                 tank_->getAccessories().getAllAccessoriesByType(
00262                         AccessoryPart::AccessoryShield);
00263         ScorchedClient::instance()->getAccessoryStore().sortList(
00264                 shields, 
00265                 OptionsDisplay::instance()->getAccessorySortKey());
00266         std::list<Accessory *>::iterator itor;
00267         for (itor = shields.begin();
00268                 itor != shields.end();
00269                 itor++)
00270         {
00271                 Accessory *current = (*itor);
00272                 if (tank_->getAccessories().canUse(current))
00273                 {
00274                         entries.push_back(GLWSelectorEntry(
00275                                 tank_->getAccessories().getAccessoryAndCountString(current), 
00276                                 &current->getToolTip(), 
00277                                 (currentShield == current), current->getTexture(), current));
00278                 }
00279         }
00280         entries.push_back(GLWSelectorEntry(LANG_RESOURCE("OFF", "Off"), &offTip, 0, 0, 0));
00281         GLWSelector::instance()->showSelector(this, x, y, entries,
00282                 ClientState::StatePlaying);
00283 }
00284 
00285 void TankShieldTip::populate()
00286 {
00287         LangString shieldsCount = LANG_RESOURCE("OFF", "Off");
00288 
00289         if (tank_->getShield().getCurrentShield())
00290         {
00291                 char buffer[128];
00292                 int count = tank_->getAccessories().getAccessoryCount(
00293                         tank_->getShield().getCurrentShield());
00294                 if (count >= 0) snprintf(buffer, 128, "%i", count);
00295                 else snprintf(buffer, 128, "Infinite");
00296 
00297                 shieldsCount = tank_->getAccessories().getAccessoryAndCountString(
00298                         tank_->getShield().getCurrentShield());
00299                 shieldsCount.append(LANG_STRING("\n"));
00300                 shieldsCount.append(
00301                         LANG_RESOURCE_1("SHIELD_POWER", "Shield Power : {0}", 
00302                         S3D::formatStringBuffer("%.0f", tank_->getShield().getShieldPower().asFloat())));
00303         }
00304 
00305         setText(ToolTip::ToolTipHelp, 
00306                 LANG_RESOURCE("SHIELDS", "Shields"), 
00307                 LANG_RESOURCE("SHIELDS_TOOLTIP",
00308                 "Protect the tank from taking shot damage.\n"
00309                 "Shields must be enabled before they take\n"
00310                 "effect.\n"
00311                 "Click to enable/disable shields.\n"
00312                 "Current Shield : ") + shieldsCount);
00313 }
00314 
00315 void TankShieldTip::itemSelected(GLWSelectorEntry *entry, int position)
00316 {
00317         if (entry->getUserData() == 0) 
00318                 TankKeyboardControlUtil::shieldsUpDown(tank_, 0);
00319         else 
00320                 TankKeyboardControlUtil::shieldsUpDown(tank_,
00321                         ((Accessory *)entry->getUserData())->getAccessoryId());
00322 }
00323 
00324 TankRankTip::TankRankTip(Tank *tank) : 
00325         tank_(tank)
00326 {
00327 }
00328 
00329 TankRankTip::~TankRankTip()
00330 {
00331 }
00332 
00333 void TankRankTip::populate()
00334 {
00335         setText(ToolTip::ToolTipHelp, 
00336                 LANG_RESOURCE("RANK", "Rank"),
00337                 LANG_RESOURCE("RANK_TOOLTIP",
00338                 "The current online ranking of this player"));
00339 }
00340 
00341 TankHealthTip::TankHealthTip(Tank *tank) : 
00342         tank_(tank)
00343 {
00344 }
00345 
00346 TankHealthTip::~TankHealthTip()
00347 {
00348 }
00349 
00350 void TankHealthTip::populate()
00351 {
00352         setText(ToolTip::ToolTipHelp, 
00353                 LANG_RESOURCE("LIFE", "Life"),
00354                 LANG_RESOURCE_2("LIFE_TOOLTIP",
00355                 "The amount of life this player has.\n"
00356                 "The tank explodes when life reaches 0.\n"
00357                 "Less weapon power is available with less life.\n"
00358                 "Life : {0}/{1}",
00359                 S3D::formatStringBuffer("%.0f", tank_->getLife().getLife().asFloat()),
00360                 S3D::formatStringBuffer("%.0f", tank_->getLife().getMaxLife().asFloat())));
00361 }
00362 
00363 TankParachutesTip::TankParachutesTip(Tank *tank) : 
00364         tank_(tank)
00365 {
00366 }
00367 
00368 TankParachutesTip::~TankParachutesTip()
00369 {
00370 }
00371 
00372 void TankParachutesTip::populate()
00373 {
00374         LangString parachuteCount = LANG_RESOURCE("OFF", "Off");
00375 
00376         if (tank_->getParachute().getCurrentParachute())
00377         {
00378                 parachuteCount = tank_->getAccessories().getAccessoryAndCountString(
00379                         tank_->getParachute().getCurrentParachute());
00380         }
00381 
00382         setText(ToolTip::ToolTipHelp, 
00383                 LANG_RESOURCE("PARACHUTES", "Parachutes"), 
00384                 LANG_RESOURCE("PARACHUTES_TOOLTIP", 
00385                 "Prevents the tank from taking damage\n"
00386                 "when falling.  Must be enabled before\n"
00387                 "they take effect.\n"
00388                 "Click to enable/disable parachutes.\n"
00389                 "Current Parachute : ") + parachuteCount);
00390 }
00391 
00392 void TankParachutesTip::showItems(float x, float y)
00393 {
00394         static ToolTip offTip(ToolTip::ToolTipHelp, 
00395                 LANG_RESOURCE("PARACHUTES_OFF", "Parachutes Off"), 
00396                 LANG_RESOURCE("PARACHUTES_OFF_TOOLTIP", 
00397                 "Don't select a parachute or\n"
00398                 "turn off any current parachute"));
00399 
00400         Accessory *currentParachute = 
00401                 tank_->getParachute().getCurrentParachute();
00402         std::list<GLWSelectorEntry> entries;
00403         std::list<Accessory *> &parachutes =
00404                 tank_->getAccessories().getAllAccessoriesByType(
00405                         AccessoryPart::AccessoryParachute);
00406         ScorchedClient::instance()->getAccessoryStore().sortList(
00407                 parachutes, 
00408                 OptionsDisplay::instance()->getAccessorySortKey());
00409 
00410         std::list<Accessory *>::iterator itor;
00411         for (itor = parachutes.begin();
00412                 itor != parachutes.end();
00413                 itor++)
00414         {
00415                 Accessory *current = (*itor);
00416                 if (tank_->getAccessories().canUse(*itor))
00417                 {
00418                         entries.push_back(GLWSelectorEntry(
00419                                 tank_->getAccessories().getAccessoryAndCountString(current), 
00420                                 &current->getToolTip(), 
00421                                 (currentParachute == current), current->getTexture(), current));
00422                 }
00423         }
00424         entries.push_back(GLWSelectorEntry(LANG_RESOURCE("OFF", "Off"), &offTip, 0, 0, 0));
00425         GLWSelector::instance()->showSelector(this, x, y, entries,
00426                 ClientState::StatePlaying);
00427 }
00428 
00429 void TankParachutesTip::itemSelected(GLWSelectorEntry *entry, int position)
00430 {
00431         if (entry->getUserData() == 0) 
00432                 TankKeyboardControlUtil::parachutesUpDown(tank_, 0);
00433         else 
00434                 TankKeyboardControlUtil::parachutesUpDown(tank_,
00435                 ((Accessory *)entry->getUserData())->getAccessoryId());
00436 }
00437 
00438 TankAutoDefenseTip::TankAutoDefenseTip(Tank *tank) : 
00439         tank_(tank)
00440 {
00441 }
00442 
00443 TankAutoDefenseTip::~TankAutoDefenseTip()
00444 {
00445 }
00446 
00447 void TankAutoDefenseTip::populate()
00448 {
00449         LangString status = 
00450                 tank_->getAccessories().getAutoDefense().haveDefense()?
00451                 LANG_RESOURCE("ON", "On"):
00452                 LANG_RESOURCE("OFF_NOT_BOUGHT", "Off (Not Bought)");
00453 
00454 
00455         setText(ToolTip::ToolTipHelp, 
00456                 LANG_RESOURCE("AUTO_DEFENSE", "Auto Defense"), 
00457                 LANG_RESOURCE("AUTO_DEFENSE_TOOLTIP",
00458                         "Allows the tank to raise shields and\n"
00459                         "activate parachutes before the round\n"
00460                         "starts.\n"
00461                         "Click to see auto defense status.\n"
00462                         "Status : ") + status);
00463 }
00464 
00465 void TankAutoDefenseTip::showItems(float x, float y)
00466 {
00467         static ToolTip useTip(ToolTip::ToolTipHelp, 
00468                 LANG_RESOURCE("AUTO_DEFENSE_ON", "Auto Defense On"), 
00469                 LANG_RESOURCE("AUTO_DEFENSE_ENABLE", "Enable the auto defense."));
00470         static ToolTip offTip(ToolTip::ToolTipHelp, 
00471                 LANG_RESOURCE("AUTO_DEFENSE_OFF", "Auto Defense Off"), 
00472                 LANG_RESOURCE("AUTO_DEFENSE_DISABLE", "Disable the auto defense."));
00473         
00474         std::list<GLWSelectorEntry> entries;
00475         if (tank_->getAccessories().getAutoDefense().haveDefense()) 
00476                 entries.push_back(GLWSelectorEntry(LANG_RESOURCE("ON", "On"), &useTip));
00477         else entries.push_back(GLWSelectorEntry(LANG_RESOURCE("OFF", "Off"), &offTip));
00478         GLWSelector::instance()->showSelector(0, x, y, entries,
00479                 ClientState::StatePlaying);
00480 }
00481 
00482 TankWeaponTip::TankWeaponTip(Tank *tank) : 
00483         tank_(tank)
00484 {
00485 }
00486 
00487 TankWeaponTip::~TankWeaponTip()
00488 {
00489 }
00490 
00491 void TankWeaponTip::populate()
00492 {
00493         LangString weapon = LANG_RESOURCE("NONE", "None");
00494         if (tank_->getAccessories().getWeapons().getCurrent())
00495         {
00496                 weapon = tank_->getAccessories().getAccessoryAndCountString(
00497                         tank_->getAccessories().getWeapons().getCurrent());
00498                 weapon.append(LANG_STRING("\n"));
00499                 weapon.append(LANG_RESOURCE_1("DESCRIPTION", "Description : {0}", 
00500                         tank_->getAccessories().getWeapons().getCurrent()->getDescription()));
00501         }
00502 
00503         setText(ToolTip::ToolTipHelp, 
00504                 LANG_RESOURCE("WEAPON", "Weapon"), 
00505                 LANG_RESOURCE("WEAPON_TOOLTIP", 
00506                 "The currently selected weapon.\n"
00507                 "Click to change weapon.\n"
00508                 "Weapon : ") + weapon);
00509 }
00510 
00511 void TankWeaponTip::showItems(float x, float y)
00512 {
00513         std::list<GLWSelectorEntry> entries;
00514 
00515         Accessory *currentWeapon = 
00516                 tank_->getAccessories().getWeapons().getCurrent();
00517         std::list<Accessory *> &weapons =
00518                 tank_->getAccessories().getAllAccessoriesByGroup("weapon");
00519         ScorchedClient::instance()->getAccessoryStore().sortList(
00520                 weapons,
00521                 OptionsDisplay::instance()->getAccessorySortKey());
00522         std::list<Accessory *>::iterator itor;
00523         for (itor = weapons.begin();
00524                 itor != weapons.end();
00525                 itor++)
00526         {
00527                 Accessory *weapon = (*itor);
00528                 if (tank_->getAccessories().canUse(weapon))
00529                 {
00530                         GLWSelectorEntry newEntry(
00531                                 tank_->getAccessories().getAccessoryAndCountString(weapon), 
00532                                 &weapon->getToolTip(), 
00533                                 (currentWeapon == weapon), weapon->getTexture(), weapon);
00534                         entries.push_back(newEntry);
00535                 }
00536         }
00537         GLWSelector::instance()->showSelector(this, x, y, entries,
00538                 ClientState::StatePlaying);
00539 }
00540 
00541 void TankWeaponTip::itemSelected(GLWSelectorEntry *entry, int position)
00542 {
00543         tank_->getAccessories().getWeapons().setWeapon((Accessory *) entry->getUserData());
00544 }
00545 
00546 TankPowerTip::TankPowerTip(Tank *tank) : 
00547         tank_(tank)
00548 {
00549 }
00550 
00551 TankPowerTip::~TankPowerTip()
00552 {
00553 }
00554 
00555 void TankPowerTip::populate()
00556 {
00557         {
00558                 setText(ToolTip::ToolTipHelp, 
00559                         LANG_RESOURCE("POWER", "Power"), 
00560                         LANG_RESOURCE_1("POWER_TOOLTIP", 
00561                         "The power used to fire the current weapon.\n"
00562                         "Click to revert back to previous settings.\n"
00563                         "Power : {0}",
00564                         tank_->getPosition().getPowerString()));
00565         }
00566 }
00567 
00568 TankRotationTip::TankRotationTip(Tank *tank) : 
00569         tank_(tank)
00570 {
00571 }
00572 
00573 TankRotationTip::~TankRotationTip()
00574 {
00575 }
00576 
00577 void TankRotationTip::populate()
00578 {
00579         setText(ToolTip::ToolTipHelp, 
00580                 LANG_RESOURCE("ROTATION", "Rotation"), 
00581                 LANG_RESOURCE_1("ROTATION_TOOLTIP", 
00582                 "The rotation of the current player's tank turret.\n"
00583                 "Click to revert back to previous settings.\n"
00584                 "Rotation : {0}",
00585                 tank_->getPosition().getRotationString()));
00586 }
00587 
00588 TankElevationTip::TankElevationTip(Tank *tank) : 
00589         tank_(tank)
00590 {
00591 }
00592 
00593 TankElevationTip::~TankElevationTip()
00594 {
00595 }
00596 
00597 void TankElevationTip::populate()
00598 {
00599         setText(ToolTip::ToolTipHelp, 
00600                 LANG_RESOURCE("ELEVATION", "Elevation"), 
00601                 LANG_RESOURCE_1("ELEVATION_TOOLTIP", 
00602                 "The elevation of the current player's gun.\n"
00603                 "Click to revert back to previous settings.\n"
00604                 "Elevation : {0}",
00605                 tank_->getPosition().getElevationString()));
00606 }
00607 
00608 static void generateTargetTip(LangString &tip, Target *target)
00609 {
00610         tip.append(LANG_RESOURCE_2("TARGET_LIFE", "Life   : {0}/{1}",
00611                 S3D::formatStringBuffer("%.0f", target->getLife().getLife().asFloat()),
00612                 S3D::formatStringBuffer("%.0f", target->getLife().getMaxLife().asFloat())));
00613 
00614         if (target->getShield().getCurrentShield())
00615         {
00616                 Shield *shield = (Shield*) 
00617                         target->getShield().getCurrentShield()->getAction();
00618 
00619                 tip.append(LANG_RESOURCE_2("TARGET_SHIELD", "\nShield   : {0}/{1}",
00620                         S3D::formatStringBuffer("%.0f", target->getShield().getShieldPower().asFloat()),
00621                         S3D::formatStringBuffer("%.0f", shield->getPower().asFloat())));
00622         }
00623         if (!target->isTarget())
00624         {
00625                 Tank *tank = (Tank *) target;
00626 
00627                 if (tank->getState().getState() != TankState::sNormal)
00628                 {
00629                         tip.append(LANG_RESOURCE_1("TARGET_STATE",
00630                                 "\nState : {0}",
00631                                 tank->getState().getSmallStateString()));;
00632                 }
00633 
00634                 tip.append(LANG_RESOURCE_2("TARGET_LIVES", "\nLives   : {0}/{1}",
00635                         S3D::formatStringBuffer("%i", tank->getState().getLives()),
00636                         S3D::formatStringBuffer("%i", tank->getState().getMaxLives())));
00637 
00638                 tip.append(LANG_RESOURCE_1("TARGET_SCORE", "\nScore   : {0}",
00639                         S3D::formatStringBuffer("%i", tank->getScore().getScore())));
00640         }
00641 }
00642 
00643 TankTip::TankTip(Tank *tank) : 
00644         tank_(tank)
00645 {
00646 }
00647 
00648 TankTip::~TankTip()
00649 {
00650 }
00651 
00652 void TankTip::populate()
00653 {
00654         LangString tip;
00655         generateTargetTip(tip, tank_);
00656 
00657         if (tank_->getScore().getSkill() > 0)
00658         {
00659                 tip.append(LANG_RESOURCE_2("TANK_SKILL", "\nSkill   : {0} ({1})",
00660                         S3D::formatStringBuffer("%i", tank_->getScore().getSkill()),
00661                         S3D::formatStringBuffer("%i", tank_->getScore().getStartSkill())));
00662         }
00663 
00664         if (tank_->getScore().getRank() > 0) 
00665         {
00666                 tip.append(LANG_RESOURCE_1("TANK_RANK",  "\nRank    : {0}",
00667                         S3D::formatStringBuffer("%i", tank_->getScore().getRank())));
00668         }
00669 
00670         setText(ToolTip::ToolTipInfo, tank_->getTargetName(), tip.c_str());
00671 }
00672 
00673 TargetTip::TargetTip(Target *target) : 
00674         target_(target)
00675 {
00676 }
00677 
00678 TargetTip::~TargetTip()
00679 {
00680 }
00681 
00682 void TargetTip::populate()
00683 {
00684         LangString tip;
00685         generateTargetTip(tip, target_);
00686         setText(ToolTip::ToolTipInfo, target_->getTargetName(), tip);
00687 }
00688 
00689 GLWTargetTips::GLWTargetTips(Target *target) : 
00690         targetTip(target)
00691 {
00692 }
00693 
00694 GLWTargetTips::~GLWTargetTips()
00695 {
00696 }
00697 
00698 GLWTankTips::GLWTankTips(Tank *tank) : 
00699         tankTip(tank),
00700         undoMenu(tank),
00701         rotationTip(tank),
00702         elevationTip(tank),
00703         powerTip(tank),
00704         weaponTip(tank),
00705         autodTip(tank),
00706         paraTip(tank),
00707         healthTip(tank),
00708         shieldTip(tank),
00709         batteryTip(tank),
00710         fuelTip(tank),
00711         rankTip(tank),
00712         nameTip(ToolTip::ToolTipHelp, 
00713                 LANG_RESOURCE("PLAYER_NAME", "Player Name"),
00714                 LANG_RESOURCE("PLAYER_CURRENTLY_PLAYING", 
00715                 "Shows the name of the player currently\n"
00716                 "making their move."))
00717 {
00718 }
00719 
00720 GLWTankTips::~GLWTankTips()
00721 {
00722 }
00723 

Generated on Mon Feb 16 15:14:46 2009 for Scorched3D by  doxygen 1.5.3