14 , playerMenu(engine, canRun)
17 , localPeoplemon(engine, view::PeoplemonAnimation::Player)
18 , opponentPeoplemon(engine, view::PeoplemonAnimation::Opponent)
19 , moveAnimation(engine) {}
22 bgndTxtr = engine.renderer().texturePool().getOrLoadTexture(
24 background.create(engine, bgndTxtr);
25 background.addToScene(scene, bl::rc::UpdateSpeed::Static);
28 statBoxes.
init(scene);
29 moveAnimation.
init(scene);
30 playerMenu.
init(scene);
31 localPeoplemon.
init(scene);
32 opponentPeoplemon.
init(scene);
53 case Command::Type::DisplayMessage:
57 case Command::Type::PlayAnimation: {
58 const bool userIsPlayer =
62 case Animation::Type::UseMove:
68 case Animation::Type::PlayerFirstSendout:
72 case Animation::Type::OpponentFirstSendout:
77 auto& anim = userIsPlayer ? localPeoplemon : opponentPeoplemon;
83 case Command::Type::SyncStateNoSwitch:
87 case Command::Type::SyncStateSwitch: {
105 BL_LOG_ERROR <<
"Unknown command type: " << cmd.
getType();
121 localPeoplemon.
update(dt);
122 opponentPeoplemon.
update(dt);
127 background.draw(ctx);
131 localPeoplemon.
render(ctx);
132 opponentPeoplemon.
render(ctx);
136 !playerMenu.
ready()) {
142 bool BattleView::observe(
const bl::input::Actor&,
unsigned int ctrl, bl::input::DispatchType,
143 bool eventTriggered) {
146 !playerMenu.
ready()) {
149 else { printer.
process(ctrl, eventTriggered); }
Core classes and functionality for both the editor and game.
unsigned int outNowIndex() const
Returns the index of the peoplemon that is out now.
core::pplmn::BattlePeoplemon & activePeoplemon()
Returns the peoplemon that is currently out.
bool isHost() const
Returns whether or not this battler is the host.
Stores and represents the current state of a battle. This is the base class for local and remote batt...
Stage currentStage() const
Returns the current stage the battle is in.
Battler & enemy()
Returns the opponent Battler.
Battler & localPlayer()
Returns the local player Battler.
@ WaitingForgetMoveChoice
view::PlayerMenu & menu()
Access the player's menu.
void render(bl::rc::scene::CodeScene::RenderContext &ctx)
Renders the battle view.
void init(bl::rc::scene::CodeScene *scene)
Initializes renderer data, loads resources, and adds entities to the scene.
bool playerChoseToSetName() const
Returns whether or not the player chose to set a nickname on a new Peoplemon.
bool playerChoseForgetMove() const
Returns whether or not the player chose to forget a move when prompted.
void update(float dt)
Updates the view, including contained animations and printing text.
void hideText()
Hides the battle text when the view is synced.
void processCommand(const Command &command)
Processes a command and updates the view.
const std::string & chosenNickname() const
Returns the nickname the player entered.
bool actionsCompleted() const
Returns true if the view is done going through the queued commands and all components are synchronize...
BattleView(bl::engine::Engine &engine, BattleState &state, bool canRun)
Construct a new Battle View.
Represents a type of animation that can be played in battle.
pplmn::MoveId getMove() const
Returns the move for this animation.
bool forHostBattler() const
Returns whether or not this animation is for the host or not.
Type getType() const
Returns the type of animation to play.
Emitted by the BattleFSM. All UI is handled via a queue of commands. Commands are resolved in the ord...
bool forHost() const
Returns whether or not this command is for the active battler.
const cmd::Message & getMessage() const
Returns the message if this command is a message.
Type getType() const
Returns the type of this command.
const cmd::Animation & getAnimation() const
Returns the animation if this command is an animation.
const std::string & chosenNickname() const
Returns the nickname chosen by the player.
void process(input::EntityControl ctrl, bool ignoreDebounce)
Displays the full message. Call when user presses the continue button.
void update(float dt)
Updates the ghost writer.
void hide()
Hides the text once the view is fully synced.
bool messageDone() const
Returns true when the full message is on display and finishPrint() has been called.
void render(bl::rc::scene::CodeScene::RenderContext &ctx)
Renders the message.
bool choseToSetName() const
Whether or not the player chose to set a nickname.
void init(bl::rc::scene::CodeScene *scene)
Initializes the UI components and adds to scene.
bool choseToForget() const
Returns whether or not the player chose to forget a move.
void setMessage(BattleState &state, const cmd::Message &message)
Set the message to be printed.
void renderBackground(bl::rc::scene::CodeScene::RenderContext &ctx)
Renders the move animation background.
void ensureLoaded(const pplmn::BattlePeoplemon &player, const pplmn::BattlePeoplemon &opponent)
Loads the move animations into the resource manager for the given peoplemon.
void playAnimation(User user, pplmn::MoveId move)
Begins playing the given move animation.
bool completed() const
Returns whether or not the animation has completed playing.
void init(bl::rc::scene::CodeScene *scene)
Initializes the animations.
void renderForeground(bl::rc::scene::CodeScene::RenderContext &ctx)
Renders the move animation foreground.
void init(bl::rc::scene::CodeScene *scene)
Initializes rendering resources.
void render(bl::rc::scene::CodeScene::RenderContext &ctx)
Renders the peoplemon animation.
void triggerAnimation(const cmd::Animation &anim)
Begins playing the given animation.
bool completed() const
Returns true if the animation has completed, false if in progress.
void update(float dt)
Updates the playing animation.
void setPeoplemon(pplmn::Id ppl)
Sets the specific peoplemon graphic and resets to hidden state.
The player menu for battles.
void handleInput(input::EntityControl input, bool ignoreDebounce)
Processes player input to update the menu state.
void setPeoplemon(int i, const pplmn::BattlePeoplemon &ppl)
Updates the menu for the given peoplemon.
void render(bl::rc::scene::CodeScene::RenderContext &ctx)
Renders the menu.
void init(bl::rc::scene::CodeScene *scene)
Creates UI elements and adds them to the scene.
void refresh()
Polls state from opened peoplemon or bag menu.
bool ready() const
Returns true when the player's choice has been made.
void sync(bool fromSwitch=false)
Updates the UI to reflect the current peoplemon state.
void init(bl::rc::scene::CodeScene *scene)
Creates entities and adds them to the scene.
void update(float dt)
Updates bar sizes if they need to change.
void setOpponent(pplmn::BattlePeoplemon *ppl)
Sets the opponent's peoplemon. Syncs right away.
void setPlayer(pplmn::BattlePeoplemon *ppl)
Sets the player's peoplemon. Syncs right away.
bool synced() const
Returns true if the view is in sync, false if an animation is in progress.
void render(bl::rc::scene::CodeScene::RenderContext &ctx)
Renders the boxes.
OwnedPeoplemon & base()
Returns the wrapped peoplemon.
Id id() const
Returns the id of this peoplemon.
static const std::string & ImagePath()