Began refactoring of story screens,

...which will also change their WML structures in the future.

For now there is only a minimal set of stubs in the new code, which is
also disabled for normal builds unless -DSHADOWM_STORYSCREEN is used.
If you find "bugs" in the new code in storyscreen.?pp, talk with me first,
I may be aware of them already...
This commit is contained in:
Ignacio R. Morelle 2009-03-30 23:06:12 +00:00
parent b1f1c34806
commit 7a501d60e7
7 changed files with 172 additions and 1 deletions

View file

@ -306,6 +306,7 @@ SET(wesnoth-main_SRC
settings.cpp
statistics.cpp
statistics_dialog.cpp
storyscreen.cpp
team.cpp
terrain_filter.cpp
time_of_day.cpp

View file

@ -143,6 +143,7 @@ wesnoth_source = \
settings.cpp \
statistics.cpp \
statistics_dialog.cpp \
storyscreen.cpp \
team.cpp \
terrain_filter.cpp \
text.cpp \

View file

@ -198,6 +198,7 @@ wesnoth_sources = Split("""
settings.cpp
statistics.cpp
statistics_dialog.cpp
storyscreen.cpp
team.cpp
terrain_filter.cpp
time_of_day.cpp

View file

@ -18,6 +18,9 @@
* campaign.
*/
// Do not remove the #ifndef below. See storyscreen.hpp.
#ifndef SHADOWM_STORYSCREEN
#include "global.hpp"
#include "foreach.hpp"
#include "gamestatus.hpp"
@ -507,3 +510,5 @@ void the_end(display &disp, std::string text, unsigned int duration)
--count;
}
}
#endif /* ! SHADOWM_STORYSCREEN */

View file

@ -52,4 +52,4 @@ void show_intro(display &disp, const vconfig& data, const config& level);
*/
void the_end(display &disp, std::string text, unsigned int duration);
#endif
#endif /* ! INTRO_HPP_INCLUDED */

96
src/storyscreen.cpp Normal file
View file

@ -0,0 +1,96 @@
/* $Id$ */
/*
Copyright (C) 2003 - 2009 by David White <dave@whitevine.net>
Copyright (C) 2009 by Ignacio R. Morelle <shadowm2006@gmail.com>
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2
or at your option any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY.
See the COPYING file for more details.
*/
// This code is work in progress, and shouldn't be enabled for production
// builds. It is supposed to completely replace the old story screens code
// at intro.cpp, introducing new WML conventions while at it.
//
// Do not remove the #ifdef below.
#ifdef SHADOWM_STORYSCREEN
#include "global.hpp"
#include "foreach.hpp"
#include "variable.hpp"
#include "display.hpp"
#include "game_events.hpp"
#include "gamestatus.hpp"
#include "gettext.hpp"
#include "intro.hpp"
#include "language.hpp"
#include "log.hpp"
#include "sound.hpp"
#include "text.hpp"
#define ERR_NG LOG_STREAM(err , engine)
#define LOG_NG LOG_STREAM(info, engine)
#define ERR_DI LOG_STREAM(err , display)
// TODO: remove when completed
#include "boost/current_function.hpp"
#define STUB() \
std::cerr << "OUCH: entered stub " << BOOST_CURRENT_FUNCTION << " [at " << __FILE__ << ":" << __LINE__ << "]\n"
class storyscreen
{
public:
storyscreen(display& disp, const vconfig& data, const config& scenario_cfg);
private:
display& disp_;
vconfig data_;
config scenario_;
};
namespace {
void write_generic_endscreen_config(config& append_to_cfg)
{
config& partcfg = append_to_cfg.add_child("story").add_child("page");
partcfg["text_align"] = "centered";
}
} // end anonymous namespace
void show_storyscreen(display& disp, const vconfig& data, const config& scenario_cfg)
{
STUB();
LOG_NG << "entering storyscreen procedure...\n";
// FIXME: stub!
LOG_NG << "leaving storyscreen procedure...\n";
}
void show_endscreen(display& disp, const t_string& text, unsigned int duration)
{
STUB();
LOG_NG << "show_endscreen() invoked...\n";
// FIXME: stub!
LOG_NG << "show_endscreen() completed...\n";
}
// Trivial drop-in compatibility with intro.cpp
void show_intro(display &disp, const vconfig& data, const config& level)
{
show_storyscreen(disp,data,level);
}
void the_end(display &disp, std::string text, unsigned int duration)
{
show_endscreen(disp, t_string(text) /* dumb! */, duration);
}
#endif /* SHADOWM_STORYSCREEN */

67
src/storyscreen.hpp Normal file
View file

@ -0,0 +1,67 @@
/* $Id$ */
/*
Copyright (C) 2003 - 2009 by David White <dave@whitevine.net>
Copyright (C) 2009 by Ignacio R. Morelle <shadowm2006@gmail.com>
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2
or at your option any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY.
See the COPYING file for more details.
*/
/** @file storyscreen.hpp */
// FIXME: textscreen.[ch]pp ??
// This code is work in progress, and shouldn't be enabled for production
// builds. It is supposed to completely replace the old story screens code
// at intro.cpp, introducing new WML conventions while at it.
//
// Do not remove the #ifdef below.
#ifdef SHADOWM_STORYSCREEN
#ifndef STORYSCREEN_HPP_INCLUDED
#define STORYSCREEN_HPP_INCLUDED
class config;
class vconfig;
class display;
class t_string;
#include "SDL.h"
#include <string>
/**
* Function to show an introduction sequence using story WML.
* The WML config data has a format similar to:
* @code
* [part]
* id='id'
* story='story'
* image='img'
* [/part]
* @endcode
* Where 'id' is a unique identifier, 'story' is text describing the
* storyline,and 'img' is a background image. Each part of the sequence will
* be displayed in turn, with the user able to go to the next part, or skip
* it entirely.
*/
void show_storyscreen(display& disp, const vconfig& data, const config& scenario_cfg);
/**
* Displays a simple fading screen with any user-provided text.
* Used after the end of single-player campaigns.
*
* @param text Text to display, centered on the screen.
*
* @param duration In milliseconds, for how much time the text will
* be displayed on screen.
*/
void show_endscreen(display& disp, const t_string& text, unsigned int duration);
#endif /* ! STORYSCREEN_HPP_INCLUDED */
#endif /* SHADOWM_STORYSCREEN */