Better code reload

This commit is contained in:
2026-05-27 14:50:34 -04:00
parent d737879ed6
commit 779c9f5c2e
9 changed files with 31 additions and 64 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -77,22 +77,10 @@ void AlxPlayerControllerBase::BeginPlay()
RootWidget->AddToViewport(0);
Super::BeginPlay();
if (FSlateApplication::IsInitialized())
{
FocusChangingHandle = FSlateApplication::Get().OnFocusChanging().AddUObject(
this, &AlxPlayerControllerBase::HandleFocusChanging);
}
}
void AlxPlayerControllerBase::EndPlay(const EEndPlayReason::Type EndPlayReason)
{
if (FocusChangingHandle.IsValid() && FSlateApplication::IsInitialized())
{
FSlateApplication::Get().OnFocusChanging().Remove(FocusChangingHandle);
FocusChangingHandle.Reset();
}
if (IsValid(RootWidget))
{
RootWidget->RemoveFromParent();
@@ -103,20 +91,6 @@ void AlxPlayerControllerBase::EndPlay(const EEndPlayReason::Type EndPlayReason)
Super::EndPlay(EndPlayReason);
}
void AlxPlayerControllerBase::HandleFocusChanging(
const FFocusEvent &FocusEvent,
const FWeakWidgetPath &OldPath,
const TSharedPtr<SWidget> &OldFocusedWidget,
const FWidgetPath &NewPath,
const TSharedPtr<SWidget> &NewFocusedWidget)
{
UE_LOG(LogLuprexIntegration, Display,
TEXT("Focus changing: '%s' -> '%s' (cause: %s)"),
OldFocusedWidget.IsValid() ? *OldFocusedWidget->GetTypeAsString() : TEXT("<none>"),
NewFocusedWidget.IsValid() ? *NewFocusedWidget->GetTypeAsString() : TEXT("<none>"),
*UEnum::GetValueAsString(FocusEvent.GetCause()));
}
UInputComponent* AlxPlayerControllerBase::GetWidgetInputComponent(UUserWidget *Widget)
{
if (!IsValid(Widget)) return nullptr;

View File

@@ -48,15 +48,6 @@ public:
virtual void BeginPlay() override;
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
private:
FDelegateHandle FocusChangingHandle;
void HandleFocusChanging(
const struct FFocusEvent &FocusEvent,
const class FWeakWidgetPath &OldPath,
const TSharedPtr<class SWidget> &OldFocusedWidget,
const class FWidgetPath &NewPath,
const TSharedPtr<class SWidget> &NewFocusedWidget);
public:
virtual void BuildInputStack(TArray<UInputComponent*>& InputStack) override;

View File

@@ -536,25 +536,30 @@ void World::probe_lua_call(int64_t actor_id, int64_t place_id, std::string_view
// in top-level code.
//
bool World::rebuild_sourcedb(int64_t actor_id) {
bool ok = true;
int successes = 0;
int failures = 0;
for (const eng::string &mod: source_db_.modules()) {
open_lthread_state(0, 0, 0, false);
eng::string err = source_db_.rebuild_module(mod);
eng::string prints = lthread_prints_.str();
clear_lthread_state();
if (!err.empty()) ok = false;
if (actor_id >= 0) {
lthread_prints_ << "Compiling " << mod << std::endl;
if (err.empty()) successes ++;
else failures ++;
if ((!err.empty()) || (!prints.empty())) {
lthread_prints_ << "Compiling " << mod << ":" << std::endl;
if (!err.empty()) lthread_prints_ << err << std::endl;
if (!prints.empty()) lthread_prints_ << prints;
lthread_prints_to_actor(actor_id);
util::dprintview(lthread_prints_.view());
if (actor_id != 0) lthread_prints_to_actor(actor_id);
}
}
if (actor_id > 0) {
lthread_prints_ << (ok ? "Compilation Successful." : "Compilation Failed.") << std::endl;
lthread_prints_to_actor(actor_id);
lthread_prints_ << "Compiled " << successes << " modules successfully." << std::endl;
if (failures > 0) {
lthread_prints_ << "Compiled " << failures << " modules with errors." << std::endl;
}
return ok;
util::dprintview(lthread_prints_.view());
if (actor_id > 0) lthread_prints_to_actor(actor_id);
return (failures == 0);
}
bool World::update_source(const util::LuaSourceVec &source, int64_t actor_id) {
@@ -698,7 +703,7 @@ HttpServerResponse World::http_serve(const HttpParser &request) {
open_lthread_state(0, 0, 0, false);
eng::string msg = traceback_pcall(L, 1, LUA_MULTRET);
if (!msg.empty()) lthread_prints_ << msg << std::endl;
lthread_prints_to_actor(0);
util::dprintview(lthread_prints_.view());
clear_lthread_state();
// If the call threw an error, return
@@ -1167,13 +1172,9 @@ void World::lthread_prints_to_actor(int64_t actor_id)
{
const eng::string &output = lthread_prints_.str();
if (output.size() > 0) {
if (actor_id >= 0) {
Tangible *actor = tangible_get(actor_id);
if (actor != nullptr) {
actor->print_buffer_.add_string(output, is_authoritative());
} else {
util::dprintview(output);
}
}
lthread_prints_.str("");
lthread_prints_.clear();

View File

@@ -292,7 +292,7 @@ void World::patch_source(StreamBuffer *sb, DebugCollector *dbc) {
DebugBlock dbb(dbc, "patch_source");
bool modified = source_db_.patch(sb, dbc);
if (modified) {
rebuild_sourcedb(-1);
rebuild_sourcedb(0);
DebugLine(dbc) << "Source DB rebuilt";
}
}

View File

@@ -284,7 +284,7 @@ public:
// Rebuild the global environment from the source database.
//
// Error messages go to the specified actor.
// Error messages go to the specified actor, and also dprint.
//
// Returns true if the rebuild goes without errors.
//
@@ -292,7 +292,7 @@ public:
// Update the source database from disk, then rebuild the global environment.
//
// Error messages go to the specified actor.
// Error messages go to the specified actor, and also dprint.
//
// Returns true if the update goes without errors.
//
@@ -378,9 +378,7 @@ public:
// Send the lthread_prints output to the specified actor.
//
// If actor_id == (-1) prints are discarded.
// If actor_id == (0) prints go to dprint.
// Anything else, and the prints go to a specific actor.
// Send prints to the specified actor's printbuffer.
//
void lthread_prints_to_actor(int64_t actor_id);