Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TWW update #91

Merged
merged 12 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
[submodule "lib/TRP-Anim-DB"]
path = lib/TRP-Anim-DB
url = https://github.com/Ellypse/TRP-Anim-DB.git
[submodule "lib/Ellyb"]
path = lib/Ellyb
url = https://github.com/Ellypse/Ellyb
[submodule "lib/CustomTutorials-2.1"]
path = lib/CustomTutorials-2.1
url = https://github.com/Jaliborc/CustomTutorials-2.1.git
14 changes: 13 additions & 1 deletion .luacheckrc
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,17 @@ stds.wow = {
"IsWarModeDesired",
},
},
C_QuestInfoSystem = {
fields = {
"GetQuestRewardSpells",
"GetQuestRewardSpellInfo",
},
},
C_QuestLog = {
fields = {
"GetQuestDetailsTheme",
"IsQuestCalling",
"IsQuestFlaggedCompletedOnAccount",
"QuestHasQuestSessionBonus",
"QuestHasWarModeBonus",
},
Expand All @@ -106,6 +113,7 @@ stds.wow = {
C_Timer = {
fields = {
"After",
"NewTimer"
},
},
CurrencyContainerUtil = {
Expand Down Expand Up @@ -144,6 +152,9 @@ stds.wow = {
Settings = {
fields = {
"OpenToCategory",
"RegisterAddOnCategory",
"RegisterCanvasLayoutCategory",
"RegisterCanvasLayoutSubcategory",
},
},

Expand Down Expand Up @@ -226,7 +237,7 @@ stds.wow = {
"QuestIsFromAreaTrigger",
"QuestModelScene",
"ReloadUI",
"ReputationBarMixin",
"ReputationEntryMixin",
"ResetCursor",
"SelectActiveQuest",
"SelectAvailableQuest",
Expand All @@ -248,6 +259,7 @@ stds.wow = {
"wipe",

-- Global variables
"ACCOUNT_COMPLETED_QUEST_NOTICE",
"BONUS_SKILLPOINTS",
"BONUS_SKILLPOINTS_TOOLTIP",
"ChatTypeInfo",
Expand Down
1 change: 1 addition & 0 deletions PlayerModelMixin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ local MANUALLY_ANIMATED_MODELS = {
4039116, -- Hanu (tuskarr)
4207724, -- Dracthyr Dragon
4198151, -- Tyrande
1721003, -- Kul Tiran male
}

---@class Storyline_PlayerModelMixin : CinematicModel
Expand Down
15 changes: 14 additions & 1 deletion events.lua
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ eventHandlers["QUEST_DETAIL"] = function()

local groupNum = GetSuggestedGroupSize();
if groupNum > 0 then
contentHeight = contentHeight + setObjectiveText(Storyline_NPCFrameObjectivesContent.GroupSuggestion, format(QUEST_SUGGESTED_GROUP_NUM, groupNum), previousText);
contentHeight = contentHeight + setObjectiveText(Storyline_NPCFrameObjectivesContent.GroupSuggestion, format(QUEST_SUGGESTED_GROUP_NUM, groupNum), previousText);
previousText = Storyline_NPCFrameObjectivesContent.GroupSuggestion;
end

Expand All @@ -305,6 +305,15 @@ eventHandlers["QUEST_DETAIL"] = function()
contentHeight = contentHeight + RewardsButtons.displayRewardsOnGrid(bucketType, bucket, Storyline_NPCFrameObjectivesContent, previousText);
end
end
previousText = Storyline_API.rewards.buttons.getPreviousElementOnTheLeft();

local questID = GetQuestID();
local warbandCompleted = C_QuestLog.IsQuestFlaggedCompletedOnAccount(questID);
if warbandCompleted then
contentHeight = contentHeight + setObjectiveText(Storyline_NPCFrameObjectivesContent.WarbandCompleted, ACCOUNT_COMPLETED_QUEST_NOTICE, previousText);
--previousText = Storyline_NPCFrameObjectivesContent.WarbandCompleted;
contentHeight = contentHeight + HOVERED_FRAME_TEXT_MARGIN;
end

-- Add some margin on the bottom
contentHeight = contentHeight + HOVERED_FRAME_TEXT_MARGIN;
Expand Down Expand Up @@ -405,6 +414,7 @@ local function handleEventSpecifics(event, texts, textIndex, eventInfo)
Storyline_NPCFrameObjectives.OK:Hide();
Storyline_NPCFrameObjectivesContent.RequiredItemText:Hide();
Storyline_NPCFrameObjectivesContent.GroupSuggestion:Hide();
Storyline_NPCFrameObjectivesContent.WarbandCompleted:Hide();
Storyline_NPCFrameObjectivesContent.Objectives:SetText('');
Storyline_NPCFrameObjectivesContent.Objectives:Hide();
Storyline_NPCFrameRewards.Content:Hide();
Expand Down Expand Up @@ -527,6 +537,7 @@ local ANIMATIONS = Storyline_API.ANIMATIONS;

-- Sadly this list is not exposed, so we will have to maintain it.
local SPECIAL_GOSSIP_FRAMES = {
-- Torghast
"npe-guide",
"skoldushall",
"mortregar",
Expand All @@ -535,6 +546,8 @@ local SPECIAL_GOSSIP_FRAMES = {
"soulforges",
"theupperreaches",
"twistingcorridors",
-- Delves
"delves-difficulty-picker"
}

function Storyline_API.initEventsStructure()
Expand Down
1 change: 0 additions & 1 deletion lib/Ellyb
Submodule Ellyb deleted from 6e5de6
100 changes: 100 additions & 0 deletions lib/Ellyb/Configuration/Configuration.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
---@type Ellyb
local Ellyb = Ellyb(...);

if Ellyb.Configuration then
return
end

-- Lua imports
local format = format;
local type = type;
local pairs = pairs;

---@class Configuration
local Configuration, _private = Ellyb.Class("Configuration");

local UNKNOWN_CONFIGURATION_KEY = [[Unknown configuration key %s.]];
local CONFIGURATION_KEY_ALREADY_EXISTS = [[Configuration key %s has already been registered.]];

---Constructor
---@param savedVariablesName string @ The saved variable name, used to access the table from _G
function Configuration:initialize(savedVariablesName)
Ellyb.Assertions.isType(savedVariablesName, "string", "savedVariablesName");

_private[self] = {};
_private[self].savedVariablesName = savedVariablesName;
_private[self].configCallbackRegistry = CreateFromMixins(CallbackRegistryBaseMixin);
_private[self].configCallbackRegistry:OnLoad();
_private[self].defaultValues = {};

-- Initialize the saved variables global table if it has never been initialized before
if not _G[savedVariablesName] then
_G[savedVariablesName] = {};
end
end

--- Register a new configuration key with its default value
---@param configurationKey string @ A new configuration key
---@param defaultValue any @ The default value for this new configuration key
function Configuration:RegisterConfigKey(configurationKey, defaultValue)
Ellyb.Assertions.isType(configurationKey, "string", "configurationKey");
assert(not self:IsConfigurationKeyRegistered(configurationKey), format(CONFIGURATION_KEY_ALREADY_EXISTS, configurationKey));

_private[self].defaultValues[configurationKey] = defaultValue;

if self:GetValue(configurationKey) == nil then
self:SetValue(configurationKey, defaultValue);
end
end

---IsConfigurationKeyRegistered
---@param configurationKey string @ A valid configuration key
---@return boolean isRegistered @ True if the configuration has already been registered
function Configuration:IsConfigurationKeyRegistered(configurationKey)
Ellyb.Assertions.isType(configurationKey, "string", "configurationKey");
return _private[self].defaultValues[configurationKey] ~= nil;
end

--- Get the value of a configuration key
---@param configurationKey string @ A valid configuration key, previously registered
function Configuration:GetValue(configurationKey)
return _G[_private[self].savedVariablesName][configurationKey];
end

--- Set the value of a configuration key
---@param configurationKey string @ A valid configuration key that has previously been registered
---@param value any @ The new value for the configuration key
function Configuration:SetValue(configurationKey, value)
Ellyb.Assertions.isType(configurationKey, "string", "configurationKey");
assert(self:IsConfigurationKeyRegistered(configurationKey), format(UNKNOWN_CONFIGURATION_KEY, configurationKey));

local savedVariables = _G[_private[self].savedVariablesName];
if savedVariables[configurationKey] ~= value then
savedVariables[configurationKey] = value;
_private[self].configCallbackRegistry:TriggerEvent(configurationKey, value);
end
end

--- Reset the value of a configuration key to its default value
---@param configurationKey string @ A valid configuration key that has previously been registered
function Configuration:ResetValue(configurationKey)
Ellyb.Assertions.isType(configurationKey, "string", "configurationKey");
assert(self:IsConfigurationKeyRegistered(configurationKey), format(UNKNOWN_CONFIGURATION_KEY, configurationKey));

self:SetValue(configurationKey, _private[self].defaultValues[configurationKey]);
end

---OnChange
---@param key string|string[] @ A configuration key or a list of configuration keys to listen for change
---@param callback function @ A callback that will be called when the value of the given key changes.
function Configuration:OnChange(key, callback)
if type(key) == "table" then
for _, k in pairs(key) do
self:OnChange(k, callback);
end
else
_private[self].configCallbackRegistry:RegisterCallback(key, callback);
end
end

Ellyb.Configuration = Configuration;
96 changes: 96 additions & 0 deletions lib/Ellyb/Documentation/Assertions.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
---@type Ellyb
local Ellyb = Ellyb(...);

-- IDE shortcut to quickly go to related module
local _ = Ellyb.Assertions;

Ellyb.Documentation:AddDocumentationTable("Ellyb.Assertions", {
Name = "Ellyb.Assertions",
Type = "System",
Namespace = "Ellyb.Assertions",

Functions = {
{
Name = "isType",
Type = "Function",
Documentation = { [[Check if a variable is of the expected type ("number", "boolean", "string")
Can also check for Widget type ("Frame", "Button", "Texture")]] },

Arguments = {
{ Name = "variable", Type = "any", Documentation = { "Any kind of variable, to be tested for its type" } },
{ Name = "expectedType", Type = "string", Documentation = { "Expected type of the variable" } },
{ Name = "variableName", Type = "string", Documentation = { "The name of the variable being tested, will be visible in the error message" } },
},
},
{
Name = "isOfTypes",
Type = "Function",
Documentation = { [[Check if a variable is of one of the types expected ("number", "boolean", "string")
Can also check for Widget types ("Frame", "Button", "Texture")]] },

Arguments = {
{ Name = "variable", Type = "any", Documentation = { "Any kind of variable, to be tested for its type" } },
{ Name = "expectedTypes", Type = "table", Documentation = { "A list of expected types for the variable" } },
{ Name = "variableName", Type = "string", Documentation = { "The name of the variable being tested, will be visible in the error message" } },
},
},
{
Name = "isNotNil",
Type = "Function",
Documentation = { [[Check if a variable is not nil]] },

Arguments = {
{ Name = "variable", Type = "any", Documentation = { "Any kind of variable, to be tested for its type" } },
{ Name = "variableName", Type = "string", Documentation = { "The name of the variable being tested, will be visible in the error message" } },
},
},
{
Name = "isNotEmpty",
Type = "Function",
Documentation = { [[Check if a variable is not empty]] },

Arguments = {
{ Name = "variable", Type = "any", Documentation = { "Any kind of variable, to be tested for its type" } },
{ Name = "variableName", Type = "string", Documentation = { "The name of the variable being tested, will be visible in the error message" } },
},

},
{
Name = "isInstanceOf",
Type = "Function",
Documentation = { [[Check if a variable is an instance of a specified class, taking polymorphism into account, so inherited class will pass the test.]] },

Arguments = {
{ Name = "variable", Type = "any", Documentation = { "Any kind of variable, to be tested for its type" } },
{ Name = "class", Type = "string", Documentation = { "A direct reference to the class definition" } },
{ Name = "variableName", Type = "string", Documentation = { "The name of the variable being tested, will be visible in the error message" } },
},

},
{
Name = "isOneOf",
Type = "Function",
Documentation = { [[Check if a variable value is one of the possible values.]] },

Arguments = {
{ Name = "variable", Type = "any", Documentation = { "Any kind of variable, to be tested for its content" } },
{ Name = "possibleValues", Type = "table", Documentation = { "A table of the possible values accepted" } },
{ Name = "variableName", Type = "string", Documentation = { "The name of the variable being tested, will be visible in the error message" } },
},

},
{
Name = "numberIsBetween",
Type = "Function",
Documentation = { [[Check if a variable is a number between a maximum and a minimum.]] },

Arguments = {
{ Name = "variable", Type = "number", Documentation = { "A number to check" } },
{ Name = "minimum", Type = "number", Documentation = { "The minimum value for the number" } },
{ Name = "maximum", Type = "number", Documentation = { "The maximum value for the number" } },
{ Name = "variableName", Type = "string", Documentation = { "The name of the variable being tested, will be visible in the error message" } },
},

},
},
});
57 changes: 57 additions & 0 deletions lib/Ellyb/Documentation/DeprecationWarnings.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---@type Ellyb
local Ellyb = Ellyb(...);

-- IDE shortcut to go to module
local _ = Ellyb.DeprecationWarnings;

Ellyb.Documentation:AddDocumentationTable("Ellyb.DeprecationWarnings", {
Name = "Ellyb.DeprecationWarnings",
Type = "System",
Namespace = "Ellyb.DeprecationWarnings",

Functions = {
{
Name = "wrapAPI",
Type = "Function",
Documentation = { "Create a new table that will throw deprecation warnings and use a given new API table to map a previous API now deprecated." },

Arguments = {
{ Name = "newAPITable", Type = "table", Nilable = false, Documentation = { "The table for the new API." } },
{ Name = "oldAPIName", Type = "string", Nilable = false, Documentation = { "The name of the deprecated API." } },
{ Name = "newAPIName", Type = "string", Nilable = false, Documentation = { "The name of the new API." } },
{ Name = "oldAPIReference", Type = "table", Nilable = true, Documentation = { "An existing table that should be used to wrap with the new API warnings." } },
},

Returns =
{
{ Name = "wrappedAPI", Type = "table", Nilable = false, Documentation = { "This table can be used to access the new API while throwing deprecation warnings." } },
},
},
{
Name = "wrapFunction",
Type = "Function",
Documentation = { "Create a new function that will throw deprecation warnings and use a given new function to map a previous API functions now deprecated." },

Arguments = {
{ Name = "newFunction", Type = "function", Nilable = false, Documentation = { "The new function that should be called instead of the deprecated one." } },
{ Name = "oldFunctionName", Type = "string", Nilable = false, Documentation = { "The name of the deprecated function." } },
{ Name = "newFunctionName", Type = "string", Nilable = false, Documentation = { "The name of the new function." } },
},

Returns =
{
{ Name = "wrappedFunction", Type = "function", Nilable = false, Documentation = { "Calling this function will call the new function and throw a deprecation warning." } },
},
},
{
Name = "warn",
Type = "Function",
Documentation = { "Send a custom deprecation warning." },

Arguments = {
{ Name = "customWarning", Type = "string", Nilable = false, Documentation = { "A custom message to display as a warning." } },

},
},
},
})
Loading
Loading