mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-11-30 09:51:38 +00:00
Each player gets the activity close button; it asks to confirm leaving, and yes takes the button away and sends the player to their last zone that is not an instance. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
51 lines
2.0 KiB
C++
51 lines
2.0 KiB
C++
#include "ZoneFireTempleServer.h"
|
|
#include "GameMessages.h"
|
|
#include "EffectsMessages.h"
|
|
#include "Entity.h"
|
|
#include "Character.h"
|
|
#include "CharacterComponent.h"
|
|
#include "Amf3.h"
|
|
|
|
void ZoneFireTempleServer::OnZoneLoadedInfo(Entity* self, const GameMessages::ZoneLoadedInfo& info) {
|
|
self->SetVar<int32_t>(u"initialPlayerCount", info.maxPlayers);
|
|
}
|
|
|
|
void ZoneFireTempleServer::ToggleActivityCloseButton(Entity* player, const bool show) {
|
|
AMFArrayValue args;
|
|
args.Insert("bShow", show);
|
|
GameMessages::UIMessageServerToSingleClient uiMessage;
|
|
uiMessage.target = player->GetObjectID();
|
|
uiMessage.strMessageName = "ToggleActivityCloseButton";
|
|
uiMessage.args = std::move(args);
|
|
uiMessage.SendToClient(player->GetSystemAddress());
|
|
}
|
|
|
|
// (The Lua also keeps a list of the players in the zone, which nothing reads.)
|
|
void ZoneFireTempleServer::OnPlayerLoaded(Entity* self, Entity* player) {
|
|
ToggleActivityCloseButton(player, true);
|
|
}
|
|
|
|
void ZoneFireTempleServer::OnMessageBoxResponse(Entity* self, Entity* sender, int32_t button, const std::u16string& identifier, const std::u16string& userData) {
|
|
if (!sender) return;
|
|
const auto asked = u"|" + GeneralUtils::ASCIIToUTF16(std::to_string(sender->GetObjectID()));
|
|
if (identifier == u"ActivityButton" && !self->GetVar<bool>(asked)) {
|
|
self->SetVar<bool>(asked, true);
|
|
GameMessages::DisplayMessageBox messageBox;
|
|
messageBox.target = sender->GetObjectID();
|
|
messageBox.bShow = true;
|
|
messageBox.imageID = 1;
|
|
messageBox.callbackClient = self->GetObjectID();
|
|
messageBox.text = u"UI_EULA_CONFIRM_EXIT_LINE2";
|
|
messageBox.identifier = u"Exit";
|
|
messageBox.SendToClient(sender->GetSystemAddress());
|
|
} else if (identifier == u"Exit") {
|
|
self->SetVar<bool>(asked, false);
|
|
if (button == 1) {
|
|
ToggleActivityCloseButton(sender, false);
|
|
auto* const character = sender->GetCharacter();
|
|
auto* const characterComponent = sender->GetComponent<CharacterComponent>();
|
|
if (character && characterComponent) characterComponent->SendToZone(character->GetLastNonInstanceZoneID());
|
|
}
|
|
}
|
|
}
|