[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] r4024 - in trunk/pingus/src: components display editor gui
From: |
grumbel at BerliOS |
Subject: |
[Pingus-CVS] r4024 - in trunk/pingus/src: components display editor gui input lisp particles pingus worldmap worldobjs |
Date: |
Wed, 4 Nov 2009 21:52:58 +0100 |
Author: grumbel
Date: 2009-11-04 21:52:55 +0100 (Wed, 04 Nov 2009)
New Revision: 4024
Modified:
trunk/pingus/src/components/action_button.cpp
trunk/pingus/src/components/choice_box.cpp
trunk/pingus/src/display/drawing_context.cpp
trunk/pingus/src/display/framebuffer_surface.cpp
trunk/pingus/src/display/null_framebuffer.cpp
trunk/pingus/src/display/scene_context.cpp
trunk/pingus/src/editor/action_properties.cpp
trunk/pingus/src/editor/action_properties.hpp
trunk/pingus/src/editor/combobox.cpp
trunk/pingus/src/editor/editor_screen.cpp
trunk/pingus/src/editor/file_dialog.cpp
trunk/pingus/src/editor/file_list.cpp
trunk/pingus/src/editor/inputbox.cpp
trunk/pingus/src/editor/level_properties.cpp
trunk/pingus/src/editor/object_properties.cpp
trunk/pingus/src/editor/object_properties.hpp
trunk/pingus/src/editor/object_selector.cpp
trunk/pingus/src/editor/object_selector_list.cpp
trunk/pingus/src/editor/object_selector_set.cpp
trunk/pingus/src/editor/panel.cpp
trunk/pingus/src/editor/viewport.cpp
trunk/pingus/src/gui/group_component.cpp
trunk/pingus/src/gui/surface_button.cpp
trunk/pingus/src/input/controller.cpp
trunk/pingus/src/input/controller.hpp
trunk/pingus/src/input/controller_description.cpp
trunk/pingus/src/input/controller_description.hpp
trunk/pingus/src/input/manager.cpp
trunk/pingus/src/input/sdl_driver.cpp
trunk/pingus/src/input/sdl_driver.hpp
trunk/pingus/src/lisp/lexer.cpp
trunk/pingus/src/lisp/lisp.cpp
trunk/pingus/src/lisp/parser.cpp
trunk/pingus/src/particles/pingu_particle_holder.cpp
trunk/pingus/src/particles/rain_particle_holder.cpp
trunk/pingus/src/particles/smoke_particle_holder.cpp
trunk/pingus/src/particles/snow_particle_holder.cpp
trunk/pingus/src/pingus/world.cpp
trunk/pingus/src/worldmap/level_dot.cpp
trunk/pingus/src/worldmap/path_graph.cpp
trunk/pingus/src/worldmap/pingus.cpp
trunk/pingus/src/worldmap/pingus_worldmap.cpp
trunk/pingus/src/worldmap/sprite_drawable.cpp
trunk/pingus/src/worldmap/worldmap.cpp
trunk/pingus/src/worldmap/worldmap_screen.cpp
trunk/pingus/src/worldobjs/entrance.cpp
Log:
More -Weffc++ cleanup, almost done
Modified: trunk/pingus/src/components/action_button.cpp
===================================================================
--- trunk/pingus/src/components/action_button.cpp 2009-11-04 19:29:46 UTC
(rev 4023)
+++ trunk/pingus/src/components/action_button.cpp 2009-11-04 20:52:55 UTC
(rev 4024)
@@ -26,11 +26,14 @@
using namespace Actions;
-ArmageddonButton::ArmageddonButton(Server* s, int x, int y)
- : RectComponent(Rect(Vector2i(x, y), Size(38, 60))),
- server(s),
- background ("core/buttons/hbuttonbgb"),
- backgroundhl("core/buttons/hbuttonbg")
+ArmageddonButton::ArmageddonButton(Server* s, int x, int y) :
+ RectComponent(Rect(Vector2i(x, y), Size(38, 60))),
+ server(s),
+ pressed(),
+ press_time(),
+ sprite(),
+ background ("core/buttons/hbuttonbgb"),
+ backgroundhl("core/buttons/hbuttonbg")
{
pressed = false;
sprite = Sprite("core/buttons/armageddon_anim");
@@ -134,11 +137,12 @@
UNUSED_ARG(y);
}
-PauseButton::PauseButton(GameSession* s, int x, int y)
- : RectComponent(Rect(Vector2i(x, y), Size(38, 60))),
- session(s),
- background ("core/buttons/hbuttonbgb"),
- backgroundhl("core/buttons/hbuttonbg")
+PauseButton::PauseButton(GameSession* s, int x, int y) :
+ RectComponent(Rect(Vector2i(x, y), Size(38, 60))),
+ session(s),
+ surface(),
+ background ("core/buttons/hbuttonbgb"),
+ backgroundhl("core/buttons/hbuttonbg")
{
surface = Sprite("core/buttons/pause");
}
Modified: trunk/pingus/src/components/choice_box.cpp
===================================================================
--- trunk/pingus/src/components/choice_box.cpp 2009-11-04 19:29:46 UTC (rev
4023)
+++ trunk/pingus/src/components/choice_box.cpp 2009-11-04 20:52:55 UTC (rev
4024)
@@ -19,10 +19,12 @@
#include "display/drawing_context.hpp"
#include "components/choice_box.hpp"
-ChoiceBox::ChoiceBox(const Rect& rect_)
- : RectComponent(rect_)
+ChoiceBox::ChoiceBox(const Rect& rect_) :
+ RectComponent(rect_),
+ current_choice(0),
+ choices(),
+ on_change()
{
- current_choice = 0;
}
void
Modified: trunk/pingus/src/display/drawing_context.cpp
===================================================================
--- trunk/pingus/src/display/drawing_context.cpp 2009-11-04 19:29:46 UTC
(rev 4023)
+++ trunk/pingus/src/display/drawing_context.cpp 2009-11-04 20:52:55 UTC
(rev 4024)
@@ -179,9 +179,11 @@
translate_stack.push_back(Vector2i(0, 0));
}
-DrawingContext::DrawingContext()
- : rect(0, 0, Display::get_width(), Display::get_height()),
- do_clipping(false)
+DrawingContext::DrawingContext() :
+ drawingrequests(),
+ translate_stack(),
+ rect(0, 0, Display::get_width(), Display::get_height()),
+ do_clipping(false)
{
translate_stack.push_back(Vector2i(0, 0));
}
Modified: trunk/pingus/src/display/framebuffer_surface.cpp
===================================================================
--- trunk/pingus/src/display/framebuffer_surface.cpp 2009-11-04 19:29:46 UTC
(rev 4023)
+++ trunk/pingus/src/display/framebuffer_surface.cpp 2009-11-04 20:52:55 UTC
(rev 4024)
@@ -16,12 +16,13 @@
#include "display/framebuffer_surface.hpp"
-FramebufferSurface::FramebufferSurface()
+FramebufferSurface::FramebufferSurface() :
+ impl()
{
}
-FramebufferSurface::FramebufferSurface(FramebufferSurfaceImpl* impl_)
- : impl(impl_)
+FramebufferSurface::FramebufferSurface(FramebufferSurfaceImpl* impl_) :
+ impl(impl_)
{
}
Modified: trunk/pingus/src/display/null_framebuffer.cpp
===================================================================
--- trunk/pingus/src/display/null_framebuffer.cpp 2009-11-04 19:29:46 UTC
(rev 4023)
+++ trunk/pingus/src/display/null_framebuffer.cpp 2009-11-04 20:52:55 UTC
(rev 4024)
@@ -31,7 +31,8 @@
Surface to_surface() const { return Surface(); }
};
-NullFramebuffer::NullFramebuffer()
+NullFramebuffer::NullFramebuffer() :
+ size()
{
}
Modified: trunk/pingus/src/display/scene_context.cpp
===================================================================
--- trunk/pingus/src/display/scene_context.cpp 2009-11-04 19:29:46 UTC (rev
4023)
+++ trunk/pingus/src/display/scene_context.cpp 2009-11-04 20:52:55 UTC (rev
4024)
@@ -42,6 +42,7 @@
color(rect),
light(rect),
highlight(rect),
+ cliprect(),
use_cliprect(false)
{
}
Modified: trunk/pingus/src/editor/action_properties.cpp
===================================================================
--- trunk/pingus/src/editor/action_properties.cpp 2009-11-04 19:29:46 UTC
(rev 4023)
+++ trunk/pingus/src/editor/action_properties.cpp 2009-11-04 20:52:55 UTC
(rev 4024)
@@ -33,10 +33,12 @@
* [active] [Actionname] [count]
*
*/
-ActionProperties::ActionProperties(EditorScreen* editor_, const Rect& rect_)
- : GroupComponent(rect_),
- editor(editor_),
- y_pos(0)
+ActionProperties::ActionProperties(EditorScreen* editor_, const Rect& rect_) :
+ GroupComponent(rect_),
+ editor(editor_),
+ level(),
+ y_pos(0),
+ action_comps()
{
add_action(Actions::BASHER);
add_action(Actions::BLOCKER);
Modified: trunk/pingus/src/editor/action_properties.hpp
===================================================================
--- trunk/pingus/src/editor/action_properties.hpp 2009-11-04 19:29:46 UTC
(rev 4023)
+++ trunk/pingus/src/editor/action_properties.hpp 2009-11-04 20:52:55 UTC
(rev 4024)
@@ -59,6 +59,7 @@
void on_checkbox_change(bool t, Actions::ActionName id);
void on_inputbox_change(const std::string& str, Actions::ActionName id);
+
private:
ActionProperties (const ActionProperties&);
ActionProperties& operator= (const ActionProperties&);
Modified: trunk/pingus/src/editor/combobox.cpp
===================================================================
--- trunk/pingus/src/editor/combobox.cpp 2009-11-04 19:29:46 UTC (rev
4023)
+++ trunk/pingus/src/editor/combobox.cpp 2009-11-04 20:52:55 UTC (rev
4024)
@@ -34,7 +34,8 @@
current_item(-1),
hover_item(),
drop_down(false),
- list_offset()
+ list_offset(),
+ on_select()
{
}
Modified: trunk/pingus/src/editor/editor_screen.cpp
===================================================================
--- trunk/pingus/src/editor/editor_screen.cpp 2009-11-04 19:29:46 UTC (rev
4023)
+++ trunk/pingus/src/editor/editor_screen.cpp 2009-11-04 20:52:55 UTC (rev
4024)
@@ -47,12 +47,19 @@
namespace Editor {
// Default constructor
-EditorScreen::EditorScreen()
- : plf(new EditorLevel()),
- panel(0),
- viewport(0),
- object_selector(0),
- show_help(false)
+EditorScreen::EditorScreen() :
+ plf(new EditorLevel()),
+ level_pathname(),
+ panel(0),
+ viewport(0),
+ object_selector(0),
+ minimap(),
+ object_properties(),
+ action_properties(),
+ level_properties(),
+ file_load_dialog(),
+ file_save_dialog(),
+ show_help(false)
{
// Create the viewport for the images and data
viewport = new Viewport(this, Rect(0, 38,
@@ -134,9 +141,9 @@
level_pathname = file;
std::cout << "Save to: " << file.str() << std::endl;
if (!plf->save_level(level_pathname.get_sys_path()))
- {
- // FIXME: save failed, prompt user
- }
+ {
+ // FIXME: save failed, prompt user
+ }
}
// Load a new level
@@ -160,86 +167,86 @@
gui_manager->draw(gc);
if (show_help)
- {
- Size size_(600, 400);
- gc.draw_fillrect(Rect(gc.get_width()/2 - size_.width/2 - 2,
- gc.get_height()/2 - size_.height/2 - 2,
- gc.get_width()/2 + size_.width/2 + 2,
- gc.get_height()/2 + size_.height/2 + 2),
- Color(0,0,0));
- gc.draw_fillrect(Rect(gc.get_width()/2 - size_.width/2,
- gc.get_height()/2 - size_.height/2,
- gc.get_width()/2 + size_.width/2,
- gc.get_height()/2 + size_.height/2),
- Color(255,255,255));
+ {
+ Size size_(600, 400);
+ gc.draw_fillrect(Rect(gc.get_width()/2 - size_.width/2 - 2,
+ gc.get_height()/2 - size_.height/2 - 2,
+ gc.get_width()/2 + size_.width/2 + 2,
+ gc.get_height()/2 + size_.height/2 + 2),
+ Color(0,0,0));
+ gc.draw_fillrect(Rect(gc.get_width()/2 - size_.width/2,
+ gc.get_height()/2 - size_.height/2,
+ gc.get_width()/2 + size_.width/2,
+ gc.get_height()/2 + size_.height/2),
+ Color(255,255,255));
- gc.print_center(Fonts::verdana11,
- Vector2i(gc.get_width()/2,
- gc.get_height()/2 - size_.height/2 + 12),
- "Editor Help");
+ gc.print_center(Fonts::verdana11,
+ Vector2i(gc.get_width()/2,
+ gc.get_height()/2 - size_.height/2 + 12),
+ "Editor Help");
- int x = gc.get_width()/2 - size_.width/2 + 12;
- int y = gc.get_height()/2 - size_.height/2 + 36;
- gc.print_center(Fonts::verdana11, Vector2i(x + 50, y),
- "A\n"
- "Shift+A\n"
- "], w\n"
- "[, s\n"
- "Shift+]\n"
- "Shift+[\n"
- "R\n"
- "Shift+R\n"
- );
+ int x = gc.get_width()/2 - size_.width/2 + 12;
+ int y = gc.get_height()/2 - size_.height/2 + 36;
+ gc.print_center(Fonts::verdana11, Vector2i(x + 50, y),
+ "A\n"
+ "Shift+A\n"
+ "], w\n"
+ "[, s\n"
+ "Shift+]\n"
+ "Shift+[\n"
+ "R\n"
+ "Shift+R\n"
+ );
- gc.print_left(Fonts::verdana11, Vector2i(x+100, y),
- _("Select all\n"
- "Clear Selection\n"
- "Raise objects\n"
- "Lower objects\n"
- "Lower objects to bottom\n"
- "Raise objects to top\n"
- "Rotate 90 degree\n"
- "Rotate 270 degree\n"));
+ gc.print_left(Fonts::verdana11, Vector2i(x+100, y),
+ _("Select all\n"
+ "Clear Selection\n"
+ "Raise objects\n"
+ "Lower objects\n"
+ "Lower objects to bottom\n"
+ "Raise objects to top\n"
+ "Rotate 90 degree\n"
+ "Rotate 270 degree\n"));
- x = int(gc.get_width()/2 + 12);
- y = int(gc.get_height()/2) - size_.height/2 + 36;
- gc.print_center(Fonts::verdana11, Vector2i(x + 50, y),
- "F\n"
- "Shift+F\n"
- "Delete\n"
- "i\n"
- "k\n"
- "j\n"
- "l\n"
- );
+ x = int(gc.get_width()/2 + 12);
+ y = int(gc.get_height()/2) - size_.height/2 + 36;
+ gc.print_center(Fonts::verdana11, Vector2i(x + 50, y),
+ "F\n"
+ "Shift+F\n"
+ "Delete\n"
+ "i\n"
+ "k\n"
+ "j\n"
+ "l\n"
+ );
- gc.print_left(Fonts::verdana11, Vector2i(x + 100, y),
- _("Flip object horizontaly\n"
- "Flip object vertically\n"
- "Delete all marked objects\n"
- "Move objects up\n"
- "Move objects down\n"
- "Move objects left\n"
- "Move objects right\n")
- );
+ gc.print_left(Fonts::verdana11, Vector2i(x + 100, y),
+ _("Flip object horizontaly\n"
+ "Flip object vertically\n"
+ "Delete all marked objects\n"
+ "Move objects up\n"
+ "Move objects down\n"
+ "Move objects left\n"
+ "Move objects right\n")
+ );
- gc.print_left(Fonts::verdana11,
- Vector2i(gc.get_width()/2 - size_.width/2 + 12,
- gc.get_height()/2 - 10),
- _("You should name your level files systematically, i.e.
by their theme, "
- "their number and your nickname:\n\n"
- " <levelname><number>-<creator>.pingus\n\n"
- "So if you create a your second level with a stone
theme, call it: "
- "stone2-yourname.pingus\n\n"
- "When you have created a level and want to have it
included "
- "in the game mail it to:\n\n"
- " address@hidden"
- "Only levels published under the GPL are allowed into
the game. The editor "
- "automatically inserts a reference \n"
- "to the GPL, if you want to have your level under a
different license, you "
- "have to change that reference.\n"
- ));
- }
+ gc.print_left(Fonts::verdana11,
+ Vector2i(gc.get_width()/2 - size_.width/2 + 12,
+ gc.get_height()/2 - 10),
+ _("You should name your level files systematically, i.e. by
their theme, "
+ "their number and your nickname:\n\n"
+ " <levelname><number>-<creator>.pingus\n\n"
+ "So if you create a your second level with a stone theme,
call it: "
+ "stone2-yourname.pingus\n\n"
+ "When you have created a level and want to have it
included "
+ "in the game mail it to:\n\n"
+ " address@hidden"
+ "Only levels published under the GPL are allowed into the
game. The editor "
+ "automatically inserts a reference \n"
+ "to the GPL, if you want to have your level under a
different license, you "
+ "have to change that reference.\n"
+ ));
+ }
}
void
@@ -248,17 +255,17 @@
GUIScreen::update(event);
switch (event.type)
- {
- case Input::SCROLLER_EVENT_TYPE:
- viewport->set_scroll_pos(viewport->get_scroll_pos() -
-
Vector2i(static_cast<int>(event.scroll.x_delta),
-
static_cast<int>(event.scroll.y_delta)));
- break;
+ {
+ case Input::SCROLLER_EVENT_TYPE:
+ viewport->set_scroll_pos(viewport->get_scroll_pos() -
+ Vector2i(static_cast<int>(event.scroll.x_delta),
+
static_cast<int>(event.scroll.y_delta)));
+ break;
- default:
- // other events are for most part handled by the GUIScreen/GUIManager
- break;
- }
+ default:
+ // other events are for most part handled by the GUIScreen/GUIManager
+ break;
+ }
}
void
@@ -298,13 +305,13 @@
EditorScreen::level_save()
{
if (level_pathname.empty())
- {
- level_save_as();
- }
+ {
+ level_save_as();
+ }
else
- {
- save(level_pathname);
- }
+ {
+ save(level_pathname);
+ }
}
void
@@ -321,10 +328,10 @@
{
Pathname tmp(System::get_userdir() + "backup/editortmpfile.pingus",
Pathname::SYSTEM_PATH);
if (!plf->save_level(tmp.get_sys_path()))
- {
- // FIXME: save failed, prompt user
- return;
- }
+ {
+ // FIXME: save failed, prompt user
+ return;
+ }
PingusLevel level(tmp);
ScreenManager::instance()->push_screen(new GameSession(level, false));
}
@@ -437,28 +444,28 @@
EditorScreen::toggle_action_properties()
{
if (action_properties->is_visible())
- {
- action_properties->hide();
- }
+ {
+ action_properties->hide();
+ }
else
- {
- action_properties->show();
- level_properties->hide();
- }
+ {
+ action_properties->show();
+ level_properties->hide();
+ }
}
void
EditorScreen::toggle_level_properties()
{
if (level_properties->is_visible())
- {
- level_properties->hide();
- }
+ {
+ level_properties->hide();
+ }
else
- {
- level_properties->show();
- action_properties->hide();
- }
+ {
+ level_properties->show();
+ action_properties->hide();
+ }
}
void
@@ -471,7 +478,7 @@
EditorScreen::update_layout()
{
Size size_(gui_manager->get_rect().get_width(),
- gui_manager->get_rect().get_height());
+ gui_manager->get_rect().get_height());
minimap->set_rect(Rect(Vector2i(size_.width-244, size_.height-183),
Size(244, 183)));
@@ -481,15 +488,15 @@
object_selector->set_rect(Rect(size_.width-244, 38, size_.width,
size_.height));
if (object_selector->is_visible())
- {
- viewport->set_rect(Rect(0, 38, size_.width - 244, size_.height));
- level_properties->set_rect(Rect(Vector2i(0,38), Size(size_.width-244,
302)));
- }
+ {
+ viewport->set_rect(Rect(0, 38, size_.width - 244, size_.height));
+ level_properties->set_rect(Rect(Vector2i(0,38), Size(size_.width-244,
302)));
+ }
else
- {
- viewport->set_rect(Rect(0, 38, size_.width, size_.height));
- level_properties->set_rect(Rect(Vector2i(0,38), Size(size_.width,
302)));
- }
+ {
+ viewport->set_rect(Rect(0, 38, size_.width, size_.height));
+ level_properties->set_rect(Rect(Vector2i(0,38), Size(size_.width, 302)));
+ }
action_properties->set_rect(Rect(Vector2i(0, 38), Size(150, 240)));
Modified: trunk/pingus/src/editor/file_dialog.cpp
===================================================================
--- trunk/pingus/src/editor/file_dialog.cpp 2009-11-04 19:29:46 UTC (rev
4023)
+++ trunk/pingus/src/editor/file_dialog.cpp 2009-11-04 20:52:55 UTC (rev
4024)
@@ -32,10 +32,21 @@
namespace Editor {
-FileDialog::FileDialog(EditorScreen* editor_, const Rect& rect_, Mode mode_)
- : GroupComponent(rect_),
- editor(editor_),
- mode(mode_)
+FileDialog::FileDialog(EditorScreen* editor_, const Rect& rect_, Mode mode_) :
+ GroupComponent(rect_),
+ editor(editor_),
+ mode(mode_),
+ file_list(),
+ up_button(),
+ down_button(),
+ open_button(),
+ cancel_button(),
+ datadir_button(),
+ userdir_button(),
+ pathname_label(),
+ filename_label(),
+ pathname_inputbox(),
+ filename_inputbox()
{
file_list = new FileList(Rect(4, 30 + 30 + 30,
rect.get_width()-4 - 30, rect.get_height() - 4
- 35));
@@ -106,14 +117,14 @@
{ // called when somebody clicks a file
if (entry.type == System::DE_DIRECTORY)
- {
- //std::cout << "Directory: " << entry.name << std::endl;
- set_directory(pathname_inputbox->get_text() + "/" + entry.name);
- }
+ {
+ //std::cout << "Directory: " << entry.name << std::endl;
+ set_directory(pathname_inputbox->get_text() + "/" + entry.name);
+ }
else
- {
- filename_inputbox->set_text(entry.name);
- }
+ {
+ filename_inputbox->set_text(entry.name);
+ }
}
void
@@ -138,22 +149,22 @@
FileDialog::on_open()
{
if (!filename_inputbox->get_text().empty())
+ {
+ if (mode == LOAD)
{
- if (mode == LOAD)
- {
- Pathname file(pathname_inputbox->get_text() + "/" +
filename_inputbox->get_text(), Pathname::SYSTEM_PATH);
- std::cout << "Open: " << file << std::endl;
- editor->load(file);
- hide();
- }
- else if (mode == SAVE)
- {
- Pathname file(pathname_inputbox->get_text() + "/" +
filename_inputbox->get_text(), Pathname::SYSTEM_PATH);
- std::cout << "Save: " << file << std::endl;
- editor->save(file);
- hide();
- }
+ Pathname file(pathname_inputbox->get_text() + "/" +
filename_inputbox->get_text(), Pathname::SYSTEM_PATH);
+ std::cout << "Open: " << file << std::endl;
+ editor->load(file);
+ hide();
}
+ else if (mode == SAVE)
+ {
+ Pathname file(pathname_inputbox->get_text() + "/" +
filename_inputbox->get_text(), Pathname::SYSTEM_PATH);
+ std::cout << "Save: " << file << std::endl;
+ editor->save(file);
+ hide();
+ }
+ }
}
void
@@ -176,7 +187,7 @@
GUI::GroupComponent::update_layout();
file_list->set_rect(Rect(4, 30 + 30 + 30,
- rect.get_width()-4 - 30, rect.get_height() - 4 -
35));
+ rect.get_width()-4 - 30, rect.get_height() - 4 -
35));
Rect file_rect = file_list->get_rect();
Modified: trunk/pingus/src/editor/file_list.cpp
===================================================================
--- trunk/pingus/src/editor/file_list.cpp 2009-11-04 19:29:46 UTC (rev
4023)
+++ trunk/pingus/src/editor/file_list.cpp 2009-11-04 20:52:55 UTC (rev
4024)
@@ -34,7 +34,8 @@
current_item(-1),
click_item(-1),
page(0),
- num_pages(0)
+ num_pages(0),
+ on_click()
{
update_layout();
}
Modified: trunk/pingus/src/editor/inputbox.cpp
===================================================================
--- trunk/pingus/src/editor/inputbox.cpp 2009-11-04 19:29:46 UTC (rev
4023)
+++ trunk/pingus/src/editor/inputbox.cpp 2009-11-04 20:52:55 UTC (rev
4024)
@@ -24,7 +24,9 @@
Inputbox::Inputbox(const Rect& rect_) :
RectComponent(rect_),
- text()
+ text(),
+ on_change(),
+ on_enter()
{
}
Modified: trunk/pingus/src/editor/level_properties.cpp
===================================================================
--- trunk/pingus/src/editor/level_properties.cpp 2009-11-04 19:29:46 UTC
(rev 4023)
+++ trunk/pingus/src/editor/level_properties.cpp 2009-11-04 20:52:55 UTC
(rev 4024)
@@ -37,10 +37,21 @@
namespace Editor {
-LevelProperties::LevelProperties(EditorScreen* editor_, const Rect& rect_)
- : GroupComponent(rect_),
- editor(editor_),
- level(0)
+LevelProperties::LevelProperties(EditorScreen* editor_, const Rect& rect_) :
+ GroupComponent(rect_),
+ editor(editor_),
+ level(0),
+ author(),
+ levelname(),
+ description(),
+ number_of_pingus(),
+ number_to_save(),
+ time(),
+ width(),
+ height(),
+ difficulty(),
+ comment(),
+ music()
{
int w = rect.get_width() - 120;
add(new Label (Rect(Vector2i( 10, 10), Size( 80, 20)), "Author:"));
@@ -158,13 +169,13 @@
{
int num = 0;
if (StringUtil::from_string(str, num))
- {
- level->set_number_to_save(num);
- }
+ {
+ level->set_number_to_save(num);
+ }
else
- {
- std::cout << "LevelProperties::on_number_to_save_change: '" << str << "'
not an integer" << std::endl;
- }
+ {
+ std::cout << "LevelProperties::on_number_to_save_change: '" << str << "'
not an integer" << std::endl;
+ }
}
@@ -173,13 +184,13 @@
{
int num = 0;
if (StringUtil::from_string(str, num))
- {
- level->set_number_of_pingus(num);
- }
+ {
+ level->set_number_of_pingus(num);
+ }
else
- {
- std::cout << "LevelProperties::on_number_of_pingus_change: '" << str <<
"' not an integer" << std::endl;
- }
+ {
+ std::cout << "LevelProperties::on_number_of_pingus_change: '" << str << "'
not an integer" << std::endl;
+ }
}
void
Modified: trunk/pingus/src/editor/object_properties.cpp
===================================================================
--- trunk/pingus/src/editor/object_properties.cpp 2009-11-04 19:29:46 UTC
(rev 4023)
+++ trunk/pingus/src/editor/object_properties.cpp 2009-11-04 20:52:55 UTC
(rev 4024)
@@ -33,9 +33,51 @@
namespace Editor {
-ObjectProperties::ObjectProperties(EditorScreen* editor_, const Rect& rect_)
- : GUI::GroupComponent(rect_, false),
- editor(editor_)
+ObjectProperties::ObjectProperties(EditorScreen* editor_, const Rect& rect_) :
+ GUI::GroupComponent(rect_, false),
+ editor(editor_),
+ objects(),
+ type_label(),
+ mesg_label(),
+ gptype_label(),
+ gptype_type(),
+ entrance_direction_label(),
+ entrance_direction(),
+ release_rate_label(),
+ release_rate_inputbox(),
+ stretch_label(),
+ stretch_x_checkbox(),
+ stretch_y_checkbox(),
+ para_x_label(),
+ para_x_inputbox(),
+ para_y_label(),
+ para_y_inputbox(),
+ scroll_x_label(),
+ scroll_x_inputbox(),
+ scroll_y_label(),
+ scroll_y_inputbox(),
+ owner_label(),
+ owner_inputbox(),
+ pos_z_label(),
+ pos_z_inputbox(),
+ color_label(),
+ color_r_inputbox(),
+ color_g_inputbox(),
+ color_b_inputbox(),
+ color_a_inputbox(),
+ small_stars_label(),
+ small_stars_inputbox(),
+ middle_stars_label(),
+ middle_stars_inputbox(),
+ large_stars_label(),
+ large_stars_inputbox(),
+ repeat_label(),
+ repeat_inputbox(),
+ flip_horizontal_button(),
+ flip_vertical_button(),
+ rotate_90_button(),
+ rotate_270_button(),
+ y_pos()
{
add(type_label = new Label(Rect(Vector2i(4, 4), Size(120, 20)),
_("Object:")));
add(mesg_label = new Label(Rect(Vector2i(10, 0), Size(180, 20)), _("Nothing
selected")));
@@ -269,131 +311,131 @@
hide_all();
if (obj)
+ {
+ unsigned int attr = obj->get_attribs();
+ if (attr & HAS_GPTYPE)
{
- unsigned int attr = obj->get_attribs();
- if (attr & HAS_GPTYPE)
- {
-
gptype_type->set_selected_item(Groundtype::string_to_type(obj->get_ground_type()));
- place(gptype_label, gptype_type);
- }
+
gptype_type->set_selected_item(Groundtype::string_to_type(obj->get_ground_type()));
+ place(gptype_label, gptype_type);
+ }
- if (attr & HAS_DIRECTION)
- {
- if (obj->get_direction() == "left")
- entrance_direction->set_selected_item(0);
- else if (obj->get_direction() == "misc")
- entrance_direction->set_selected_item(1);
- else if (obj->get_direction() == "right")
- entrance_direction->set_selected_item(2);
- else
- std::cout << "Error: ObjectProperties::set_object: unknown
direction: " << obj->get_direction() << std::endl;
+ if (attr & HAS_DIRECTION)
+ {
+ if (obj->get_direction() == "left")
+ entrance_direction->set_selected_item(0);
+ else if (obj->get_direction() == "misc")
+ entrance_direction->set_selected_item(1);
+ else if (obj->get_direction() == "right")
+ entrance_direction->set_selected_item(2);
+ else
+ std::cout << "Error: ObjectProperties::set_object: unknown direction:
" << obj->get_direction() << std::endl;
- place(entrance_direction_label, entrance_direction);
- }
+ place(entrance_direction_label, entrance_direction);
+ }
- if (attr & HAS_SPEED)
- { // obsolete in large part, since sprites have their own speed
- }
+ if (attr & HAS_SPEED)
+ { // obsolete in large part, since sprites have their own speed
+ }
- if (attr & HAS_PARALLAX)
- { // used for hotspot
- }
+ if (attr & HAS_PARALLAX)
+ { // used for hotspot
+ }
- if (attr & HAS_REPEAT)
- {
- repeat_inputbox->set_text(StringUtil::to_string(obj->get_repeat()));
- place(repeat_label, repeat_inputbox);
- }
+ if (attr & HAS_REPEAT)
+ {
+ repeat_inputbox->set_text(StringUtil::to_string(obj->get_repeat()));
+ place(repeat_label, repeat_inputbox);
+ }
- if (attr & HAS_OWNER)
- {
- owner_inputbox->set_text(StringUtil::to_string(obj->get_owner()));
- place(owner_label, owner_inputbox);
- }
+ if (attr & HAS_OWNER)
+ {
+ owner_inputbox->set_text(StringUtil::to_string(obj->get_owner()));
+ place(owner_label, owner_inputbox);
+ }
- if (attr & HAS_COLOR)
- {
-
color_r_inputbox->set_text(StringUtil::to_string((int)obj->get_color().r));
-
color_g_inputbox->set_text(StringUtil::to_string((int)obj->get_color().g));
-
color_b_inputbox->set_text(StringUtil::to_string((int)obj->get_color().b));
-
color_a_inputbox->set_text(StringUtil::to_string((int)obj->get_color().a));
+ if (attr & HAS_COLOR)
+ {
+
color_r_inputbox->set_text(StringUtil::to_string((int)obj->get_color().r));
+
color_g_inputbox->set_text(StringUtil::to_string((int)obj->get_color().g));
+
color_b_inputbox->set_text(StringUtil::to_string((int)obj->get_color().b));
+
color_a_inputbox->set_text(StringUtil::to_string((int)obj->get_color().a));
- place(color_label);
- place(color_r_inputbox);
- place(color_g_inputbox);
- place(color_b_inputbox);
- place(color_a_inputbox);
- advance();
- }
+ place(color_label);
+ place(color_r_inputbox);
+ place(color_g_inputbox);
+ place(color_b_inputbox);
+ place(color_a_inputbox);
+ advance();
+ }
- if (attr & HAS_SCROLL)
- {
-
scroll_x_inputbox->set_text(StringUtil::to_string(obj->get_scroll_x()));
-
scroll_y_inputbox->set_text(StringUtil::to_string(obj->get_scroll_y()));
+ if (attr & HAS_SCROLL)
+ {
+ scroll_x_inputbox->set_text(StringUtil::to_string(obj->get_scroll_x()));
+ scroll_y_inputbox->set_text(StringUtil::to_string(obj->get_scroll_y()));
- place(scroll_x_label, scroll_x_inputbox);
- place(scroll_y_label, scroll_y_inputbox);
- }
+ place(scroll_x_label, scroll_x_inputbox);
+ place(scroll_y_label, scroll_y_inputbox);
+ }
- if (attr & HAS_PARA)
- {
- para_x_inputbox->set_text(StringUtil::to_string(obj->get_para_x()));
- para_y_inputbox->set_text(StringUtil::to_string(obj->get_para_y()));
+ if (attr & HAS_PARA)
+ {
+ para_x_inputbox->set_text(StringUtil::to_string(obj->get_para_x()));
+ para_y_inputbox->set_text(StringUtil::to_string(obj->get_para_y()));
- place(para_x_label, para_x_inputbox);
- place(para_y_label, para_y_inputbox);
- }
+ place(para_x_label, para_x_inputbox);
+ place(para_y_label, para_y_inputbox);
+ }
- if (attr & HAS_STRETCH)
- {
- stretch_x_checkbox->set_checked(obj->get_stretch_y());
- stretch_y_checkbox->set_checked(obj->get_stretch_y());
+ if (attr & HAS_STRETCH)
+ {
+ stretch_x_checkbox->set_checked(obj->get_stretch_y());
+ stretch_y_checkbox->set_checked(obj->get_stretch_y());
- place(stretch_label);
- place(stretch_x_checkbox);
- place(stretch_y_checkbox);
- advance();
- }
+ place(stretch_label);
+ place(stretch_x_checkbox);
+ place(stretch_y_checkbox);
+ advance();
+ }
- if (attr & HAS_RELEASE_RATE)
- {
-
release_rate_inputbox->set_text(StringUtil::to_string(obj->get_release_rate()));
- place(release_rate_label, release_rate_inputbox);
- }
+ if (attr & HAS_RELEASE_RATE)
+ {
+
release_rate_inputbox->set_text(StringUtil::to_string(obj->get_release_rate()));
+ place(release_rate_label, release_rate_inputbox);
+ }
- if (attr & HAS_STARFIELD)
- {
-
small_stars_inputbox->set_text(StringUtil::to_string(obj->get_small_stars()));
-
middle_stars_inputbox->set_text(StringUtil::to_string(obj->get_middle_stars()));
-
large_stars_inputbox->set_text(StringUtil::to_string(obj->get_large_stars()));
+ if (attr & HAS_STARFIELD)
+ {
+
small_stars_inputbox->set_text(StringUtil::to_string(obj->get_small_stars()));
+
middle_stars_inputbox->set_text(StringUtil::to_string(obj->get_middle_stars()));
+
large_stars_inputbox->set_text(StringUtil::to_string(obj->get_large_stars()));
- place(small_stars_label, small_stars_inputbox);
- place(middle_stars_label, middle_stars_inputbox);
- place(large_stars_label, large_stars_inputbox);
- }
+ place(small_stars_label, small_stars_inputbox);
+ place(middle_stars_label, middle_stars_inputbox);
+ place(large_stars_label, large_stars_inputbox);
+ }
- if (1) // everybody has z-pos
- {
- pos_z_inputbox->set_text(StringUtil::to_string(obj->get_pos_z()));
- place(pos_z_label, pos_z_inputbox);
- }
+ if (1) // everybody has z-pos
+ {
+ pos_z_inputbox->set_text(StringUtil::to_string(obj->get_pos_z()));
+ place(pos_z_label, pos_z_inputbox);
+ }
- if (attr & CAN_ROTATE)
- {
- y_pos += 4;
- place(flip_horizontal_button);
- place(flip_vertical_button);
- place(rotate_90_button);
- place(rotate_270_button);
- y_pos += 36;
- }
+ if (attr & CAN_ROTATE)
+ {
+ y_pos += 4;
+ place(flip_horizontal_button);
+ place(flip_vertical_button);
+ place(rotate_90_button);
+ place(rotate_270_button);
+ y_pos += 36;
}
+ }
else
- {
- place(mesg_label);
- advance();
- }
+ {
+ place(mesg_label);
+ advance();
+ }
finalize();
}
@@ -410,22 +452,22 @@
std::string obj_type;
if (objects.empty())
- {
- type_label->set_text(_("Object:"));
- mesg_label->set_text(_("Nothing selected"));
- set_object(0);
- }
+ {
+ type_label->set_text(_("Object:"));
+ mesg_label->set_text(_("Nothing selected"));
+ set_object(0);
+ }
else if (objects.size() > 1)
- {
- type_label->set_text(_("Object: [Group]"));
- mesg_label->set_text(_("Group not supported"));
- set_object(0);
- }
+ {
+ type_label->set_text(_("Object: [Group]"));
+ mesg_label->set_text(_("Group not supported"));
+ set_object(0);
+ }
else
- {
- type_label->set_text(_("Object: ") +
objects.front()->get_section_name());
- set_object(objects.front());
- }
+ {
+ type_label->set_text(_("Object: ") + objects.front()->get_section_name());
+ set_object(objects.front());
+ }
}
void
@@ -459,14 +501,14 @@
ObjectProperties::on_entrance_direction_change(const ComboItem& item)
{
for(Objects::iterator i = objects.begin(); i != objects.end(); ++i)
- {
- if (item.id == 0)
- (*i)->set_direction("left");
- else if (item.id == 1)
- (*i)->set_direction("misc");
- else // (item.id == 2)
- (*i)->set_direction("right");
- }
+ {
+ if (item.id == 0)
+ (*i)->set_direction("left");
+ else if (item.id == 1)
+ (*i)->set_direction("misc");
+ else // (item.id == 2)
+ (*i)->set_direction("right");
+ }
}
void
@@ -523,71 +565,71 @@
ObjectProperties::on_color_r_change(const std::string& str)
{
for(Objects::iterator i = objects.begin(); i != objects.end(); ++i)
- {
- Color color = (*i)->get_color();
- color.r = StringUtil::to<int>(str);
- (*i)->set_color(color);
- }
+ {
+ Color color = (*i)->get_color();
+ color.r = StringUtil::to<int>(str);
+ (*i)->set_color(color);
+ }
}
void
ObjectProperties::on_color_g_change(const std::string& str)
{
for(Objects::iterator i = objects.begin(); i != objects.end(); ++i)
- {
- Color color = (*i)->get_color();
- color.g = StringUtil::to<int>(str);
- (*i)->set_color(color);
- }
+ {
+ Color color = (*i)->get_color();
+ color.g = StringUtil::to<int>(str);
+ (*i)->set_color(color);
+ }
}
void
ObjectProperties::on_color_b_change(const std::string& str)
{
for(Objects::iterator i = objects.begin(); i != objects.end(); ++i)
- {
- Color color = (*i)->get_color();
- color.b = StringUtil::to<int>(str);
- (*i)->set_color(color);
- }
+ {
+ Color color = (*i)->get_color();
+ color.b = StringUtil::to<int>(str);
+ (*i)->set_color(color);
+ }
}
void
ObjectProperties::on_color_a_change(const std::string& str)
{
for(Objects::iterator i = objects.begin(); i != objects.end(); ++i)
- {
- Color color = (*i)->get_color();
- color.a = StringUtil::to<int>(str);
- (*i)->set_color(color);
- }
+ {
+ Color color = (*i)->get_color();
+ color.a = StringUtil::to<int>(str);
+ (*i)->set_color(color);
+ }
}
void
ObjectProperties::on_small_stars_change(const std::string& str)
{
for(Objects::iterator i = objects.begin(); i != objects.end(); ++i)
- {
- (*i)->set_small_stars(StringUtil::to<int>(str));
- }
+ {
+ (*i)->set_small_stars(StringUtil::to<int>(str));
+ }
}
void
ObjectProperties::on_middle_stars_change(const std::string& str)
{
for(Objects::iterator i = objects.begin(); i != objects.end(); ++i)
- {
- (*i)->set_middle_stars(StringUtil::to<int>(str));
- }
+ {
+ (*i)->set_middle_stars(StringUtil::to<int>(str));
+ }
}
void
ObjectProperties::on_large_stars_change(const std::string& str)
{
for(Objects::iterator i = objects.begin(); i != objects.end(); ++i)
- {
- (*i)->set_large_stars(StringUtil::to<int>(str));
- }
+ {
+ (*i)->set_large_stars(StringUtil::to<int>(str));
+ }
}
void
@@ -597,9 +639,9 @@
if (r <= 0)
r = 1;
for(Objects::iterator i = objects.begin(); i != objects.end(); ++i)
- {
- (*i)->set_repeat(r);
- }
+ {
+ (*i)->set_repeat(r);
+ }
}
void
Modified: trunk/pingus/src/editor/object_properties.hpp
===================================================================
--- trunk/pingus/src/editor/object_properties.hpp 2009-11-04 19:29:46 UTC
(rev 4023)
+++ trunk/pingus/src/editor/object_properties.hpp 2009-11-04 20:52:55 UTC
(rev 4024)
@@ -20,7 +20,7 @@
#include "gui/group_component.hpp"
namespace Editor {
-
+
class Label;
class EditorScreen;
class Combobox;
@@ -112,7 +112,7 @@
void finalize();
void place(GUI::RectComponent* comp);
void place(GUI::RectComponent* comp1, GUI::RectComponent* comp2);
-
+
void on_gptype_change(const ComboItem& item);
void on_stretch_x_change(bool t);
void on_stretch_y_change(bool t);
@@ -140,7 +140,10 @@
void on_flip_vertical();
void on_rotate_90();
void on_rotate_270();
-
+
+private:
+ ObjectProperties(const ObjectProperties&);
+ ObjectProperties & operator=(const ObjectProperties&);
};
} // namespace Editor
Modified: trunk/pingus/src/editor/object_selector.cpp
===================================================================
--- trunk/pingus/src/editor/object_selector.cpp 2009-11-04 19:29:46 UTC (rev
4023)
+++ trunk/pingus/src/editor/object_selector.cpp 2009-11-04 20:52:55 UTC (rev
4024)
@@ -212,15 +212,16 @@
public:
ObjectSelectorButton(ObjectSelectorList* object_list_,
- const Vector2i& pos_, const std::string& sprite_, const
std::string& tooltip_)
- : RectComponent(Rect(pos_, Size(30, 30))),
- object_list(object_list_),
- button_raised(Sprite("core/editor/obj_button-raised")),
- button_pressed(Sprite("core/editor/obj_button-pressed")),
- sprite(Sprite(sprite_)),
- mouse_over(false),
- mouse_down(false),
- tooltip(tooltip_)
+ const Vector2i& pos_, const std::string& sprite_, const
std::string& tooltip_) :
+ RectComponent(Rect(pos_, Size(30, 30))),
+ object_list(object_list_),
+ button_raised(Sprite("core/editor/obj_button-raised")),
+ button_pressed(Sprite("core/editor/obj_button-pressed")),
+ sprite(Sprite(sprite_)),
+ mouse_over(false),
+ mouse_down(false),
+ tooltip(tooltip_),
+ on_click()
{
}
@@ -278,6 +279,10 @@
}
void update_layout() {}
+
+private:
+ ObjectSelectorButton(const ObjectSelectorButton&);
+ ObjectSelectorButton & operator=(const ObjectSelectorButton&);
};
@@ -299,7 +304,8 @@
liquid_set(0),
trap_set(0),
weather_set(0),
- worldobj_set(0)
+ worldobj_set(0),
+ callback()
{
add(object_list = new ObjectSelectorList(editor, this,
Rect(2, 2 + 60 + 2,
rect.get_width() - 2, rect.get_height() - 2)));
Modified: trunk/pingus/src/editor/object_selector_list.cpp
===================================================================
--- trunk/pingus/src/editor/object_selector_list.cpp 2009-11-04 19:29:46 UTC
(rev 4023)
+++ trunk/pingus/src/editor/object_selector_list.cpp 2009-11-04 20:52:55 UTC
(rev 4024)
@@ -29,17 +29,20 @@
namespace Editor {
-ObjectSelectorList::ObjectSelectorList(EditorScreen* editor_, ObjectSelector*
object_selector_, const Rect& rect_)
- : RectComponent(rect_),
- editor(editor_),
- object_selector(object_selector_),
- drawing_context(new DrawingContext(rect, true)),
- offset(0),
- old_offset(0),
- mode(NOTHING),
- current_object(-1),
- drag_object(-1),
- set(0)
+ObjectSelectorList::ObjectSelectorList(EditorScreen* editor_, ObjectSelector*
object_selector_, const Rect& rect_) :
+ RectComponent(rect_),
+ editor(editor_),
+ object_selector(object_selector_),
+ drawing_context(new DrawingContext(rect, true)),
+ offset(0),
+ old_offset(0),
+ drag_start(),
+ mouse_pos(),
+ real_mouse_pos(),
+ mode(NOTHING),
+ current_object(-1),
+ drag_object(-1),
+ set(0)
{
}
@@ -56,46 +59,46 @@
gc.fill_screen(Color(100, 100, 100));
if (set)
+ {
+ gc.push_modelview();
+ gc.translate(0, static_cast<int>(offset));
+
+ for(Objects::const_iterator i = set->get_objects().begin(); i !=
set->get_objects().end(); ++i)
{
- gc.push_modelview();
- gc.translate(0, static_cast<int>(offset));
+ int x = (i - set->get_objects().begin()) % 5;
+ int y = (i - set->get_objects().begin()) / 5;
- for(Objects::const_iterator i = set->get_objects().begin(); i !=
set->get_objects().end(); ++i)
- {
- int x = (i - set->get_objects().begin()) % 5;
- int y = (i - set->get_objects().begin()) / 5;
+ gc.draw((*i)->thumbnail, Vector2i(x * 48, y * 48));
- gc.draw((*i)->thumbnail, Vector2i(x * 48, y * 48));
+ gc.draw_rect(Rect(x * 48, y * 48,
+ x * 48 + 48, y * 48 + 48),
+ Color(155,155,155));
- gc.draw_rect(Rect(x * 48, y * 48,
- x * 48 + 48, y * 48 + 48),
- Color(155,155,155));
+ if (has_mouse_over() && current_object != -1 && (i -
set->get_objects().begin()) == current_object)
+ {
+ gc.draw_fillrect(Rect(x * 48, y * 48,
+ x * 48 + 48, y * 48 + 48),
+ Color(255,255,255, 100));
- if (has_mouse_over() && current_object != -1 && (i -
set->get_objects().begin()) == current_object)
- {
- gc.draw_fillrect(Rect(x * 48, y * 48,
- x * 48 + 48, y * 48 + 48),
- Color(255,255,255, 100));
-
- gc.draw_rect(Rect(x * 48, y * 48,
- x * 48 + 48, y * 48 + 48),
- Color(255,255,255));
- }
- }
+ gc.draw_rect(Rect(x * 48, y * 48,
+ x * 48 + 48, y * 48 + 48),
+ Color(255,255,255));
+ }
+ }
- gc.pop_modelview();
- }
+ gc.pop_modelview();
+ }
parent_gc.draw(gc);
if (set && mode == OBJECT_DRAG)
- {
- Sprite sprite = set->get_objects()[current_object]->sprite;
- parent_gc.draw(sprite,
- real_mouse_pos
- - Vector2i(sprite.get_width()/2, sprite.get_height()/2)
- + sprite.get_offset(),
- 2000.0f);
- }
+ {
+ Sprite sprite = set->get_objects()[current_object]->sprite;
+ parent_gc.draw(sprite,
+ real_mouse_pos
+ - Vector2i(sprite.get_width()/2, sprite.get_height()/2)
+ + sprite.get_offset(),
+ 2000.0f);
+ }
}
void
@@ -104,10 +107,10 @@
if (!set) return;
if (mode == NOTHING && current_object != -1)
- {
- drag_object = current_object;
- mode = OBJECT_DRAG;
- }
+ {
+ drag_object = current_object;
+ mode = OBJECT_DRAG;
+ }
}
void
@@ -116,35 +119,35 @@
if (!set) return;
if (mode == OBJECT_DRAG)
+ {
+ mode = NOTHING;
+
+ if (current_object != -1)
{
- mode = NOTHING;
-
- if (current_object != -1)
- {
- // FIXME: Should check if the current mouse over component
- // is the Viewport, else no drag should take place, this
- // checks if the current mouse_over_comp is the
- // ObjectSelector, which is good enough but not perfect
- if (!object_selector->get_rect().contains(Vector2i(x +
object_selector->get_rect().left,
- y +
object_selector->get_rect().top)))
- {
- Vector2i p = editor->get_viewport()->screen2world(x +
object_selector->get_rect().left,
- y +
object_selector->get_rect().top);
+ // FIXME: Should check if the current mouse over component
+ // is the Viewport, else no drag should take place, this
+ // checks if the current mouse_over_comp is the
+ // ObjectSelector, which is good enough but not perfect
+ if (!object_selector->get_rect().contains(Vector2i(x +
object_selector->get_rect().left,
+ y +
object_selector->get_rect().top)))
+ {
+ Vector2i p = editor->get_viewport()->screen2world(x +
object_selector->get_rect().left,
+ y +
object_selector->get_rect().top);
- // place object with left/top instead of center origin
- p -=
Vector2i(set->get_objects()[current_object]->sprite.get_width()/2,
-
set->get_objects()[current_object]->sprite.get_height()/2);
+ // place object with left/top instead of center origin
+ p -= Vector2i(set->get_objects()[current_object]->sprite.get_width()/2,
+
set->get_objects()[current_object]->sprite.get_height()/2);
- p += set->get_objects()[current_object]->sprite.get_offset();
+ p += set->get_objects()[current_object]->sprite.get_offset();
- LevelObj* obj = set->get_objects()[current_object]->create(p,
editor->get_level()->get_level_impl());
- if (obj)
- editor->add_object(obj);
- else
- std::cout << "ObjectSelectorList::Object: create() not
implemented" << std::endl;
- }
- }
+ LevelObj* obj = set->get_objects()[current_object]->create(p,
editor->get_level()->get_level_impl());
+ if (obj)
+ editor->add_object(obj);
+ else
+ std::cout << "ObjectSelectorList::Object: create() not implemented"
<< std::endl;
+ }
}
+ }
}
void
@@ -153,11 +156,11 @@
if (!set) return;
if (mode == NOTHING)
- {
- drag_start = Vector2i(x,y);
- mode = SCROLLING;
- old_offset = offset;
- }
+ {
+ drag_start = Vector2i(x,y);
+ mode = SCROLLING;
+ old_offset = offset;
+ }
}
void
@@ -182,21 +185,21 @@
int height = (set->get_objects().size() / width) +
((set->get_objects().size() % width > 0) ? 1 : 0);
if (mode != OBJECT_DRAG)
+ {
+ if (!set->get_objects().empty())
{
- if (!set->get_objects().empty())
- {
- int obj_x = Math::clamp(0, mouse_pos.x / 48, width - 1);
- int obj_y = Math::clamp(0, int(mouse_pos.y - offset) / 48, height-1);
+ int obj_x = Math::clamp(0, mouse_pos.x / 48, width - 1);
+ int obj_y = Math::clamp(0, int(mouse_pos.y - offset) / 48, height-1);
- current_object = Math::clamp(-1, (obj_y * 5) + obj_x,
int(set->get_objects().size()-1));
- }
+ current_object = Math::clamp(-1, (obj_y * 5) + obj_x,
int(set->get_objects().size()-1));
}
+ }
if (mode == SCROLLING)
- {
- offset = old_offset + (y - drag_start.y);
- offset = Math::clamp(Math::min(rect.get_height() - (height * 48.0f),
0.0f), offset, 0.0f);
- }
+ {
+ offset = old_offset + (y - drag_start.y);
+ offset = Math::clamp(Math::min(rect.get_height() - (height * 48.0f),
0.0f), offset, 0.0f);
+ }
}
void
Modified: trunk/pingus/src/editor/object_selector_set.cpp
===================================================================
--- trunk/pingus/src/editor/object_selector_set.cpp 2009-11-04 19:29:46 UTC
(rev 4023)
+++ trunk/pingus/src/editor/object_selector_set.cpp 2009-11-04 20:52:55 UTC
(rev 4024)
@@ -18,10 +18,11 @@
namespace Editor {
-ObjectSelectorSet::ObjectSelectorSet(ObjectSelectorList* list_, int thumb_w,
int thumb_h)
- : list(list_),
- thumb_size(thumb_w, thumb_h),
- offset(0)
+ObjectSelectorSet::ObjectSelectorSet(ObjectSelectorList* list_, int thumb_w,
int thumb_h) :
+ list(list_),
+ thumb_size(thumb_w, thumb_h),
+ objects(),
+ offset(0)
{
}
Modified: trunk/pingus/src/editor/panel.cpp
===================================================================
--- trunk/pingus/src/editor/panel.cpp 2009-11-04 19:29:46 UTC (rev 4023)
+++ trunk/pingus/src/editor/panel.cpp 2009-11-04 20:52:55 UTC (rev 4024)
@@ -90,14 +90,14 @@
gc.draw(sprite, pos + Vector2i(5,5));
if (mouse_over)
- {
- int t_w = Fonts::verdana11.get_width(tooltip);
- Rect t_r(pos.x + 17 - t_w/2 - 4, pos.y + 38 - 2,
- pos.x + 17 + t_w/2 + 4, pos.y + 38 +
Fonts::verdana11.get_height() + 4);
- gc.draw_fillrect(t_r, Color(255, 255, 200), 1000.0f);
- gc.draw_rect(t_r, Color(0,0,0), 1000.0f);
- gc.print_center(Fonts::verdana11, Vector2i(pos.x + 17, pos.y + 38),
tooltip, 1000.0f);
- }
+ {
+ int t_w = Fonts::verdana11.get_width(tooltip);
+ Rect t_r(pos.x + 17 - t_w/2 - 4, pos.y + 38 - 2,
+ pos.x + 17 + t_w/2 + 4, pos.y + 38 +
Fonts::verdana11.get_height() + 4);
+ gc.draw_fillrect(t_r, Color(255, 255, 200), 1000.0f);
+ gc.draw_rect(t_r, Color(0,0,0), 1000.0f);
+ gc.print_center(Fonts::verdana11, Vector2i(pos.x + 17, pos.y + 38),
tooltip, 1000.0f);
+ }
}
/** Emmitted when pointer enters the region of the component */
@@ -144,10 +144,11 @@
PanelButton & operator=(const PanelButton&);
};
-Panel::Panel(EditorScreen* editor_)
- : editor(editor_),
- logo("core/editor/logo"),
- pos(2,2)
+Panel::Panel(EditorScreen* editor_) :
+ editor(editor_),
+ logo("core/editor/logo"),
+ pos(2,2),
+ callback()
{
editor->get_gui_manager()->add(this);
@@ -189,18 +190,18 @@
&EditorScreen::objects_lower_to_bottom);
if (0)
- { // rotate and flip are now in the object properties
- add_separator();
- add_button("core/editor/object-flip-horizontal", _("Flip object
horizontally") + " (F)",
- &EditorScreen::objects_flip_horizontal);
- add_button("core/editor/object-flip-vertical", _("Flip object
vertically") + " (Shift+F)",
- &EditorScreen::objects_flip_vertical);
- add_separator();
- add_button("core/editor/object-rotate-left", _("Rotate object -90
degree") + " (Shift+R)",
- &EditorScreen::objects_rotate_left);
- add_button("core/editor/object-rotate-right", _("Rotate object 90
degree") + " (R)",
- &EditorScreen::objects_rotate_right);
- }
+ { // rotate and flip are now in the object properties
+ add_separator();
+ add_button("core/editor/object-flip-horizontal", _("Flip object
horizontally") + " (F)",
+ &EditorScreen::objects_flip_horizontal);
+ add_button("core/editor/object-flip-vertical", _("Flip object vertically")
+ " (Shift+F)",
+ &EditorScreen::objects_flip_vertical);
+ add_separator();
+ add_button("core/editor/object-rotate-left", _("Rotate object -90
degree") + " (Shift+R)",
+ &EditorScreen::objects_rotate_left);
+ add_button("core/editor/object-rotate-right", _("Rotate object 90 degree")
+ " (R)",
+ &EditorScreen::objects_rotate_right);
+ }
// add_separator();
//add_button("core/editor/snap-grid", "Snap objects to grid",
Modified: trunk/pingus/src/editor/viewport.cpp
===================================================================
--- trunk/pingus/src/editor/viewport.cpp 2009-11-04 19:29:46 UTC (rev
4023)
+++ trunk/pingus/src/editor/viewport.cpp 2009-11-04 20:52:55 UTC (rev
4024)
@@ -31,15 +31,22 @@
namespace Editor {
// Constructor
-Viewport::Viewport(EditorScreen* e, const Rect& rect_)
- : RectComponent(rect_),
- state(rect.get_width(), rect.get_height()),
- drawing_context(new DrawingContext(rect)),
- editor(e),
- autoscroll(false),
- highlighted_area(0,0,0,0),
- snap_to(false),
- current_action(NOTHING)
+Viewport::Viewport(EditorScreen* e, const Rect& rect_) :
+ RectComponent(rect_),
+ state(rect.get_width(), rect.get_height()),
+ drawing_context(new DrawingContext(rect)),
+ editor(e),
+ autoscroll(false),
+ mouse_world_pos(),
+ mouse_screen_pos(),
+ drag_world_pos(),
+ drag_screen_pos(),
+ selected_objs(),
+ highlighted_area(0,0,0,0),
+ context_menu(),
+ snap_to(false),
+ current_action(NOTHING),
+ selection_changed()
{
}
Modified: trunk/pingus/src/gui/group_component.cpp
===================================================================
--- trunk/pingus/src/gui/group_component.cpp 2009-11-04 19:29:46 UTC (rev
4023)
+++ trunk/pingus/src/gui/group_component.cpp 2009-11-04 20:52:55 UTC (rev
4024)
@@ -20,14 +20,15 @@
namespace GUI {
-GroupComponent::GroupComponent(const Rect& rect_, bool clip_)
- : RectComponent(rect_),
- drawing_context(rect_, clip_),
- mouse_over_comp(0),
- focused_comp(0),
- grabbed_comp(0),
- primary_pressed_comp(0),
- secondary_pressed_comp(0)
+GroupComponent::GroupComponent(const Rect& rect_, bool clip_) :
+ RectComponent(rect_),
+ children(),
+ drawing_context(rect_, clip_),
+ mouse_over_comp(0),
+ focused_comp(0),
+ grabbed_comp(0),
+ primary_pressed_comp(0),
+ secondary_pressed_comp(0)
{
}
Modified: trunk/pingus/src/gui/surface_button.cpp
===================================================================
--- trunk/pingus/src/gui/surface_button.cpp 2009-11-04 19:29:46 UTC (rev
4023)
+++ trunk/pingus/src/gui/surface_button.cpp 2009-11-04 20:52:55 UTC (rev
4024)
@@ -24,8 +24,14 @@
SurfaceButton::SurfaceButton (int arg_x_pos, int arg_y_pos,
const std::string& arg_button_surface,
const std::string& arg_button_pressed_surface,
- const std::string& arg_button_mouse_over_surface)
- : x_pos (arg_x_pos), y_pos (arg_y_pos), pressed (false), mouse_over (false)
+ const std::string& arg_button_mouse_over_surface)
:
+ x_pos (arg_x_pos),
+ y_pos (arg_y_pos),
+ button_surface(),
+ button_pressed_surface(),
+ button_mouse_over_surface(),
+ pressed (false),
+ mouse_over (false)
{
button_surface = Sprite(arg_button_surface);
button_pressed_surface = Sprite(arg_button_pressed_surface);
@@ -51,11 +57,11 @@
SurfaceButton::is_at (int x, int y)
{
/*std::cout << "Is AT: " << (x > x_pos && x < x_pos +
int(button_surface.get_width ())
- && y > y_pos && y < y_pos +
int(button_surface.get_height ()))
- << std::endl;*/
+ && y > y_pos && y < y_pos + int(button_surface.get_height ()))
+ << std::endl;*/
return x > x_pos && x < x_pos + int(button_surface.get_width ())
- && y > y_pos && y < y_pos + int(button_surface.get_height ());
+ && y > y_pos && y < y_pos + int(button_surface.get_height ());
}
void
Modified: trunk/pingus/src/input/controller.cpp
===================================================================
--- trunk/pingus/src/input/controller.cpp 2009-11-04 19:29:46 UTC (rev
4023)
+++ trunk/pingus/src/input/controller.cpp 2009-11-04 20:52:55 UTC (rev
4024)
@@ -28,7 +28,13 @@
return current_;
}
-Controller::Controller(const ControllerDescription& desc)
+Controller::Controller(const ControllerDescription& desc) :
+ buttons(),
+ axes(),
+ pointers(),
+ scrollers(),
+ keyboards(),
+ events()
{
current_ = this;
Modified: trunk/pingus/src/input/controller.hpp
===================================================================
--- trunk/pingus/src/input/controller.hpp 2009-11-04 19:29:46 UTC (rev
4023)
+++ trunk/pingus/src/input/controller.hpp 2009-11-04 20:52:55 UTC (rev
4024)
@@ -47,6 +47,7 @@
std::vector<ControllerKeyboard*> keyboards;
std::vector<Event> events;
+
public:
void clear_events();
void poll_events(std::vector<Event>& events);
@@ -73,6 +74,7 @@
void add_keyboard(int id, ControllerKeyboard* keyboard);
void update(float delta);
+
private:
Controller(const Controller&);
Controller& operator= (const Controller&);
Modified: trunk/pingus/src/input/controller_description.cpp
===================================================================
--- trunk/pingus/src/input/controller_description.cpp 2009-11-04 19:29:46 UTC
(rev 4023)
+++ trunk/pingus/src/input/controller_description.cpp 2009-11-04 20:52:55 UTC
(rev 4024)
@@ -20,7 +20,9 @@
namespace Input {
-ControllerDescription::ControllerDescription()
+ControllerDescription::ControllerDescription() :
+ str_to_event(),
+ id_to_event()
{
}
Modified: trunk/pingus/src/input/controller_description.hpp
===================================================================
--- trunk/pingus/src/input/controller_description.hpp 2009-11-04 19:29:46 UTC
(rev 4023)
+++ trunk/pingus/src/input/controller_description.hpp 2009-11-04 20:52:55 UTC
(rev 4024)
@@ -28,6 +28,12 @@
EventType type;
int id;
std::string name;
+
+ InputEventDefinition() :
+ type(),
+ id(),
+ name()
+ {}
};
class ControllerDescription
Modified: trunk/pingus/src/input/manager.cpp
===================================================================
--- trunk/pingus/src/input/manager.cpp 2009-11-04 19:29:46 UTC (rev 4023)
+++ trunk/pingus/src/input/manager.cpp 2009-11-04 20:52:55 UTC (rev 4024)
@@ -38,7 +38,10 @@
namespace Input {
-Manager::Manager()
+Manager::Manager() :
+ drivers(),
+ controllers(),
+ desc()
{
desc.add_axis("action-axis", ACTION_AXIS);
@@ -72,22 +75,22 @@
Manager::~Manager()
{
for(Drivers::iterator i = drivers.begin(); i != drivers.end(); ++i)
- {
- delete *i;
- }
+ {
+ delete *i;
+ }
}
static std::string get_driver_part(const std::string& fullname)
{
std::string::size_type i = fullname.find_first_of(':');
if (i != std::string::npos)
- {
- return fullname.substr(0, i);
- }
+ {
+ return fullname.substr(0, i);
+ }
else
- {
- return "core";
- }
+ {
+ return "core";
+ }
}
Controller*
@@ -98,94 +101,94 @@
FileReader reader = FileReader::parse(filename);
if (reader.get_name() != "pingus-controller")
- {
- PingusError::raise("Controller: invalid config file '" + filename.str()
+ "'");
- }
+ {
+ PingusError::raise("Controller: invalid config file '" + filename.str() +
"'");
+ }
else
+ {
+ const std::vector<FileReader>& sections = reader.get_sections();
+ for (std::vector<FileReader>::const_iterator i = sections.begin();
+ i != sections.end(); ++i)
{
- const std::vector<FileReader>& sections = reader.get_sections();
- for (std::vector<FileReader>::const_iterator i = sections.begin();
- i != sections.end(); ++i)
+ if (StringUtil::has_suffix(i->get_name(), "pointer"))
+ {
+ const std::vector<FileReader>& pointers = i->get_sections();
+ for(std::vector<FileReader>::const_iterator j = pointers.begin(); j !=
pointers.end(); ++j)
{
- if (StringUtil::has_suffix(i->get_name(), "pointer"))
- {
- const std::vector<FileReader>& pointers = i->get_sections();
- for(std::vector<FileReader>::const_iterator j =
pointers.begin(); j != pointers.end(); ++j)
- {
- int id = desc.get_definition(i->get_name()).id;
- ControllerPointer* ctrl_pointer =
controller->get_pointer(id);
- Pointer* pointer = create_pointer(*j, ctrl_pointer);
- if (pointer)
- ctrl_pointer->add_pointer(pointer);
- else
- std::cout << "Manager: pointer: Couldn't create pointer "
<< j->get_name() << std::endl;
- }
+ int id = desc.get_definition(i->get_name()).id;
+ ControllerPointer* ctrl_pointer = controller->get_pointer(id);
+ Pointer* pointer = create_pointer(*j, ctrl_pointer);
+ if (pointer)
+ ctrl_pointer->add_pointer(pointer);
+ else
+ std::cout << "Manager: pointer: Couldn't create pointer " <<
j->get_name() << std::endl;
+ }
- }
- else if (StringUtil::has_suffix(i->get_name(), "scroller"))
- {
- const std::vector<FileReader>& scrollers = i->get_sections();
- for(std::vector<FileReader>::const_iterator j =
scrollers.begin(); j != scrollers.end(); ++j)
- {
- int id = desc.get_definition(i->get_name()).id;
- ControllerScroller* ctrl_scroller =
controller->get_scroller(id);
- Scroller* scroller = create_scroller(*j, ctrl_scroller);
- if (scroller)
- ctrl_scroller->add_scroller(scroller);
- else
- std::cout << "Manager: scroller: Couldn't create scroller
" << j->get_name() << std::endl;
- }
+ }
+ else if (StringUtil::has_suffix(i->get_name(), "scroller"))
+ {
+ const std::vector<FileReader>& scrollers = i->get_sections();
+ for(std::vector<FileReader>::const_iterator j = scrollers.begin(); j
!= scrollers.end(); ++j)
+ {
+ int id = desc.get_definition(i->get_name()).id;
+ ControllerScroller* ctrl_scroller = controller->get_scroller(id);
+ Scroller* scroller = create_scroller(*j, ctrl_scroller);
+ if (scroller)
+ ctrl_scroller->add_scroller(scroller);
+ else
+ std::cout << "Manager: scroller: Couldn't create scroller " <<
j->get_name() << std::endl;
+ }
- }
- else if (StringUtil::has_suffix(i->get_name(), "button"))
- {
- const std::vector<FileReader>& buttons = i->get_sections();
- for(std::vector<FileReader>::const_iterator j = buttons.begin();
j != buttons.end(); ++j)
- {
- int id = desc.get_definition(i->get_name()).id;
- ControllerButton* ctrl_button = controller->get_button(id);
- Button* button = create_button(*j, ctrl_button);
- if (button)
- ctrl_button->add_button(button);
- else
- std::cout << "Manager: button: Couldn't create button " <<
j->get_name() << std::endl;
- }
- }
- else if (StringUtil::has_suffix(i->get_name(), "axis"))
- {
- const std::vector<FileReader>& axes = i->get_sections();
- for(std::vector<FileReader>::const_iterator j = axes.begin(); j
!= axes.end(); ++j)
- {
- int id = desc.get_definition(i->get_name()).id;
- ControllerAxis* ctrl_axis = controller->get_axis(id);
- Axis* axis = create_axis(*j, ctrl_axis);
- if (axis)
- ctrl_axis->add_axis(axis);
- else
- std::cout << "Manager: axis: Couldn't create axis " <<
j->get_name() << std::endl;
- }
- }
- else if (StringUtil::has_suffix(i->get_name(), "keyboard"))
- {
- const std::vector<FileReader>& keyboards = i->get_sections();
- for(std::vector<FileReader>::const_iterator j =
keyboards.begin(); j != keyboards.end(); ++j)
- {
- int id = desc.get_definition(i->get_name()).id;
- ControllerKeyboard* ctrl_keyboard =
controller->get_keyboard(id);
- Keyboard* keyboard = create_keyboard(*j, ctrl_keyboard);
- if (keyboard)
- ctrl_keyboard->add_keyboard(keyboard);
- else
- std::cout << "Manager: keyboard: Couldn't create keyboard
" << j->get_name() << std::endl;
- }
- }
+ }
+ else if (StringUtil::has_suffix(i->get_name(), "button"))
+ {
+ const std::vector<FileReader>& buttons = i->get_sections();
+ for(std::vector<FileReader>::const_iterator j = buttons.begin(); j !=
buttons.end(); ++j)
+ {
+ int id = desc.get_definition(i->get_name()).id;
+ ControllerButton* ctrl_button = controller->get_button(id);
+ Button* button = create_button(*j, ctrl_button);
+ if (button)
+ ctrl_button->add_button(button);
else
- {
- PingusError::raise(std::string("Manager: Unkown Element in
Controller Config: ")
- + i->get_name());
- }
+ std::cout << "Manager: button: Couldn't create button " <<
j->get_name() << std::endl;
}
+ }
+ else if (StringUtil::has_suffix(i->get_name(), "axis"))
+ {
+ const std::vector<FileReader>& axes = i->get_sections();
+ for(std::vector<FileReader>::const_iterator j = axes.begin(); j !=
axes.end(); ++j)
+ {
+ int id = desc.get_definition(i->get_name()).id;
+ ControllerAxis* ctrl_axis = controller->get_axis(id);
+ Axis* axis = create_axis(*j, ctrl_axis);
+ if (axis)
+ ctrl_axis->add_axis(axis);
+ else
+ std::cout << "Manager: axis: Couldn't create axis " <<
j->get_name() << std::endl;
+ }
+ }
+ else if (StringUtil::has_suffix(i->get_name(), "keyboard"))
+ {
+ const std::vector<FileReader>& keyboards = i->get_sections();
+ for(std::vector<FileReader>::const_iterator j = keyboards.begin(); j
!= keyboards.end(); ++j)
+ {
+ int id = desc.get_definition(i->get_name()).id;
+ ControllerKeyboard* ctrl_keyboard = controller->get_keyboard(id);
+ Keyboard* keyboard = create_keyboard(*j, ctrl_keyboard);
+ if (keyboard)
+ ctrl_keyboard->add_keyboard(keyboard);
+ else
+ std::cout << "Manager: keyboard: Couldn't create keyboard " <<
j->get_name() << std::endl;
+ }
+ }
+ else
+ {
+ PingusError::raise(std::string("Manager: Unkown Element in Controller
Config: ")
+ + i->get_name());
+ }
}
+ }
Controller* ctrl = controller.release();
controllers.push_back(ctrl);
@@ -207,12 +210,12 @@
Manager::get_driver(const std::string& name)
{
for(Drivers::iterator i = drivers.begin(); i != drivers.end(); ++i)
+ {
+ if ((*i)->get_name() == name)
{
- if ((*i)->get_name() == name)
- {
- return *i;
- }
+ return *i;
}
+ }
return 0;
}
@@ -222,41 +225,41 @@
Driver* driver = get_driver(name);
if (driver)
- {
- return driver;
- }
+ {
+ return driver;
+ }
else
- {
- std::cout << "Manager: Loading driver '" << name << "'" << std::endl;
+ {
+ std::cout << "Manager: Loading driver '" << name << "'" << std::endl;
- if (name == "sdl") {
- driver = new SDLDriver();
- } else if (name == "core") {
- driver = new CoreDriver(this);
+ if (name == "sdl") {
+ driver = new SDLDriver();
+ } else if (name == "core") {
+ driver = new CoreDriver(this);
#ifdef HAVE_LINUXUSBMOUSE
- } else if (name == "usbmouse") {
- driver = new USBMouseDriver();
+ } else if (name == "usbmouse") {
+ driver = new USBMouseDriver();
#endif
#ifdef HAVE_LINUXEVDEV
- } else if (name == "evdev") {
- driver = new EvdevDriver();
+ } else if (name == "evdev") {
+ driver = new EvdevDriver();
#endif
#ifdef HAVE_XINPUT
- } else if (name == "xinput") {
- driver = new XInputDriver();
+ } else if (name == "xinput") {
+ driver = new XInputDriver();
#endif
#ifdef HAVE_CWIID
- } else if (name == "wiimote") {
- driver = new WiimoteDriver();
+ } else if (name == "wiimote") {
+ driver = new WiimoteDriver();
#endif
- } else {
- std::cout << "Manager: Unknown driver: " << name << std::endl;
- return 0;
- }
+ } else {
+ std::cout << "Manager: Unknown driver: " << name << std::endl;
+ return 0;
+ }
- drivers.push_back(driver);
- return driver;
- }
+ drivers.push_back(driver);
+ return driver;
+ }
}
Button*
@@ -266,14 +269,14 @@
Driver* drv = load_driver(driver);
if (drv)
- {
- return drv->create_button(reader, parent);
- }
+ {
+ return drv->create_button(reader, parent);
+ }
else
- {
- std::cout << "Manager: Error: Couldn't find driver: '" << driver << "'"
<< std::endl;
- return 0;
- }
+ {
+ std::cout << "Manager: Error: Couldn't find driver: '" << driver << "'" <<
std::endl;
+ return 0;
+ }
}
Axis*
@@ -283,14 +286,14 @@
Driver* drv = load_driver(driver);
if (drv)
- {
- return drv->create_axis(reader, parent);
- }
+ {
+ return drv->create_axis(reader, parent);
+ }
else
- {
- std::cout << "Manager: Error: Couldn't find driver: '" << driver << "'"
<< std::endl;
- return 0;
- }
+ {
+ std::cout << "Manager: Error: Couldn't find driver: '" << driver << "'" <<
std::endl;
+ return 0;
+ }
}
Pointer*
@@ -300,14 +303,14 @@
Driver* drv = load_driver(driver);
if (drv)
- {
- return drv->create_pointer(reader, parent);
- }
+ {
+ return drv->create_pointer(reader, parent);
+ }
else
- {
- std::cout << "Manager: Error: Couldn't find driver: '" << driver << "'"
<< std::endl;
- return 0;
- }
+ {
+ std::cout << "Manager: Error: Couldn't find driver: '" << driver << "'" <<
std::endl;
+ return 0;
+ }
}
Scroller*
@@ -317,14 +320,14 @@
Driver* drv = load_driver(driver);
if (drv)
- {
- return drv->create_scroller(reader, parent);
- }
+ {
+ return drv->create_scroller(reader, parent);
+ }
else
- {
- std::cout << "Manager: Error: Couldn't find driver: '" << driver << "'"
<< std::endl;
- return 0;
- }
+ {
+ std::cout << "Manager: Error: Couldn't find driver: '" << driver << "'" <<
std::endl;
+ return 0;
+ }
}
Keyboard*
@@ -334,14 +337,14 @@
Driver* drv = load_driver(driver);
if (drv)
- {
- return drv->create_keyboard(reader, parent);
- }
+ {
+ return drv->create_keyboard(reader, parent);
+ }
else
- {
- std::cout << "Manager: Error: Couldn't find driver: '" << driver << "'"
<< std::endl;
- return 0;
- }
+ {
+ std::cout << "Manager: Error: Couldn't find driver: '" << driver << "'" <<
std::endl;
+ return 0;
+ }
}
} // namespace Input
Modified: trunk/pingus/src/input/sdl_driver.cpp
===================================================================
--- trunk/pingus/src/input/sdl_driver.cpp 2009-11-04 19:29:46 UTC (rev
4023)
+++ trunk/pingus/src/input/sdl_driver.cpp 2009-11-04 20:52:55 UTC (rev
4024)
@@ -23,10 +23,19 @@
namespace Input {
-SDLDriver::SDLDriver()
- : keyboard_binding(0)
+SDLDriver::SDLDriver() :
+ scroller_bindings(),
+ pointer_bindings(),
+ keyboard_button_bindings(),
+ mouse_button_bindings(),
+ joystick_button_bindings(),
+ joystick_axis_bindings(),
+ keyboard_binding(0),
+ string2key(),
+ joystick_handles()
{
- for (int i = 0; i < SDLK_LAST; ++i) {
+ for (int i = 0; i < SDLK_LAST; ++i)
+ {
char* key_name = SDL_GetKeyName(static_cast<SDLKey>(i));
string2key[key_name] = static_cast<SDLKey>(i);
@@ -51,130 +60,130 @@
{
//std::cout << "SDL: " << reader.get_name() << std::endl;
if (reader.get_name() == "sdl:joystick-button")
- {
- JoystickButtonBinding binding;
+ {
+ JoystickButtonBinding binding;
- reader.read_int("device", binding.device);
- reader.read_int("button", binding.button);
+ reader.read_int("device", binding.device);
+ reader.read_int("button", binding.button);
- if (open_joystick(binding.device))
- {
- binding.binding = new Button(parent);
- joystick_button_bindings.push_back(binding);
+ if (open_joystick(binding.device))
+ {
+ binding.binding = new Button(parent);
+ joystick_button_bindings.push_back(binding);
- return binding.binding;
- }
- else
- {
- return 0;
- }
+ return binding.binding;
}
+ else
+ {
+ return 0;
+ }
+ }
else if (reader.get_name() == "sdl:mouse-button")
- {
- MouseButtonBinding binding;
+ {
+ MouseButtonBinding binding;
- reader.read_int("button", binding.button);
- binding.binding = new Button(parent);
- mouse_button_bindings.push_back(binding);
+ reader.read_int("button", binding.button);
+ binding.binding = new Button(parent);
+ mouse_button_bindings.push_back(binding);
- return binding.binding;
- }
+ return binding.binding;
+ }
else if (reader.get_name() == "sdl:keyboard-button")
+ {
+ std::string key;
+ if (reader.read_string("key", key))
{
- std::string key;
- if (reader.read_string("key", key))
- {
- String2Key::iterator i = string2key.find(key);
- if (i != string2key.end())
- {
- KeyboardButtonBinding binding;
+ String2Key::iterator i = string2key.find(key);
+ if (i != string2key.end())
+ {
+ KeyboardButtonBinding binding;
- binding.key = i->second;
- binding.binding = new Button(parent);
- keyboard_button_bindings.push_back(binding);
+ binding.key = i->second;
+ binding.binding = new Button(parent);
+ keyboard_button_bindings.push_back(binding);
- return binding.binding;
- }
- else
- {
- std::cout << "SDLDriver: Couldn't find keysym for key '" << key
<< "'" << std::endl;
- return 0;
- }
- }
- else
- {
- std::cout << "SDLDriver: 'key' missing" << std::endl;
- return 0;
- }
+ return binding.binding;
+ }
+ else
+ {
+ std::cout << "SDLDriver: Couldn't find keysym for key '" << key << "'"
<< std::endl;
+ return 0;
+ }
}
- else
+ else
{
+ std::cout << "SDLDriver: 'key' missing" << std::endl;
return 0;
}
+ }
+ else
+ {
+ return 0;
+ }
}
Axis*
SDLDriver::create_axis(const FileReader& reader, Control* parent)
{
if (reader.get_name() == "sdl:joystick-axis")
- {
- JoystickAxisBinding binding;
+ {
+ JoystickAxisBinding binding;
- reader.read_int("device", binding.device);
- reader.read_int("axis", binding.axis);
+ reader.read_int("device", binding.device);
+ reader.read_int("axis", binding.axis);
- if (open_joystick(binding.device))
- {
- binding.binding = new Axis(parent);
- joystick_axis_bindings.push_back(binding);
+ if (open_joystick(binding.device))
+ {
+ binding.binding = new Axis(parent);
+ joystick_axis_bindings.push_back(binding);
- return binding.binding;
- }
- else
- {
- return 0;
- }
+ return binding.binding;
}
- else
+ else
{
return 0;
}
+ }
+ else
+ {
+ return 0;
+ }
}
Scroller*
SDLDriver::create_scroller(const FileReader& reader, Control* parent)
{
if (reader.get_name() == "sdl:mouse-scroller")
- {
- ScrollerBinding binding;
+ {
+ ScrollerBinding binding;
- binding.binding = new Scroller(parent);
- scroller_bindings.push_back(binding);
+ binding.binding = new Scroller(parent);
+ scroller_bindings.push_back(binding);
- return binding.binding;
- }
+ return binding.binding;
+ }
else
- {
- return 0;
- }
+ {
+ return 0;
+ }
}
Pointer*
SDLDriver::create_pointer(const FileReader& reader, Control* parent)
{
if (reader.get_name() == "sdl:mouse-pointer")
- {
- PointerBinding binding;
+ {
+ PointerBinding binding;
- binding.binding = new Pointer(parent);
- pointer_bindings.push_back(binding);
+ binding.binding = new Pointer(parent);
+ pointer_bindings.push_back(binding);
- return binding.binding;
- }
+ return binding.binding;
+ }
else
- {
- return 0;
- }
+ {
+ return 0;
+ }
}
bool
@@ -182,23 +191,23 @@
{
JoystickHandles::iterator i = joystick_handles.find(device);
if (i == joystick_handles.end())
+ {
+ SDL_Joystick* joy = SDL_JoystickOpen(device);
+ if (joy)
{
- SDL_Joystick* joy = SDL_JoystickOpen(device);
- if (joy)
- {
- joystick_handles[device] = joy;
- return true;
- }
- else
- {
- std::cout << "SDLDriver: Couldn't open joystick number " << device
<< std::endl;
- return false;
- }
+ joystick_handles[device] = joy;
+ return true;
}
- else
+ else
{
- return true;
+ std::cout << "SDLDriver: Couldn't open joystick number " << device <<
std::endl;
+ return false;
}
+ }
+ else
+ {
+ return true;
+ }
}
void
@@ -209,97 +218,97 @@
// the SDLDriver
SDL_Event event;
while (SDL_PollEvent(&event))
+ {
+ switch(event.type)
{
- switch(event.type)
+ case SDL_QUIT: // FIXME: make this into a GameEvent
+ ScreenManager::instance()->pop_all_screens();
+ break;
+
+ case SDL_MOUSEMOTION:
+ for(std::vector<PointerBinding>::iterator i = pointer_bindings.begin();
+ i != pointer_bindings.end(); ++i)
{
- case SDL_QUIT: // FIXME: make this into a GameEvent
- ScreenManager::instance()->pop_all_screens();
- break;
+ i->binding->set_pos(Vector2f(event.motion.x, event.motion.y));
+ }
- case SDL_MOUSEMOTION:
- for(std::vector<PointerBinding>::iterator i =
pointer_bindings.begin();
- i != pointer_bindings.end(); ++i)
- {
- i->binding->set_pos(Vector2f(event.motion.x, event.motion.y));
- }
+ for(std::vector<ScrollerBinding>::iterator i =
scroller_bindings.begin();
+ i != scroller_bindings.end(); ++i)
+ {
+ i->binding->set_delta(Vector2f(event.motion.xrel,
event.motion.yrel));
+ }
+ break;
- for(std::vector<ScrollerBinding>::iterator i =
scroller_bindings.begin();
- i != scroller_bindings.end(); ++i)
- {
- i->binding->set_delta(Vector2f(event.motion.xrel,
event.motion.yrel));
- }
- break;
+ case SDL_MOUSEBUTTONDOWN:
+ case SDL_MOUSEBUTTONUP:
+ for(std::vector<MouseButtonBinding>::iterator i =
mouse_button_bindings.begin();
+ i != mouse_button_bindings.end(); ++i)
+ {
+ if (event.button.button == (*i).button)
+ {
+ if (event.button.state == SDL_PRESSED)
+ (*i).binding->set_state(BUTTON_PRESSED);
+ else
+ (*i).binding->set_state(BUTTON_RELEASED);
+ }
+ }
+ break;
- case SDL_MOUSEBUTTONDOWN:
- case SDL_MOUSEBUTTONUP:
- for(std::vector<MouseButtonBinding>::iterator i =
mouse_button_bindings.begin();
- i != mouse_button_bindings.end(); ++i)
- {
- if (event.button.button == (*i).button)
- {
- if (event.button.state == SDL_PRESSED)
- (*i).binding->set_state(BUTTON_PRESSED);
- else
- (*i).binding->set_state(BUTTON_RELEASED);
- }
- }
- break;
+ case SDL_VIDEORESIZE:
+ Display::resize(Size(event.resize.w, event.resize.h));
+ break;
- case SDL_VIDEORESIZE:
- Display::resize(Size(event.resize.w, event.resize.h));
- break;
+ case SDL_KEYDOWN:
+ if (keyboard_binding)
+ keyboard_binding->send_char(event.key.keysym.unicode);
+
+ case SDL_KEYUP:
+ if (event.key.state == SDL_PRESSED)
+ global_event.on_button_press(event.key);
+ else
+ global_event.on_button_release(event.key);
- case SDL_KEYDOWN:
- if (keyboard_binding)
- keyboard_binding->send_char(event.key.keysym.unicode);
-
- case SDL_KEYUP:
+ for(std::vector<KeyboardButtonBinding>::iterator i =
keyboard_button_bindings.begin();
+ i != keyboard_button_bindings.end(); ++i)
+ {
+ if (event.key.keysym.sym == i->key)
+ {
if (event.key.state == SDL_PRESSED)
- global_event.on_button_press(event.key);
+ i->binding->set_state(BUTTON_PRESSED);
else
- global_event.on_button_release(event.key);
+ i->binding->set_state(BUTTON_RELEASED);
+ }
+ }
+ break;
- for(std::vector<KeyboardButtonBinding>::iterator i =
keyboard_button_bindings.begin();
- i != keyboard_button_bindings.end(); ++i)
- {
- if (event.key.keysym.sym == i->key)
- {
- if (event.key.state == SDL_PRESSED)
- i->binding->set_state(BUTTON_PRESSED);
- else
- i->binding->set_state(BUTTON_RELEASED);
- }
- }
- break;
-
- case SDL_JOYAXISMOTION:
- for(std::vector<JoystickAxisBinding>::iterator i =
joystick_axis_bindings.begin();
- i != joystick_axis_bindings.end(); ++i)
- {
- if (event.jaxis.which == i->device &&
- event.jaxis.axis == i->axis)
- i->binding->set_state(event.jaxis.value / 32767.0f);
- }
- break;
+ case SDL_JOYAXISMOTION:
+ for(std::vector<JoystickAxisBinding>::iterator i =
joystick_axis_bindings.begin();
+ i != joystick_axis_bindings.end(); ++i)
+ {
+ if (event.jaxis.which == i->device &&
+ event.jaxis.axis == i->axis)
+ i->binding->set_state(event.jaxis.value / 32767.0f);
+ }
+ break;
- case SDL_JOYBUTTONDOWN:
- case SDL_JOYBUTTONUP:
- for(std::vector<JoystickButtonBinding>::iterator i =
joystick_button_bindings.begin();
- i != joystick_button_bindings.end(); ++i)
- {
- if (event.jbutton.which == i->device &&
- event.jbutton.button == i->button)
- {
- i->binding->set_state(event.jbutton.state == SDL_PRESSED ?
BUTTON_PRESSED : BUTTON_RELEASED);
- }
- }
- break;
+ case SDL_JOYBUTTONDOWN:
+ case SDL_JOYBUTTONUP:
+ for(std::vector<JoystickButtonBinding>::iterator i =
joystick_button_bindings.begin();
+ i != joystick_button_bindings.end(); ++i)
+ {
+ if (event.jbutton.which == i->device &&
+ event.jbutton.button == i->button)
+ {
+ i->binding->set_state(event.jbutton.state == SDL_PRESSED ?
BUTTON_PRESSED : BUTTON_RELEASED);
+ }
+ }
+ break;
- default:
- // FIXME: Do something with other events
- break;
- }
+ default:
+ // FIXME: Do something with other events
+ break;
}
+ }
}
} // namespace Input
Modified: trunk/pingus/src/input/sdl_driver.hpp
===================================================================
--- trunk/pingus/src/input/sdl_driver.hpp 2009-11-04 19:29:46 UTC (rev
4023)
+++ trunk/pingus/src/input/sdl_driver.hpp 2009-11-04 20:52:55 UTC (rev
4024)
@@ -78,9 +78,7 @@
typedef std::map<int, SDL_Joystick*> JoystickHandles;
JoystickHandles joystick_handles;
-
- bool open_joystick(int device);
-
+
public:
SDLDriver();
~SDLDriver();
@@ -95,6 +93,9 @@
std::string get_name() const { return "sdl"; }
private:
+ bool open_joystick(int device);
+
+private:
SDLDriver(const SDLDriver&);
SDLDriver & operator=(const SDLDriver&);
};
Modified: trunk/pingus/src/lisp/lexer.cpp
===================================================================
--- trunk/pingus/src/lisp/lexer.cpp 2009-11-04 19:29:46 UTC (rev 4023)
+++ trunk/pingus/src/lisp/lexer.cpp 2009-11-04 20:52:55 UTC (rev 4024)
@@ -31,8 +31,13 @@
{
};
-Lexer::Lexer(std::istream& newstream)
- : stream(newstream), eof(false), linenumber(0)
+Lexer::Lexer(std::istream& newstream) :
+ stream(newstream),
+ eof(false),
+ linenumber(0),
+ bufend(),
+ c(),
+ token_length()
{
try {
// trigger a refill of the buffer
@@ -134,7 +139,7 @@
} catch(EOFException& ) {
std::stringstream msg;
msg << "Parse error in line " << startline << ": "
- << "EOF while parsing string.";
+ << "EOF while parsing string.";
throw std::runtime_error(msg.str());
}
nextChar();
@@ -153,7 +158,7 @@
} catch(EOFException& ) {
std::stringstream msg;
msg << "Parse Error in line " << linenumber << ": "
- << "EOF while parsing constant.";
+ << "EOF while parsing constant.";
throw std::runtime_error(msg.str());
}
@@ -167,7 +172,7 @@
{
std::stringstream msg;
msg << "Parse Error in line " << linenumber << ": "
- << "Unknown constant '" << token_string << "'.";
+ << "Unknown constant '" << token_string << "'.";
throw std::runtime_error(msg.str());
}
Modified: trunk/pingus/src/lisp/lisp.cpp
===================================================================
--- trunk/pingus/src/lisp/lisp.cpp 2009-11-04 19:29:46 UTC (rev 4023)
+++ trunk/pingus/src/lisp/lisp.cpp 2009-11-04 20:52:55 UTC (rev 4024)
@@ -24,34 +24,34 @@
namespace lisp
{
-Lisp::Lisp(int val)
- : type(TYPE_INT)
+Lisp::Lisp(int val) :
+ v(), type(TYPE_INT)
{
v.int_ = val;
}
-Lisp::Lisp(float val)
- : type(TYPE_FLOAT)
+Lisp::Lisp(float val) :
+ v(), type(TYPE_FLOAT)
{
v.float_ = val;
}
-Lisp::Lisp(bool val)
- : type(TYPE_BOOL)
+Lisp::Lisp(bool val) :
+ v(), type(TYPE_BOOL)
{
v.bool_ = val;
}
-Lisp::Lisp(LispType newtype, const std::string& str)
- : type(newtype)
+Lisp::Lisp(LispType newtype, const std::string& str) :
+ v(), type(newtype)
{
assert(newtype == TYPE_SYMBOL || type == TYPE_STRING);
v.string = new char[str.size()+1];
memcpy(v.string, str.c_str(), str.size()+1);
}
-Lisp::Lisp(const std::vector<boost::shared_ptr<Lisp> >& list_elements)
- : type(TYPE_LIST)
+Lisp::Lisp(const std::vector<boost::shared_ptr<Lisp> >& list_elements) :
+ v(), type(TYPE_LIST)
{
v.list.size = list_elements.size();
v.list.entries = new boost::shared_ptr<Lisp> [v.list.size];
Modified: trunk/pingus/src/lisp/parser.cpp
===================================================================
--- trunk/pingus/src/lisp/parser.cpp 2009-11-04 19:29:46 UTC (rev 4023)
+++ trunk/pingus/src/lisp/parser.cpp 2009-11-04 20:52:55 UTC (rev 4024)
@@ -36,7 +36,8 @@
class ParseError : public std::exception
{
public:
- ParseError(const Parser* parser, const std::string& message) throw()
+ ParseError(const Parser* parser, const std::string& message) throw() :
+ string()
{
std::ostringstream msg;
msg << "Parse error in file '" << parser->filename << "' line "
@@ -55,8 +56,10 @@
std::string string;
};
-Parser::Parser()
- : lexer(0)
+Parser::Parser() :
+ filename(),
+ lexer(0),
+ token()
{
}
Modified: trunk/pingus/src/particles/pingu_particle_holder.cpp
===================================================================
--- trunk/pingus/src/particles/pingu_particle_holder.cpp 2009-11-04
19:29:46 UTC (rev 4023)
+++ trunk/pingus/src/particles/pingu_particle_holder.cpp 2009-11-04
20:52:55 UTC (rev 4024)
@@ -35,8 +35,9 @@
}
-PinguParticleHolder::PinguParticleHolder ()
- : surface("particles/pingu_explo")
+PinguParticleHolder::PinguParticleHolder () :
+ surface("particles/pingu_explo"),
+ particles()
{
}
Modified: trunk/pingus/src/particles/rain_particle_holder.cpp
===================================================================
--- trunk/pingus/src/particles/rain_particle_holder.cpp 2009-11-04 19:29:46 UTC
(rev 4023)
+++ trunk/pingus/src/particles/rain_particle_holder.cpp 2009-11-04 20:52:55 UTC
(rev 4024)
@@ -32,10 +32,11 @@
}
-RainParticleHolder::RainParticleHolder ()
- : rain1_surf("particles/rain1"),
- rain2_surf("particles/rain2"),
- rain_splash("particles/rain_splash")
+RainParticleHolder::RainParticleHolder () :
+ rain1_surf("particles/rain1"),
+ rain2_surf("particles/rain2"),
+ rain_splash("particles/rain_splash"),
+ particles()
{
}
Modified: trunk/pingus/src/particles/smoke_particle_holder.cpp
===================================================================
--- trunk/pingus/src/particles/smoke_particle_holder.cpp 2009-11-04
19:29:46 UTC (rev 4023)
+++ trunk/pingus/src/particles/smoke_particle_holder.cpp 2009-11-04
20:52:55 UTC (rev 4024)
@@ -21,8 +21,12 @@
namespace Particles {
-SmokeParticleHolder::SmokeParticle::SmokeParticle (float x, float y, float
vel_x, float vel_y)
- : pos(Vector3f(x,y)), velocity(Vector3f(vel_x, vel_y))
+SmokeParticleHolder::SmokeParticle::SmokeParticle (float x, float y, float
vel_x, float vel_y) :
+ time(),
+ livetime(),
+ use_surf2(),
+ pos(Vector3f(x,y)),
+ velocity(Vector3f(vel_x, vel_y))
{
time = livetime = 25 + (rand() % 10);
use_surf2 = rand() % 2;
@@ -31,7 +35,8 @@
SmokeParticleHolder::SmokeParticleHolder ()
: surf1("particles/smoke"),
- surf2("particles/smoke2")
+ surf2("particles/smoke2"),
+ particles()
{
}
@@ -42,12 +47,12 @@
// search for dead entry to replace
for (std::vector<SmokeParticle>::iterator it=particles.begin(); it !=
particles.end(); ++it)
if (!it->livetime)
- {
- *it = SmokeParticle(x, y, vel_x, vel_y);
- return;
- }
+ {
+ *it = SmokeParticle(x, y, vel_x, vel_y);
+ return;
+ }
- // create new entry
+ // create new entry
particles.push_back(SmokeParticle(x, y, vel_x, vel_y));
}
@@ -56,16 +61,16 @@
{
// update all contained particles
for (std::vector<SmokeParticle>::iterator it=particles.begin(); it !=
particles.end(); ++it)
- {
- // skip dead particles
- if (!it->livetime)
- continue;
+ {
+ // skip dead particles
+ if (!it->livetime)
+ continue;
- it->pos.x += it->velocity.x;
- it->pos.y += it->velocity.y;
+ it->pos.x += it->velocity.x;
+ it->pos.y += it->velocity.y;
- --it->livetime;
- }
+ --it->livetime;
+ }
}
@@ -73,15 +78,15 @@
SmokeParticleHolder::draw (SceneContext& gc)
{
for (std::vector<SmokeParticle>::iterator it=particles.begin(); it !=
particles.end(); ++it)
- {
- if (!it->livetime)
- continue;
+ {
+ if (!it->livetime)
+ continue;
- if (!it->use_surf2)
- gc.color().draw(surf1, it->pos);
- else
- gc.color().draw(surf2, it->pos);
- }
+ if (!it->use_surf2)
+ gc.color().draw(surf1, it->pos);
+ else
+ gc.color().draw(surf2, it->pos);
+ }
}
} // namespace Particles
Modified: trunk/pingus/src/particles/snow_particle_holder.cpp
===================================================================
--- trunk/pingus/src/particles/snow_particle_holder.cpp 2009-11-04 19:29:46 UTC
(rev 4023)
+++ trunk/pingus/src/particles/snow_particle_holder.cpp 2009-11-04 20:52:55 UTC
(rev 4024)
@@ -26,41 +26,42 @@
namespace Particles {
-SnowParticleHolder::SnowParticle::SnowParticle (int x, int y, bool colliding_)
- : alive(true),
- colliding(colliding_),
- pos(Vector3f((float)x,(float)y)),
- velocity(Vector3f(0.0f, 1 + (Math::frand() * 3.5f)))
+SnowParticleHolder::SnowParticle::SnowParticle (int x, int y, bool colliding_)
:
+ alive(true),
+ colliding(colliding_),
+ type(SnowParticleHolder::Snow1),
+ pos(Vector3f((float)x,(float)y)),
+ velocity(Vector3f(0.0f, 1 + (Math::frand() * 3.5f)))
{
switch (rand() % 10)
- {
- case 0:
- type = SnowParticleHolder::Snow1;
- break;
- case 1:
- type = SnowParticleHolder::Snow2;
- break;
- case 2:
- case 3:
- type = SnowParticleHolder::Snow3;
- break;
- case 5:
- case 6:
- type = SnowParticleHolder::Snow4;
- default:
- type = SnowParticleHolder::Snow5;
- break;
- }
+ {
+ case 0:
+ type = SnowParticleHolder::Snow1;
+ break;
+ case 1:
+ type = SnowParticleHolder::Snow2;
+ break;
+ case 2:
+ case 3:
+ type = SnowParticleHolder::Snow3;
+ break;
+ case 5:
+ case 6:
+ type = SnowParticleHolder::Snow4;
+ default:
+ type = SnowParticleHolder::Snow5;
+ break;
+ }
}
-
-SnowParticleHolder::SnowParticleHolder ()
- : snow1("particles/snow1"),
- snow2("particles/snow2"),
- snow3("particles/snow3"),
- snow4("particles/snow4"),
- snow5("particles/snow5"),
- ground("particles/ground_snow")
+SnowParticleHolder::SnowParticleHolder() :
+ snow1("particles/snow1"),
+ snow2("particles/snow2"),
+ snow3("particles/snow3"),
+ snow4("particles/snow4"),
+ snow5("particles/snow5"),
+ ground("particles/ground_snow"),
+ particles()
{
}
@@ -71,12 +72,12 @@
// search for dead entry to replace
for (std::vector<SnowParticle>::iterator it=particles.begin(); it !=
particles.end(); ++it)
if (!it->alive)
- {
- *it = SnowParticle(x, y, colliding);
- return;
- }
+ {
+ *it = SnowParticle(x, y, colliding);
+ return;
+ }
- // create new entry
+ // create new entry
particles.push_back(SnowParticle(x, y, colliding));
}
@@ -85,32 +86,32 @@
{
// update all contained particles
for (std::vector<SnowParticle>::iterator it=particles.begin(); it !=
particles.end(); ++it)
+ {
+ // skip dead particles
+ if (!it->alive)
+ continue;
+ it->pos.x += it->velocity.x;
+ it->pos.y += it->velocity.y;
+
+ if (it->pos.y > world->get_height())
{
- // skip dead particles
- if (!it->alive)
- continue;
- it->pos.x += it->velocity.x;
- it->pos.y += it->velocity.y;
+ it->alive = false;
+ continue;
+ }
- if (it->pos.y > world->get_height())
- {
- it->alive = false;
- continue;
- }
-
- it->velocity.x += (Math::frand() - 0.5f) / 10;
- if (it->colliding)
- {
- int pixel =
world->get_colmap()->getpixel(static_cast<int>(it->pos.x),
static_cast<int>(it->pos.y));
- if ( pixel != Groundtype::GP_NOTHING
- && pixel != Groundtype::GP_WATER
- && pixel != Groundtype::GP_OUTOFSCREEN)
- {
- world->get_gfx_map()->put(ground.get_surface(),
static_cast<int>(it->pos.x - 1), static_cast<int>(it->pos.y - 1));
- it->alive = false;
- }
- }
+ it->velocity.x += (Math::frand() - 0.5f) / 10;
+ if (it->colliding)
+ {
+ int pixel = world->get_colmap()->getpixel(static_cast<int>(it->pos.x),
static_cast<int>(it->pos.y));
+ if ( pixel != Groundtype::GP_NOTHING
+ && pixel != Groundtype::GP_WATER
+ && pixel != Groundtype::GP_OUTOFSCREEN)
+ {
+ world->get_gfx_map()->put(ground.get_surface(),
static_cast<int>(it->pos.x - 1), static_cast<int>(it->pos.y - 1));
+ it->alive = false;
+ }
}
+ }
}
@@ -118,31 +119,31 @@
SnowParticleHolder::draw (SceneContext& gc)
{
for (std::vector<SnowParticle>::iterator it=particles.begin(); it !=
particles.end(); ++it)
+ {
+ if (!it->alive)
+ continue;
+
+ switch (it->type)
{
- if (!it->alive)
- continue;
-
- switch (it->type)
- {
- case Snow1:
- gc.color().draw(snow1, it->pos);
- break;
- case Snow2:
- gc.color().draw(snow2, it->pos);
- break;
- case Snow3:
- gc.color().draw(snow3, it->pos);
- break;
- case Snow4:
- gc.color().draw(snow4, it->pos);
- break;
- case Snow5:
- gc.color().draw(snow5, it->pos);
- break;
- default:
- assert(!"Invalid Snow-Type");
- }
+ case Snow1:
+ gc.color().draw(snow1, it->pos);
+ break;
+ case Snow2:
+ gc.color().draw(snow2, it->pos);
+ break;
+ case Snow3:
+ gc.color().draw(snow3, it->pos);
+ break;
+ case Snow4:
+ gc.color().draw(snow4, it->pos);
+ break;
+ case Snow5:
+ gc.color().draw(snow5, it->pos);
+ break;
+ default:
+ assert(!"Invalid Snow-Type");
}
+ }
}
} // namespace Particles
Modified: trunk/pingus/src/pingus/world.cpp
===================================================================
--- trunk/pingus/src/pingus/world.cpp 2009-11-04 19:29:46 UTC (rev 4023)
+++ trunk/pingus/src/pingus/world.cpp 2009-11-04 20:52:55 UTC (rev 4024)
@@ -48,6 +48,12 @@
gfx_map(new GroundMap(plf.get_size().width, plf.get_size().height)),
game_time(0),
do_armageddon(false),
+ armageddon_count(0),
+ world_obj(),
+ pingu_particle_holder(),
+ rain_particle_holder(),
+ smoke_particle_holder(),
+ snow_particle_holder(),
pingus(new PinguHolder(plf)),
colmap(gfx_map->get_colmap()),
gravitational_acceleration(0.25f)
Modified: trunk/pingus/src/worldmap/level_dot.cpp
===================================================================
--- trunk/pingus/src/worldmap/level_dot.cpp 2009-11-04 19:29:46 UTC (rev
4023)
+++ trunk/pingus/src/worldmap/level_dot.cpp 2009-11-04 20:52:55 UTC (rev
4024)
@@ -36,13 +36,14 @@
namespace WorldmapNS {
-LevelDot::LevelDot(FileReader reader)
- : Dot(reader.read_section("dot")),
- green_dot_sur("core/worldmap/dot_green"),
- red_dot_sur("core/worldmap/dot_red"),
- inaccessible_dot_sur("core/worldmap/dot_invalid"),
- highlight_green_dot_sur("core/worldmap/dot_green_hl"),
- highlight_red_dot_sur("core/worldmap/dot_red_hl")
+LevelDot::LevelDot(FileReader reader) :
+ Dot(reader.read_section("dot")),
+ green_dot_sur("core/worldmap/dot_green"),
+ red_dot_sur("core/worldmap/dot_red"),
+ inaccessible_dot_sur("core/worldmap/dot_invalid"),
+ highlight_green_dot_sur("core/worldmap/dot_green_hl"),
+ highlight_red_dot_sur("core/worldmap/dot_red_hl"),
+ plf()
{
std::string resname;
reader.read_string("levelname", resname);
@@ -68,26 +69,26 @@
if (savegame
&& (savegame->get_status() == Savegame::FINISHED
|| savegame->get_status() == Savegame::ACCESSIBLE))
- {
- if (savegame->get_status() == Savegame::FINISHED)
- if (highlight)
- {
- gc.draw (highlight_green_dot_sur, pos);
- }
- else
- {
- gc.draw (green_dot_sur, pos);
- }
+ {
+ if (savegame->get_status() == Savegame::FINISHED)
+ if (highlight)
+ {
+ gc.draw (highlight_green_dot_sur, pos);
+ }
else
- if (highlight)
- gc.draw (highlight_red_dot_sur, pos);
- else
- gc.draw (red_dot_sur, pos);
- }
+ {
+ gc.draw (green_dot_sur, pos);
+ }
+ else
+ if (highlight)
+ gc.draw (highlight_red_dot_sur, pos);
+ else
+ gc.draw (red_dot_sur, pos);
+ }
else
- {
- gc.draw (inaccessible_dot_sur, pos);
- }
+ {
+ gc.draw (inaccessible_dot_sur, pos);
+ }
}
void
@@ -130,43 +131,43 @@
int pos_correction = 0;
if (accessible())
- {
- int length = Fonts::pingus_small.bounding_rect(0, 0,
_(get_plf().get_levelname())).get_width() / 2;
- int realpos = gc.world_to_screen(Vector2i(static_cast<int>(pos.x),
static_cast<int>(pos.y))).x;
- if (realpos - length < 0)
- pos_correction = realpos - length;
- else if (realpos + length > gc.get_width())
- pos_correction = realpos + length - static_cast<int>(gc.get_width());
+ {
+ int length = Fonts::pingus_small.bounding_rect(0, 0,
_(get_plf().get_levelname())).get_width() / 2;
+ int realpos = gc.world_to_screen(Vector2i(static_cast<int>(pos.x),
static_cast<int>(pos.y))).x;
+ if (realpos - length < 0)
+ pos_correction = realpos - length;
+ else if (realpos + length > gc.get_width())
+ pos_correction = realpos + length - static_cast<int>(gc.get_width());
- gc.print_center(Fonts::pingus_small,
- Vector2i((int)pos.x - pos_correction,
- (int)pos.y - 44),
- _(get_plf().get_levelname()),
- 10000);
- }
+ gc.print_center(Fonts::pingus_small,
+ Vector2i((int)pos.x - pos_correction,
+ (int)pos.y - 44),
+ _(get_plf().get_levelname()),
+ 10000);
+ }
else
- {
- int length = Fonts::pingus_small.bounding_rect(0, 0,
_("locked")).get_width() / 2;
- int realpos = gc.world_to_screen(Vector2i(static_cast<int>(pos.x),
static_cast<int>(pos.y))).x;
- if (realpos - length < 0)
- pos_correction = realpos - length;
- else if (realpos + length > gc.get_width())
- pos_correction = realpos + length - static_cast<int>(gc.get_width());
+ {
+ int length = Fonts::pingus_small.bounding_rect(0, 0,
_("locked")).get_width() / 2;
+ int realpos = gc.world_to_screen(Vector2i(static_cast<int>(pos.x),
static_cast<int>(pos.y))).x;
+ if (realpos - length < 0)
+ pos_correction = realpos - length;
+ else if (realpos + length > gc.get_width())
+ pos_correction = realpos + length - static_cast<int>(gc.get_width());
- gc.print_center(Fonts::pingus_small,
- Vector2i((int)pos.x - pos_correction,
- (int)pos.y - 30),
- _("locked"),
- 10000);
- }
+ gc.print_center(Fonts::pingus_small,
+ Vector2i((int)pos.x - pos_correction,
+ (int)pos.y - 30),
+ _("locked"),
+ 10000);
+ }
if (maintainer_mode)
- {
- gc.print_center(Fonts::pingus_small,
- Vector2i((int)pos.x, (int)pos.y - 56),
- get_plf().get_resname(),
- 10000);
- }
+ {
+ gc.print_center(Fonts::pingus_small,
+ Vector2i((int)pos.x, (int)pos.y - 56),
+ get_plf().get_resname(),
+ 10000);
+ }
}
void
@@ -174,16 +175,16 @@
{
Savegame* savegame = SavegameManager::instance()->get(plf.get_resname());
if (savegame == 0 || savegame->get_status() == Savegame::NONE)
- {
- Savegame savegame_(plf.get_resname(),
- Savegame::ACCESSIBLE,
- 0,
- 0);
- SavegameManager::instance()->store(savegame_);
- }
+ {
+ Savegame savegame_(plf.get_resname(),
+ Savegame::ACCESSIBLE,
+ 0,
+ 0);
+ SavegameManager::instance()->store(savegame_);
+ }
else
- {
- }
+ {
+ }
}
} // namespace WorldmapNS
Modified: trunk/pingus/src/worldmap/path_graph.cpp
===================================================================
--- trunk/pingus/src/worldmap/path_graph.cpp 2009-11-04 19:29:46 UTC (rev
4023)
+++ trunk/pingus/src/worldmap/path_graph.cpp 2009-11-04 20:52:55 UTC (rev
4024)
@@ -29,8 +29,13 @@
namespace WorldmapNS {
-PathGraph::PathGraph(Worldmap* arg_worldmap, FileReader &reader)
- : worldmap(arg_worldmap)
+PathGraph::PathGraph(Worldmap* arg_worldmap, FileReader &reader) :
+ worldmap(arg_worldmap),
+ graph(),
+ dots(),
+ pathfinder_cache(),
+ node_lookup(),
+ edge_lookup()
{
parse_nodes(reader.read_section("nodes"));
parse_edges(reader.read_section("edges"));
@@ -58,28 +63,28 @@
for(std::vector<FileReader>::const_iterator i = childs.begin();
i != childs.end(); ++i)
+ {
+ Dot* dot = DotFactory::create(*i);
+ if (dot)
{
- Dot* dot = DotFactory::create(*i);
- if (dot)
- {
- // add the dot to the pathfinding
- NodeId id = graph.add_node(dot);
+ // add the dot to the pathfinding
+ NodeId id = graph.add_node(dot);
- //std::cout << "Adding to lookup table: " << dot->get_name() <<
std::endl;
- node_lookup[dot->get_name()] = id;
+ //std::cout << "Adding to lookup table: " << dot->get_name() <<
std::endl;
+ node_lookup[dot->get_name()] = id;
- // add the dot to the list of drawables
- if (worldmap)
- worldmap->add_drawable(dot);
+ // add the dot to the list of drawables
+ if (worldmap)
+ worldmap->add_drawable(dot);
- // FIXME: should be use this for freeing the stuff?
- dots.push_back(dot);
- }
- else
- {
- std::cout << "PathGraph: Couldn't create node" << std::endl;
- }
+ // FIXME: should be use this for freeing the stuff?
+ dots.push_back(dot);
}
+ else
+ {
+ std::cout << "PathGraph: Couldn't create node" << std::endl;
+ }
+ }
}
void
@@ -89,70 +94,70 @@
for(std::vector<FileReader>::const_iterator i = childs.begin();
i != childs.end(); ++i)
+ {
+ if (i->get_name() == "edge")
{
- if (i->get_name() == "edge")
- {
- std::string name;
- std::string source;
- std::string destination;
+ std::string name;
+ std::string source;
+ std::string destination;
- i->read_string("name", name);
- i->read_string("source", source);
- i->read_string("destination", destination);
+ i->read_string("name", name);
+ i->read_string("source", source);
+ i->read_string("destination", destination);
- // FIXME: add path-data parsing here
- Path* path = new Path();
+ // FIXME: add path-data parsing here
+ Path* path = new Path();
- const std::vector<FileReader>& childs2 =
reader.read_section("positions").get_sections();
+ const std::vector<FileReader>& childs2 =
reader.read_section("positions").get_sections();
- for(std::vector<FileReader>::const_iterator j = childs2.begin();
- j != childs2.end(); ++j)
- {
- if (j->get_name() == "position")
- {
- Vector3f pos;
- j->read_float("x", pos.x);
- j->read_float("y", pos.y);
- j->read_float("z", pos.z);
- path->push_back(pos);
- }
- }
+ for(std::vector<FileReader>::const_iterator j = childs2.begin();
+ j != childs2.end(); ++j)
+ {
+ if (j->get_name() == "position")
+ {
+ Vector3f pos;
+ j->read_float("x", pos.x);
+ j->read_float("y", pos.y);
+ j->read_float("z", pos.z);
+ path->push_back(pos);
+ }
+ }
- Path full_path;
-
full_path.push_back(graph.resolve_node(lookup_node(source)).data->get_pos());
- full_path.insert(*path);
-
full_path.push_back(graph.resolve_node(lookup_node(destination)).data->get_pos());
+ Path full_path;
+
full_path.push_back(graph.resolve_node(lookup_node(source)).data->get_pos());
+ full_path.insert(*path);
+
full_path.push_back(graph.resolve_node(lookup_node(destination)).data->get_pos());
- // FIXME: merge this together with the Pingus::distance() stuff in a
seperate Path class
- float cost = full_path.length();
+ // FIXME: merge this together with the Pingus::distance() stuff in a
seperate Path class
+ float cost = full_path.length();
- // FIXME: Memory leak
- if (worldmap && pingus_debug_flags & PINGUS_DEBUG_WORLDMAP)
- worldmap->add_drawable(new PathDrawable(full_path));
+ // FIXME: Memory leak
+ if (worldmap && pingus_debug_flags & PINGUS_DEBUG_WORLDMAP)
+ worldmap->add_drawable(new PathDrawable(full_path));
- // FIXME: No error checking,
- EdgeId id1 = graph.add_edge(path, // FIXME: Memory leak!
- lookup_node(destination),
lookup_node(source),
- cost /* costs */);
+ // FIXME: No error checking,
+ EdgeId id1 = graph.add_edge(path, // FIXME: Memory leak!
+ lookup_node(destination),
lookup_node(source),
+ cost /* costs */);
- Path* path2 = new Path();
- path2->reverse_insert(*path);
- //EdgeId id2 =
- graph.add_edge(path2, // FIXME: Memory leak!
- lookup_node(source), lookup_node(destination),
- cost /* costs */);
+ Path* path2 = new Path();
+ path2->reverse_insert(*path);
+ //EdgeId id2 =
+ graph.add_edge(path2, // FIXME: Memory leak!
+ lookup_node(source), lookup_node(destination),
+ cost /* costs */);
- //std::cout << "Cost: " << cost << std::endl;
+ //std::cout << "Cost: " << cost << std::endl;
- // FIXME: edge lookup is flawed, since we have different edges in
both directions
+ // FIXME: edge lookup is flawed, since we have different edges in both
directions
- edge_lookup[name] = id1;
- }
- else
- {
- PingusError::raise("PathGraph: unhandled: ");
- }
+ edge_lookup[name] = id1;
}
+ else
+ {
+ PingusError::raise("PathGraph: unhandled: ");
+ }
+ }
}
PathfinderResult
@@ -161,10 +166,10 @@
Pathfinder<Dot*,Path*>*& pfinder = pathfinder_cache[start_id];
if (!pfinder)
- {
- pfinder = new Pathfinder<Dot*, Path*>(graph, start_id);
- pathfinder_cache[start_id] = pfinder;
- }
+ {
+ pfinder = new Pathfinder<Dot*, Path*>(graph, start_id);
+ pathfinder_cache[start_id] = pfinder;
+ }
return pfinder->get_result(end_id);
}
@@ -174,14 +179,14 @@
{
std::map<std::string, EdgeId>::iterator i = edge_lookup.find(name);
if (i == edge_lookup.end())
- {
- std::cout << "Couldn't find EdgeId for: " << name << std::endl;
- return NoEdge;
- }
+ {
+ std::cout << "Couldn't find EdgeId for: " << name << std::endl;
+ return NoEdge;
+ }
else
- {
- return i->second;
- }
+ {
+ return i->second;
+ }
}
NodeId
@@ -189,14 +194,14 @@
{
std::map<std::string, NodeId>::iterator i = node_lookup.find(name);
if (i == node_lookup.end())
- {
- std::cout << "Couldn't find NodeId for: " << name << std::endl;
- return NoNode;
- }
+ {
+ std::cout << "Couldn't find NodeId for: " << name << std::endl;
+ return NoNode;
+ }
else
- {
- return i->second;
- }
+ {
+ return i->second;
+ }
}
std::string
@@ -204,12 +209,12 @@
{
for (std::map<std::string, NodeId>::iterator i = node_lookup.begin();
i != node_lookup.end(); ++i)
+ {
+ if (i->second == id)
{
- if (i->second == id)
- {
- return i->first;
- }
+ return i->first;
}
+ }
std::cout << "PathGraph: Couldn't find id: " << id << std::endl;
return "error_node";
}
@@ -219,12 +224,12 @@
{
for (std::map<std::string, EdgeId>::iterator i = node_lookup.begin();
i != node_lookup.end(); ++i)
+ {
+ if (i->second == id)
{
- if (i->second == id)
- {
- return i->first;
- }
+ return i->first;
}
+ }
std::cout << "PathGraph: Couldn't find id: " << id << std::endl;
return "error_node";
}
@@ -239,13 +244,13 @@
PathGraph::get_dot(float x_pos, float y_pos)
{
for(std::vector<Dot*>::iterator i = dots.begin(); i != dots.end(); ++i)
- {
- float x = x_pos - (*i)->get_pos().x;
- float y = y_pos - (*i)->get_pos().y;
+ {
+ float x = x_pos - (*i)->get_pos().x;
+ float y = y_pos - (*i)->get_pos().y;
- if (Math::sqrt(x*x + y*y) < 30.0f)
- return *i;
- }
+ if (Math::sqrt(x*x + y*y) < 30.0f)
+ return *i;
+ }
return 0;
}
Modified: trunk/pingus/src/worldmap/pingus.cpp
===================================================================
--- trunk/pingus/src/worldmap/pingus.cpp 2009-11-04 19:29:46 UTC (rev
4023)
+++ trunk/pingus/src/worldmap/pingus.cpp 2009-11-04 20:52:55 UTC (rev
4024)
@@ -26,11 +26,20 @@
namespace WorldmapNS {
-Pingus::Pingus (PathGraph* arg_path)
- : Drawable("pingus"),
- path(arg_path),
- sprite_standing("core/worldmap/pingus_standing"),
- arrow("core/worldmap/arrow")
+Pingus::Pingus (PathGraph* arg_path) :
+ Drawable("pingus"),
+ path(arg_path),
+ sprite_standing("core/worldmap/pingus_standing"),
+ arrow("core/worldmap/arrow"),
+ current_node(),
+ source_node(),
+ target_node(),
+ final_target_node(),
+ node_path(),
+ edge_path(),
+ edge_path_position(),
+ pos(),
+ last_pos()
{
sprite.load(Direction::LEFT, Sprite("core/worldmap/pingus/left"));
sprite.load(Direction::RIGHT, Sprite("core/worldmap/pingus/right"));
@@ -50,24 +59,24 @@
// Add 10 to z_pos so that the pingu gets drawn above the node it is
// standing one
if (final_target_node != NoNode && current_node == NoNode)
- {
- gc.draw(arrow, path->get_dot(final_target_node)->get_pos() + Vector3f(0,
0, 10));
- }
+ {
+ gc.draw(arrow, path->get_dot(final_target_node)->get_pos() + Vector3f(0,
0, 10));
+ }
if (!is_walking())
- {
- gc.draw(sprite_standing, pos);
- }
+ {
+ gc.draw(sprite_standing, pos);
+ }
else
- {
- // FIXME: Replace the sprite and add up/down here
- float direction = get_direction();
+ {
+ // FIXME: Replace the sprite and add up/down here
+ float direction = get_direction();
- if (direction >= 0 && direction < 180)
- gc.draw(sprite[Direction::RIGHT], pos + Vector3f(0, 0, 10));
- else
- gc.draw(sprite[Direction::LEFT], pos + Vector3f(0, 0, 10));
- }
+ if (direction >= 0 && direction < 180)
+ gc.draw(sprite[Direction::RIGHT], pos + Vector3f(0, 0, 10));
+ else
+ gc.draw(sprite[Direction::LEFT], pos + Vector3f(0, 0, 10));
+ }
}
void
@@ -93,17 +102,17 @@
edge_path_position += velocity * delta;
if (edge_path_position > edge_path.length()) // target reached
+ {
+ if (node_path.empty ()) // final target reached
{
- if (node_path.empty ()) // final target reached
- {
- current_node = target_node;
- final_target_node = NoNode;
- }
- else // edge is traveled, now go to the next node
- {
- update_edge_path();
- }
+ current_node = target_node;
+ final_target_node = NoNode;
}
+ else // edge is traveled, now go to the next node
+ {
+ update_edge_path();
+ }
+ }
// Recalc pingu position on the screen
last_pos = pos;
@@ -123,102 +132,102 @@
final_target_node = target;
if (current_node == target)
+ {
+ return true;
+ }
+ else if (current_node != NoNode) // pingu stands still
+ {
+ const PathfinderResult& res = path->get_path (current_node, target);
+
+ if (res.path.empty())
{
- return true;
+ // No path could be found
+ return false;
}
- else if (current_node != NoNode) // pingu stands still
+ else
{
- const PathfinderResult& res = path->get_path (current_node, target);
+ node_path = res.path;
- if (res.path.empty())
- {
- // No path could be found
- return false;
- }
- else
- {
- node_path = res.path;
+ // Simulate that we just reached current_node, then update the edge_path
+ target_node = node_path.back(); // equal to current_node;
+ node_path.pop_back();
+ update_edge_path();
- // Simulate that we just reached current_node, then update the
edge_path
- target_node = node_path.back(); // equal to current_node;
- node_path.pop_back();
- update_edge_path();
-
- current_node = NoNode;
- return true;
- }
+ current_node = NoNode;
+ return true;
}
+ }
else // pingu between two nodes
+ {
+ if (target_node == target)
{
- if (target_node == target)
+ node_path.clear();
+ return true;
+ }
+ else if (source_node == target)
+ {
+ // Reverse the pingu
+ std::swap(target_node, source_node);
+ edge_path.reverse();
+ edge_path_position = edge_path.length() - edge_path_position;
+ node_path.clear();
+ return true;
+ }
+ else
+ {
+ const PathfinderResult& node_path1 = path->get_path (source_node,
target);
+ const PathfinderResult& node_path2 = path->get_path (target_node,
target);
+
+ // Check that a path exist
+ if (node_path1.path.empty())
+ {
+ if (node_path2.path.empty())
{
- node_path.clear();
- return true;
+ return false;
}
- else if (source_node == target)
+ else
{
+ node_path = node_path2.path;
+ }
+ }
+ else
+ {
+ // Select the shorter path
+ if (node_path1.cost + edge_path_position
+ < node_path2.cost + (edge_path.length() - edge_path_position))
+ { // walk to source node, which means to reverse the pingu
+ node_path = node_path1.path;
+
// Reverse the pingu
std::swap(target_node, source_node);
edge_path.reverse();
edge_path_position = edge_path.length() - edge_path_position;
- node_path.clear();
- return true;
}
- else
- {
- const PathfinderResult& node_path1 = path->get_path (source_node,
target);
- const PathfinderResult& node_path2 = path->get_path (target_node,
target);
+ else
+ { // walk to target_node
+ node_path = node_path2.path;
+ }
+ }
- // Check that a path exist
- if (node_path1.path.empty())
- {
- if (node_path2.path.empty())
- {
- return false;
- }
- else
- {
- node_path = node_path2.path;
- }
- }
- else
- {
- // Select the shorter path
- if (node_path1.cost + edge_path_position
- < node_path2.cost + (edge_path.length() -
edge_path_position))
- { // walk to source node, which means to reverse the pingu
- node_path = node_path1.path;
+ // Pop the first element on the stack, since we are already targeting it
+ node_path.pop_back();
- // Reverse the pingu
- std::swap(target_node, source_node);
- edge_path.reverse();
- edge_path_position = edge_path.length() - edge_path_position;
- }
- else
- { // walk to target_node
- node_path = node_path2.path;
- }
- }
-
- // Pop the first element on the stack, since we are already
targeting it
- node_path.pop_back();
-
- return true;
- }
+ return true;
}
+ }
}
Vector3f
Pingus::calc_pos ()
{
if (current_node != NoNode) // pingu stands still
- {
- return path->graph.resolve_node(current_node).data->get_pos ();
- }
+ {
+ return path->graph.resolve_node(current_node).data->get_pos ();
+ }
else // between two nodes
- {
- return edge_path.at(edge_path_position);
- }
+ {
+ return edge_path.at(edge_path_position);
+ }
}
void
Modified: trunk/pingus/src/worldmap/pingus_worldmap.cpp
===================================================================
--- trunk/pingus/src/worldmap/pingus_worldmap.cpp 2009-11-04 19:29:46 UTC
(rev 4023)
+++ trunk/pingus/src/worldmap/pingus_worldmap.cpp 2009-11-04 20:52:55 UTC
(rev 4024)
@@ -44,14 +44,33 @@
FileReader path_graph;
std::vector<FileReader> objects;
+
+ PingusWorldmapImpl() :
+ filename(),
+ name(),
+ short_name(),
+ description(),
+ music(),
+ author(),
+ email(),
+ width(),
+ height(),
+ default_node(),
+ final_node(),
+ intro_story(),
+ end_story(),
+ path_graph(),
+ objects()
+ {}
};
-PingusWorldmap::PingusWorldmap()
+PingusWorldmap::PingusWorldmap() :
+ impl()
{
}
-PingusWorldmap::PingusWorldmap(const Pathname& pathname)
- : impl(new PingusWorldmapImpl())
+PingusWorldmap::PingusWorldmap(const Pathname& pathname) :
+ impl(new PingusWorldmapImpl())
{
parse_file(FileReader::parse(pathname));
}
Modified: trunk/pingus/src/worldmap/sprite_drawable.cpp
===================================================================
--- trunk/pingus/src/worldmap/sprite_drawable.cpp 2009-11-04 19:29:46 UTC
(rev 4023)
+++ trunk/pingus/src/worldmap/sprite_drawable.cpp 2009-11-04 20:52:55 UTC
(rev 4024)
@@ -25,8 +25,11 @@
namespace WorldmapNS {
-SpriteDrawable::SpriteDrawable(FileReader reader)
- : Drawable(reader)
+SpriteDrawable::SpriteDrawable(FileReader reader) :
+ Drawable(reader),
+ surface(),
+ pos(),
+ auto_uncover()
{
auto_uncover = false;
ResDescriptor desc;
@@ -49,29 +52,29 @@
SpriteDrawable::draw(DrawingContext& gc)
{
if (surface)
+ {
+ if (auto_uncover)
{
- if (auto_uncover)
- {
- Vector3f pingus_pos = Worldmap::current()->get_pingus()->get_pos();
- // Pingu is not over the surface
- if (!(pingus_pos.x > pos.x && pingus_pos.x < pos.x +
surface.get_width()
- &&
- pingus_pos.y > pos.y && pingus_pos.y < pos.y +
surface.get_height()))
- {
- gc.draw(surface, pos);
- }
- else if (pingus_pos.z > pos.z + 1000)
- { // FIXME: Hack for the 0.6.0 release/tutorial world remove later
- gc.draw(surface, pos);
- }
- }
- else
- {
- gc.draw(surface, pos);
- }
+ Vector3f pingus_pos = Worldmap::current()->get_pingus()->get_pos();
+ // Pingu is not over the surface
+ if (!(pingus_pos.x > pos.x && pingus_pos.x < pos.x + surface.get_width()
+ &&
+ pingus_pos.y > pos.y && pingus_pos.y < pos.y +
surface.get_height()))
+ {
+ gc.draw(surface, pos);
+ }
+ else if (pingus_pos.z > pos.z + 1000)
+ { // FIXME: Hack for the 0.6.0 release/tutorial world remove later
+ gc.draw(surface, pos);
+ }
+ }
+ else
+ {
+ gc.draw(surface, pos);
}
}
+}
-} // namespace WorldmapNS
+ } // namespace WorldmapNS
/* EOF */
Modified: trunk/pingus/src/worldmap/worldmap.cpp
===================================================================
--- trunk/pingus/src/worldmap/worldmap.cpp 2009-11-04 19:29:46 UTC (rev
4023)
+++ trunk/pingus/src/worldmap/worldmap.cpp 2009-11-04 20:52:55 UTC (rev
4024)
@@ -51,10 +51,18 @@
Worldmap* Worldmap::current_ = 0;
-Worldmap::Worldmap(const std::string& arg_filename)
- : filename(arg_filename),
- mouse_x(0),
- mouse_y(0)
+Worldmap::Worldmap(const std::string& arg_filename) :
+ worldmap(),
+ filename(arg_filename),
+ default_node(),
+ final_node(),
+ pingus(),
+ gc_state(),
+ path_graph(),
+ drawables(),
+ objects(),
+ mouse_x(0),
+ mouse_y(0)
{
current_ = this;
@@ -63,18 +71,18 @@
// Create all objects
const std::vector<FileReader>& object_reader = worldmap.get_objects();
for(std::vector<FileReader>::const_iterator i = object_reader.begin(); i !=
object_reader.end(); ++i)
+ {
+ Drawable* drawable = DrawableFactory::create(*i);
+ if (drawable)
{
- Drawable* drawable = DrawableFactory::create(*i);
- if (drawable)
- {
- objects.push_back(drawable);
- drawables.push_back(drawable);
- }
- else
- {
- std::cout << "Worldmap::parse_objects: Parse Error" << std::endl;
- }
+ objects.push_back(drawable);
+ drawables.push_back(drawable);
}
+ else
+ {
+ std::cout << "Worldmap::parse_objects: Parse Error" << std::endl;
+ }
+ }
FileReader path_graph_reader = worldmap.get_graph();
path_graph = new PathGraph(this, path_graph_reader);
@@ -92,7 +100,7 @@
Worldmap::~Worldmap()
{
for (DrawableLst::iterator i = drawables.begin (); i != drawables.end ();
++i)
- delete (*i);
+ delete (*i);
delete path_graph;
}
@@ -107,27 +115,27 @@
int height = worldmap.get_height();
if (width >= gc.get_width())
- {
- min = gc.get_width()/2;
- max = width - gc.get_width()/2;
- }
+ {
+ min = gc.get_width()/2;
+ max = width - gc.get_width()/2;
+ }
else
- {
- min = width - gc.get_width()/2;
- max = gc.get_width()/2;
- }
+ {
+ min = width - gc.get_width()/2;
+ max = gc.get_width()/2;
+ }
pingu_pos.x = Math::clamp(min, pingu_pos.x, max);
if (height >= gc.get_height())
- {
- min = gc.get_height()/2;
- max = height - gc.get_height()/2;
- }
+ {
+ min = gc.get_height()/2;
+ max = height - gc.get_height()/2;
+ }
else
- {
- min = height - gc.get_height()/2;
- max = gc.get_height()/2;
- }
+ {
+ min = height - gc.get_height()/2;
+ max = gc.get_height()/2;
+ }
pingu_pos.y = Math::clamp(min, pingu_pos.y, max);
gc_state.set_pos(Vector2i(pingu_pos.x, pingu_pos.y));
@@ -150,9 +158,9 @@
Worldmap::update(float delta)
{
for (DrawableLst::iterator i = drawables.begin (); i != drawables.end ();
++i)
- {
- (*i)->update (delta);
- }
+ {
+ (*i)->update (delta);
+ }
}
void
@@ -181,69 +189,69 @@
Vector2f click_pos = gc_state.screen2world(Vector2i(x, y));
if (pingus_debug_flags & PINGUS_DEBUG_WORLDMAP)
- {
- std::cout
- << "\n<leveldot>\n"
- << " <dot>\n"
- << " <name>leveldot_X</name>\n"
- << " <position>\n"
- << " <x>" << (int)click_pos.x << "</x>\n"
- << " <y>" << (int)click_pos.y << "</y>\n"
- << " <z>0</z>\n"
- << " </position>\n"
- << " </dot>\n"
- << " <levelname>level10.pingus</levelname>\n"
- << "</leveldot>\n" << std::endl;
- }
+ {
+ std::cout
+ << "\n<leveldot>\n"
+ << " <dot>\n"
+ << " <name>leveldot_X</name>\n"
+ << " <position>\n"
+ << " <x>" << (int)click_pos.x << "</x>\n"
+ << " <y>" << (int)click_pos.y << "</y>\n"
+ << " <z>0</z>\n"
+ << " </position>\n"
+ << " </dot>\n"
+ << " <levelname>level10.pingus</levelname>\n"
+ << "</leveldot>\n" << std::endl;
+ }
Dot* dot = path_graph->get_dot(click_pos.x, click_pos.y);
if (dot)
+ {
+ if (maintainer_mode)
+ std::cout << "Worldmap: Clicked on: " << dot->get_name() << std::endl;
+
+ if (path_graph->lookup_node(dot->get_name()) == pingus->get_node())
{
if (maintainer_mode)
- std::cout << "Worldmap: Clicked on: " << dot->get_name() << std::endl;
-
- if (path_graph->lookup_node(dot->get_name()) == pingus->get_node())
+ std::cout << "Worldmap: Pingu is on node, issue on_click()" <<
std::endl;
+ dot->on_click();
+ }
+ else
+ {
+ if (dot->accessible())
+ {
+ if (!pingus->walk_to_node(path_graph->lookup_node(dot->get_name())))
{
if (maintainer_mode)
- std::cout << "Worldmap: Pingu is on node, issue on_click()" <<
std::endl;
- dot->on_click();
+ std::cout << "Worldmap: NO PATH TO NODE FOUND!" << std::endl;
}
- else
+ else
{
- if (dot->accessible())
- {
- if
(!pingus->walk_to_node(path_graph->lookup_node(dot->get_name())))
- {
- if (maintainer_mode)
- std::cout << "Worldmap: NO PATH TO NODE FOUND!" <<
std::endl;
- }
- else
- {
-
StatManager::instance()->set_string(worldmap.get_short_name() +
"-current-node", dot->get_name());
- }
- }
- else
- {
- Sound::PingusSound::play_sound("chink");
- }
+ StatManager::instance()->set_string(worldmap.get_short_name() +
"-current-node", dot->get_name());
}
+ }
+ else
+ {
+ Sound::PingusSound::play_sound("chink");
+ }
}
+ }
}
void
Worldmap::on_secondary_button_press(int x, int y)
{
if (maintainer_mode)
- {
- Vector3f click_pos = gc_state.screen2world(Vector2i(x, y));
+ {
+ Vector3f click_pos = gc_state.screen2world(Vector2i(x, y));
- Dot* dot = path_graph->get_dot(click_pos.x, click_pos.y);
- if (dot)
- { // FIXME: Dot NodeID missmatch...
- NodeId id = path_graph->get_id(dot);
- pingus->set_position(id);
- }
+ Dot* dot = path_graph->get_dot(click_pos.x, click_pos.y);
+ if (dot)
+ { // FIXME: Dot NodeID missmatch...
+ NodeId id = path_graph->get_id(dot);
+ pingus->set_position(id);
}
+ }
}
void
@@ -252,42 +260,43 @@
NodeId node = get_pingus()->get_node();
if (node != NoNode)
+ {
+ Dot* dot = path_graph->get_dot(node);
+ if (dot)
{
- Dot* dot = path_graph->get_dot(node);
- if (dot)
- {
- dot->on_click();
- }
+ dot->on_click();
}
+ }
else
- {
- if (maintainer_mode)
- std::cout << "Worldmap: Pingus not on level" << std::endl;
- }
+ {
+ if (maintainer_mode)
+ std::cout << "Worldmap: Pingus not on level" << std::endl;
+ }
}
struct unlock_nodes
{
PathGraph* path_graph;
- unlock_nodes(PathGraph* g)
+
+ unlock_nodes(PathGraph* g) :
+ path_graph(g)
{
- path_graph = g;
}
void operator()(Node<Dot*>& node)
{
if (node.data->finished())
+ {
+ //std::cout << "Unlocking neightbours of: " << node.data << std::endl;
+ for (std::vector<EdgeId>::iterator i = node.next.begin(); i !=
node.next.end(); ++i)
{
- //std::cout << "Unlocking neightbours of: " << node.data << std::endl;
- for (std::vector<EdgeId>::iterator i = node.next.begin(); i !=
node.next.end(); ++i)
- {
- Edge<Path*>& edge = path_graph->graph.resolve_edge(*i);
+ Edge<Path*>& edge = path_graph->graph.resolve_edge(*i);
- // FIXME: This should be identical to node.data->unlock(), but not
sure
- path_graph->graph.resolve_node(edge.source).data->unlock();
- path_graph->graph.resolve_node(edge.destination).data->unlock();
- }
+ // FIXME: This should be identical to node.data->unlock(), but not sure
+ path_graph->graph.resolve_node(edge.source).data->unlock();
+ path_graph->graph.resolve_node(edge.destination).data->unlock();
}
+ }
}
};
@@ -302,21 +311,21 @@
StatManager::instance()->get_bool(worldmap.get_short_name() +
"-endstory-seen", credits_unlocked);
if (!credits_unlocked)
+ {
+ // See if the last level is finished
+ Dot* dot = path_graph->get_dot(final_node);
+ if (dot)
{
- // See if the last level is finished
- Dot* dot = path_graph->get_dot(final_node);
- if (dot)
- {
- if (dot->finished())
- {
- ScreenManager::instance()->push_screen(new
StoryScreen(worldmap.get_end_story()));
- }
- }
- else
- {
- std::cout << "Error: Worldmap: Last level missing" << std::endl;
- }
+ if (dot->finished())
+ {
+ ScreenManager::instance()->push_screen(new
StoryScreen(worldmap.get_end_story()));
+ }
}
+ else
+ {
+ std::cout << "Error: Worldmap: Last level missing" << std::endl;
+ }
+ }
#endif
}
@@ -330,12 +339,12 @@
std::string node_name;
if (StatManager::instance()->get_string(worldmap.get_short_name() +
"-current-node", node_name))
- {
- // Just in case that level doesn't exist, look it up.
- id = path_graph->lookup_node(node_name);
- if (id == NoNode)
- id = default_node;
- }
+ {
+ // Just in case that level doesn't exist, look it up.
+ id = path_graph->lookup_node(node_name);
+ if (id == NoNode)
+ id = default_node;
+ }
else
id = default_node;
@@ -355,17 +364,17 @@
Worldmap::get_levelname()
{
if (pingus->get_node() != NoNode)
- {
- LevelDot* leveldot =
dynamic_cast<LevelDot*>(path_graph->get_dot(pingus->get_node()));
- if (leveldot)
- return _(leveldot->get_plf().get_levelname());
- else
- return "---";
- }
+ {
+ LevelDot* leveldot =
dynamic_cast<LevelDot*>(path_graph->get_dot(pingus->get_node()));
+ if (leveldot)
+ return _(leveldot->get_plf().get_levelname());
+ else
+ return "---";
+ }
else
- {
- return _("...walking...");
- }
+ {
+ return _("...walking...");
+ }
}
int
Modified: trunk/pingus/src/worldmap/worldmap_screen.cpp
===================================================================
--- trunk/pingus/src/worldmap/worldmap_screen.cpp 2009-11-04 19:29:46 UTC
(rev 4023)
+++ trunk/pingus/src/worldmap/worldmap_screen.cpp 2009-11-04 20:52:55 UTC
(rev 4024)
@@ -228,14 +228,16 @@
worldmap_screen->get_worldmap()->enter_level();
}
-WorldmapScreen::WorldmapScreen()
- : levelname_bg("core/worldmap/levelname_bg"),
- is_init(false),
- exit_worldmap(false),
- close_button(0),
- story_button(0),
- credits_button(0),
- enter_button(0)
+WorldmapScreen::WorldmapScreen() :
+ levelname_bg("core/worldmap/levelname_bg"),
+ is_init(false),
+ exit_worldmap(false),
+ worldmap(),
+ new_worldmap(),
+ close_button(0),
+ story_button(0),
+ credits_button(0),
+ enter_button(0)
{
// FIXME: a bit ugly because of the proteced member, but should work
// FIXME: well enough. GUIScreen could also use multi-inheritage,
Modified: trunk/pingus/src/worldobjs/entrance.cpp
===================================================================
--- trunk/pingus/src/worldobjs/entrance.cpp 2009-11-04 19:29:46 UTC (rev
4023)
+++ trunk/pingus/src/worldobjs/entrance.cpp 2009-11-04 20:52:55 UTC (rev
4024)
@@ -33,6 +33,8 @@
owner_id(0),
type("generic"),
smallmap_symbol("core/misc/smallmap_entrance"),
+ surface(),
+ last_release(),
last_direction(0)
{
reader.read_string("type", type);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] r4024 - in trunk/pingus/src: components display editor gui input lisp particles pingus worldmap worldobjs,
grumbel at BerliOS <=