получение режима внтури игры
This commit is contained in:
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include "core/Logger.hpp"
|
#include "core/Logger.hpp"
|
||||||
#include "core/Mem.hpp"
|
#include "core/Mem.hpp"
|
||||||
|
#include "runtime/LuaBindings.hpp"
|
||||||
#include "runtime/ModuleInstall.hpp"
|
#include "runtime/ModuleInstall.hpp"
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
@@ -20,6 +21,26 @@ namespace moonwell
|
|||||||
{
|
{
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
constexpr uint32_t kTraitorFlag = 0x40000000u;
|
||||||
|
bool g_loginCharacterIsTraitor = false;
|
||||||
|
|
||||||
|
int __cdecl SetLoginCharacterFlags(void* state)
|
||||||
|
{
|
||||||
|
uint32_t flags = 0;
|
||||||
|
if (state && wxl::runtime::lua::IsNumber(state, 1))
|
||||||
|
flags = static_cast<uint32_t>(wxl::runtime::lua::ToNumber(state, 1));
|
||||||
|
|
||||||
|
g_loginCharacterIsTraitor = (flags & kTraitorFlag) != 0;
|
||||||
|
wxl::runtime::lua::PushBoolean(state, g_loginCharacterIsTraitor ? 1 : 0);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int __cdecl IsTraitor(void* state)
|
||||||
|
{
|
||||||
|
wxl::runtime::lua::PushBoolean(state, g_loginCharacterIsTraitor ? 1 : 0);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
struct Patch
|
struct Patch
|
||||||
{
|
{
|
||||||
const char* name;
|
const char* name;
|
||||||
@@ -196,6 +217,9 @@ namespace moonwell
|
|||||||
{
|
{
|
||||||
Registration()
|
Registration()
|
||||||
{
|
{
|
||||||
|
wxl::runtime::lua::RegisterFunction(
|
||||||
|
"MoonWellSetLoginCharacterFlags", &SetLoginCharacterFlags);
|
||||||
|
wxl::runtime::lua::RegisterFunction("MoonWellIsTraitor", &IsTraitor);
|
||||||
wxl::runtime::modules::RegisterBoot("moonwell", &InstallBoot);
|
wxl::runtime::modules::RegisterBoot("moonwell", &InstallBoot);
|
||||||
wxl::runtime::modules::Register("moonwell-log-flush", &InstallRuntimeLogFlush);
|
wxl::runtime::modules::Register("moonwell-log-flush", &InstallRuntimeLogFlush);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1139,6 +1139,12 @@ end
|
|||||||
function CharacterSelect_EnterWorld()
|
function CharacterSelect_EnterWorld()
|
||||||
PlaySound("gsCharacterSelectionEnterWorld");
|
PlaySound("gsCharacterSelectionEnterWorld");
|
||||||
StopGlueAmbience();
|
StopGlueAmbience();
|
||||||
|
-- Persist the server-provided game-mode bit across the GlueXML -> FrameXML
|
||||||
|
-- Lua-state transition. WarcraftXL owns the value for this Wow.exe process.
|
||||||
|
if ( type(MoonWellSetLoginCharacterFlags) == "function" ) then
|
||||||
|
local info = { GetCharacterInfo(CharacterSelect.selectedIndex) };
|
||||||
|
MoonWellSetLoginCharacterFlags(info[11] or 0);
|
||||||
|
end
|
||||||
EnterWorld();
|
EnterWorld();
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,62 +1,81 @@
|
|||||||
-- ============================================================================
|
-- MoonWell client game-mode integration.
|
||||||
-- MoonWell Client
|
-- WarcraftXL retains the selected character's server-provided charFlags while
|
||||||
-- Server integration: game modes, traitor faction display
|
-- WoW replaces the GlueXML Lua state with the in-world FrameXML state.
|
||||||
-- ============================================================================
|
|
||||||
|
|
||||||
-- Global flag read by FrameXML files to decide which faction icon to show.
|
|
||||||
-- true = show opposite faction icon (traitor)
|
|
||||||
-- false = show real faction icon (normal)
|
|
||||||
MoonWell_IsTraitor = false
|
MoonWell_IsTraitor = false
|
||||||
|
|
||||||
-- ============================================================================
|
local function RefreshFactionIcons()
|
||||||
-- AIO handler — called by server on login
|
|
||||||
-- Server: AIO:Handle(player, "MoonWellClient", "Init", gameMode)
|
|
||||||
-- gameMode: 0 = normal, 1 = traitor
|
|
||||||
-- ============================================================================
|
|
||||||
|
|
||||||
if not AIO then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local Handler = AIO.AddHandlers("MoonWellClient", {})
|
|
||||||
|
|
||||||
local function MoonWell_RefreshFactionIcons()
|
|
||||||
-- Portrait PvP icon
|
|
||||||
if PlayerFrame_UpdatePvPStatus then
|
if PlayerFrame_UpdatePvPStatus then
|
||||||
PlayerFrame_UpdatePvPStatus()
|
PlayerFrame_UpdatePvPStatus()
|
||||||
end
|
end
|
||||||
-- DragonUI PvP micro button: SetupPVPButton() runs on load before AIO responds,
|
|
||||||
-- so we refresh its DragonUIPVPIcon texture directly after Init.
|
if PVPFrame and PVPFrame:IsShown() and PVPFrame_Update then
|
||||||
|
PVPFrame_Update()
|
||||||
|
end
|
||||||
|
if BattlefieldFrame and BattlefieldFrame:IsShown() and BattlefieldFrame_Update then
|
||||||
|
BattlefieldFrame_Update()
|
||||||
|
end
|
||||||
|
|
||||||
if PVPMicroButton and PVPMicroButton.DragonUIPVPIcon then
|
if PVPMicroButton and PVPMicroButton.DragonUIPVPIcon then
|
||||||
local factionGroup = UnitFactionGroup("player")
|
local factionGroup = UnitFactionGroup("player")
|
||||||
if factionGroup then
|
if factionGroup then
|
||||||
local displayFaction = MoonWell_IsTraitor
|
local displayFaction = MoonWell_IsTraitor
|
||||||
and (factionGroup == "Alliance" and "Horde" or "Alliance")
|
and (factionGroup == "Alliance" and "Horde" or "Alliance")
|
||||||
or factionGroup
|
or factionGroup
|
||||||
local microTexture = "Interface\\AddOns\\DragonUI\\Textures\\Micromenu\\micropvp"
|
local texture = "Interface\\AddOns\\DragonUI\\Textures\\Micromenu\\micropvp"
|
||||||
local icon = PVPMicroButton.DragonUIPVPIcon
|
local icon = PVPMicroButton.DragonUIPVPIcon
|
||||||
|
local highlight = PVPMicroButton:GetHighlightTexture()
|
||||||
|
|
||||||
if displayFaction == "Alliance" then
|
if displayFaction == "Alliance" then
|
||||||
icon:SetTexture(microTexture)
|
icon:SetTexture(texture)
|
||||||
icon:SetTexCoord(0, 118/256, 0, 151/256)
|
icon:SetTexCoord(0, 118/256, 0, 151/256)
|
||||||
elseif displayFaction == "Horde" then
|
if highlight then
|
||||||
icon:SetTexture(microTexture)
|
highlight:SetTexture(texture)
|
||||||
icon:SetTexCoord(118/256, 236/256, 0, 151/256)
|
highlight:SetTexCoord(0, 118/256, 0, 151/256)
|
||||||
end
|
end
|
||||||
local hl = PVPMicroButton:GetHighlightTexture()
|
|
||||||
if hl then
|
|
||||||
if displayFaction == "Alliance" then
|
|
||||||
hl:SetTexture(microTexture)
|
|
||||||
hl:SetTexCoord(0, 118/256, 0, 151/256)
|
|
||||||
elseif displayFaction == "Horde" then
|
elseif displayFaction == "Horde" then
|
||||||
hl:SetTexture(microTexture)
|
icon:SetTexture(texture)
|
||||||
hl:SetTexCoord(118/256, 236/256, 0, 151/256)
|
icon:SetTexCoord(118/256, 236/256, 0, 151/256)
|
||||||
|
if highlight then
|
||||||
|
highlight:SetTexture(texture)
|
||||||
|
highlight:SetTexCoord(118/256, 236/256, 0, 151/256)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function Handler.Init(_, mode)
|
local function ReadNativeGameMode()
|
||||||
MoonWell_IsTraitor = (tonumber(mode) == 1)
|
if type(MoonWellIsTraitor) ~= "function" then
|
||||||
MoonWell_RefreshFactionIcons()
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
MoonWell_IsTraitor = MoonWellIsTraitor() and true or false
|
||||||
|
RefreshFactionIcons()
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local events = CreateFrame("Frame")
|
||||||
|
events:RegisterEvent("PLAYER_LOGIN")
|
||||||
|
events:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||||
|
events:RegisterEvent("UNIT_FACTION")
|
||||||
|
events:SetScript("OnEvent", function(self, event, unit)
|
||||||
|
if event ~= "UNIT_FACTION" or unit == "player" then
|
||||||
|
ReadNativeGameMode()
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- WarcraftXL may publish its Lua globals shortly after addons are loaded.
|
||||||
|
-- Lua 5.1/WotLK has no C_Timer, so retry cheaply until the native API appears.
|
||||||
|
local elapsedTotal = 0
|
||||||
|
events:SetScript("OnUpdate", function(self, elapsed)
|
||||||
|
elapsedTotal = elapsedTotal + elapsed
|
||||||
|
if elapsedTotal < 0.25 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
elapsedTotal = 0
|
||||||
|
|
||||||
|
if ReadNativeGameMode() then
|
||||||
|
self:SetScript("OnUpdate", nil)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
## Interface: 30300
|
## Interface: 30300
|
||||||
## Title: MoonWell Client
|
## Title: MoonWell Client
|
||||||
## Notes: MoonWell server integration — game modes, traitor faction display
|
## Notes: Native WarcraftXL game-mode and traitor faction display
|
||||||
## Version: 1.0.0
|
## Version: 2.0.0
|
||||||
## Author: MoonWell
|
## Author: MoonWell
|
||||||
## SavedVariables: MoonWellClientDB
|
## SavedVariables: MoonWellClientDB
|
||||||
## Dependencies: AIO_Client
|
|
||||||
## DefaultState: Enabled
|
## DefaultState: Enabled
|
||||||
## X-Hidden: 1
|
## X-Hidden: 1
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user