Story Viewer: delegate storyscreen controller creation to dialog
I left the controller passed in an argument for compatibility with the GUI1 dialog, but since that's removed it makes sense that the dialog handle the creation of the controller, especially since due to an oversight it made a copy instead of holding a reference. This also allows storyscreen/interface.*pp to be removed. The START_POSITION was part of the GUI1 implementation and isn't needed anymore.
This commit is contained in:
parent
7e84348ace
commit
47d77c79d4
7 changed files with 19 additions and 102 deletions
|
@ -1044,8 +1044,6 @@
|
|||
<Unit filename="../../src/statistics.hpp" />
|
||||
<Unit filename="../../src/storyscreen/controller.cpp" />
|
||||
<Unit filename="../../src/storyscreen/controller.hpp" />
|
||||
<Unit filename="../../src/storyscreen/interface.cpp" />
|
||||
<Unit filename="../../src/storyscreen/interface.hpp" />
|
||||
<Unit filename="../../src/storyscreen/part.cpp" />
|
||||
<Unit filename="../../src/storyscreen/part.hpp" />
|
||||
<Unit filename="../../src/synced_checkup.cpp" />
|
||||
|
|
|
@ -360,7 +360,6 @@ settings.cpp
|
|||
side_filter.cpp
|
||||
statistics.cpp
|
||||
storyscreen/controller.cpp
|
||||
storyscreen/interface.cpp
|
||||
storyscreen/part.cpp
|
||||
synced_checkup.cpp
|
||||
synced_commands.cpp
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "gui/widgets/stacked_widget.hpp"
|
||||
#include "gui/widgets/window.hpp"
|
||||
#include "sound.hpp"
|
||||
#include "variable.hpp"
|
||||
|
||||
namespace gui2
|
||||
{
|
||||
|
@ -74,8 +75,8 @@ static const unsigned int LAYER_TEXT = 2;
|
|||
|
||||
REGISTER_DIALOG(story_viewer)
|
||||
|
||||
story_viewer::story_viewer(storyscreen::controller& controller)
|
||||
: controller_(controller)
|
||||
story_viewer::story_viewer(const std::string& scenario_name, const config& cfg_parsed)
|
||||
: controller_(vconfig(cfg_parsed, true), scenario_name)
|
||||
, part_index_(0)
|
||||
, current_part_(nullptr)
|
||||
, timer_id_(0)
|
||||
|
|
|
@ -31,13 +31,24 @@ namespace dialogs
|
|||
class story_viewer : public modal_dialog
|
||||
{
|
||||
public:
|
||||
explicit story_viewer(storyscreen::controller& controller);
|
||||
story_viewer(const std::string& scenario_name, const config& cfg_parsed);
|
||||
|
||||
~story_viewer();
|
||||
|
||||
static void display(storyscreen::controller& controller, CVideo& video)
|
||||
static void display(const std::string& scenario_name, const config::const_child_itors& story, CVideo& video)
|
||||
{
|
||||
story_viewer(controller).show(video);
|
||||
// Combine all the [story] tags into a single config. Handle this here since
|
||||
// storyscreen::controller doesn't have a default constructor.
|
||||
config cfg;
|
||||
for(const auto& iter : story) {
|
||||
cfg.append_children(iter);
|
||||
}
|
||||
|
||||
if(cfg.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
story_viewer(scenario_name, cfg).show(video);
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "game_events/pump.hpp"
|
||||
#include "game_preferences.hpp"
|
||||
#include "gettext.hpp"
|
||||
#include "gui/dialogs/story_viewer.hpp"
|
||||
#include "gui/dialogs/transient_message.hpp"
|
||||
#include "hotkey/hotkey_handler_sp.hpp"
|
||||
#include "log.hpp"
|
||||
|
@ -49,7 +50,6 @@
|
|||
#include "scripting/plugins/context.hpp"
|
||||
#include "soundsource.hpp"
|
||||
#include "statistics.hpp"
|
||||
#include "storyscreen/interface.hpp"
|
||||
#include "units/unit.hpp"
|
||||
#include "wesnothd_connection_error.hpp"
|
||||
#include "whiteboard/manager.hpp"
|
||||
|
@ -235,7 +235,7 @@ LEVEL_RESULT playsingle_controller::play_scenario(const config& level)
|
|||
sound::commit_music_changes();
|
||||
|
||||
if(!this->is_skipping_replay()) {
|
||||
show_story(gui_->video(), get_scenario_name(), level.child_range("story"));
|
||||
gui2::dialogs::story_viewer::display(get_scenario_name(), level.child_range("story"), gui_->video());
|
||||
}
|
||||
gui_->labels().read(level);
|
||||
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2009 - 2017 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 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.
|
||||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Storyscreen controller (wrapper interface).
|
||||
*/
|
||||
|
||||
#include "variable.hpp"
|
||||
|
||||
#include "storyscreen/interface.hpp"
|
||||
#include "storyscreen/controller.hpp"
|
||||
|
||||
#include "gui/dialogs/story_viewer.hpp"
|
||||
|
||||
void show_story(CVideo& video, const std::string &scenario_name,
|
||||
const config::const_child_itors &story)
|
||||
{
|
||||
// Combine all the [story] tags into a single config
|
||||
config cfg;
|
||||
for(const auto& iter : story) {
|
||||
cfg.append_children(iter);
|
||||
}
|
||||
|
||||
if(cfg.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
storyscreen::controller controller(vconfig(cfg, true), scenario_name);
|
||||
|
||||
gui2::dialogs::story_viewer::display(controller, video);
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2009 - 2017 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 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.
|
||||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Storyscreen controller (wrapper interface).
|
||||
*/
|
||||
|
||||
#ifndef STORYSCREEN_HPP_INCLUDED
|
||||
#define STORYSCREEN_HPP_INCLUDED
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "config.hpp"
|
||||
|
||||
class vconfig;
|
||||
class CVideo;
|
||||
class t_string;
|
||||
|
||||
namespace storyscreen {
|
||||
|
||||
enum START_POSITION {
|
||||
START_BEGINNING,
|
||||
START_END
|
||||
};
|
||||
|
||||
} /* storyscreen namespace */
|
||||
|
||||
/**
|
||||
* Shows an introduction sequence using story WML.
|
||||
*
|
||||
* Each part of the sequence will be displayed in turn, with the user
|
||||
* able to go to the next part, previous part, or skip it entirely.
|
||||
*/
|
||||
void show_story(CVideo& video, const std::string &scenario_name,
|
||||
const config::const_child_itors &story);
|
||||
|
||||
#endif /* ! STORYSCREEN_HPP_INCLUDED */
|
Loading…
Add table
Reference in a new issue