X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fgui%2Fmousecursor.cpp;h=3a873216128d2ffe8ad9386fedfb9e32e18bb0d4;hb=c13404a6b6a97ad0d5e1c9f905d7a7e37b797c13;hp=bd3ff525b67b0a300a3bfb1cf9ef92ab2a978b31;hpb=c0093d25093395cb62fc2526ab42be65a9f015b8;p=supertux.git diff --git a/src/gui/mousecursor.cpp b/src/gui/mousecursor.cpp index bd3ff525b..3a8732161 100644 --- a/src/gui/mousecursor.cpp +++ b/src/gui/mousecursor.cpp @@ -1,7 +1,7 @@ // $Id$ // -// SuperTux - A Jump'n Run -// Copyright (C) 2004 Ricardo Cruz +// SuperTux +// Copyright (C) 2006 Matthias Braun // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -19,34 +19,28 @@ #include -#include "app/globals.h" -#include "video/drawing_context.h" -#include "gui/mousecursor.h" +#include "gui/mousecursor.hpp" -using namespace SuperTux; +#include +#include + +#include "video/surface.hpp" +#include "video/drawing_context.hpp" +#include "main.hpp" MouseCursor* MouseCursor::current_ = 0; extern SDL_Surface* screen; -MouseCursor::MouseCursor(std::string cursor_file, int frames) : mid_x(0), mid_y(0) +MouseCursor::MouseCursor(std::string cursor_file) : mid_x(0), mid_y(0) { - cursor = new Surface(cursor_file, true); - - cur_state = MC_NORMAL; - cur_frame = 0; - tot_frames = frames; + cursor = new Surface(cursor_file); - timer.init(false); - timer.start(MC_FRAME_PERIOD); - - SDL_ShowCursor(SDL_DISABLE); + cur_state = MC_NORMAL; } MouseCursor::~MouseCursor() { delete cursor; - - SDL_ShowCursor(SDL_ENABLE); } int MouseCursor::state() @@ -76,31 +70,18 @@ void MouseCursor::draw(DrawingContext& context) x = int(x * float(SCREEN_WIDTH)/screen->w); y = int(y * float(SCREEN_HEIGHT)/screen->h); - w = cursor->w / tot_frames; - h = cursor->h / MC_STATES_NB; - if(ispressed &SDL_BUTTON(1) || ispressed &SDL_BUTTON(2)) - { - if(cur_state != MC_CLICK) - { - state_before_click = cur_state; - cur_state = MC_CLICK; - } - } - else - { - if(cur_state == MC_CLICK) - cur_state = state_before_click; - } - - if(timer.get_left() < 0 && tot_frames > 1) - { - cur_frame++; - if(cur_frame++ >= tot_frames) - cur_frame = 0; - - timer.start(MC_FRAME_PERIOD); + w = (int) cursor->get_width(); + h = (int) (cursor->get_height() / MC_STATES_NB); + if(ispressed &SDL_BUTTON(1) || ispressed &SDL_BUTTON(2)) { + if(cur_state != MC_CLICK) { + state_before_click = cur_state; + cur_state = MC_CLICK; } + } else { + if(cur_state == MC_CLICK) + cur_state = state_before_click; + } - context.draw_surface_part(cursor, Vector(w*cur_frame, h*cur_state), Vector(w, - h), Vector(x-mid_x, y-mid_y), LAYER_GUI+100); + context.draw_surface_part(cursor, Vector(0, h*cur_state), + Vector(w, h), Vector(x-mid_x, y-mid_y), LAYER_GUI+100); }