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/GLWTankSlider.h> 00022 #include <GLW/GLWFont.h> 00023 #include <GLEXT/GLState.h> 00024 #include <common/Keyboard.h> 00025 #include <common/ToolTipResource.h> 00026 #include <client/ScorchedClient.h> 00027 #include <tank/TankContainer.h> 00028 #include <tank/TankState.h> 00029 #include <tank/TankPosition.h> 00030 #include <lang/LangResource.h> 00031 00032 REGISTER_CLASS_SOURCE(GLWTankSlider); 00033 00034 GLWTankSlider::GLWTankSlider() : 00035 GLWDragger(0.0f, 0.0f, 0.0f, 100.0f) 00036 { 00037 setHandler(this); 00038 setToolTip(new ToolTipResource(ToolTip::ToolTipHelp, 00039 "POWER", "Power", 00040 "POWER_CHANGE_TOOLTIP", 00041 "Change the power of the current tank\n" 00042 "by clicking with the left mouse button\n" 00043 "and dragging up and down.\n" 00044 "Shift key decreases sensitivity.")); 00045 } 00046 00047 GLWTankSlider::~GLWTankSlider() 00048 { 00049 } 00050 00051 void GLWTankSlider::draw() 00052 { 00053 Tank *currentTank = 00054 ScorchedClient::instance()->getTankContainer().getCurrentTank(); 00055 if (currentTank) 00056 { 00057 if (currentTank->getState().getState() == TankState::sNormal) 00058 { 00059 setCurrent(currentTank->getPosition().getPower().asFloat()); 00060 } 00061 } 00062 00063 GLWDragger::draw(); 00064 } 00065 00066 void GLWTankSlider::currentChanged(unsigned int id, float value) 00067 { 00068 Tank *currentTank = 00069 ScorchedClient::instance()->getTankContainer().getCurrentTank(); 00070 if (currentTank) 00071 { 00072 if (currentTank->getState().getState() == TankState::sNormal) 00073 { 00074 if (id == getId()) 00075 { 00076 currentTank->getPosition().changePower( 00077 fixed::fromFloat(value), false); 00078 } 00079 } 00080 } 00081 }
1.5.3