140 lines
8.2 KiB
Lua
140 lines
8.2 KiB
Lua
-- Source chooser text/order from current Octo GlueStrings/ChallengeList.
|
|
-- Source creation choices 1..12; plain Hardcore bit zero is realm-owned.
|
|
local rows = {
|
|
{ mask = 2, name = "Slow & Steady", description = "Gaining 50% fewer experience points from defeating enemies. Lose 5% of accumulated experience from current level upon being defeated by enemies." },
|
|
{ mask = 4, name = "War Mode", description = "PvP is enabled. You may disable it at any time, but doing so permanently removes War Mode for this character. While active: experience gain from all sources is increased by 15%, and killing players in the open world grants experience." },
|
|
{ mask = 8, name = "Vagrant's Endeavor", description = "You can only use poor and common quality equipment. Enchanting items is not allowed." },
|
|
{ mask = 16, name = "Traveling Craftmaster", description = "Equip only what you craft. True power comes from your own hands!" },
|
|
{ mask = 32, name = "Level One Lunatic", description = "During this challenge, you will earn exclusive titles while staying at level one." },
|
|
{ mask = 64, name = "Boaring Adventure", description = "In this challenge, leveling up is a real pig deal. Experience comes exclusively from slaying boars!" },
|
|
{ mask = 512, name = "Trial of Heroism", description = "Achieve level 58 by earning experience strictly from orange and red-tier monsters and quests." },
|
|
{ mask = 256, name = "Path of the Brewmaster", description = "From bar to the Barrens, your journey begins! You gain no experience unless you're completely smashed. For every ding, have a drink!" },
|
|
{ mask = 128, name = "Exhaustion", description = "No longer gaining rested experience, but your weapon skill gain will be doubled." },
|
|
{ mask = 1024, name = "Way of the Samurai", description = "You may only wield katana-style swords. No other weapon (bows, guns, etc.) may be equipped. Available only to Warriors, Paladins, Hunters, and Rogues." },
|
|
{ mask = 2048, name = "Together Forever", description = "Bind your fate to up to four companions at level 1. You gain experience from kills only while your entire fellowship is with you. The bond is permanent." },
|
|
{ mask = 4096, name = "True Hardcore", description = "Lock this character to the Hardcore Realm. Allows the selection of names that are reserved on the other realms." },
|
|
};
|
|
local selected = {};
|
|
local panel;
|
|
local function api(query, value, field)
|
|
if not C_Login or type(C_Login.GetTurtleRealmSnapshot) ~= "function" then return nil; end
|
|
local ok, result = pcall(C_Login.GetTurtleRealmSnapshot, query, value or 0, field or 0);
|
|
return ok and result or nil;
|
|
end
|
|
local function samuraiAllowed()
|
|
local class = C_CharacterCreation and C_CharacterCreation.GetSelectedClass and C_CharacterCreation.GetSelectedClass();
|
|
if type(class) == "table" then class = class.classID; end
|
|
return class == 1 or class == 2 or class == 3 or class == 4;
|
|
end
|
|
local function hardcoreRealm()
|
|
if api(0, 0) ~= 0 then return false; end
|
|
local index = api(0, 11);
|
|
if type(index) ~= "number" or index < 0 then return false; end
|
|
local realmType = api(1, index, 0);
|
|
return realmType == 6 or realmType == 8; -- Source RP / RP-PvP, matching Octo isRP.
|
|
end
|
|
local function sanitize()
|
|
if not samuraiAllowed() then selected[10] = nil; end
|
|
if not hardcoreRealm() then selected[12] = nil; end
|
|
if selected[11] then selected[5] = nil; end
|
|
end
|
|
local function allowed(index)
|
|
if index == 10 then return samuraiAllowed(); end
|
|
if index == 12 then return hardcoreRealm(); end
|
|
if index == 5 then return not selected[11]; end
|
|
if index == 11 then return not selected[5]; end
|
|
return true;
|
|
end
|
|
local function refresh()
|
|
sanitize();
|
|
if panel then
|
|
for i, button in ipairs(panel.choices) do
|
|
button:SetChecked(selected[i] and true or false);
|
|
button:SetShown(i ~= 12 or hardcoreRealm());
|
|
local available = allowed(i);
|
|
button.label:SetTextColor(available and 1 or 0.55, available and 1 or 0.55, available and 1 or 0.55);
|
|
end
|
|
end
|
|
end
|
|
local function mask()
|
|
sanitize();
|
|
local value = 0;
|
|
for i = 1, 12 do if selected[i] then value = value + rows[i].mask; end end
|
|
return value;
|
|
end
|
|
function GW_SourceChallengeReset()
|
|
selected = {};
|
|
api(22, 0);
|
|
if panel then for _, button in ipairs(panel.choices) do button:SetChecked(false); end end
|
|
end
|
|
function GW_SourceChallengeStage()
|
|
local value = mask();
|
|
-- Called after begin/options, immediately before the immutable request is staged.
|
|
return api(22, value) == value;
|
|
end
|
|
local function showDescription(button)
|
|
local row = rows[button.index];
|
|
local text = row.description;
|
|
if button.index == 10 then text = text .. "\nWarriors, Paladins, Hunters, and Rogues only."; end
|
|
if button.index == 11 then text = text .. "\nMutually exclusive with " .. rows[5].name .. "."; end
|
|
if button.index == 12 then text = text .. "\nHardcore realms only."; end
|
|
panel.description:SetText(text);
|
|
end
|
|
function GW_SourceChallengeAttach(frame, enabled)
|
|
if panel then panel.toggle:SetShown(enabled and not frame.paidServiceType); return; end
|
|
panel = CreateFrame("Frame", nil, frame, "BackdropTemplate");
|
|
-- Own the clicks and wheel over the panel: the customization controls under it must not react.
|
|
panel:SetFrameStrata("DIALOG"); panel:SetToplevel(true); panel:EnableMouse(true); panel:EnableMouseWheel(true);
|
|
local toggle = CreateFrame("Button", nil, frame, "UIPanelButtonTemplate");
|
|
toggle:SetSize(150, 25); toggle:SetPoint("TOPRIGHT", frame, "TOPRIGHT", -50, -55);
|
|
panel.toggle = toggle;
|
|
toggle:SetText("Challenges");
|
|
toggle:SetShown(enabled and not frame.paidServiceType);
|
|
toggle:SetScript("OnClick", function() panel:SetShown(not panel:IsShown()); end);
|
|
local close = CreateFrame("Button", nil, panel, "UIPanelCloseButton");
|
|
close:SetPoint("TOPRIGHT", -2, -2);
|
|
close:SetScript("OnClick", function() panel:Hide(); end);
|
|
panel:Hide();
|
|
panel:SetSize(330, 485);
|
|
panel:SetPoint("TOPRIGHT", frame, "TOPRIGHT", -28, -90);
|
|
panel:SetFrameStrata("DIALOG");
|
|
panel:SetBackdrop({bgFile="Interface/Tooltips/UI-Tooltip-Background", edgeFile="Interface/Tooltips/UI-Tooltip-Border", tile=true, tileSize=16, edgeSize=16, insets={left=4,right=4,top=4,bottom=4}});
|
|
panel:SetBackdropColor(0, 0, 0, 0.92);
|
|
local title = panel:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge");
|
|
title:SetPoint("TOP", 0, -14); title:SetText("Challenges");
|
|
panel.choices = {};
|
|
for i, row in ipairs(rows) do
|
|
local button = CreateFrame("CheckButton", nil, panel, "UICheckButtonTemplate");
|
|
button.index = i;
|
|
button:SetPoint("TOPLEFT", 12, -38 - (i-1)*25);
|
|
button:SetSize(24, 24);
|
|
local label = button:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall");
|
|
label:SetPoint("LEFT", button, "RIGHT", 3, 0); label:SetText(row.name);
|
|
button.label = label;
|
|
button:SetScript("OnClick", function(self)
|
|
local available = api(23, 0);
|
|
if not allowed(self.index) or type(available) ~= "number" or available < 0 then self:SetChecked(false); return; end
|
|
selected[self.index] = self:GetChecked() and true or nil;
|
|
refresh();
|
|
showDescription(self);
|
|
end);
|
|
button:SetScript("OnEnter", showDescription);
|
|
panel.choices[i] = button;
|
|
end
|
|
panel.description = panel:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall");
|
|
panel.description:SetPoint("TOPLEFT", 16, -350); panel.description:SetWidth(298);
|
|
panel.description:SetJustifyH("LEFT");
|
|
panel.description:SetText("Choose optional challenges before creating your character. Hover over a challenge for details.");
|
|
panel:SetScript("OnShow", refresh);
|
|
panel:SetScript("OnUpdate", function(self, elapsed)
|
|
self.refreshElapsed = (self.refreshElapsed or 0) + elapsed;
|
|
if self.refreshElapsed >= 0.25 then self.refreshElapsed = 0; refresh(); end
|
|
end);
|
|
refresh();
|
|
frame:HookScript("OnHide", function() GW_SourceChallengeReset(); panel:Hide(); end);
|
|
frame:HookScript("OnShow", function()
|
|
GW_SourceChallengeReset(); panel:Hide();
|
|
end);
|
|
if frame.BackButton then frame.BackButton:HookScript("OnClick", GW_SourceChallengeReset); end
|
|
end
|