feat(jobs): Jobs.1 client UI infra (handler + library + tecla J) + UI tweaks
Infraestrutura cliente da promocao de classe (Jobs.1). WBP_JobChangePanel NAO esta neste commit — foi exploracao descartada (criar UI dinamica de botoes via MCP BP graph esbarrou em limites do CreateWidget node). A fundacao C++ fica pronta pra ser usada quando voltarmos pra UI. INFRA C++ NOVA (Source/ZMMOJobs/) * UZMMOJobChangeNetworkHandler (WorldSubsystem novo) — bind no OnJobChangeResult do plugin e re-broadcast via FZMMOOnJobChangeResultBP (dynamic multicast assignavel em BP). WBP futura escuta direto. * UZMMOJobsSubsystem helpers: GetJobsByTier(EZMMOJobTier) + GetEligibleNextJobs(currentClassId) — filtra por ParentClassId. Pure. * UZMMOJobsLibrary BPFL wrappers + SendJobChangeRequest convenience (delega pro UZeusNetworkSubsystem). Dep ZeusNetwork adicionada no Build.cs. ENUM + INPUT * EZMMOInGameUIState ganha JobChangePanel (entre StatusWindow e Inventory). DA_InGameScreenSet pendente de receber entry quando WBP for criada (tecla J vai falhar silenciosamente ate la). * ZMMOPlayerController: tecla J -> ToggleJobChangePanel -> Flow->ToggleScreen(JobChangePanel). Espelha pattern do Alt+A do StatusWindow (InputComponent legacy BindKey + FInputChord). UI TWEAKS * WBP_StatusWindow + DT_UI_Styles: ajustes visuais no Editor durante a sessao (sem mudanca funcional documentavel — provavelmente fontes/ spacing/cores). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
67
Source/ZMMOJobs/Private/ZMMOJobChangeNetworkHandler.cpp
Normal file
67
Source/ZMMOJobs/Private/ZMMOJobChangeNetworkHandler.cpp
Normal file
@@ -0,0 +1,67 @@
|
||||
#include "ZMMOJobChangeNetworkHandler.h"
|
||||
|
||||
#include "Engine/GameInstance.h"
|
||||
#include "Engine/World.h"
|
||||
#include "ZeusNetworkSubsystem.h"
|
||||
|
||||
DEFINE_LOG_CATEGORY_STATIC(LogZMMOJobChange, Log, All);
|
||||
|
||||
bool UZMMOJobChangeNetworkHandler::ShouldCreateSubsystem(UObject* Outer) const
|
||||
{
|
||||
// Mesmo criterio do AttributeNetworkHandler — so' em mundos de gameplay
|
||||
// (PIE / standalone in-game). Editor preview / front-end menu nao precisa.
|
||||
const UWorld* World = Cast<UWorld>(Outer);
|
||||
if (World == nullptr) { return false; }
|
||||
return World->WorldType == EWorldType::Game
|
||||
|| World->WorldType == EWorldType::PIE;
|
||||
}
|
||||
|
||||
void UZMMOJobChangeNetworkHandler::Initialize(FSubsystemCollectionBase& Collection)
|
||||
{
|
||||
Super::Initialize(Collection);
|
||||
|
||||
if (UZeusNetworkSubsystem* Net = GetZeusNetSubsystem())
|
||||
{
|
||||
JobChangeResultHandle = Net->OnJobChangeResult.AddUObject(
|
||||
this, &UZMMOJobChangeNetworkHandler::HandleJobChangeResult);
|
||||
UE_LOG(LogZMMOJobChange, Log,
|
||||
TEXT("[ZMMOJobChangeNetworkHandler] Bind OnJobChangeResult OK"));
|
||||
}
|
||||
else
|
||||
{
|
||||
UE_LOG(LogZMMOJobChange, Warning,
|
||||
TEXT("[ZMMOJobChangeNetworkHandler] ZeusNetworkSubsystem indisponivel — bind pulado"));
|
||||
}
|
||||
}
|
||||
|
||||
void UZMMOJobChangeNetworkHandler::Deinitialize()
|
||||
{
|
||||
if (UZeusNetworkSubsystem* Net = GetZeusNetSubsystem())
|
||||
{
|
||||
if (JobChangeResultHandle.IsValid())
|
||||
{
|
||||
Net->OnJobChangeResult.Remove(JobChangeResultHandle);
|
||||
JobChangeResultHandle.Reset();
|
||||
}
|
||||
}
|
||||
OnJobChangeResult.Clear();
|
||||
Super::Deinitialize();
|
||||
}
|
||||
|
||||
void UZMMOJobChangeNetworkHandler::HandleJobChangeResult(
|
||||
bool bAccepted, int32 Reason, int32 NewClassId)
|
||||
{
|
||||
UE_LOG(LogZMMOJobChange, Log,
|
||||
TEXT("[ZMMOJobChangeNetworkHandler] S_JOB_CHANGE_RESULT accepted=%d reason=%d newClassId=%d"),
|
||||
bAccepted ? 1 : 0, Reason, NewClassId);
|
||||
OnJobChangeResult.Broadcast(bAccepted, Reason, NewClassId);
|
||||
}
|
||||
|
||||
UZeusNetworkSubsystem* UZMMOJobChangeNetworkHandler::GetZeusNetSubsystem() const
|
||||
{
|
||||
const UWorld* World = GetWorld();
|
||||
if (World == nullptr) { return nullptr; }
|
||||
UGameInstance* GI = World->GetGameInstance();
|
||||
if (GI == nullptr) { return nullptr; }
|
||||
return GI->GetSubsystem<UZeusNetworkSubsystem>();
|
||||
}
|
||||
Reference in New Issue
Block a user