storyscreen/interface.cpp

Go to the documentation of this file.
00001 /* $Id: interface.cpp 52533 2012-01-07 02:35:17Z shadowmaster $ */
00002 /*
00003    Copyright (C) 2009 - 2012 by Ignacio R. Morelle <shadowm2006@gmail.com>
00004    Part of the Battle for Wesnoth Project http://www.wesnoth.org/
00005 
00006    This program is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License as published by
00008    the Free Software Foundation; either version 2 of the License, or
00009    (at your option) any later version.
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY.
00012 
00013    See the COPYING file for more details.
00014 */
00015 
00016 /**
00017  * @file
00018  * Storyscreen controller (wrapper interface).
00019  */
00020 
00021 #include "global.hpp"
00022 #include "foreach.hpp"
00023 #include "variable.hpp"
00024 
00025 #include "storyscreen/interface.hpp"
00026 #include "storyscreen/controller.hpp"
00027 
00028 #include "display.hpp"
00029 #include "game_events.hpp"
00030 #include "gettext.hpp"
00031 #include "intro.hpp"
00032 #include "language.hpp"
00033 #include "log.hpp"
00034 #include "sound.hpp"
00035 #include "text.hpp"
00036 
00037 static lg::log_domain log_engine("engine");
00038 #define LOG_NG LOG_STREAM(info, log_engine)
00039 
00040 // TODO: remove when completed
00041 #include "stub.hpp"
00042 
00043 namespace {
00044 
00045     int count_segments(const config::const_child_itors &story)
00046     {
00047         config::const_child_iterator itor = story.first;
00048         int count = 0;
00049         while(itor != story.second) {
00050             ++itor;
00051             ++count;
00052         }
00053         return count;
00054     }
00055 } // end anonymous namespace
00056 
00057 void show_story(display &disp, const std::string &scenario_name,
00058     const config::const_child_itors &story)
00059 {
00060     const int total_segments = count_segments(story);
00061     int segment_count = 0;
00062     config::const_child_iterator itor = story.first;
00063     storyscreen::START_POSITION startpos = storyscreen::START_BEGINNING;
00064     while (itor != story.second)
00065     {
00066         storyscreen::controller ctl(disp, vconfig(*itor, true),
00067             scenario_name, segment_count, total_segments);
00068         storyscreen::STORY_RESULT result = ctl.show(startpos);
00069 
00070         switch(result) {
00071         case storyscreen::NEXT:
00072             if(itor != story.second) {
00073                 ++itor;
00074                 ++segment_count;
00075                 startpos = storyscreen::START_BEGINNING;
00076             }
00077             break;
00078         case storyscreen::BACK:
00079             if(itor != story.first) {
00080                 --itor;
00081                 --segment_count;
00082                 startpos = storyscreen::START_END;
00083             }
00084             break;
00085         case storyscreen::QUIT:
00086             return;
00087         }
00088     }
00089     return;
00090 }
00091 
00092 void show_endscreen(display& /*disp*/, const t_string& /*text*/, unsigned int /*duration*/)
00093 {
00094     STUB();
00095     LOG_NG << "show_endscreen() invoked...\n";
00096 
00097     config story_cfg;
00098 
00099     // FIXME: stub!
00100 
00101     LOG_NG << "show_endscreen() completed...\n";
00102 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Fri May 25 2012 01:02:44 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs