feat: Implement pause/resume conversation actions
When paused, conversation entries cannot be skipped by clicking the mouse.
This commit is contained in:
parent
77adec041f
commit
3d29f31eb2
5 changed files with 36 additions and 3 deletions
|
@ -99,6 +99,16 @@ void ActionExecutor::executeActions(const shared_ptr<Object> &object, float dt)
|
|||
case ActionType::PlayAnimation:
|
||||
executePlayAnimation(object, dynamic_pointer_cast<PlayAnimationAction>(action), dt);
|
||||
break;
|
||||
case ActionType::PauseConversation: {
|
||||
_game->conversation().pause();
|
||||
action->complete();
|
||||
break;
|
||||
}
|
||||
case ActionType::ResumeConversation: {
|
||||
_game->conversation().resume();
|
||||
action->complete();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
debug("ActionExecutor: action not implemented: " + to_string(static_cast<int>(type)), 2);
|
||||
action->complete();
|
||||
|
|
|
@ -108,6 +108,7 @@ public:
|
|||
CharacterGeneration &characterGeneration() { return *_charGen; }
|
||||
CameraType cameraType() const { return _cameraType; }
|
||||
ScriptRunner &scriptRunner() { return _scriptRunner; }
|
||||
Conversation &conversation() { return *_conversation; }
|
||||
|
||||
void setCursorType(CursorType type);
|
||||
void setLoadFromSaveGame(bool load);
|
||||
|
|
|
@ -273,13 +273,17 @@ bool Conversation::handle(const SDL_Event &event) {
|
|||
}
|
||||
|
||||
bool Conversation::handleMouseButtonDown(const SDL_MouseButtonEvent &event) {
|
||||
if (event.button == SDL_BUTTON_LEFT && !_entryEnded && (_dialog->isSkippable() || g_allEntriesSkippable)) {
|
||||
if (event.button == SDL_BUTTON_LEFT && !_entryEnded && isSkippableEntry()) {
|
||||
endCurrentEntry();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Conversation::isSkippableEntry() const {
|
||||
return g_allEntriesSkippable || (_dialog->isSkippable() && !_paused);
|
||||
}
|
||||
|
||||
void Conversation::endCurrentEntry() {
|
||||
_entryEnded = true;
|
||||
|
||||
|
@ -306,7 +310,7 @@ bool Conversation::handleKeyUp(const SDL_KeyboardEvent &event) {
|
|||
SDL_Scancode key = event.keysym.scancode;
|
||||
if (key >= SDL_SCANCODE_1 && key <= SDL_SCANCODE_9) {
|
||||
int index = key - SDL_SCANCODE_1;
|
||||
if (_entryEnded || _dialog->isSkippable() || g_allEntriesSkippable) {
|
||||
if (_entryEnded) {
|
||||
pickReply(index);
|
||||
return true;
|
||||
}
|
||||
|
@ -337,6 +341,14 @@ CameraType Conversation::getCamera(int &cameraId) const {
|
|||
return CameraType::Dialog;
|
||||
}
|
||||
|
||||
void Conversation::pause() {
|
||||
_paused = true;
|
||||
}
|
||||
|
||||
void Conversation::resume() {
|
||||
_paused = false;
|
||||
}
|
||||
|
||||
} // namespace game
|
||||
|
||||
} // namespace reone
|
||||
|
|
|
@ -61,6 +61,13 @@ public:
|
|||
*/
|
||||
CameraType getCamera(int &cameraId) const;
|
||||
|
||||
/**
|
||||
* Pause this conversation. When paused, entries cannot be skipped by clicking the mouse.
|
||||
*/
|
||||
void pause();
|
||||
|
||||
void resume();
|
||||
|
||||
protected:
|
||||
Game *_game;
|
||||
std::string _repliesControlTag;
|
||||
|
@ -71,6 +78,7 @@ protected:
|
|||
std::shared_ptr<render::LipAnimation> _lipAnimation;
|
||||
const Dialog::EntryReply *_currentEntry { nullptr };
|
||||
bool _entryEnded { false };
|
||||
bool _paused { false };
|
||||
|
||||
virtual void onStart();
|
||||
virtual void onFinish();
|
||||
|
@ -99,6 +107,8 @@ private:
|
|||
void scheduleEndOfEntry();
|
||||
void loadReplies();
|
||||
|
||||
bool isSkippableEntry() const;
|
||||
|
||||
/**
|
||||
* Replaces text in the message control.
|
||||
*/
|
||||
|
|
|
@ -243,7 +243,7 @@ void Routines::addKotorRoutines() {
|
|||
add("ActionWait", Void, { Float }, &Routines::actionWait);
|
||||
add("SetAreaTransitionBMP", Void, { Int, String });
|
||||
add("ActionStartConversation", Void, { Object, String, Int, Int, Int, String, String, String, String, String, String, Int }, &Routines::actionStartConversation);
|
||||
add("ActionPauseConversation", Void, { }), &Routines::actionPauseConversation;
|
||||
add("ActionPauseConversation", Void, { }, &Routines::actionPauseConversation);
|
||||
add("ActionResumeConversation", Void, { }, &Routines::actionResumeConversation);
|
||||
add("EffectBeam", Effect, { Int, Object, Int, Int }, &Routines::effectBeam);
|
||||
add("GetReputation", Int, { Object, Object });
|
||||
|
|
Loading…
Reference in a new issue