Lua Console Overhaul in progress

This commit is contained in:
2025-12-09 02:42:13 -05:00
parent a242244f9c
commit 2d1def8dc6
10 changed files with 105 additions and 63 deletions

View File

@@ -3,7 +3,6 @@
#include "LuprexGameModeBase.h"
#include "lpx-drvutil.hpp"
#include "lpx-paths.hpp"
#include "ConsoleOutput.h"
#include "Tangible.h"
#include "TangibleManager.h"
#include "LuaCall.h"
@@ -124,18 +123,15 @@ void ALuprexGameModeBase::ResetToInitialState()
NextRotateCube = 1.0;
}
void ALuprexGameModeBase::UpdateConsoleOutput() {
// Copy Luprex Stdout into the console.
FlxLockedWrapper lockedwrap(LockableWrapper);
if (Playing) {
ConsoleOutput.Append(lockedwrap.FetchStdout());
}
// If the Console text has changed, update the widget.
if (ConsoleOutput.IsDirty()) {
ConsoleSetOutput(ConsoleOutput.Get());
ConsoleOutput.ClearDirty();
FString Text = lockedwrap.FetchStdout();
if (!Text.IsEmpty())
{
ConsoleAddOutput(Text);
}
}
}
@@ -227,32 +223,15 @@ UlxLuaValues *ALuprexGameModeBase::LuaCallEnd(AccessKind kind, AActor *place) {
}
}
void ALuprexGameModeBase::ExecuteDebuggingCommand(FlxLockedWrapper &w, const FString &fs) {
// Nothing here right now.
}
void ALuprexGameModeBase::ConsoleSendInput(const FString& fs)
FString ALuprexGameModeBase::LuaValidate(const FString &Code)
{
if (fs.IsEmpty()) {
return;
}
FTCHARToUTF8 UCode(*Code);
FlxLockedWrapper w(LockableWrapper);
if (w->engine != nullptr)
{
ConsoleOutput.AppendLine(FString("> ") + fs);
// This is a bad way to do this. The problem is that if some
// lua code contains '\\', we'll catch it instead of passing it
// through. There's no simple solution, though.
if (fs[0] == '\\') {
ExecuteDebuggingCommand(w, fs);
} else {
FTCHARToUTF8 utf8fs(fs);
std::string ufs(utf8fs.Get(), utf8fs.Length());
ufs = ufs + "\n";
w->play_recv_incoming(w.Get(), 0, ufs.size(), ufs.c_str());
}
}
uint32_t retpklen;
const char *retpk;
w->play_access(w.Get(), AccessKind::VALIDATE_LUA, 0, UCode.Length(), UCode.Get(), &retpklen, &retpk);
FString Result(retpklen, (const UTF8CHAR*)retpk);
return Result;
}
void ALuprexGameModeBase::OnWorldPreActorTick(UWorld* InWorld, ELevelTick InLevelTick, float deltaseconds)