projects
/
supertux.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
06f58c8
)
Replaced .reset(new Surface()) with a factory method
author
grumbel
<grumbel@837edb03-e0f3-0310-88ca-d4d4e8b29345>
Sat, 21 Nov 2009 16:12:01 +0000
(16:12 +0000)
committer
grumbel
<grumbel@837edb03-e0f3-0310-88ca-d4d4e8b29345>
Sat, 21 Nov 2009 16:12:01 +0000
(16:12 +0000)
git-svn-id: http://supertux.lethargik.org/svn/supertux/trunk/supertux@6080
837edb03
-e0f3-0310-88ca-
d4d4e8b29345
14 files changed:
src/badguy/yeti.cpp
patch
|
blob
|
history
src/gui/menu.cpp
patch
|
blob
|
history
src/object/background.cpp
patch
|
blob
|
history
src/object/decal.cpp
patch
|
blob
|
history
src/object/level_time.cpp
patch
|
blob
|
history
src/object/player.cpp
patch
|
blob
|
history
src/supertux/console.cpp
patch
|
blob
|
history
src/supertux/game_session.cpp
patch
|
blob
|
history
src/supertux/info_box_line.cpp
patch
|
blob
|
history
src/supertux/info_box_line.hpp
patch
|
blob
|
history
src/supertux/player_status.cpp
patch
|
blob
|
history
src/supertux/textscroller.cpp
patch
|
blob
|
history
src/video/surface.cpp
patch
|
blob
|
history
src/video/surface.hpp
patch
|
blob
|
history
diff --git
a/src/badguy/yeti.cpp
b/src/badguy/yeti.cpp
index
08631e5
..
d56e3a5
100644
(file)
--- a/
src/badguy/yeti.cpp
+++ b/
src/badguy/yeti.cpp
@@
-64,7
+64,7
@@
Yeti::Yeti(const Reader& reader) :
countMe = false;
sound_manager->preload("sounds/yeti_gna.wav");
sound_manager->preload("sounds/yeti_roar.wav");
countMe = false;
sound_manager->preload("sounds/yeti_gna.wav");
sound_manager->preload("sounds/yeti_roar.wav");
- hud_head
.reset(new Surface("images/creatures/yeti/hudlife.png")
);
+ hud_head
= Surface::create("images/creatures/yeti/hudlife.png"
);
}
Yeti::~Yeti()
}
Yeti::~Yeti()
diff --git
a/src/gui/menu.cpp
b/src/gui/menu.cpp
index
48a4c87
..
f80569d
100644
(file)
--- a/
src/gui/menu.cpp
+++ b/
src/gui/menu.cpp
@@
-68,11
+68,11
@@
Menu::Menu() :
effect_progress = 0.0f;
effect_start_time = 0.0f;
effect_progress = 0.0f;
effect_start_time = 0.0f;
- checkbox
.reset(new Surface("images/engine/menu/checkbox-unchecked.png")
);
- checkbox_checked
.reset(new Surface("images/engine/menu/checkbox-checked.png")
);
- back
.reset(new Surface("images/engine/menu/arrow-back.png")
);
- arrow_left
.reset(new Surface("images/engine/menu/arrow-left.png")
);
- arrow_right
.reset(new Surface("images/engine/menu/arrow-right.png")
);
+ checkbox
= Surface::create("images/engine/menu/checkbox-unchecked.png"
);
+ checkbox_checked
= Surface::create("images/engine/menu/checkbox-checked.png"
);
+ back
= Surface::create("images/engine/menu/arrow-back.png"
);
+ arrow_left
= Surface::create("images/engine/menu/arrow-left.png"
);
+ arrow_right
= Surface::create("images/engine/menu/arrow-right.png"
);
}
Menu::~Menu()
}
Menu::~Menu()
diff --git
a/src/object/background.cpp
b/src/object/background.cpp
index
619645b
..
59a8871
100644
(file)
--- a/
src/object/background.cpp
+++ b/
src/object/background.cpp
@@
-62,10
+62,10
@@
Background::Background(const Reader& reader) :
set_image(imagefile, speed);
reader.get("speed-y", speed_y);
if (reader.get("image-top", imagefile_top)) {
set_image(imagefile, speed);
reader.get("speed-y", speed_y);
if (reader.get("image-top", imagefile_top)) {
- image_top
.reset(new Surface(imagefile_top)
);
+ image_top
= Surface::create(imagefile_top
);
}
if (reader.get("image-bottom", imagefile_bottom)) {
}
if (reader.get("image-bottom", imagefile_bottom)) {
- image_bottom
.reset(new Surface(imagefile_bottom)
);
+ image_bottom
= Surface::create(imagefile_bottom
);
}
}
}
}
@@
-84,7
+84,7
@@
Background::set_image(const std::string& name, float speed)
this->imagefile = name;
this->speed = speed;
this->imagefile = name;
this->speed = speed;
- image
.reset(new Surface(name)
);
+ image
= Surface::create(name
);
}
void
}
void
diff --git
a/src/object/decal.cpp
b/src/object/decal.cpp
index
a22d8db
..
67d5011
100644
(file)
--- a/
src/object/decal.cpp
+++ b/
src/object/decal.cpp
@@
-31,7
+31,7
@@
Decal::Decal(const Reader& reader) :
pos = Vector(px, py);
if(!reader.get("image", imagefile)) throw std::runtime_error("Must specify image for decal");
pos = Vector(px, py);
if(!reader.get("image", imagefile)) throw std::runtime_error("Must specify image for decal");
- image
.reset(new Surface(imagefile)
);
+ image
= Surface::create(imagefile
);
reader.get("layer", layer);
}
reader.get("layer", layer);
}
diff --git
a/src/object/level_time.cpp
b/src/object/level_time.cpp
index
bc32397
..
6f096b0
100644
(file)
--- a/
src/object/level_time.cpp
+++ b/
src/object/level_time.cpp
@@
-39,7
+39,7
@@
LevelTime::LevelTime(const Reader& reader) :
reader.get("name", name);
reader.get("time", time_left);
if(time_left <= 0) throw std::runtime_error("No or invalid leveltime specified");
reader.get("name", name);
reader.get("time", time_left);
if(time_left <= 0) throw std::runtime_error("No or invalid leveltime specified");
- time_surface
.reset(new Surface("images/engine/hud/time-0.png")
);
+ time_surface
= Surface::create("images/engine/hud/time-0.png"
);
}
void
}
void
diff --git
a/src/object/player.cpp
b/src/object/player.cpp
index
e394c0e
..
575113e
100644
(file)
--- a/
src/object/player.cpp
+++ b/
src/object/player.cpp
@@
-155,7
+155,7
@@
Player::Player(PlayerStatus* _player_status, const std::string& name) :
controller = g_main_controller;
scripting_controller.reset(new CodeController());
sprite = sprite_manager->create("images/creatures/tux/tux.sprite");
controller = g_main_controller;
scripting_controller.reset(new CodeController());
sprite = sprite_manager->create("images/creatures/tux/tux.sprite");
- airarrow
.reset(new Surface("images/engine/hud/airarrow.png")
);
+ airarrow
= Surface::create("images/engine/hud/airarrow.png"
);
idle_timer.start(IDLE_TIME[0]/1000.0f);
sound_manager->preload("sounds/bigjump.wav");
idle_timer.start(IDLE_TIME[0]/1000.0f);
sound_manager->preload("sounds/bigjump.wav");
diff --git
a/src/supertux/console.cpp
b/src/supertux/console.cpp
index
ba171d0
..
ffff99f
100644
(file)
--- a/
src/supertux/console.cpp
+++ b/
src/supertux/console.cpp
@@
-60,8
+60,8
@@
Console::init_graphics()
{
font.reset(new Font(Font::FIXED,"fonts/andale12.stf",1));
fontheight = font->get_height();
{
font.reset(new Font(Font::FIXED,"fonts/andale12.stf",1));
fontheight = font->get_height();
- background
.reset(new Surface("images/engine/console.png")
);
- background2
.reset(new Surface("images/engine/console2.png")
);
+ background
= Surface::create("images/engine/console.png"
);
+ background2
= Surface::create("images/engine/console2.png"
);
}
void
}
void
diff --git
a/src/supertux/game_session.cpp
b/src/supertux/game_session.cpp
index
b1396bf
..
cffb72d
100644
(file)
--- a/
src/supertux/game_session.cpp
+++ b/
src/supertux/game_session.cpp
@@
-73,7
+73,7
@@
GameSession::GameSession(const std::string& levelfile_, Statistics* statistics)
game_pause = false;
speed_before_pause = g_screen_manager->get_speed();
game_pause = false;
speed_before_pause = g_screen_manager->get_speed();
- statistics_backdrop
.reset(new Surface("images/engine/menu/score-backdrop.png")
);
+ statistics_backdrop
= Surface::create("images/engine/menu/score-backdrop.png"
);
restart_level();
restart_level();
diff --git
a/src/supertux/info_box_line.cpp
b/src/supertux/info_box_line.cpp
index
19bf347
..
23fb1a6
100644
(file)
--- a/
src/supertux/info_box_line.cpp
+++ b/
src/supertux/info_box_line.cpp
@@
-111,12
+111,14
@@
InfoBoxLine::InfoBoxLine(char format_char, const std::string& text) :
font = get_font_by_format_char(format_char);
lineType = get_linetype_by_format_char(format_char);
color = get_color_by_format_char(format_char);
font = get_font_by_format_char(format_char);
lineType = get_linetype_by_format_char(format_char);
color = get_color_by_format_char(format_char);
- if (lineType == IMAGE) image = new Surface(text);
+ if (lineType == IMAGE)
+ {
+ image = Surface::create(text);
+ }
}
InfoBoxLine::~InfoBoxLine()
{
}
InfoBoxLine::~InfoBoxLine()
{
- delete image;
}
const std::vector<InfoBoxLine*>
}
const std::vector<InfoBoxLine*>
@@
-172,7
+174,7
@@
InfoBoxLine::draw(DrawingContext& context, const Rect& bbox, int layer)
Vector position = bbox.p1;
switch (lineType) {
case IMAGE:
Vector position = bbox.p1;
switch (lineType) {
case IMAGE:
- context.draw_surface(image, Vector( (bbox.p1.x + bbox.p2.x - image->get_width()) / 2, position.y), layer);
+ context.draw_surface(image
.get()
, Vector( (bbox.p1.x + bbox.p2.x - image->get_width()) / 2, position.y), layer);
break;
case NORMAL_LEFT:
context.draw_text(font, text, Vector(position.x, position.y), ALIGN_LEFT, layer, color);
break;
case NORMAL_LEFT:
context.draw_text(font, text, Vector(position.x, position.y), ALIGN_LEFT, layer, color);
diff --git
a/src/supertux/info_box_line.hpp
b/src/supertux/info_box_line.hpp
index
ac1f079
..
3501229
100644
(file)
--- a/
src/supertux/info_box_line.hpp
+++ b/
src/supertux/info_box_line.hpp
@@
-19,6
+19,7
@@
#include <string>
#include <vector>
#include <string>
#include <vector>
+#include <memory>
#include "video/color.hpp"
#include "video/color.hpp"
@@
-48,7
+49,7
@@
private:
Font* font;
Color color;
std::string text;
Font* font;
Color color;
std::string text;
-
Surface*
image;
+
std::auto_ptr<Surface>
image;
private:
InfoBoxLine(const InfoBoxLine&);
private:
InfoBoxLine(const InfoBoxLine&);
diff --git
a/src/supertux/player_status.cpp
b/src/supertux/player_status.cpp
index
24bde70
..
4dc5188
100644
(file)
--- a/
src/supertux/player_status.cpp
+++ b/
src/supertux/player_status.cpp
@@
-40,7
+40,7
@@
PlayerStatus::PlayerStatus() :
{
reset();
{
reset();
- coin_surface
.reset(new Surface("images/engine/hud/coins-0.png")
);
+ coin_surface
= Surface::create("images/engine/hud/coins-0.png"
);
sound_manager->preload("sounds/coin.wav");
sound_manager->preload("sounds/lifeup.wav");
}
sound_manager->preload("sounds/coin.wav");
sound_manager->preload("sounds/lifeup.wav");
}
diff --git
a/src/supertux/textscroller.cpp
b/src/supertux/textscroller.cpp
index
8d5db1a
..
61af4c6
100644
(file)
--- a/
src/supertux/textscroller.cpp
+++ b/
src/supertux/textscroller.cpp
@@
-70,7
+70,7
@@
TextScroller::TextScroller(const std::string& filename) :
lines = InfoBoxLine::split(text, SCREEN_WIDTH - 2*LEFT_BORDER);
// load background image
lines = InfoBoxLine::split(text, SCREEN_WIDTH - 2*LEFT_BORDER);
// load background image
- background
.reset(new Surface("images/background/" + background_file)
);
+ background
= Surface::create("images/background/" + background_file
);
scroll = 0;
fading = false;
scroll = 0;
fading = false;
diff --git
a/src/video/surface.cpp
b/src/video/surface.cpp
index
b15d80b
..
6c55ab1
100644
(file)
--- a/
src/video/surface.cpp
+++ b/
src/video/surface.cpp
@@
-23,6
+23,24
@@
#include "video/texture.hpp"
#include "video/video_systems.hpp"
#include "video/texture.hpp"
#include "video/video_systems.hpp"
+std::auto_ptr<Surface>
+Surface::create(const std::string& file)
+{
+ return std::auto_ptr<Surface>(new Surface(file));
+}
+
+std::auto_ptr<Surface>
+Surface::create(const std::string& file, int x, int y, int w, int h)
+{
+ return std::auto_ptr<Surface>(new Surface(file, x, y, w, h));
+}
+
+std::auto_ptr<Surface>
+Surface::create(const Surface& other)
+{
+ return std::auto_ptr<Surface>(new Surface(other));
+}
+
Surface::Surface(const std::string& file) :
texture(texture_manager->get(file)),
surface_data(),
Surface::Surface(const std::string& file) :
texture(texture_manager->get(file)),
surface_data(),
diff --git
a/src/video/surface.hpp
b/src/video/surface.hpp
index
9613917
..
6769e60
100644
(file)
--- a/
src/video/surface.hpp
+++ b/
src/video/surface.hpp
@@
-18,6
+18,7
@@
#define HEADER_SUPERTUX_VIDEO_SURFACE_HPP
#include <string>
#define HEADER_SUPERTUX_VIDEO_SURFACE_HPP
#include <string>
+#include <memory>
#include "math/vector.hpp"
#include "math/vector.hpp"
@@
-30,6
+31,11
@@
class Texture;
*/
class Surface
{
*/
class Surface
{
+public:
+ static std::auto_ptr<Surface> create(const std::string& file);
+ static std::auto_ptr<Surface> create(const std::string& file, int x, int y, int w, int h);
+ static std::auto_ptr<Surface> create(const Surface& other);
+
private:
Texture* texture;
void *surface_data;
private:
Texture* texture;
void *surface_data;