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

Disable About/Ignored tabs when no data in them #1002

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
19 changes: 17 additions & 2 deletions totalRP3/Modules/Register/Characters/RegisterMain.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ local showCharacteristicsTab, showAboutTab, showMiscTab, showNotesTab;
local get = TRP3_API.profile.getData;
local showTextInputPopup = TRP3_API.popup.showTextInputPopup;
local toast = TRP3_API.ui.tooltip.toast;
local tsize = Utils.table.size;

-- Saved variables references
local profiles, characters;
Expand Down Expand Up @@ -546,10 +547,26 @@ local function showDefaultTab()
TRP3_Addon:TriggerEvent(TRP3_Addon.Events.NAVIGATION_TUTORIAL_REFRESH, "player_main");
end

local function getAboutDataExists(profile)
if profile and profile.about then
if profile.about.MU then
return true;
elseif profile.about.T1 and profile.about.T1.TX then
return true;
elseif profile.about.T2 and tsize(profile.about.T2) ~= 0 then
return true;
elseif profile.about.T3 and (profile.about.T3.PH.TX or profile.about.T3.PS.TX or profile.about.T3.HI.TX) then
return true;
end
end
return false;
end

local function showTabs()
local context = getCurrentContext();
assert(context, "No context for page player_main !");
if not context.isPlayer or getPlayerCurrentProfileID() ~= getConfigValue("default_profile_id") then
tabGroup.tabs[2]:SetTabLocked(not getAboutDataExists(context.profile));
tabGroup:SetAllTabsVisible(true);
tabGroup:SelectTab(1);
else
Expand All @@ -572,8 +589,6 @@ end
-- CLEANUP
--*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

local tsize = Utils.table.size;

-- Unbound character from missing profiles
local function cleanupCharacters()
for unitID, character in pairs(characters) do
Expand Down
7 changes: 5 additions & 2 deletions totalRP3/Modules/Register/Main/RegisterList.lua
Original file line number Diff line number Diff line change
Expand Up @@ -749,11 +749,16 @@ end
-- UI : LIST
--*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

local tabGroup;

function refreshList()
local lines;
TRP3_RegisterListEmpty:Hide();
TRP3_RegisterListHeaderActions:Hide();

-- Disable ignored tab when no character ignored
tabGroup.tabs[3]:SetTabLocked(tsize(getIgnoredList()) == 0);

if currentMode == MODE_CHARACTER then
lines = getCharacterLines();
TRP3_RegisterList.decorate = decorateCharacterLine;
Expand Down Expand Up @@ -837,8 +842,6 @@ end
-- Init
--*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

local tabGroup;

local function createTabBar()
local frame = CreateFrame("Frame", "TRP3_RegisterMainTabBar", TRP3_RegisterList);
frame:SetSize(400, 30);
Expand Down
12 changes: 11 additions & 1 deletion totalRP3/UI/TabSystem.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ function TRP3_TabButtonMixin:SetTabSelected(selected)
self:MarkDirty();
end

function TRP3_TabButtonMixin:IsTabLocked()
return GetValueOrCallFunction(self, "locked");
end

function TRP3_TabButtonMixin:SetTabLocked(locked)
self.locked = locked;
self:MarkDirty();
end

function TRP3_TabButtonMixin:MarkDirty()
self:SetScript("OnUpdate", self.Update);
end
Expand All @@ -45,8 +54,9 @@ end

function TRP3_TabButtonMixin:Update()
local selected = self:IsTabSelected();
local locked = self:IsTabLocked();

self:SetEnabled(not selected);
self:SetEnabled(not selected and not locked);
self.Left:SetShown(not selected);
self.Middle:SetShown(not selected);
self.Right:SetShown(not selected);
Expand Down
1 change: 1 addition & 0 deletions totalRP3/UI/TabSystem.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ https://raw.githubusercontent.com/Meorawr/wow-ui-schema/main/UI.xsd">
<Button name="TRP3_TabButtonTemplate" mixin="TRP3_TabButtonMixin" motionScriptsWhileDisabled="true" virtual="true">
<KeyValues>
<KeyValue key="selected" value="false" type="boolean"/>
<KeyValue key="locked" value="false" type="boolean"/>
<KeyValue key="selectedFontObject" value="GameFontHighlightSmall" type="global"/>
<KeyValue key="unselectedFontObject" value="GameFontNormalSmall" type="global"/>
</KeyValues>
Expand Down
Loading