-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: sync player dialogue through chat
- Loading branch information
1 parent
99b16c4
commit e811196
Showing
20 changed files
with
213 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#pragma once | ||
|
||
struct PlayerDialogueEvent | ||
{ | ||
PlayerDialogueEvent(String aText) | ||
: Text(std::move(aText)) | ||
{ | ||
} | ||
|
||
String Text; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#include "MenuTopicManager.h" | ||
|
||
#include <Events/PlayerDialogueEvent.h> | ||
|
||
TP_THIS_FUNCTION(TPlayDialogueOption, bool, MenuTopicManager, int32_t aIndex); | ||
static TPlayDialogueOption* RealPlayDialogueOption = nullptr; | ||
|
||
MenuTopicManager* MenuTopicManager::Get() noexcept | ||
{ | ||
POINTER_SKYRIMSE(MenuTopicManager*, s_singleton, 401099); | ||
|
||
return *s_singleton.Get(); | ||
} | ||
|
||
bool TP_MAKE_THISCALL(HookPlayDialogueOption, MenuTopicManager, int32_t aIndex) | ||
{ | ||
if (apThis->pOptions) | ||
{ | ||
int i = 0; | ||
const char* pText = nullptr; | ||
for (auto option : *apThis->pOptions) | ||
{ | ||
if (i == aIndex) | ||
{ | ||
pText = option->text; | ||
break; | ||
} | ||
i++; | ||
} | ||
|
||
if (pText != nullptr) | ||
World::Get().GetRunner().Trigger(PlayerDialogueEvent(pText)); | ||
} | ||
|
||
return ThisCall(RealPlayDialogueOption, apThis, aIndex); | ||
} | ||
|
||
TiltedPhoques::Initializer s_menuTopicHooks([]() | ||
{ | ||
POINTER_SKYRIMSE(TPlayDialogueOption, s_playDialogueOption, 35269); | ||
|
||
RealPlayDialogueOption = s_playDialogueOption.Get(); | ||
|
||
TP_HOOK(&RealPlayDialogueOption, HookPlayDialogueOption); | ||
}); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#pragma once | ||
|
||
struct MenuTopicManager | ||
{ | ||
static MenuTopicManager* Get() noexcept; | ||
|
||
struct DialogueOption | ||
{ | ||
const char* text; | ||
}; | ||
|
||
uint8_t pad0[0x20]; | ||
GameList<DialogueOption>* pOptions; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#include <Messages/NotifyPlayerDialogue.h> | ||
|
||
void NotifyPlayerDialogue::SerializeRaw(TiltedPhoques::Buffer::Writer& aWriter) const noexcept | ||
{ | ||
Serialization::WriteString(aWriter, Text); | ||
} | ||
|
||
void NotifyPlayerDialogue::DeserializeRaw(TiltedPhoques::Buffer::Reader& aReader) noexcept | ||
{ | ||
ServerMessage::DeserializeRaw(aReader); | ||
|
||
Text = Serialization::ReadString(aReader); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#pragma once | ||
|
||
#include "Message.h" | ||
|
||
struct NotifyPlayerDialogue final : ServerMessage | ||
{ | ||
static constexpr ServerOpcode Opcode = kNotifyPlayerDialogue; | ||
|
||
NotifyPlayerDialogue() : ServerMessage(Opcode) | ||
{ | ||
} | ||
|
||
void SerializeRaw(TiltedPhoques::Buffer::Writer& aWriter) const noexcept override; | ||
void DeserializeRaw(TiltedPhoques::Buffer::Reader& aReader) noexcept override; | ||
|
||
bool operator==(const NotifyPlayerDialogue& achRhs) const noexcept | ||
{ | ||
return GetOpcode() == achRhs.GetOpcode() && | ||
Text == achRhs.Text; | ||
} | ||
|
||
TiltedPhoques::String Text{}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#include <Messages/PlayerDialogueRequest.h> | ||
|
||
void PlayerDialogueRequest::SerializeRaw(TiltedPhoques::Buffer::Writer& aWriter) const noexcept | ||
{ | ||
Serialization::WriteString(aWriter, Text); | ||
} | ||
|
||
void PlayerDialogueRequest::DeserializeRaw(TiltedPhoques::Buffer::Reader& aReader) noexcept | ||
{ | ||
ClientMessage::DeserializeRaw(aReader); | ||
|
||
Text = Serialization::ReadString(aReader); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#pragma once | ||
|
||
#include "Message.h" | ||
|
||
using TiltedPhoques::String; | ||
|
||
struct PlayerDialogueRequest final : ClientMessage | ||
{ | ||
static constexpr ClientOpcode Opcode = kPlayerDialogueRequest; | ||
|
||
PlayerDialogueRequest() : ClientMessage(Opcode) | ||
{ | ||
} | ||
|
||
void SerializeRaw(TiltedPhoques::Buffer::Writer& aWriter) const noexcept override; | ||
void DeserializeRaw(TiltedPhoques::Buffer::Reader& aReader) noexcept override; | ||
|
||
bool operator==(const PlayerDialogueRequest& acRhs) const noexcept | ||
{ | ||
return GetOpcode() == acRhs.GetOpcode() && | ||
Text == acRhs.Text; | ||
} | ||
|
||
TiltedPhoques::String Text{}; | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.