[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] r2798 - branches/pingus_sdl/src
From: |
grumbel at BerliOS |
Subject: |
[Pingus-CVS] r2798 - branches/pingus_sdl/src |
Date: |
Sat, 4 Aug 2007 21:26:46 +0200 |
Author: grumbel
Date: 2007-08-04 21:26:45 +0200 (Sat, 04 Aug 2007)
New Revision: 2798
Added:
branches/pingus_sdl/src/font_test_screen.cpp
branches/pingus_sdl/src/font_test_screen.hpp
Modified:
branches/pingus_sdl/src/SConscript
branches/pingus_sdl/src/font_description.hpp
branches/pingus_sdl/src/pingus_main.cpp
branches/pingus_sdl/src/pingus_main.hpp
Log:
- added little font test application
Modified: branches/pingus_sdl/src/SConscript
===================================================================
--- branches/pingus_sdl/src/SConscript 2007-08-04 18:23:29 UTC (rev 2797)
+++ branches/pingus_sdl/src/SConscript 2007-08-04 19:26:45 UTC (rev 2798)
@@ -140,6 +140,7 @@
'sexpr_file_writer.cpp',
'fonts.cpp',
'font.cpp',
+'font_test_screen.cpp',
'font_description.cpp',
'sprite.cpp',
'fps_counter.cpp',
Modified: branches/pingus_sdl/src/font_description.hpp
===================================================================
--- branches/pingus_sdl/src/font_description.hpp 2007-08-04 18:23:29 UTC
(rev 2797)
+++ branches/pingus_sdl/src/font_description.hpp 2007-08-04 19:26:45 UTC
(rev 2798)
@@ -26,6 +26,8 @@
#ifndef HEADER_FONT_DESCRIPTION_HPP
#define HEADER_FONT_DESCRIPTION_HPP
+#include <string>
+
/** */
class FontDescription
{
Added: branches/pingus_sdl/src/font_test_screen.cpp
===================================================================
--- branches/pingus_sdl/src/font_test_screen.cpp 2007-08-04 18:23:29 UTC
(rev 2797)
+++ branches/pingus_sdl/src/font_test_screen.cpp 2007-08-04 19:26:45 UTC
(rev 2798)
@@ -0,0 +1,111 @@
+/* $Id$
+** __ __ __ ___ __ __ __ __
+** / \ / \__| ____ __| _/_______/ |_|__| | | | ____
+** \ \/\/ / |/ \ / __ |/ ___/\ __\ | | | | _/ __ \
+** \ /| | | \/ /_/ |\___ \ | | | | |_| |_\ ___/
+** \__/\ / |__|___| /\____ /____ > |__| |__|____/____/\___ >
+** \/ \/ \/ \/ \/
+** Copyright (C) 2007 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 "fonts.hpp"
+#include "display/drawing_context.hpp"
+#include "font_description.hpp"
+#include "font_test_screen.hpp"
+
+FontTestScreen::FontTestScreen(const std::string& fontfile)
+ : scrollx(0),
+ scrolly(0)
+{
+ std::cout << "### Loading font file: " << fontfile << std::endl;
+ font = Font(FontDescription(fontfile));
+}
+
+bool
+FontTestScreen::draw(DrawingContext& gc)
+{
+ int checker = 40;
+ for(int y = 0; y < gc.get_height()/checker; y += 1)
+ for(int x = 0; x < gc.get_width()/checker; x += 1)
+ {
+ if ((x+y) % 2 != 0)
+ gc.draw_fillrect(x*checker, y*checker,
+ x*checker + checker, y*checker + checker,
+ Color(100, 100, 100));
+ else
+ gc.draw_fillrect(x*checker, y*checker,
+ x*checker + checker, y*checker + checker,
+ Color(0, 0, 0));
+ }
+
+ gc.print_left(Fonts::chalk_large, 10, 10, "Pingus - Font Test");
+
+ gc.push_modelview();
+ gc.translate(scrollx, scrolly);
+
+ for(int i = 0; i < 256; ++i)
+ {
+ int x = 64 + (i%20)*(font.get_height() + 4);
+ int y = 64 + (i/20)*(font.get_height() + 6);
+
+ if (font.get_width(char(i)))
+ {
+ gc.draw_rect(x, y,
+ x+font.get_width(char(i)),
+ y+font.get_height(),
+ Color(255,0,255));
+ gc.print_left(font,
+ x, y,
+ std::string(1, char(i)));
+ }
+ else
+ {
+ gc.draw_rect(x, y,
+ x+font.get_height(),
+ y+font.get_height(),
+ Color(255,0,0));
+ }
+ }
+ gc.pop_modelview();
+
+ return true;
+}
+
+void
+FontTestScreen::update (const GameDelta& delta)
+{
+ const Input::EventLst& events = delta.get_events ();
+
+ for (Input::EventLst::const_iterator i = events.begin ();
+ i != events.end ();
+ ++i)
+ {
+ switch (i->type)
+ {
+ case Input::ScrollEventType:
+ scrollx += i->scroll.x_delta;
+ scrolly += i->scroll.y_delta;
+ break;
+
+ default:
+ break;
+ }
+ }
+}
+
+/* EOF */
Property changes on: branches/pingus_sdl/src/font_test_screen.cpp
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: branches/pingus_sdl/src/font_test_screen.hpp
===================================================================
--- branches/pingus_sdl/src/font_test_screen.hpp 2007-08-04 18:23:29 UTC
(rev 2797)
+++ branches/pingus_sdl/src/font_test_screen.hpp 2007-08-04 19:26:45 UTC
(rev 2798)
@@ -0,0 +1,53 @@
+/* $Id$
+** __ __ __ ___ __ __ __ __
+** / \ / \__| ____ __| _/_______/ |_|__| | | | ____
+** \ \/\/ / |/ \ / __ |/ ___/\ __\ | | | | _/ __ \
+** \ /| | | \/ /_/ |\___ \ | | | | |_| |_\ ___/
+** \__/\ / |__|___| /\____ /____ > |__| |__|____/____/\___ >
+** \/ \/ \/ \/ \/
+** Copyright (C) 2007 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_TEST_SCREEN_HPP
+#define HEADER_FONT_TEST_SCREEN_HPP
+
+#include "gui/screen.hpp"
+#include "font.hpp"
+
+/** */
+class FontTestScreen : public Screen
+{
+private:
+ Font font;
+ float scrollx;
+ float scrolly;
+
+public:
+ FontTestScreen(const std::string& fontfile);
+
+ bool draw(DrawingContext& gc);
+ void update (const GameDelta& delta);
+
+private:
+ FontTestScreen (const FontTestScreen&);
+ FontTestScreen& operator= (const FontTestScreen&);
+};
+
+#endif
+
+/* EOF */
Property changes on: branches/pingus_sdl/src/font_test_screen.hpp
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified: branches/pingus_sdl/src/pingus_main.cpp
===================================================================
--- branches/pingus_sdl/src/pingus_main.cpp 2007-08-04 18:23:29 UTC (rev
2797)
+++ branches/pingus_sdl/src/pingus_main.cpp 2007-08-04 19:26:45 UTC (rev
2798)
@@ -78,6 +78,7 @@
#include "cheat.hpp"
// #include "blitter_test.hpp"
// #include "preview_renderer.hpp"
+#include "font_test_screen.hpp"
#include "worldmap/manager.hpp"
#include "worldobj_factory.hpp"
@@ -226,6 +227,8 @@
_("Load a custom worldmap from FILE"));
argp.add_option('e', "editor", "",
_("Loads the level editor"));
+ argp.add_option(363, "font", "FILE",
+ _("Test a font"));
argp.add_option('v', "verbose", "",
_("Print some more messages to stdout, can be set multiple
times to increase verbosity"));
argp.add_option('V', "version", "",
@@ -524,6 +527,10 @@
blitter_test = true;
break;
+ case 363: // font test
+ fontfile = argp.get_argument();
+ break;
+
case 'h':
argp.print_help();
exit(EXIT_SUCCESS);
@@ -692,6 +699,10 @@
{
//ScreenManager::instance()->push_screen(new InputDebugScreen (), true);
}
+ else if (!fontfile.empty())
+ {
+ ScreenManager::instance()->push_screen(new FontTestScreen(fontfile),
true);
+ }
else if (render_preview)
{
if (levelfile.empty())
Modified: branches/pingus_sdl/src/pingus_main.hpp
===================================================================
--- branches/pingus_sdl/src/pingus_main.hpp 2007-08-04 18:23:29 UTC (rev
2797)
+++ branches/pingus_sdl/src/pingus_main.hpp 2007-08-04 19:26:45 UTC (rev
2798)
@@ -38,6 +38,7 @@
/// the name of the exe: argv[0]
std::string executable_name;
std::string levelfile;
+ std::string fontfile;
/** Filename to which the level preview should be saved */
std::string preview_file;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] r2798 - branches/pingus_sdl/src,
grumbel at BerliOS <=