[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] r2638 - in branches/pingus_sdl/src: . components display gu
From: |
grumbel at BerliOS |
Subject: |
[Pingus-CVS] r2638 - in branches/pingus_sdl/src: . components display gui math sound worldmap |
Date: |
Sat, 13 Jan 2007 21:43:04 +0100 |
Author: grumbel
Date: 2007-01-13 21:43:01 +0100 (Sat, 13 Jan 2007)
New Revision: 2638
Added:
branches/pingus_sdl/src/command_line.cpp
branches/pingus_sdl/src/command_line.hpp
branches/pingus_sdl/src/command_line_generic.cpp
branches/pingus_sdl/src/command_line_generic.hpp
branches/pingus_sdl/src/font.cpp
branches/pingus_sdl/src/font.hpp
branches/pingus_sdl/src/math/
branches/pingus_sdl/src/math/color.hpp
branches/pingus_sdl/src/math/matrix.cpp
branches/pingus_sdl/src/math/matrix.hpp
branches/pingus_sdl/src/math/origin.cpp
branches/pingus_sdl/src/math/origin.hpp
branches/pingus_sdl/src/math/quaternion.cpp
branches/pingus_sdl/src/math/quaternion.hpp
branches/pingus_sdl/src/math/rect.cpp
branches/pingus_sdl/src/math/rect.hpp
branches/pingus_sdl/src/math/size.hpp
branches/pingus_sdl/src/math/vector2f.cpp
branches/pingus_sdl/src/math/vector2f.hpp
branches/pingus_sdl/src/math/vector2i.hpp
branches/pingus_sdl/src/math/vector3f.cpp
branches/pingus_sdl/src/math/vector3f.hpp
branches/pingus_sdl/src/origin.cpp
branches/pingus_sdl/src/origin.hpp
branches/pingus_sdl/src/shared_ptr.hxx
branches/pingus_sdl/src/sprite.cpp
branches/pingus_sdl/src/sprite.hpp
Removed:
branches/pingus_sdl/src/vector.cxx
branches/pingus_sdl/src/vector.hxx
Modified:
branches/pingus_sdl/src/SConscript
branches/pingus_sdl/src/blitter.hxx
branches/pingus_sdl/src/components/menu_button.cxx
branches/pingus_sdl/src/components/menu_button.hxx
branches/pingus_sdl/src/display/drawing_context.cxx
branches/pingus_sdl/src/display/drawing_context.hxx
branches/pingus_sdl/src/display/drawing_request.hxx
branches/pingus_sdl/src/exit_menu.cxx
branches/pingus_sdl/src/exit_menu.hxx
branches/pingus_sdl/src/file_dialog.hxx
branches/pingus_sdl/src/fonts.cxx
branches/pingus_sdl/src/fonts.hxx
branches/pingus_sdl/src/graphic_context_state.hxx
branches/pingus_sdl/src/gui/display.cxx
branches/pingus_sdl/src/gui/display.hxx
branches/pingus_sdl/src/gui/screen_manager.cxx
branches/pingus_sdl/src/gui/screen_manager.hxx
branches/pingus_sdl/src/gui/surface_button.cxx
branches/pingus_sdl/src/gui/surface_button.hxx
branches/pingus_sdl/src/layer_manager.cxx
branches/pingus_sdl/src/layer_manager.hxx
branches/pingus_sdl/src/pingus_level.hxx
branches/pingus_sdl/src/pingus_menu.cxx
branches/pingus_sdl/src/pingus_menu.hxx
branches/pingus_sdl/src/pingus_menu_manager.cxx
branches/pingus_sdl/src/resource.cxx
branches/pingus_sdl/src/resource.hxx
branches/pingus_sdl/src/sound/sound.cxx
branches/pingus_sdl/src/sound/sound.hxx
branches/pingus_sdl/src/sound/sound_real.cxx
branches/pingus_sdl/src/sound/sound_real.hxx
branches/pingus_sdl/src/sound/sound_res_mgr.cxx
branches/pingus_sdl/src/theme_selector.cxx
branches/pingus_sdl/src/theme_selector.hxx
branches/pingus_sdl/src/worldmap/manager.hxx
branches/pingus_sdl/src/worldmap/worldmap.hxx
Log:
- some more SDL stuff, trying to get the main menu to run
Modified: branches/pingus_sdl/src/SConscript
===================================================================
--- branches/pingus_sdl/src/SConscript 2007-01-13 11:37:45 UTC (rev 2637)
+++ branches/pingus_sdl/src/SConscript 2007-01-13 20:43:01 UTC (rev 2638)
@@ -44,15 +44,15 @@
env.ParseConfig('sdl-config --cflags --libs')
-sdl_env.ParseConfig('sdl-config --cflags --libs')
-sdl_env['LIBS'] += ['SDL_image']
-sdl_env.Program('display/scene_test', [
- 'display/scene_graph.cxx',
- 'display/sprite_node.cxx',
- 'display/scene_node.cxx',
- 'math/rect.cpp',
- 'math/origin.cpp',
- 'display/scene_test.cxx'])
+# sdl_env.ParseConfig('sdl-config --cflags --libs')
+# sdl_env['LIBS'] += ['SDL_image']
+# sdl_env.Program('display/scene_test', [
+# 'display/scene_graph.cxx',
+# 'display/sprite_node.cxx',
+# 'display/scene_node.cxx',
+# 'math/rect.cpp',
+# 'math/origin.cpp',
+# 'display/scene_test.cxx'])
env.Program('../pingus', [
@@ -131,11 +131,13 @@
'command_line.cpp',
'command_line_generic.cpp',
-# 'exit_menu.cxx',
+'exit_menu.cxx',
# 'file_dialog.cxx',
# 'file_dialog_item.cxx',
# 'file_reader.cxx',
-# 'fonts.cxx',
+'fonts.cxx',
+'font.cpp',
+'sprite.cpp',
# 'fps_counter.cxx',
# 'game_counter.cxx',
# 'game_session.cxx',
@@ -151,15 +153,15 @@
# 'gui/combobox.cxx',
# 'gui/cursor.cxx',
'gui/display.cxx',
-# 'gui/gui_manager.cxx',
-# 'gui/gui_screen.cxx',
+'gui/gui_manager.cxx',
+'gui/gui_screen.cxx',
# 'gui/input_box.cxx',
# 'gui/input_debug_screen.cxx',
-# 'gui/root_gui_manager.cxx',
-# 'gui/screen.cxx',
+'gui/root_gui_manager.cxx',
+'gui/screen.cxx',
'gui/screen_manager.cxx',
'gui/screen_ptr.cxx',
-# 'gui/surface_button.cxx',
+'gui/surface_button.cxx',
# # 'input/axes/button_axis.cxx',
# # 'input/axes/inverted_axis.cxx',
@@ -186,10 +188,10 @@
# # 'input/scrollers/multiple_scroller.cxx',
# # 'input/scrollers/pointer_scroller.cxx',
-# 'layer_manager.cxx',
+'layer_manager.cxx',
# 'level_interrupt.cxx',
# 'loading.cxx',
-# 'components/menu_button.cxx',
+'components/menu_button.cxx',
# 'mover.cxx',
# 'movers/linear_mover.cxx',
# 'multiline_text.cxx',
@@ -209,16 +211,16 @@
# 'pingus_level.cxx',
'pingus_main.cxx',
# 'pingus_map_manager.cxx',
-# 'pingus_menu.cxx',
-# 'pingus_menu_manager.cxx',
-# 'pingus_sub_menu.cxx',
+'pingus_menu.cxx',
+'pingus_menu_manager.cxx',
+'pingus_sub_menu.cxx',
# 'plf_res_mgr.cxx',
# 'plt_xml.cxx',
# 'preview_renderer.cxx',
# 'range.cxx',
-# 'res_descriptor.cxx',
-# 'resource.cxx',
-# 'resource_modifier.cxx',
+'res_descriptor.cxx',
+'resource.cxx',
+'resource_modifier.cxx',
# 'result.cxx',
# 'result_screen.cxx',
# 'savegame.cxx',
@@ -227,21 +229,23 @@
# 'server.cxx',
# 'server_event.cxx',
# 'smallmap_image.cxx',
-# 'sound/sound.cxx',
-# 'sound/sound_dummy.cxx',
+'sound/sound.cxx',
+'sound/sound_dummy.cxx',
# 'sound/sound_real.cxx',
-# 'sound/sound_res_mgr.cxx',
+'sound/sound_res_mgr.cxx',
# 'ground_map.cxx',
# 'start_screen.cxx',
# 'stat_manager.cxx',
# 'state_sprite.cxx',
# 'story_screen.cxx',
-# 'string_format.cxx',
+# 'string_format.cxx',
+'origin.cpp',
'system.cxx',
# 'timer.cxx',
'tinygettext/tinygettext.cxx',
# 'true_server.cxx',
-'vector.cxx',
+'math/vector2f.cpp',
+'math/vector3f.cpp',
# 'world.cxx',
# 'worldmap/dot.cxx',
# 'worldmap/dot_factory.cxx',
Modified: branches/pingus_sdl/src/blitter.hxx
===================================================================
--- branches/pingus_sdl/src/blitter.hxx 2007-01-13 11:37:45 UTC (rev 2637)
+++ branches/pingus_sdl/src/blitter.hxx 2007-01-13 20:43:01 UTC (rev 2638)
@@ -21,13 +21,13 @@
#define HEADER_PINGUS_BLITTER_HXX
#include "pingus.hxx"
-#include <ClanLib/Display/color.h>
+////#include <ClanLib/Display/color.h>
class CL_Surface;
class CL_PixelBuffer;
namespace Pingus {
-
+#if 0
/** A bunch of blitting and creation functions to operate on
CL_PixelBuffer. Some of them a similar to the ones in ClanLib, but
this are slower and work. */
@@ -106,7 +106,7 @@
Blitter (const Blitter&);
Blitter& operator= (const Blitter&);
};
-
+#endif
} // namespace Pingus
#endif
Added: branches/pingus_sdl/src/command_line.cpp
===================================================================
--- branches/pingus_sdl/src/command_line.cpp 2007-01-13 11:37:45 UTC (rev
2637)
+++ branches/pingus_sdl/src/command_line.cpp 2007-01-13 20:43:01 UTC (rev
2638)
@@ -0,0 +1,96 @@
+/*
+** ClanLib SDK
+** Copyright (c) 1997-2005 The ClanLib Team
+**
+** This software is provided 'as-is', without any express or implied
+** warranty. In no event will the authors be held liable for any damages
+** arising from the use of this software.
+**
+** Permission is granted to anyone to use this software for any purpose,
+** including commercial applications, and to alter it and redistribute it
+** freely, subject to the following restrictions:
+**
+** 1. The origin of this software must not be misrepresented; you must not
+** claim that you wrote the original software. If you use this software
+** in a product, an acknowledgment in the product documentation would be
+** appreciated but is not required.
+** 2. Altered source versions must be plainly marked as such, and must not be
+** misrepresented as being the original software.
+** 3. This notice may not be removed or altered from any source distribution.
+**
+** Note: Some of the libraries ClanLib may link to may have additional
+** requirements or restrictions.
+**
+** File Author(s):
+**
+** Magnus Norddahl
+** (if your name is missing here, please add it)
+*/
+
+#include "command_line.hpp"
+#include "command_line_generic.hpp"
+
+CommandLine::CommandLine()
+{
+ impl = new CommandLine_Generic();
+}
+
+CommandLine::~CommandLine()
+{
+ delete impl;
+}
+
+void CommandLine::parse_args(int argc, char** argv)
+{
+ impl->parse_args(argc, argv);
+}
+
+void CommandLine::print_help()
+{
+ impl->print_help();
+}
+
+void CommandLine::set_help_indent(int i)
+{
+ impl->set_help_indent(i);
+}
+
+void CommandLine::add_usage(const std::string& usage)
+{
+ impl->add_usage(usage);
+}
+
+void CommandLine::add_doc(const std::string& doc)
+{
+ impl->add_doc(doc);
+}
+
+void CommandLine::add_group(const std::string& grouptopic)
+{
+ impl->add_group(grouptopic);
+}
+
+void CommandLine::add_option(
+ int key,
+ const std::string& long_option,
+ const std::string& argument,
+ const std::string& help,
+ bool visible)
+{
+ impl->add_option(key, long_option, argument, help, visible);
+}
+
+bool CommandLine::next()
+{
+ return impl->next();
+}
+
+int CommandLine::get_key()
+{
+ return impl->get_key();
+}
+
+std::string CommandLine::get_argument()
+{
+ return impl->get_argument();
+}
Added: branches/pingus_sdl/src/command_line.hpp
===================================================================
--- branches/pingus_sdl/src/command_line.hpp 2007-01-13 11:37:45 UTC (rev
2637)
+++ branches/pingus_sdl/src/command_line.hpp 2007-01-13 20:43:01 UTC (rev
2638)
@@ -0,0 +1,157 @@
+/*
+** ClanLib SDK
+** Copyright (c) 1997-2005 The ClanLib Team
+**
+** This software is provided 'as-is', without any express or implied
+** warranty. In no event will the authors be held liable for any damages
+** arising from the use of this software.
+**
+** Permission is granted to anyone to use this software for any purpose,
+** including commercial applications, and to alter it and redistribute it
+** freely, subject to the following restrictions:
+**
+** 1. The origin of this software must not be misrepresented; you must not
+** claim that you wrote the original software. If you use this software
+** in a product, an acknowledgment in the product documentation would be
+** appreciated but is not required.
+** 2. Altered source versions must be plainly marked as such, and must not be
+** misrepresented as being the original software.
+** 3. This notice may not be removed or altered from any source distribution.
+**
+** Note: Some of the libraries ClanLib may link to may have additional
+** requirements or restrictions.
+**
+** File Author(s):
+**
+** Magnus Norddahl
+** (if your name is missing here, please add it)
+*/
+
+//! clanCore="System"
+//! header=core.h
+
+#ifndef HEADER_COMMAND_LINE_HPP
+#define HEADER_COMMAND_LINE_HPP
+
+#if _MSC_VER > 1000
+#pragma once
+#endif
+
+#include <string>
+#include <vector>
+
+class CommandLine_Generic;
+
+//: Helper class to parse command line arguments
+//- !group=Core/System!
+//- !header=core.h!
+//- <p>The CommandLine class helps to parse command line arguments, namely
+//- the argc/argv pair that you get from main(). CommandLine mimics
+//- getopt_long() behaviour as closely as possible, while providing a
+//- cleaner interface and a few additional features, like automatic
+//- generation of '--help' output. CommandLine can parse long arguments
+//- in the following styles:</p>
+//-
+//- <p>program --file FILENAME<br>
+//- program --file=FILENAME</p>
+//-
+//- <p>Short arguments are handled like this:</p>
+//-
+//- <p>program -f FILENAME</p>
+//-
+//- <p>Concatenating short arguments is also supported, so that:</p>
+//-
+//- <p>program -f -a -b FILENAME</p>
+//-
+//- <p>is equivalent to:</p>
+//-
+//- <p>program -fab FILENAME</p>
+//-
+//- <p>Non-option arguments (aka rest arguments) are supported as well:</p>
+//-
+//- <p>program SOMEFILE SOMEOTHERFILE ...</p>
+//-
+//- <p>To avoid ambiguity when a filename starts with '-' CommandLine stops
+//- parsing arguments after the first encounter of a '--', so in</p>
+//-
+//- <p>program -f -b -- -f -b</p>
+//-
+//- <p>In the above example the first '-f -b' options are treated as
+//- normal while the ones after the '--' are treated as rest arguments
+//- (aka filenames in most programs).</p>
+class CommandLine
+{
+//! Construction:
+public:
+ CommandLine();
+
+ ~CommandLine();
+
+//! Attributes:
+public:
+ enum
+ {
+ REST_ARG = -2
+ };
+
+ //: Return the key of the current option
+ int get_key();
+
+ //: Return the argument to the current option
+ std::string get_argument();
+
+//! Operations:
+public:
+ //: Change the indention used for the help message, default is 18
+ void set_help_indent(int i);
+
+ //: Add a usage line to the help output, usage is for example
+ //: "[OPTIONS]... FILE", the program name will get appended
+ //: automatically
+ void add_usage(const std::string& usage);
+
+ //: Adds extra documentation to the help output, should only be
+ //: used at the beginning or at the end, to
+ void add_doc(const std::string& doc);
+
+ //: Starts a new group of options, the grouptopic gets printed
+ //: above the group of options in the print_help() output
+ void add_group(const std::string& grouptopic);
+
+ //: Adds a option to the parser
+ //param key: a letter for a short-option or a numeric value
+ //param key: larger than 255 that identifies the option
+ //param long_option: the long name of this option or "" if non
+ //param long_option: should be used for this option
+ //param argument: the type of the argument that this option
+ //param argument: requires (i.e. FILE, SIZE, WIDTH, etc.) or "" if no
argument is
+ //param argument: required
+ //param help: the help string for this option
+ //param visible: true if the option should be listed in the help
+ //param visible: output, false will not list it in the help output
which might
+ //param visible: be usefull for cheat-options or backward-compability
options
+ //param visible: than would only clutter the help output
+ void add_option(
+ int key,
+ const std::string& long_option,
+ const std::string& argument,
+ const std::string& help,
+ bool visible = true);
+
+ //: Parse the options arcording to the options added with
+ //: add_option(), result of the parsing is accessible via
+ //: next() and get_key()/get_argument()
+ void parse_args(int argc, char** argv);
+
+ //: Print the help output, normaly done via a --help option
+ void print_help();
+
+ //: Goto the next option
+ bool next();
+
+//! Implementation:
+private:
+ CommandLine_Generic* impl;
+};
+
+#endif
Added: branches/pingus_sdl/src/command_line_generic.cpp
===================================================================
--- branches/pingus_sdl/src/command_line_generic.cpp 2007-01-13 11:37:45 UTC
(rev 2637)
+++ branches/pingus_sdl/src/command_line_generic.cpp 2007-01-13 20:43:01 UTC
(rev 2638)
@@ -0,0 +1,336 @@
+/*
+** ClanLib SDK
+** Copyright (c) 1997-2005 The ClanLib Team
+**
+** This software is provided 'as-is', without any express or implied
+** warranty. In no event will the authors be held liable for any damages
+** arising from the use of this software.
+**
+** Permission is granted to anyone to use this software for any purpose,
+** including commercial applications, and to alter it and redistribute it
+** freely, subject to the following restrictions:
+**
+** 1. The origin of this software must not be misrepresented; you must not
+** claim that you wrote the original software. If you use this software
+** in a product, an acknowledgment in the product documentation would be
+** appreciated but is not required.
+** 2. Altered source versions must be plainly marked as such, and must not be
+** misrepresented as being the original software.
+** 3. This notice may not be removed or altered from any source distribution.
+**
+** Note: Some of the libraries ClanLib may link to may have additional
+** requirements or restrictions.
+**
+** File Author(s):
+**
+** Magnus Norddahl
+** (if your name is missing here, please add it)
+*/
+
+#include <iomanip>
+#include <iostream>
+#include <stdexcept>
+#include <stdio.h>
+
+#include "command_line_generic.hpp"
+
+
+#ifdef WIN32
+#define snprintf _snprintf
+#endif
+
+CommandLine_Generic::CommandLine_Generic()
+{
+ help_indent = 18;
+}
+
+void CommandLine_Generic::parse_args(int argc, char** argv)
+{
+ programm = argv[0];
+
+ for(int i = 1; i < argc; ++i)
+ {
+ if (argv[i][0] == '-')
+ {
+ if (argv[i][1] == '-')
+ {
+ // We got a long option
+ if (argv[i][2] == '\0') {
+ // Got a '--', so we stop evaluating arguments
+ ++i;
+ while(i < argc)
+ {
+ read_option(CommandLine::REST_ARG, argv[i]);
+ ++i;
+ }
+ }
+ else
+ {
+ std::string opt = argv[i] + 2;
+ std::string long_opt;
+ std::string long_opt_arg;
+
+ std::string::size_type pos = opt.find('=');
+
+ if (pos != std::string::npos)
+ {
+ long_opt = opt.substr(0, pos);
+ long_opt_arg = opt.substr(pos+1);
+ }
+ else
+ {
+ long_opt = opt;
+ }
+
+ // Long Option
+ Option* option = lookup_long_option(long_opt);
+
+ if (option)
+ {
+ if (option->argument.empty())
+ {
+ read_option(option->key, "");
+ }
+ else
+ {
+ if (pos != std::string::npos)
+ {
+ read_option(option->key, long_opt_arg);
+ }
+ else
+ {
+ if (i == argc - 1)
+ {
+ throw std::runtime_error("option '" +
std::string(argv[i]) + "' requires an argument");
+ }
+ else
+ {
+ read_option(option->key, argv[i + 1]);
+ ++i;
+ }
+ }
+ }
+ }
+ else
+ {
+ throw std::runtime_error("unrecognized option '" +
std::string(argv[i]) + "'");
+ }
+ }
+ }
+ else
+ {
+ // We got a short option
+ char* p = argv[i] + 1;
+
+ if (*p != '\0') {
+ // Handle option chains
+ while (*p)
+ {
+ // Short option(s)
+ Option* option = lookup_short_option(*p);
+
+ if (option)
+ {
+ if (option->argument.empty())
+ {
+ read_option(option->key, "");
+ }
+ else
+ {
+ if (i == argc - 1 || *(p+1) != '\0')
+ {
+ // No more arguments
+ throw std::runtime_error("option requires an
argument -- " + std::string(1, *p));
+ }
+ else
+ {
+ read_option(option->key, argv[i + 1]);
+ ++i;
+ }
+ }
+ }
+ else
+ {
+ throw std::runtime_error("invalid option -- " +
std::string(1, *p));
+ }
+ ++p;
+ }
+ }
+ else
+ {
+ read_option(CommandLine::REST_ARG, "-");
+ }
+ }
+ }
+ else
+ {
+ read_option(CommandLine::REST_ARG, argv[i]);
+ }
+ }
+
+ current_option = parsed_options.end();
+}
+
+CommandLine_Generic::Option *CommandLine_Generic::lookup_short_option(char
short_option)
+{
+ for(Options::iterator i = options.begin(); i != options.end(); ++i)
+ {
+ if (i->key == short_option)
+ return &(*i);
+ }
+ return 0;
+}
+
+CommandLine_Generic::Option *CommandLine_Generic::lookup_long_option(const
std::string& long_option)
+{
+ for(Options::iterator i = options.begin(); i != options.end(); ++i)
+ {
+ if (i->long_option == long_option)
+ return &*i;
+ }
+ return 0;
+}
+
+void CommandLine_Generic::read_option(int key, const std::string& argument)
+{
+ ParsedOption parsed_option;
+
+ parsed_option.key = key;
+ parsed_option.argument = argument;
+
+ parsed_options.push_back(parsed_option);
+}
+
+void CommandLine_Generic::print_help()
+{
+ bool first_usage = true;
+ for(Options::iterator i = options.begin(); i != options.end(); ++i)
+ {
+ if (i->visible)
+ {
+ if (i->key == USAGE)
+ {
+ if (first_usage)
+ {
+ std::cout << "Usage: " << programm << " " << i->help <<
std::endl;
+ first_usage = false;
+ }
+ else
+ {
+ std::cout << "or: " << programm << " " << i->help <<
std::endl;
+ }
+ }
+ else if (i->key == GROUP)
+ {
+ if (i != options.begin())
+ std::cout << std::endl;
+ std::cout << i->help << std::endl;
+ }
+ else if (i->key == DOC)
+ {
+ if (i != options.begin())
+ std::cout << std::endl;
+ std::cout << i->help << std::endl;
+ }
+ else
+ {
+ char option[256] = { 0 };
+ char argument[256] = { 0 };
+
+ if (i->key > 255 || i->key < 0)
+ snprintf(option, 256, "--%s", i->long_option.c_str());
+ else if (i->long_option.empty())
+ snprintf(option, 256, "-%c", char(i->key));
+ else
+ snprintf(option, 256, "-%c, --%s", char(i->key),
i->long_option.c_str());
+
+ if (!i->argument.empty())
+ {
+ if (i->long_option.empty())
+ snprintf(argument, 256, " %s", i->argument.c_str());
+ else
+ snprintf(argument, 256, "=%s", i->argument.c_str());
+ }
+
+ std::cout << " "
+ << std::setiosflags(std::ios::left) <<
std::setw(help_indent)
+ << (std::string(option) + std::string(argument)) <<
std::setw(0)
+ << " " << i->help << std::endl;
+ }
+ }
+ }
+ std::cout << std::endl;
+}
+
+void CommandLine_Generic::add_usage(const std::string& usage)
+{
+ Option option;
+
+ option.key = USAGE;
+ option.help = usage;
+ option.visible = true;
+
+ options.push_back(option);
+}
+
+void CommandLine_Generic::add_doc(const std::string& grouptopic)
+{
+ Option option;
+
+ option.key = DOC;
+ option.help = grouptopic;
+ option.visible = true;
+
+ options.push_back(option);
+}
+
+void CommandLine_Generic::add_group(const std::string& grouptopic)
+{
+ Option option;
+
+ option.key = GROUP;
+ option.help = grouptopic;
+ option.visible = true;
+
+ options.push_back(option);
+}
+
+void CommandLine_Generic::add_option(int key,
+ const std::string& long_option,
+ const std::string& argument,
+ const std::string& help,
+ bool visible)
+{
+ Option option;
+
+ option.key = key;
+ option.help = help;
+ option.long_option = long_option;
+ option.argument = argument;
+ option.visible = visible;
+
+ options.push_back(option);
+}
+
+bool CommandLine_Generic::next()
+{
+ if (current_option == parsed_options.end())
+ {
+ (current_option = parsed_options.begin());
+ return current_option != parsed_options.end();
+ }
+ else
+ {
+ return (++current_option) != parsed_options.end();
+ }
+}
+
+int CommandLine_Generic::get_key()
+{
+ return current_option->key;
+}
+
+std::string CommandLine_Generic::get_argument()
+{
+ return current_option->argument;
+}
Added: branches/pingus_sdl/src/command_line_generic.hpp
===================================================================
--- branches/pingus_sdl/src/command_line_generic.hpp 2007-01-13 11:37:45 UTC
(rev 2637)
+++ branches/pingus_sdl/src/command_line_generic.hpp 2007-01-13 20:43:01 UTC
(rev 2638)
@@ -0,0 +1,111 @@
+/*
+** ClanLib SDK
+** Copyright (c) 1997-2005 The ClanLib Team
+**
+** This software is provided 'as-is', without any express or implied
+** warranty. In no event will the authors be held liable for any damages
+** arising from the use of this software.
+**
+** Permission is granted to anyone to use this software for any purpose,
+** including commercial applications, and to alter it and redistribute it
+** freely, subject to the following restrictions:
+**
+** 1. The origin of this software must not be misrepresented; you must not
+** claim that you wrote the original software. If you use this software
+** in a product, an acknowledgment in the product documentation would be
+** appreciated but is not required.
+** 2. Altered source versions must be plainly marked as such, and must not be
+** misrepresented as being the original software.
+** 3. This notice may not be removed or altered from any source distribution.
+**
+** Note: Some of the libraries ClanLib may link to may have additional
+** requirements or restrictions.
+**
+** File Author(s):
+**
+** Magnus Norddahl
+** (if your name is missing here, please add it)
+*/
+
+#ifndef HEADER_COMMAND_LINE_GENERIC_HPP
+#define HEADER_COMMAND_LINE_GENERIC_HPP
+
+#if _MSC_VER > 1000
+#pragma once
+#endif
+
+#include <string>
+#include <vector>
+#include "command_line.hpp"
+
+class CommandLine_Generic
+{
+private:
+ int help_indent;
+
+ std::string programm;
+
+ struct Option
+ {
+ int key;
+ std::string help;
+ std::string long_option;
+ std::string argument;
+ bool visible;
+ };
+
+ typedef std::vector<Option> Options;
+ Options options;
+
+ struct ParsedOption
+ {
+ int key;
+ std::string argument;
+ };
+
+ typedef std::vector<ParsedOption> ParsedOptions;
+ ParsedOptions parsed_options;
+ ParsedOptions::iterator current_option;
+
+ enum
+ {
+ GROUP = -3,
+ DOC = -4,
+ USAGE = -5
+ };
+
+public:
+ CommandLine_Generic();
+
+ void set_help_indent(int i) { help_indent = i; }
+
+ void add_usage(const std::string& usage);
+ void add_doc(const std::string& doc);
+ void add_group(const std::string& grouptopic);
+
+ void add_option(int key,
+ const std::string&
long_option,
+ const std::string& argument,
+ const std::string& help,
+ bool visible = true);
+
+ void parse_args(int argc, char** argv);
+ void print_help();
+
+ bool next();
+ int get_key();
+ std::string get_argument();
+
+private:
+ void read_option(int id, const std::string& argument);
+
+ /** Find the Option structure that matches \a short_option */
+ Option* lookup_short_option(char short_option);
+
+ /** Find the Option structure that matches \a long_option */
+ Option* lookup_long_option (const std::string& long_option);
+};
+
+#endif
+
+/* EOF */
Modified: branches/pingus_sdl/src/components/menu_button.cxx
===================================================================
--- branches/pingus_sdl/src/components/menu_button.cxx 2007-01-13 11:37:45 UTC
(rev 2637)
+++ branches/pingus_sdl/src/components/menu_button.cxx 2007-01-13 20:43:01 UTC
(rev 2638)
@@ -17,27 +17,24 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#include <ClanLib/Display/display.h>
-#include <ClanLib/Display/font.h>
-
#include "../globals.hxx"
#include "../debug.hxx"
#include "../sound/sound.hxx"
#include "../resource.hxx"
#include "../pingus_menu_manager.hxx"
-#include "../theme_selector.hxx"
-#include "../gui/screen_manager.hxx"
-#include "../worldmap/manager.hxx"
-#include "../story_screen.hxx"
+////#include "../theme_selector.hxx"
+////#include "../gui/screen_manager.hxx"
+////#include "../worldmap/manager.hxx"
+////#include "../story_screen.hxx"
#include "../gettext.h"
-#include "../stat_manager.hxx"
+////#include "../stat_manager.hxx"
#include "menu_button.hxx"
namespace Pingus {
-MenuButton::MenuButton(const CL_Point& pos_, const CL_Sprite& sprite_,
- const std::string& text_, const std::string&
desc_)
+MenuButton::MenuButton(const Vector2i& pos_, const Sprite& sprite_,
+ const std::string& text_, const std::string& desc_)
{
text = text_;
desc = desc_;
@@ -76,7 +73,7 @@
void
MenuButton::on_click ()
{
- click();
+ ////click();
}
void
@@ -84,11 +81,11 @@
{
if (mouse_over && !pressed)
{
- gc.print_center(font, (float)CL_Display::get_width() / 2,
- (float)(CL_Display::get_height() - font.get_height()),
+ gc.print_center(font, (float)Display::get_width() / 2,
+ (float)(Display::get_height() - font.get_height()),
desc.c_str());
- gc.draw(surface_p, Vector((float)(x_pos - surface_p.get_width()/2),
+ gc.draw(surface_p, Vector3f((float)(x_pos - surface_p.get_width()/2),
(float)(y_pos - surface_p.get_height()/2)));
gc.print_center(font_large, (float)x_pos + 32,
@@ -99,12 +96,12 @@
{
float shrink = 0.9f;
- gc.print_center(font, (float)CL_Display::get_width() / 2,
- (float)CL_Display::get_height() - 20,
+ gc.print_center(font, (float)Display::get_width() / 2,
+ (float)Display::get_height() - 20,
desc.c_str());
gc.draw(surface_p,
- Vector((float)(x_pos - surface_p.get_width()/2 * shrink),
+ Vector3f((float)(x_pos - surface_p.get_width()/2 * shrink),
(float)(y_pos - surface_p.get_height()/2 * shrink)));
gc.print_center(font_large,
@@ -115,7 +112,7 @@
else
{
gc.draw(surface_p,
- Vector((float)(x_pos - surface_p.get_width()/2),
+ Vector3f((float)(x_pos - surface_p.get_width()/2),
(float)(y_pos - surface_p.get_height()/2)));
}
UNUSED_ARG(gc);
Modified: branches/pingus_sdl/src/components/menu_button.hxx
===================================================================
--- branches/pingus_sdl/src/components/menu_button.hxx 2007-01-13 11:37:45 UTC
(rev 2637)
+++ branches/pingus_sdl/src/components/menu_button.hxx 2007-01-13 20:43:01 UTC
(rev 2638)
@@ -21,8 +21,9 @@
#define HEADER_PINGUS_MENU_BUTTON_HXX
#include <string>
-#include <ClanLib/Display/sprite.h>
-#include <ClanLib/Display/font.h>
+#include "sprite.hpp"
+#include "font.hpp"
+#include "math/vector2i.hpp"
#include "../gui/component.hxx"
namespace Pingus {
@@ -33,9 +34,9 @@
class MenuButton : public GUI::Component
{
protected:
- CL_Sprite surface_p;
- CL_Font font;
- CL_Font font_large;
+ Sprite surface_p;
+ Font font;
+ Font font_large;
int x_pos;
int y_pos;
@@ -46,10 +47,10 @@
bool mouse_over;
bool pressed;
- CL_Signal_v0 click;
+ ////CL_Signal_v0 click;
public:
- MenuButton(const CL_Point& pos, const CL_Sprite& sprite,
+ MenuButton(const Vector2i& pos, const Sprite& sprite,
const std::string& text, const std::string& desc);
MenuButton();
virtual ~MenuButton();
@@ -67,7 +68,7 @@
void on_primary_button_click (int x, int y) { on_click (); UNUSED_ARG(x);
UNUSED_ARG(y); }
virtual void on_click ();
- CL_Signal_v0& sig_click() { return click; }
+ ////CL_Signal_v0& sig_click() { return click; }
private:
MenuButton (const MenuButton&);
MenuButton& operator= (const MenuButton&);
Modified: branches/pingus_sdl/src/display/drawing_context.cxx
===================================================================
--- branches/pingus_sdl/src/display/drawing_context.cxx 2007-01-13 11:37:45 UTC
(rev 2637)
+++ branches/pingus_sdl/src/display/drawing_context.cxx 2007-01-13 20:43:01 UTC
(rev 2638)
@@ -21,6 +21,10 @@
#include <iostream>
#include <iostream>
#include "drawing_context.hxx"
+#include "gui/display.hxx"
+#include "../sprite.hpp"
+#include "../font.hpp"
+#include "../origin.hpp"
namespace Pingus {
@@ -31,6 +35,46 @@
}
};
+class FontDrawingRequest : public DrawingRequest
+{
+private:
+ Font font;
+ std::string text;
+ float x;
+ float y;
+public:
+ FontDrawingRequest(Font font_, Origin origin, const Vector3f& pos, const
std::string& text_, float z)
+ : DrawingRequest(Vector3f(pos.x, pos.y, z)),
+ font(font_),
+ text(text_)
+ {
+ font.set_alignment(origin);
+ }
+
+ virtual ~FontDrawingRequest() {}
+
+ void draw(SDL_Surface* target) {
+ font.draw(static_cast<int>(pos.x), static_cast<int>(pos.y), text, target);
+ }
+};
+
+class SpriteDrawingRequest : public DrawingRequest
+{
+private:
+ Sprite sprite;
+
+public:
+ SpriteDrawingRequest(const Sprite& sprite_, const Vector3f& pos_)
+ : DrawingRequest(pos_),
+ sprite(sprite_)
+ {}
+ virtual ~SpriteDrawingRequest() {}
+
+ void draw(SDL_Surface* target) {
+ sprite.draw(pos.x, pos.y, target);
+ }
+};
+
#if 0
class FillScreenDrawingRequest : public DrawingRequest
{
@@ -38,7 +82,7 @@
CL_Color color;
public:
FillScreenDrawingRequest(const CL_Color& color_)
- : DrawingRequest(CL_Vector(0, 0, -1000.0f)), color(color_)
+ : DrawingRequest(Vector3f(0, 0, -1000.0f)), color(color_)
{
}
virtual ~FillScreenDrawingRequest() {}
@@ -54,7 +98,7 @@
CL_Surface sprite;
public:
- SurfaceDrawingRequest(const CL_Surface& sprite_, const CL_Vector& pos_)
+ SurfaceDrawingRequest(const CL_Surface& sprite_, const Vector3f& pos_)
: DrawingRequest(pos_),
sprite(sprite_)
{}
@@ -65,28 +109,6 @@
}
};
-class FontDrawingRequest : public DrawingRequest
-{
-private:
- CL_Font font;
- std::string text;
- float x;
- float y;
-public:
- FontDrawingRequest(CL_Font font_, CL_Origin origin, const CL_Vector& pos,
const std::string& text_, float z)
- : DrawingRequest(CL_Vector(pos.x, pos.y, z)),
- font(font_), text(text_)
- {
- font.set_alignment(origin);
- }
-
- virtual ~FontDrawingRequest() {}
-
- void draw(CL_GraphicContext* gc) {
- font.draw(static_cast<int>(pos.x), static_cast<int>(pos.y), text, gc);
- }
-};
-
class LineDrawingRequest : public DrawingRequest
{
private:
@@ -99,7 +121,7 @@
const Vector& pos2_,
const CL_Color& color_,
float z)
- : DrawingRequest(CL_Vector(0, 0, z)),
+ : DrawingRequest(Vector3f(0, 0, z)),
pos1(pos1_),
pos2(pos2_),
color(color_)
@@ -122,7 +144,7 @@
public:
RectDrawingRequest(const CL_Rectf& rect_, const CL_Color& color_, bool
filled_, float z)
- : DrawingRequest(CL_Vector(rect.left, rect.top, z)),
+ : DrawingRequest(Vector3f(rect.left, rect.top, z)),
rect(rect_), color(color_), filled(filled_)
{}
@@ -135,29 +157,12 @@
}
};
-class SpriteDrawingRequest : public DrawingRequest
-{
-private:
- CL_Sprite sprite;
-
-public:
- SpriteDrawingRequest(const CL_Sprite& sprite_, const CL_Vector& pos_)
- : DrawingRequest(pos_),
- sprite(sprite_)
- {}
- virtual ~SpriteDrawingRequest() {}
-
- void draw(CL_GraphicContext* gc) {
- sprite.draw(pos.x, pos.y, gc);
- }
-};
-
class TextDrawingRequest : public DrawingRequest
{
private:
std::string text;
public:
- TextDrawingRequest(const std::string& text_, const CL_Vector& pos_)
+ TextDrawingRequest(const std::string& text_, const Vector3f& pos_)
: DrawingRequest(pos_),
text(text_)
{}
@@ -176,7 +181,7 @@
public:
DrawingContextDrawingRequest(DrawingContext* dc_, float z)
- : DrawingRequest(Vector3(0,0,z)),
+ : DrawingRequest(Vector3f(0,0,z)),
dc(dc_)
{}
@@ -192,7 +197,7 @@
DrawingContext::DrawingContext()
{
- translate_stack.push_back(Vector(0, 0));
+ translate_stack.push_back(Vector3f(0, 0));
}
DrawingContext::~DrawingContext()
@@ -246,30 +251,31 @@
void
DrawingContext::draw(const CL_Surface& surface, const Vector& pos)
{
- draw(new SurfaceDrawingRequest(surface, CL_Vector(translate_stack.back().x +
pos.x,
+ draw(new SurfaceDrawingRequest(surface, Vector3f(translate_stack.back().x +
pos.x,
translate_stack.back().y +
pos.y,
pos.z)));
}
-
+#endif
void
-DrawingContext::draw(const CL_Sprite& sprite, const Vector& pos)
+DrawingContext::draw(const Sprite& sprite, const Vector3f& pos)
{
draw(sprite, pos.x, pos.y, pos.z);
}
void
-DrawingContext::draw(const CL_Sprite& sprite, float x, float y, float z)
+DrawingContext::draw(const Sprite& sprite, float x, float y, float z)
{ // FIXME: This should get flattend down to a simple texture draw
// command for easier sorting after texture-id/alpha
- draw(new SpriteDrawingRequest(sprite, CL_Vector(translate_stack.back().x + x,
+ draw(new SpriteDrawingRequest(sprite, Vector3f(translate_stack.back().x + x,
translate_stack.back().y + y,
z)));
}
+#if 0
void
DrawingContext::draw(const std::string& text, float x, float y, float z)
{
- draw(new TextDrawingRequest(text, CL_Vector(x, y, z)));
+ draw(new TextDrawingRequest(text, Vector3f(x, y, z)));
}
void
@@ -373,69 +379,62 @@
static_cast<int>(-translate_stack.back().y)),
CL_Size((int)get_width(), (int)get_height()));
}
-
+#endif
float
DrawingContext::get_width() const
{
- return (float)CL_Display::get_width();
+ return (float)Display::get_width();
}
float
DrawingContext::get_height() const
{
- return (float)CL_Display::get_height();
+ return (float)Display::get_height();
}
void
-DrawingContext::print_left (const CL_Font& font_, float x_pos, float y_pos,
const std::string& str, float z)
+DrawingContext::print_left (const Font& font_, float x_pos, float y_pos, const
std::string& str, float z)
{
-#if 0
draw(new FontDrawingRequest(font_,
origin_top_left,
- CL_Vector(x_pos + translate_stack.back().x,
+ Vector3f(x_pos + translate_stack.back().x,
y_pos + translate_stack.back().y),
str,
z));
-#endif
}
void
-DrawingContext::print_center (const CL_Font& font_, float x_pos, float y_pos,
const std::string& str, float z)
+DrawingContext::print_center (const Font& font_, float x_pos, float y_pos,
const std::string& str, float z)
{
-#if 0
draw(new FontDrawingRequest(font_,
origin_top_center,
- CL_Vector(x_pos + translate_stack.back().x,
+ Vector3f(x_pos + translate_stack.back().x,
y_pos + translate_stack.back().y),
str,
z));
-#endif
}
void
-DrawingContext::print_right (const CL_Font& font_, float x_pos, float y_pos,
const std::string& str, float z)
+DrawingContext::print_right (const Font& font_, float x_pos, float y_pos,
const std::string& str, float z)
{
-#if 0
draw(new FontDrawingRequest(font_,
origin_top_right,
- CL_Vector(x_pos + translate_stack.back().x,
- y_pos + translate_stack.back().y),
+ Vector3f(x_pos + translate_stack.back().x,
+ y_pos + translate_stack.back().y),
str,
z));
-#endif
}
-#endif
-Vector
-DrawingContext::screen_to_world (Vector pos)
+Vector3f
+DrawingContext::screen_to_world (Vector3f pos)
{
- return pos - Vector(translate_stack.back().x, translate_stack.back().y);
+ return pos - Vector3f(translate_stack.back().x, translate_stack.back().y);
}
-Vector
-DrawingContext::world_to_screen (Vector pos)
+Vector3f
+DrawingContext::world_to_screen (Vector3f pos)
{
- return pos + Vector(translate_stack.back().x, translate_stack.back().y);
+ return pos + Vector3f(translate_stack.back().x, translate_stack.back().y);
}
}
Modified: branches/pingus_sdl/src/display/drawing_context.hxx
===================================================================
--- branches/pingus_sdl/src/display/drawing_context.hxx 2007-01-13 11:37:45 UTC
(rev 2637)
+++ branches/pingus_sdl/src/display/drawing_context.hxx 2007-01-13 20:43:01 UTC
(rev 2638)
@@ -25,10 +25,11 @@
#include "SDL.h"
#include <vector>
#include "drawing_request.hxx"
-#include "../vector.hxx"
+#include "../math/vector3f.hpp"
+#include "../math/color.hpp"
-class CL_Font;
-class CL_Sprite;
+class Font;
+class Sprite;
class CL_Surface;
namespace Pingus {
@@ -45,7 +46,7 @@
typedef std::vector<DrawingRequest*> DrawingRequests;
DrawingRequests drawingrequests;
- std::vector<Vector> translate_stack;
+ std::vector<Vector3f> translate_stack;
public:
DrawingContext();
@@ -66,6 +67,9 @@
worth a try */
void draw(DrawingContext* dc, float z = 0);
+ void draw(const Sprite& sprite, const Vector3f& pos);
+ void draw(const Sprite& sprite, float x, float y, float z = 0);
+
#if 0
/** Fills the screen with a given color, this is different from
@@ -73,29 +77,27 @@
queue */
void fill_screen(const CL_Color& color);
- void draw(const CL_Surface& surface, const Vector& pos);
- void draw(const CL_Sprite& sprite, float x, float y, float z = 0);
void draw(const std::string& text, float x, float y, float z = 0);
- void draw(const CL_Sprite&, const Vector& pos);
+ void draw(const CL_Surface& surface, const Vector& pos);
+#endif
void draw_line (float x1, float y1, float x2, float y2,
- const CL_Color& color, float z = 0);
+ const Color& color, float z = 0);
void draw_fillrect (float x1, float y1, float x2, float y2,
- const CL_Color& color, float z = 0);
+ const Color& color, float z = 0);
void draw_rect (float x1, float y1, float x2, float y2,
- const CL_Color& color, float z = 0);
+ const Color& color, float z = 0);
void draw_pixel (float x_pos, float y_pos,
- const CL_Color& color);
+ const Color& color);
void draw_circle (float x_pos, float y_pos, float radius,
- const CL_Color& color);
+ const Color& color);
/** Draws an arc, starting from angle_start to angle_end in
counterclockwise direction. Angles are taken in radian */
void draw_arc (float x_pos, float y_pos, float radius, float angle_start,
float angle_end,
- const CL_Color& color);
+ const Color& color);
/*} */
-#endif
/** Translate the drawing context */
void translate(float x, float y);
@@ -117,16 +119,16 @@
float get_height() const;
/** Print a text left aligned */
- void print_left (const CL_Font& font, float x_pos, float y_pos, const
std::string& str, float z = 0.0f);
+ void print_left (const Font& font, float x_pos, float y_pos, const
std::string& str, float z = 0.0f);
/** Print a text centred to the given position */
- void print_center (const CL_Font& font, float x_pos, float y_pos, const
std::string& str, float z = 0.0f);
+ void print_center (const Font& font, float x_pos, float y_pos, const
std::string& str, float z = 0.0f);
/** Print a text right aligned */
- void print_right (const CL_Font& font, float x_pos, float y_pos, const
std::string& str, float z = 0.0f);
+ void print_right (const Font& font, float x_pos, float y_pos, const
std::string& str, float z = 0.0f);
- Vector screen_to_world (Vector pos);
- Vector world_to_screen (Vector pos);
+ Vector3f screen_to_world (Vector3f pos);
+ Vector3f world_to_screen (Vector3f pos);
private:
DrawingContext (const DrawingContext&);
Modified: branches/pingus_sdl/src/display/drawing_request.hxx
===================================================================
--- branches/pingus_sdl/src/display/drawing_request.hxx 2007-01-13 11:37:45 UTC
(rev 2637)
+++ branches/pingus_sdl/src/display/drawing_request.hxx 2007-01-13 20:43:01 UTC
(rev 2638)
@@ -21,17 +21,17 @@
#define HEADER_DRAWING_REQUEST_HXX
#include "SDL.h"
-#include "math/vector3.hpp"
+#include "math/vector3f.hpp"
/**
*/
class DrawingRequest
{
protected:
- Vector3 pos;
+ Vector3f pos;
public:
- DrawingRequest(const Vector3& pos_) : pos(pos_) {}
+ DrawingRequest(const Vector3f& pos_) : pos(pos_) {}
virtual ~DrawingRequest() {};
virtual void draw(SDL_Surface* gc) = 0;
Modified: branches/pingus_sdl/src/exit_menu.cxx
===================================================================
--- branches/pingus_sdl/src/exit_menu.cxx 2007-01-13 11:37:45 UTC (rev
2637)
+++ branches/pingus_sdl/src/exit_menu.cxx 2007-01-13 20:43:01 UTC (rev
2638)
@@ -17,7 +17,6 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#include <ClanLib/Display/display.h>
#include "gettext.h"
#include "pingus_menu_manager.hxx"
#include "resource.hxx"
@@ -33,8 +32,8 @@
PingusMenuManager* manager;
public:
ExitMenuYesButton (PingusMenuManager* m)
- : GUI::SurfaceButton(CL_Display::get_width()/2 - 170,
- CL_Display::get_height()/2 + 15,
+ : GUI::SurfaceButton(Display::get_width()/2 - 170,
+ Display::get_height()/2 + 15,
ResDescriptor("core/menu/exit_button_normal"),
ResDescriptor("core/menu/exit_button_pressed"),
ResDescriptor("core/menu/exit_button_hover")),
@@ -44,8 +43,8 @@
void draw (DrawingContext& gc) {
SurfaceButton::draw(gc);
- gc.print_right(Fonts::chalk_large, (float)CL_Display::get_width()/2 - 80,
- (float)CL_Display::get_height()/2 + 25, _("Yes"));
+ gc.print_right(Fonts::chalk_large, (float)Display::get_width()/2 - 80,
+ (float)Display::get_height()/2 + 25, _("Yes"));
}
void on_click()
@@ -67,7 +66,7 @@
PingusMenuManager* manager;
public:
ExitMenuNoButton (PingusMenuManager* m)
- : GUI::SurfaceButton(CL_Display::get_width()/2, CL_Display::get_height()/2
+ 15,
+ : GUI::SurfaceButton(Display::get_width()/2, Display::get_height()/2 + 15,
ResDescriptor("core/menu/exit_button_normal"),
ResDescriptor("core/menu/exit_button_pressed"),
ResDescriptor("core/menu/exit_button_hover")),
@@ -77,8 +76,8 @@
void draw (DrawingContext& gc) {
SurfaceButton::draw(gc);
- gc.print_right(Fonts::chalk_large, (float)CL_Display::get_width()/2 + 80,
- (float)CL_Display::get_height()/2 + 25, _("No"));
+ gc.print_right(Fonts::chalk_large, (float)Display::get_width()/2 + 80,
+ (float)Display::get_height()/2 + 25, _("No"));
}
void on_click() {
@@ -107,10 +106,10 @@
bool
ExitMenu::draw (DrawingContext& gc)
{
- //gc.draw_fillrect (0, 0, CL_Display::get_width (), CL_Display::get_height
(),
+ //gc.draw_fillrect (0, 0, Display::get_width (), Display::get_height (),
//0, 0, 0, 0.5);
- gc.draw(sur, Vector(gc.get_width ()/2 - sur.get_width ()/2,
- gc.get_height ()/2 - sur.get_height ()/2));
+ gc.draw(sur, Vector3f(gc.get_width ()/2 - sur.get_width ()/2,
+ gc.get_height ()/2 - sur.get_height ()/2));
gc.print_center(Fonts::chalk_large, gc.get_width()/2, gc.get_height()/2 -
70, _("Exit Pingus?"));
PingusSubMenu::draw(gc);
return true;
Modified: branches/pingus_sdl/src/exit_menu.hxx
===================================================================
--- branches/pingus_sdl/src/exit_menu.hxx 2007-01-13 11:37:45 UTC (rev
2637)
+++ branches/pingus_sdl/src/exit_menu.hxx 2007-01-13 20:43:01 UTC (rev
2638)
@@ -20,7 +20,6 @@
#ifndef HEADER_PINGUS_EXIT_MENU_HXX
#define HEADER_PINGUS_EXIT_MENU_HXX
-#include <ClanLib/Display/sprite.h>
#include "pingus_sub_menu.hxx"
namespace Pingus {
@@ -30,7 +29,7 @@
class ExitMenu : public PingusSubMenu
{
private:
- CL_Sprite sur;
+ Sprite sur;
public:
ExitMenu (PingusMenuManager* manager);
Modified: branches/pingus_sdl/src/file_dialog.hxx
===================================================================
--- branches/pingus_sdl/src/file_dialog.hxx 2007-01-13 11:37:45 UTC (rev
2637)
+++ branches/pingus_sdl/src/file_dialog.hxx 2007-01-13 20:43:01 UTC (rev
2638)
@@ -20,116 +20,115 @@
#ifndef HEADER_PINGUS_FILE_DIALOG_HXX
#define HEADER_PINGUS_FILE_DIALOG_HXX
-#include <ClanLib/Display/sprite.h>
#include <vector>
#include <string>
#include "pingus_sub_menu.hxx"
namespace Pingus {
- class Vector;
- class FileDialogItem;
- class FileDialogOkButton;
- class FileDialogScrollButton;
- class FileDialogListener;
+class Vector;
+class FileDialogItem;
+class FileDialogOkButton;
+class FileDialogScrollButton;
+class FileDialogListener;
- namespace GUI {
- class InputBox;
- }
+namespace GUI {
+class InputBox;
+}
- struct FileItem {
- std::string name;
- std::string short_name;
- std::string friendly_name;
- bool is_accessible;
- bool is_finished;
- bool is_directory;
- };
+struct FileItem {
+ std::string name;
+ std::string short_name;
+ std::string friendly_name;
+ bool is_accessible;
+ bool is_finished;
+ bool is_directory;
+};
- /** Sorting function for FileItem's */
- inline bool FileItemCompare (const FileItem& a, const FileItem& b)
- {
- if (a.is_directory == b.is_directory)
- return (a.name < b.name);
- else
- return (a.is_directory);
- }
+/** Sorting function for FileItem's */
+inline bool FileItemCompare (const FileItem& a, const FileItem& b)
+{
+ if (a.is_directory == b.is_directory)
+ return (a.name < b.name);
+ else
+ return (a.is_directory);
+}
class FileDialog : public PingusSubMenu
{
private:
- CL_Sprite sprite;
+ Sprite sprite;
- /** The OK button - need to be able to hide and show it */
- FileDialogOkButton* ok_button;
+ /** The OK button - need to be able to hide and show it */
+ FileDialogOkButton* ok_button;
- /** Scroll buttons */
- FileDialogScrollButton* up_button;
- FileDialogScrollButton* down_button;
+ /** Scroll buttons */
+ FileDialogScrollButton* up_button;
+ FileDialogScrollButton* down_button;
- /** The owner of this file dialog */
- FileDialogListener* listener;
+ /** The owner of this file dialog */
+ FileDialogListener* listener;
- /** Box to take the keyboard input */
- GUI::InputBox* inputbox;
+ /** Box to take the keyboard input */
+ GUI::InputBox* inputbox;
- /** Should this dialog box be used for loading? True for load, false
for saving */
- bool for_loading;
+ /** Should this dialog box be used for loading? True for load, false for
saving */
+ bool for_loading;
- /** Mask for which files to display (*.pingus, *.xml, etc.) */
- std::string file_mask;
+ /** Mask for which files to display (*.pingus, *.xml, etc.) */
+ std::string file_mask;
- /** Current path that is being displayed */
- std::string current_path;
+ /** Current path that is being displayed */
+ std::string current_path;
- /** Offset in the file_list that is the index of the first file/folder
shown */
- unsigned current_offset;
+ /** Offset in the file_list that is the index of the first file/folder shown
*/
+ unsigned current_offset;
- /** Current file that is selected */
- FileItem current_file;
+ /** Current file that is selected */
+ FileItem current_file;
- /** List of directories & files in the current folder */
- std::vector<FileItem> file_list;
+ /** List of directories & files in the current folder */
+ std::vector<FileItem> file_list;
- /** List of files in the directory */
- std::vector<FileDialogItem*> file_dialog_items;
+ /** List of files in the directory */
+ std::vector<FileDialogItem*> file_dialog_items;
- /** Scroll the displayed file list */
- void offset_changed();
+ /** Scroll the displayed file list */
+ void offset_changed();
public:
- FileDialog (FileDialogListener* listener_,
- const std::string filemask_,
- const std::string searchpath_,
- const bool for_load = true);
+ FileDialog (FileDialogListener* listener_,
+ const std::string filemask_,
+ const std::string searchpath_,
+ const bool for_load = true);
~FileDialog ();
bool draw (DrawingContext& gc);
- void update(const GameDelta &delta);
+ void update(const GameDelta &delta);
- void preload();
+ void preload();
- /** Refresh the file list */
- void refresh();
+ /** Refresh the file list */
+ void refresh();
- /** Return the current path in the dialog */
- std::string get_path() const { return current_path; }
+ /** Return the current path in the dialog */
+ std::string get_path() const { return current_path; }
- /** Return the file mask */
- std::string get_file_mask() const { return file_mask; }
+ /** Return the file mask */
+ std::string get_file_mask() const { return file_mask; }
- /** Sets the currently selected file name */
- void set_selected_file(FileItem f);
+ /** Sets the currently selected file name */
+ void set_selected_file(FileItem f);
- /** The Ok button has been pressed - either Save or Load this file */
- void ok_pressed();
+ /** The Ok button has been pressed - either Save or Load this file */
+ void ok_pressed();
- /** The Cancel button has been pressed - close the box */
- void cancel_pressed();
+ /** The Cancel button has been pressed - close the box */
+ void cancel_pressed();
- /** Need to scroll the list of files if possible */
- void scroll(int direction);
+ /** Need to scroll the list of files if possible */
+ void scroll(int direction);
private:
FileDialog (const FileDialog&);
Added: branches/pingus_sdl/src/font.cpp
===================================================================
--- branches/pingus_sdl/src/font.cpp 2007-01-13 11:37:45 UTC (rev 2637)
+++ branches/pingus_sdl/src/font.cpp 2007-01-13 20:43:01 UTC (rev 2638)
@@ -0,0 +1,30 @@
+/* $Id$
+** __ __ __ ___ __ __ __ __
+** / \ / \__| ____ __| _/_______/ |_|__| | | | ____
+** \ \/\/ / |/ \ / __ |/ ___/\ __\ | | | | _/ __ \
+** \ /| | | \/ /_/ |\___ \ | | | | |_| |_\ ___/
+** \__/\ / |__|___| /\____ /____ > |__| |__|____/____/\___ >
+** \/ \/ \/ \/ \/
+** Copyright (C) 2005 Ingo Ruhnke <address@hidden>
+**
+** This program is free software; you can redistribute it and/or
+** modify it under the terms of the GNU General Public License
+** as published by the Free Software Foundation; either version 2
+** of the License, or (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+** 02111-1307, USA.
+*/
+
+#include "font.hpp"
+
+
+
+/* EOF */
Added: branches/pingus_sdl/src/font.hpp
===================================================================
--- branches/pingus_sdl/src/font.hpp 2007-01-13 11:37:45 UTC (rev 2637)
+++ branches/pingus_sdl/src/font.hpp 2007-01-13 20:43:01 UTC (rev 2638)
@@ -0,0 +1,46 @@
+/* $Id$
+** __ __ __ ___ __ __ __ __
+** / \ / \__| ____ __| _/_______/ |_|__| | | | ____
+** \ \/\/ / |/ \ / __ |/ ___/\ __\ | | | | _/ __ \
+** \ /| | | \/ /_/ |\___ \ | | | | |_| |_\ ___/
+** \__/\ / |__|___| /\____ /____ > |__| |__|____/____/\___ >
+** \/ \/ \/ \/ \/
+** Copyright (C) 2005 Ingo Ruhnke <address@hidden>
+**
+** This program is free software; you can redistribute it and/or
+** modify it under the terms of the GNU General Public License
+** as published by the Free Software Foundation; either version 2
+** of the License, or (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+** 02111-1307, USA.
+*/
+
+#ifndef HEADER_FONT_HPP
+#define HEADER_FONT_HPP
+
+#include <string>
+#include "SDL.h"
+#include "origin.hpp"
+
+/** */
+class Font
+{
+private:
+public:
+ Font() {}
+ void draw(int, int, const std::string& text, SDL_Surface* target) {}
+ void set_alignment(Origin origin) {}
+ int get_height() { return 0; }
+};
+
+#endif
+
+/* EOF */
Modified: branches/pingus_sdl/src/fonts.cxx
===================================================================
--- branches/pingus_sdl/src/fonts.cxx 2007-01-13 11:37:45 UTC (rev 2637)
+++ branches/pingus_sdl/src/fonts.cxx 2007-01-13 20:43:01 UTC (rev 2638)
@@ -25,24 +25,25 @@
std::string encoding("ISO-8859-1");
-CL_Font chalk_large;
-CL_Font chalk_normal;
-CL_Font chalk_small;
+Font chalk_large;
+Font chalk_normal;
+Font chalk_small;
-CL_Font pingus_small;
-CL_Font pingus_small_fix_num;
-CL_Font pingus_large;
+Font pingus_small;
+Font pingus_small_fix_num;
+Font pingus_large;
-CL_Font smallfont;
-CL_Font smallfont_h;
+Font smallfont;
+Font smallfont_h;
-CL_Font courier_small;
-CL_Font xterm;
-CL_Font lcd;
+Font courier_small;
+Font xterm;
+Font lcd;
void
init ()
{
+#if 0
chalk_large = Resource::load_font("fonts/chalk_large" + std::string(".") +
encoding);
chalk_normal = Resource::load_font("fonts/chalk_normal" + std::string(".") +
encoding);
chalk_small = Resource::load_font("fonts/chalk_small" + std::string(".") +
encoding);
@@ -57,21 +58,22 @@
smallfont_h = Resource::load_font("fonts/courier_small" + std::string(".")
+ encoding); // PingusResource::load_font("Fonts/smallfont_h","fonts");
lcd = Resource::load_font("fonts/courier_small" + std::string(".")
+ encoding); // PingusResource::load_font("Fonts/numbers", "fonts");
+#endif
}
void deinit ()
{
- chalk_large = CL_Font();
- chalk_normal = CL_Font();
- chalk_small = CL_Font();
- pingus_small = CL_Font();
- pingus_small_fix_num = CL_Font();
- pingus_large = CL_Font();
- courier_small = CL_Font();
- xterm = CL_Font();
- smallfont = CL_Font();
- smallfont_h = CL_Font();
- lcd = CL_Font();
+ chalk_large = Font();
+ chalk_normal = Font();
+ chalk_small = Font();
+ pingus_small = Font();
+ pingus_small_fix_num = Font();
+ pingus_large = Font();
+ courier_small = Font();
+ xterm = Font();
+ smallfont = Font();
+ smallfont_h = Font();
+ lcd = Font();
}
} // namespace Fonts
Modified: branches/pingus_sdl/src/fonts.hxx
===================================================================
--- branches/pingus_sdl/src/fonts.hxx 2007-01-13 11:37:45 UTC (rev 2637)
+++ branches/pingus_sdl/src/fonts.hxx 2007-01-13 20:43:01 UTC (rev 2638)
@@ -21,26 +21,27 @@
#define HEADER_PINGUS_FONTS_HXX
#include "display/drawing_context.hxx"
+#include "font.hpp"
namespace Pingus {
namespace Fonts {
extern std::string encoding;
-// extern CL_Font chalk_large;
-// extern CL_Font chalk_normal;
-// extern CL_Font chalk_small;
+extern Font chalk_large;
+extern Font chalk_normal;
+extern Font chalk_small;
-// extern CL_Font courier_small;
+extern Font courier_small;
-// extern CL_Font pingus_small;
-// extern CL_Font pingus_small_fix_num;
-// extern CL_Font pingus_large;
+extern Font pingus_small;
+extern Font pingus_small_fix_num;
+extern Font pingus_large;
-// extern CL_Font smallfont;
-// extern CL_Font smallfont_h;
-// extern CL_Font xterm;
-// extern CL_Font lcd;
+extern Font smallfont;
+extern Font smallfont_h;
+extern Font xterm;
+extern Font lcd;
/** Load all fonts */
void init ();
Modified: branches/pingus_sdl/src/graphic_context_state.hxx
===================================================================
--- branches/pingus_sdl/src/graphic_context_state.hxx 2007-01-13 11:37:45 UTC
(rev 2637)
+++ branches/pingus_sdl/src/graphic_context_state.hxx 2007-01-13 20:43:01 UTC
(rev 2638)
@@ -20,14 +20,9 @@
#ifndef HEADER_GRAPHIC_CONTEXT_STATE_HXX
#define HEADER_GRAPHIC_CONTEXT_STATE_HXX
-#include <ClanLib/Core/Math/point.h>
-#include <ClanLib/Core/Math/rect.h>
-#include <ClanLib/Core/System/sharedptr.h>
#include "display/drawing_context.hxx"
#include "display/scene_context.hxx"
-class CL_GraphicContext;
-
class GraphicContextStateImpl;
/** Helper class for capturing the state of a GraphicContext, with
@@ -47,8 +42,10 @@
void set_size(int w, int h);
+#if 0
void push(CL_GraphicContext* gc = 0);
void pop (CL_GraphicContext* gc = 0);
+#endif
void push(Pingus::DrawingContext& gc);
void pop (Pingus::DrawingContext& gc);
@@ -70,8 +67,8 @@
float get_rotation();
/** Move the center of the visible area to pos */
- void set_pos(const CL_Pointf& pos);
- CL_Pointf get_pos() const;
+ void set_pos(const Vector& pos);
+ Vector get_pos() const;
/** Set zoom to z, while ensuring that the screen position \a pos
(normaly the position of the mouse pointer) stays in the same
@@ -82,7 +79,7 @@
void zoom_to (const CL_Rectf& rect);
- CL_Pointf screen2world(const CL_Point& pos);
+ Vector screen2world(const CL_Point& pos);
private:
CL_SharedPtr<GraphicContextStateImpl> impl;
Modified: branches/pingus_sdl/src/gui/display.cxx
===================================================================
--- branches/pingus_sdl/src/gui/display.cxx 2007-01-13 11:37:45 UTC (rev
2637)
+++ branches/pingus_sdl/src/gui/display.cxx 2007-01-13 20:43:01 UTC (rev
2638)
@@ -92,6 +92,18 @@
}
}
+int
+Display::get_width()
+{
+ return screen->w;
+}
+
+int
+Display::get_height()
+{
+ return screen->h;
+}
+
} // namespace Pingus
/* EOF */
Modified: branches/pingus_sdl/src/gui/display.hxx
===================================================================
--- branches/pingus_sdl/src/gui/display.hxx 2007-01-13 11:37:45 UTC (rev
2637)
+++ branches/pingus_sdl/src/gui/display.hxx 2007-01-13 20:43:01 UTC (rev
2638)
@@ -62,6 +62,9 @@
static void add_flip_screen_hook(DisplayHook*);
static void remove_flip_screen_hook(DisplayHook*);
+ static int get_width();
+ static int get_height();
+
static void set_video_mode(int width, int height);
static SDL_Surface* get_screen() { return screen; }
private:
Modified: branches/pingus_sdl/src/gui/screen_manager.cxx
===================================================================
--- branches/pingus_sdl/src/gui/screen_manager.cxx 2007-01-13 11:37:45 UTC
(rev 2637)
+++ branches/pingus_sdl/src/gui/screen_manager.cxx 2007-01-13 20:43:01 UTC
(rev 2638)
@@ -79,23 +79,8 @@
continue;
}
- { // Let SDL fetch events
- SDL_Event event;
- while(SDL_PollEvent(&event))
- {
- switch(event.type)
- {
- case SDL_QUIT:
- pop_screen();
- break;
+ process_events();
- default:
- // FIXME: feed other events to the input manager
- break;
- }
- }
- }
-
// Get new events from ClanLib
////input_controller->update(time_delta);
@@ -168,6 +153,26 @@
#endif
}
+void
+ScreenManager::process_events()
+{
+ // Let SDL fetch events
+ SDL_Event event;
+ while(SDL_PollEvent(&event))
+ {
+ switch(event.type)
+ {
+ case SDL_QUIT:
+ pop_screen();
+ break;
+
+ default:
+ // FIXME: feed other events to the input manager
+ break;
+ }
+ }
+}
+
ScreenPtr&
ScreenManager::get_current_screen()
{
Modified: branches/pingus_sdl/src/gui/screen_manager.hxx
===================================================================
--- branches/pingus_sdl/src/gui/screen_manager.hxx 2007-01-13 11:37:45 UTC
(rev 2637)
+++ branches/pingus_sdl/src/gui/screen_manager.hxx 2007-01-13 20:43:01 UTC
(rev 2638)
@@ -81,6 +81,8 @@
/** FadeOver test*/
void fade_over (ScreenPtr& old_screen, ScreenPtr& new_screen);
+ void process_events();
+
/** @return a pointer to the current Screen */
ScreenPtr& get_current_screen();
Modified: branches/pingus_sdl/src/gui/surface_button.cxx
===================================================================
--- branches/pingus_sdl/src/gui/surface_button.cxx 2007-01-13 11:37:45 UTC
(rev 2637)
+++ branches/pingus_sdl/src/gui/surface_button.cxx 2007-01-13 20:43:01 UTC
(rev 2638)
@@ -18,7 +18,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../resource.hxx"
-#include "../vector.hxx"
+#include "../math/vector3f.hpp"
#include "../display/drawing_context.hxx"
#include "surface_button.hxx"
@@ -45,11 +45,11 @@
SurfaceButton::draw (DrawingContext& gc)
{
if (pressed && mouse_over)
- gc.draw(button_pressed_surface, Vector((float)x_pos, (float)y_pos));
+ gc.draw(button_pressed_surface, Vector3f((float)x_pos, (float)y_pos));
else if (!pressed && mouse_over)
- gc.draw(button_mouse_over_surface, Vector((float)x_pos, (float)y_pos));
+ gc.draw(button_mouse_over_surface, Vector3f((float)x_pos, (float)y_pos));
else
- gc.draw(button_surface, Vector((float)x_pos, (float)y_pos));
+ gc.draw(button_surface, Vector3f((float)x_pos, (float)y_pos));
}
bool
Modified: branches/pingus_sdl/src/gui/surface_button.hxx
===================================================================
--- branches/pingus_sdl/src/gui/surface_button.hxx 2007-01-13 11:37:45 UTC
(rev 2637)
+++ branches/pingus_sdl/src/gui/surface_button.hxx 2007-01-13 20:43:01 UTC
(rev 2638)
@@ -20,7 +20,6 @@
#ifndef HEADER_PINGUS_GUI_SURFACE_BUTTON_HXX
#define HEADER_PINGUS_GUI_SURFACE_BUTTON_HXX
-#include <ClanLib/display.h>
#include "component.hxx"
namespace Pingus {
@@ -36,9 +35,10 @@
protected:
int x_pos;
int y_pos;
- CL_Sprite button_surface;
- CL_Sprite button_pressed_surface;
- CL_Sprite button_mouse_over_surface;
+
+ Sprite button_surface;
+ Sprite button_pressed_surface;
+ Sprite button_mouse_over_surface;
bool pressed;
bool mouse_over;
Modified: branches/pingus_sdl/src/layer_manager.cxx
===================================================================
--- branches/pingus_sdl/src/layer_manager.cxx 2007-01-13 11:37:45 UTC (rev
2637)
+++ branches/pingus_sdl/src/layer_manager.cxx 2007-01-13 20:43:01 UTC (rev
2638)
@@ -18,8 +18,6 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <iostream>
-#include <ClanLib/Display/sprite.h>
-#include <ClanLib/Display/sprite_description.h>
#include "layer_manager.hxx"
namespace Pingus {
@@ -33,11 +31,9 @@
}
void
-LayerManager::add_layer (const CL_PixelBuffer& sur, float x_o, float y_o,
float x_u, float y_u)
+LayerManager::add_layer(Sprite sprite, float x_o, float y_o, float x_u, float
y_u)
{
- CL_SpriteDescription desc;
- desc.add_frame(sur);
- layers.push_back (Layer(CL_Sprite(desc), x_o, y_o, x_u, y_u));
+ layers.push_back(Layer(sprite, x_o, y_o, x_u, y_u));
}
void
Modified: branches/pingus_sdl/src/layer_manager.hxx
===================================================================
--- branches/pingus_sdl/src/layer_manager.hxx 2007-01-13 11:37:45 UTC (rev
2637)
+++ branches/pingus_sdl/src/layer_manager.hxx 2007-01-13 20:43:01 UTC (rev
2638)
@@ -22,8 +22,8 @@
#include "pingus.hxx"
#include <cmath>
-#include <ClanLib/Display/sprite.h>
-#include <ClanLib/Display/display.h>
+#include "sprite.hpp"
+#include "gui/display.hxx"
#include "display/drawing_context.hxx"
namespace Pingus {
@@ -34,7 +34,7 @@
class Layer
{
private:
- CL_Sprite sur;
+ Sprite sur;
float x_pos;
float y_pos;
@@ -52,7 +52,7 @@
x_offset(0), y_offset(0)
{}
- Layer (const CL_Sprite& arg_sur, float x_o, float y_o, float x_u, float
y_u)
+ Layer (const Sprite& arg_sur, float x_o, float y_o, float x_u, float y_u)
: sur(arg_sur),
x_pos(0), y_pos(0),
x_update(x_u), y_update(y_u),
@@ -61,14 +61,14 @@
void draw (DrawingContext& gc)
{
- gc.draw(sur, Vector(x_pos + x_offset, y_pos + y_offset));
- gc.draw(sur, Vector(x_pos + x_offset - gc.get_width(), y_pos +
y_offset));
+ gc.draw(sur, Vector3f(x_pos + x_offset, y_pos + y_offset));
+ gc.draw(sur, Vector3f(x_pos + x_offset - gc.get_width(), y_pos +
y_offset));
}
void update (float delta)
{
- x_pos = fmod((x_pos + x_update * delta),(float)CL_Display::get_width());
- y_pos = fmod((y_pos + y_update * delta),(float)CL_Display::get_height());
+ x_pos = fmod((x_pos + x_update * delta),(float)Display::get_width());
+ y_pos = fmod((y_pos + y_update * delta),(float)Display::get_height());
}
};
@@ -78,7 +78,7 @@
LayerManager ();
~LayerManager();
- void add_layer (const CL_PixelBuffer& sur, float x_o, float y_o, float x_u,
float y_u);
+ void add_layer (Sprite sur, float x_o, float y_o, float x_u, float y_u);
void draw (DrawingContext& gc);
void update (float delta);
Added: branches/pingus_sdl/src/math/color.hpp
===================================================================
--- branches/pingus_sdl/src/math/color.hpp 2007-01-13 11:37:45 UTC (rev
2637)
+++ branches/pingus_sdl/src/math/color.hpp 2007-01-13 20:43:01 UTC (rev
2638)
@@ -0,0 +1,47 @@
+/* $Id$
+** __ __ __ ___ __ __ __ __
+** / \ / \__| ____ __| _/_______/ |_|__| | | | ____
+** \ \/\/ / |/ \ / __ |/ ___/\ __\ | | | | _/ __ \
+** \ /| | | \/ /_/ |\___ \ | | | | |_| |_\ ___/
+** \__/\ / |__|___| /\____ /____ > |__| |__|____/____/\___ >
+** \/ \/ \/ \/ \/
+** Copyright (C) 2005 Ingo Ruhnke <address@hidden>
+**
+** This program is free software; you can redistribute it and/or
+** modify it under the terms of the GNU General Public License
+** as published by the Free Software Foundation; either version 2
+** of the License, or (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+** 02111-1307, USA.
+*/
+
+#ifndef HEADER_MATH_COLOR_HPP
+#define HEADER_MATH_COLOR_HPP
+
+#include "SDL.h"
+
+/** */
+class Color
+{
+public:
+ uint8_t r;
+ uint8_t g;
+ uint8_t b;
+ uint8_t a;
+
+ Color(uint8_t r_, uint8_t g_, uint8_t b_, uint8_t a_)
+ : r(r_), g(g_), b(b_), a(a_)
+ {}
+};
+
+#endif
+
+/* EOF */
Added: branches/pingus_sdl/src/math/matrix.cpp
===================================================================
--- branches/pingus_sdl/src/math/matrix.cpp 2007-01-13 11:37:45 UTC (rev
2637)
+++ branches/pingus_sdl/src/math/matrix.cpp 2007-01-13 20:43:01 UTC (rev
2638)
@@ -0,0 +1,188 @@
+/*
+** ClanLib SDK
+** Copyright (c) 1997-2005 The ClanLib Team
+**
+** This software is provided 'as-is', without any express or implied
+** warranty. In no event will the authors be held liable for any damages
+** arising from the use of this software.
+**
+** Permission is granted to anyone to use this software for any purpose,
+** including commercial applications, and to alter it and redistribute it
+** freely, subject to the following restrictions:
+**
+** 1. The origin of this software must not be misrepresented; you must not
+** claim that you wrote the original software. If you use this software
+** in a product, an acknowledgment in the product documentation would be
+** appreciated but is not required.
+** 2. Altered source versions must be plainly marked as such, and must not be
+** misrepresented as being the original software.
+** 3. This notice may not be removed or altered from any source distribution.
+**
+** Note: Some of the libraries ClanLib may link to may have additional
+** requirements or restrictions.
+**
+** File Author(s):
+**
+** Magnus Norddahl
+** (if your name is missing here, please add it)
+*/
+
+#include <string.h>
+#include <iostream>
+#include <math.h>
+#include "matrix.hpp"
+
+/////////////////////////////////////////////////////////////////////////////
+// Matrix construction:
+
+Matrix::Matrix()
+{
+ memset(matrix, 0, sizeof(float[16]));
+}
+
+Matrix
+Matrix::identity()
+{
+ Matrix matrix;
+
+ matrix.matrix[0] = 1.0;
+ matrix.matrix[5] = 1.0;
+ matrix.matrix[10] = 1.0;
+ matrix.matrix[15] = 1.0;
+
+ return matrix;
+}
+
+Matrix::Matrix(const Matrix ©)
+{
+ for (int i=0; i<16; i++)
+ matrix[i] = copy.matrix[i];
+}
+
+Matrix::Matrix(const float *init_matrix)
+{
+ for (int i=0; i<16; i++)
+ matrix[i] = init_matrix[i];
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Matrix attributes:
+
+float Matrix::get_origin_x() const
+{
+ return matrix[12];
+}
+
+float Matrix::get_origin_y() const
+{
+ return matrix[13];
+}
+
+float Matrix::get_origin_z() const
+{
+ return matrix[14];
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Matrix operations:
+
+bool Matrix::operator==(const Matrix &other) const
+{
+ for (int i=0; i<16; i++)
+ if (matrix[i] != other.matrix[i]) return false;
+ return true;
+}
+
+bool Matrix::operator!=(const Matrix &other) const
+{
+ for (int i=0; i<16; i++)
+ if (matrix[i] != other.matrix[i]) return true;
+ return false;
+}
+
+Matrix &Matrix::operator =(const Matrix ©)
+{
+ for (int i=0; i<16; i++)
+ matrix[i] = copy.matrix[i];
+ return *this;
+}
+
+Matrix Matrix::multiply(const Matrix &mult) const
+{
+ Matrix result;
+ for (int x=0; x<4; x++)
+ {
+ for (int y=0; y<4; y++)
+ {
+ result.matrix[x+y*4] =
+ matrix[x]*mult.matrix[y*4] +
+ matrix[x+4]*mult.matrix[y*4+1] +
+ matrix[x+8]*mult.matrix[y*4+2] +
+ matrix[x+12]*mult.matrix[y*4+3];
+ }
+ }
+ return result;
+}
+
+Matrix
+Matrix::scale(float x, float y, float z)
+{
+ Matrix matrix = Matrix::identity();
+ matrix[0] = x;
+ matrix[5] = y;
+ matrix[10] = z;
+ return multiply(matrix);
+}
+
+Matrix
+Matrix::translate(float x, float y, float z)
+{
+ Matrix matrix = Matrix::identity();
+ matrix[12] = x;
+ matrix[13] = y;
+ matrix[14] = z;
+ return multiply(matrix);
+}
+
+Matrix
+Matrix::rotate(float angle, float x, float y, float z)
+{
+ double len2 = x*x+y*y+z*z;
+ if (len2 != 1.0)
+ {
+ double len = sqrt(len2);
+ x /= len;
+ y /= len;
+ z /= len;
+ }
+
+ double c = cos(angle*3.14159265/180);
+ double s = sin(angle*3.14159265/180);
+
+ Matrix matrix = Matrix::identity();
+ matrix[0] = x*x*(1-c)+c;
+ matrix[1] = y*x*(1-c)+z*s;
+ matrix[2] = x*z*(1-c)-y*s;
+
+ matrix[4] = x*y*(1-c)-z*s;
+ matrix[5] = y*y*(1-c)+c;
+ matrix[6] = y*z*(1-c)+x*s;
+
+ matrix[8] = x*z*(1-c)+y*s;
+ matrix[9] = y*z*(1-c)-x*s;
+ matrix[10] = z*z*(1-c)+c;
+
+ return multiply(matrix);
+}
+
+std::ostream& operator<<(std::ostream& s, const Matrix& m)
+{
+ s << "[" << m[ 0] << ", " << m[ 4] << ", " << m[ 8] << ", " << m[12] << "\n";
+ s << " " << m[ 1] << ", " << m[ 5] << ", " << m[ 9] << ", " << m[13] << "\n";
+ s << " " << m[ 2] << ", " << m[ 6] << ", " << m[10] << ", " << m[14] << "\n";
+ s << " " << m[ 3] << ", " << m[ 7] << ", " << m[11] << ", " << m[15] <<
"]\n";
+
+ return s;
+}
+
+/* EOF */
Added: branches/pingus_sdl/src/math/matrix.hpp
===================================================================
--- branches/pingus_sdl/src/math/matrix.hpp 2007-01-13 11:37:45 UTC (rev
2637)
+++ branches/pingus_sdl/src/math/matrix.hpp 2007-01-13 20:43:01 UTC (rev
2638)
@@ -0,0 +1,102 @@
+/*
+** ClanLib SDK
+** Copyright (c) 1997-2005 The ClanLib Team
+**
+** This software is provided 'as-is', without any express or implied
+** warranty. In no event will the authors be held liable for any damages
+** arising from the use of this software.
+**
+** Permission is granted to anyone to use this software for any purpose,
+** including commercial applications, and to alter it and redistribute it
+** freely, subject to the following restrictions:
+**
+** 1. The origin of this software must not be misrepresented; you must not
+** claim that you wrote the original software. If you use this software
+** in a product, an acknowledgment in the product documentation would be
+** appreciated but is not required.
+** 2. Altered source versions must be plainly marked as such, and must not be
+** misrepresented as being the original software.
+** 3. This notice may not be removed or altered from any source distribution.
+**
+** Note: Some of the libraries ClanLib may link to may have additional
+** requirements or restrictions.
+**
+** File Author(s):
+**
+** Magnus Norddahl
+** (if your name is missing here, please add it)
+*/
+
+#ifndef HEADER_MATH_MATRIX_HPP
+#define HEADER_MATH_MATRIX_HPP
+
+#include <iosfwd>
+
+//: 4x4 Matrix.
+class Matrix
+{
+//! Construction:
+public:
+ //: Constructs a 4x4 matrix.
+ Matrix();
+
+ Matrix(const Matrix ©);
+
+ Matrix(const float *matrix);
+
+ /** Returns identity matrix */
+ static Matrix identity();
+
+//! Attributes:
+public:
+ float matrix[16];
+
+ //: Operator that returns the matrix cell at the given index.
+ float &operator[](int i) { return matrix[i]; }
+
+ //: Operator that returns the matrix cell at the given index.
+ const float &operator[](int i) const { return matrix[i]; }
+
+ //: Operator that returns the matrix cell at the given index.
+ float &operator[](unsigned int i) { return matrix[i]; }
+
+ //: Operator that returns the matrix cell at the given index.
+ const float &operator[](unsigned int i) const { return matrix[i]; }
+
+ //: Returns the x coordinate for the point (0,0,0) multiplied with this
matrix.
+ float get_origin_x() const;
+
+ //: Returns the y coordinate for the point (0,0,0) multiplied with this
matrix.
+ float get_origin_y() const;
+
+ //: Returns the z coordinate for the point (0,0,0) multiplied with this
matrix.
+ float get_origin_z() const;
+
+//! Operations:
+public:
+ //: Copy assignment operator.
+ Matrix &operator =(const Matrix ©);
+
+ //: Equality operator.
+ bool operator==(const Matrix &other) const;
+
+ //: Not-equal operator.
+ bool operator!=(const Matrix &other) const;
+
+ //: Multiply two matrices.
+ Matrix multiply(const Matrix &matrix) const;
+
+ //: Multiply the matrix with the given scale/translate/rotate matrix
+ Matrix scale(float x, float y, float z);
+ Matrix translate(float x, float y, float z);
+ Matrix rotate(float angle, float x, float y, float z);
+
+//! Implementation:
+private:
+};
+
+std::ostream& operator<<(std::ostream& s, const Matrix& m);
+
+#endif
+
+/* EOF */
Added: branches/pingus_sdl/src/math/origin.cpp
===================================================================
--- branches/pingus_sdl/src/math/origin.cpp 2007-01-13 11:37:45 UTC (rev
2637)
+++ branches/pingus_sdl/src/math/origin.cpp 2007-01-13 20:43:01 UTC (rev
2638)
@@ -0,0 +1,102 @@
+/*
+** ClanLib SDK
+** Copyright (c) 1997-2005 The ClanLib Team
+**
+** This software is provided 'as-is', without any express or implied
+** warranty. In no event will the authors be held liable for any damages
+** arising from the use of this software.
+**
+** Permission is granted to anyone to use this software for any purpose,
+** including commercial applications, and to alter it and redistribute it
+** freely, subject to the following restrictions:
+**
+** 1. The origin of this software must not be misrepresented; you must not
+** claim that you wrote the original software. If you use this software
+** in a product, an acknowledgment in the product documentation would be
+** appreciated but is not required.
+** 2. Altered source versions must be plainly marked as such, and must not be
+** misrepresented as being the original software.
+** 3. This notice may not be removed or altered from any source distribution.
+**
+** Note: Some of the libraries ClanLib may link to may have additional
+** requirements or restrictions.
+**
+** File Author(s):
+**
+** Magnus Norddahl
+** (if your name is missing here, please add it)
+*/
+
+#include "origin.hpp"
+
+Point calc_origin(Origin origin, const Size &size)
+{
+ switch(origin)
+ {
+ case origin::top_left:
+ default:
+ return Point(0, 0);
+ break;
+ case origin::top_center:
+ return Point(size.width / 2, 0);
+ break;
+ case origin::top_right:
+ return Point(size.width, 0);
+ break;
+ case origin::center_left:
+ return Point(0, size.height / 2);
+ break;
+ case origin::center:
+ return Point(size.width / 2, size.height / 2);
+ break;
+ case origin::center_right:
+ return Point(size.width, size.height / 2);
+ break;
+ case origin::bottom_left:
+ return Point(0, size.height);
+ break;
+ case origin::bottom_center:
+ return Point(size.width / 2, size.height);
+ break;
+ case origin::bottom_right:
+ return Point(size.width, size.height);
+ break;
+ }
+}
+
+Vector calc_origin(Origin origin, const Sizef &size)
+{
+ switch(origin)
+ {
+ case origin::top_left:
+ default:
+ return Vector(0, 0);
+ break;
+ case origin::top_center:
+ return Vector(size.width / 2, 0);
+ break;
+ case origin::top_right:
+ return Vector(size.width, 0);
+ break;
+ case origin::center_left:
+ return Vector(0, size.height / 2);
+ break;
+ case origin::center:
+ return Vector(size.width / 2, size.height / 2);
+ break;
+ case origin::center_right:
+ return Vector(size.width, size.height / 2);
+ break;
+ case origin::bottom_left:
+ return Vector(0, size.height);
+ break;
+ case origin::bottom_center:
+ return Vector(size.width / 2, size.height);
+ break;
+ case origin::bottom_right:
+ return Vector(size.width, size.height);
+ break;
+ }
+}
+
+/* EOF */
Added: branches/pingus_sdl/src/math/origin.hpp
===================================================================
--- branches/pingus_sdl/src/math/origin.hpp 2007-01-13 11:37:45 UTC (rev
2637)
+++ branches/pingus_sdl/src/math/origin.hpp 2007-01-13 20:43:01 UTC (rev
2638)
@@ -0,0 +1,65 @@
+/*
+** ClanLib SDK
+** Copyright (c) 1997-2005 The ClanLib Team
+**
+** This software is provided 'as-is', without any express or implied
+** warranty. In no event will the authors be held liable for any damages
+** arising from the use of this software.
+**
+** Permission is granted to anyone to use this software for any purpose,
+** including commercial applications, and to alter it and redistribute it
+** freely, subject to the following restrictions:
+**
+** 1. The origin of this software must not be misrepresented; you must not
+** claim that you wrote the original software. If you use this software
+** in a product, an acknowledgment in the product documentation would be
+** appreciated but is not required.
+** 2. Altered source versions must be plainly marked as such, and must not be
+** misrepresented as being the original software.
+** 3. This notice may not be removed or altered from any source distribution.
+**
+** Note: Some of the libraries ClanLib may link to may have additional
+** requirements or restrictions.
+**
+** File Author(s):
+**
+** Magnus Norddahl
+** (if your name is missing here, please add it)
+*/
+
+//! clanCore="Math"
+//! header=core.h
+
+#ifndef HEADER_MATH_ORIGIN_HPP
+#define HEADER_MATH_ORIGIN_HPP
+
+namespace origin {
+
+//: Alignment origins.
+//- !group=Core/Math!
+//- !header=core.h!
+enum Origin
+{
+ top_left,
+ top_center,
+ top_right,
+ center_left,
+ center,
+ center_right,
+ bottom_left,
+ bottom_center,
+ bottom_right
+};
+
+}
+
+typedef origin::Origin Origin;
+
+
+//: Returns the anchor point for the origin within the dimensions of the size
structure.
+//- !group=Display/Display 2D!
+//- !header=display.h!
+Point calc_origin(Origin origin, const Size &size);
+Vector calc_origin(Origin origin, const Sizef &size);
+
+#endif
Added: branches/pingus_sdl/src/math/quaternion.cpp
===================================================================
--- branches/pingus_sdl/src/math/quaternion.cpp 2007-01-13 11:37:45 UTC (rev
2637)
+++ branches/pingus_sdl/src/math/quaternion.cpp 2007-01-13 20:43:01 UTC (rev
2638)
@@ -0,0 +1,106 @@
+// $Id$
+//
+// Windstille - A Jump'n Shoot Game
+// Copyright (C) 2005 Matthias Braun <address@hidden>
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#include <config.h>
+
+#include "quaternion.hpp"
+
+#include <math.h>
+
+float
+Quaternion::magnitude() const
+{
+ return sqrt(w*w + x*x + y*y + z*z);
+}
+
+void
+Quaternion::normalize()
+{
+ float mag = magnitude();
+ w /= mag;
+ x /= mag;
+ y /= mag;
+ z /= mag;
+}
+
+Matrix
+Quaternion::to_matrix() const
+{
+ Matrix r;
+ r.matrix[0] = 1.0f - 2.0f * (y*y + z*z);
+ r.matrix[4] = 2.0f * (x*y - z*w);
+ r.matrix[8] = 2.0f * (x*z + y*w);
+ r.matrix[12] = 0.0f;
+
+ r.matrix[1] = 2.0f * (x*y + z*w);
+ r.matrix[5] = 1.0f - 2.0f * (x*x + z*z);
+ r.matrix[9] = 2.0f * (y*z - x*w);
+ r.matrix[13] = 0.0f;
+
+ r.matrix[2] = 2.0f * (x*z - y*w);
+ r.matrix[6] = 2.0f * (y*z + x*w);
+ r.matrix[10] = 1.0f - 2.0f * (x*x + y*y);
+ r.matrix[14] = 0.0f;
+
+ r.matrix[3] = 0.0f;
+ r.matrix[7] = 0.0f;
+ r.matrix[11] = 0.0f;
+ r.matrix[15] = 1.0f;
+
+ return r;
+}
+
+static float clamp(float val, float min, float max)
+{
+ if(val < min)
+ val = min;
+ else if(val > max)
+ val = max;
+
+ return val;
+}
+
+Quaternion
+Quaternion::slerp(const Quaternion& o, float t) const
+{
+ /** Matze: I don't understand this code :-/ It's from
+ *
http://number-none.com/product/Understanding%20Slerp,%20Then%20Not%20Using%20It/
+ * Though the article recommends not to use slerp I see no code for the other
+ * methods so I'll use slerp anyway
+ */
+ float dot = dot_product(o);
+
+ const float DOT_THRESHOLD = 0.995;
+ if(dot > DOT_THRESHOLD) {
+ // quaternions are too close, lineary interpolate them
+ Quaternion result = *this + (o - *this)*t;
+ result.normalize();
+ return result;
+ }
+
+ dot = clamp(dot, -1 ,1); // robustness
+ float theta_O = acos(dot);
+ float theta = theta_O * t;
+
+ Quaternion v2 = o - (*this * dot);
+ v2.normalize();
+
+ return (*this * cos(theta)) + (v2 * sin(theta));
+}
+
+/* EOF */
Added: branches/pingus_sdl/src/math/quaternion.hpp
===================================================================
--- branches/pingus_sdl/src/math/quaternion.hpp 2007-01-13 11:37:45 UTC (rev
2637)
+++ branches/pingus_sdl/src/math/quaternion.hpp 2007-01-13 20:43:01 UTC (rev
2638)
@@ -0,0 +1,90 @@
+// $Id$
+//
+// Windstille - A Jump'n Shoot Game
+// Copyright (C) 2005 Matthias Braun <address@hidden>
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+#ifndef __QUATERNION_HPP__
+#define __QUATERNION_HPP__
+
+#include "matrix.hpp"
+
+class Quaternion
+{
+public:
+ float w;
+ float x;
+ float y;
+ float z;
+
+ Quaternion()
+ : w(0), x(0), y(0), z(0)
+ {}
+
+ Quaternion(float w, float x, float y, float z)
+ : w(w), x(x), y(y), z(z)
+ {}
+
+ float magnitude() const;
+ void normalize();
+
+ const Quaternion& operator*= (const Quaternion& o)
+ {
+ *this = *this * o;
+ return *this;
+ }
+
+ Quaternion operator* (const Quaternion& o) const
+ {
+ return Quaternion(
+ w*o.w - x*o.x - y*o.y - z*o.z,
+ w*o.x + x*o.w + y*o.z - z*o.y,
+ w*o.y + y*o.w + z*o.x - x*o.z,
+ w*o.z + z*o.w + x*o.y - y*o.x);
+ }
+
+ Quaternion operator- (const Quaternion& o) const
+ {
+ return Quaternion(w-o.w, x-o.x, y-o.y, z-o.z);
+ }
+
+ Quaternion operator+ (const Quaternion& o) const
+ {
+ return Quaternion(w+o.w, x+o.x, y+o.y, z+o.z);
+ }
+
+ Quaternion operator* (float s) const
+ {
+ return Quaternion(w*s, x*s, y*s, z*s);
+ }
+
+ float dot_product(const Quaternion& o) const
+ {
+ return x*o.x + y*o.y + z*o.z + w*o.w;
+ }
+
+ Matrix to_matrix() const;
+ /**
+ * spherical linear interpolation
+ * Returns this quaternion rotation added with t* the way from this
quaternion
+ * to the o quaternion (so t should be between 0 and 1 usually)
+ */
+ Quaternion slerp(const Quaternion& o, float t) const;
+};
+
+#endif
+
+/* EOF */
Added: branches/pingus_sdl/src/math/rect.cpp
===================================================================
--- branches/pingus_sdl/src/math/rect.cpp 2007-01-13 11:37:45 UTC (rev
2637)
+++ branches/pingus_sdl/src/math/rect.cpp 2007-01-13 20:43:01 UTC (rev
2638)
@@ -0,0 +1,62 @@
+/*
+** ClanLib SDK
+** Copyright (c) 1997-2005 The ClanLib Team
+**
+** This software is provided 'as-is', without any express or implied
+** warranty. In no event will the authors be held liable for any damages
+** arising from the use of this software.
+**
+** Permission is granted to anyone to use this software for any purpose,
+** including commercial applications, and to alter it and redistribute it
+** freely, subject to the following restrictions:
+**
+** 1. The origin of this software must not be misrepresented; you must not
+** claim that you wrote the original software. If you use this software
+** in a product, an acknowledgment in the product documentation would be
+** appreciated but is not required.
+** 2. Altered source versions must be plainly marked as such, and must not be
+** misrepresented as being the original software.
+** 3. This notice may not be removed or altered from any source distribution.
+**
+** Note: Some of the libraries ClanLib may link to may have additional
+** requirements or restrictions.
+**
+** File Author(s):
+**
+** Magnus Norddahl
+** (if your name is missing here, please add it)
+*/
+
+
+#include <cmath>
+
+#include "rect.hpp"
+
+#define cl_min(a,b) ((a < b) ? a : b)
+#define cl_max(a,b) ((a > b) ? a : b)
+
+Rect Rect::get_rot_bounds(const Point &hotspot, float angle) const
+{
+ //Find the rotated positions of each corner
+ Rect retVal(*this);
+ Point ul = Point(retVal.left, retVal.top).rotate(hotspot, angle);
+ Point ur = Point(retVal.right, retVal.top).rotate(hotspot, angle);
+ Point ll = Point(retVal.left, retVal.bottom).rotate(hotspot, angle);
+ Point lr = Point(retVal.right, retVal.bottom).rotate(hotspot, angle);
+
+ //Use the sidemost corners as the bounds of the new rectangle
+ retVal.left = cl_min(cl_min(ul.x, ur.x), cl_min(ll.x, lr.x));
+ retVal.right = cl_max(cl_max(ul.x, ur.x), cl_max(ll.x, lr.x));
+ retVal.top = cl_min(cl_min(ul.y, ur.y), cl_min(ll.y, lr.y));
+ retVal.bottom = cl_max(cl_max(ul.y, ur.y), cl_max(ll.y, lr.y));
+
+ return retVal;
+}
+
+Rect Rect::get_rot_bounds(Origin origin, int x, int y, float angle) const
+{
+ return get_rot_bounds(
+ Point(left, top) + calc_origin(origin, get_size()) + Point(x,
y),
+ angle);
+}
+
Added: branches/pingus_sdl/src/math/rect.hpp
===================================================================
--- branches/pingus_sdl/src/math/rect.hpp 2007-01-13 11:37:45 UTC (rev
2637)
+++ branches/pingus_sdl/src/math/rect.hpp 2007-01-13 20:43:01 UTC (rev
2638)
@@ -0,0 +1,374 @@
+/*
+** ClanLib SDK
+** Copyright (c) 1997-2005 The ClanLib Team
+**
+** This software is provided 'as-is', without any express or implied
+** warranty. In no event will the authors be held liable for any damages
+** arising from the use of this software.
+**
+** Permission is granted to anyone to use this software for any purpose,
+** including commercial applications, and to alter it and redistribute it
+** freely, subject to the following restrictions:
+**
+** 1. The origin of this software must not be misrepresented; you must not
+** claim that you wrote the original software. If you use this software
+** in a product, an acknowledgment in the product documentation would be
+** appreciated but is not required.
+** 2. Altered source versions must be plainly marked as such, and must not be
+** misrepresented as being the original software.
+** 3. This notice may not be removed or altered from any source distribution.
+**
+** Note: Some of the libraries ClanLib may link to may have additional
+** requirements or restrictions.
+**
+** File Author(s):
+**
+** Magnus Norddahl
+** (if your name is missing here, please add it)
+*/
+
+#ifndef __MATH_RECT_HPP__
+#define __MATH_RECT_HPP__
+
+#include "origin.hpp"
+#include "vector.hpp"
+#include "size.hpp"
+
+class Rectf;
+
+//: 2D (left,top,right,bottom) rectangle structure.
+//- !group=Core/Math!
+//- !header=core.h!
+class Rect
+{
+//! Construction:
+public:
+ //: Constructs an rectangle.
+ //param left: Initial left position of rectangle.
+ //param top: Initial top position of rectangle.
+ //param right: Initial right position of rectangle.
+ //param bottom: Initial bottom position of rectangle.
+ //param point: Initial top-left position of rectangle.
+ //param size: Initial size of rectangle.
+ //param rect: Initial rectangle position and size.
+ Rect() { left = right = top = bottom = 0; }
+
+ explicit Rect(const Rectf& rect);
+
+ Rect(int new_left, int new_top, int new_right, int new_bottom)
+ { left = new_left; top = new_top; right = new_right; bottom =
new_bottom; }
+
+ Rect(const Point &p, const Size &size)
+ { left = p.x; top = p.y; right = left + size.width; bottom = top +
size.height; }
+
+ Rect(const Rect &rect)
+ { left = rect.left; top = rect.top; right = rect.right; bottom =
rect.bottom; }
+
+ //: Rect += Rect operator.
+ Rect &operator+=(const Rect &r)
+ { left += r.left; top += r.top; right += r.right; bottom += r.bottom;
return *this; }
+
+ //: Rect -= Rect operator.
+ Rect &operator-=(const Rect &r)
+ { left -= r.left; top -= r.top; right -= r.right; bottom -= r.bottom;
return *this; }
+
+ //: Rect += Point operator.
+ Rect &operator+=(const Point &p)
+ { left += p.x; top += p.y; right += p.x; bottom += p.y; return *this; }
+
+ //: Rect -= Point operator.
+ Rect &operator-=(const Point &p)
+ { left -= p.x; top -= p.y; right -= p.x; bottom -= p.y; return *this; }
+
+ //: Rect + Rect operator.
+ Rect operator+(const Rect &r) const
+ { return Rect(left + r.left, top + r.top, right + r.right, bottom +
r.bottom); }
+
+ //: Rect - Rect operator.
+ Rect operator-(const Rect &r) const
+ { return Rect(left - r.left, top - r.top, right - r.right, bottom -
r.bottom); }
+
+ //: Rect + Point operator.
+ Rect operator+(const Point &p) const
+ { return Rect(left + p.x, top + p.y, right + p.x, bottom + p.y); }
+
+ //: Rect - Point operator.
+ Rect operator-(const Point &p) const
+ { return Rect(left - p.x, top - p.y, right - p.x, bottom - p.y); }
+
+ //: Rect == Rect operator.
+ bool operator==(const Rect &r) const
+ { return (left == r.left && top == r.top && right == r.right && bottom
&& r.bottom); }
+
+ //: Rect != Rect operator.
+ bool operator!=(const Rect &r) const
+ { return (left != r.left || top != r.top || right != r.right || bottom
!= r.bottom); }
+
+//! Attributes:
+public:
+ //: X1-coordinate.
+ int left;
+
+ //: Y1-coordinate.
+ int top;
+
+ //: X2-coordinate.
+ int right;
+
+ //: Y2-coordinate.
+ int bottom;
+
+ //: Returns the width of the rectangle.
+ int get_width() const { return right - left; }
+
+ //: Returns the height of the rectangle.
+ int get_height() const { return bottom - top; }
+
+ //: Returns the size of the rectangle.
+ Size get_size() const { return Size(right - left, bottom - top); }
+
+ //: Returns true if point is inside the rectangle.
+ bool is_inside(const Point &p) const { return (p.x >= left && p.y >=
top && p.x <= right && p.y <= bottom); }
+
+ //: Returns true if rectangle passed is overlapping or inside this
rectangle.
+ bool is_overlapped(const Rect &r) const
+ {
+ return (r.left < right && r.right > left && r.top < bottom &&
r.bottom > top);
+ }
+
+ //: Returns another Rect containing a rotated version of this one.
+ //param hotspot: Point to rotate around.
+ //param origin: Determines the hotspot point within the rectangle
+ //param x, y: Offsets applied negatively to the hotspot point
+ //param angle: Angle to rotate in degrees.
+ Rect get_rot_bounds(const Point &hotspot, float angle) const;
+ Rect get_rot_bounds(Origin origin, int x, int y, float angle) const;
+
+//! Operations:
+public:
+ //: Sets the size of the rectangle, maintaining top/left position.
+ void set_size(const Size &size)
+ {
+ right = left + size.width;
+ bottom = top + size.height;
+ }
+
+ //: Calculates and returns the union of two rectangles.
+ Rect calc_union(const Rect &rect)
+ {
+ Rect result;
+ if (left > rect.left) result.left = left; else
result.left = rect.left;
+ if (right < rect.right) result.right = right; else
result.right = rect.right;
+ if (top > rect.top) result.top = top; else
result.top = rect.top;
+ if (bottom < rect.bottom) result.bottom = bottom; else
result.bottom = rect.bottom;
+ return result;
+ }
+
+ //: Normalize rectangle. Ensures that left is less than right and top
is less than bottom.
+ void normalize()
+ {
+ if (left > right)
+ {
+ int temp = right;
+ right = left;
+ left = temp;
+ }
+
+ if (top > bottom)
+ {
+ int temp = bottom;
+ bottom = top;
+ top = temp;
+ }
+ }
+
+ //: Applies an origin and offset pair to this rectangle
+ //param origin: The new origin to adjust to from default upper-left
position
+ //param x, y: Offsets applied negatively to each corner of the rectangle
+ void apply_alignment(Origin origin, int x, int y)
+ {
+ Point offset = calc_origin(origin, get_size());
+ offset.x -= x;
+ offset.y -= y;
+
+ left += offset.x;
+ top += offset.y;
+ right += offset.x;
+ bottom += offset.y;
+ }
+};
+
+//: 2D (left,top,right,bottom) floating point rectangle structure.
+class Rectf
+{
+//! Construction:
+public:
+ //: Constructs an rectangle.
+ //param left: Initial left position of rectangle.
+ //param top: Initial top position of rectangle.
+ //param right: Initial right position of rectangle.
+ //param bottom: Initial bottom position of rectangle.
+ //param point: Initial top-left position of rectangle.
+ //param size: Initial size of rectangle.
+ //param rect: Initial rectangle position and size.
+ Rectf() { left = right = top = bottom = 0.0f; }
+
+ Rectf(const Rect& rect)
+ : left((float)rect.left),
+ top((float)rect.top),
+ right((float)rect.right),
+ bottom((float)rect.bottom)
+ {}
+
+ Rectf(float new_left, float new_top, float new_right, float new_bottom)
+ { left = new_left; top = new_top; right = new_right; bottom =
new_bottom; }
+
+ Rectf(const Vector &p, const Sizef &size)
+ { left = p.x; top = p.y; right = left + size.width; bottom = top +
size.height; }
+
+ Rectf(const Rectf &rect)
+ { left = rect.left; top = rect.top; right = rect.right; bottom =
rect.bottom; }
+
+ //: Rect += Rect operator.
+ Rectf &operator+=(const Rectf &r)
+ { left += r.left; top += r.top; right += r.right; bottom += r.bottom;
return *this; }
+
+ //: Rect -= Rect operator.
+ Rectf &operator-=(const Rectf &r)
+ { left -= r.left; top -= r.top; right -= r.right; bottom -= r.bottom;
return *this; }
+
+ //: Rect += Point operator.
+ Rectf &operator+=(const Vector &p)
+ { left += p.x; top += p.y; right += p.x; bottom += p.y; return *this; }
+
+ //: Rect -= Point operator.
+ Rectf &operator-=(const Vector &p)
+ { left -= p.x; top -= p.y; right -= p.x; bottom -= p.y; return *this; }
+
+ //: Rect + Rect operator.
+ Rectf operator+(const Rectf &r) const
+ { return Rectf(left + r.left, top + r.top, right + r.right, bottom +
r.bottom); }
+
+ //: Rect - Rect operator.
+ Rectf operator-(const Rectf &r) const
+ { return Rectf(left - r.left, top - r.top, right - r.right, bottom -
r.bottom); }
+
+ //: Rect + Point operator.
+ Rectf operator+(const Vector &p) const
+ { return Rectf(left + p.x, top + p.y, right + p.x, bottom + p.y); }
+
+ //: Rect - Point operator.
+ Rectf operator-(const Vector &p) const
+ { return Rectf(left - p.x, top - p.y, right - p.x, bottom - p.y); }
+
+ //: Rect == Rect operator.
+ bool operator==(const Rectf &r) const
+ { return (left == r.left && top == r.top && right == r.right && bottom
&& r.bottom); }
+
+ //: Rect != Rect operator.
+ bool operator!=(const Rect &r) const
+ { return (left != r.left || top != r.top || right != r.right || bottom
!= r.bottom); }
+
+//! Attributes:
+public:
+ //: X1-coordinate.
+ float left;
+
+ //: Y1-coordinate.
+ float top;
+
+ //: X2-coordinate.
+ float right;
+
+ //: Y2-coordinate.
+ float bottom;
+
+ //: Returns the width of the rectangle.
+ float get_width() const { return right - left; }
+
+ //: Returns the height of the rectangle.
+ float get_height() const { return bottom - top; }
+
+ //: Returns the size of the rectangle.
+ Sizef get_size() const { return Sizef(right - left, bottom - top); }
+
+ //: Returns true if point is inside the rectangle.
+ bool is_inside(const Vector &p) const { return (p.x >= left && p.y >=
top && p.x <= right && p.y <= bottom); }
+
+ //: Returns true if rectangle passed is overlapping or inside this
rectangle.
+ bool is_overlapped(const Rectf &r) const
+ {
+ return (r.left < right && r.right > left && r.top < bottom &&
r.bottom > top);
+ }
+
+//! Operations:
+public:
+ //: Sets the size of the rectangle, maintaining top/left position.
+ void set_size(const Size &size)
+ {
+ right = left + size.width;
+ bottom = top + size.height;
+ }
+
+ //: Calculates and returns the union of two rectangles.
+ Rectf calc_union(const Rectf &rect)
+ {
+ Rectf result;
+ if (left > rect.left) result.left = left; else
result.left = rect.left;
+ if (right < rect.right) result.right = right; else
result.right = rect.right;
+ if (top > rect.top) result.top = top; else
result.top = rect.top;
+ if (bottom < rect.bottom) result.bottom = bottom; else
result.bottom = rect.bottom;
+ return result;
+ }
+
+ //: Normalize rectangle. Ensures that left<right and top<bottom.
+ void normalize()
+ {
+ if (left > right)
+ {
+ float temp = right;
+ right = left;
+ left = temp;
+ }
+
+ if (top > bottom)
+ {
+ float temp = bottom;
+ bottom = top;
+ top = temp;
+ }
+ }
+
+ //: Applies an origin and offset pair to this rectangle
+ //param origin: The new origin to adjust to from default upper-left
position
+ //param x, y: Offsets applied negatively to each corner of the rectangle
+ void apply_alignment(Origin origin, float x, float y)
+ {
+ Vector offset = calc_origin(origin, get_size());
+ offset.x -= x;
+ offset.y -= y;
+
+ left += offset.x;
+ top += offset.y;
+ right += offset.x;
+ bottom += offset.y;
+ }
+
+ // Moves each edge f away from the center, thus width = old_width + 2*f
+ Rectf grow(float f) const {
+ return Rectf(left - f,
+ top - f,
+ right + f,
+ bottom + f);
+ }
+};
+
+inline Rect::Rect(const Rectf& rect)
+ : left(static_cast<int>(rect.left)),
+ top(static_cast<int>(rect.top)),
+ right(static_cast<int>(rect.right)),
+ bottom(static_cast<int>(rect.bottom))
+{}
+
+#endif
+
Added: branches/pingus_sdl/src/math/size.hpp
===================================================================
--- branches/pingus_sdl/src/math/size.hpp 2007-01-13 11:37:45 UTC (rev
2637)
+++ branches/pingus_sdl/src/math/size.hpp 2007-01-13 20:43:01 UTC (rev
2638)
@@ -0,0 +1,160 @@
+/*
+** ClanLib SDK
+** Copyright (c) 1997-2005 The ClanLib Team
+**
+** This software is provided 'as-is', without any express or implied
+** warranty. In no event will the authors be held liable for any damages
+** arising from the use of this software.
+**
+** Permission is granted to anyone to use this software for any purpose,
+** including commercial applications, and to alter it and redistribute it
+** freely, subject to the following restrictions:
+**
+** 1. The origin of this software must not be misrepresented; you must not
+** claim that you wrote the original software. If you use this software
+** in a product, an acknowledgment in the product documentation would be
+** appreciated but is not required.
+** 2. Altered source versions must be plainly marked as such, and must not be
+** misrepresented as being the original software.
+** 3. This notice may not be removed or altered from any source distribution.
+**
+** Note: Some of the libraries ClanLib may link to may have additional
+** requirements or restrictions.
+**
+** File Author(s):
+**
+** Magnus Norddahl
+** (if your name is missing here, please add it)
+*/
+
+//! clanCore="Math"
+//! header=core.h
+
+#ifndef HEADER_MATH_SIZE_HPP
+#define HEADER_MATH_SIZE_HPP
+
+#if _MSC_VER > 1000
+#pragma once
+#endif
+
+class Sizef;
+
+//: 2D (width,height) size structure.
+//- !group=Core/Math!
+//- !header=core.h!
+class Size
+{
+//! Construction:
+public:
+ //: Constructs a size structure.
+ //param width: Initial width of size structure.
+ //param height: Initial height of size structure.
+ //param size: Size structure to construct this one from.
+ Size() { return; }
+
+ Size(int width, int height)
+ : width(width), height(height) { }
+
+ Size(const Size &s)
+ { width = s.width; height = s.height; }
+
+ explicit Size(const Sizef& s);
+
+//! Attributes:
+public:
+ //: Size width.
+ int width;
+
+ //: Size height.
+ int height;
+
+//! Operations:
+public:
+ //: Size += Size operator.
+ Size &operator+=(const Size &s)
+ { width += s.width; height += s.height; return *this; }
+
+ //: Size -= Size operator.
+ Size &operator-=(const Size &s)
+ { width -= s.width; height -= s.height; return *this; }
+
+ //: Size + Size operator.
+ Size operator+(const Size &s) const
+ { return Size(width + s.width, height + s.height); }
+
+ //: Size - Size operator.
+ Size operator-(const Size &s) const
+ { return Size(width - s.width, height - s.height); }
+
+ //: Size == Size operator (deep compare).
+ bool operator==(const Size &s) const
+ { return (width == s.width) && (height == s.height); }
+
+ //: Size != Size operator (deep compare).
+ bool operator!=(const Size &s) const
+ { return (width != s.width) || (height != s.height); }
+};
+
+//: 2D (width,height) floating point size structure.
+class Sizef
+{
+//! Construction:
+public:
+ //: Constructs a size structure.
+ //param width: Initial width of size structure.
+ //param height: Initial height of size structure.
+ //param size: Size structure to construct this one from.
+ Sizef() { return; }
+
+ Sizef(const Size& s)
+ : width((float)s.width),
+ height((float)s.height)
+ {}
+
+ Sizef(float width, float height)
+ : width(width), height(height) { }
+
+ Sizef(const Sizef &s)
+ { width = s.width; height = s.height; }
+
+//! Attributes:
+public:
+ //: Size width.
+ float width;
+
+ //: Size height.
+ float height;
+
+//! Operations:
+public:
+ //: Size += Size operator.
+ Sizef &operator+=(const Sizef &s)
+ { width += s.width; height += s.height; return *this; }
+
+ //: Size -= Size operator.
+ Sizef &operator-=(const Sizef &s)
+ { width -= s.width; height -= s.height; return *this; }
+
+ //: Size + Size operator.
+ Sizef operator+(const Sizef &s) const
+ { return Sizef(width + s.width, height + s.height); }
+
+ //: Size - Size operator.
+ Sizef operator-(const Sizef &s) const
+ { return Sizef(width - s.width, height - s.height); }
+
+ //: Size == Size operator (deep compare).
+ bool operator==(const Sizef &s) const
+ { return (width == s.width) && (height == s.height); }
+
+ //: Size != Size operator (deep compare).
+ bool operator!=(const Size &s) const
+ { return (width != s.width) || (height != s.height); }
+};
+
+inline Size::Size(const Sizef& s)
+ : width(static_cast<int>(s.width)),
+ height(static_cast<int>(s.height))
+{}
+
+#endif
Added: branches/pingus_sdl/src/math/vector2f.cpp
===================================================================
--- branches/pingus_sdl/src/math/vector2f.cpp 2007-01-13 11:37:45 UTC (rev
2637)
+++ branches/pingus_sdl/src/math/vector2f.cpp 2007-01-13 20:43:01 UTC (rev
2638)
@@ -0,0 +1,57 @@
+// $Id: vector.cpp 2642 2005-06-26 13:38:53Z matzebraun $
+//
+// SuperTux - A Jump'n Run
+// Copyright (C) 2004 Matthias Braun <address@hidden
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+#include <config.h>
+#include <cmath>
+#include <iostream>
+#include "math/vector2f.hpp"
+
+void
+Vector2f::normalize()
+{
+ float mag = magnitude();
+ x /= mag;
+ y /= mag;
+}
+
+Vector2f Vector2f::unit() const
+{
+ return *this / magnitude();
+}
+
+float
+Vector2f::magnitude() const
+{
+ return sqrt(x*x + y*y);
+}
+
+std::ostream& operator<<(std::ostream& s, const Vector2f& v)
+{
+ s << "(" << v.x << ", " << v.y << ")";
+ return s;
+}
+
+Vector2f
+Vector2f::rotate(float angle) const
+{
+ float len = magnitude();
+ return Vector2f(len * cos(angle), len * sin(angle));
+}
+
+/* EOF */
Added: branches/pingus_sdl/src/math/vector2f.hpp
===================================================================
--- branches/pingus_sdl/src/math/vector2f.hpp 2007-01-13 11:37:45 UTC (rev
2637)
+++ branches/pingus_sdl/src/math/vector2f.hpp 2007-01-13 20:43:01 UTC (rev
2638)
@@ -0,0 +1,134 @@
+// $Id: vector.hpp 2642 2005-06-26 13:38:53Z matzebraun $
+//
+// SuperTux - A Jump'n Run
+// Copyright (C) 2004 Matthias Braun <address@hidden>
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+#ifndef SUPERTUX_VECTOR_H
+#define SUPERTUX_VECTOR_H
+
+#include <iosfwd>
+
+/** Simple two dimensional vector. */
+class Vector2f
+{
+public:
+ Vector2f(float nx, float ny)
+ : x(nx), y(ny)
+ { }
+ Vector2f(const Vector2f& other)
+ : x(other.x), y(other.y)
+ { }
+ Vector2f()
+ : x(0), y(0)
+ { }
+
+ bool operator ==(const Vector2f& other) const
+ {
+ return x == other.x && y == other.y;
+ }
+
+ bool operator !=(const Vector2f& other) const
+ {
+ return !(x == other.x && y == other.y);
+ }
+
+ const Vector2f& operator=(const Vector2f& other)
+ {
+ x = other.x;
+ y = other.y;
+ return *this;
+ }
+
+ Vector2f operator+(const Vector2f& other) const
+ {
+ return Vector2f(x + other.x, y + other.y);
+ }
+
+ Vector2f operator-(const Vector2f& other) const
+ {
+ return Vector2f(x - other.x, y - other.y);
+ }
+
+ Vector2f operator*(float s) const
+ {
+ return Vector2f(x * s, y * s);
+ }
+
+ Vector2f operator/(float s) const
+ {
+ return Vector2f(x / s, y / s);
+ }
+
+ Vector2f operator-() const
+ {
+ return Vector2f(-x, -y);
+ }
+
+ const Vector2f& operator +=(const Vector2f& other)
+ {
+ x += other.x;
+ y += other.y;
+ return *this;
+ }
+
+ const Vector2f& operator -=(const Vector2f& other)
+ {
+ x -= other.x;
+ y -= other.y;
+ return *this;
+ }
+
+ const Vector2f& operator *=(float val)
+ {
+ x *= val;
+ y *= val;
+ return *this;
+ }
+
+ const Vector2f& operator /=(float val)
+ {
+ x /= val;
+ y /= val;
+ return *this;
+ }
+
+ /** Takes angle in radian and returns a copy of the vector rotated
+ by \a angle */
+ Vector2f rotate(float angle) const;
+
+ /// Scalar product of 2 vectors
+ float operator*(const Vector2f& other) const
+ {
+ return x*other.x + y*other.y;
+ }
+
+ float magnitude() const;
+ float length() const { return magnitude(); }
+
+ Vector2f unit() const;
+ void normalize();
+
+ // ... add the other operators as needed, I'm too lazy now ...
+
+ float x, y; // leave this public, get/set methods just give me headaches
+ // for such simple stuff :)
+};
+
+std::ostream& operator<<(std::ostream& s, const Vector2f& v);
+
+#endif
+
Added: branches/pingus_sdl/src/math/vector2i.hpp
===================================================================
--- branches/pingus_sdl/src/math/vector2i.hpp 2007-01-13 11:37:45 UTC (rev
2637)
+++ branches/pingus_sdl/src/math/vector2i.hpp 2007-01-13 20:43:01 UTC (rev
2638)
@@ -0,0 +1,37 @@
+// $Id$
+//
+// Pingus - A free Lemmings clone
+// Copyright (C) 2002 Ingo Ruhnke <address@hidden>
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+#ifndef HEADER_VECTOR2_HPP
+#define HEADER_VECTOR2_HPP
+
+/** */
+class Vector2i
+{
+public:
+ int x;
+ int y;
+
+ Vector2i(int x_, int y_)
+ : x(x_), y(y_) {}
+
+};
+
+#endif
+
+/* EOF */
Added: branches/pingus_sdl/src/math/vector3f.cpp
===================================================================
--- branches/pingus_sdl/src/math/vector3f.cpp 2007-01-13 11:37:45 UTC (rev
2637)
+++ branches/pingus_sdl/src/math/vector3f.cpp 2007-01-13 20:43:01 UTC (rev
2638)
@@ -0,0 +1,166 @@
+// $Id: vector.cxx,v 1.6 2003/10/19 12:25:47 grumbel Exp $
+//
+// Pingus - A free Lemmings clone
+// Copyright (C) 2000 Ingo Ruhnke <address@hidden>
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+#include <math.h>
+#include <iostream>
+#include "vector3f.hpp"
+
+Vector3f::Vector3f (float x_, float y_, float z_) : x(x_), y(y_), z(z_)
+{
+}
+
+Vector3f::Vector3f (const Vector3f& old) : x(old.x), y(old.y), z(old.z)
+{
+}
+
+Vector3f&
+Vector3f::operator= (const Vector3f& old)
+{
+ if (this != &old)
+ {
+ x = old.x;
+ y = old.y;
+ z = old.z;
+ }
+
+ return *this;
+}
+
+Vector3f
+Vector3f::operator- () const
+{
+ return Vector3f(-x, -y, -z);
+}
+
+Vector3f
+Vector3f::operator+ (const Vector3f& add) const
+{
+ return Vector3f(x + add.x, y + add.y, z + add.z);
+}
+
+Vector3f
+Vector3f::operator- (const Vector3f& sub) const
+{
+ return Vector3f(x - sub.x, y - sub.y, z - sub.z);
+}
+
+Vector3f
+Vector3f::operator* (float mul) const
+{
+ return Vector3f(mul * x, mul * y, mul * z);
+}
+
+Vector3f&
+Vector3f::operator+= (const Vector3f& add)
+{
+ x += add.x;
+ y += add.y;
+ z += add.z;
+ return *this;
+}
+
+Vector3f&
+Vector3f::operator-= (const Vector3f& sub)
+{
+ x -= sub.x;
+ y -= sub.y;
+ z -= sub.z;
+ return *this;
+}
+
+Vector3f&
+Vector3f::operator*= (float mul)
+{
+ x *= mul;
+ y *= mul;
+ z *= mul;
+ return *this;
+}
+
+void
+Vector3f::normalize ()
+{
+ float f = sqrt(x * x + y * y + z * z);
+
+ if (f)
+ {
+ x /= f;
+ y /= f;
+ z /= f;
+ }
+}
+
+float
+Vector3f::length() const
+{
+ return sqrt(x * x + y * y + z * z);
+}
+
+Vector3f
+Vector3f::rotate (float angle, const Vector3f& pos) const
+{
+ const float s = sin(angle);
+ const float c = cos(angle);
+
+ return Vector3f( x * (pos.x * pos.x * (1-c) + c)
+ + y * (pos.x * pos.y * (1-c) - pos.z *s)
+ + z * (pos.x * pos.z * (1-c) + pos.y *s),
+
+ x * (pos.y * pos.x * (1-c) + pos.z *s)
+ + y * (pos.y * pos.y * (1-c) + c)
+ + z * (pos.y * pos.z * (1-c) - pos.x *s),
+
+ x * (pos.x * pos.z * (1-c) - pos.y *s)
+ + y * (pos.y * pos.z * (1-c) + pos.x *s)
+ + z * (pos.z * pos.z * (1-c) + c)
+ );
+}
+
+float
+Vector3f::distance(const Vector3f& a, const Vector3f& b)
+{
+ float x = b.x - a.x;
+ float y = b.y - a.y;
+ float z = b.z - a.z;
+
+ return fabsf(sqrt((x * x) + (y * y) + (z * z)));
+}
+
+float
+Vector3f::distance2d(const Vector3f& a, const Vector3f& b)
+{
+ float x = b.x - a.x;
+ float y = b.y - a.y;
+
+ return fabsf(sqrt((x * x) + (y * y)));
+}
+
+Vector3f
+Vector3f::interpolate(const Vector3f& a, const Vector3f& b, float perc)
+{
+ Vector3f c = b - a;
+ return a + (c * perc);
+}
+
+std::ostream& operator<<(std::ostream& os, const Vector3f& v)
+{
+ return os << v.x << " " << v.y << " " << v.z;
+}
+
+/* EOF */
Added: branches/pingus_sdl/src/math/vector3f.hpp
===================================================================
--- branches/pingus_sdl/src/math/vector3f.hpp 2007-01-13 11:37:45 UTC (rev
2637)
+++ branches/pingus_sdl/src/math/vector3f.hpp 2007-01-13 20:43:01 UTC (rev
2638)
@@ -0,0 +1,69 @@
+// $Id: vector.hxx,v 1.5 2003/10/18 23:17:27 grumbel Exp $
+//
+// Pingus - A free Lemmings clone
+// Copyright (C) 2000 Ingo Ruhnke <address@hidden>
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+#ifndef HEADER_PINGUS_MATH_VECTOR3F_HPP
+#define HEADER_PINGUS_MATH_VECTOR3F_HPP
+
+#include <iosfwd>
+#include "pingus.hxx"
+
+class Vector3f
+{
+public:
+ float x;
+ float y;
+ float z;
+
+public:
+ explicit Vector3f (float x_=0, float y_=0, float z_=0);
+
+ Vector3f (const Vector3f& old);
+ Vector3f& operator= (const Vector3f& old);
+
+ Vector3f operator- () const;
+
+ Vector3f operator+ (const Vector3f& add) const;
+ Vector3f operator- (const Vector3f& sub) const;
+ Vector3f operator* ( float mul) const;
+
+ Vector3f& operator+= (const Vector3f& add);
+ Vector3f& operator-= (const Vector3f& sub);
+ Vector3f& operator*= ( float mul);
+
+ void normalize ();
+
+ float length() const;
+
+ Vector3f rotate (float angle, const Vector3f& pos) const;
+
+ static float distance(const Vector3f& a, const Vector3f& b);
+ static float distance2d(const Vector3f& a, const Vector3f& b);
+
+ /** Calculate a position between a and b, relative to the value of
+ \a perc (perc == 0 -> a, perc == 1.0 -> b) */
+ static Vector3f interpolate(const Vector3f& a, const Vector3f& b, float
perc);
+
+ friend std::ostream& operator<< (std::ostream& os, const Vector3f& v);
+};
+
+std::ostream& operator<< (std::ostream& os, const Vector3f& v);
+
+#endif
+
+/* EOF */
Added: branches/pingus_sdl/src/origin.cpp
===================================================================
--- branches/pingus_sdl/src/origin.cpp 2007-01-13 11:37:45 UTC (rev 2637)
+++ branches/pingus_sdl/src/origin.cpp 2007-01-13 20:43:01 UTC (rev 2638)
@@ -0,0 +1,141 @@
+/*
+** ClanLib SDK
+** Copyright (c) 1997-2005 The ClanLib Team
+**
+** This software is provided 'as-is', without any express or implied
+** warranty. In no event will the authors be held liable for any damages
+** arising from the use of this software.
+**
+** Permission is granted to anyone to use this software for any purpose,
+** including commercial applications, and to alter it and redistribute it
+** freely, subject to the following restrictions:
+**
+** 1. The origin of this software must not be misrepresented; you must not
+** claim that you wrote the original software. If you use this software
+** in a product, an acknowledgment in the product documentation would be
+** appreciated but is not required.
+** 2. Altered source versions must be plainly marked as such, and must not be
+** misrepresented as being the original software.
+** 3. This notice may not be removed or altered from any source distribution.
+**
+** Note: Some of the libraries ClanLib may link to may have additional
+** requirements or restrictions.
+**
+** File Author(s):
+**
+** Magnus Norddahl
+** (if your name is missing here, please add it)
+*/
+
+#include "origin.hpp"
+
+#if 0
+Point calc_origin(Origin origin, const CL_Size &size)
+{
+ switch(origin)
+ {
+ case origin_top_left:
+ default:
+ return CL_Point(0, 0);
+ break;
+ case origin_top_center:
+ return CL_Point(size.width / 2, 0);
+ break;
+ case origin_top_right:
+ return CL_Point(size.width, 0);
+ break;
+ case origin_center_left:
+ return CL_Point(0, size.height / 2);
+ break;
+ case origin_center:
+ return CL_Point(size.width / 2, size.height / 2);
+ break;
+ case origin_center_right:
+ return CL_Point(size.width, size.height / 2);
+ break;
+ case origin_bottom_left:
+ return CL_Point(0, size.height);
+ break;
+ case origin_bottom_center:
+ return CL_Point(size.width / 2, size.height);
+ break;
+ case origin_bottom_right:
+ return CL_Point(size.width, size.height);
+ break;
+ }
+}
+
+CL_Pointf calc_origin(CL_Origin origin, const CL_Sizef &size)
+{
+ switch(origin)
+ {
+ case origin_top_left:
+ default:
+ return CL_Pointf(0, 0);
+ break;
+ case origin_top_center:
+ return CL_Pointf(size.width / 2, 0);
+ break;
+ case origin_top_right:
+ return CL_Pointf(size.width, 0);
+ break;
+ case origin_center_left:
+ return CL_Pointf(0, size.height / 2);
+ break;
+ case origin_center:
+ return CL_Pointf(size.width / 2, size.height / 2);
+ break;
+ case origin_center_right:
+ return CL_Pointf(size.width, size.height / 2);
+ break;
+ case origin_bottom_left:
+ return CL_Pointf(0, size.height);
+ break;
+ case origin_bottom_center:
+ return CL_Pointf(size.width / 2, size.height);
+ break;
+ case origin_bottom_right:
+ return CL_Pointf(size.width, size.height);
+ break;
+ }
+}
+
+CL_Pointd calc_origin(CL_Origin origin, const CL_Sized &size)
+{
+ switch(origin)
+ {
+ case origin_top_left:
+ default:
+ return CL_Pointd(0, 0);
+ break;
+ case origin_top_center:
+ return CL_Pointd(size.width / 2, 0);
+ break;
+ case origin_top_right:
+ return CL_Pointd(size.width, 0);
+ break;
+ case origin_center_left:
+ return CL_Pointd(0, size.height / 2);
+ break;
+ case origin_center:
+ return CL_Pointd(size.width / 2, size.height / 2);
+ break;
+ case origin_center_right:
+ return CL_Pointd(size.width, size.height / 2);
+ break;
+ case origin_bottom_left:
+ return CL_Pointd(0, size.height);
+ break;
+ case origin_bottom_center:
+ return CL_Pointd(size.width / 2, size.height);
+ break;
+ case origin_bottom_right:
+ return CL_Pointd(size.width, size.height);
+ break;
+ }
+}
+
+#endif
+
+/* EOF */
+
Added: branches/pingus_sdl/src/origin.hpp
===================================================================
--- branches/pingus_sdl/src/origin.hpp 2007-01-13 11:37:45 UTC (rev 2637)
+++ branches/pingus_sdl/src/origin.hpp 2007-01-13 20:43:01 UTC (rev 2638)
@@ -0,0 +1,65 @@
+/*
+** ClanLib SDK
+** Copyright (c) 1997-2005 The ClanLib Team
+**
+** This software is provided 'as-is', without any express or implied
+** warranty. In no event will the authors be held liable for any damages
+** arising from the use of this software.
+**
+** Permission is granted to anyone to use this software for any purpose,
+** including commercial applications, and to alter it and redistribute it
+** freely, subject to the following restrictions:
+**
+** 1. The origin of this software must not be misrepresented; you must not
+** claim that you wrote the original software. If you use this software
+** in a product, an acknowledgment in the product documentation would be
+** appreciated but is not required.
+** 2. Altered source versions must be plainly marked as such, and must not be
+** misrepresented as being the original software.
+** 3. This notice may not be removed or altered from any source distribution.
+**
+** Note: Some of the libraries ClanLib may link to may have additional
+** requirements or restrictions.
+**
+** File Author(s):
+**
+** Magnus Norddahl
+** (if your name is missing here, please add it)
+*/
+
+//! clanCore="Math"
+//! header=core.h
+
+#ifndef header_origin
+#define header_origin
+
+#if _MSC_VER > 1000
+#pragma once
+#endif
+
+//: Alignment origins.
+//- !group=Core/Math!
+//- !header=core.h!
+enum Origin
+{
+ origin_top_left,
+ origin_top_center,
+ origin_top_right,
+ origin_center_left,
+ origin_center,
+ origin_center_right,
+ origin_bottom_left,
+ origin_bottom_center,
+ origin_bottom_right
+};
+
+#if 0
+//: Returns the anchor point for the origin within the dimensions of the size
structure.
+//- !group=Display/Display 2D!
+//- !header=display.h!
+CL_API_CORE CL_Point calc_origin(CL_Origin origin, const CL_Size &size);
+CL_API_CORE CL_Pointf calc_origin(CL_Origin origin, const CL_Sizef &size);
+CL_API_CORE CL_Pointd calc_origin(CL_Origin origin, const CL_Sized &size);
+#endif
+
+#endif
Modified: branches/pingus_sdl/src/pingus_level.hxx
===================================================================
--- branches/pingus_sdl/src/pingus_level.hxx 2007-01-13 11:37:45 UTC (rev
2637)
+++ branches/pingus_sdl/src/pingus_level.hxx 2007-01-13 20:43:01 UTC (rev
2638)
@@ -20,11 +20,10 @@
#ifndef HEADER_PINGUS_LEVEL_HXX
#define HEADER_PINGUS_LEVEL_HXX
-#include <ClanLib/Core/System/sharedptr.h>
-#include <ClanLib/Core/Math/size.h>
#include <string>
#include <vector>
#include <map>
+#include "shared_ptr.hxx"
#include "file_reader.hxx"
namespace Pingus {
@@ -82,7 +81,7 @@
const std::string get_resname() const;
protected:
- CL_SharedPtr<PingusLevelImpl> impl;
+ SharedPtr<PingusLevelImpl> impl;
};
} // namespace Pingus
Modified: branches/pingus_sdl/src/pingus_menu.cxx
===================================================================
--- branches/pingus_sdl/src/pingus_menu.cxx 2007-01-13 11:37:45 UTC (rev
2637)
+++ branches/pingus_sdl/src/pingus_menu.cxx 2007-01-13 20:43:01 UTC (rev
2638)
@@ -17,8 +17,6 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#include <ClanLib/Display/display.h>
-#include <ClanLib/core.h>
#include <config.h>
#include "gettext.h"
#include "components/menu_button.hxx"
@@ -29,8 +27,8 @@
#include "stat_manager.hxx"
#include "start_screen.hxx"
#include "story_screen.hxx"
-#include "worldmap/worldmap.hxx"
-#include "worldmap/manager.hxx"
+////#include "worldmap/worldmap.hxx"
+////#include "worldmap/manager.hxx"
#include "gui/screen_manager.hxx"
#include "pingus_menu_manager.hxx"
#include "gui/gui_manager.hxx"
@@ -43,46 +41,47 @@
PingusMenu::PingusMenu (PingusMenuManager* m)
: PingusSubMenu (m),
- filedialog(0)
+ filedialog(0)
{
is_init = false;
- start_button = new MenuButton(CL_Point(CL_Display::get_width() * 400 / 800,
- CL_Display::get_height() * 450 / 600),
+ start_button = new MenuButton(Vector2i(Display::get_width() * 400 / 800,
+ Display::get_height() * 450 / 600),
Resource::load_sprite("core/menu/play_on"),
_("Start"),
_("..:: Start the game ::.."));
- quit_button = new MenuButton(CL_Point(CL_Display::get_width() * 650 / 800,
- CL_Display::get_height() * 450 / 600),
+ quit_button = new MenuButton(Vector2i(Display::get_width() * 650 / 800,
+ Display::get_height() * 450 / 600),
Resource::load_sprite("core/menu/exit_on"),
_("Exit"),
_("..:: Bye, bye ::.."));
- contrib_button = new MenuButton(CL_Point(CL_Display::get_width() * 150 / 800,
- CL_Display::get_height() * 450 /
600),
+ contrib_button = new MenuButton(Vector2i(Display::get_width() * 150 / 800,
+ Display::get_height() * 450 / 600),
Resource::load_sprite("core/menu/options_on"),
_("Contrib\nLevels"),
_("..:: Play User Build levels ::.."));
- story_button = new MenuButton(CL_Point(CL_Display::get_width() * 400 / 800,
- CL_Display::get_height() * 340 /
600),
+ story_button = new MenuButton(Vector2i(Display::get_width() * 400 / 800,
+ Display::get_height() * 340 / 600),
Resource::load_sprite("core/menu/credits_on"),
_("Story"),
_("..:: Start the story ::.."));
- multiplayer_button = new MenuButton(CL_Point(CL_Display::get_width() * 150 /
800,
- CL_Display::get_height() * 340
/ 600),
+ multiplayer_button = new MenuButton(Vector2i(Display::get_width() * 150 /
800,
+ Display::get_height() * 340 /
600),
Resource::load_sprite("core/menu/multi_on"),
_("Multiplayer"),
_("..:: Multiplayer Match ::.."));
- editor_button = new MenuButton(CL_Point(CL_Display::get_width() * 400 /
800,
- CL_Display::get_height() * 450
/ 600),
-
Resource::load_sprite("core/menu/create_on"),
- _("Level Editor"),
- _("..:: Create your own levels ::.."));
+ editor_button = new MenuButton(Vector2i(Display::get_width() * 400 / 800,
+ Display::get_height() * 450 / 600),
+ Resource::load_sprite("core/menu/create_on"),
+ _("Level Editor"),
+ _("..:: Create your own levels ::.."));
+#if 0
slots.push_back(start_button->sig_click().connect(this,
&PingusMenu::setup_game_menu));
slots.push_back(quit_button->sig_click().connect(this,
&PingusMenu::do_quit));
@@ -90,7 +89,8 @@
slots.push_back(multiplayer_button->sig_click().connect(this,
&PingusMenu::setup_main_menu));
slots.push_back(contrib_button->sig_click().connect(this,
&PingusMenu::setup_contrib_menu));
- slots.push_back(editor_button->sig_click().connect(this,
&PingusMenu::do_edit));
+ slots.push_back(editor_button->sig_click().connect(this,
&PingusMenu::do_edit));
+#endif
}
void
@@ -99,7 +99,7 @@
gui_manager->remove(contrib_button);
gui_manager->remove(story_button);
gui_manager->remove(multiplayer_button);
- gui_manager->remove(editor_button);
+ gui_manager->remove(editor_button);
gui_manager->add(quit_button);
gui_manager->add(start_button);
@@ -112,30 +112,34 @@
gui_manager->add(contrib_button);
gui_manager->add(story_button);
- gui_manager->add(editor_button);
- // FIXME: Re-enable this next line once multiplayer functionality
- // is actually available.
+ gui_manager->add(editor_button);
+ // FIXME: Re-enable this next line once multiplayer functionality
+ // is actually available.
//gui_manager->add(multiplayer_button);
}
void
PingusMenu::setup_contrib_menu()
{
- if (filedialog)
- delete filedialog;
- filedialog = new FileDialog(this, ".pingus",
- path_manager.complete("levels/"), true);
+#if 0
+ if (filedialog)
+ delete filedialog;
+ filedialog = new FileDialog(this, ".pingus",
+ path_manager.complete("levels/"), true);
manager->push_menu (filedialog);
+#endif
}
void
PingusMenu::setup_worldmap_menu()
{
- if (filedialog)
- delete filedialog;
- filedialog = new FileDialog(this, ".xml",
- path_manager.complete("worldmaps/"), true);
+#if 0
+ if (filedialog)
+ delete filedialog;
+ filedialog = new FileDialog(this, ".xml",
+ path_manager.complete("worldmaps/"), true);
manager->push_menu (filedialog);
+#endif
}
void
@@ -152,14 +156,14 @@
PingusMenu::~PingusMenu()
{
- delete start_button;
- delete quit_button;
- delete contrib_button;
- delete story_button;
- delete multiplayer_button;
- delete editor_button;
- if (filedialog)
- delete filedialog;
+ delete start_button;
+ delete quit_button;
+ delete contrib_button;
+ delete story_button;
+ delete multiplayer_button;
+ delete editor_button;
+ if (filedialog)
+ delete filedialog;
}
void
@@ -171,32 +175,36 @@
void
PingusMenu::do_start(const std::string &filename)
{ // Start the story or worldmap mode
+#if 0
Sound::PingusSound::play_sound ("letsgo");
- WorldMapNS::WorldMapManager::instance()->load(filename);
+ WorldMapNS::WorldMapManager::instance()->load(filename);
bool story_seen = false;
-
StatManager::instance()->get_bool(WorldMapNS::WorldMapManager::instance()->
- get_worldmap()->get_shortname() + "-startstory-seen",
story_seen);
+ StatManager::instance()->get_bool(WorldMapNS::WorldMapManager::instance()->
+ get_worldmap()->get_shortname() +
"-startstory-seen", story_seen);
- if (!story_seen)
- ScreenManager::instance()->push_screen(new StoryScreen(
-
WorldMapNS::WorldMapManager::instance()->get_worldmap()->get_intro_story()),
true);
+ if (!story_seen)
+ ScreenManager::instance()->push_screen
+ (new
StoryScreen(WorldMapNS::WorldMapManager::instance()->get_worldmap()->get_intro_story()),
true);
else
-
ScreenManager::instance()->push_screen(WorldMapNS::WorldMapManager::instance());
+
ScreenManager::instance()->push_screen(WorldMapNS::WorldMapManager::instance());
+#endif
}
void PingusMenu::do_contrib(const std::string &levelfile)
{ // Launch the specified level - don't bother checking for it, it has to exist
+#if 0
Sound::PingusSound::play_sound ("letsgo");
ScreenManager::instance()->push_screen
- (new StartScreen(PLFResMgr::load_plf_from_filename(levelfile)),
- true);
+ (new StartScreen(PLFResMgr::load_plf_from_filename(levelfile)),
+ true);
+#endif
}
void PingusMenu::do_edit()
{ // Launch the level editor
- Sound::PingusSound::stop_music();
- ScreenManager::instance()->push_screen (new Editor::EditorScreen());
+ Sound::PingusSound::stop_music();
+ //// ScreenManager::instance()->push_screen (new Editor::EditorScreen());
}
void
@@ -217,26 +225,26 @@
if (gc.get_height() == 480)
{
gc.draw(background,
- Vector((gc.get_width()/2) - (background.get_width()/2),
- 20.0f));
+ Vector3f((gc.get_width()/2) - (background.get_width()/2),
+ 20.0f));
}
else
{
gc.draw(background,
- Vector((gc.get_width()/2) - (background.get_width()/2),
-
static_cast<float>(CL_Display::get_height()/10)));
+ Vector3f((gc.get_width()/2) - (background.get_width()/2),
+ static_cast<float>(Display::get_height()/10)));
}
#ifdef OFFICIAL_PINGUS_BUILD
gc.print_left(Fonts::pingus_small, 20.0f,
-
static_cast<float>(CL_Display::get_height()-100),
+ static_cast<float>(Display::get_height()-100),
"Pingus version "VERSION", Copyright (C) 2003 Ingo Ruhnke
<address@hidden>\n");
#else
gc.print_left(Fonts::pingus_small, 20.0f,
-
static_cast<float>(CL_Display::get_height()-100),
+ static_cast<float>(Display::get_height()-100),
"Pingus version "VERSION" (unofficial build), Copyright (C)
2003 Ingo Ruhnke <address@hidden>\n");
#endif
gc.print_left(Fonts::pingus_small, 20.0f,
-
static_cast<float>(CL_Display::get_height()-70),
+ static_cast<float>(Display::get_height()-70),
"Pingus comes with ABSOLUTELY NO WARRANTY. This is free
software, and you are welcome\n"
"to redistribute it under certain conditions; see the file
COPYING for details.\n");
}
@@ -244,19 +252,19 @@
void
PingusMenu::load(const std::string &file, const std::string &filemask)
{
- // Level
- if (filemask == ".pingus")
- do_contrib(file);
- // Worldmap
- else if (filemask == ".xml")
- do_start(file);
- manager->pop_menu();
+ // Level
+ if (filemask == ".pingus")
+ do_contrib(file);
+ // Worldmap
+ else if (filemask == ".xml")
+ do_start(file);
+ manager->pop_menu();
}
void
PingusMenu::cancel()
{
- manager->pop_menu();
+ manager->pop_menu();
}
} // namespace Pingus
Modified: branches/pingus_sdl/src/pingus_menu.hxx
===================================================================
--- branches/pingus_sdl/src/pingus_menu.hxx 2007-01-13 11:37:45 UTC (rev
2637)
+++ branches/pingus_sdl/src/pingus_menu.hxx 2007-01-13 20:43:01 UTC (rev
2638)
@@ -47,11 +47,10 @@
public:
bool is_init;
private:
- std::vector<CL_Slot> slots;
+ ////std::vector<CL_Slot> slots;
- CL_Sprite background;
+ Sprite background;
LayerManager layer_manager;
- CL_Surface cursor_sur;
MenuButton* start_button;
MenuButton* quit_button;
@@ -59,31 +58,31 @@
MenuButton* contrib_button;
MenuButton* story_button;
MenuButton* multiplayer_button;
- MenuButton* editor_button;
- FileDialog* filedialog;
+ MenuButton* editor_button;
+ FileDialog* filedialog;
void on_resize (int w, int h);
// These functions setup the different menus
void setup_main_menu();
void setup_game_menu();
- /** Show the levels folder */
+ /** Show the levels folder */
void setup_contrib_menu();
- /** Show the worldmap folder */
- void setup_worldmap_menu();
+ /** Show the worldmap folder */
+ void setup_worldmap_menu();
- /** Quit the game */
+ /** Quit the game */
void do_quit();
- /** Start the story/worldmap mode */
- void do_start(const std::string &filename);
- /** Start the level editor */
- void do_edit();
+ /** Start the story/worldmap mode */
+ void do_start(const std::string &filename);
+ /** Start the level editor */
+ void do_edit();
- /** Use this to load the level or worldmap */
- virtual void load(const std::string &file, const std::string &filemask);
+ /** Use this to load the level or worldmap */
+ virtual void load(const std::string &file, const std::string &filemask);
- /** Cancels the file dialog box */
- virtual void cancel();
+ /** Cancels the file dialog box */
+ virtual void cancel();
public:
PingusMenu (PingusMenuManager* m);
Modified: branches/pingus_sdl/src/pingus_menu_manager.cxx
===================================================================
--- branches/pingus_sdl/src/pingus_menu_manager.cxx 2007-01-13 11:37:45 UTC
(rev 2637)
+++ branches/pingus_sdl/src/pingus_menu_manager.cxx 2007-01-13 20:43:01 UTC
(rev 2638)
@@ -18,7 +18,6 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <iostream>
-#include <ClanLib/Display/display.h>
#include "gui/screen_manager.hxx"
#include "sound/sound.hxx"
#include "resource.hxx"
@@ -33,12 +32,13 @@
: mainmenu (this),
exitmenu (this)
{
- int w = (int)CL_Display::get_width();
- int h = (int)CL_Display::get_height();
+ int w = Display::get_width();
+ int h = Display::get_height();
// We only need to scale the background main menu images if the screen
// resolution is not default
if (w != 800 && h != 600)
{
+#if 0
background.add_layer (Blitter::scale_surface_to_canvas(
Resource::load_pixelbuffer("core/menu/layer1"), w, 185
* h / 600), 0, 0, 12, 0);
background.add_layer (Blitter::scale_surface_to_canvas(
@@ -49,14 +49,15 @@
Resource::load_pixelbuffer("core/menu/layer4"), w, 171
* h / 600), 0, 429 * (float)h / 600, 100, 0);
background.add_layer (Blitter::scale_surface_to_canvas(
Resource::load_pixelbuffer("core/menu/layer5"), 302 * w
/ 800, 104 * h / 600), 0, 500 * (float)h / 600, 200, 0);
+#endif
}
else
{
-
background.add_layer(Resource::load_pixelbuffer("core/menu/layer1"), 0, 0, 12,
0);
-
background.add_layer(Resource::load_pixelbuffer("core/menu/layer2"), 0, 150,
25, 0);
-
background.add_layer(Resource::load_pixelbuffer("core/menu/layer3"), 0, 200,
50, 0);
-
background.add_layer(Resource::load_pixelbuffer("core/menu/layer4"), 0, 429,
100, 0);
-
background.add_layer(Resource::load_pixelbuffer("core/menu/layer5"), 0, 500,
200, 0);
+ background.add_layer(Resource::load_sprite("core/menu/layer1"),
0, 0, 12, 0);
+ background.add_layer(Resource::load_sprite("core/menu/layer2"),
0, 150, 25, 0);
+ background.add_layer(Resource::load_sprite("core/menu/layer3"),
0, 200, 50, 0);
+ background.add_layer(Resource::load_sprite("core/menu/layer4"),
0, 429, 100, 0);
+ background.add_layer(Resource::load_sprite("core/menu/layer5"),
0, 500, 200, 0);
}
push_menu (&mainmenu);
}
@@ -68,16 +69,19 @@
bool
PingusMenuManager::draw (DrawingContext& gc)
{
+#if 0
background.draw (gc);
- gc.draw_fillrect(0.0, static_cast<float>(CL_Display::get_height () - 22),
- static_cast<float>(CL_Display::get_width ()),
-
static_cast<float>(CL_Display::get_height ()),
- CL_Color(0, 0, 0, 255));
+ gc.draw_fillrect(0.0,
+ static_cast<float>(Display::get_height () - 22),
+ static_cast<float>(Display::get_width ()),
+ static_cast<float>(Display::get_height ()),
+ Color(0, 0, 0, 255));
for (MenuStackIter i = menu_stack.begin (); i != menu_stack.end (); ++i)
(*i)->draw (gc);
+#endif
return true;
}
Modified: branches/pingus_sdl/src/resource.cxx
===================================================================
--- branches/pingus_sdl/src/resource.cxx 2007-01-13 11:37:45 UTC (rev
2637)
+++ branches/pingus_sdl/src/resource.cxx 2007-01-13 20:43:01 UTC (rev
2638)
@@ -25,9 +25,6 @@
#include <assert.h>
-#include <ClanLib/core.h>
-#include <ClanLib/display.h>
-#include <ClanLib/Display/font.h>
#include "system.hxx"
#include "path_manager.hxx"
#include "globals.hxx"
@@ -36,13 +33,14 @@
#include "debug.hxx"
namespace Pingus {
-
+#if 0
CL_ResourceManager Resource::resmgr;
std::map<ResDescriptor, CL_Surface> Resource::surface_map;
-
+#endif
void
Resource::init()
{
+#if 0
resmgr.add_resources(CL_ResourceManager(path_manager.complete("data/core.xml")));
resmgr.add_resources(CL_ResourceManager(path_manager.complete("data/entrances.xml")));
resmgr.add_resources(CL_ResourceManager(path_manager.complete("data/exits.xml")));
@@ -67,10 +65,12 @@
resmgr.add_resources(CL_ResourceManager(path_manager.complete("data/worldmaps.xml")));
resmgr.add_resources(CL_ResourceManager(path_manager.complete("data/worldobjs.xml")));
resmgr.add_resources(CL_ResourceManager(path_manager.complete("data/alias.xml")));
+#endif
}
// Returns all resources in the given section
+#if 0
std::vector<std::string>
Resource::get_resources(const std::string& type, const std::string& section)
{
@@ -80,7 +80,6 @@
return resmgr.get_resources_of_type(type, section);
}
-
// Returns a list of sections. Returns all sections if left blank.
std::vector<std::string>
Resource::get_sections(const std::string& section)
@@ -90,31 +89,38 @@
else
return resmgr.get_sections(section);
}
+#endif
-
void
Resource::deinit()
{
cleanup();
+#if 0
surface_map.clear();
+#endif
}
+#if 0
CL_Surface
Resource::load_surface(const std::string& res_name,
ResourceModifierNS::ResourceModifier modifier)
{
return load_surface(ResDescriptor(res_name, modifier));
}
+#endif
-CL_Sprite
+Sprite
Resource::load_sprite(const ResDescriptor& desc)
{
return load_sprite(desc.res_name);
}
-CL_Sprite
+Sprite
Resource::load_sprite(const std::string& res_name)
{
+ return Sprite();
+
+#if 0
try {
return CL_Sprite(res_name, &resmgr);
} catch (CL_Error& err) {
@@ -122,8 +128,10 @@
std::cout << "CL_Error: " << err.message << std::endl;
return CL_Sprite("core/misc/404sprite", &resmgr);
}
+#endif
}
+#if 0
CL_SpriteDescription
Resource::load_sprite_desc(const std::string& res_name)
{
@@ -302,15 +310,17 @@
}
}
-CL_Font
+Font
Resource::load_font(const std::string& res_name)
{
- return CL_Font(res_name, &resmgr);
+ return Font(res_name, &resmgr);
}
+#endif
void
Resource::cleanup ()
{
+#if 0
CL_Resource res;
std::vector<std::string> resources = resmgr.get_all_resources();
for (std::vector<std::string>::iterator i = resources.begin(); i !=
resources.end(); i++)
@@ -319,6 +329,7 @@
while (res.get_reference_count() > 0)
res.unload();
}
+#endif
}
unsigned int
Modified: branches/pingus_sdl/src/resource.hxx
===================================================================
--- branches/pingus_sdl/src/resource.hxx 2007-01-13 11:37:45 UTC (rev
2637)
+++ branches/pingus_sdl/src/resource.hxx 2007-01-13 20:43:01 UTC (rev
2638)
@@ -22,7 +22,7 @@
#include <map>
#include <vector>
-#include <ClanLib/display.h>
+#include "sprite.hpp"
#include "res_descriptor.hxx"
class CL_ResourceManager;
@@ -35,6 +35,7 @@
class Resource
{
public:
+#if 0
static CL_ResourceManager resmgr;
static std::map<ResDescriptor, CL_Surface> surface_map;
@@ -43,15 +44,15 @@
static CL_Surface apply_modifier (const CL_Surface&, const ResDescriptor&
res_desc);
static CL_PixelBuffer apply_modifier_to_pixelbuffer(CL_PixelBuffer, const
ResDescriptor& res_desc);
- /** Returns a list of resources for the given section.
- Returns all if blank */
- static std::vector<std::string> get_resources(const std::string &type,
- const std::string §ion = "");
+ /** Returns a list of resources for the given section.
+ Returns all if blank */
+ static std::vector<std::string> get_resources(const std::string &type,
+ const std::string §ion =
"");
- /** Returns a list of sections under the given section.
- Returns all sections if blank */
- static std::vector<std::string> get_sections(const std::string §ion
= std::string());
-
+ /** Returns a list of sections under the given section.
+ Returns all sections if blank */
+ static std::vector<std::string> get_sections(const std::string §ion =
std::string());
+#endif
public:
static void init();
static void deinit();
@@ -59,6 +60,7 @@
/** */
static unsigned int get_mtime (const std::string& res_name);
+#if 0
/** Load a surface with res_name from datafile */
static CL_Surface load_surface(const std::string& res_name,
ResourceModifierNS::ResourceModifier modifier
@@ -66,7 +68,10 @@
/** Load a surface from the ResDescriptor */
static CL_Surface load_surface(const ResDescriptor&);
- static CL_Sprite load_sprite(const ResDescriptor&);
+#endif
+ static Sprite load_sprite(const ResDescriptor&);
+ static Sprite load_sprite(const std::string& res_name);
+#if 0
static CL_Sprite load_sprite(const std::string& res_name);
static CL_SpriteDescription load_sprite_desc(const std::string& res_name);
static CL_PixelBuffer load_pixelbuffer(const std::string& res_name);
@@ -74,7 +79,7 @@
/** Load a font with res_name from datafile */
static CL_Font load_font(const std::string& res_name);
-
+#endif
/** Cleanup all currently unused surfaces */
static void cleanup ();
Added: branches/pingus_sdl/src/shared_ptr.hxx
===================================================================
--- branches/pingus_sdl/src/shared_ptr.hxx 2007-01-13 11:37:45 UTC (rev
2637)
+++ branches/pingus_sdl/src/shared_ptr.hxx 2007-01-13 20:43:01 UTC (rev
2638)
@@ -0,0 +1,51 @@
+// $Id$
+//
+// Flexlay - A Generic 2D Game Editor
+// Copyright (C) 2002 Ingo Ruhnke <address@hidden>
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+#ifndef HEADER_SHARED_PTR_HXX
+#define HEADER_SHARED_PTR_HXX
+
+#include <assert.h>
+
+/** */
+template<typename T>
+class SharedPtr
+{
+private:
+ T* ptr;
+public:
+ template<typename Parent> friend class SharedPtr;
+
+ SharedPtr() : ptr(0) {}
+ SharedPtr(T* p) : ptr(p) {}
+
+ template <typename Parent>
+ SharedPtr(const SharedPtr<Parent>& p) : ptr(p.ptr) {}
+
+ T& operator*() { assert(ptr); return *ptr; }
+ T const& operator*() const { assert(ptr); return *ptr; }
+
+ T* operator->() { assert(ptr); return ptr; }
+ T const* operator->() const { assert(ptr); return ptr; }
+
+ T* get() const { return ptr; }
+};
+
+#endif
+
+/* EOF */
Modified: branches/pingus_sdl/src/sound/sound.cxx
===================================================================
--- branches/pingus_sdl/src/sound/sound.cxx 2007-01-13 11:37:45 UTC (rev
2637)
+++ branches/pingus_sdl/src/sound/sound.cxx 2007-01-13 20:43:01 UTC (rev
2638)
@@ -17,13 +17,11 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#include <ClanLib/Core/System/error.h>
#include <iostream>
#include <assert.h>
#include "../path_manager.hxx"
#include "../globals.hxx"
#include "sound_dummy.hxx"
-#include "sound_real.hxx"
#include "sound.hxx"
namespace Pingus {
@@ -34,6 +32,8 @@
void
PingusSound::init (PingusSoundImpl* s)
{
+ PingusSound::init (new PingusSoundDummy());
+#if 0
if (s == 0)
{
if (sound_enabled || music_enabled)
@@ -60,6 +60,7 @@
{
sound = s;
}
+#endif
}
void
Modified: branches/pingus_sdl/src/sound/sound.hxx
===================================================================
--- branches/pingus_sdl/src/sound/sound.hxx 2007-01-13 11:37:45 UTC (rev
2637)
+++ branches/pingus_sdl/src/sound/sound.hxx 2007-01-13 20:43:01 UTC (rev
2638)
@@ -20,7 +20,6 @@
#ifndef HEADER_PINGUS_SOUND_HXX
#define HEADER_PINGUS_SOUND_HXX
-#include <ClanLib/sound.h>
#include <string>
#include "sounds.hxx"
#include "sound_impl.hxx"
@@ -36,17 +35,17 @@
static PingusSoundImpl* sound;
public:
- PingusSound () { }
- ~PingusSound () { }
+ PingusSound () { }
+ ~PingusSound () { }
- static void init (PingusSoundImpl* s = 0);
+ static void init (PingusSoundImpl* s = 0);
static void deinit ();
/** Load a sound file and play it immediately.
- @param name Name of the sound, aka 'ohno'
- @param volume volume
- @param panning panning */
+ @param name Name of the sound, aka 'ohno'
+ @param volume volume
+ @param panning panning */
static void play_sound(const std::string & name, float volume = 1.0f, float
panning = 0.0f);
static void play_music(const std::string & name, float volume = 1.0f);
Modified: branches/pingus_sdl/src/sound/sound_real.cxx
===================================================================
--- branches/pingus_sdl/src/sound/sound_real.cxx 2007-01-13 11:37:45 UTC
(rev 2637)
+++ branches/pingus_sdl/src/sound/sound_real.cxx 2007-01-13 20:43:01 UTC
(rev 2638)
@@ -17,24 +17,11 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-#include <ClanLib/sound.h>
-#include <ClanLib/Core/System/error.h>
-
#include "../globals.hxx"
#include "../debug.hxx"
#include "sound_res_mgr.hxx"
#include "sound_real.hxx"
-#ifdef HAVE_LIBCLANVORBIS
-# include <ClanLib/vorbis.h>
-#endif
-
-#ifdef HAVE_LIBCLANMIKMOD
-# include <ClanLib/mikmod.h>
-# include <ClanLib/MikMod/setupmikmod.h>
-#endif
-
namespace Pingus {
namespace Sound {
Modified: branches/pingus_sdl/src/sound/sound_real.hxx
===================================================================
--- branches/pingus_sdl/src/sound/sound_real.hxx 2007-01-13 11:37:45 UTC
(rev 2637)
+++ branches/pingus_sdl/src/sound/sound_real.hxx 2007-01-13 20:43:01 UTC
(rev 2638)
@@ -24,7 +24,6 @@
#include <vector>
#include "sound_impl.hxx"
#include "sound.hxx"
-#include <ClanLib/Sound/soundbuffer_session.h>
class CL_SoundBuffer;
class CL_SoundBuffer_Session;
@@ -43,8 +42,8 @@
/** Music Controller Session */
CL_SoundBuffer_Session* music_session;
- /** Sound Output object */
- CL_SoundOutput* sound_output;
+ /** Sound Output object */
+ CL_SoundOutput* sound_output;
public:
PingusSoundReal ();
Modified: branches/pingus_sdl/src/sound/sound_res_mgr.cxx
===================================================================
--- branches/pingus_sdl/src/sound/sound_res_mgr.cxx 2007-01-13 11:37:45 UTC
(rev 2637)
+++ branches/pingus_sdl/src/sound/sound_res_mgr.cxx 2007-01-13 20:43:01 UTC
(rev 2638)
@@ -17,7 +17,6 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#include <ClanLib/sound.h>
#include "../path_manager.hxx"
#include "../globals.hxx"
#include "../debug.hxx"
@@ -30,6 +29,7 @@
SoundHandle
SoundResMgr::load(const std::string& name)
{
+#if 0
SoundMap::iterator i = sound_map.find(name);
if (i == sound_map.end())
@@ -47,14 +47,18 @@
pout(PINGUS_DEBUG_LOADING) << "SoundResMgr: Loading sound from cache: "
<< name << std::endl;
return i->second;
}
+#endif
+ return 0;
}
void SoundResMgr::free_sound_map()
{
+#if 0
for (SoundMap::iterator i = sound_map.begin(); i != sound_map.end(); ++i)
- {
- delete i->second;
- }
+ {
+ delete i->second;
+ }
+#endif
}
} // namespace Pingus
Added: branches/pingus_sdl/src/sprite.cpp
===================================================================
--- branches/pingus_sdl/src/sprite.cpp 2007-01-13 11:37:45 UTC (rev 2637)
+++ branches/pingus_sdl/src/sprite.cpp 2007-01-13 20:43:01 UTC (rev 2638)
@@ -0,0 +1,70 @@
+/* $Id$
+** __ __ __ ___ __ __ __ __
+** / \ / \__| ____ __| _/_______/ |_|__| | | | ____
+** \ \/\/ / |/ \ / __ |/ ___/\ __\ | | | | _/ __ \
+** \ /| | | \/ /_/ |\___ \ | | | | |_| |_\ ___/
+** \__/\ / |__|___| /\____ /____ > |__| |__|____/____/\___ >
+** \/ \/ \/ \/ \/
+** Copyright (C) 2005 Ingo Ruhnke <address@hidden>
+**
+** This program is free software; you can redistribute it and/or
+** modify it under the terms of the GNU General Public License
+** as published by the Free Software Foundation; either version 2
+** of the License, or (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+** 02111-1307, USA.
+*/
+
+#include "SDL.h"
+#include "SDL_image.h"
+#include "sprite.hpp"
+
+class SpriteImpl
+{
+public:
+ SpriteImpl(const std::string& name)
+ {
+ //IMG_Load
+ }
+};
+
+Sprite::Sprite()
+ : impl(0)
+{
+}
+
+Sprite::Sprite(const std::string& name)
+ : impl(new SpriteImpl(name))
+{
+}
+
+Sprite::~Sprite()
+{
+}
+
+void
+Sprite::draw(float x, float y, SDL_Surface* target)
+{
+}
+
+int
+Sprite::get_width()
+{
+ return 0;
+}
+
+int
+Sprite::get_height()
+{
+ return 0;
+}
+
+/* EOF */
Added: branches/pingus_sdl/src/sprite.hpp
===================================================================
--- branches/pingus_sdl/src/sprite.hpp 2007-01-13 11:37:45 UTC (rev 2637)
+++ branches/pingus_sdl/src/sprite.hpp 2007-01-13 20:43:01 UTC (rev 2638)
@@ -0,0 +1,53 @@
+/* $Id$
+** __ __ __ ___ __ __ __ __
+** / \ / \__| ____ __| _/_______/ |_|__| | | | ____
+** \ \/\/ / |/ \ / __ |/ ___/\ __\ | | | | _/ __ \
+** \ /| | | \/ /_/ |\___ \ | | | | |_| |_\ ___/
+** \__/\ / |__|___| /\____ /____ > |__| |__|____/____/\___ >
+** \/ \/ \/ \/ \/
+** Copyright (C) 2005 Ingo Ruhnke <address@hidden>
+**
+** This program is free software; you can redistribute it and/or
+** modify it under the terms of the GNU General Public License
+** as published by the Free Software Foundation; either version 2
+** of the License, or (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+** 02111-1307, USA.
+*/
+
+#ifndef HEADER_SPRITE_HPP
+#define HEADER_SPRITE_HPP
+
+#include <string>
+#include "SDL.h"
+#include "shared_ptr.hxx"
+
+class SpriteImpl;
+
+/** */
+class Sprite
+{
+public:
+ Sprite();
+ Sprite(const std::string& name);
+ ~Sprite();
+
+ int get_width();
+ int get_height();
+
+ void draw(float x, float y, SDL_Surface* target);
+private:
+ SharedPtr<SpriteImpl> impl;
+};
+
+#endif
+
+/* EOF */
Modified: branches/pingus_sdl/src/theme_selector.cxx
===================================================================
--- branches/pingus_sdl/src/theme_selector.cxx 2007-01-13 11:37:45 UTC (rev
2637)
+++ branches/pingus_sdl/src/theme_selector.cxx 2007-01-13 20:43:01 UTC (rev
2638)
@@ -226,9 +226,9 @@
current_theme = themes.end();
- on_button_press_slot = CL_Input::sig_button_press ().connect (event,
&ThemeSelector::Event::on_button_press);
- on_button_release_slot = CL_Input::sig_button_release ().connect (event,
&ThemeSelector::Event::on_button_release);
- on_mouse_move_slot = CL_Input::sig_mouse_move ().connect (event,
&ThemeSelector::Event::on_mouse_move);
+ ////on_button_press_slot = CL_Input::sig_button_press ().connect (event,
&ThemeSelector::Event::on_button_press);
+ ////on_button_release_slot = CL_Input::sig_button_release ().connect (event,
&ThemeSelector::Event::on_button_release);
+ ////on_mouse_move_slot = CL_Input::sig_mouse_move ().connect (event,
&ThemeSelector::Event::on_mouse_move);
}
ThemeSelector::~ThemeSelector()
@@ -242,9 +242,9 @@
// CL_Input::chain_button_press.remove(event);
// CL_Input::chain_button_release.remove(event);
- CL_Input::sig_button_press ().disconnect (on_button_press_slot);
- CL_Input::sig_button_release ().disconnect (on_button_release_slot);
- CL_Input::sig_mouse_move ().disconnect (on_mouse_move_slot);
+ ////CL_Input::sig_button_press ().disconnect (on_button_press_slot);
+ ////CL_Input::sig_button_release ().disconnect (on_button_release_slot);
+ ////CL_Input::sig_mouse_move ().disconnect (on_mouse_move_slot);
delete event;
}
Modified: branches/pingus_sdl/src/theme_selector.hxx
===================================================================
--- branches/pingus_sdl/src/theme_selector.hxx 2007-01-13 11:37:45 UTC (rev
2637)
+++ branches/pingus_sdl/src/theme_selector.hxx 2007-01-13 20:43:01 UTC (rev
2638)
@@ -23,11 +23,9 @@
#include "pingus.hxx"
#include <vector>
#include <string>
-#include <ClanLib/Signals/slot.h>
-#include <ClanLib/Display/surface.h>
class CL_Key;
-class CL_Font;
+class Font;
class CL_InputDevice;
namespace Pingus {
@@ -39,7 +37,7 @@
{
private:
std::string label;
- CL_Font font;
+ Font font;
public:
ListItem(std::string);
@@ -68,9 +66,9 @@
class ThemeSelector
{
public:
- CL_Slot on_button_press_slot;
- CL_Slot on_button_release_slot;
- CL_Slot on_mouse_move_slot;
+ ////CL_Slot on_button_press_slot;
+ ////CL_Slot on_button_release_slot;
+ ////CL_Slot on_mouse_move_slot;
class Event /*: public CL_Event_ButtonPress,
public CL_Event_ButtonRelease,
@@ -102,10 +100,10 @@
std::vector<Theme*>::iterator current_theme;
/** A large font, used for the Title Name */
- CL_Font title_font;
+ Font title_font;
/** This font is used for the levelnames */
- CL_Font theme_font;
+ Font theme_font;
/// The red arrow to the right
CL_Surface right_arrow;
Deleted: branches/pingus_sdl/src/vector.cxx
===================================================================
--- branches/pingus_sdl/src/vector.cxx 2007-01-13 11:37:45 UTC (rev 2637)
+++ branches/pingus_sdl/src/vector.cxx 2007-01-13 20:43:01 UTC (rev 2638)
@@ -1,170 +0,0 @@
-// $Id: vector.cxx,v 1.6 2003/10/19 12:25:47 grumbel Exp $
-//
-// Pingus - A free Lemmings clone
-// Copyright (C) 2000 Ingo Ruhnke <address@hidden>
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-#include <math.h>
-#include <iostream>
-#include "vector.hxx"
-
-namespace Pingus {
-
-Vector::Vector (float x_, float y_, float z_) : x(x_), y(y_), z(z_)
-{
-}
-
-Vector::Vector (const Vector& old) : x(old.x), y(old.y), z(old.z)
-{
-}
-
-Vector&
-Vector::operator= (const Vector& old)
-{
- if (this != &old)
- {
- x = old.x;
- y = old.y;
- z = old.z;
- }
-
- return *this;
-}
-
-Vector
-Vector::operator- () const
-{
- return Vector(-x, -y, -z);
-}
-
-Vector
-Vector::operator+ (const Vector& add) const
-{
- return Vector(x + add.x, y + add.y, z + add.z);
-}
-
-Vector
-Vector::operator- (const Vector& sub) const
-{
- return Vector(x - sub.x, y - sub.y, z - sub.z);
-}
-
-Vector
-Vector::operator* (float mul) const
-{
- return Vector(mul * x, mul * y, mul * z);
-}
-
-Vector&
-Vector::operator+= (const Vector& add)
-{
- x += add.x;
- y += add.y;
- z += add.z;
- return *this;
-}
-
-Vector&
-Vector::operator-= (const Vector& sub)
-{
- x -= sub.x;
- y -= sub.y;
- z -= sub.z;
- return *this;
-}
-
-Vector&
-Vector::operator*= (float mul)
-{
- x *= mul;
- y *= mul;
- z *= mul;
- return *this;
-}
-
-void
-Vector::normalize ()
-{
- float f = sqrt(x * x + y * y + z * z);
-
- if (f)
- {
- x /= f;
- y /= f;
- z /= f;
- }
-}
-
-float
-Vector::length() const
-{
- return sqrt(x * x + y * y + z * z);
-}
-
-Vector
-Vector::rotate (float angle, const Vector& pos) const
-{
- const float s = sin(angle);
- const float c = cos(angle);
-
- return Vector( x * (pos.x * pos.x * (1-c) + c)
- + y * (pos.x * pos.y * (1-c) - pos.z *s)
- + z * (pos.x * pos.z * (1-c) + pos.y *s),
-
- x * (pos.y * pos.x * (1-c) + pos.z *s)
- + y * (pos.y * pos.y * (1-c) + c)
- + z * (pos.y * pos.z * (1-c) - pos.x *s),
-
- x * (pos.x * pos.z * (1-c) - pos.y *s)
- + y * (pos.y * pos.z * (1-c) + pos.x *s)
- + z * (pos.z * pos.z * (1-c) + c)
- );
-}
-
-float
-Vector::distance(const Vector& a, const Vector& b)
-{
- float x = b.x - a.x;
- float y = b.y - a.y;
- float z = b.z - a.z;
-
- return fabsf(sqrt((x * x) + (y * y) + (z * z)));
-}
-
-float
-Vector::distance2d(const Vector& a, const Vector& b)
-{
- float x = b.x - a.x;
- float y = b.y - a.y;
-
- return fabsf(sqrt((x * x) + (y * y)));
-}
-
-Vector
-Vector::interpolate(const Vector& a, const Vector& b, float perc)
-{
- Vector c = b - a;
- return a + (c * perc);
-}
-
-} // namespace Pingus
-
-std::ostream& operator<< (std::ostream& os, const Pingus::Vector& v)
-{
- return os << v.x << " " << v.y << " " << v.z;
-}
-
-/* EOF */
Deleted: branches/pingus_sdl/src/vector.hxx
===================================================================
--- branches/pingus_sdl/src/vector.hxx 2007-01-13 11:37:45 UTC (rev 2637)
+++ branches/pingus_sdl/src/vector.hxx 2007-01-13 20:43:01 UTC (rev 2638)
@@ -1,73 +0,0 @@
-// $Id: vector.hxx,v 1.5 2003/10/18 23:17:27 grumbel Exp $
-//
-// Pingus - A free Lemmings clone
-// Copyright (C) 2000 Ingo Ruhnke <address@hidden>
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-#ifndef HEADER_PINGUS_VECTOR_HXX
-#define HEADER_PINGUS_VECTOR_HXX
-
-#include <iosfwd>
-#include "pingus.hxx"
-
-namespace Pingus {
-
-class Vector
-{
-public:
- float x;
- float y;
- float z;
-
-public:
- explicit Vector (float x_=0, float y_=0, float z_=0);
-
- Vector (const Vector& old);
- Vector& operator= (const Vector& old);
-
- Vector operator- () const;
-
- Vector operator+ (const Vector& add) const;
- Vector operator- (const Vector& sub) const;
- Vector operator* ( float mul) const;
-
- Vector& operator+= (const Vector& add);
- Vector& operator-= (const Vector& sub);
- Vector& operator*= ( float mul);
-
- void normalize ();
-
- float length() const;
-
- Vector rotate (float angle, const Vector& pos) const;
-
- static float distance(const Vector& a, const Vector& b);
- static float distance2d(const Vector& a, const Vector& b);
-
- /** Calculate a position between a and b, relative to the value of
- \a perc (perc == 0 -> a, perc == 1.0 -> b) */
- static Vector interpolate(const Vector& a, const Vector& b, float perc);
-
- friend std::ostream& operator<< (std::ostream& os, const Vector& v);
-};
-
-} // namespace Pingus
-
-std::ostream& operator<< (std::ostream& os, const Pingus::Vector& v);
-
-#endif
-
-/* EOF */
Modified: branches/pingus_sdl/src/worldmap/manager.hxx
===================================================================
--- branches/pingus_sdl/src/worldmap/manager.hxx 2007-01-13 11:37:45 UTC
(rev 2637)
+++ branches/pingus_sdl/src/worldmap/manager.hxx 2007-01-13 20:43:01 UTC
(rev 2638)
@@ -21,7 +21,6 @@
#define HEADER_PINGUS_WORLDMAP_MANAGER_HXX
#include <string>
-#include <ClanLib/Signals/slot.h>
#include "../gui/gui_manager.hxx"
#include "../gui/gui_screen.hxx"
Modified: branches/pingus_sdl/src/worldmap/worldmap.hxx
===================================================================
--- branches/pingus_sdl/src/worldmap/worldmap.hxx 2007-01-13 11:37:45 UTC
(rev 2637)
+++ branches/pingus_sdl/src/worldmap/worldmap.hxx 2007-01-13 20:43:01 UTC
(rev 2638)
@@ -20,7 +20,6 @@
#ifndef HEADER_PINGUS_WORLDMAP_WORLDMAP_HXX
#define HEADER_PINGUS_WORLDMAP_WORLDMAP_HXX
-#include <ClanLib/Display/sprite.h>
#include <vector>
#include "../file_reader.hxx"
#include "../display/drawing_context.hxx"
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] r2638 - in branches/pingus_sdl/src: . components display gui math sound worldmap,
grumbel at BerliOS <=