00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <GLW/GLWTankFire.h>
00022 #include <client/ScorchedClient.h>
00023 #include <tankgraph/TankKeyboardControlUtil.h>
00024 #include <common/ToolTipResource.h>
00025 #include <lang/LangResource.h>
00026 #include <tank/TankContainer.h>
00027 #include <tank/TankState.h>
00028
00029 REGISTER_CLASS_SOURCE(GLWTankFire);
00030
00031 GLWTankFire::GLWTankFire() :
00032 GLWidget(0.0f, 0.0f, 0.0f, 0.0f)
00033 {
00034 setToolTip(new ToolTipResource(ToolTip::ToolTipHelp,
00035 "FIRE_CURRENT_WEAPON", "Fire Current Weapon",
00036 "FIRE_CURRENT_WEAPON_TOOLTIP",
00037 "Fires the current tanks currently selected\n"
00038 "weapon."));
00039 }
00040
00041 GLWTankFire::~GLWTankFire()
00042 {
00043
00044 }
00045
00046 void GLWTankFire::mouseDown(int button, float x, float y, bool &skipRest)
00047 {
00048 if (inBox(x, y, x_, y_, w_, h_))
00049 {
00050 dragging_ = true;
00051 }
00052 }
00053
00054 void GLWTankFire::mouseUp(int button, float x, float y, bool &skipRest)
00055 {
00056 if (dragging_)
00057 {
00058 if (inBox(x, y, x_, y_, w_, h_))
00059 {
00060 Tank *currentTank =
00061 ScorchedClient::instance()->getTankContainer().getCurrentTank();
00062 if (currentTank)
00063 {
00064 if (currentTank->getState().getState() ==
00065 TankState::sNormal)
00066 {
00067 TankKeyboardControlUtil::fireShot(currentTank);
00068 }
00069 }
00070 }
00071 }
00072 dragging_ = false;
00073 }
00074