Refactor out display class from storyscreen functions
This commit is contained in:
parent
c486e4b040
commit
e656751938
7 changed files with 19 additions and 27 deletions
|
@ -222,7 +222,7 @@ LEVEL_RESULT playsingle_controller::play_scenario(const config& level)
|
|||
sound::commit_music_changes();
|
||||
|
||||
if(!this->is_skipping_replay()) {
|
||||
show_story(*gui_, get_scenario_name(), level.child_range("story"));
|
||||
show_story(gui_->video(), get_scenario_name(), level.child_range("story"));
|
||||
}
|
||||
gui_->labels().read(level);
|
||||
|
||||
|
|
|
@ -44,9 +44,9 @@ static lg::log_domain log_engine("engine");
|
|||
|
||||
namespace storyscreen {
|
||||
|
||||
controller::controller(display& disp, const vconfig& data, const std::string& scenario_name,
|
||||
controller::controller(CVideo& video, const vconfig& data, const std::string& scenario_name,
|
||||
int segment_index)
|
||||
: disp_(disp)
|
||||
: video_(video)
|
||||
, disp_resize_lock_()
|
||||
, evt_context_()
|
||||
, scenario_name_(scenario_name)
|
||||
|
@ -152,11 +152,11 @@ STORY_RESULT controller::show(START_POSITION startpos)
|
|||
return NEXT;
|
||||
}
|
||||
|
||||
gui::button back_button (disp_.video(), "", gui::button::TYPE_PRESS, "button_normal/button_small_H22"
|
||||
gui::button back_button (video_, "", gui::button::TYPE_PRESS, "button_normal/button_small_H22"
|
||||
, gui::button::DEFAULT_SPACE, true, "icons/arrows/long_arrow_ornate_left");
|
||||
gui::button next_button (disp_.video(), "", gui::button::TYPE_PRESS, "button_normal/button_small_H22"
|
||||
gui::button next_button (video_, "", gui::button::TYPE_PRESS, "button_normal/button_small_H22"
|
||||
, gui::button::DEFAULT_SPACE, true, "icons/arrows/long_arrow_ornate_right");
|
||||
gui::button play_button (disp_.video(), _("Skip"));
|
||||
gui::button play_button (video_, _("Skip"));
|
||||
|
||||
// Build renderer cache unless built for a low-memory environment;
|
||||
// caching the scaled backgrounds can take over a decent amount of memory.
|
||||
|
@ -164,7 +164,7 @@ STORY_RESULT controller::show(START_POSITION startpos)
|
|||
std::vector< render_pointer_type > uis_;
|
||||
BOOST_FOREACH(part_pointer_type p, parts_) {
|
||||
ASSERT_LOG( p != NULL, "Ouch: hit NULL storyscreen part in collection" );
|
||||
render_pointer_type const rpt(new part_ui(*p, disp_, next_button, back_button, play_button));
|
||||
render_pointer_type const rpt(new part_ui(*p, video_, next_button, back_button, play_button));
|
||||
uis_.push_back(rpt);
|
||||
}
|
||||
#endif
|
||||
|
@ -185,7 +185,7 @@ STORY_RESULT controller::show(START_POSITION startpos)
|
|||
#ifndef LOW_MEM
|
||||
part_ui &render_interface = *uis_[k];
|
||||
#else
|
||||
part_ui render_interface(*parts_[k], disp_, next_button, back_button, play_button);
|
||||
part_ui render_interface(*parts_[k], video_, next_button, back_button, play_button);
|
||||
#endif
|
||||
|
||||
LOG_NG << "displaying storyscreen part " << k+1 << " of " << parts_.size() << '\n';
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
class display;
|
||||
class vconfig;
|
||||
|
||||
namespace storyscreen {
|
||||
|
@ -44,7 +43,7 @@ class floating_image;
|
|||
class controller
|
||||
{
|
||||
public:
|
||||
controller(display& disp, const vconfig& data, const std::string& scenario_name,
|
||||
controller(CVideo& video, const vconfig& data, const std::string& scenario_name,
|
||||
int segment_index);
|
||||
|
||||
/**
|
||||
|
@ -59,7 +58,7 @@ private:
|
|||
// Executes WML flow instructions and inserts parts.
|
||||
void resolve_wml(const vconfig& cfg);
|
||||
|
||||
display& disp_;
|
||||
CVideo& video_;
|
||||
const resize_lock disp_resize_lock_;
|
||||
const events::event_context evt_context_;
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#include "storyscreen/interface.hpp"
|
||||
#include "storyscreen/controller.hpp"
|
||||
|
||||
#include "display.hpp"
|
||||
#include "gettext.hpp"
|
||||
#include "intro.hpp"
|
||||
#include "language.hpp"
|
||||
|
@ -34,7 +33,7 @@
|
|||
static lg::log_domain log_engine("engine");
|
||||
#define LOG_NG LOG_STREAM(info, log_engine)
|
||||
|
||||
void show_story(display &disp, const std::string &scenario_name,
|
||||
void show_story(CVideo& video, const std::string &scenario_name,
|
||||
const config::const_child_itors &story)
|
||||
{
|
||||
events::event_context story_context;
|
||||
|
@ -44,7 +43,7 @@ void show_story(display &disp, const std::string &scenario_name,
|
|||
storyscreen::START_POSITION startpos = storyscreen::START_BEGINNING;
|
||||
while (itor != story.second)
|
||||
{
|
||||
storyscreen::controller ctl(disp, vconfig(*itor, true),
|
||||
storyscreen::controller ctl(video, vconfig(*itor, true),
|
||||
scenario_name, segment_count);
|
||||
storyscreen::STORY_RESULT result = ctl.show(startpos);
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#include "config.hpp"
|
||||
|
||||
class vconfig;
|
||||
class display;
|
||||
class CVideo;
|
||||
class t_string;
|
||||
|
||||
namespace storyscreen {
|
||||
|
@ -43,7 +43,7 @@ enum START_POSITION {
|
|||
* 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(display &disp, const std::string &scenario_name,
|
||||
void show_story(CVideo& video, const std::string &scenario_name,
|
||||
const config::const_child_itors &story);
|
||||
|
||||
#endif /* ! STORYSCREEN_HPP_INCLUDED */
|
||||
|
|
|
@ -86,12 +86,11 @@ namespace {
|
|||
|
||||
namespace storyscreen {
|
||||
|
||||
part_ui::part_ui(part &p, display &disp, gui::button &next_button,
|
||||
part_ui::part_ui(part &p, CVideo& video, gui::button &next_button,
|
||||
gui::button &back_button, gui::button&play_button)
|
||||
: events::sdl_handler(false)
|
||||
, p_(p)
|
||||
, disp_(disp)
|
||||
, video_(disp.video())
|
||||
, video_(video)
|
||||
, keys_()
|
||||
, next_button_(next_button)
|
||||
, back_button_(back_button)
|
||||
|
@ -298,10 +297,6 @@ void part_ui::prepare_geometry()
|
|||
back_button_.set_location(buttons_x_, buttons_y_ - 30);
|
||||
next_button_.set_location(buttons_x_ + play_button_.width() - next_button_.width(), buttons_y_ - 30);
|
||||
play_button_.set_location(buttons_x_, buttons_y_);
|
||||
|
||||
next_button_.set_volatile(true);
|
||||
play_button_.set_volatile(true);
|
||||
back_button_.set_volatile(true);
|
||||
}
|
||||
|
||||
void part_ui::prepare_floating_images()
|
||||
|
@ -952,7 +947,7 @@ bool part_ui::handle_interface()
|
|||
events::pump();
|
||||
events::raise_process_event();
|
||||
events::raise_draw_event();
|
||||
disp_.flip();
|
||||
video_.flip();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ public:
|
|||
* @param disp Display.
|
||||
* @param next_button Next button. Shouldn't be destroyed before the part_ui object.
|
||||
*/
|
||||
part_ui(part &p, display &disp, gui::button &next_button,
|
||||
part_ui(part &p, CVideo& video, gui::button &next_button,
|
||||
gui::button &back_button, gui::button& play_button);
|
||||
|
||||
/**
|
||||
|
@ -71,8 +71,7 @@ public:
|
|||
|
||||
private:
|
||||
part& p_;
|
||||
display& disp_;
|
||||
CVideo& video_; // convenience, it's currently obtained from disp_
|
||||
CVideo& video_;
|
||||
CKey keys_; // convenience
|
||||
|
||||
gui::button& next_button_;
|
||||
|
|
Loading…
Add table
Reference in a new issue