The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
replay_controller.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2015 - 2016 by the Battle for Wesnoth Project
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY.
10 
11  See the COPYING file for more details.
12 */
13 
14 #pragma once
15 
16 #include "global.hpp"
17 #include "play_controller.hpp"
18 #include "replay.hpp"
19 #include "mouse_handler_base.hpp" //events::command_disabler
20 
21 #include <vector>
22 
23 class video;
24 
26 {
27 public:
29  {
30  public:
31  virtual void move_done() {}
32  virtual void new_side_turn(int , int ) {}
33  virtual bool should_stop() { return true; }
35  };
36  static void nop() {};
37  replay_controller(play_controller& controller, bool control_view, const boost::shared_ptr<config>& reset_state, const std::function<void()>& on_end_replay = nop);
39 
40  // void reset_replay();
41  void play_replay();
42  void stop_replay();
43  void replay_next_turn();
44  void replay_next_side();
45  void replay_next_move();
47 
48  bool recorder_at_end() const;
49  bool should_stop() const { return stop_condition_->should_stop(); }
50  bool can_execute_command(const hotkey::hotkey_command& cmd, int index) const;
51  bool is_controlling_view() const { return vision_.is_initialized(); }
52  bool allow_reset_replay() const { return reset_state_.get() != nullptr; }
54  void return_to_play_side(bool r = true) { return_to_play_side_ = r; }
56  void replay_show_each();
57  void replay_show_team1();
58  void update_teams();
59  void update_viewing_player();
60 private:
61  void add_replay_theme();
62  void init();
63  void update_gui();
64  void rebuild_replay_theme();
65  void handle_generic_event(const std::string& name) override;
66 
67  void reset_replay_ui();
68  void update_replay_ui();
69 
72 
73  std::shared_ptr<gui::button> play_button();
74  std::shared_ptr<gui::button> stop_button();
75  std::shared_ptr<gui::button> reset_button();
76  std::shared_ptr<gui::button> play_turn_button();
77  std::shared_ptr<gui::button> play_side_button();
78  std::shared_ptr<gui::button> play_move_button();
79 
81  return play_button() && stop_button() && reset_button() &&
83  }
85  boost::scoped_ptr<replay_stop_condition> stop_condition_;
87 
89  {
93  };
94  boost::optional<REPLAY_VISION> vision_;
96  std::function<void()> on_end_replay_;
98 };
99 
std::function< void()> on_end_replay_
boost::optional< REPLAY_VISION > vision_
void return_to_play_side(bool r=true)
Stores all information related to functions that can be bound to hotkeys.
Replay control code.
bool is_controlling_view() const
events::command_disabler disabler_
const boost::shared_ptr< config > & get_reset_state()
std::shared_ptr< gui::button > play_button()
bool recorder_at_end() const
boost::scoped_ptr< replay_stop_condition > stop_condition_
void handle_generic_event(const std::string &name) override
REPLAY_RETURN
Definition: replay.hpp:155
std::shared_ptr< gui::button > play_turn_button()
boost::shared_ptr< config > reset_state_
std::shared_ptr< gui::button > stop_button()
REPLAY_RETURN play_side_impl()
replay_controller(play_controller &controller, bool control_view, const boost::shared_ptr< config > &reset_state, const std::function< void()> &on_end_replay=nop)
bool allow_reset_replay() const
GLuint index
Definition: glew.h:1782
GLdouble GLdouble GLdouble r
Definition: glew.h:1374
GLuint const GLchar * name
Definition: glew.h:1782
std::shared_ptr< gui::button > play_side_button()
void replay_ui_playback_should_start()
play_controller & controller_
bool can_execute_command(const hotkey::hotkey_command &cmd, int index) const
std::shared_ptr< gui::button > reset_button()
GLsizei const GLcharARB ** string
Definition: glew.h:4503
bool should_stop() const
std::shared_ptr< gui::button > play_move_button()