diff --git a/data/po/de.po b/data/po/de.po new file mode 100644 index 000000000..73d35256b --- /dev/null +++ b/data/po/de.po @@ -0,0 +1,714 @@ +# +# Stefan von Halenbach 2007 +# This translation is licensed under BSD-licens +# +msgid "" +msgstr "" +"Project-Id-Version: Supertuxkart 0.3\n" +"POT-Creation-Date: \n" +"PO-Revision-Date: 2007-05-16 01:00+0100\n" +"Last-Translator: Stefan von Halenbach \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Poedit-Language: German\n" +"X-Poedit-Country: GERMANY\n" +"X-Poedit-SourceCharset: utf-8\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: herring_manager.cpp:245 +#, c-format +msgid "" +"The herring style '%s' in your configuration file does not exist.\n" +"It is ignored.\n" +msgstr "" +"Die Erscheinungsform '%s' gibt es nicht in Deiner Konfiguration.\n" +"Es wird ignoriert.\n" + +#: herring_manager.cpp:256 +#, c-format +msgid "" +"The herring style '%s' specified on the command line does not exist.\n" +"It is ignored.\n" +msgstr "" +"Die Erscheinungsform '%s' gibt es nicht in Deiner Konfiguration.\n" +"Die Eingabe auf der Kommandozeile wird ignoriert.\n" + +#: herring_manager.cpp:342 +#, c-format +msgid "Couldn't load map '%s': no herring node." +msgstr "" + +#: kart_properties_manager.cpp:92 +#, c-format +msgid "KartPropertiesManager: Couldn't find kart: '%s'" +msgstr "Kart-Eigenschaftenmanager: Kann Kart nicht finden in: '%s'" + +#: loader.cpp:70 +#, c-format +msgid "Data files will be fetched from: '%s'\n" +msgstr "Spieldaten werden von '%s' heruntergeladen.\n" + +#: loader.cpp:178 +#, c-format +msgid "Couldn't find file '%s'." +msgstr "Kann Datei '%s' nicht öffnen." + +#: main.cpp:63 +#, c-format +msgid "" +"Usage: %s [OPTIONS]\n" +"\n" +"Run SuperTuxKart, a racing game with go-kart that features the Tux and friends.\n" +"\n" +"Options:\n" +" -N, --no-start-screen Quick race\n" +" -l, --list-tracks Show available tracks\n" +" -k, --numkarts NUM Number of karts on the racetrack\n" +" --kart NAME Use kart number NAME\n" +" --list-karts Show available karts\n" +" --laps N Define number of laps to N\n" +" --herring STYLE Use STYLE as your herring style\n" +" -f, --fullscreen Fullscreen display\n" +" -w, --windowed Windowed display (default)\n" +" -s, --screensize WxH Set the screen size (e.g. 320x200)\n" +" -v, --version Show version\n" +" -h, --help Show this help\n" +"\n" +"You can visit SuperTuxKart's homepage at http://supertuxkart.berlios.de\n" +"\n" +msgstr "" +"Eingabeformat: %s [OPTIONEN]\n" +"\n" +"Starte supertuxkart. Ein Spiel in dem es um ein Go-Kart-Wettrennen von Tux \n" +"und seinen Freunden geht.\n" +"\n" +"Optionen:\n" +" -N, --no-start-screen Schneller Spielstart\n" +" -l, --list-tracks Zeige vorhandere Strecken\n" +" -k, --numkarts NUM Anzahl der Karts auf der Rennstrecke\n" +" --kart NAME Benutze das Kart NAME\n" +" --list-karts Zeige vorhandene Karts\n" +" --laps N Setze Anzahl der zu fahrenden Runden mit N fest.\n" +" --herring STYLE Benutze STYLE als Dein Erscheinungsbild des Herings.\n" +" -f, --fullscreen Darstellung im Vollbildformat\n" +" -w, --windowed Darstellung im Fenster (Voreinstellung)\n" +" -s, --screensize WxH Setze die Bildschirmauflösung fest (z.B. 320x200)\n" +" -v, --version Zeige Programmversion\n" +" -h, --help Zeige diese Hilfe\n" +"\n" +"Du kannst SuperTuxKart's Internetseite auf http://supertuxkart.berlios.de besuchen.\n" +"\n" + +#: main.cpp:105 +msgid "--help" +msgstr "" + +#: main.cpp:106 +msgid "-help" +msgstr "" + +#: main.cpp:120 +#, c-format +msgid "You choose to start in track: %s.\n" +msgstr "Du beginnst auf Rennstrecke: %s.\n" + +#: main.cpp:126 +#, c-format +msgid "You choose to have %s karts.\n" +msgstr "Du hast %s Karts zur Verfügung.\n" + +#: main.cpp:131 +#, c-format +msgid " Available tracks:\n" +msgstr "Verfügbare Strecken:\n" + +#: main.cpp:137 +#, c-format +msgid "" +"Use --track N to choose track.\n" +"\n" +msgstr "" +"Benutze --track N um die Runde vorzuwählen.\n" +"\n" + +#: main.cpp:147 +#, c-format +msgid " Available karts:\n" +msgstr "Verfügbare Karts:\n" + +#: main.cpp:168 +#, c-format +msgid "Enabling mirror mode.\n" +msgstr "Geteilter Bildschirmmodus.\n" + +#: main.cpp:177 +#, c-format +msgid "You choose to have %d laps.\n" +msgstr "Du fährst %d Runden.\n" + +#: main.cpp:207 +#, c-format +msgid "You choose to be in %dx%d.\n" +msgstr "Du bist in %dx%d.\n" + +#: main.cpp:211 +#, c-format +msgid "Error: --screensize argument must be given as WIDTHxHEIGHT\n" +msgstr "Fehler: --screensize muss als Argument BREITExHÖHE bekommen\n" + +#: main.cpp:240 +#, c-format +msgid "" +"Invalid parameter: %s.\n" +"\n" +msgstr "" +"Ungültiger Parameter: %s.\n" +"\n" + +#: main.cpp:372 +#, c-format +msgid "" +"\n" +"Aborting SuperTuxKart\n" +msgstr "" +"\n" +"Beende SuperTuxKart\n" + +#: moving_texture.cpp:77 +#, c-format +msgid "Unrecognised @autodcs string: '%s'\n" +msgstr "" + +#: sound_manager.cpp:50 +#, c-format +msgid "WARNING: Could not initialize the PLIB based sound.\n" +msgstr "" + +#: sound_manager.cpp:62 +#, c-format +msgid "WARNING: Could not initialize the ALUT based sound.\n" +msgstr "" + +#: user_config.cpp:127 +#: gui/config_controls.cpp:36 +#, c-format +msgid "Player %d" +msgstr "Spieler %d" + +#: user_config.cpp:209 +#, c-format +msgid "Couldn't create '%s', config files will not be saved.\n" +msgstr "Kann Datei '%s' nicht erzeugen. Konfiguration kann nicht gespeichert werden.\n" + +#: user_config.cpp:215 +#, c-format +msgid "Config directory '%s' successfully created.\n" +msgstr "Unterverzeichnis '%s' für Konfigurationsdaten erfolgreich erstellt.\n" + +#: user_config.cpp:240 +#, c-format +msgid "Config file '%s' does not exist, it will be created.\n" +msgstr "Konfigurationsdatei '%s' kann nicht gefunden werden. Wird erstellt.\n" + +#: user_config.cpp:252 +#, c-format +msgid "No tuxkart-config node" +msgstr "" + +#: user_config.cpp:261 +#, c-format +msgid "" +"\n" +"Config file version '%d' is too old.\n" +"The following changes have been applied in the current SuperTuxKart version:\n" +msgstr "" +"\n" +"Version der Konfigurationsdatei '%d' ist viel zu alt.\n" +"Die folgenden Änderungen wurden in der aktuellen Version von SuperTuxKart hinzugefügt:\n" + +#: user_config.cpp:267 +#, c-format +msgid "- Single window menu, old status display,new keyboard style settings were removed\n" +msgstr "" + +#: user_config.cpp:269 +#, c-format +msgid "- Key bindings were changed, please check the settings. All existing values were discarded.\n" +msgstr "" + +#: user_config.cpp:272 +#, c-format +msgid "Config file version '%d' is too old. Discarding your configuration. Sorry. :(\n" +msgstr "Die Version '%d' der Konfigurationsdatei ist zu alt. Die Konfiguration kann leider nicht verwendet werden. \n" + +#: user_config.cpp:280 +#, c-format +msgid "This warning can be ignored.\n" +msgstr "Diese Warnung kann auch ignoriert werden.\n" + +#: user_config.cpp:313 +#, c-format +msgid "No '%s' node" +msgstr "" + +#: user_config.cpp:338 +#, c-format +msgid "Error while parsing config '%s':\n" +msgstr "Fehler beim Parsen der Konfigurationsdatei '%s':\n" + +#: user_config.cpp:490 +#, c-format +msgid "Couldn't write config: " +msgstr "Kann Konfigurationsdatei nicht auf Festplatte schreiben:" + +#: user_config.cpp:549 +#, c-format +msgid "%s" +msgstr "%s" + +#: user_config.cpp:552 +#, c-format +msgid "joy %d axis %d %c" +msgstr "Joystick %d Achsen %d %c" + +#: user_config.cpp:556 +#, c-format +msgid "joy %d btn %d" +msgstr "Joystick %d Knopf %d" + +#: user_config.cpp:559 +#, c-format +msgid "joy %d hat %d" +msgstr "Joystick %d Richtungstasten %d" + +#: user_config.cpp:562 +#, c-format +msgid "mouse btn %d" +msgstr "Maus Schalter %d" + +#: user_config.cpp:565 +#, c-format +msgid "mouse axis %d %c" +msgstr "Maus Achsen %d %c" + +#: user_config.cpp:569 +#, c-format +msgid "Invalid" +msgstr "Ungültig" + +#: gui/char_sel.cpp:52 +#, c-format +msgid "Player %d, choose a driver" +msgstr "Wähle einen Fahrer, Spieler %d" + +#: gui/char_sel.cpp:76 +msgid "No driver choosed" +msgstr "Kein Fahrer ausgewählt" + +#: gui/config_controls.cpp:28 +msgid "Edit controls for which player?" +msgstr "Steuerung für welchen Spieler einstellen?" + +#: gui/config_controls.cpp:41 +#: gui/config_display.cpp:49 +#: gui/config_sound.cpp:56 +#: gui/difficulty.cpp:46 +#: gui/game_mode.cpp:48 +#: gui/grand_prix_select.cpp:58 +#: gui/num_laps.cpp:43 +#: gui/num_players.cpp:41 +#: gui/options.cpp:50 +#: gui/player_controls.cpp:54 +#: gui/scrolled_text.cpp:74 +msgid "Press to go back" +msgstr "Taste für verlassen, ohne zu ändern" + +#: gui/config_display.cpp:40 +msgid "Display Settings" +msgstr "Grafikeinstellungen" + +#: gui/config_display.cpp:43 +#: gui/config_display.cpp:88 +msgid "Fullscreen mode" +msgstr "Vollbildmodus" + +#: gui/config_display.cpp:47 +#: gui/config_display.cpp:86 +msgid "Window mode" +msgstr "Fenstermodus" + +#: gui/config_sound.cpp:35 +msgid "Sound Settings" +msgstr "Musikeinstellungen" + +#: gui/config_sound.cpp:42 +msgid " Turn off music " +msgstr "Musik ausschalten" + +#: gui/config_sound.cpp:45 +msgid " Turn on music " +msgstr "Musik einschalten" + +#: gui/config_sound.cpp:49 +msgid " Turn off sound effects " +msgstr "Geräuscheffekte ausschalten" + +#: gui/config_sound.cpp:52 +msgid " Turn on sound effects " +msgstr "Geräuscheffekte einschalten" + +#: gui/config_sound.cpp:88 +msgid "Turn on music" +msgstr "Musik einschalten" + +#: gui/config_sound.cpp:93 +msgid "Turn off music" +msgstr "Musik ausschalten" + +#: gui/config_sound.cpp:101 +msgid "Turn on sound effects" +msgstr "Geräuscheffekte einschalten" + +#: gui/config_sound.cpp:106 +msgid "Turn off sound effects" +msgstr "Geräuscheffekte ausschalten" + +#: gui/credits_menu.cpp:44 +#, c-format +msgid "Couldn't load '%s'\n" +msgstr "Kann Datei '%s' nicht öffnen.\n" + +#: gui/credits_menu.cpp:45 +msgid "CREDIT file was not installed properly!!" +msgstr "Die Datei mit der Liste der Beteiligten wurde nicht richtig installiert!!" + +#: gui/credits_menu.cpp:46 +msgid "Please check 'data/CREDIT'!!" +msgstr "Bitte Datei \"data/CREDIT\" überprüfen!!" + +#: gui/difficulty.cpp:37 +msgid "Choose your skill level" +msgstr "Schwierigkeitsgrad wählen" + +#: gui/difficulty.cpp:42 +msgid "Racer" +msgstr "Rennfahrer" + +#: gui/difficulty.cpp:43 +msgid "Driver" +msgstr "Pistenschreck" + +#: gui/difficulty.cpp:44 +msgid "Novice" +msgstr "Fahranfänger" + +#: gui/game_mode.cpp:37 +msgid "Choose a Race Mode" +msgstr "Wähle die Strecke" + +#: gui/game_mode.cpp:41 +msgid "Grand Prix" +msgstr "Grand Prix" + +#: gui/game_mode.cpp:42 +msgid "Quick Race" +msgstr "Schnelle Runde" + +#: gui/game_mode.cpp:45 +msgid "Time Trial" +msgstr "Gegen die Zeit" + +#: gui/grand_prix_ending.cpp:61 +#, c-format +msgid "The winner is %s!" +msgstr "Gewonnen hat %s!" + +#: gui/grand_prix_ending.cpp:65 +#: gui/race_results_gui.cpp:87 +msgid "Back to the main menu" +msgstr "Zurück zum Hauptmenü" + +#: gui/grand_prix_select.cpp:34 +msgid "Choose a Grand Prix" +msgstr "Wähle einen Kurs" + +#: gui/help_menu.cpp:132 +msgid "Force your rivals bite *your* dust!" +msgstr "Lass Deine Gegner *Deinen* Staub schlucken!" + +#: gui/help_menu.cpp:136 +msgid "Avoid bananas" +msgstr "Halte dich von Bananen fern" + +#: gui/help_menu.cpp:137 +msgid "Grab blue boxes and coins" +msgstr "Sammle blaue Kisten und Münzen" + +#: gui/help_menu.cpp:177 +msgid "" +"At high speeds wheelies drive you faster, but you can't steer. If you\n" +"get stuck or fall too far, use the rescue button to get back on track." +msgstr "" +"Bei hohen Geschwindigkeiten hilft der Kickstart beim schnelleren \n" +"Vorankommen auf der Strecke. Allerdings kann dann nicht \n" +"gelenkt werden. Wenn du stecken bleibst, oder über die Fahrbahn hinausschießt, benutze einfach den \n" +"Rettungsknopf um wieder auf die Fahrbahn zu kommen." + +#: gui/help_menu.cpp:184 +msgid "Check the current keys bindings for the first player:" +msgstr "Überprüfe die Tastenbelegung für den ersten Spieler:" + +#: gui/help_menu.cpp:205 +msgid "Next screen" +msgstr "Nächster Bildschirm" + +#: gui/help_menu.cpp:206 +#: gui/help_menu.cpp:263 +msgid "Go back to the main menu" +msgstr "Zurück zum Hauptmenü" + +#: gui/help_menu.cpp:223 +msgid "To help you win, there are certain collectables you can grab:" +msgstr "Um dich beim Gewinnen ein wenig zu unterstützen, gibt es kleine Hilfen zum Aufsammeln:" + +#: gui/help_menu.cpp:234 +#: gui/help_menu.cpp:259 +msgid "Missile - fast stopper in a straight line" +msgstr "Rakete - Vollbremsung in einer geraden Linie" + +#: gui/help_menu.cpp:238 +msgid "Homing missile - follows rivals, but is slower than the missile" +msgstr "Lenkrakete - Folgt Gegnern. Ist aber etwas langsamer als die andere Rakete" + +#: gui/help_menu.cpp:242 +msgid "Fuzzy blob/Spark - very slow, but bounces from walls" +msgstr "Haariger Blubber/Blitz - sehr langsam, aber prallt von Wänden ab" + +#: gui/help_menu.cpp:246 +msgid "Zipper - speed boost" +msgstr "Reißverschluss - Geschwindigkeitssteigerung" + +#: gui/help_menu.cpp:250 +msgid "Parachute - slows down all karts in a better position!" +msgstr "Fallschirm - Bremst alle vorrausfahrenden Karts ab!" + +#: gui/help_menu.cpp:254 +msgid "Anvil - slows down greatly the kart in the first position" +msgstr "Amboss - Bremst das Kart an erster Position sehr stark" + +#: gui/help_menu.cpp:262 +msgid "Previous screen" +msgstr "Voriger Bildschirm" + +#: gui/main_menu.cpp:43 +msgid "Single Player" +msgstr "Einzelspieler" + +#: gui/main_menu.cpp:44 +msgid "Multiplayer" +msgstr "Mehrspieler" + +#: gui/main_menu.cpp:45 +#: gui/options.cpp:38 +#: gui/race_menu.cpp:47 +msgid "Options" +msgstr "Einstellungen" + +#: gui/main_menu.cpp:46 +msgid "Quit" +msgstr "Beenden" + +#: gui/main_menu.cpp:48 +#: gui/race_menu.cpp:48 +msgid "Help" +msgstr "Hilfe" + +#: gui/main_menu.cpp:49 +msgid "Credits" +msgstr "Mitwirkende" + +#: gui/num_laps.cpp:34 +msgid "Choose number of laps" +msgstr "Wähle die Anzahl der Runden" + +#: gui/num_laps.cpp:36 +msgid "One" +msgstr "Eine" + +#: gui/num_laps.cpp:37 +msgid "Two" +msgstr "Zwei" + +#: gui/num_laps.cpp:38 +msgid "Four" +msgstr "Vier" + +#: gui/num_laps.cpp:39 +msgid "Five" +msgstr "Fünf" + +#: gui/num_laps.cpp:40 +msgid "Six" +msgstr "Sechs" + +#: gui/num_laps.cpp:41 +msgid "Eight" +msgstr "Acht" + +#: gui/num_players.cpp:37 +msgid "Two Players" +msgstr "Zwei Spieler" + +#: gui/num_players.cpp:38 +msgid "Three Players" +msgstr "Drei Spieler" + +#: gui/num_players.cpp:39 +msgid "Four Players" +msgstr "Vier Spieler" + +#: gui/options.cpp:39 +msgid "Controls" +msgstr "Steuerung" + +#: gui/options.cpp:46 +msgid "Display" +msgstr "Anzeigeoptionen" + +#: gui/options.cpp:48 +msgid "Sound" +msgstr "Lautstärke" + +#: gui/player_controls.cpp:30 +msgid "Left" +msgstr "Links" + +#: gui/player_controls.cpp:30 +msgid "Right" +msgstr "Rechts" + +#: gui/player_controls.cpp:30 +msgid "Accelerate" +msgstr "Beschleunigen" + +#: gui/player_controls.cpp:31 +msgid "Brake" +msgstr "Bremsen" + +#: gui/player_controls.cpp:31 +msgid "Wheelie" +msgstr "Kickstart" + +#: gui/player_controls.cpp:31 +msgid "Jump" +msgstr "Sprung" + +#: gui/player_controls.cpp:32 +msgid "Rescue" +msgstr "Retten" + +#: gui/player_controls.cpp:32 +msgid "Fire" +msgstr "Schießen" + +#: gui/player_controls.cpp:39 +#, c-format +msgid "Choose your controls, %s" +msgstr "Wähle die Steuerungsart, %s" + +#: gui/player_controls.cpp:79 +msgid "Press key" +msgstr "Taste drücken" + +#: gui/race_gui.cpp:335 +#, c-format +msgid "YOU FINISHED %s" +msgstr "%s hat es ins Ziel geschafft" + +#: gui/race_gui.cpp:340 +msgid "CONGRATULATIONS" +msgstr "Herzlichen Glückwunsch!" + +#: gui/race_gui.cpp:341 +msgid "YOU WON THE RACE!" +msgstr "Du hast das Rennen gewonnen!" + +#: gui/race_gui.cpp:489 +#: gui/race_gui.cpp:503 +msgid "WRONG WAY!" +msgstr "Falsche Richtung!" + +#: gui/race_gui.cpp:770 +msgid "REV" +msgstr "Rückwärts" + +#: gui/race_gui.cpp:817 +#, c-format +msgid "Finished" +msgstr "Beendet" + +#: gui/race_gui.cpp:822 +msgid "Lap" +msgstr "Runde" + +#: gui/race_gui.cpp:856 +msgid "Ready!" +msgstr "Achtung!" + +#: gui/race_gui.cpp:859 +msgid "Set!" +msgstr "Fertig?" + +#: gui/race_gui.cpp:862 +msgid "Go!" +msgstr "Los!" + +#: gui/race_gui.cpp:879 +msgid "Penalty time!!" +msgstr "Strafzeit!!" + +#: gui/race_menu.cpp:43 +msgid "Paused" +msgstr "Pause" + +#: gui/race_menu.cpp:46 +msgid "Return To Race" +msgstr "Zurück zum Rennen" + +#: gui/race_menu.cpp:49 +msgid "Restart Race" +msgstr "Rennen neu starten" + +#: gui/race_menu.cpp:53 +#: gui/race_results_gui.cpp:91 +msgid "Setup New Race" +msgstr "Neues Rennen konfigurieren" + +#: gui/race_menu.cpp:56 +msgid "Exit Race" +msgstr "Rennen beenden" + +#: gui/race_results_gui.cpp:41 +msgid "Race results" +msgstr "Rennergebnisse" + +#: gui/race_results_gui.cpp:88 +msgid "Race in this track again" +msgstr "Diese Runde nochmal fahren" + +#: gui/track_sel.cpp:42 +msgid "Choose a Track" +msgstr "Wähle eine Strecke aus" + +#: lisp/parser.cpp:52 +#, c-format +msgid "Couldn't open file '%s'." +msgstr "Kann Datei '%s' nicht öffnen." + +#: lisp/writer.cpp:40 +#, c-format +msgid "LispWriter Error: Couldn't open file '%s'." +msgstr "" + diff --git a/data/po/de/LC_MESSAGES/supertuxkart.mo b/data/po/de/LC_MESSAGES/supertuxkart.mo new file mode 100644 index 000000000..b4e7af7c1 Binary files /dev/null and b/data/po/de/LC_MESSAGES/supertuxkart.mo differ diff --git a/src/Makefile.am b/src/Makefile.am index 9631503d4..39717dde8 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -52,6 +52,7 @@ supertuxkart_SOURCES = main.cpp \ stk_config.cpp stk_config.hpp \ highscores.cpp highscores.hpp \ highscore_manager.cpp highscore_manager.hpp \ + unlock_manager.cpp unlock_manager.hpp \ file_manager.cpp file_manager.hpp \ loader.cpp loadre.hpp \ race_manager.cpp race_manager.hpp \ @@ -91,6 +92,10 @@ supertuxkart_SOURCES = main.cpp \ translation.cpp translation.hpp \ traffic.cpp \ player.hpp \ + challenges/challenge.hpp challenges/challenge.cpp \ + challenges/all_tracks.cpp challenges/all_tracks.hpp \ + challenges/energy_math_class.cpp challenges/energy_math_class.hpp\ + challenges/win_gotm_cup.cpp challenges/win_gotm_cup.hpp \ lisp/lisp.cpp lisp/lisp.hpp \ lisp/lexer.cpp lisp/lexer.hpp \ lisp/parser.cpp lisp/parser.hpp \ @@ -119,6 +124,8 @@ supertuxkart_SOURCES = main.cpp \ gui/help_page_two.cpp gui/help_page_two.hpp \ gui/credits_menu.cpp gui/credits_menu.hpp \ gui/grand_prix_select.cpp gui/grand_prix_select.hpp \ + gui/challenges_menu.cpp gui/challenges_menu.hpp \ + gui/feature_unlocked.cpp gui/feature_unlocked.hpp \ gui/font.hpp gui/font.cpp \ robots/default_robot.cpp robots/default_robot.hpp \ replay_buffer_tpl.hpp \ diff --git a/src/challenges/all_tracks.cpp b/src/challenges/all_tracks.cpp new file mode 100755 index 000000000..43418668b --- /dev/null +++ b/src/challenges/all_tracks.cpp @@ -0,0 +1,58 @@ +// $Id: all_tracks.cpp 1259 2007-09-24 12:28:19Z hiker $ +// +// SuperTuxKart - a fun racing game with go-kart +// Copyright (C) 2008 Joerg Henrichs +// +// 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 ruseful, +// 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 +#include "challenges/all_tracks.hpp" +#include "world.hpp" +#include "unlock_manager.hpp" + +AllTracks::AllTracks() : Challenge("alltracks", "All Tracks") +{ + setChallengeDescription("Finish one race\nin each track"); + setFeatureDescription("New track: SnowTuxPeak\nnow available"); + setFeature("snowtuxpeak"); +} // AllTracks + +//----------------------------------------------------------------------------- +void AllTracks::loadState(const lisp::Lisp* config) +{ + config->getVector("solved-tracks", m_raced_tracks); +} // loadState + +//----------------------------------------------------------------------------- +void AllTracks::saveState(lisp::Writer* writer) +{ + writer->write("solved-tracks\t", m_raced_tracks); +} // saveState + +//----------------------------------------------------------------------------- +bool AllTracks::raceFinished() +{ + // If the current track is not yet in the list of raced tracks, add it: + std::string track_name = world->getTrack()->getIdent(); + if(std::find(m_raced_tracks.begin(), m_raced_tracks.end(), track_name) + ==m_raced_tracks.end()) + { + m_raced_tracks.push_back(track_name); + } + + // Check if all tracks are finished. If so, unlock feature + return (m_raced_tracks.size()==13); +} // raceFinished +//----------------------------------------------------------------------------- diff --git a/src/challenges/all_tracks.hpp b/src/challenges/all_tracks.hpp new file mode 100755 index 000000000..efe739b41 --- /dev/null +++ b/src/challenges/all_tracks.hpp @@ -0,0 +1,40 @@ +// $Id: all_tracks.hpp 1259 2007-09-24 12:28:19Z hiker $ +// +// SuperTuxKart - a fun racing game with go-kart +// Copyright (C) 2008 Joerg Henrichs +// +// 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_ALL_TRACKS_H +#define HEADER_ALL_TRACKS_H + +#include +#include + +#include "challenges/challenge.hpp" + +class AllTracks : public Challenge +{ +private: + std::vector m_raced_tracks; +public: + AllTracks(); + virtual void loadState(const lisp::Lisp* config); + virtual void saveState(lisp::Writer* writer); + virtual bool raceFinished(); + +}; // AllTracks + +#endif diff --git a/src/challenges/challenge.cpp b/src/challenges/challenge.cpp new file mode 100755 index 000000000..3d83447b9 --- /dev/null +++ b/src/challenges/challenge.cpp @@ -0,0 +1,54 @@ +// $Id: challenge.cpp 1259 2007-09-24 12:28:19Z hiker $ +// +// SuperTuxKart - a fun racing game with go-kart +// Copyright (C) 2008 Joerg Henrichs +// +// 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 "challenges/challenge.hpp" +#include "unlock_manager.hpp" + +Challenge::Challenge(std::string id, std::string name) : + m_state(CH_INACTIVE), m_Id(id), m_Name(name) +{ +} // Challenge + +//----------------------------------------------------------------------------- +/** Loads the state for a challenge object (esp. m_state), and calls the + * virtual function loadState for additional information + */ +void Challenge::load(const lisp::Lisp* config) +{ + const lisp::Lisp* subnode= config->getLisp(getId()); + if(!subnode) return; + + // See if the challenge is solved (it's activated later from the + // unlock_manager). + bool finished=false; + subnode->get("solved", finished); + m_state = finished ? CH_SOLVED : CH_INACTIVE; + if(!finished) loadState(subnode); +} // load + +//----------------------------------------------------------------------------- +void Challenge::save(lisp::Writer* writer) +{ + writer->beginList(getId()); + writer->write("solved", isSolved()); + if(!isSolved()) saveState(writer); + writer->endList(getId()); +} // save + +//----------------------------------------------------------------------------- diff --git a/src/challenges/challenge.hpp b/src/challenges/challenge.hpp new file mode 100755 index 000000000..59d2e7785 --- /dev/null +++ b/src/challenges/challenge.hpp @@ -0,0 +1,79 @@ +// $Id: challenge.hpp 1259 2007-09-24 12:28:19Z hiker $ +// +// SuperTuxKart - a fun racing game with go-kart +// Copyright (C) 2008 Joerg Henrichs +// +// 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_CHALLENGE_H +#define HEADER_CHALLENGE_H + +#include +#include + +#include "lisp/lisp.hpp" +#include "lisp/parser.hpp" +#include "lisp/writer.hpp" + + +// A base class for all challenges +class Challenge +{ + enum {CH_INACTIVE, // challenge not yet possible + CH_ACTIVE, // challenge possible, but not yet solved + CH_SOLVED} m_state; // challenge was solved + std::string m_Id; // short, internal name for this challenge + std::string m_Name; // name used in menu for this challenge + std::string m_Description; // description + std::string m_feature_description; // Description of feature to unlock + std::string m_feature; // Feature to unlock + std::vector m_prerequisites; +public: + Challenge(std::string id, std::string name); + virtual ~Challenge() {}; + const std::string& getId() const {return m_Id; } + const std::string& getName() const {return m_Name; } + void setFeatureDescription(const std::string& f) + {m_feature_description=f; } + const std::string& + getFeatureDescription() const {return m_feature_description; } + void setFeature(const std::string& s) {m_feature=s; } + const std::string& getFeature() const {return m_feature; } + void setChallengeDescription(const std::string& d) + {m_Description=d; } + const std::string& + getChallengeDescription() const {return m_Description; } + void addDependency(const std::string id) {m_prerequisites.push_back(id);} + bool isSolved() const {return m_state==CH_SOLVED; } + bool isActive() const {return m_state==CH_ACTIVE; } + void setSolved() {m_state = CH_SOLVED; } + void setActive() {m_state = CH_ACTIVE; } + const std::vector& + getPrerequisites() const {return m_prerequisites; } + void load(const lisp::Lisp* config); + void save(lisp::Writer* writer); + + // These functions are meant for customisation, e.g. load/save + // additional state information specific to the challenge + virtual void loadState(const lisp::Lisp* config) {}; + virtual void saveState(lisp::Writer* writer) {}; + + // These functions are called when a race/gp is finished. It allows + // the challenge to unlock features (when returning true), otherwise + // the feature remains locked. + virtual bool raceFinished() {return false;} // end of a race + virtual bool grandPrixFinished() {return false;} // end of a GP +}; +#endif diff --git a/src/challenges/energy_math_class.cpp b/src/challenges/energy_math_class.cpp new file mode 100755 index 000000000..a0b7fb473 --- /dev/null +++ b/src/challenges/energy_math_class.cpp @@ -0,0 +1,43 @@ +// $Id: energy_math_class.cpp 1259 2007-09-24 12:28:19Z hiker $ +// +// SuperTuxKart - a fun racing game with go-kart +// Copyright (C) 2008 Joerg Henrichs +// +// 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 ruseful, +// 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 +#include "challenges/energy_math_class.hpp" +#include "world.hpp" +#include "unlock_manager.hpp" + +EnergyMathClass::EnergyMathClass() : Challenge("energymathclass", "Collect Coins in Race track") +{ + setChallengeDescription("Collect at least 6 coins\non three laps of\nOliver's Math Class\nin under 1 minute."); + setFeatureDescription("New game mode\n'Grand Prix'\nnow available"); + setFeature("grandprix"); +} // EnergyMathClass + +//----------------------------------------------------------------------------- +bool EnergyMathClass::raceFinished() +{ + std::string track_name = world->getTrack()->getIdent(); + if(track_name!="olivermath") return false; // wrong track + Kart* kart=world->getPlayerKart(0); + if(kart->getFinishTime()>60) return false; // too slow + if(kart->getLap()!=3 ) return false; // wrong number of laps + if(kart->getNumHerring()<6 ) return false; // not enough herrings + return true; +} // raceFinished +//----------------------------------------------------------------------------- diff --git a/src/challenges/energy_math_class.hpp b/src/challenges/energy_math_class.hpp new file mode 100755 index 000000000..39670744d --- /dev/null +++ b/src/challenges/energy_math_class.hpp @@ -0,0 +1,35 @@ +// $Id: energy_math_class.hpp 1259 2007-09-24 12:28:19Z hiker $ +// +// SuperTuxKart - a fun racing game with go-kart +// Copyright (C) 2008 Joerg Henrichs +// +// 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_ENERGY_MATH_CLASS_H +#define HEADER_ENERGY_MATH_CLASS_H + +#include +#include + +#include "challenges/challenge.hpp" + +class EnergyMathClass : public Challenge +{ +public: + EnergyMathClass(); + virtual bool raceFinished(); +}; // EnergyMathClass + +#endif diff --git a/src/challenges/win_gotm_cup.cpp b/src/challenges/win_gotm_cup.cpp new file mode 100755 index 000000000..2b287c332 --- /dev/null +++ b/src/challenges/win_gotm_cup.cpp @@ -0,0 +1,52 @@ +// $Id: win_gotm_cup.cpp 1259 2007-09-24 12:28:19Z hiker $ +// +// SuperTuxKart - a fun racing game with go-kart +// Copyright (C) 2008 Joerg Henrichs +// +// 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 ruseful, +// 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 +#include "challenges/win_gotm_cup.hpp" +#include "world.hpp" +#include "unlock_manager.hpp" +#include "race_setup.hpp" +#include "race_manager.hpp" + +WinGOTMCup::WinGOTMCup() : Challenge("wingotmcup", "Win GOTM Cup") +{ + setChallengeDescription("Win the GOTM Cup\non level 'racer'\nwith at least\nthree computer opponents."); + setFeatureDescription("New track\n'Amazonian Journey'\navailable"); + // The energymathclass challenge must be done, otherwise GP can't be selected + addDependency("energymathclass"); + setFeature("jungle"); +} // WinGOTMCup + +//----------------------------------------------------------------------------- +bool WinGOTMCup::grandPrixFinished() +{ + const RaceSetup* race=&world->m_race_setup; + if (race->m_mode != RaceSetup::RM_GRAND_PRIX || + race->m_difficulty != RD_HARD || + race->getNumKarts() < 4 || + race->getNumPlayers() > 1) return false; + // Check if the player was number one: + for(int i=0; i<(int)world->getNumKarts(); i++) + { + const Kart* k=world->getKart(i); + if(k->isPlayerKart()) return k->getPosition()==1; + } + return false; +} // raceFinished +//----------------------------------------------------------------------------- diff --git a/src/challenges/win_gotm_cup.hpp b/src/challenges/win_gotm_cup.hpp new file mode 100755 index 000000000..3c4dd1518 --- /dev/null +++ b/src/challenges/win_gotm_cup.hpp @@ -0,0 +1,35 @@ +// $Id: win_gotm_cup.hpp 1259 2007-09-24 12:28:19Z hiker $ +// +// SuperTuxKart - a fun racing game with go-kart +// Copyright (C) 2008 Joerg Henrichs +// +// 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_WIN_GOTM_CUP_H +#define HEADER_WIN_GOTM_CUP_H + +#include +#include + +#include "challenges/challenge.hpp" + +class WinGOTMCup: public Challenge +{ +public: + WinGOTMCup(); + virtual bool grandPrixFinished(); +}; // WinGOTMCup + +#endif diff --git a/src/file_manager.cpp b/src/file_manager.cpp index 7c853e1a2..c784d2378 100644 --- a/src/file_manager.cpp +++ b/src/file_manager.cpp @@ -101,7 +101,9 @@ FileManager::FileManager() #else m_root_dir = "/usr/local/share/games/supertuxkart" ; #endif - fprintf(stderr, _("Data files will be fetched from: '%s'\n"), + // We can't use _() here, since translations will only be initalised + // after the filemanager (to get the path to the tranlsations from it) + fprintf(stderr, "Data files will be fetched from: '%s'\n", m_root_dir.c_str() ); pushTextureSearchPath(m_root_dir+"/data/textures"); @@ -207,6 +209,11 @@ std::string FileManager::getHerringDir() const { return m_root_dir+"/data/herrings"; } // getHerringDir +//----------------------------------------------------------------------------- +std::string FileManager::getTranslationDir() const +{ + return m_root_dir+"/data/po"; +} // getTranslationDir //----------------------------------------------------------------------------- std::vector FileManager::getMusicDirs() const diff --git a/src/file_manager.hpp b/src/file_manager.hpp index 02d293a2e..bc6214ca5 100644 --- a/src/file_manager.hpp +++ b/src/file_manager.hpp @@ -40,26 +40,27 @@ public: FileManager(); ~FileManager(); - std::string getHomeDir () const; - std::string getTrackDir () const; - std::string getKartDir () const; - std::string getHerringDir () const; + std::string getHomeDir () const; + std::string getTrackDir () const; + std::string getKartDir () const; + std::string getHerringDir () const; + std::string getTranslationDir() const; std::vectorgetMusicDirs() const; - std::string getTextureFile (const std::string& fname) const; - std::string getKartFile (const std::string& fname, - const std::string& kart="") const; - std::string getTrackFile (const std::string& fname, - const std::string& track="") const; - std::string getConfigFile (const std::string& fname) const; - std::string getHighscoreFile(const std::string& fname) const; - std::string getLogFile (const std::string& fname) const; - std::string getHerringFile (const std::string& fname) const; - std::string getMusicFile (const std::string& fname) const; - std::string getSFXFile (const std::string& fname) const; - std::string getFontFile (const std::string& fname) const; - std::string getModelFile (const std::string& fname) const; + std::string getTextureFile (const std::string& fname) const; + std::string getKartFile (const std::string& fname, + const std::string& kart="") const; + std::string getTrackFile (const std::string& fname, + const std::string& track="") const; + std::string getConfigFile (const std::string& fname) const; + std::string getHighscoreFile (const std::string& fname) const; + std::string getLogFile (const std::string& fname) const; + std::string getHerringFile (const std::string& fname) const; + std::string getMusicFile (const std::string& fname) const; + std::string getSFXFile (const std::string& fname) const; + std::string getFontFile (const std::string& fname) const; + std::string getModelFile (const std::string& fname) const; #ifdef HAVE_GHOST_REPLAY - std::string getReplayFile(const std::string& fname) const; + std::string getReplayFile (const std::string& fname) const; #endif void listFiles(std::set& result, const std::string& dir, diff --git a/src/gui/challenges_menu.cpp b/src/gui/challenges_menu.cpp new file mode 100755 index 000000000..b5a959ac4 --- /dev/null +++ b/src/gui/challenges_menu.cpp @@ -0,0 +1,93 @@ +// $Id: challenges_menu.cpp 1305 2007-11-26 14:28:15Z hiker $ +// +// SuperTuxKart - a fun racing game with go-kart +// Copyright (C) 2008 Joerg Henrichs +// +// 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 "gui/challenges_menu.hpp" +#include "widget_manager.hpp" +#include "menu_manager.hpp" +#include "unlock_manager.hpp" +#include "translation.hpp" + +enum WidgetTokens +{ + WTOK_TITLE, + WTOK_BACK, + WTOK_DESCRIPTION, + WTOK_CHALLENGES +}; + +ChallengesMenu::ChallengesMenu() +{ + const bool SHOW_RECT = true; + const bool SHOW_TEXT = true; + widget_manager->setInitialActivationState(false); + widget_manager->setInitialRectState(SHOW_RECT, WGT_AREA_ALL, WGT_TRANS_BLACK); + widget_manager->setInitialTextState(SHOW_TEXT, "", WGT_FNT_MED, WGT_FONT_GUI ); + + widget_manager->addWgt( WTOK_TITLE, 60, 10); + widget_manager->showWgtRect( WTOK_TITLE ); + widget_manager->setWgtText( WTOK_TITLE, _("Active Challenges")); + widget_manager->setWgtTextSize( WTOK_TITLE, WGT_FNT_LRG); + widget_manager->showWgtText( WTOK_TITLE ); + widget_manager->breakLine(); + + m_all_challenges=unlock_manager->getActiveChallenges(); + for(int i=0; i<(int)m_all_challenges.size(); i++) + { + widget_manager->addWgt(WTOK_CHALLENGES+i, 60, 10); + widget_manager->setWgtText( WTOK_CHALLENGES+i, _(m_all_challenges[i]->getName().c_str()) ); + widget_manager->activateWgt(WTOK_CHALLENGES+i); + widget_manager->breakLine(); + } + + widget_manager->addWgt( WTOK_DESCRIPTION, 60, 30); + widget_manager->showWgtRect( WTOK_DESCRIPTION ); + widget_manager->setWgtText( WTOK_DESCRIPTION, ""); + widget_manager->showWgtText( WTOK_DESCRIPTION ); + widget_manager->breakLine(); + + widget_manager->addWgt(WTOK_BACK, 50, 7); + widget_manager->showWgtRect(WTOK_BACK); + widget_manager->showWgtText(WTOK_BACK); + widget_manager->setWgtText(WTOK_BACK, _("Go back to the main menu")); + widget_manager->activateWgt(WTOK_BACK); + + widget_manager->layout(WGT_AREA_ALL); +} // ChallengesMenu +//----------------------------------------------------------------------------- +ChallengesMenu::~ChallengesMenu() +{ + widget_manager->reset(); +} // ~ChallengesMenu + +//----------------------------------------------------------------------------- + +void ChallengesMenu::select() +{ + if(widget_manager->getSelectedWgt()==WTOK_BACK) + { + menu_manager->popMenu(); + return; + } + int n=widget_manager->getSelectedWgt()-WTOK_CHALLENGES; + if(n>=0 && n<(int)m_all_challenges.size()) + { + widget_manager->setWgtText(WTOK_DESCRIPTION, + m_all_challenges[n]->getChallengeDescription()); + } +} // select diff --git a/src/gui/challenges_menu.hpp b/src/gui/challenges_menu.hpp new file mode 100755 index 000000000..aee73b59f --- /dev/null +++ b/src/gui/challenges_menu.hpp @@ -0,0 +1,38 @@ +// $Id: challenges.hpp 1305 2007-11-26 14:28:15Z hiker $ +// +// SuperTuxKart - a fun racing game with go-kart +// Copyright (C) 2008 Joerg Henrichs +// +// 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_CHALLENGES_H +#define HEADER_CHALLENGES_H + +#include +#include "challenges/challenge.hpp" +#include "base_gui.hpp" + +class ChallengesMenu: public BaseGUI +{ +private: + std::vector m_all_challenges; + +public: + ChallengesMenu(); + ~ChallengesMenu(); + void select (); +}; // ChallengesMenu + +#endif diff --git a/src/gui/char_sel.cpp b/src/gui/char_sel.cpp index 5df064a4c..fd48da5f7 100644 --- a/src/gui/char_sel.cpp +++ b/src/gui/char_sel.cpp @@ -29,6 +29,7 @@ #include "kart_properties.hpp" #include "material_manager.hpp" #include "material.hpp" +#include "unlock_manager.hpp" #include "translation.hpp" #if defined(WIN32) && !defined(__CYGWIN__) # define snprintf _snprintf @@ -83,6 +84,7 @@ CharSel::CharSel(int whichPlayer) if (kartAvailable(i)) { const KartProperties* kp= kart_properties_manager->getKartById(i); + if(unlock_manager->isLocked(kp->getIdent())) continue; Material *m = material_manager->getMaterial(kp->getIconFile()); widget_manager->addWgt( WTOK_RACER0 + i, 8, 11); widget_manager->showWgtRect( WTOK_RACER0 + i); diff --git a/src/gui/feature_unlocked.cpp b/src/gui/feature_unlocked.cpp new file mode 100755 index 000000000..109bda0f9 --- /dev/null +++ b/src/gui/feature_unlocked.cpp @@ -0,0 +1,87 @@ +// $Id: feature_unlocked.cpp 1305 2007-11-26 14:28:15Z hiker $ +// +// SuperTuxKart - a fun racing game with go-kart +// Copyright (C) 2008 Joerg Henrichs +// +// 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 "gui/feature_unlocked.hpp" +#include "widget_manager.hpp" +#include "menu_manager.hpp" +#include "unlock_manager.hpp" +#include "translation.hpp" + +enum WidgetTokens +{ + WTOK_TITLE, + WTOK_CONTINUE, + WTOK_DESCRIPTION +}; + +FeatureUnlocked::FeatureUnlocked() +{ + const bool SHOW_RECT = true; + const bool SHOW_TEXT = true; + widget_manager->setInitialActivationState(false); + widget_manager->setInitialRectState(SHOW_RECT, WGT_AREA_ALL, WGT_TRANS_BLACK); + widget_manager->setInitialTextState(SHOW_TEXT, "", WGT_FNT_MED, WGT_FONT_GUI ); + + widget_manager->addWgt( WTOK_TITLE, 60, 10); + widget_manager->showWgtRect( WTOK_TITLE ); + widget_manager->setWgtText( WTOK_TITLE, _("New Feature Unlocked")); + widget_manager->setWgtTextSize( WTOK_TITLE, WGT_FNT_LRG); + widget_manager->showWgtText( WTOK_TITLE ); + widget_manager->breakLine(); + + m_new_features=unlock_manager->getUnlockedFeatures(); + assert(m_new_features.size()>0); + unlock_manager->clearUnlocked(); + + widget_manager->addWgt( WTOK_DESCRIPTION, 60, 30); + widget_manager->showWgtRect( WTOK_DESCRIPTION ); + widget_manager->setWgtText( WTOK_DESCRIPTION, m_new_features[0]->getFeatureDescription()); + widget_manager->showWgtText( WTOK_DESCRIPTION ); + widget_manager->breakLine(); + + widget_manager->addWgt(WTOK_CONTINUE, 50, 7); + widget_manager->showWgtRect(WTOK_CONTINUE); + widget_manager->showWgtText(WTOK_CONTINUE); + widget_manager->setWgtText(WTOK_CONTINUE, _("Continue")); + widget_manager->activateWgt(WTOK_CONTINUE); + + widget_manager->layout(WGT_AREA_ALL); +} // FeatureUnlocked + +//----------------------------------------------------------------------------- +FeatureUnlocked::~FeatureUnlocked() +{ + widget_manager->reset(); +} // ~FeatureUnlocked + +//----------------------------------------------------------------------------- + +void FeatureUnlocked::select() +{ + assert(widget_manager->getSelectedWgt()==WTOK_CONTINUE); + m_new_features.erase(m_new_features.begin()); + if(m_new_features.size()>0) + { + widget_manager->setWgtText( WTOK_DESCRIPTION, m_new_features[0]->getFeature()); + } + else + { + menu_manager->popMenu(); + } +} // select diff --git a/src/gui/feature_unlocked.hpp b/src/gui/feature_unlocked.hpp new file mode 100755 index 000000000..81930b2a2 --- /dev/null +++ b/src/gui/feature_unlocked.hpp @@ -0,0 +1,38 @@ +// $Id: feature_unlocked.hpp 1305 2007-11-26 14:28:15Z hiker $ +// +// SuperTuxKart - a fun racing game with go-kart +// Copyright (C) 2008 Joerg Henrichs +// +// 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_FEATURE_UNLOCKED_H +#define HEADER_FEATURE_UNLOCKED_H + +#include +#include "challenges/challenge.hpp" +#include "base_gui.hpp" + +class FeatureUnlocked: public BaseGUI +{ +private: + std::vector m_new_features; + +public: + FeatureUnlocked(); + ~FeatureUnlocked(); + void select (); +}; // FeatureUnlocked + +#endif diff --git a/src/gui/game_mode.cpp b/src/gui/game_mode.cpp index 81f1b5ca1..9ceaf94d5 100644 --- a/src/gui/game_mode.cpp +++ b/src/gui/game_mode.cpp @@ -23,6 +23,7 @@ #include "menu_manager.hpp" #include "translation.hpp" #include "user_config.hpp" +#include "unlock_manager.hpp" enum WidgetTokens { @@ -49,7 +50,15 @@ GameMode::GameMode() widget_manager->setInitialActivationState(true); widget_manager->addWgt(WTOK_GP, 50, 7); - widget_manager->setWgtText( WTOK_GP, _("Grand Prix")); + if(unlock_manager->isLocked("grandprix")) + { + widget_manager->setWgtText( WTOK_GP, "???"); + widget_manager->deactivateWgt(WTOK_GP); + } + else + { + widget_manager->setWgtText( WTOK_GP, _("Grand Prix")); + } widget_manager->addWgt(WTOK_QUICKRACE, 50, 7); widget_manager->setWgtText( WTOK_QUICKRACE, _("Quick Race")); diff --git a/src/gui/grand_prix_ending.cpp b/src/gui/grand_prix_ending.cpp index c77a1e3e8..5b3bb9b08 100644 --- a/src/gui/grand_prix_ending.cpp +++ b/src/gui/grand_prix_ending.cpp @@ -26,6 +26,7 @@ #include "sound_manager.hpp" #include "grand_prix_ending.hpp" #include "kart_properties_manager.hpp" +#include "unlock_manager.hpp" #include "widget_manager.hpp" #include "race_manager.hpp" #include "game_manager.hpp" @@ -142,7 +143,14 @@ GrandPrixEnd::GrandPrixEnd() widget_manager->activateWgt(WTOK_QUIT); widget_manager->showWgtRect(WTOK_QUIT); widget_manager->showWgtText(WTOK_QUIT); - widget_manager->setWgtText(WTOK_QUIT, _("Back to the main menu")); + if(unlock_manager->getUnlockedFeatures().size()>0) + { + widget_manager->setWgtText(WTOK_QUIT, _("Continue")); + } + else + { + widget_manager->setWgtText(WTOK_QUIT, _("Back to the main menu")); + } widget_manager->layout(WGT_AREA_TOP); @@ -218,5 +226,17 @@ void GrandPrixEnd::update(float dt) //----------------------------------------------------------------------------- void GrandPrixEnd::select() { + // If a new feature was unlocked, display the new feature first + // before returning to the main menu + if(unlock_manager->getUnlockedFeatures().size()>0) + { + // This removes this menu from the stack, and adds the main menu. + // Then we push the new feature menu on top, so that it will be + // displayed next, and on return the main menu is shown. + menu_manager->switchToMainMenu(); + menu_manager->pushMenu(MENUID_UNLOCKED_FEATURE); + return; + } + menu_manager->switchToMainMenu(); } diff --git a/src/gui/grand_prix_select.cpp b/src/gui/grand_prix_select.cpp index 10196577c..b809504ee 100644 --- a/src/gui/grand_prix_select.cpp +++ b/src/gui/grand_prix_select.cpp @@ -25,6 +25,7 @@ #include "menu_manager.hpp" #include "race_manager.hpp" #include "user_config.hpp" +#include "unlock_manager.hpp" #include "translation.hpp" enum WidgetTokens @@ -65,6 +66,7 @@ GrandPrixSelect::GrandPrixSelect() if (StringUtils::has_suffix(*i, ".cup")) { CupData cup(*i); + if(unlock_manager->isLocked(cup.getName())) continue; m_all_cups.push_back(cup); widget_manager->addWgt(WTOK_FIRSTPRIX + nId, 40, 7); widget_manager->setWgtText(WTOK_FIRSTPRIX + nId, cup.getName()); diff --git a/src/gui/main_menu.cpp b/src/gui/main_menu.cpp index 93908d62a..eb7c361a9 100644 --- a/src/gui/main_menu.cpp +++ b/src/gui/main_menu.cpp @@ -25,11 +25,13 @@ #include "menu_manager.hpp" #include "translation.hpp" #include "user_config.hpp" +#include "unlock_manager.hpp" enum WidgetTokens { WTOK_SINGLE, WTOK_MULTI, + WTOK_CHALLENGES, WTOK_OPTIONS, WTOK_QUIT, WTOK_EMPTY, @@ -54,6 +56,12 @@ MainMenu::MainMenu() widget_manager->addWgt(WTOK_MULTI, 25, 7); widget_manager->setWgtText( WTOK_MULTI, _("Multiplayer") ); + std::vector all_challenges=unlock_manager->getActiveChallenges(); + if(all_challenges.size()>0) + { + widget_manager->addWgt(WTOK_CHALLENGES, 25, 7); + widget_manager->setWgtText( WTOK_CHALLENGES, _("Challenges") ); + } widget_manager->addWgt(WTOK_OPTIONS, 25, 7); widget_manager->setWgtText( WTOK_OPTIONS, _("Options") ); @@ -105,7 +113,9 @@ void MainMenu::select() case WTOK_MULTI: menu_manager->pushMenu(MENUID_NUMPLAYERS); break; - + case WTOK_CHALLENGES: + menu_manager->pushMenu(MENUID_CHALLENGES); + break; case WTOK_OPTIONS: menu_manager->pushMenu(MENUID_OPTIONS); break; diff --git a/src/gui/menu_manager.cpp b/src/gui/menu_manager.cpp index 07e234773..8f0db4ede 100644 --- a/src/gui/menu_manager.cpp +++ b/src/gui/menu_manager.cpp @@ -52,6 +52,8 @@ #include "sdldrv.hpp" #include "user_config.hpp" #include "widget_manager.hpp" +#include "challenges_menu.hpp" +#include "feature_unlocked.hpp" using namespace std; @@ -144,6 +146,9 @@ void MenuManager::update() case MENUID_MAINMENU: m_current_menu= new MainMenu(); break; + case MENUID_CHALLENGES: + m_current_menu= new ChallengesMenu(); + break; case MENUID_CHARSEL_P1: case MENUID_CHARSEL_P2: case MENUID_CHARSEL_P3: @@ -162,6 +167,9 @@ void MenuManager::update() case MENUID_TRACKSEL: m_current_menu= new TrackSel(); break; + case MENUID_UNLOCKED_FEATURE: + m_current_menu = new FeatureUnlocked(); + break; case MENUID_NUMLAPS: m_current_menu= new NumLaps(); break; @@ -260,7 +268,7 @@ void MenuManager::update() } } // update -//----------------------------------------------------------------------------- +//----------k------------------------------------------------------------------- void MenuManager::switchToGrandPrixEnding() { if (m_current_menu != NULL) diff --git a/src/gui/menu_manager.hpp b/src/gui/menu_manager.hpp index a85666756..725a31113 100644 --- a/src/gui/menu_manager.hpp +++ b/src/gui/menu_manager.hpp @@ -32,6 +32,7 @@ enum MenuManagerIDs MENUID_CHARSEL_P2, MENUID_CHARSEL_P3, MENUID_CHARSEL_P4, + MENUID_CHALLENGES, MENUID_DIFFICULTY, MENUID_GAMEMODE, MENUID_RACERESULT, @@ -44,6 +45,7 @@ enum MenuManagerIDs MENUID_OPTIONS, MENUID_EXITGAME, MENUID_GRANDPRIXSELECT, + MENUID_UNLOCKED_FEATURE, // menu configuration MENUID_CONFIG_DISPLAY, diff --git a/src/gui/race_results_gui.cpp b/src/gui/race_results_gui.cpp index 032a8a348..1c0e2810e 100644 --- a/src/gui/race_results_gui.cpp +++ b/src/gui/race_results_gui.cpp @@ -27,6 +27,7 @@ #include "menu_manager.hpp" #include "race_manager.hpp" #include "highscore_manager.hpp" +#include "unlock_manager.hpp" #include "translation.hpp" enum WidgetTokens @@ -149,26 +150,35 @@ RaceResultsGUI::RaceResultsGUI() widget_manager->setInitialActivationState(true); widget_manager->addWgt( WTOK_CONTINUE, 60, 7); - if(world->m_race_setup.m_mode==RaceSetup::RM_GRAND_PRIX) - { - widget_manager->setWgtText( WTOK_CONTINUE, _("Continue Grand Prix")); - } - else - { - widget_manager->setWgtText( WTOK_CONTINUE, _("Back to the main menu")); - } - widget_manager->breakLine(); - widget_manager->addWgt( WTOK_RESTART_RACE, 60, 7); - widget_manager->setWgtText( WTOK_RESTART_RACE, _("Race in this track again")); - widget_manager->breakLine(); - - if(world->m_race_setup.m_mode==RaceSetup::RM_QUICK_RACE) + // If a new feature was unlocked, only offer 'continue' otherwise add the + // full menu choices. The new feature menu returns to this menu, and will + // then display the whole menu. + if(unlock_manager->getUnlockedFeatures().size()>0) { - widget_manager->addWgt( WTOK_SETUP_NEW_RACE, 60, 7); - widget_manager->setWgtText( WTOK_SETUP_NEW_RACE, _("Setup New Race")); - } + widget_manager->setWgtText( WTOK_CONTINUE, _("Continue")); + } else + { + if(world->m_race_setup.m_mode==RaceSetup::RM_GRAND_PRIX) + { + widget_manager->setWgtText( WTOK_CONTINUE, _("Continue Grand Prix")); + } + else + { + widget_manager->setWgtText( WTOK_CONTINUE, _("Back to the main menu")); + } + widget_manager->breakLine(); + widget_manager->addWgt( WTOK_RESTART_RACE, 60, 7); + widget_manager->setWgtText( WTOK_RESTART_RACE, _("Race in this track again")); + widget_manager->breakLine(); + + if(world->m_race_setup.m_mode==RaceSetup::RM_QUICK_RACE) + { + widget_manager->addWgt( WTOK_SETUP_NEW_RACE, 60, 7); + widget_manager->setWgtText( WTOK_SETUP_NEW_RACE, _("Setup New Race")); + } + } // if !unlock_manager has something unlocked widget_manager->layout(WGT_AREA_ALL); } // RaceResultsGUI @@ -183,6 +193,14 @@ RaceResultsGUI::~RaceResultsGUI() //----------------------------------------------------------------------------- void RaceResultsGUI::select() { + // Push the unlocked-feature menu in for now + if(unlock_manager->getUnlockedFeatures().size()>0) + { + // Push the new feature menu on the stack, from where + // control will be returned to this menu. + menu_manager->pushMenu(MENUID_UNLOCKED_FEATURE); + return; + } switch( widget_manager->getSelectedWgt() ) { case WTOK_CONTINUE: diff --git a/src/gui/track_sel.cpp b/src/gui/track_sel.cpp index 286dfa27b..2e5f366e5 100644 --- a/src/gui/track_sel.cpp +++ b/src/gui/track_sel.cpp @@ -26,6 +26,7 @@ #include "user_config.hpp" #include "material.hpp" #include "material_manager.hpp" +#include "unlock_manager.hpp" #include "translation.hpp" enum WidgetTokens @@ -62,8 +63,19 @@ TrackSel::TrackSel() for (unsigned int i = 0; i != track_manager->getTrackCount(); ++i) { + // snowtuxpeak must be unlocked + const Track *track = track_manager->getTrack(i); + bool isAvailable = !unlock_manager->isLocked(track->getIdent()); widget_manager->addWgt( WTOK_TRACK0 + i, 40, 6); - widget_manager->setWgtText( WTOK_TRACK0 + i, track_manager->getTrack(i)->getName()); + if(isAvailable) + { + widget_manager->setWgtText( WTOK_TRACK0 + i, track->getName()); + } + else + { + widget_manager->setWgtText( WTOK_TRACK0 + i, "???"); + widget_manager->deactivateWgt(WTOK_TRACK0 + i); + } if( i%2 != 0 ) widget_manager->breakLine(); else if (i + 1 == track_manager->getTrackCount() ) { diff --git a/src/ide/vc8/supertuxkart.vcproj b/src/ide/vc8/supertuxkart.vcproj index 6db01164f..4d69f0616 100644 --- a/src/ide/vc8/supertuxkart.vcproj +++ b/src/ide/vc8/supertuxkart.vcproj @@ -522,7 +522,7 @@ Optimization="0" WholeProgramOptimization="false" AdditionalIncludeDirectories="./../../../src;"$(PLIB_PATH)";"$(SDL_PATH)\include";"$(ALUT_PATH)\include";"$(OGG_PATH)\include";"$(VORBIS_PATH)\include";"$(OPENAL_PATH)\include";"$(OPENAL_PATH)\include\AL";../../../src/bullet/src;"$(GLUT_PATH)\include";"$(GETTEXT_PATH)/include"" - PreprocessorDefinitions="BT_NO_PROFILE;HAVE_OPENAL;HAVE_OGGVORBIS;_DEBUG;_CONSOLE;WIN32;NOMINMAX;VERSION=\"0.4alpha\";_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;DEBUG;PACKAGE=\"supertuxkart\"" + PreprocessorDefinitions="BT_NO_PROFILE;HAVE_OPENAL;HAVE_OGGVORBIS;_DEBUG;_CONSOLE;WIN32;NOMINMAX;VERSION=\"0.4alpha\";_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;DEBUG;PACKAGE=\"supertuxkart\";HAS_GETTEXT" GeneratePreprocessedFile="0" MinimalRebuild="true" BasicRuntimeChecks="3" @@ -550,6 +550,9 @@ IgnoreAllDefaultLibraries="false" IgnoreDefaultLibraryNames="libcmt.lib" GenerateDebugInformation="true" + GenerateMapFile="false" + MapFileName="" + MapExports="false" SubSystem="1" LinkTimeCodeGeneration="0" TargetMachine="1" @@ -902,6 +905,10 @@ RelativePath="..\..\triangle_mesh.cpp" > + + @@ -925,6 +932,10 @@ RelativePath="../../../src\gui\base_gui.cpp" > + + @@ -953,6 +964,10 @@ RelativePath="..\..\gui\display_res_confirm.cpp" > + + @@ -1050,6 +1065,26 @@ > + + + + + + + + + + + + @@ -1359,6 +1398,10 @@ RelativePath="../../../src\gui\base_gui.hpp" > + + @@ -1387,6 +1430,10 @@ RelativePath="..\..\gui\display_res_confirm.hpp" > + + @@ -1484,6 +1531,26 @@ > + + + + + + + + + + #include "user_config.hpp" +#include "unlock_manager.hpp" #include "track_manager.hpp" #include "track.hpp" #include "kart_properties_manager.hpp" @@ -370,9 +371,12 @@ int handleCmdLine(int argc, char **argv) //============================================================================= void InitTuxkart() { - file_manager = new FileManager(); - loader = new Loader(); + file_manager = new FileManager(); + translations = new Translations(); + loader = new Loader(); loader->setCreateStateCallback(getAppState); + // unlock manager is needed when reading the config file + unlock_manager = new UnlockManager(); user_config = new UserConfig(); sound_manager = new SoundManager(); @@ -405,7 +409,6 @@ void InitTuxkart() int main(int argc, char *argv[] ) { try { - initTranslations(); glutInit(&argc, argv); InitTuxkart(); diff --git a/src/race_manager.cpp b/src/race_manager.cpp index dad868812..a375e5fd4 100644 --- a/src/race_manager.cpp +++ b/src/race_manager.cpp @@ -24,6 +24,7 @@ #include "game_manager.hpp" #include "kart_properties_manager.hpp" #include "race_manager.hpp" +#include "unlock_manager.hpp" #include "gui/menu_manager.hpp" #include "world.hpp" #include "scene.hpp" @@ -155,7 +156,6 @@ GrandPrixMode::next() { scene->clear(); start_race(m_track); - } else { @@ -173,6 +173,7 @@ GrandPrixMode::exit_race() } else { + unlock_manager->grandPrixFinished(); menu_manager->switchToGrandPrixEnding(); } } diff --git a/src/translation.cpp b/src/translation.cpp index bef157ed9..689538b2b 100755 --- a/src/translation.cpp +++ b/src/translation.cpp @@ -1,15 +1,21 @@ #include "translation.hpp" +#include "file_manager.hpp" -initTranslations::initTranslations() { +Translations* translations=NULL; + +Translations::Translations() { #ifdef HAS_GETTEXT // LC_ALL does not work, sscanf will then not always be able // to scan for example: s=-1.1,-2.3,-3.3 correctly, which is // used in driveline files. - setlocale (LC_CTYPE, ""); -// setlocale (LC_MESSAGES, ""); - bindtextdomain (PACKAGE, "./data/po"); - //bindtextdomain (PACKAGE, LOCALEDIR); +#if defined(WIN32) && !defined(__CYGWIN__) + // Windows does not have LC_MESSAGES + setlocale(LC_CTYPE, ""); +#else + setlocale(LC_MESSAGES, ""); +#endif + bindtextdomain (PACKAGE, file_manager->getTranslationDir().c_str()); textdomain (PACKAGE); #endif -} +} // Translations diff --git a/src/translation.hpp b/src/translation.hpp index 2f93ffe01..81de91cf0 100644 --- a/src/translation.hpp +++ b/src/translation.hpp @@ -25,12 +25,14 @@ # define _(String) gettext(String) # define gettext_noop(String) String # define N_(String) gettext_noop (String) +// libintl defines its own fprintf, which doesn't work for me :( +# if defined(WIN32) && !defined(__CYGWIN__) +# undef fprintf +# endif #else # define _(String) (String) # define gettext_noop(String) String # define N_(String) String -# define textdomain(Domain) -# define bindtextdomain(Package, Directory) #endif // This length is used for all translated error messages. @@ -38,11 +40,12 @@ // This length is used for all normal messages #define MAX_MESSAGE_LENGTH 80 -class initTranslations +class Translations { public: - initTranslations(); + Translations(); }; +extern Translations* translations; #endif /* EOF */ diff --git a/src/unlock_manager.cpp b/src/unlock_manager.cpp new file mode 100755 index 000000000..beca35dd8 --- /dev/null +++ b/src/unlock_manager.cpp @@ -0,0 +1,180 @@ +// $Id: challenge_manager.cpp 1259 2007-09-24 12:28:19Z hiker $ +// +// SuperTuxKart - a fun racing game with go-kart +// Copyright (C) 2008 Joerg Henrichs +// +// 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 "unlock_manager.hpp" + +#include "challenges/all_tracks.hpp" +#include "challenges/energy_math_class.hpp" +#include "challenges/win_gotm_cup.hpp" + +UnlockManager* unlock_manager=0; +//----------------------------------------------------------------------------- + +UnlockManager::UnlockManager() +{ + // The global variable 'unlock_manager' is needed in the challenges, + // but it's not set yet - so we define it here (and it gets re-assign + // in main). + unlock_manager=this; + + // Add all challenges: + Challenge *c; + c=new AllTracks(); m_all_challenges[c->getId()]=c; + c=new EnergyMathClass(); m_all_challenges[c->getId()]=c; + c=new WinGOTMCup(); m_all_challenges[c->getId()]=c; + + computeActive(); +} // UnlockManager + +//----------------------------------------------------------------------------- +std::vector UnlockManager::getActiveChallenges() +{ + std::vector all_active; + for(AllChallengesType::iterator i =m_all_challenges.begin(); + i!=m_all_challenges.end(); i++) + { + if(i->second->isActive()) all_active.push_back(i->second); + } + return all_active; +} // getActiveChallenges + +//----------------------------------------------------------------------------- +Challenge* UnlockManager::getChallenge(const std::string& id) +{ + if(m_all_challenges.find(id)==m_all_challenges.end()) return NULL; + return m_all_challenges[id]; +} // getChallenge + +//----------------------------------------------------------------------------- +/** This is called from user_config when reading the config file +*/ +void UnlockManager::load(const lisp::Lisp* config) +{ + for(AllChallengesType::iterator i =m_all_challenges.begin(); + i!=m_all_challenges.end(); i++) + { + i->second->load(config); + } + computeActive(); +} // load + +//----------------------------------------------------------------------------- +void UnlockManager::save(lisp::Writer* writer) +{ + for(AllChallengesType::iterator i =m_all_challenges.begin(); + i!=m_all_challenges.end(); i++) + { + i->second->save(writer); + } // for i in m_all_challenges +} // save + +//----------------------------------------------------------------------------- +void UnlockManager::computeActive() +{ + for(AllChallengesType::iterator i =m_all_challenges.begin(); + i!=m_all_challenges.end(); i++) + { + // If a challenge is solved, nothing needs to be done + // -------------------------------------------------- + if((i->second)->isSolved()) continue; + + // Otherwise lock the feature, and check if the challenge is active + // ---------------------------------------------------------------- + lockFeature(i->second->getFeature()); + std::vector pre_req=(i->second)->getPrerequisites(); + bool allSolved=true; + for(std::vector::iterator pre =pre_req.begin(); + pre!=pre_req.end(); pre++) + { + const Challenge*p = getChallenge(*pre); + if(!p) + { + fprintf(stderr,"Challenge prerequisite '%s' of '%s' not found - ignored\n", + pre->c_str(), i->first.c_str()); + continue; + } + if(!p->isSolved()) + { + allSolved=false; + break; + } + } // for all pre in pre_req + if(allSolved) + { + i->second->setActive(); + } // if solved + } // for i +} // computeActive +//----------------------------------------------------------------------------- +/** This is called when a race is finished. Call all active challenges +*/ +void UnlockManager::raceFinished() +{ + for(AllChallengesType::iterator i =m_all_challenges.begin(); + i!=m_all_challenges.end(); i++) + { + if(i->second->isActive() && i->second->raceFinished()) + { + unlockFeature(i->second); + } // if isActive && challenge solved + } +} // raceFinished + +//----------------------------------------------------------------------------- +void UnlockManager::grandPrixFinished() +{ + for(AllChallengesType::iterator i =m_all_challenges.begin(); + i!=m_all_challenges.end(); i++) + { + if(i->second->isActive() &&i->second->grandPrixFinished()) + { + unlockFeature(i->second); + } + } +} // grandPrixFinished + +//----------------------------------------------------------------------------- +void UnlockManager::lockFeature(const std::string& feature) +{ + m_locked_features[feature]=true; +} // lockFeature + +//----------------------------------------------------------------------------- +void UnlockManager::unlockFeature(Challenge* c) +{ + const std::string& feature=c->getFeature(); + std::map::iterator p=m_locked_features.find(feature); + if(p==m_locked_features.end()) + { + fprintf(stderr,"Unlocking feature '%s' failed: feature is not locked.\n", + (feature).c_str()); + return; + } + m_locked_features.erase(p); + + // Add to list of recently unlocked features + m_unlocked_features.push_back(c); + c->setSolved(); // reset isActive flag +} // unlockFeature + +//----------------------------------------------------------------------------- +bool UnlockManager::isLocked(const std::string& feature) +{ + return m_locked_features.find(feature)!=m_locked_features.end(); +} // featureIsLocked diff --git a/src/unlock_manager.hpp b/src/unlock_manager.hpp new file mode 100755 index 000000000..4ee154b4d --- /dev/null +++ b/src/unlock_manager.hpp @@ -0,0 +1,57 @@ +// $Id: challenge_manager.hpp 1259 2007-09-24 12:28:19Z hiker $ +// +// SuperTuxKart - a fun racing game with go-kart +// Copyright (C) 2008 Joerg Henrichs +// +// 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_UNLOCK_MANAGER_H +#define HEADER_UNLOCK_MANAGER_H + +#include + +#include "challenges/challenge.hpp" +#include "lisp/lisp.hpp" +#include "lisp/parser.hpp" +#include "lisp/writer.hpp" + +class UnlockManager +{ +private: + typedef std::map AllChallengesType; + AllChallengesType m_all_challenges; + std::map m_locked_features; + std::vector m_unlocked_features; + Challenge *getChallenge (const std::string& id); + void computeActive (); +public: + UnlockManager (); + void load (const lisp::Lisp*); + void save (lisp::Writer* writer); + std::vector + getActiveChallenges(); + const std::vector + getUnlockedFeatures() {return m_unlocked_features;} + + void clearUnlocked () {m_unlocked_features.clear(); } + void raceFinished (); + void grandPrixFinished (); + void unlockFeature (Challenge* c); + void lockFeature (const std::string& feature); + bool isLocked (const std::string& feature); +}; // UnlockManager + +extern UnlockManager* unlock_manager; +#endif diff --git a/src/user_config.cpp b/src/user_config.cpp index 010d524b9..d1d668bb0 100644 --- a/src/user_config.cpp +++ b/src/user_config.cpp @@ -40,6 +40,7 @@ #include "lisp/parser.hpp" #include "lisp/writer.hpp" #include "translation.hpp" +#include "unlock_manager.hpp" #include "race_manager.hpp" #include "file_manager.hpp" #if defined(WIN32) && !defined(__CYGWIN__) @@ -430,6 +431,10 @@ void UserConfig::loadConfig(const std::string& filename) //get whether to log errors to file lisp->get("log-errors", m_log_errors); + // Unlock information: + const lisp::Lisp* unlock_info = lisp->getLisp("unlock-info"); + if(unlock_info) unlock_manager->load(unlock_info); + /*get player configurations*/ for(i=0; iwriteComment("error logging to log (true) or stderr (false)"); writer->write("log-errors\t", m_log_errors); + // Write unlock information back + writer->beginList("unlock-info"); + unlock_manager->save(writer); + writer->endList("unlock-info"); + /* write player configurations */ for(i=0; iraceFinished(); } // updateRaceStatus //-----------------------------------------------------------------------------