mirror of
https://github.com/araxiaonline/ets-module-collection.git
synced 2026-06-13 02:52:20 -04:00
Added more changes to mythicplus.client and server
This commit is contained in:
@@ -92,8 +92,8 @@ const MPTextures: Record<string, WoWAPI.Texture> = {};
|
||||
const MPFonts: Record<string, WoWAPI.FontString> = {};
|
||||
|
||||
function refreshUIState() {
|
||||
updateInfoText(MythicClientState.selected);
|
||||
updateSkulls(MythicClientState.selected);
|
||||
updateInfoText(MythicClientState.difficulty);
|
||||
updateSkulls(MythicClientState.difficulty);
|
||||
}
|
||||
|
||||
// Updates the skull images based on the selected difficulty passed in
|
||||
@@ -258,7 +258,7 @@ function CreateInfoText(parent: WoWAPI.Frame, difficulty: Difficulty = null): vo
|
||||
// Creates the skull frames UI elements and artwork for the Mythic+ UI panel
|
||||
function CreateSkullFrame(difficulty: Difficulty, title: string, imageIndex: number): void {
|
||||
|
||||
const parent = _G["MythicPlusPanel"];
|
||||
const parent = MythicUIPanel;
|
||||
const MythicFrame = CreateFrame("Frame", `SkullFrame${difficulty}`, parent, null, difficulty);
|
||||
MythicFrame.SetSize(MPanelStyles.skullWidth, MPanelStyles.skullHeight);
|
||||
|
||||
@@ -275,7 +275,7 @@ function CreateSkullFrame(difficulty: Difficulty, title: string, imageIndex: num
|
||||
texture.SetAlpha(1);
|
||||
});
|
||||
MythicFrame.SetScript("OnLeave", function(f: WoWAPI.Frame) {
|
||||
if(MythicClientState.selected == f.GetID()) {
|
||||
if(MythicClientState.difficulty == f.GetID()) {
|
||||
return;
|
||||
}
|
||||
const texture = <WoWAPI.Texture>MPTextures[`SkullImg${difficulty}`];
|
||||
@@ -289,16 +289,16 @@ function CreateSkullFrame(difficulty: Difficulty, title: string, imageIndex: num
|
||||
|
||||
PlaySound("PVPTHROUGHQUEUE");
|
||||
|
||||
if(MythicClientState.selected == f.GetID()) {
|
||||
MythicClientState.selected = 0;
|
||||
SetDungeonDifficulty(2);
|
||||
if(MythicClientState.difficulty == f.GetID()) {
|
||||
MythicClientState.difficulty = GetDungeonDifficultyID() - 1;
|
||||
refreshUIState();
|
||||
} else {
|
||||
MythicClientState.selected = f.GetID();
|
||||
SetDungeonDifficulty(2);
|
||||
MythicClientState.difficulty = f.GetID();
|
||||
// always assume heoric for map setting for scaling under the hood.
|
||||
SetDungeonDifficulty(2);
|
||||
}
|
||||
|
||||
aio.Handle("MythicPlus", "SetDifficulty", MythicClientState.selected);
|
||||
aio.Handle("MythicPlus", "SetDifficulty", MythicClientState.difficulty);
|
||||
refreshUIState();
|
||||
});
|
||||
|
||||
@@ -314,6 +314,7 @@ function CreateSkullFrame(difficulty: Difficulty, title: string, imageIndex: num
|
||||
titleFont.SetText(title);
|
||||
}
|
||||
|
||||
// Main launch pad for the Mythic+ UI panel
|
||||
function ShowUIPanel(): void {
|
||||
|
||||
if(MythicUIPanel) {
|
||||
@@ -341,12 +342,14 @@ function ShowUIPanel(): void {
|
||||
|
||||
MythicUIPanel = mainFrame;
|
||||
|
||||
// This is used to create an all black background for the Mythic+ UI panel
|
||||
const bgTexture = mainFrame.CreateTexture("MythicBGTexture", "OVERLAY");
|
||||
bgTexture.SetAllPoints(mainFrame);
|
||||
bgTexture.SetTexture("Interface\\Buttons\\WHITE8X8")
|
||||
bgTexture.SetVertexColor(0.0, 0.0, 0.0, 0.8);
|
||||
bgTexture.SetSize(MPanelStyles.width,MPanelStyles.height);
|
||||
|
||||
// This creates all the skull selectors for the mythic board.
|
||||
CreateSkullFrame(Difficulty.Mythic, "Mythic +", 0);
|
||||
CreateSkullFrame(Difficulty.Legendary, "Legendary ++", 2);
|
||||
CreateSkullFrame(Difficulty.Ascendant, "Ascendant +++", 4);
|
||||
@@ -371,7 +374,7 @@ mythicPlusHandlers.UpdateState = (state: MythicPlusState) : void => {
|
||||
// Shows the button that opens the Mythic+ UI
|
||||
function ShowUIButton(): void {
|
||||
const button = CreateFrame("Button", "MythicPlusButton", UIParent);
|
||||
button.SetSize(28, 58);
|
||||
button.SetSize(32, 32);
|
||||
button.SetPoint("TOPRIGHT", -25, -225);
|
||||
button.EnableMouse(true);
|
||||
// button.SetBackdrop({
|
||||
@@ -391,23 +394,23 @@ function ShowUIButton(): void {
|
||||
return;
|
||||
}
|
||||
PlaySound("GAMEDIALOGOPEN");
|
||||
mythicPlusHandlers.ShowUI();
|
||||
aio.Handle("MythicPlus", "ShowUI");
|
||||
});
|
||||
|
||||
// const btnBg = button.CreateTexture("MythicPlusButtonBG", "BACKGROUND");
|
||||
// btnBg.SetAllPoints(button);
|
||||
// btnBg.SetTexture("Interface\\Buttons\\WHITE8X8");
|
||||
// btnBg.SetVertexColor(0, 0, 0, 1);
|
||||
const btnBg = button.CreateTexture("MythicPlusButtonBG", "BACKGROUND");
|
||||
btnBg.SetAllPoints(button);
|
||||
btnBg.SetTexture("Interface\\Buttons\\WHITE8X8");
|
||||
btnBg.SetVertexColor(0, 0, 0, 1);
|
||||
|
||||
// const btnTexture = button.CreateTexture("MythicPlusButtonTexture", "ARTWORK");
|
||||
// btnTexture.SetPoint("CENTER", 0, 0);
|
||||
// btnTexture.SetSize(32, 32);
|
||||
// btnTexture.SetTexture(selectImages[0]);
|
||||
|
||||
const btnTexture = button.CreateTexture("MythicPlusButtonTexture", "OVERLAY");
|
||||
btnTexture.SetTexture("Interface\\Buttons\\UI-MicroButton-Socials-Up");
|
||||
const btnTexture = button.CreateTexture("MythicPlusButtonTexture", "ARTWORK");
|
||||
btnTexture.SetPoint("CENTER", 0, 0);
|
||||
btnTexture.SetSize(32, 32);
|
||||
btnTexture.SetTexture(selectImages[0]);
|
||||
|
||||
// const btnTexture = button.CreateTexture("MythicPlusButtonTexture", "OVERLAY");
|
||||
// btnTexture.SetTexture("Interface\\Buttons\\UI-MicroButton-Socials-Up");
|
||||
// btnTexture.SetPoint("CENTER", 0, 0);
|
||||
// btnTexture.SetSize(32, 32);
|
||||
// btnTexture.SetTexture(selectImages[0]);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@ import { Logger } from "../../classes/logger";
|
||||
import type { MythicPlusState } from "./mythicplus.state";
|
||||
|
||||
const logger = new Logger("MythicPlusMod");
|
||||
|
||||
// PlayerGUID -> MythicPlusState
|
||||
const StateStorage: Map<number, MythicPlusState> = new Map();
|
||||
|
||||
// This looks up the current group id for the player -1 indicates no group
|
||||
@@ -57,6 +59,7 @@ function _setDifficulty(player: Player, difficulty: number): void {
|
||||
return;
|
||||
}
|
||||
|
||||
// 0 is the lowest difficulty and 4 is the highest
|
||||
if(difficulty > 4) {
|
||||
logger.error(`Invalid difficulty set: ${difficulty}`);
|
||||
}
|
||||
@@ -74,6 +77,7 @@ function SetDifficulty(this:void, player: Player, difficulty: number): void {
|
||||
aio.Handle(player, 'MythicPlus', 'UpdateState', StateStorage.get(player.GetGUIDLow()));
|
||||
}
|
||||
|
||||
// This is used to
|
||||
function _refreshState(player: Player) {
|
||||
if(player.IsInGroup()) {
|
||||
const groupId = getPlayerGroupId(player);
|
||||
@@ -94,6 +98,7 @@ function GetState(this:void, player: Player): void {
|
||||
aio.Handle(player, 'MythicPlus', 'UpdateState', state);
|
||||
}
|
||||
|
||||
// This is the command to open the mythic plus panel
|
||||
const OpenUI: player_event_on_command = (event: number,player: Player, command: string): boolean => {
|
||||
if(command == 'mythicplus') {
|
||||
const state = StateStorage.get(player.GetGUIDLow());
|
||||
@@ -110,17 +115,54 @@ const OpenUI: player_event_on_command = (event: number,player: Player, command:
|
||||
return true;
|
||||
};
|
||||
|
||||
// This enables the client to fire a request to open the mythic plus panel after updating state
|
||||
function ShowUI(this:void, player: Player): void {
|
||||
_refreshState(player);
|
||||
aio.Handle(player, 'MythicPlus', 'ShowUI', StateStorage.get(player.GetGUIDLow()));
|
||||
}
|
||||
|
||||
RegisterPlayerEvent(PlayerEvents.PLAYER_EVENT_ON_COMMAND, (...args) => OpenUI(...args));
|
||||
|
||||
const MPStartState: player_event_on_login = (_event: number, player: Player): void => {
|
||||
_refreshState(player);
|
||||
aio.Handle(player, 'MythicPlus', 'UpdateState', StateStorage.get(player.GetGUIDLow()));
|
||||
};
|
||||
|
||||
// On login set up the mythic panel mod state for the player
|
||||
RegisterPlayerEvent(PlayerEvents.PLAYER_EVENT_ON_LOGIN, (...args) => MPStartState(...args));
|
||||
|
||||
const MPGroupDisband: group_event_on_disband = (_event: number, group: Group): void => {
|
||||
const members = group.GetMembers();
|
||||
|
||||
for(let i = 0; i < members.length; i++) {
|
||||
_refreshState(members[i]);
|
||||
aio.Handle(members[i], 'MythicPlus', 'UpdateState', StateStorage.get(members[i].GetGUIDLow()));
|
||||
}
|
||||
}
|
||||
|
||||
RegisterGroupEvent(GroupEvents.GROUP_EVENT_ON_DISBAND, (...args) => MPGroupDisband(...args));
|
||||
|
||||
// When a leader change happens need to update the state storage for each leader to enable changes in the panel.
|
||||
const MPLeaderChange: group_event_on_leader_change = (_event: number,group: Group, leader: number, oldLeader: number): void => {
|
||||
_refreshState(GetPlayerByGUID(leader));
|
||||
aio.Handle(GetPlayerByGUID(leader), 'MythicPlus', 'UpdateState', StateStorage.get(leader));
|
||||
|
||||
_refreshState(GetPlayerByGUID(oldLeader));
|
||||
aio.Handle(GetPlayerByGUID(oldLeader), 'MythicPlus', 'UpdateState', StateStorage.get(oldLeader));
|
||||
}
|
||||
|
||||
RegisterGroupEvent(GroupEvents.GROUP_EVENT_ON_LEADER_CHANGE, (...args) => MPLeaderChange(...args));
|
||||
|
||||
|
||||
const DeletePlayerState: player_event_on_logout = (event: number, player: Player) => {
|
||||
StateStorage.delete(player.GetGUIDLow());
|
||||
};
|
||||
|
||||
RegisterPlayerEvent(PlayerEvents.PLAYER_EVENT_ON_LOGOUT, (...args) => DeletePlayerState(...args));
|
||||
|
||||
// API Handlers available to the client
|
||||
const MPHandlers = aio.AddHandlers("MythicPlus", {
|
||||
ShowUI,
|
||||
SetDifficulty,
|
||||
GetState,
|
||||
});
|
||||
11
modules/UI/mythicplus/mythicplus.state.ts
Normal file
11
modules/UI/mythicplus/mythicplus.state.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
|
||||
export type MythicPlusState = {
|
||||
difficulty: number;
|
||||
inGroup: boolean;
|
||||
groupId: number;
|
||||
groupLeader: number;
|
||||
isLeader: boolean;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user