From: <the...@us...> - 2007-06-23 00:35:07
|
Revision: 58 http://qonk.svn.sourceforge.net/qonk/?rev=58&view=rev Author: thebohemian Date: 2007-06-22 17:35:05 -0700 (Fri, 22 Jun 2007) Log Message: ----------- - preliminary menu system and some autoconf fixes Modified Paths: -------------- branches/input-abstraction-2007-06-12/config.h.in branches/input-abstraction-2007-06-12/configure.ac branches/input-abstraction-2007-06-12/guichan/guichan/Makefile.am branches/input-abstraction-2007-06-12/src/Makefile.am branches/input-abstraction-2007-06-12/src/main.cpp branches/input-abstraction-2007-06-12/src/sdl_driver.cpp Added Paths: ----------- branches/input-abstraction-2007-06-12/src/menu.cpp branches/input-abstraction-2007-06-12/src/menu.h Modified: branches/input-abstraction-2007-06-12/config.h.in =================================================================== --- branches/input-abstraction-2007-06-12/config.h.in 2007-06-22 23:46:58 UTC (rev 57) +++ branches/input-abstraction-2007-06-12/config.h.in 2007-06-23 00:35:05 UTC (rev 58) @@ -12,6 +12,9 @@ /* Define to 1 if you have the `SDL_gfx' library (-lSDL_gfx). */ #undef HAVE_LIBSDL_GFX +/* Define to 1 if you have the `SDL_image' library (-lSDL_image). */ +#undef HAVE_LIBSDL_IMAGE + /* Define to 1 if you have the `SDL_ttf' library (-lSDL_ttf). */ #undef HAVE_LIBSDL_TTF @@ -27,6 +30,9 @@ /* Define to 1 if you have the <SDL/SDL.h> header file. */ #undef HAVE_SDL_SDL_H +/* Define to 1 if you have the <SDL/SDL_image.h> header file. */ +#undef HAVE_SDL_SDL_IMAGE_H + /* Define to 1 if you have the <SDL/SDL_ttf.h> header file. */ #undef HAVE_SDL_SDL_TTF_H Modified: branches/input-abstraction-2007-06-12/configure.ac =================================================================== --- branches/input-abstraction-2007-06-12/configure.ac 2007-06-22 23:46:58 UTC (rev 57) +++ branches/input-abstraction-2007-06-12/configure.ac 2007-06-23 00:35:05 UTC (rev 58) @@ -24,10 +24,11 @@ AC_CHECK_LIB([SDL], [SDL_Init]) AC_CHECK_LIB([SDL_ttf], [TTF_Init], ,AC_MSG_ERROR([SDL_ttf missing. Please install at least version 2.0!])) AC_CHECK_LIB([SDL_gfx], [pixelColor], ,AC_MSG_ERROR([SDL_gfx missing. Please install at least version 1.2!])) +AC_CHECK_LIB([SDL_image], [IMG_Load], ,AC_MSG_ERROR([SDL_image missing. Please install at least version 1.2!])) # Checks for header files. AC_HEADER_STDC -AC_CHECK_HEADERS([stdlib.h SDL/SDL.h SDL/SDL_gfxPrimitives.h SDL/SDL_ttf.h]) +AC_CHECK_HEADERS([stdlib.h SDL/SDL.h SDL/SDL_gfxPrimitives.h SDL/SDL_ttf.h SDL/SDL_image.h]) # Checks for typedefs, structures, and compiler characteristics. AC_HEADER_STDBOOL Modified: branches/input-abstraction-2007-06-12/guichan/guichan/Makefile.am =================================================================== --- branches/input-abstraction-2007-06-12/guichan/guichan/Makefile.am 2007-06-22 23:46:58 UTC (rev 57) +++ branches/input-abstraction-2007-06-12/guichan/guichan/Makefile.am 2007-06-23 00:35:05 UTC (rev 58) @@ -6,9 +6,9 @@ libguichan_a_LIBADD = widgets/libguichan_widgets.a sdl/libguichan_sdl.a -libguichan_a_DEPENDENCIES = \ - widgets/libguichan_widgets.a \ - sdl/libguichan_sdl.a +#libguichan_a_DEPENDENCIES = \ +# widgets/libguichan_widgets.a \ +# sdl/libguichan_sdl.a # The Gui-chan library sources libguichan_a_SOURCES = \ Modified: branches/input-abstraction-2007-06-12/src/Makefile.am =================================================================== --- branches/input-abstraction-2007-06-12/src/Makefile.am 2007-06-22 23:46:58 UTC (rev 57) +++ branches/input-abstraction-2007-06-12/src/Makefile.am 2007-06-23 00:35:05 UTC (rev 58) @@ -6,7 +6,10 @@ bin_PROGRAMS = qonk -qonk_LDADD = lisp/liblisp.a $(top_srcdir)/guichan/guichan/libguichan.a +qonk_LDADD = lisp/liblisp.a\ + $(top_builddir)/guichan/guichan/sdl/libguichan_sdl.a\ + $(top_builddir)/guichan/guichan/widgets/libguichan_widgets.a\ + $(top_builddir)/guichan/guichan/libguichan.a qonk_SOURCES = " \ actions.cpp \ @@ -21,6 +24,8 @@ extensions.h \ fonts.cpp \ fonts.h \ + menu.cpp \ + menu.h \ game.cpp \ game.h \ input.h \ Modified: branches/input-abstraction-2007-06-12/src/main.cpp =================================================================== --- branches/input-abstraction-2007-06-12/src/main.cpp 2007-06-22 23:46:58 UTC (rev 57) +++ branches/input-abstraction-2007-06-12/src/main.cpp 2007-06-23 00:35:05 UTC (rev 58) @@ -13,8 +13,6 @@ #include "main.h" #include "sdl_driver.h" -#include "guichan/guichan.hpp" - #include <iostream> #include <iomanip> #include <sstream> Added: branches/input-abstraction-2007-06-12/src/menu.cpp =================================================================== --- branches/input-abstraction-2007-06-12/src/menu.cpp (rev 0) +++ branches/input-abstraction-2007-06-12/src/menu.cpp 2007-06-23 00:35:05 UTC (rev 58) @@ -0,0 +1,96 @@ +#include "menu.h" + +#include "guichan/guichan/sdl.hpp" + +#include <iostream> + +using namespace gcn; +using namespace std; + +Menu::Menu() +{ + gui = new Gui(); + SDLInput *input = new SDLInput(); + + gui->setInput(input); + gui->setGraphics(new SDLGraphics()); + Image::setImageLoader(new SDLImageLoader()); + + normal = loadFont("techyfontbig2.png"); + highlighted = loadFont("techyfontbighighlight.png"); + + top = new Container(); + top->setOpaque(false); + + TextBox *box = new TextBox("qonk"); + box->setFont(normal); + box->setEditable(false); + box->setFocusable(false); + top->add(box); + + gui->setTop(top); + +} + +Menu::~Menu() +{ + delete highlighted; + delete normal; + + delete top; + delete gui; +} + +void +Menu::render() +{ + gui->draw(); +} + +void +Menu::update() +{ + gui->logic(); +} + +ImageFont * +Menu::loadFont(string fileName) +{ + ImageFont *font = 0; + std::string s = PKG_DATA_DIR; + s += fileName; + + try + { + font = new ImageFont(s, " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,!?-+/():;%&`'*#=[]\""); + return font; + } + catch (gcn::Exception &e) + { + } + + s = "data"; +#ifdef WINDOWS + s += "\\"; +#else + s += "/"; +#endif + s += fileName; + + try + { + font = new ImageFont(s, " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,!?-+/():;%&`'*#=[]\""); + return font; + } + catch (gcn::Exception &e) + { + } + + cerr << "Could not load " << fileName << " from the following directories: " << endl + << PKG_DATA_DIR << endl + << "data" << endl; + + exit( 1 ); + + return 0; +} Added: branches/input-abstraction-2007-06-12/src/menu.h =================================================================== --- branches/input-abstraction-2007-06-12/src/menu.h (rev 0) +++ branches/input-abstraction-2007-06-12/src/menu.h 2007-06-23 00:35:05 UTC (rev 58) @@ -0,0 +1,33 @@ +// menu.h +// +// (c) Robert Schuster, 2007 +// +// Licensed under GNU GPL version 2 or, at your option, any later version. + +#ifndef MENU_H +#define MENU_H + +#include "guichan/guichan.hpp" + +class Menu +{ + gcn::Gui *gui; + + gcn::ImageFont *normal; + gcn::ImageFont *highlighted; + + gcn::Container *top; + + static gcn::ImageFont *loadFont(std::string); + + public: + Menu(); + ~Menu(); + + void render(); + + void update(); + +}; + +#endif Modified: branches/input-abstraction-2007-06-12/src/sdl_driver.cpp =================================================================== --- branches/input-abstraction-2007-06-12/src/sdl_driver.cpp 2007-06-22 23:46:58 UTC (rev 57) +++ branches/input-abstraction-2007-06-12/src/sdl_driver.cpp 2007-06-23 00:35:05 UTC (rev 58) @@ -25,6 +25,7 @@ std::cerr << "Couldn't initialize SDL: " << SDL_GetError() << std::endl; exit( 1 ); } + SDL_EnableUNICODE(SDL_ENABLE); timer.start(); atexit( SDL_Quit ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |