Reformatted and cleaned up includes for the storyscreen internals
This commit is contained in:
parent
71740c8216
commit
3ff2816fee
4 changed files with 193 additions and 150 deletions
|
@ -21,23 +21,23 @@
|
|||
#include "storyscreen/controller.hpp"
|
||||
#include "storyscreen/part.hpp"
|
||||
|
||||
#include <cassert>
|
||||
#include "variable.hpp"
|
||||
|
||||
#include "game_data.hpp"
|
||||
#include "game_events/conditional_wml.hpp"
|
||||
#include "game_events/manager.hpp"
|
||||
#include "game_events/pump.hpp"
|
||||
#include "game_data.hpp"
|
||||
#include "gettext.hpp"
|
||||
#include "log.hpp"
|
||||
#include "resources.hpp"
|
||||
#include "variable.hpp"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
static lg::log_domain log_engine("engine");
|
||||
#define ERR_NG LOG_STREAM(err, log_engine)
|
||||
#define LOG_NG LOG_STREAM(info, log_engine)
|
||||
|
||||
namespace storyscreen {
|
||||
|
||||
namespace storyscreen
|
||||
{
|
||||
controller::controller(const vconfig& data, const std::string& scenario_name)
|
||||
: scenario_name_(scenario_name)
|
||||
, parts_()
|
||||
|
@ -48,8 +48,7 @@ controller::controller(const vconfig& data, const std::string& scenario_name)
|
|||
|
||||
void controller::resolve_wml(const vconfig& cfg)
|
||||
{
|
||||
for(vconfig::all_children_iterator i = cfg.ordered_begin(); i != cfg.ordered_end(); ++i)
|
||||
{
|
||||
for(vconfig::all_children_iterator i = cfg.ordered_begin(); i != cfg.ordered_end(); ++i) {
|
||||
// i->first and i->second are goddamn temporaries; do not make references
|
||||
const std::string key = i->first;
|
||||
const vconfig node = i->second;
|
||||
|
@ -58,16 +57,17 @@ void controller::resolve_wml(const vconfig& cfg)
|
|||
part_pointer_type const story_part(new part(node));
|
||||
// Use scenario name as part title if the WML doesn't supply a custom one.
|
||||
if((*story_part).show_title() && (*story_part).title().empty()) {
|
||||
(*story_part).set_title( scenario_name_ );
|
||||
(*story_part).set_title(scenario_name_);
|
||||
}
|
||||
|
||||
parts_.push_back(story_part);
|
||||
}
|
||||
// [if]
|
||||
else if(key == "if") {
|
||||
// check if the [if] tag has a [then] child;
|
||||
// if we try to execute a non-existing [then], we get a segfault
|
||||
if (game_events::conditional_passed(node)) {
|
||||
if (node.has_child("then")) {
|
||||
if(game_events::conditional_passed(node)) {
|
||||
if(node.has_child("then")) {
|
||||
resolve_wml(node.child("then"));
|
||||
}
|
||||
}
|
||||
|
@ -78,17 +78,20 @@ void controller::resolve_wml(const vconfig& cfg)
|
|||
bool elseif_flag = false;
|
||||
// for each [elseif]: test if it has a [then] child
|
||||
// if the condition matches, execute [then] and raise flag
|
||||
for (vconfig::child_list::const_iterator elseif = elseif_children.begin(); elseif != elseif_children.end(); ++elseif) {
|
||||
if (game_events::conditional_passed(*elseif)) {
|
||||
if (elseif->has_child("then")) {
|
||||
for(vconfig::child_list::const_iterator elseif = elseif_children.begin();
|
||||
elseif != elseif_children.end(); ++elseif) {
|
||||
if(game_events::conditional_passed(*elseif)) {
|
||||
if(elseif->has_child("then")) {
|
||||
resolve_wml(elseif->child("then"));
|
||||
}
|
||||
|
||||
elseif_flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// if we have an [else] tag and no [elseif] was successful (flag not raised), execute it
|
||||
if (node.has_child("else") && !elseif_flag) {
|
||||
if(node.has_child("else") && !elseif_flag) {
|
||||
resolve_wml(node.child("else"));
|
||||
}
|
||||
}
|
||||
|
@ -100,19 +103,23 @@ void controller::resolve_wml(const vconfig& cfg)
|
|||
bool case_not_found = true;
|
||||
|
||||
for(vconfig::all_children_iterator j = node.ordered_begin(); j != node.ordered_end(); ++j) {
|
||||
if(j->first != "case") continue;
|
||||
if(j->first != "case") {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Enter all matching cases.
|
||||
const std::string var_expected_value = (j->second)["value"];
|
||||
if(var_actual_value == var_expected_value) {
|
||||
if(var_actual_value == var_expected_value) {
|
||||
case_not_found = false;
|
||||
resolve_wml(j->second);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(case_not_found) {
|
||||
for(vconfig::all_children_iterator j = node.ordered_begin(); j != node.ordered_end(); ++j) {
|
||||
if(j->first != "else") continue;
|
||||
if(j->first != "else") {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Enter all elses.
|
||||
resolve_wml(j->second);
|
||||
|
@ -128,7 +135,8 @@ void controller::resolve_wml(const vconfig& cfg)
|
|||
else if(key == "wml_message") {
|
||||
// As with [deprecated_message],
|
||||
// it won't appear until the scenario start event is complete.
|
||||
resources::game_events->pump().put_wml_message(node["logger"], node["message"], node["in_chat"].to_bool(false));
|
||||
resources::game_events->pump().put_wml_message(
|
||||
node["logger"], node["message"], node["in_chat"].to_bool(false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,18 +25,17 @@
|
|||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
class CVideo;
|
||||
class vconfig;
|
||||
|
||||
namespace storyscreen {
|
||||
|
||||
namespace storyscreen
|
||||
{
|
||||
class part;
|
||||
class floating_image;
|
||||
|
||||
class controller
|
||||
{
|
||||
public:
|
||||
typedef std::shared_ptr< part > part_pointer_type;
|
||||
typedef std::shared_ptr<part> part_pointer_type;
|
||||
|
||||
controller(const vconfig& data, const std::string& scenario_name);
|
||||
|
||||
|
@ -57,7 +56,7 @@ private:
|
|||
std::string scenario_name_;
|
||||
|
||||
// The part cache.
|
||||
std::vector< part_pointer_type > parts_;
|
||||
std::vector<part_pointer_type> parts_;
|
||||
};
|
||||
|
||||
} // end namespace storyscreen
|
||||
|
|
|
@ -17,8 +17,6 @@
|
|||
* Storyscreen parts and floating images representation.
|
||||
*/
|
||||
|
||||
#include "log.hpp"
|
||||
#include "resources.hpp"
|
||||
#include "storyscreen/part.hpp"
|
||||
|
||||
#include "config.hpp"
|
||||
|
@ -26,12 +24,13 @@
|
|||
#include "game_events/conditional_wml.hpp"
|
||||
#include "game_events/manager.hpp"
|
||||
#include "game_events/pump.hpp"
|
||||
#include "image.hpp"
|
||||
#include "log.hpp"
|
||||
#include "resources.hpp"
|
||||
#include "serialization/string_utils.hpp"
|
||||
#include "variable.hpp"
|
||||
|
||||
namespace storyscreen {
|
||||
|
||||
namespace storyscreen
|
||||
{
|
||||
floating_image::floating_image(const floating_image& fi)
|
||||
: file_()
|
||||
, x_(0)
|
||||
|
@ -55,11 +54,16 @@ floating_image::floating_image(const config& cfg)
|
|||
|
||||
void floating_image::assign(const floating_image& fi)
|
||||
{
|
||||
if(&fi == this)
|
||||
if(&fi == this) {
|
||||
return;
|
||||
}
|
||||
|
||||
file_ = fi.file_; x_ = fi.x_; y_ = fi.y_; delay_ = fi.delay_;
|
||||
autoscaled_ = fi.autoscaled_; centered_ = fi.centered_;
|
||||
file_ = fi.file_;
|
||||
x_ = fi.x_;
|
||||
y_ = fi.y_;
|
||||
delay_ = fi.delay_;
|
||||
autoscaled_ = fi.autoscaled_;
|
||||
centered_ = fi.centered_;
|
||||
}
|
||||
|
||||
background_layer::background_layer()
|
||||
|
@ -70,7 +74,8 @@ background_layer::background_layer()
|
|||
, keep_aspect_ratio_(true)
|
||||
, is_base_layer_(false)
|
||||
, image_file_()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
background_layer::background_layer(const config& cfg)
|
||||
: scale_horizontally_(true)
|
||||
|
@ -84,6 +89,7 @@ background_layer::background_layer(const config& cfg)
|
|||
if(cfg.has_attribute("image")) {
|
||||
image_file_ = cfg["image"].str();
|
||||
}
|
||||
|
||||
if(cfg.has_attribute("scale")) {
|
||||
scale_vertically_ = cfg["scale"].to_bool(true);
|
||||
scale_horizontally_ = cfg["scale"].to_bool(true);
|
||||
|
@ -91,10 +97,12 @@ background_layer::background_layer(const config& cfg)
|
|||
if(cfg.has_attribute("scale_vertically")) {
|
||||
scale_vertically_ = cfg["scale_vertically"].to_bool(true);
|
||||
}
|
||||
|
||||
if(cfg.has_attribute("scale_horizontally")) {
|
||||
scale_horizontally_ = cfg["scale_horizontally"].to_bool(true);
|
||||
}
|
||||
}
|
||||
|
||||
if(cfg.has_attribute("tile")) {
|
||||
tile_vertically_ = cfg["tile"].to_bool(false);
|
||||
tile_horizontally_ = cfg["tile"].to_bool(false);
|
||||
|
@ -102,19 +110,22 @@ background_layer::background_layer(const config& cfg)
|
|||
if(cfg.has_attribute("tile_vertically")) {
|
||||
tile_vertically_ = cfg["tile_vertically"].to_bool(false);
|
||||
}
|
||||
|
||||
if(cfg.has_attribute("tile_horizontally")) {
|
||||
tile_horizontally_ = cfg["tile_horizontally"].to_bool(false);
|
||||
}
|
||||
}
|
||||
|
||||
if(cfg.has_attribute("keep_aspect_ratio")) {
|
||||
keep_aspect_ratio_ = cfg["keep_aspect_ratio"].to_bool(true);
|
||||
}
|
||||
|
||||
if(cfg.has_attribute("base_layer")) {
|
||||
is_base_layer_ = cfg["base_layer"].to_bool(false);
|
||||
}
|
||||
}
|
||||
|
||||
part::part(const vconfig &part_cfg)
|
||||
part::part(const vconfig& part_cfg)
|
||||
: show_title_()
|
||||
, text_()
|
||||
, text_title_()
|
||||
|
@ -134,11 +145,11 @@ part::BLOCK_LOCATION part::string_tblock_loc(const std::string& s)
|
|||
if(s.empty() != true) {
|
||||
if(s == "top") {
|
||||
return part::BLOCK_TOP;
|
||||
}
|
||||
else if (s == "middle") {
|
||||
} else if(s == "middle") {
|
||||
return part::BLOCK_MIDDLE;
|
||||
}
|
||||
}
|
||||
|
||||
return part::BLOCK_BOTTOM;
|
||||
}
|
||||
|
||||
|
@ -147,15 +158,15 @@ part::TEXT_ALIGNMENT part::string_title_align(const std::string& s)
|
|||
if(s.empty() != true) {
|
||||
if(s == "right") {
|
||||
return part::TEXT_RIGHT;
|
||||
}
|
||||
else if(s == "center") {
|
||||
} else if(s == "center") {
|
||||
return part::TEXT_CENTERED;
|
||||
}
|
||||
}
|
||||
|
||||
return part::TEXT_LEFT;
|
||||
}
|
||||
|
||||
void part::resolve_wml(const vconfig &cfg)
|
||||
void part::resolve_wml(const vconfig& cfg)
|
||||
{
|
||||
if(cfg.null()) {
|
||||
return;
|
||||
|
@ -167,6 +178,7 @@ void part::resolve_wml(const vconfig &cfg)
|
|||
if(cfg.has_attribute("background")) {
|
||||
bl.set_file(cfg["background"].str());
|
||||
}
|
||||
|
||||
if(cfg.has_attribute("scale_background")) {
|
||||
bl.set_scale_horizontally(cfg["scale_background"].to_bool(true));
|
||||
bl.set_scale_vertically(cfg["scale_background"].to_bool(true));
|
||||
|
@ -174,10 +186,12 @@ void part::resolve_wml(const vconfig &cfg)
|
|||
if(cfg.has_attribute("scale_background_vertically")) {
|
||||
bl.set_scale_vertically(cfg["scale_background_vertically"].to_bool(true));
|
||||
}
|
||||
|
||||
if(cfg.has_attribute("scale_background_horizontally")) {
|
||||
bl.set_scale_horizontally(cfg["scale_background_horizontally"].to_bool(true));
|
||||
}
|
||||
}
|
||||
|
||||
if(cfg.has_attribute("tile_background")) {
|
||||
bl.set_tile_horizontally(cfg["tile_background"].to_bool(false));
|
||||
bl.set_tile_vertically(cfg["tile_background"].to_bool(false));
|
||||
|
@ -185,52 +199,61 @@ void part::resolve_wml(const vconfig &cfg)
|
|||
if(cfg.has_attribute("tile_background_vertically")) {
|
||||
bl.set_tile_vertically(cfg["tile_background_vertically"].to_bool(false));
|
||||
}
|
||||
|
||||
if(cfg.has_attribute("tile_background_horizontally")) {
|
||||
bl.set_tile_vertically(cfg["tile_background_horizontally"].to_bool(false));
|
||||
}
|
||||
}
|
||||
|
||||
if(cfg.has_attribute("keep_aspect_ratio")) {
|
||||
bl.set_keep_aspect_ratio(cfg["keep_aspect_ratio"].to_bool(true));
|
||||
}
|
||||
background_layers_.push_back(bl);
|
||||
|
||||
background_layers_.push_back(bl);
|
||||
|
||||
if(cfg.has_attribute("show_title")) {
|
||||
show_title_ = cfg["show_title"].to_bool();
|
||||
}
|
||||
|
||||
if(cfg.has_attribute("story")) {
|
||||
text_ = cfg["story"].str();
|
||||
}
|
||||
|
||||
if(cfg.has_attribute("title")) {
|
||||
text_title_ = cfg["title"].str();
|
||||
if(!cfg.has_attribute("show_title")) {
|
||||
show_title_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(cfg.has_attribute("text_layout")) {
|
||||
text_block_loc_ = string_tblock_loc(cfg["text_layout"]);
|
||||
}
|
||||
|
||||
if(cfg.has_attribute("text_alignment")) {
|
||||
text_alignment_ = string_title_align(cfg["text_alignment"]);
|
||||
}
|
||||
|
||||
if(cfg.has_attribute("title_alignment")) {
|
||||
title_alignment_ = string_title_align(cfg["title_alignment"]);
|
||||
}
|
||||
|
||||
if(cfg.has_attribute("music")) {
|
||||
music_ = cfg["music"].str();
|
||||
}
|
||||
|
||||
if(cfg.has_attribute("sound")) {
|
||||
sound_ = cfg["sound"].str();
|
||||
}
|
||||
|
||||
// Execution flow/branching/[image]
|
||||
for(vconfig::all_children_iterator i = cfg.ordered_begin(); i != cfg.ordered_end(); ++ i) {
|
||||
for(vconfig::all_children_iterator i = cfg.ordered_begin(); i != cfg.ordered_end(); ++i) {
|
||||
// i->first and i->second are goddamn temporaries; do not make references
|
||||
const std::string key = i->first;
|
||||
const vconfig node = i->second;
|
||||
|
||||
// [background_layer]
|
||||
if (key == "background_layer") {
|
||||
if(key == "background_layer") {
|
||||
background_layers_.push_back(node.get_parsed_config());
|
||||
}
|
||||
// [image]
|
||||
|
@ -241,8 +264,8 @@ void part::resolve_wml(const vconfig &cfg)
|
|||
else if(key == "if") {
|
||||
// check if the [if] tag has a [then] child;
|
||||
// if we try to execute a non-existing [then], we get a segfault
|
||||
if (game_events::conditional_passed(node)) {
|
||||
if (node.has_child("then")) {
|
||||
if(game_events::conditional_passed(node)) {
|
||||
if(node.has_child("then")) {
|
||||
resolve_wml(node.child("then"));
|
||||
}
|
||||
}
|
||||
|
@ -253,17 +276,20 @@ void part::resolve_wml(const vconfig &cfg)
|
|||
bool elseif_flag = false;
|
||||
// for each [elseif]: test if it has a [then] child
|
||||
// if the condition matches, execute [then] and raise flag
|
||||
for (vconfig::child_list::const_iterator elseif = elseif_children.begin(); elseif != elseif_children.end(); ++elseif) {
|
||||
if (game_events::conditional_passed(*elseif)) {
|
||||
if (elseif->has_child("then")) {
|
||||
for(vconfig::child_list::const_iterator elseif = elseif_children.begin();
|
||||
elseif != elseif_children.end(); ++elseif) {
|
||||
if(game_events::conditional_passed(*elseif)) {
|
||||
if(elseif->has_child("then")) {
|
||||
resolve_wml(elseif->child("then"));
|
||||
}
|
||||
|
||||
elseif_flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// if we have an [else] tag and no [elseif] was successful (flag not raised), execute it
|
||||
if (node.has_child("else") && !elseif_flag) {
|
||||
if(node.has_child("else") && !elseif_flag) {
|
||||
resolve_wml(node.child("else"));
|
||||
}
|
||||
}
|
||||
|
@ -275,19 +301,23 @@ void part::resolve_wml(const vconfig &cfg)
|
|||
bool case_not_found = true;
|
||||
|
||||
for(vconfig::all_children_iterator j = node.ordered_begin(); j != node.ordered_end(); ++j) {
|
||||
if(j->first != "case") continue;
|
||||
if(j->first != "case") {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Enter all matching cases.
|
||||
const std::string var_expected_value = (j->second)["value"];
|
||||
if(var_actual_value == var_expected_value) {
|
||||
if(var_actual_value == var_expected_value) {
|
||||
case_not_found = false;
|
||||
resolve_wml(j->second);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(case_not_found) {
|
||||
for(vconfig::all_children_iterator j = node.ordered_begin(); j != node.ordered_end(); ++j) {
|
||||
if(j->first != "else") continue;
|
||||
if(j->first != "else") {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Enter all elses.
|
||||
resolve_wml(j->second);
|
||||
|
@ -303,10 +333,10 @@ void part::resolve_wml(const vconfig &cfg)
|
|||
else if(key == "wml_message") {
|
||||
// As with [deprecated_message],
|
||||
// it won't appear until the scenario start event is complete.
|
||||
resources::game_events->pump().put_wml_message(node["logger"], node["message"], node["in_chat"].to_bool(false));
|
||||
resources::game_events->pump().put_wml_message(
|
||||
node["logger"], node["message"], node["in_chat"].to_bool(false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // end namespace storyscreen
|
||||
|
||||
|
|
|
@ -26,10 +26,9 @@
|
|||
|
||||
class config;
|
||||
class vconfig;
|
||||
class display;
|
||||
|
||||
namespace storyscreen {
|
||||
|
||||
namespace storyscreen
|
||||
{
|
||||
/**
|
||||
* Represents and contains information about image labels used
|
||||
* in story screen parts.
|
||||
|
@ -49,7 +48,8 @@ public:
|
|||
*/
|
||||
floating_image(const floating_image& fi);
|
||||
|
||||
floating_image& operator=(const floating_image& fi) {
|
||||
floating_image& operator=(const floating_image& fi)
|
||||
{
|
||||
assign(fi);
|
||||
return *this;
|
||||
}
|
||||
|
@ -63,7 +63,8 @@ public:
|
|||
* Returns the referential X coordinate of the image.
|
||||
* The actual (corrected) value is determined at render time.
|
||||
*/
|
||||
int ref_x() const {
|
||||
int ref_x() const
|
||||
{
|
||||
return x_;
|
||||
}
|
||||
|
||||
|
@ -71,7 +72,8 @@ public:
|
|||
* Returns the referential Y coordinate of the image.
|
||||
* The actual (corrected) value is determined at render time.
|
||||
*/
|
||||
int ref_y() const {
|
||||
int ref_y() const
|
||||
{
|
||||
return y_;
|
||||
}
|
||||
|
||||
|
@ -79,18 +81,25 @@ public:
|
|||
* Whether the image should be automatically scaled as much as
|
||||
* the storyscreen background is.
|
||||
*/
|
||||
bool autoscale() const { return autoscaled_; }
|
||||
bool autoscale() const
|
||||
{
|
||||
return autoscaled_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the image coordinates specify the location of its
|
||||
* center (true) or top-left corner (false).
|
||||
*/
|
||||
bool centered() const { return centered_; }
|
||||
bool centered() const
|
||||
{
|
||||
return centered_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delay before displaying, in milliseconds.
|
||||
*/
|
||||
int display_delay() const { return delay_; }
|
||||
/** Delay before displaying, in milliseconds. */
|
||||
int display_delay() const
|
||||
{
|
||||
return delay_;
|
||||
}
|
||||
|
||||
private:
|
||||
std::string file_;
|
||||
|
@ -106,9 +115,6 @@ private:
|
|||
class background_layer
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
background_layer();
|
||||
|
||||
/**
|
||||
|
@ -117,103 +123,90 @@ public:
|
|||
*/
|
||||
background_layer(const config& cfg);
|
||||
|
||||
/**
|
||||
* Whether the layer should be scaled horizontally.
|
||||
*/
|
||||
bool scale_horizontally() const {
|
||||
/** Whether the layer should be scaled horizontally. */
|
||||
bool scale_horizontally() const
|
||||
{
|
||||
return scale_horizontally_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether the layer should be scaled horizontally.
|
||||
*/
|
||||
void set_scale_horizontally(bool b) {
|
||||
/** Sets whether the layer should be scaled horizontally. */
|
||||
void set_scale_horizontally(bool b)
|
||||
{
|
||||
scale_horizontally_ = b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the layer should be scaled vertically.
|
||||
*/
|
||||
bool scale_vertically() const {
|
||||
/** Whether the layer should be scaled vertically. */
|
||||
bool scale_vertically() const
|
||||
{
|
||||
return scale_vertically_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether the layer should be scaled vertically.
|
||||
*/
|
||||
void set_scale_vertically(bool b) {
|
||||
/** Sets whether the layer should be scaled vertically. */
|
||||
void set_scale_vertically(bool b)
|
||||
{
|
||||
scale_vertically_ = b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the layer should be tiled horizontally.
|
||||
*/
|
||||
bool tile_horizontally() const {
|
||||
/** Whether the layer should be tiled horizontally. */
|
||||
bool tile_horizontally() const
|
||||
{
|
||||
return tile_horizontally_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether the layer should be tiled horizontally.
|
||||
*/
|
||||
void set_tile_horizontally(bool b) {
|
||||
/** Sets whether the layer should be tiled horizontally. */
|
||||
void set_tile_horizontally(bool b)
|
||||
{
|
||||
tile_horizontally_ = b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the layer should be tiled vertically.
|
||||
*/
|
||||
bool tile_vertically() const {
|
||||
/** Whether the layer should be tiled vertically. */
|
||||
bool tile_vertically() const
|
||||
{
|
||||
return tile_vertically_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether the layer should be tiled vertically.
|
||||
*/
|
||||
void set_tile_vertically(bool b) {
|
||||
/** Sets whether the layer should be tiled vertically. */
|
||||
void set_tile_vertically(bool b)
|
||||
{
|
||||
tile_vertically_ = b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the aspect ratio should be preserved while scaling.
|
||||
*/
|
||||
bool keep_aspect_ratio() const {
|
||||
/** Whether the aspect ratio should be preserved while scaling. */
|
||||
bool keep_aspect_ratio() const
|
||||
{
|
||||
return keep_aspect_ratio_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether the aspect ratio should be preserved.
|
||||
*/
|
||||
void set_keep_aspect_ratio(bool b) {
|
||||
/** Sets whether the aspect ratio should be preserved. */
|
||||
void set_keep_aspect_ratio(bool b)
|
||||
{
|
||||
keep_aspect_ratio_ = b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether is this layer the base layer.
|
||||
*/
|
||||
bool is_base_layer() const {
|
||||
/** Whether is this layer the base layer. */
|
||||
bool is_base_layer() const
|
||||
{
|
||||
return is_base_layer_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether is this layer a base layer.
|
||||
*/
|
||||
void set_base_layer(bool b) {
|
||||
/** Sets whether is this layer a base layer. */
|
||||
void set_base_layer(bool b)
|
||||
{
|
||||
is_base_layer_ = b;
|
||||
}
|
||||
|
||||
/**
|
||||
* The path to the file to load the image from.
|
||||
*/
|
||||
const std::string& file() const {
|
||||
/** The path to the file to load the image from. */
|
||||
const std::string& file() const
|
||||
{
|
||||
return image_file_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the path to the image file.
|
||||
*/
|
||||
void set_file(const std::string& str) {
|
||||
/** Sets the path to the image file. */
|
||||
void set_file(const std::string& str)
|
||||
{
|
||||
image_file_ = str;
|
||||
}
|
||||
|
||||
private:
|
||||
bool scale_horizontally_;
|
||||
bool scale_vertically_;
|
||||
|
@ -236,98 +229,112 @@ public:
|
|||
* possible horizontally.
|
||||
*/
|
||||
enum BLOCK_LOCATION {
|
||||
BLOCK_TOP, /**< Top of the screen. */
|
||||
BLOCK_MIDDLE, /**< Center of the screen. */
|
||||
BLOCK_BOTTOM /**< Bottom of the screen. This is the default. */
|
||||
BLOCK_TOP, /**< Top of the screen. */
|
||||
BLOCK_MIDDLE, /**< Center of the screen. */
|
||||
BLOCK_BOTTOM /**< Bottom of the screen. This is the default. */
|
||||
};
|
||||
|
||||
/**
|
||||
* Currently used to indicate where the page title should be placed.
|
||||
* It always takes as little space (horizontally) as possible,
|
||||
* and it is always placed at the top of the screen.
|
||||
*/
|
||||
enum TEXT_ALIGNMENT {
|
||||
TEXT_LEFT, /**< Top-left corner. */
|
||||
TEXT_CENTERED, /**< Center on the topmost edge of the screen. */
|
||||
TEXT_RIGHT /**< Top-right corner. */
|
||||
TEXT_LEFT, /**< Top-left corner. */
|
||||
TEXT_CENTERED, /**< Center on the topmost edge of the screen. */
|
||||
TEXT_RIGHT /**< Top-right corner. */
|
||||
};
|
||||
|
||||
/**
|
||||
* Used to signal user actions.
|
||||
*/
|
||||
enum RESULT {
|
||||
NEXT, /**< Jump to next story part. */
|
||||
SKIP, /**< Skip all story parts for this set. */
|
||||
QUIT /**< Quit game and go back to main menu. */
|
||||
NEXT, /**< Jump to next story part. */
|
||||
SKIP, /**< Skip all story parts for this set. */
|
||||
QUIT /**< Quit game and go back to main menu. */
|
||||
};
|
||||
|
||||
/**
|
||||
* Constructs a storyscreen part from a managed WML node.
|
||||
* @param part_cfg Node object which should correspond to a [part] block's contents.
|
||||
*/
|
||||
part(const vconfig &part_cfg);
|
||||
part(const vconfig& part_cfg);
|
||||
|
||||
/** Whether the story screen title should be displayed or not. */
|
||||
bool show_title() const {
|
||||
bool show_title() const
|
||||
{
|
||||
return show_title_;
|
||||
}
|
||||
|
||||
/** Retrieves the story text itself. */
|
||||
const std::string& text() const {
|
||||
const std::string& text() const
|
||||
{
|
||||
return text_;
|
||||
}
|
||||
|
||||
/** Changes the story text. */
|
||||
void set_text(const std::string& text) {
|
||||
void set_text(const std::string& text)
|
||||
{
|
||||
text_ = text;
|
||||
}
|
||||
|
||||
/** Retrieves the story screen title. */
|
||||
const std::string& title() const {
|
||||
const std::string& title() const
|
||||
{
|
||||
return text_title_;
|
||||
}
|
||||
|
||||
/** Changes the story screen title. */
|
||||
void set_title(const std::string& title) {
|
||||
void set_title(const std::string& title)
|
||||
{
|
||||
text_title_ = title;
|
||||
}
|
||||
|
||||
/** Retrieves the background music. */
|
||||
const std::string& music() const {
|
||||
const std::string& music() const
|
||||
{
|
||||
return music_;
|
||||
}
|
||||
|
||||
/** Retrieves a one-time-only sound effect. */
|
||||
const std::string& sound() const {
|
||||
const std::string& sound() const
|
||||
{
|
||||
return sound_;
|
||||
}
|
||||
|
||||
/** Retrieves the area of the screen on which the story text is displayed. */
|
||||
BLOCK_LOCATION story_text_location() const {
|
||||
BLOCK_LOCATION story_text_location() const
|
||||
{
|
||||
return text_block_loc_;
|
||||
}
|
||||
|
||||
/** Retrieves the alignment of the story text within the text area. */
|
||||
TEXT_ALIGNMENT story_text_alignment() const {
|
||||
TEXT_ALIGNMENT story_text_alignment() const
|
||||
{
|
||||
return text_alignment_;
|
||||
}
|
||||
|
||||
/** Retrieves the alignment of the title text against the screen. */
|
||||
TEXT_ALIGNMENT title_text_alignment() const {
|
||||
TEXT_ALIGNMENT title_text_alignment() const
|
||||
{
|
||||
return title_alignment_;
|
||||
}
|
||||
|
||||
/** Retrieve any associated floating images for this story screen. */
|
||||
const std::vector<floating_image>& get_floating_images() const {
|
||||
const std::vector<floating_image>& get_floating_images() const
|
||||
{
|
||||
return floating_images_;
|
||||
}
|
||||
|
||||
/** Retrieve background layers for this story screen. */
|
||||
const std::vector<background_layer>& get_background_layers() const {
|
||||
const std::vector<background_layer>& get_background_layers() const
|
||||
{
|
||||
return background_layers_;
|
||||
}
|
||||
|
||||
private:
|
||||
/** Takes care of initializing and branching properties. */
|
||||
void resolve_wml(const vconfig &cfg);
|
||||
void resolve_wml(const vconfig& cfg);
|
||||
|
||||
static BLOCK_LOCATION string_tblock_loc(const std::string& s);
|
||||
static TEXT_ALIGNMENT string_title_align(const std::string& s);
|
||||
|
@ -348,5 +355,4 @@ private:
|
|||
|
||||
} // end namespace storyscreen
|
||||
|
||||
|
||||
#endif /* ! STORYSCREEN_PART_HPP_INCLUDED */
|
||||
|
|
Loading…
Add table
Reference in a new issue