projects
/
supertux.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix for bug #436 - just clear last_menus when set_current(NULL) is called
[supertux.git]
/
src
/
gui
/
button.cpp
diff --git
a/src/gui/button.cpp
b/src/gui/button.cpp
index
2f4580a
..
6288665
100644
(file)
--- a/
src/gui/button.cpp
+++ b/
src/gui/button.cpp
@@
-1,7
+1,7
@@
// $Id$
// $Id$
-//
+//
// SuperTux
// SuperTux
-// Copyright (C) 200
5
Matthias Braun <matze@braunis.de>
+// Copyright (C) 200
6
Matthias Braun <matze@braunis.de>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@
-12,21
+12,23
@@
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
-//
+//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-// 02111-1307, USA.
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
+
#include <config.h>
#include <config.h>
-#include "SDL.h"
+#include "button.hpp"
+
+#include <SDL.h>
#include <iostream>
#include <iostream>
-#include "main.h"
-#include "
button.h
"
-#include "
mousecursor.h
"
-#include "video/
font.h
"
-#include "video/
surface.h
"
+#include "main.h
pp
"
+#include "
mousecursor.hpp
"
+#include "
video/font.hpp
"
+#include "video/
surface.hpp
"
+#include "video/
drawing_context.hpp
"
Font* Button::info_font = 0;
extern SDL_Surface* screen;
Font* Button::info_font = 0;
extern SDL_Surface* screen;
@@
-37,7
+39,7
@@
Button::Button(Surface* image_, std::string info_, SDLKey binding_)
: binding(binding_)
{
image = image_;
: binding(binding_)
{
image = image_;
- size = Vector(image->
w, image->h
);
+ size = Vector(image->
get_width(), image->get_height()
);
id = 0;
info = info_;
}
id = 0;
info = info_;
}
@@
-61,13
+63,13
@@
if(state == BT_SHOW_INFO)
offset = Vector(size.x, - 10);
else if(pos.x + tanslation.x < 100)
offset = Vector(size.x, 0);
offset = Vector(size.x, - 10);
else if(pos.x + tanslation.x < 100)
offset = Vector(size.x, 0);
- else
+ else
offset = Vector(-30, -size.y/2);
offset = Vector(-30, -size.y/2);
- context.draw_text(info_font, info, pos + offset,
LEFT_ALLIGN
, LAYER_GUI+2);
+ context.draw_text(info_font, info, pos + offset,
ALIGN_LEFT
, LAYER_GUI+2);
if(binding != 0)
context.draw_text(info_font, "(" + std::string(SDL_GetKeyName(binding)) +
")", pos + offset + Vector(0,12),
if(binding != 0)
context.draw_text(info_font, "(" + std::string(SDL_GetKeyName(binding)) +
")", pos + offset + Vector(0,12),
-
LEFT_ALLIGN
, LAYER_GUI+2);
+
ALIGN_LEFT
, LAYER_GUI+2);
}
context.draw_surface_part(image, Vector(0,0), size, pos, LAYER_GUI+1);
}
context.draw_surface_part(image, Vector(0,0), size, pos, LAYER_GUI+1);
@@
-94,7
+96,7
@@
switch(event.type)
state = BT_SELECTED;
}
break;
state = BT_SELECTED;
}
break;
- case SDL_KEYDOWN: // key pressed
+ case SDL_KEYDOWN:
// key pressed
if(event.key.keysym.sym == binding)
state = BT_SELECTED;
break;
if(event.key.keysym.sym == binding)
state = BT_SELECTED;
break;
@@
-162,7
+164,7
@@
for(Buttons::iterator i = buttons.begin(); i != buttons.end(); ++i)
i->pos.y + i->size.y > (row + buttons_box.y) * buttons_size.y)
continue;
i->pos.y + i->size.y > (row + buttons_box.y) * buttons_size.y)
continue;
- i->draw(context, i->id == button_selected
? true : false
);
+ i->draw(context, i->id == button_selected);
}
context.pop_transform();
}
}
context.pop_transform();
}
@@
-178,7
+180,7
@@
switch(event.type)
if(mouse_left_button)
{
if(mouse_left_button)
{
- pos.x += int(event.motion.xrel * float(SCREEN_WIDTH)/screen->w);
+ pos.x += int(event.motion.xrel * float(SCREEN_WIDTH)/screen->w);
pos.y += int(event.motion.yrel * float(SCREEN_HEIGHT)/screen->h);
caught_event = true;
}
pos.y += int(event.motion.yrel * float(SCREEN_HEIGHT)/screen->h);
caught_event = true;
}