From: <the...@us...> - 2007-07-28 10:17:50
|
Revision: 89 http://qonk.svn.sourceforge.net/qonk/?rev=89&view=rev Author: thebohemian Date: 2007-07-28 03:17:49 -0700 (Sat, 28 Jul 2007) Log Message: ----------- - removed unneeded files Removed Paths: ------------- trunk/src/readconf.cpp trunk/src/readconf.h Deleted: trunk/src/readconf.cpp =================================================================== --- trunk/src/readconf.cpp 2007-07-28 10:16:24 UTC (rev 88) +++ trunk/src/readconf.cpp 2007-07-28 10:17:49 UTC (rev 89) @@ -1,170 +0,0 @@ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <sys/stat.h> - -#include "readconf.h" - -Config *Config::instance = 0; - -Config& -Config::getInstance() { - if (!instance) { - instance = new Config("qonk.settings"); - } - - return *instance; -} - -Config::Config( const std::string& configFileName ){ - std::string pathname = ""; -#ifdef WINDOWS - // Do nothing. Falls back to application directory. -#elif MAC_OSX - // Get from some mysterious directory ... -#else - // GNU/LINUX/BSD/POSIX/... - if(getenv("HOME")!=NULL) { - pathname = getenv("HOME"); - pathname += "/.qonk/"; - mkdir(pathname.c_str(), 0755); - } -#endif - - fileName = pathname + configFileName; -} - -bool -Config::load() { - if( !fileExists(fileName)) - return false; - - std::ifstream file( fileName.c_str() ); - while (!file.eof()){ - std::string line; - getline( file, line ); - - std::string::size_type loc = line.find( "=", 0 ); - if( line[0] != '#' ) - if( loc != std::string::npos ) { - std::string parameter = stripWhiteSpace( line.substr( 0, loc ) ); - std::string value = stripWhiteSpace( line.substr( loc + 1 ) ); - data[parameter] = value; - } - } - file.close(); - - return true; -} - -bool -Config::save() { - std::ofstream outfile( fileName.c_str() ); - for( std::map< std::string, std::string >::const_iterator i = data.begin(); i != data.end(); i++ ) { - std::string temp = i->first + "=" + i->second; - outfile.write( temp.data(), temp.size() ); - outfile.write( "\n", 1 ); - } - outfile.close(); - - return true; -} - -std::string -Config::getValue( const std::string& parameter, std::string defaultValue ) const { - std::map< std::string, std::string >::const_iterator i = data.find( parameter ); - if( i != data.end() ) - return i->second; - else - return defaultValue; -} - -void -Config::setValue( const std::string& parameter, std::string value) { - data[parameter] = value; -} - -bool -Config::getValueAsBool( const std::string& parameter, bool defaultValue ) const { - std::map< std::string, std::string >::const_iterator i = data.find( parameter ); - if( i != data.end() ) - return fromString<bool>(i->second); - else - return defaultValue; -} - -void -Config::setValue( const std::string& parameter, bool value) { - data[parameter] = toString<bool>(value); -} - -int -Config::getValueAsInt( const std::string& parameter, int defaultValue ) const { - std::map< std::string, std::string >::const_iterator i = data.find( parameter ); - if( i != data.end() ) - { - return fromString<int>(i->second); - } - else - return defaultValue; -} - -void -Config::setValue( const std::string& parameter, int value) { - data[parameter] = toString<int>(value); -} - -void -Config::print() const { - for( std::map< std::string, std::string >::const_iterator i = data.begin(); i != data.end(); i++ ) - std::cout << "'" << i->first << "' => '" << i->second << "'" << std::endl; -} - -template <typename T> -T -Config::fromString( const std::string& s) { - std::istringstream iss(s); - - T target; - - iss >> target; - - return target; -} - -template <typename T> -std::string -Config::toString( const T& t) { - std::ostringstream oss; - - oss << t; - - return oss.str(); -} - -bool -fileExists( const std::string& fileName ) { - std::ifstream infile( fileName.c_str() ); - bool result = infile.good(); - infile.close(); - return result; -} - -bool -str2bool( const std::string& s ) { - if (s == std::string("true")) { - return true; - } else if (s == std::string("false")){ - return false; - } else { - std::cerr << "Invalid bool type"; - } -} - -std::string -stripWhiteSpace( const std::string& original ) { - int begin = original.find_first_not_of( " " ); - int end = original.find_last_not_of( " " ); - return original.substr( begin, end - begin + 1 ); -} Deleted: trunk/src/readconf.h =================================================================== --- trunk/src/readconf.h 2007-07-28 10:16:24 UTC (rev 88) +++ trunk/src/readconf.h 2007-07-28 10:17:49 UTC (rev 89) @@ -1,53 +0,0 @@ -// ReadConf.h -// Class for reading named values from configuration files -// Troels Kofoed Jacobsen, Mar 19 2007, tkj...@gm... -// Licensed under GPLv2 -#ifndef READCONF_H -#define READCONF_H - -#include <string> -#include <map> -#include <vector> -#include <fstream> -#include <iostream> -#include <cctype> -#include <sstream> - -class Config { - -public: - static Config& getInstance(); - - bool load(); - bool save(); - - std::string getValue( const std::string& parameter, std::string defaultValue = "") const; - void setValue (const std::string &, std::string value); - - bool getValueAsBool( const std::string& parameter, bool defaultValue = false ) const; - void setValue (const std::string &, bool value); - - int getValueAsInt( const std::string& parameter, int defaultValue = 0 ) const; - void setValue (const std::string &, int value); - - void print() const; - -private: - Config( const std::string& fileName ); - - template <typename T> static T fromString(const std::string&); - - template <typename T> static std::string toString(const T&); - - std::map< std::string, std::string > data; - - std::string fileName; - - static Config *instance; -}; - -bool fileExists( const std::string& ); -bool str2bool(const std::string& ); -std::string stripWhiteSpace( const std::string& ); - -#endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2007-09-09 15:21:45
|
Revision: 101 http://qonk.svn.sourceforge.net/qonk/?rev=101&view=rev Author: thebohemian Date: 2007-09-09 08:21:35 -0700 (Sun, 09 Sep 2007) Log Message: ----------- - fixed canceling input change Modified Paths: -------------- trunk/src/controloptions.cpp trunk/src/menu.cpp trunk/src/menumanager.cpp trunk/src/menusystem.cpp trunk/src/menusystem.h Modified: trunk/src/controloptions.cpp =================================================================== --- trunk/src/controloptions.cpp 2007-09-09 14:58:32 UTC (rev 100) +++ trunk/src/controloptions.cpp 2007-09-09 15:21:35 UTC (rev 101) @@ -83,8 +83,13 @@ label->setCaption(base + Settings::getAsString(gameAction)); label->adjustSize(); sensing = false; + + // Report that an operation was interrupted (prevents + // menu being left or menu system made invisible). + return true; } - return sensing; + + return false; } void reset() Modified: trunk/src/menu.cpp =================================================================== --- trunk/src/menu.cpp 2007-09-09 14:58:32 UTC (rev 100) +++ trunk/src/menu.cpp 2007-09-09 15:21:35 UTC (rev 101) @@ -142,6 +142,8 @@ entries->at(selected)->getWidget()->setFont(menuSystem->getHighlightedFont()); menuSystem->enter(parentMenuId); + + cerr << "nothing was canceled" << endl; } } Modified: trunk/src/menumanager.cpp =================================================================== --- trunk/src/menumanager.cpp 2007-09-09 14:58:32 UTC (rev 100) +++ trunk/src/menumanager.cpp 2007-09-09 15:21:35 UTC (rev 101) @@ -137,6 +137,6 @@ if (b) menuSystem->invoke(); else - menuSystem->leave(); + menuSystem->cancel(); } Modified: trunk/src/menusystem.cpp =================================================================== --- trunk/src/menusystem.cpp 2007-09-09 14:58:32 UTC (rev 100) +++ trunk/src/menusystem.cpp 2007-09-09 15:21:35 UTC (rev 101) @@ -237,10 +237,10 @@ } void -MenuSystem::leave() +MenuSystem::cancel() { if (currentMenu) - currentMenu->leave(); + currentMenu->cancel(); } @@ -252,7 +252,7 @@ void MenuSystem::KeyListener::keyReleased(KeyEvent &keyEvent) { - // MenuSystem does handle making itself visible. This is done from main. + // MenuSystem does not handle making itself visible. This is done from main. if (!system.currentMenu) return; Modified: trunk/src/menusystem.h =================================================================== --- trunk/src/menusystem.h 2007-09-09 14:58:32 UTC (rev 100) +++ trunk/src/menusystem.h 2007-09-09 15:21:35 UTC (rev 101) @@ -63,7 +63,7 @@ void enter(Menu::Id = Menu::MAIN); - void leave(); + void cancel(); void invoke(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2007-09-09 15:32:02
|
Revision: 102 http://qonk.svn.sourceforge.net/qonk/?rev=102&view=rev Author: thebohemian Date: 2007-09-09 08:31:59 -0700 (Sun, 09 Sep 2007) Log Message: ----------- - added some docs Modified Paths: -------------- trunk/src/menu.h trunk/src/menumanager.h trunk/src/menusystem.h Modified: trunk/src/menu.h =================================================================== --- trunk/src/menu.h 2007-09-09 15:21:35 UTC (rev 101) +++ trunk/src/menu.h 2007-09-09 15:31:59 UTC (rev 102) @@ -55,8 +55,12 @@ void registered(MenuSystem *); + /** Unconditionally make this menu visible. + */ void enter(); + /** Unconditionally make this menu invisible. + */ void leave(); gcn::Container *getContainer() const; @@ -67,6 +71,9 @@ void down(); + /** Cancels the operation of the currently selected widget. If there + * was no operation activate the parent menu. + */ void cancel(); void invoke(); Modified: trunk/src/menumanager.h =================================================================== --- trunk/src/menumanager.h 2007-09-09 15:21:35 UTC (rev 101) +++ trunk/src/menumanager.h 2007-09-09 15:31:59 UTC (rev 102) @@ -51,6 +51,14 @@ bool update(); + /** Indicate that input sensing should be finished. + * + * If a new input has been determined and the operation should + * end as succeeded the argument's value is <code>true</code>. + * + * If the operation should end as cancelled the argument's value + * is <code>false</code>. + * */ void senseFinished(bool); GameOptions &getGameOptions() const { return *gameOptions; }; Modified: trunk/src/menusystem.h =================================================================== --- trunk/src/menusystem.h 2007-09-09 15:21:35 UTC (rev 101) +++ trunk/src/menusystem.h 2007-09-09 15:31:59 UTC (rev 102) @@ -63,6 +63,18 @@ void enter(Menu::Id = Menu::MAIN); + /** Cancels whatever operation is currently in progress. + * + * At the moment the following operations are known: + * <ul> + * <li>A widget may have initiated the input sensing mode. If it is + * canceled the input mapping will not change.</li> + * + * <li>A certain submenu is open. On canceling it will get close and + * enter its parent menu.</li> + * + * <li>The main menu is open. On canceling it will be hidden.</li> + */ void cancel(); void invoke(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2007-09-09 16:30:07
|
Revision: 103 http://qonk.svn.sourceforge.net/qonk/?rev=103&view=rev Author: thebohemian Date: 2007-09-09 09:30:02 -0700 (Sun, 09 Sep 2007) Log Message: ----------- - already set mappings are properly removed (and screen updates correctly) Modified Paths: -------------- trunk/src/controloptions.cpp trunk/src/menu.cpp trunk/src/settings.cpp trunk/src/settings.h Modified: trunk/src/controloptions.cpp =================================================================== --- trunk/src/controloptions.cpp 2007-09-09 15:31:59 UTC (rev 102) +++ trunk/src/controloptions.cpp 2007-09-09 16:30:02 UTC (rev 103) @@ -28,6 +28,11 @@ ControlOptions::finishSensing(GameAction ga, bool b) { main.finishSensing(ga, b); + + map <GameAction, MenuAction * >::iterator iter; + for( iter = controlActions.begin(); iter != controlActions.end(); iter++ ) { + iter->second->update(); + } } void @@ -62,8 +67,6 @@ if (sensing) { controlOptions.finishSensing(gameAction, true); - label->setCaption(base + Settings::getAsString(gameAction)); - label->adjustSize(); sensing = false; } else @@ -80,8 +83,6 @@ if (sensing) { controlOptions.finishSensing(gameAction, false); - label->setCaption(base + Settings::getAsString(gameAction)); - label->adjustSize(); sensing = false; // Report that an operation was interrupted (prevents @@ -98,6 +99,13 @@ label->setCaption(base + Settings::getAsString(gameAction)); label->adjustSize(); } + + void update() + { + label->setCaption(base + Settings::getAsString(gameAction)); + label->adjustSize(); + } + }; MenuAction * Modified: trunk/src/menu.cpp =================================================================== --- trunk/src/menu.cpp 2007-09-09 15:31:59 UTC (rev 102) +++ trunk/src/menu.cpp 2007-09-09 16:30:02 UTC (rev 103) @@ -142,8 +142,6 @@ entries->at(selected)->getWidget()->setFont(menuSystem->getHighlightedFont()); menuSystem->enter(parentMenuId); - - cerr << "nothing was canceled" << endl; } } Modified: trunk/src/settings.cpp =================================================================== --- trunk/src/settings.cpp 2007-09-09 15:31:59 UTC (rev 102) +++ trunk/src/settings.cpp 2007-09-09 16:30:02 UTC (rev 103) @@ -326,15 +326,65 @@ void Settings::unset(GameAction ga) { - // Deletion is implemented by shift the value to the left - // and creating an empty entry in the 2nd location. - inputMap[ga][0] = inputMap[ga][1]; - inputMap[ga][1].inputType = IT_NONE; + // Deletes the 2nd entry if it exists or + // the first if not. + if (inputMap[ga][1].inputType != IT_NONE) + inputMap[ga][1].inputType = IT_NONE; + else + inputMap[ga][0].inputType = IT_NONE; } void +Settings::unsetDuplicates (GameAction ga, InputType it, int id0, int id1, int id2) +{ + for (int cga = GA_FIRST; cga < GA_COUNT; cga++) + { + if (cga != ga) + { + // If the input occurs in any other mapping + // delete it properly from there. + + if (inputMap[cga][1].inputType == it + && inputMap[cga][1].id0 == id0 + && inputMap[cga][1].id1 == id1 + && inputMap[cga][1].id2 == id2) + { + // Deletes it from the 2nd entry. + inputMap[cga][1].inputType = IT_NONE; + } + + if (inputMap[cga][0].inputType == it + && inputMap[cga][0].id0 == id0 + && inputMap[cga][0].id1 == id1 + && inputMap[cga][0].id2 == id2) + { + // Deletes it from the 1st entry and + // shifts the 2nd to the first. + inputMap[cga][0] = inputMap[cga][1]; + inputMap[cga][1].inputType = IT_NONE; + } + } + } +} + +void Settings::set(GameAction ga, InputType it, int id0, int id1, int id2) { + // Do not change anything if the sensed input already + // exists for the game action. + if (inputMap[ga][0].inputType == it + && inputMap[ga][0].id0 == id0 + && inputMap[ga][0].id1 == id1 + && inputMap[ga][0].id2 == id2 + || inputMap[ga][1].inputType == it + && inputMap[ga][1].id0 == id0 + && inputMap[ga][1].id1 == id1 + && inputMap[ga][1].id2 == id2) + return; + + // Removes the input from all mappings where it occurs. + unsetDuplicates(ga, it, id0, id1, id2); + // Setting a new value is implemented by shifting the value to the // right and applying the new values in the 1st location. Modified: trunk/src/settings.h =================================================================== --- trunk/src/settings.h 2007-09-09 15:31:59 UTC (rev 102) +++ trunk/src/settings.h 2007-09-09 16:30:02 UTC (rev 103) @@ -33,11 +33,19 @@ static void readInput(const lisp::Lisp *, const char *, GameAction); static void setupDefaultActionMap(); static void set(GameAction, InputType, int, int, int); + + /** Iterates through the input mapping and unsets all + * where the given input occurs. + * + * This makes sure an input is not bound multiple times. + */ + static void unsetDuplicates(GameAction, InputType, int, int, int); static std::string getConfigFilePath(); static bool fileExists(const std::string&); static std::string getInputAsString(Input &); + public: static void init(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2007-09-11 18:30:24
|
Revision: 106 http://qonk.svn.sourceforge.net/qonk/?rev=106&view=rev Author: thebohemian Date: 2007-09-11 11:30:22 -0700 (Tue, 11 Sep 2007) Log Message: ----------- - created a release branch for 0.3.x Modified Paths: -------------- branches/qonk-0.3-release/configure.ac branches/qonk-0.3-release/src/Makefile.am branches/qonk-0.3-release/src/controloptions.cpp branches/qonk-0.3-release/src/gameoptions.cpp branches/qonk-0.3-release/src/main.cpp branches/qonk-0.3-release/src/menumanager.cpp branches/qonk-0.3-release/src/menumanager.h branches/qonk-0.3-release/src/videooptions.cpp trunk/configure.ac trunk/src/Makefile.am trunk/src/controloptions.cpp trunk/src/gameoptions.cpp trunk/src/main.cpp trunk/src/menumanager.cpp trunk/src/menumanager.h trunk/src/videooptions.cpp Added Paths: ----------- branches/qonk-0.3-release/ branches/qonk-0.3-release/BRANCH-README branches/qonk-0.3-release/src/ui/ branches/qonk-0.3-release/src/ui/Makefile.am branches/qonk-0.3-release/src/ui/menu.cpp branches/qonk-0.3-release/src/ui/menu.h branches/qonk-0.3-release/src/ui/menuaction.cpp branches/qonk-0.3-release/src/ui/menuaction.h branches/qonk-0.3-release/src/ui/menuentry.cpp branches/qonk-0.3-release/src/ui/menuentry.h branches/qonk-0.3-release/src/ui/menusystem.cpp branches/qonk-0.3-release/src/ui/menusystem.h releases/qonk-0.3.0/ releases/qonk-0.3.0/HISTORY releases/qonk-0.3.0/INSTALL releases/qonk-0.3.0/Makefile.am releases/qonk-0.3.0/README releases/qonk-0.3.0/THANKYOU releases/qonk-0.3.0/TODO releases/qonk-0.3.0/configure.ac releases/qonk-0.3.0/guichan/guichan/Makefile.am releases/qonk-0.3.0/src/Makefile.am releases/qonk-0.3.0/src/controloptions.cpp releases/qonk-0.3.0/src/lisp/Makefile.am releases/qonk-0.3.0/src/menu.cpp releases/qonk-0.3.0/src/menu.h releases/qonk-0.3.0/src/menumanager.cpp releases/qonk-0.3.0/src/menumanager.h releases/qonk-0.3.0/src/menusystem.cpp releases/qonk-0.3.0/src/menusystem.h releases/qonk-0.3.0/src/settings.cpp releases/qonk-0.3.0/src/settings.h trunk/src/ui/ trunk/src/ui/Makefile.am trunk/src/ui/menu.cpp trunk/src/ui/menu.h trunk/src/ui/menuaction.cpp trunk/src/ui/menuaction.h trunk/src/ui/menuentry.cpp trunk/src/ui/menuentry.h trunk/src/ui/menusystem.cpp trunk/src/ui/menusystem.h Removed Paths: ------------- branches/qonk-0.3-release/src/menu.cpp branches/qonk-0.3-release/src/menu.h branches/qonk-0.3-release/src/menuaction.cpp branches/qonk-0.3-release/src/menuaction.h branches/qonk-0.3-release/src/menuentry.cpp branches/qonk-0.3-release/src/menuentry.h branches/qonk-0.3-release/src/menusystem.cpp branches/qonk-0.3-release/src/menusystem.h releases/qonk-0.3.0/HISTORY releases/qonk-0.3.0/Makefile.am releases/qonk-0.3.0/README releases/qonk-0.3.0/TODO releases/qonk-0.3.0/configure.ac releases/qonk-0.3.0/guichan/guichan/Makefile.am releases/qonk-0.3.0/src/Makefile.am releases/qonk-0.3.0/src/controloptions.cpp releases/qonk-0.3.0/src/lisp/Makefile.am releases/qonk-0.3.0/src/menu.cpp releases/qonk-0.3.0/src/menu.h releases/qonk-0.3.0/src/menumanager.cpp releases/qonk-0.3.0/src/menumanager.h releases/qonk-0.3.0/src/menusystem.cpp releases/qonk-0.3.0/src/menusystem.h releases/qonk-0.3.0/src/settings.cpp releases/qonk-0.3.0/src/settings.h trunk/src/menu.cpp trunk/src/menu.h trunk/src/menuaction.cpp trunk/src/menuaction.h trunk/src/menuentry.cpp trunk/src/menuentry.h trunk/src/menusystem.cpp trunk/src/menusystem.h Copied: branches/qonk-0.3-release (from rev 105, trunk) Added: branches/qonk-0.3-release/BRANCH-README =================================================================== --- branches/qonk-0.3-release/BRANCH-README (rev 0) +++ branches/qonk-0.3-release/BRANCH-README 2007-09-11 18:30:22 UTC (rev 106) @@ -0,0 +1,5 @@ +This is the Release branch for 0.3.x releases: Backport and commit all patches +to this branch. + +After that create "svn copy" it to a release/ folder, delete this file from +the release and create a tarball (make dist). Modified: branches/qonk-0.3-release/configure.ac =================================================================== --- trunk/configure.ac 2007-09-11 09:02:05 UTC (rev 105) +++ branches/qonk-0.3-release/configure.ac 2007-09-11 18:30:22 UTC (rev 106) @@ -41,6 +41,7 @@ AC_CONFIG_FILES([Makefile data/Makefile src/lisp/Makefile + src/ui/Makefile src/Makefile guichan/Makefile guichan/guichan/Makefile Modified: branches/qonk-0.3-release/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2007-09-11 09:02:05 UTC (rev 105) +++ branches/qonk-0.3-release/src/Makefile.am 2007-09-11 18:30:22 UTC (rev 106) @@ -1,14 +1,15 @@ -SUBDIRS = lisp +SUBDIRS = lisp ui -AM_CPPFLAGS=-DPKG_DATA_DIR="\"$(pkgdatadir)/\"" - INCLUDES = -I$(top_srcdir)/guichan +AM_CPPFLAGS=-DPKG_DATA_DIR="\"$(pkgdatadir)/\"" + bin_PROGRAMS = qonk -qonk_LDADD = lisp/liblisp.a\ - $(top_builddir)/guichan/guichan/sdl/libguichan_sdl.a\ - $(top_builddir)/guichan/guichan/widgets/libguichan_widgets.a\ +qonk_LDADD = lisp/liblisp.a \ + ui/libui.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 = \ @@ -26,16 +27,8 @@ extensions.h \ fonts.cpp \ fonts.h \ - menu.cpp \ - menu.h \ - menuaction.cpp \ - menuaction.h \ - menuentry.cpp \ - menuentry.h \ menumanager.cpp \ menumanager.h \ - menusystem.cpp \ - menusystem.h \ game.cpp \ game.h \ gameoptions.cpp \ Modified: branches/qonk-0.3-release/src/controloptions.cpp =================================================================== --- trunk/src/controloptions.cpp 2007-09-11 09:02:05 UTC (rev 105) +++ branches/qonk-0.3-release/src/controloptions.cpp 2007-09-11 18:30:22 UTC (rev 106) @@ -3,8 +3,9 @@ #include "guichan/guichan.hpp" +#include "ui/menuaction.h" + #include "controloptions.h" -#include "menuaction.h" #include "main.h" #include "settings.h" Modified: branches/qonk-0.3-release/src/gameoptions.cpp =================================================================== --- trunk/src/gameoptions.cpp 2007-09-11 09:02:05 UTC (rev 105) +++ branches/qonk-0.3-release/src/gameoptions.cpp 2007-09-11 18:30:22 UTC (rev 106) @@ -5,11 +5,12 @@ #include "guichan/guichan.hpp" +#include "ui/menuaction.h" + #include "settings.h" +#include "main.h" #include "gameoptions.h" -#include "menuaction.h" -#include "main.h" using namespace std; using namespace gcn; Modified: branches/qonk-0.3-release/src/main.cpp =================================================================== --- trunk/src/main.cpp 2007-09-11 09:02:05 UTC (rev 105) +++ branches/qonk-0.3-release/src/main.cpp 2007-09-11 18:30:22 UTC (rev 106) @@ -21,7 +21,6 @@ #include "videooptions.h" #include "gameoptions.h" - using namespace std; Main::Main() Deleted: branches/qonk-0.3-release/src/menu.cpp =================================================================== --- trunk/src/menu.cpp 2007-09-11 09:02:05 UTC (rev 105) +++ branches/qonk-0.3-release/src/menu.cpp 2007-09-11 18:30:22 UTC (rev 106) @@ -1,268 +0,0 @@ -#include "menu.h" - -#include <iostream> - -#include "menu.h" -#include "menusystem.h" -#include "menuentry.h" -#include "menuaction.h" - -using namespace gcn; -using namespace std; - -Menu::Menu(Id parentId, std::string menuTitle, int x) - : menuSystem(0), selected(-1), locx(x) -{ - parentMenuId = parentId; - container = new Container(); - - title = new Label(menuTitle); - container->add(title); - container->setOpaque(false); - container->setVisible(false); - - entries = new vector < MenuEntry * >(); -} - -Menu::~Menu() -{ - for (vector< MenuEntry * >::iterator i = entries->begin(); i != entries->end(); i++) - { - delete (*i); - } - - delete entries; - - delete container; -} - -void -Menu::addEntry(MenuEntry *entry) -{ - entries->push_back(entry); - - container->add(entry->getWidget()); - - if (menuSystem) - entry->registered(menuSystem); -} - -Container * -Menu::getContainer() const -{ - return container; -} - -void -Menu::enter() -{ - container->setVisible(true); - - if (selected == -1) - { - selected = 0; - entries->at(0)->getWidget()->setFont(menuSystem->getHighlightedFont()); - } -} - -void -Menu::leave() -{ - container->setVisible(false); -} - -void -Menu::registered(MenuSystem *system) -{ - menuSystem = system; - - for (vector< MenuEntry * >::iterator i = entries->begin(); i != entries->end(); i++) - (*i)->registered(system); - -} - -void -Menu::resize(int w, int h) -{ - container->setSize(w, h); - - int maxWidth = 0; - for (vector< MenuEntry * >::iterator i = entries->begin(); i != entries->end(); i++) - { - gcn::Widget *w = (*i)->getWidget(); - maxWidth = max(w->getWidth(), maxWidth); - } - - int x = (!locx) ? (w/2 - maxWidth/2) : locx; - int y = h/8; - - title->setPosition(x, y); - y += 2 * title->getHeight(); - - for (vector< MenuEntry * >::iterator i = entries->begin(); i != entries->end(); i++) - { - gcn::Widget *w = (*i)->getWidget(); - w->setPosition(x, y); - y += w->getHeight(); - } - -} - -void -Menu::up() -{ - entries->at(selected)->getWidget()->setFont(menuSystem->getNormalFont()); - - if (--selected < 0) - selected = entries->size()-1; - - entries->at(selected)->getWidget()->setFont(menuSystem->getHighlightedFont()); -} - -void -Menu::down() -{ - entries->at(selected)->getWidget()->setFont(menuSystem->getNormalFont()); - - if (++selected >= entries->size()) - selected = 0; - - entries->at(selected)->getWidget()->setFont(menuSystem->getHighlightedFont()); -} - -void -Menu::cancel() -{ - // If the cancel operation aborted some operation we skip going one - // menu level up. - if (!entries->at(selected)->cancel()) - { - entries->at(selected)->getWidget()->setFont(menuSystem->getNormalFont()); - selected = 0; - entries->at(selected)->getWidget()->setFont(menuSystem->getHighlightedFont()); - - menuSystem->enter(parentMenuId); - } -} - -void -Menu::reset() -{ - entries->at(selected)->reset(); -} - -void -Menu::invoke() -{ - entries->at(selected)->invoke(); -} - -void -Menu::next() -{ - entries->at(selected)->next(); -} - -void -Menu::previous() -{ - entries->at(selected)->previous(); -} - -class ActionEntry : public MenuEntry -{ - MenuAction *action; - - public: - ActionEntry(string s, MenuAction *a) - : action(a), MenuEntry(a->getWidget(s)) - { - } - - ~ActionEntry() - { - delete action; - } - - void invoke() - { - action->invoke(); - } - - void previous() - { - action->previous(); - } - - void next() - { - action->next(); - } - - /** Delegates the question if some action was - * cancelled or not to the action. - */ - bool cancel() - { - return action->cancel(); - } - - void reset() - { - action->reset(); - } - -}; - -void -Menu::addAction(string s, MenuAction *action) -{ - addEntry(new ActionEntry(s, action)); -} - -class LinkEntry : public MenuEntry -{ - Menu::Id target; - - public: - LinkEntry(string s, Menu::Id id) - : MenuEntry(new Label(s)), target(id) - { - } - - void invoke() - { - menuSystem->enter(target); - } - -}; - -void -Menu::addLink(string s, Menu::Id id) -{ - addEntry(new LinkEntry(s, id)); -} - -class BackLink : public MenuEntry -{ - Menu *menu; - - public: - BackLink(Menu *newMenu) - : MenuEntry(new Label("back")), menu(newMenu) - { - } - - void invoke() - { - menu->cancel(); - } - -}; - -void -Menu::addBackLink() -{ - addEntry(new BackLink(this)); -} - Deleted: branches/qonk-0.3-release/src/menu.h =================================================================== --- trunk/src/menu.h 2007-09-11 09:02:05 UTC (rev 105) +++ branches/qonk-0.3-release/src/menu.h 2007-09-11 18:30:22 UTC (rev 106) @@ -1,89 +0,0 @@ -// 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 <vector> - -#include "guichan/guichan.hpp" - -class MenuSystem; -class MenuEntry; -class MenuAction; - -class Menu -{ - public: - enum Id - { - NONE, MAIN, SINGLEPLAYER, MULTIPLAYER, OPTIONS, AUDIO_OPTIONS, VIDEO_OPTIONS, - CONTROL_OPTIONS - }; - - private: - - Id parentMenuId; - - gcn::Container *container; - - int selected; - - gcn::Label *title; - - std::vector < MenuEntry * > *entries; - - MenuSystem *menuSystem; - - int locx; - - public: - Menu(Id, std::string, int = 0); - - ~Menu(); - - void addEntry(MenuEntry *); - - void addAction(std::string, MenuAction *); - - void addLink(std::string, Menu::Id); - - void addBackLink(); - - void registered(MenuSystem *); - - /** Unconditionally make this menu visible. - */ - void enter(); - - /** Unconditionally make this menu invisible. - */ - void leave(); - - gcn::Container *getContainer() const; - - void resize(int, int); - - void up(); - - void down(); - - /** Cancels the operation of the currently selected widget. If there - * was no operation activate the parent menu. - */ - void cancel(); - - void invoke(); - - void next(); - - void previous(); - - void reset(); - -}; - -#endif Deleted: branches/qonk-0.3-release/src/menuaction.cpp =================================================================== --- trunk/src/menuaction.cpp 2007-09-11 09:02:05 UTC (rev 105) +++ branches/qonk-0.3-release/src/menuaction.cpp 2007-09-11 18:30:22 UTC (rev 106) @@ -1,18 +0,0 @@ -#include "guichan/guichan.hpp" - -#include "menuaction.h" -#include "main.h" - -using namespace std; - -gcn::Widget * -MenuAction::getWidget(string s) -{ - return new gcn::Label(s); -} - -void -QuitAction::invoke() -{ - main.quit(); -} Deleted: branches/qonk-0.3-release/src/menuaction.h =================================================================== --- trunk/src/menuaction.h 2007-09-11 09:02:05 UTC (rev 105) +++ branches/qonk-0.3-release/src/menuaction.h 2007-09-11 18:30:22 UTC (rev 106) @@ -1,48 +0,0 @@ -// menuaction.h -// -// (c) Robert Schuster, 2007 -// -// Licensed under GNU GPL version 2 or, at your option, any later version. - -#ifndef MENUACTION_H -#define MENUACTION_H - -#include "guichan/guichan.hpp" - -class Main; - -/* TODO: Realize all customized behavior with specific MenuEntry subclasses - * and remove the need for a MenuAction delegate object. - */ -class MenuAction -{ - public: - virtual gcn::Widget *getWidget(std::string); - - virtual void invoke() = 0; - - virtual void next() { }; - - virtual void previous() { }; - - virtual void update() { }; - - /** Returns true if some operation was cancelled or false if not. - */ - virtual bool cancel() { return false; } - - virtual void reset() { } -}; - -class QuitAction : public MenuAction -{ - Main &main; - - public: - QuitAction(Main &newMain) - : main(newMain) { } - - void invoke(); -}; - -#endif Deleted: branches/qonk-0.3-release/src/menuentry.cpp =================================================================== --- trunk/src/menuentry.cpp 2007-09-11 09:02:05 UTC (rev 105) +++ branches/qonk-0.3-release/src/menuentry.cpp 2007-09-11 18:30:22 UTC (rev 106) @@ -1,26 +0,0 @@ -#include "guichan/guichan.hpp" - -#include "menuentry.h" -#include "menusystem.h" - -using namespace gcn; -using namespace std; - -MenuEntry::MenuEntry(gcn::Widget *w) - : menuSystem(0), widget(w) -{ - -} - -MenuEntry::~MenuEntry() -{ - delete widget; -} - -void -MenuEntry::registered(MenuSystem *system) -{ - menuSystem = system; -} - - Deleted: branches/qonk-0.3-release/src/menuentry.h =================================================================== --- trunk/src/menuentry.h 2007-09-11 09:02:05 UTC (rev 105) +++ branches/qonk-0.3-release/src/menuentry.h 2007-09-11 18:30:22 UTC (rev 106) @@ -1,52 +0,0 @@ -// menuentry.h -// -// (c) Robert Schuster, 2007 -// -// Licensed under GNU GPL version 2 or, at your option, any later version. - -#ifndef MENUENTRY_H -#define MENUENTRY_H - -#include "guichan/guichan.hpp" - -class MenuSystem; - -class MenuEntry -{ - protected: - gcn::Widget *widget; - - MenuSystem *menuSystem; - - MenuEntry(gcn::Widget *); - - public: - virtual ~MenuEntry(); - - void registered(MenuSystem *); - - gcn::Widget *getWidget() const { return widget; } - - virtual void invoke() = 0; - - virtual void next() { }; - - virtual void previous() { }; - - /** Returns true if some operation was cancelled or false if not. - * - * This is neccessary for the menu to know whether it should go - * on level up or not. - */ - virtual bool cancel() { return false; } - - /** - * Puts the underlying attribute to its default value. - * - * Needs only be implemented by entries that support this. - */ - virtual void reset() { }; - -}; - -#endif Modified: branches/qonk-0.3-release/src/menumanager.cpp =================================================================== --- trunk/src/menumanager.cpp 2007-09-11 09:02:05 UTC (rev 105) +++ branches/qonk-0.3-release/src/menumanager.cpp 2007-09-11 18:30:22 UTC (rev 106) @@ -1,8 +1,8 @@ #include "menumanager.h" -#include "menusystem.h" -#include "menu.h" -#include "menuaction.h" +#include "ui/menusystem.h" +#include "ui/menu.h" +#include "ui/menuaction.h" #include "controloptions.h" #include "gameoptions.h" @@ -140,3 +140,8 @@ menuSystem->cancel(); } +void +QuitAction::invoke() +{ + main.quit(); +} Modified: branches/qonk-0.3-release/src/menumanager.h =================================================================== --- trunk/src/menumanager.h 2007-09-11 09:02:05 UTC (rev 105) +++ branches/qonk-0.3-release/src/menumanager.h 2007-09-11 18:30:22 UTC (rev 106) @@ -66,4 +66,15 @@ VideoOptions &getVideoOptions() const { return *videoOptions; }; }; +class QuitAction : public MenuAction +{ + Main &main; + + public: + QuitAction(Main &newMain) + : main(newMain) { } + + void invoke(); +}; + #endif Deleted: branches/qonk-0.3-release/src/menusystem.cpp =================================================================== --- trunk/src/menusystem.cpp 2007-09-11 09:02:05 UTC (rev 105) +++ branches/qonk-0.3-release/src/menusystem.cpp 2007-09-11 18:30:22 UTC (rev 106) @@ -1,283 +0,0 @@ -#include <iostream> - -#include "settings.h" -#include "canvas.h" - -#include "menusystem.h" -#include "menu.h" - -using namespace gcn; -using namespace std; - -MenuSystem::MenuSystem(SDLInput *input) - : currentMenu(0) -{ - gui = new Gui(); - - gui->setInput(input); - gui->setGraphics(Canvas::getSDLGraphics()); - Image::setImageLoader(new SDLImageLoader()); - - menuKeyListener = new MenuSystem::KeyListener(*this); - gui->addGlobalKeyListener(menuKeyListener); - - normal = loadFont("normal.png"); - highlighted = loadFont("highlight.png"); - gcn::Widget::setGlobalFont(normal); - - top = new Container(); - top->setOpaque(false); - top->setVisible(true); - top->setPosition(0,0); - top->setDimension(Rectangle(0, 0, Settings::getScreenWidth(), Settings::getScreenHeight())); - - gui->setTop(top); - - menus = new map< Menu::Id, Menu * > (); -} - -MenuSystem::~MenuSystem() -{ - delete highlighted; - delete normal; - - delete top; - - gui->removeGlobalKeyListener(menuKeyListener); - delete menuKeyListener; - - delete gui; - - delete menus; -} - -void -MenuSystem::render() -{ - gui->draw(); -} - -bool -MenuSystem::update() -{ - gui->logic(); - - if (currentMenu != nextMenu) - { - if (currentMenu) - currentMenu->leave(); - - if (nextMenu) - nextMenu->enter(); - - currentMenu = nextMenu; - } - - return currentMenu; -} - -void -MenuSystem::resize() -{ - int w = Settings::getScreenWidth(); - int h = Settings::getScreenHeight(); - top->setSize(w, h); - - for (map< Menu::Id, Menu * >::iterator i = menus->begin(); i != menus->end(); i++) - { - i->second->resize(w, h); - } - -} - -void -MenuSystem::addMenu(Menu::Id menuId, Menu *menu) -{ - (*menus)[menuId] = menu; - menu->registered(this); - top->add(menu->getContainer()); -} - -ImageFont * -MenuSystem::getNormalFont() -{ - return normal; -} - -ImageFont * -MenuSystem::getHighlightedFont() -{ - return highlighted; -} - -ImageFont * -MenuSystem::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; -} - -Image * -MenuSystem::loadImage(string fileName) -{ - Image *image = 0; - std::string s = PKG_DATA_DIR; - s += fileName; - - try - { - image = Image::load(s); - return image; - } - catch (gcn::Exception &e) - { - } - - s = "data"; -#ifdef WINDOWS - s += "\\"; -#else - s += "/"; -#endif - s += fileName; - - try - { - image = Image::load(s); - return image; - } - catch (gcn::Exception &e) - { - } - - cerr << "Could not load " << fileName << " from the following directories: " << endl - << PKG_DATA_DIR << endl - << "data" << endl; - - exit( 1 ); - - return 0; -} - -/** - * Makes the menu with the given id visible and hides the currently visible - * one (if there is one). - * - * If called with no argument the main menu is shown. - * - * If called with id == NONE the menus are made invisible. - * - * Actually the menusystem does not change to current visible menu at once. It - * just marks which menu it should show next and completes the request when - * update() is called next. - * Doing so prevents the menusystem from hiding right after it was made visible - * from main. - * - */ -void -MenuSystem::enter(Menu::Id id) -{ - if (id != Menu::NONE) - { - nextMenu = (*menus)[id]; - } - else - { - nextMenu = 0; - } - -} - -bool -MenuSystem::isVisible() const -{ - return currentMenu; -} - -void -MenuSystem::invoke() -{ - if (currentMenu) - currentMenu->invoke(); -} - -void -MenuSystem::cancel() -{ - if (currentMenu) - currentMenu->cancel(); - -} - -MenuSystem::KeyListener::KeyListener(MenuSystem &menuSystem) - : system(menuSystem) -{ -} - -void -MenuSystem::KeyListener::keyReleased(KeyEvent &keyEvent) -{ - // MenuSystem does not handle making itself visible. This is done from main. - if (!system.currentMenu) - return; - - switch (keyEvent.getKey().getValue()) - { - case Key::BACKSPACE: - system.currentMenu->reset(); - break; - case Key::ESCAPE: - system.currentMenu->cancel(); - break; - case Key::ENTER: - system.currentMenu->invoke(); - break; - case Key::UP: - system.currentMenu->up(); - break; - case Key::DOWN: - system.currentMenu->down(); - break; - case Key::LEFT: - system.currentMenu->previous(); - break; - case Key::RIGHT: - system.currentMenu->next(); - break; - } -} Deleted: branches/qonk-0.3-release/src/menusystem.h =================================================================== --- trunk/src/menusystem.h 2007-09-11 09:02:05 UTC (rev 105) +++ branches/qonk-0.3-release/src/menusystem.h 2007-09-11 18:30:22 UTC (rev 106) @@ -1,89 +0,0 @@ -// menusystem.h -// -// (c) Robert Schuster, 2007 -// -// Licensed under GNU GPL version 2 or, at your option, any later version. - -#ifndef MENUSYSTEM_H -#define MENUSYSTEM_H - -#include <map> - -#include "guichan/guichan.hpp" -#include "guichan/guichan/sdl.hpp" - -#include "menu.h" - -/** - * MenuSystem cares for all the low-level interaction of the menu system with - * guichan. - * - * It is only supposed to be called through MenuManager. - */ -class MenuSystem -{ - class KeyListener : public gcn::KeyListener - { - MenuSystem &system; - - public: - KeyListener(MenuSystem &menuSystem); - - virtual void keyReleased(gcn::KeyEvent &); - }; - - gcn::Gui *gui; - - gcn::ImageFont *normal; - gcn::ImageFont *highlighted; - - gcn::Container *top; - - std::map< Menu::Id, Menu * > *menus; - - Menu *currentMenu, *nextMenu; - - KeyListener *menuKeyListener; - - static gcn::ImageFont *loadFont(std::string); - - static gcn::Image *loadImage(std::string); - - public: - MenuSystem(gcn::SDLInput *); - ~MenuSystem(); - - void render(); - - bool update(); - - void resize(); - - void addMenu(Menu::Id, Menu *); - - void enter(Menu::Id = Menu::MAIN); - - /** Cancels whatever operation is currently in progress. - * - * At the moment the following operations are known: - * <ul> - * <li>A widget may have initiated the input sensing mode. If it is - * canceled the input mapping will not change.</li> - * - * <li>A certain submenu is open. On canceling it will get close and - * enter its parent menu.</li> - * - * <li>The main menu is open. On canceling it will be hidden.</li> - */ - void cancel(); - - void invoke(); - - bool isVisible() const; - - gcn::ImageFont *getNormalFont(); - - gcn::ImageFont *getHighlightedFont(); -}; - -#endif Added: branches/qonk-0.3-release/src/ui/Makefile.am =================================================================== --- branches/qonk-0.3-release/src/ui/Makefile.am (rev 0) +++ branches/qonk-0.3-release/src/ui/Makefile.am 2007-09-11 18:30:22 UTC (rev 106) @@ -0,0 +1,16 @@ +AM_CPPFLAGS=-DPKG_DATA_DIR="\"$(pkgdatadir)/\"" + +INCLUDES = -I$(top_srcdir)/guichan + +noinst_LIBRARIES = libui.a + +libui_a_SOURCES = \ + menuaction.h \ + menuaction.cpp \ + menu.h \ + menu.cpp \ + menuentry.h \ + menuentry.cpp \ + menusystem.h \ + menusystem.cpp + Copied: branches/qonk-0.3-release/src/ui/menu.cpp (from rev 103, trunk/src/menu.cpp) =================================================================== --- branches/qonk-0.3-release/src/ui/menu.cpp (rev 0) +++ branches/qonk-0.3-release/src/ui/menu.cpp 2007-09-11 18:30:22 UTC (rev 106) @@ -0,0 +1,268 @@ +#include "menu.h" + +#include <iostream> + +#include "menu.h" +#include "menusystem.h" +#include "menuentry.h" +#include "menuaction.h" + +using namespace gcn; +using namespace std; + +Menu::Menu(Id parentId, std::string menuTitle, int x) + : menuSystem(0), selected(-1), locx(x) +{ + parentMenuId = parentId; + container = new Container(); + + title = new Label(menuTitle); + container->add(title); + container->setOpaque(false); + container->setVisible(false); + + entries = new vector < MenuEntry * >(); +} + +Menu::~Menu() +{ + for (vector< MenuEntry * >::iterator i = entries->begin(); i != entries->end(); i++) + { + delete (*i); + } + + delete entries; + + delete container; +} + +void +Menu::addEntry(MenuEntry *entry) +{ + entries->push_back(entry); + + container->add(entry->getWidget()); + + if (menuSystem) + entry->registered(menuSystem); +} + +Container * +Menu::getContainer() const +{ + return container; +} + +void +Menu::enter() +{ + container->setVisible(true); + + if (selected == -1) + { + selected = 0; + entries->at(0)->getWidget()->setFont(menuSystem->getHighlightedFont()); + } +} + +void +Menu::leave() +{ + container->setVisible(false); +} + +void +Menu::registered(MenuSystem *system) +{ + menuSystem = system; + + for (vector< MenuEntry * >::iterator i = entries->begin(); i != entries->end(); i++) + (*i)->registered(system); + +} + +void +Menu::resize(int w, int h) +{ + container->setSize(w, h); + + int maxWidth = 0; + for (vector< MenuEntry * >::iterator i = entries->begin(); i != entries->end(); i++) + { + gcn::Widget *w = (*i)->getWidget(); + maxWidth = max(w->getWidth(), maxWidth); + } + + int x = (!locx) ? (w/2 - maxWidth/2) : locx; + int y = h/8; + + title->setPosition(x, y); + y += 2 * title->getHeight(); + + for (vector< MenuEntry * >::iterator i = entries->begin(); i != entries->end(); i++) + { + gcn::Widget *w = (*i)->getWidget(); + w->setPosition(x, y); + y += w->getHeight(); + } + +} + +void +Menu::up() +{ + entries->at(selected)->getWidget()->setFont(menuSystem->getNormalFont()); + + if (--selected < 0) + selected = entries->size()-1; + + entries->at(selected)->getWidget()->setFont(menuSystem->getHighlightedFont()); +} + +void +Menu::down() +{ + entries->at(selected)->getWidget()->setFont(menuSystem->getNormalFont()); + + if (++selected >= entries->size()) + selected = 0; + + entries->at(selected)->getWidget()->setFont(menuSystem->getHighlightedFont()); +} + +void +Menu::cancel() +{ + // If the cancel operation aborted some operation we skip going one + // menu level up. + if (!entries->at(selected)->cancel()) + { + entries->at(selected)->getWidget()->setFont(menuSystem->getNormalFont()); + selected = 0; + entries->at(selected)->getWidget()->setFont(menuSystem->getHighlightedFont()); + + menuSystem->enter(parentMenuId); + } +} + +void +Menu::reset() +{ + entries->at(selected)->reset(); +} + +void +Menu::invoke() +{ + entries->at(selected)->invoke(); +} + +void +Menu::next() +{ + entries->at(selected)->next(); +} + +void +Menu::previous() +{ + entries->at(selected)->previous(); +} + +class ActionEntry : public MenuEntry +{ + MenuAction *action; + + public: + ActionEntry(string s, MenuAction *a) + : action(a), MenuEntry(a->getWidget(s)) + { + } + + ~ActionEntry() + { + delete action; + } + + void invoke() + { + action->invoke(); + } + + void previous() + { + action->previous(); + } + + void next() + { + action->next(); + } + + /** Delegates the question if some action was + * cancelled or not to the action. + */ + bool cancel() + { + return action->cancel(); + } + + void reset() + { + action->reset(); + } + +}; + +void +Menu::addAction(string s, MenuAction *action) +{ + addEntry(new ActionEntry(s, action)); +} + +class LinkEntry : public MenuEntry +{ + Menu::Id target; + + public: + LinkEntry(string s, Menu::Id id) + : MenuEntry(new Label(s)), target(id) + { + } + + void invoke() + { + menuSystem->enter(target); + } + +}; + +void +Menu::addLink(string s, Menu::Id id) +{ + addEntry(new LinkEntry(s, id)); +} + +class BackLink : public MenuEntry +{ + Menu *menu; + + public: + BackLink(Menu *newMenu) + : MenuEntry(new Label("back")), menu(newMenu) + { + } + + void invoke() + { + menu->cancel(); + } + +}; + +void +Menu::addBackLink() +{ + addEntry(new BackLink(this)); +} + Copied: branches/qonk-0.3-release/src/ui/menu.h (from rev 102, trunk/src/menu.h) =================================================================== --- branches/qonk-0.3-release/src/ui/menu.h (rev 0) +++ branches/qonk-0.3-release/src/ui/menu.h 2007-09-11 18:30:22 UTC (rev 106) @@ -0,0 +1,89 @@ +// 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 <vector> + +#include "guichan/guichan.hpp" + +class MenuSystem; +class MenuEntry; +class MenuAction; + +class Menu +{ + public: + enum Id + { + NONE, MAIN, SINGLEPLAYER, MULTIPLAYER, OPTIONS, AUDIO_OPTIONS, VIDEO_OPTIONS, + CONTROL_OPTIONS + }; + + private: + + Id parentMenuId; + + gcn::Container *container; + + int selected; + + gcn::Label *title; + + std::vector < MenuEntry * > *entries; + + MenuSystem *menuSystem; + + int locx; + + public: + Menu(Id, std::string, int = 0); + + ~Menu(); + + void addEntry(MenuEntry *); + + void addAction(std::string, MenuAction *); + + void addLink(std::string, Menu::Id); + + void addBackLink(); + + void registered(MenuSystem *); + + /** Unconditionally make this menu visible. + */ + void enter(); + + /** Unconditionally make this menu invisible. + */ + void leave(); + + gcn::Container *getContainer() const; + + void resize(int, int); + + void up(); + + void down(); + + /** Cancels the operation of the currently selected widget. If there + * was no operation activate the parent menu. + */ + void cancel(); + + void invoke(); + + void next(); + + void previous(); + + void reset(); + +}; + +#endif Copied: branches/qonk-0.3-release/src/ui/menuaction.cpp (from rev 93, trunk/src/menuaction.cpp) =================================================================== --- branches/qonk-0.3-release/src/ui/menuaction.cpp (rev 0) +++ branches/qonk-0.3-release/src/ui/menuaction.cpp 2007-09-11 18:30:22 UTC (rev 106) @@ -0,0 +1,11 @@ +#include "guichan/guichan.hpp" + +#include "menuaction.h" + +using namespace std; + +gcn::Widget * +MenuAction::getWidget(string s) +{ + return new gcn::Label(s); +} Copied: branches/qonk-0.3-release/src/ui/menuaction.h (from rev 93, trunk/src/menuaction.h) =================================================================== --- branches/qonk-0.3-release/src/ui/menuaction.h (rev 0) +++ branches/qonk-0.3-release/src/ui/menuaction.h 2007-09-11 18:30:22 UTC (rev 106) @@ -0,0 +1,35 @@ +// menuaction.h +// +// (c) Robert Schuster, 2007 +// +// Licensed under GNU GPL version 2 or, at your option, any later version. + +#ifndef MENUACTION_H +#define MENUACTION_H + +#include "guichan/guichan.hpp" + +/* TODO: Realize all customized behavior with specific MenuEntry subclasses + * and remove the need for a MenuAction delegate object. + */ +class MenuAction +{ + public: + virtual gcn::Widget *getWidget(std::string); + + virtual void invoke() = 0; + + virtual void next() { }; + + virtual void previous() { }; + + virtual void update() { }; + + /** Returns true if some operation was cancelled or false if not. + */ + virtual bool cancel() { return false; } + + virtual void reset() { } +}; + +#endif Copied: branches/qonk-0.3-release/src/ui/menuentry.cpp (from rev 93, trunk/src/menuentry.cpp) =================================================================== --- branches/qonk-0.3-release/src/ui/menuentry.cpp (rev 0) +++ branches/qonk-0.3-release/src/ui/menuentry.cpp 2007-09-11 18:30:22 UTC (rev 106) @@ -0,0 +1,26 @@ +#include "guichan/guichan.hpp" + +#include "menuentry.h" +#include "menusystem.h" + +using namespace gcn; +using namespace std; + +MenuEntry::MenuEntry(gcn::Widget *w) + : menuSystem(0), widget(w) +{ + +} + +MenuEntry::~MenuEntry() +{ + delete widget; +} + +void +MenuEntry::registered(MenuSystem *system) +{ + menuSystem = system; +} + + Copied: branches/qonk-0.3-release/src/ui/menuentry.h (from rev 93, trunk/src/menuentry.h) =================================================================== --- branches/qonk-0.3-release/src/ui/menuentry.h (rev 0) +++ branches/qonk-0.3-release/src/ui/menuentry.h 2007-09-11 18:30:22 UTC (rev 106) @@ -0,0 +1,52 @@ +// menuentry.h +// +// (c) Robert Schuster, 2007 +// +// Licensed under GNU GPL version 2 or, at your option, any later version. + +#ifndef MENUENTRY_H +#define MENUENTRY_H + +#include "guichan/guichan.hpp" + +class MenuSystem; + +class MenuEntry +{ + protected: + gcn::Widget *widget; + + MenuSystem *menuSystem; + + MenuEntry(gcn::Widget *); + + public: + virtual ~MenuEntry(); + + void registered(MenuSystem *); + + gcn::Widget *getWidget() const { return widget; } + + virtual void invoke() = 0; + + virtual void next() { }; + + virtual void previous() { }; + + /** Returns true if some operation was cancelled or false if not. + * + * This is neccessary for the menu to know whether it should go + * on level up or not. + */ + virtual bool cancel() { return false; } + + /** + * Puts the underlying attribute to its default value. + * + * Needs only be implemented by entries that support this. + */ + virtual void reset() { }; + +}; + +#endif Copied: branches/qonk-0.3-release/src/ui/menusystem.cpp (from rev 101, trunk/src/menusystem.cpp) =================================================================== --- branches/qonk-0.3-release/src/ui/menusystem.cpp (rev 0) +++ branches/qonk-0.3-release/src/ui/menusystem.cpp 2007-09-11 18:30:22 UTC (rev 106) @@ -0,0 +1,283 @@ +#include <iostream> + +#include "settings.h" +#include "canvas.h" + +#include "menusystem.h" +#include "menu.h" + +using namespace gcn; +using namespace std; + +MenuSystem::MenuSystem(SDLInput *input) + : currentMenu(0) +{ + gui = new Gui(); + + gui->setInput(input); + gui->setGraphics(Canvas::getSDLGraphics()); + Image::setImageLoader(new SDLImageLoader()); + + menuKeyListener = new MenuSystem::KeyListener(*this); + gui->addGlobalKeyListener(menuKeyListener); + + normal = loadFont("normal.png"); + highlighted = loadFont("highlight.png"); + gcn::Widget::setGlobalFont(normal); + + top = new Container(); + top->setOpaque(false); + top->setVisible(true); + top->setPosition(0,0); + top->setDimension(Rectangle(0, 0, Settings::getScreenWidth(), Settings::getScreenHeight())); + + gui->setTop(top); + + menus = new map< Menu::Id, Menu * > (); +} + +MenuSystem::~MenuSystem() +{ + delete highlighted; + delete normal; + + delete top; + + gui->removeGlobalKeyListener(menuKeyListener); + delete menuKeyListener; + + delete gui; + + delete menus; +} + +void +MenuSystem::render() +{ + gui->draw(); +} + +bool +MenuSystem::update() +{ + gui->logic(); + + if (currentMenu != nextMenu) + { + if (currentMenu) + currentMenu->leave(); + + if (nextMenu) + nextMenu->enter(); + + currentMenu = nextMenu; + } + + return currentMenu; +} + +void +MenuSystem::resize() +{ + int w = Settings::getScreenWidth(); + int h = Settings::getScreenHeight(); + top->setSize(w, h); + + for (map< Menu::Id, Menu * >::iterator i = menus->begin(); i != menus->end(); i++) + { + i->second->resize(w, h); + } + +} + +void +MenuSystem::addMenu(Menu::Id menuId, Menu *menu) +{ + (*menus)[menuId] = menu; + menu->registered(this); + top->add(menu->getContainer()); +} + +ImageFont * +MenuSystem::getNormalFont() +{ + return normal; +} + +ImageFont * +MenuSystem::getHighlightedFont() +{ + return highlighted; +} + +ImageFont * +MenuSystem::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; +} + +Image * +MenuSystem::loadImage(string fileName) +{ + Image *image = 0; + std::string s = PKG_DATA_DIR; + s += fileName; + + try + { + image = Image::load(s); + return image; + } + catch (gcn::Exception &e) + { + } + + s = "data"; +#ifdef WINDOWS + s += "\\"; +#else + s += "/"; +#endif + s += fileName; + + try + { + image = Image::load(s); + return image; + } + catch (gcn::Exception &e) + { + } + + cerr << "Could not load " << fileName << " from the following directories: " << endl + << PKG_DATA_DIR << endl + << "data" << endl; + + exit( 1 ); + + return 0; +} + +/** + * Makes the menu with the given id visible and hides the currently visible + * one (if there is one). + * + * If called with no argument the main menu is shown. + * + * If called with id == NONE the menus are made invisible. + * + * Actually the menusystem does not change to current visible menu at once. It + * just marks which menu it should show next and completes the request when + * update() is called next. + * Doing so prevents the menusystem from hiding right after it was made visible + * from main. + * + */ +void +MenuSystem::enter(Menu::Id id) +{ + if (id != Menu::NONE) + { + nextMenu = (*menus)[id]; + } + else + { + nextMenu = 0; + } + +} + +bool +MenuSystem::isVisible() const +{ + return currentMenu; +} + +void +MenuSystem::invoke() +{ + if (currentMenu) + currentMenu->invoke(); +} + +void +MenuSystem::cancel() +{ + if (currentMenu) + currentMenu->cancel(); + +} + +MenuSystem::KeyListener::KeyListener(MenuSystem &menuSystem) + : system(menuSystem) +{ +} + +void +MenuSystem::KeyListener::keyReleased(KeyEvent &keyEvent) +{ + // MenuSystem does not handle making itself visible. This is done from main. + if (!system.currentMenu) + return; + + switch (keyEvent.getKey().getValue()) + { + case Key::BACKSPACE: + system.currentMenu->reset(); + break; + case Key::ESCAPE: + system.currentMenu->cancel(); + break; + case Key::ENTER: + system.currentMenu->invoke(); + break; + case Key::UP: + system.currentMenu->up(); + break; + case Key::DOWN: + system.currentMenu->down(); + break; + case Key::LEFT: + system.currentMenu->previous(); + break; + case Key::RIGHT: + system.currentMenu->next(); + break; + } +} Copied: branches/qonk-0.3-release/src/ui/menusystem.h (from rev 102, trunk/src/menusystem.h) =================================================================== --- branches/qonk-0.3-release/src/ui/menusystem.h (rev 0) +++ branches/qonk-0.3-release/src/ui/menusystem.h 2007-09-11 18:30:22 UTC (rev 106) @@ -0,0 +1,89 @@ +// menusystem.h +// +// (c) Robert Schuster, 2007 +// +// Licensed under GNU GPL version 2 or, at your option, any later version. + +#ifndef MENUSYSTEM_H +#define MENUSYSTEM_H + +#include <map> + +#include "guichan/guichan.hpp" +#include "guichan/guichan/sdl.hpp" + +#include "menu.h" + +/** + * MenuSystem cares for all the low-level interaction of the menu system with + * guichan. + * + * It is only supposed to be called through MenuManager. + */ +class MenuSystem +{ + class KeyListener : public gcn::KeyListener + { + MenuSystem &system; + + public: + KeyListener(MenuSystem &menuSystem); + + virtual void keyReleased(gcn::KeyEvent &); + }; + + gcn::Gui *gui; + + gcn::ImageFont *normal; + gcn::ImageFont *highlighted; + + gcn::Container *top; + + std::map< Menu::Id, Menu * > *menus; + + Menu *currentMenu, *nextMenu; + + KeyListener *menuKeyListener; + + static gcn::ImageFont *loadFont(std::string); + + static gcn::Image *loadImage(std::string); + + public: + MenuSystem(gcn::SDLInput *); + ~MenuSystem(); + + void render(); + + bool update(); + + void resize(); + + void addMenu(Menu::Id, Menu *); + + void enter(Menu::Id = Menu::MAIN); + + /** Cancels whatever operation is currently in progress. + * + * At the moment the following operations are known: + * <ul> + * <li>A widget may have initiated the input sensing mode. If it is + * canceled the input mapping will not change.</li> + * + * <li>A certain submenu is open. On canceling it will get close and + * enter its parent menu.</li> + * + * <li>The main menu is open. On canceling it will be hidden.</li> + */ + void cancel(); + + void invoke(); + + bool isVisible() const; + + gcn::ImageFont *getNormalFont(); + + gcn::ImageFont *getHighlightedFont(); +}; + +#endif Modified: branches/qonk-0.3-release/src/videooptions.cpp =================================================================== --- trunk/src/videooptions.cpp 2007-09-11 09:02:05 UTC (rev 105) +++ branches/qonk-0.3-release/src/videooptions.cpp 2007-09-11 18:30:22 UTC (rev 106) @@ -5,10 +5,11 @@ #include "guichan/guichan.hpp" +#include "ui/menuaction.h" + #include "settings.h" #include "videooptions.h" -#include "menuaction.h" #include "main.h" using namespace std; Copied: releases/qonk-0.3.0 (from rev 93, trunk) Deleted: releases/qonk-0.3.0/HISTORY =================================================================== --- trunk/HISTORY 2007-07-28 21:25:43 UTC (rev 93) +++ releases/qonk-0.3.0/HISTORY 2007-09-11 18:30:22 UTC (rev 106) @@ -1,32 +0,0 @@ -0.0.3 - NOT_RELEASED_YET - -Features: - - new project page: http//qonk.sf.net - - public SVN repository: https://qonk.svn.sf.net/svnroot/qonk - - freely chosable input (mouse, keyboard, gamepad, ...) - - config file - - advance to next level without leaving game - - upgraded ship and universe painting - - basic menu system with many working parts - - autotools build system - - single ship mode -Bugs fixed: - - do not call SDL functions in Timere before SDL_Init because of static - initialization - - properly update screen size changes - - allow removing input mappings -other: - - simplified initial planet claiming - - remove need for static Timer variable - -rs-2007-02-17 - 2007-02-17 A modificated version -Modificated qonk based on 0.0.2beta1 by Robert Schuster: - - ships selection by percentage - - the bigger the planet the shorter the built cycle - -0.0.2beta1 - 2003 - Second public release -Another slightly updated version by Anthony. -http://anthony.liekens.net/pub/files/qonk-0.0.2beta1.tar.gz - -0.0.1 - 2003 - First public release -Initial version by Anthony Liekens -http://anthony.liekens.net/pub/files/qonk-0.0.1.tar.gz Copied: releases/qonk-0.3.0/HISTORY (from rev 95, trunk/HISTORY) =================================================================== --- releases/qonk-0.3.0/HISTORY (rev 0) +++ releases/qonk-0.3.0/HISTORY 2007-09-11 18:30:22 UTC (rev 106) @@ -0,0 +1,33 @@ +0.3.0 - released on 2007/09/09 +Features: + - new project page: http//qonk.sf.net + - public SVN repository: https://qonk.svn.sf.net/svnroot/qonk + - freely choosable input (mouse, keyboard, gamepad, ...) + - config file + - advance to next level without leaving game + - upgraded ship and universe painting + - basic menu system with many working parts + - autotools build system + - single ship mode +Bugs fixed: + - do not call SDL functions in Timer before SDL_Init because of static + initialization + - properly update screen size changes + - allow removing input mappings +other: + - simplified initial planet claiming + - remove need for static Timer variable + - switch to traditional MAJOR.MINOR.MICRO version number scheme + +rs-2007-02-17 - 2007-02-17 A modificated version +Modificated qonk based on 0.0.2beta1 by Robert Schuster: + - ships selection by percentage + - the bigger the planet the shorter the built cycle + +0.0.2beta1 - 2003 - Second public release +Another slightly updated version by Anthony. +http://anthony.liekens.net/pub/files/qonk-0.0.2beta1.tar.gz + +0.0.1 - 2003 - First public release +Initial version by Anthony Liekens +http://anthony.liekens.net/pub/files/qonk-0.0.1.tar.gz Copied: releases/qonk-0.3.0/INSTALL (from rev 100, trunk/INSTALL) =================================================================== --- releases/qonk-0.3.0/INSTALL (rev 0) +++ releases/qonk-0.3.0/INSTALL 2007-09-11 18:30:22 UTC (rev 106) @@ -0,0 +1,47 @@ +General compilation notes +------------------------- + +Qonk uses GNU Autoconf to manage the compilation. Call + + ./configure --help + +to see available options. + +Like all good applications Qonk is able to be run without installation. It tries +to find its data files in ./data first and uses $(pkgdatadir)/data in a second +attempt. + +Dependencies +------------ + +Qonk tries to only use components available in free software operating systems. + +Install the development version of the following packages in order to compile +from source: + + SDL (>= 1.2) + SDL_ttf (>= 2.0) + SDL_gfx (>= 1.2) + SDL_image (>= 1.2) + +Qonk includes a modified version of guichan 0.6.1 in its sources and statically +links that into the executable. The build system was not tested to use a +system-wide installation of guichan 0.6.1. Furthermore since guichan is not +extensively used in Qonk it is planned to remove it in further releases. + +Compilation +----------- + +In a published tarball you only need to execute + + ./configure + make + make install + +(To avoid system-wide installation use the --prefix argument for ./configure !) + +You get helpful error messages if something is not correct with the +dependencies. + +If you want to built the sources from SVN you need to issue ./autogen.sh and +have the autotools installed (GNU Automake, GNU Autoconf, GNU libtool). Deleted: releases/qonk-0.3.0/Makefile.am =================================================================== --- trunk/Makefile.am 2007-07-28 21:25:43 UTC (rev 93) +++ releases/qonk-0.3.0/Makefile.am 2007-09-11 18:30:22 UTC (rev 106) @@ -1,4 +0,0 @@ -SUBDIRS = guichan src data - -EXTRA_DIST = README COPYING missing Makefile.manual TODO - Copied: releases/qonk-0.3.0/Makefile.am (from rev 95, trunk/Makefile.am) =================================================================== --- releases/qonk-0.3.0/Makefile.am (rev 0) +++ releases/qonk-0.3.0/Makefile.am 2007-09-11 18:30:22 UTC (rev 106) @@ -0,0 +1,4 @@ +SUBDIRS = guichan src data + +EXTRA_DIST = autogen.sh README COPYING missing TODO HISTORY THANKYOU + Deleted: releases/qonk-0.3.0/README =================================================================== --- trunk/README 2007-07-28 21:25:43 UTC (rev 93) +++ releases/qonk-0.3.0/README 2007-09-11 18:30:22 UTC (rev 106) @@ -1,113 +0,0 @@ -Qonk 0.0.3 -========== - -Qonk is a small build-and-conquer strategy game with very simple rules. A -complete game only lasts for a few minutes and can be a fun break away from -work or whatever you're doing. - -The setting of the game is a solar system of planets. Your goal is to conquer -all of the planets in the game by sending ships there. Planets that are -under your control generate new ships. Simple AI players are playing against -you. As you gain more experience throughout the game, more AI players have to -be kicked out of bigger solar systems. - -(from http://anthony.liekens.net/index.php/Computers/Qonk) - -The game is currently very much in beta and was written and published by -Anthony Liekens. - -Dependencies ------------- -To compile the program you will need to install SDL, SDL_ttf and SDL_gfx. It is -built using GNU Autoconf. In a published tarball you only need to execute - - ./configure - make - make install - -You get helpful error messages if something is not correct with the -dependencies. - -If you want to built the sources from SVN you need to issue ./autogen.sh and -have the autotools installed (GNU Automake, GNU Autoconf, GNU libtool). - -How to play -------------- - -Select a group of planets to put their ships into your selection for the next -move. Now do a right-click near the planet where you want to send you fleet to. -You can attack neutral (grey), enemy (some color) and reinforce your own planets -(the white ones). - -The number of ships starting from a planets depends on the number of ships being -stationed there and the current fleet strength setting. In the beginning the -strength is set to 50%. That means that half of the ships on each planets will -take off when you order them to move. You can choose other strength settings by -pressing the number keys (1 -> 10%, 9 -> 90%, 0->100%). If you press the 's' key -you are in single ship mode. This means that on each move order one ship leaves -from the selected planets (there has to be at least one stationed, though). - -Besides setting the strength to certain values you can lower or higher the -strength by using the mouse wheel. Below 10% comes the single ship mode, -when requesting to lower the strength it switches to 100%. The same happens in -the reverse order when you increase the strength and are at 100%. - -New ships are continuisly built on the planets (and moons) you own. Bigger -planets usually built ships faster than smaller ones. - -Other options -------------- - -You can toggle displaying of enemy ships by pressing the 'e' key. - -If you see yourself losing and want to retry, press 'r'. If you have won instead -press 'n' to start the next round. - -Press 'f' to switch between fullscreen and windowed mode. In windowed mode you -need to make sure that the mouse cannot leave the game's window. Press 'g' to -activate input grabbing and press it again if you want to release the input. - -Last but not least 'p' can be used to pause and unpause the game and 'ESC' quits -it. - -Command line options --------------------- - -Start the game with qonk <numberOfPlanets> <numberOfComputerPlayers> to run a -game with such a universe. - -Config file ------------ - -On GNU/Linux and other POSIX-like systems a config file is written in your -home directory at .qonk/qonk.config. - -The format is LISP-like (you remember it from SuperTuxKart probably :) ). At the -moment editing the config file is the only possibility to switch the various -of the game except for the fullscreen mode state and the game's progress which -are saved on exit. - -If you feel sufficiently experienced you can change the input configuration of -the game. Don't use escape or g in any of your mappings, because those are -hardcoded to quitting and toggling the input grab. - -Development ------------ - -Plans are there to add a menu system, some GUI components and perhaps -a single-computer multiplayer mode. Feel free to contact the development team -via the mailing-list. - -Issues ------- -- You cannot select ships which are already in the vasts of space. - -Homepage --------- - -http://qonk.sf.net - -Project page -------------- - -http://sf.net/projects/qonk Copied: releases/qonk-0.3.0/README (from rev 100, trunk/README) =================================================================== --- releases/qonk-0.3.0/README (rev 0) +++ releases/qonk-0.3.0/README 2007-09-11 18:30:22 UTC (rev 106) @@ -0,0 +1,124 @@ +Qonk 0.0.3 +========== + +Qonk is a small build-and-conquer strategy game with very simple rules. A +complete game only lasts for a few minutes and can be a fun break away from +work or whatever you're doing. + +The setting of the game is a solar system of planets. Your goal is to conquer +all of the planets in the game by sending ships there. Planets that are +under your control generate new ships. Simple AI players are playing against +you. As you gain more experience throughout the game, more AI players have to +be kicked out of bigger solar systems. + +(from http://anthony.liekens.net/index.php/Computers/Qonk) + +The game is currently very much in beta. + +For information on how to compile the source code refer to the INSTALL file. + +How to play +----------- + +The goal is wipe out all enemies from the solar system. + +Select a group of planets to put their ships into your selection for the next +move. Now do a right-click near the planet where you want to send you fleet to. +You can attack neutral (grey), enemy (some color) and reinforce your own planets +(the white ones). + +The number of ships starting from a planet depends on the number of ships being +stationed there and the current fleet strength setting. In the beginning the +strength is set to 50%. That means that half of the ships on each selected +planet will take off when you order them to move. You can choose other +strength settings by pressing the number keys (1 -> 10%, 9 -> 90%, 0->100%). +If you press the 's' key you are in single ship mode. This means that on each +move order one ship leaves from the selected planets (there has to be at least +one stationed, though). + +Besides setting the strength to certain values you can lower or higher the +strength by using the mouse wheel. Below 10% comes the single ship mode, +when requesting to lower the strength it switches to 100%. The same happens in +the reverse order when you increase the strength and are at 100%. + +New ships are continuisly built on the planets (and moons) you own. Bigger +planets usually built ships faster than smaller ones. + +Ships stationing at a planet or moon are automatically defending it. The rule +is simple: One defending ship destroys one attacking ships and vice versa. A +planet or moon defended by N ships can only be conquered by at least N + 1 +ships. + +Other options +------------- + +You can toggle displaying of enemy ships by pressing the 'e' key. + +If you see yourself losing and want to retry, press 'r'. If you have won instead +press 'n' to start the next round. + +Press 'f' to switch between fullscreen and windowed mode. In windowed mode you +need to make sure that the mouse cannot leave the game's window. Press 'g' to +activate input grabbing and press it again if you want to release the input. + +To pause the game just press ESC to open the menus. Pressing ESC again puts you +back into the action. + +Command line options +-------------------- + +Start the game with qonk <numberOfPlanets> <numberOfComputerPlayers> to run a +game with such a universe. + +Config file +----------- + +On GNU/Linux and other POSIX-like systems a config file is written in your +home directory at .qonk/qonk.config. + +The format is LISP-like (you remember it from SuperTuxKart probably :) ). + +Development +----------- + +Plans are there to add a single-computer multiplayer mode. Feel free to +contact the development team via the mailing-list. + +Issues +------ +- You cannot select ships which are already in the vasts of space. + +Homepage +-------- + +http://qonk.sourceforge.net + +Project page +------------- + +http://sourceforge.net/projects/qonk + +License +------- + +This game is free software released under the GNU General Public License 2 +or, at your option, any later version. See the file COPYING for details. + +Acknowledgements +---------------- +Qonk uses a number of free software components (libraries) for which we thank +their authors: + +Simple Direct Media Library: http://libsdl.org + * This library is truly a gem! + +Guichan: http://guichan.sf.net + * Provides us some user interface components and made the menu system + implementation easier. + +GNU Autotools: http://gnu.org/software/autoconf + http://gnu.org/software/automake + * These make lifes for packagers and people who cross-compile so much easier. + Unfortunately many people do not understand all the issues around compiling, + linking and installing on different platforms and coping with compatibility + and blame the Autotools for being the root of all evil. Copied: releases/qonk-0.3.0/THANKYOU (from rev 94, trunk/THANKYOU) =================================================================== --- releases/qonk-0.3.0/THANKYOU (rev 0) +++ releases/qonk-0.3.0/THANKYOU 2007-09-11 18:30:22 UTC (rev 106) @@ -0,0 +1,6 @@ +The following people have contributed to Qonk: + +Anthony Liekens +Jens Fursund +Robert Schuster +Troels Kofoed Jacobsen Deleted: releases/qonk-0.3.0/TODO =================================================================== --- trunk/TODO 2007-07-28 21:25:43 UTC (rev 93) +++ releases/qonk-0.3.0/TODO 2007-09-11 18:30:22 UTC (rev 106) @@ -1,14 +0,0 @@ -AI to hunt for the large planets first - -Difficulty level: -EASY: HumanPlayer build ships faster -NORMAL: As is -HARD: Can't see enemys ships - -Animated sun - Fluctuat... [truncated message content] |
From: <the...@us...> - 2008-06-01 21:48:41
|
Revision: 138 http://qonk.svn.sourceforge.net/qonk/?rev=138&view=rev Author: thebohemian Date: 2008-06-01 14:48:40 -0700 (Sun, 01 Jun 2008) Log Message: ----------- - fix compilation error Modified Paths: -------------- trunk/src/engine/Makefile trunk/src/sdl_driver.h Modified: trunk/src/engine/Makefile =================================================================== --- trunk/src/engine/Makefile 2007-10-21 20:41:57 UTC (rev 137) +++ trunk/src/engine/Makefile 2008-06-01 21:48:40 UTC (rev 138) @@ -112,9 +112,9 @@ PACKAGE = qonk PACKAGE_BUGREPORT = qon...@li... PACKAGE_NAME = qonk -PACKAGE_STRING = qonk 0.3.1+svn +PACKAGE_STRING = qonk 0.3.0 PACKAGE_TARNAME = qonk -PACKAGE_VERSION = 0.3.1+svn +PACKAGE_VERSION = 0.3.0 PATH_SEPARATOR = : RANLIB = ranlib SDL_CFLAGS = -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT @@ -123,7 +123,7 @@ SET_MAKE = SHELL = /bin/sh STRIP = -VERSION = 0.3.1+svn +VERSION = 0.3.0 ac_ct_CC = gcc ac_ct_CXX = g++ am__fastdepCC_FALSE = # Modified: trunk/src/sdl_driver.h =================================================================== --- trunk/src/sdl_driver.h 2007-10-21 20:41:57 UTC (rev 137) +++ trunk/src/sdl_driver.h 2008-06-01 21:48:40 UTC (rev 138) @@ -27,9 +27,9 @@ gcn::SDLInput *getSDLInput(); - Input &getSensedInput(); + Input &getSensedInput(); - void initActionMap(); + void initActionMap(); void setSenseMode(bool); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2008-06-01 21:49:36
|
Revision: 139 http://qonk.svn.sourceforge.net/qonk/?rev=139&view=rev Author: thebohemian Date: 2008-06-01 14:49:34 -0700 (Sun, 01 Jun 2008) Log Message: ----------- - re-added missing files (fixes compilation finally) Added Paths: ----------- trunk/src/menumanager.cpp trunk/src/menumanager.h Added: trunk/src/menumanager.cpp =================================================================== --- trunk/src/menumanager.cpp (rev 0) +++ trunk/src/menumanager.cpp 2008-06-01 21:49:34 UTC (rev 139) @@ -0,0 +1,150 @@ +#include "menumanager.h" + +#include "ui/menusystem.h" +#include "ui/menu.h" +#include "ui/menuaction.h" + +#include "engine/canvas.h" + +#include "controloptions.h" +#include "gameoptions.h" +#include "videooptions.h" + +#include "input.h" +#include "main.h" +#include "sdl_driver.h" +#include "settings.h" + +MenuManager::MenuManager(Main &newMain) + : main(newMain) +{ + menuSystem = new MenuSystem(main.getSDLDriver().getSDLInput(), Canvas::getSDLGraphics ()); + + controlOptions = new ControlOptions(main); + videoOptions = new VideoOptions(); + gameOptions = new GameOptions(); + + Menu *m = new Menu(Menu::NONE, "qonk"); + m->addLink("singleplayer", Menu::SINGLEPLAYER); + m->addLink("multiplayer", Menu::MULTIPLAYER); + m->addLink("options", Menu::OPTIONS); + m->addAction("quit", new QuitAction(main)); + menuSystem->addMenu(Menu::MAIN, m); + + m = new Menu(Menu::MAIN, "singleplayer"); + m->addAction("planets", gameOptions->getPlanetsAction()); + m->addAction("enemies", gameOptions->getPlayersAction()); + m->addAction("show enemies", gameOptions->getEnemyVisibilityAction()); + m->addAction("start game", gameOptions->getStartSinglePlayerGameAction(main)); + m->addBackLink(); + menuSystem->addMenu(Menu::SINGLEPLAYER, m); + + m = new Menu(Menu::MAIN, "multiplayer"); + m->addLink("this is not", Menu::NONE); + m->addLink("yet implemented.", Menu::NONE); + m->addBackLink(); + menuSystem->addMenu(Menu::MULTIPLAYER, m); + + m = new Menu(Menu::MAIN, "options"); + m->addLink("audio", Menu::AUDIO_OPTIONS); + m->addLink("video", Menu::VIDEO_OPTIONS); + m->addLink("controls", Menu::CONTROL_OPTIONS); + m->addBackLink(); + menuSystem->addMenu(Menu::OPTIONS, m); + + m = new Menu(Menu::OPTIONS, "audio"); + m->addLink("this is not", Menu::NONE); + m->addLink("yet implemented.", Menu::NONE); + m->addBackLink(); + menuSystem->addMenu(Menu::AUDIO_OPTIONS, m); + + m = new Menu(Menu::OPTIONS, "video"); + m->addAction("screen size:", videoOptions->getScreenSizeAction()); + m->addAction("toggle fullscreen", videoOptions->getToggleFullscreenAction()); + m->addAction("apply", videoOptions->getApplyVideoOptionsAction(main)); + m->addBackLink(); + menuSystem->addMenu(Menu::VIDEO_OPTIONS, m); + + m = new Menu(Menu::OPTIONS, "controls", 10); + m->addAction("select all", controlOptions->getControlAction(GA_SELECT_ALL)); + m->addAction("show enemies", controlOptions->getControlAction(GA_TOGGLE_ENEMY_VISIBILITY)); + m->addAction("selection", controlOptions->getControlAction(GA_SELECTION)); + m->addAction("cursor up", controlOptions->getControlAction(GA_CURSOR_UP)); + m->addAction("cursor down", controlOptions->getControlAction(GA_CURSOR_DOWN)); + m->addAction("cursor left", controlOptions->getControlAction(GA_CURSOR_LEFT)); + m->addAction("cursor right", controlOptions->getControlAction(GA_CURSOR_RIGHT)); + m->addAction("select nearest", controlOptions->getControlAction(GA_SELECT_NEAREST_PLANET)); + m->addAction("move to nearest", controlOptions->getControlAction(GA_MOVE_TO_NEAREST_PLANET)); + m->addAction("single ship mode", controlOptions->getControlAction(GA_SET_FLEET_STRENGTH_SINGLE)); + m->addBackLink(); + menuSystem->addMenu(Menu::CONTROL_OPTIONS, m); + + resize(); + + menuSystem->enter(); +} + +MenuManager::~MenuManager() +{ + delete menuSystem; + + delete gameOptions; + delete videoOptions; +} + +void +MenuManager::showSinglePlayerMenu() +{ + menuSystem->enter(Menu::SINGLEPLAYER); +} + +void +MenuManager::show() +{ + menuSystem->enter(); +} + +void +MenuManager::hide() +{ + menuSystem->enter(Menu::NONE); +} + +bool +MenuManager::isVisible() const +{ + return menuSystem->isVisible(); +} + +void +MenuManager::resize() +{ + menuSystem->resize(Settings::getScreenWidth (), Settings::getScreenHeight ()); +} + +void +MenuManager::render() +{ + menuSystem->render(); +} + +bool +MenuManager::update() +{ + return menuSystem->update(); +} + +void +MenuManager::senseFinished(bool b) +{ + if (b) + menuSystem->invoke(); + else + menuSystem->cancel(); +} + +void +QuitAction::invoke() +{ + main.quit(); +} Added: trunk/src/menumanager.h =================================================================== --- trunk/src/menumanager.h (rev 0) +++ trunk/src/menumanager.h 2008-06-01 21:49:34 UTC (rev 139) @@ -0,0 +1,82 @@ +// menumanager.h +// +// (c) Robert Schuster, 2007 +// +// Licensed under GNU GPL version 2 or, at your option, any later version. + +#ifndef MENUMANAGER_H +#define MENUMANAGER_H + +class Main; + +class ControlOptions; +class VideoOptions; +class GameOptions; + +class MenuSystem; + +#include "ui/menuaction.h" + +/** + * MenuManager forms the facade for interacting with the game's menus. + * + * It speaks to MenuSystem and builds up the menus and their menu entries. However + * it does not touch any of the guichan internal. + * + * This is done to keep the guichan integration low and give the menu + * construction a dedicated place that is not polluted with low-level stuff. + * + */ +class MenuManager +{ + Main &main; + + ControlOptions *controlOptions; + VideoOptions *videoOptions; + GameOptions *gameOptions; + + MenuSystem *menuSystem; + + public: + MenuManager(Main &); + + ~MenuManager(); + + void showSinglePlayerMenu(); + void show(); + void hide(); + bool isVisible() const; + + void resize(); + + void render(); + + bool update(); + + /** Indicate that input sensing should be finished. + * + * If a new input has been determined and the operation should + * end as succeeded the argument's value is <code>true</code>. + * + * If the operation should end as cancelled the argument's value + * is <code>false</code>. + * */ + void senseFinished(bool); + + GameOptions &getGameOptions() const { return *gameOptions; }; + + VideoOptions &getVideoOptions() const { return *videoOptions; }; +}; + +class QuitAction : public MenuAction +{ + Main &main; + + public: + QuitAction(Main &newMain) + : main(newMain) { } + + void invoke(); +}; + +#endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |