00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <graph/SoftwareMouse.h>
00022 #include <client/ScorchedClient.h>
00023 #include <engine/GameState.h>
00024 #include <image/ImageFactory.h>
00025 #include <GLEXT/GLState.h>
00026 #include <common/Defines.h>
00027 #include <graph/OptionsDisplay.h>
00028 #include <SDL/SDL.h>
00029
00030 SoftwareMouse *SoftwareMouse::instance_ = 0;
00031
00032 SoftwareMouse *SoftwareMouse::instance()
00033 {
00034 if (!instance_)
00035 {
00036 instance_ = new SoftwareMouse;
00037 }
00038 return instance_;
00039 }
00040
00041 SoftwareMouse::SoftwareMouse() :
00042 GameStateI("SoftwareMouse")
00043 {
00044 }
00045
00046 SoftwareMouse::~SoftwareMouse()
00047 {
00048 }
00049
00050 void SoftwareMouse::draw(const unsigned currentstate)
00051 {
00052 if (!OptionsDisplay::instance()->getSoftwareMouse()) return;
00053
00054 static bool createdTexture = false;
00055 if (!createdTexture)
00056 {
00057 createdTexture = true;
00058 std::string file1 = S3D::getDataFile("data/windows/pointer.bmp");
00059 std::string file2 = S3D::getDataFile("data/windows/pointera.bmp");
00060 ImageHandle map = ImageFactory::loadImageHandle(file1.c_str(), file2.c_str());
00061 mouseTex_.create(map, false);
00062
00063 SDL_ShowCursor(SDL_DISABLE);
00064 }
00065
00066 GLState state(GLState::BLEND_ON | GLState::TEXTURE_ON | GLState::DEPTH_OFF);
00067
00068 int mouseX = ScorchedClient::instance()->getGameState().getMouseX();
00069 int mouseY = ScorchedClient::instance()->getGameState().getMouseY();
00070
00071 mouseTex_.draw();
00072 glPushMatrix();
00073 glTranslatef(float(mouseX), float(mouseY), 0.0f);
00074 glColor3f(1.0f, 1.0f, 1.0f);
00075
00076 glScalef(2.0f, 2.0f, 2.0f);
00077
00078 glTranslatef(0.0f, -16.0f, 0.0f);
00079 glBegin(GL_QUADS);
00080 glTexCoord2f(0.0f, 0.0f);
00081 glVertex2f(0.0f, 0.0f);
00082 glTexCoord2f(1.0f, 0.0f);
00083 glVertex2f(16.0f, 0.0f);
00084 glTexCoord2f(1.0f, 1.0f);
00085 glVertex2f(16.0f, 16.0f);
00086 glTexCoord2f(0.0f, 1.0f);
00087 glVertex2f(0.0f, 16.0f);
00088 glEnd();
00089 glPopMatrix();
00090 }
00091