Lots of refactoring in IntegrationGameModeBase

This commit is contained in:
2023-09-05 03:20:11 -04:00
parent cfc536011e
commit 1482e5e43f
6 changed files with 109 additions and 51 deletions

View File

@@ -65,46 +65,44 @@ void AIntegrationGameModeBase::ResetToInitialState()
}
void AIntegrationGameModeBase::HandleLuprexConsoleOutput(FLockedWrapper &w)
{
uint32_t ndata; const char* data;
w->get_outgoing(w.Get(), 0, &ndata, &data);
if (ndata == 0) return;
std::string_view src(data, ndata);
int consumed;
std::u16string cps = drvutil::utf8_to_ucs2(src, &consumed);
w->play_sent_outgoing(w.Get(), 0, consumed);
FString fs(cps.size(), (const UCS2CHAR*)(&cps[0]));
ConsoleOutput.Append(fs);
}
void AIntegrationGameModeBase::UpdateConsoleOutput() {
// Copy Luprex Stdout into the console.
FLockedWrapper lockedwrap(LockableWrapper);
ConsoleOutput.Append(lockedwrap.FetchStdout());
void AIntegrationGameModeBase::Tick(float DeltaSeconds)
{
Super::Tick(DeltaSeconds);
{
FLockedWrapper lockedwrap(LockableWrapper);
if (lockedwrap->engine != nullptr)
{
EngineSeconds += DeltaSeconds;
HandleLuprexConsoleOutput(lockedwrap);
}
}
// Copy Debugging Prints into the console.
TArray<FString> prints = DebugPrintControl::GetStored();
for (const FString& fs : prints) {
ConsoleOutput.AppendLine(fs);
}
if (ConsoleOutput.IsDirty())
{
// If the Console text has changed, update the widget.
if (ConsoleOutput.IsDirty()) {
ConsoleSetOutput(ConsoleOutput.Get());
ConsoleOutput.ClearDirty();
}
if (EngineSeconds >= NextThreadTrigger)
}
void AIntegrationGameModeBase::MaybeTriggerUpdateTask(float deltaseconds) {
FLockedWrapper lockedwrap(LockableWrapper);
if (lockedwrap->engine != nullptr)
{
LuprexUpdateTask.Trigger();
NextThreadTrigger += 0.05;
EngineSeconds += deltaseconds;
if (EngineSeconds >= NextThreadTrigger)
{
LuprexUpdateTask.Trigger();
NextThreadTrigger += 0.05;
}
}
}
void AIntegrationGameModeBase::Tick(float deltaseconds)
{
Super::Tick(deltaseconds);
UpdateConsoleOutput();
MaybeTriggerUpdateTask(deltaseconds);
}
void AIntegrationGameModeBase::ConsoleSendInput(const FString& fs)
{
FLockedWrapper w(LockableWrapper);