Skip to content

Commit

Permalink
Fixed Icons bugging after theme switched
Browse files Browse the repository at this point in the history
  • Loading branch information
iamEvanYT committed Nov 28, 2023
1 parent 8c3cf89 commit 7d2329e
Show file tree
Hide file tree
Showing 4 changed files with 172 additions and 111 deletions.
4 changes: 2 additions & 2 deletions src/Icon/IconController.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ local function checkTopbarEnabled()
return starterGui:GetCore("TopbarEnabled")
end,function(err)
--has not been registered yet, but default is that is enabled
return true
return true
end)
return (success and bool)
end
Expand Down Expand Up @@ -1094,7 +1094,7 @@ coroutine.wrap(function()
-- Required attrbute for using TopbarPlus
-- This is not printed within stuido and to the game owner to prevent mixing with debug prints
local gameName = placeInfo.Name
print(("\n\n\n⚽ %s uses TopbarPlus %s\n🍍 TopbarPlus was developed by ForeverHD and the Nanoblox Team\n🚀 You can learn more and take a free copy by searching for 'TopbarPlus' on the DevForum\n\n"):format(gameName, version))
print(("\n\n\n⚽ %s uses TopbarPlus-Forked %s\n🍍 TopbarPlus-Forked was originally developed by ForeverHD and the Nanoblox Team, forked by iamEvanRBLX.\n🚀 You can learn more and take a free copy by searching for 'TopbarPlus' on the DevForum\n\n"):format(gameName, version))
end
end
end
Expand Down
198 changes: 99 additions & 99 deletions src/Icon/Themes/Old_RobloxTopbar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,105 +21,105 @@ local newIcon = Icon.new()
--]]

return {

-- Settings which describe how an item behaves or transitions between states
action = {
toggleTransitionInfo = TweenInfo.new(0.15, Enum.EasingStyle.Quad, Enum.EasingDirection.Out),
resizeInfo = TweenInfo.new(0.15, Enum.EasingStyle.Quad, Enum.EasingDirection.Out),
repositionInfo = TweenInfo.new(0.15, Enum.EasingStyle.Quad, Enum.EasingDirection.Out),
captionFadeInfo = TweenInfo.new(0.1, Enum.EasingStyle.Quad, Enum.EasingDirection.Out),
tipFadeInfo = TweenInfo.new(0.1, Enum.EasingStyle.Quad, Enum.EasingDirection.Out),
dropdownSlideInfo = TweenInfo.new(0.15, Enum.EasingStyle.Quad, Enum.EasingDirection.Out),
menuSlideInfo = TweenInfo.new(0.15, Enum.EasingStyle.Quad, Enum.EasingDirection.Out),
},

-- Settings which describe how an item appears when 'deselected' and 'selected'
toggleable = {
-- How items appear normally (i.e. when they're 'deselected')
deselected = {
iconBackgroundColor = Color3.fromRGB(0, 0, 0),
iconBackgroundTransparency = 0.5,
iconCornerRadius = UDim.new(0.25, 0),
iconGradientColor = ColorSequence.new(Color3.fromRGB(255, 255, 255)),
iconGradientRotation = 0,
iconImage = "",
iconImageColor =Color3.fromRGB(255, 255, 255),
iconImageTransparency = 0,
iconImageYScale = 0.63,
iconImageRatio = 1,
iconLabelYScale = 0.45,
iconScale = UDim2.new(1, 0, 1, 0),
forcedIconSizeX = 32;
forcedIconSizeY = 32;
iconSize = UDim2.new(0, 32, 0, 32),
iconOffset = UDim2.new(0, 0, 0, 0),
iconText = "",
iconTextColor = Color3.fromRGB(255, 255, 255),
iconFont = Enum.Font.GothamSemibold,
noticeCircleColor = Color3.fromRGB(255, 255, 255),
noticeCircleImage = "http://www.roblox.com/asset/?id=4871790969",
noticeTextColor = Color3.fromRGB(31, 33, 35),
baseZIndex = 1,
order = 1,
alignment = "left",
clickSoundId = "rbxassetid://5273899897",
clickVolume = 0,
clickPlaybackSpeed = 1,
clickTimePosition = 0.12
},
-- How items appear after the icon has been clicked (i.e. when they're 'selected')
-- If a selected value is not specified, it will default to the deselected value
selected = {
iconBackgroundColor = Color3.fromRGB(245, 245, 245),
iconBackgroundTransparency = 0.1,
iconImageColor = Color3.fromRGB(57, 60, 65),
iconTextColor = Color3.fromRGB(57, 60, 65),
clickPlaybackSpeed = 1.5,
}
},
-- Settings which describe how an item behaves or transitions between states
action = {
toggleTransitionInfo = TweenInfo.new(0.15, Enum.EasingStyle.Quad, Enum.EasingDirection.Out),
resizeInfo = TweenInfo.new(0.15, Enum.EasingStyle.Quad, Enum.EasingDirection.Out),
repositionInfo = TweenInfo.new(0.15, Enum.EasingStyle.Quad, Enum.EasingDirection.Out),
captionFadeInfo = TweenInfo.new(0.1, Enum.EasingStyle.Quad, Enum.EasingDirection.Out),
tipFadeInfo = TweenInfo.new(0.1, Enum.EasingStyle.Quad, Enum.EasingDirection.Out),
dropdownSlideInfo = TweenInfo.new(0.15, Enum.EasingStyle.Quad, Enum.EasingDirection.Out),
menuSlideInfo = TweenInfo.new(0.15, Enum.EasingStyle.Quad, Enum.EasingDirection.Out),
},

-- Settings which describe how an item appears when 'deselected' and 'selected'
toggleable = {
-- How items appear normally (i.e. when they're 'deselected')
deselected = {
iconBackgroundColor = Color3.fromRGB(0, 0, 0),
iconBackgroundTransparency = 0.5,
iconCornerRadius = UDim.new(0.25, 0),
iconGradientColor = ColorSequence.new(Color3.fromRGB(255, 255, 255)),
iconGradientRotation = 0,
iconImage = "",
iconImageColor =Color3.fromRGB(255, 255, 255),
iconImageTransparency = 0,
iconImageYScale = 0.63,
iconImageRatio = 1,
iconLabelYScale = 0.45,
iconScale = UDim2.new(1, 0, 1, 0),
forcedIconSizeX = 32;
forcedIconSizeY = 32;
iconSize = UDim2.new(0, 32, 0, 32),
iconOffset = UDim2.new(0, 0, 0, 0),
iconText = "",
iconTextColor = Color3.fromRGB(255, 255, 255),
iconFont = Enum.Font.GothamSemibold,
noticeCircleColor = Color3.fromRGB(255, 255, 255),
noticeCircleImage = "http://www.roblox.com/asset/?id=4871790969",
noticeTextColor = Color3.fromRGB(31, 33, 35),
baseZIndex = 1,
order = 1,
alignment = "left",
clickSoundId = "rbxassetid://5273899897",
clickVolume = 0,
clickPlaybackSpeed = 1,
clickTimePosition = 0.12
},
-- How items appear after the icon has been clicked (i.e. when they're 'selected')
-- If a selected value is not specified, it will default to the deselected value
selected = {
iconBackgroundColor = Color3.fromRGB(245, 245, 245),
iconBackgroundTransparency = 0.1,
iconImageColor = Color3.fromRGB(57, 60, 65),
iconTextColor = Color3.fromRGB(57, 60, 65),
clickPlaybackSpeed = 1.5,
}
},

-- Settings where toggleState doesn't matter (they have a singular state)
other = {
-- Caption settings
captionBackgroundColor = Color3.fromRGB(0, 0, 0),
captionBackgroundTransparency = 0.5,
captionTextColor = Color3.fromRGB(255, 255, 255),
captionTextTransparency = 0,
captionFont = Enum.Font.GothamSemibold,
captionOverlineColor = Color3.fromRGB(0, 170, 255),
captionOverlineTransparency = 0,
captionCornerRadius = UDim.new(0.25, 0),
-- Tip settings
tipBackgroundColor = Color3.fromRGB(255, 255, 255),
tipBackgroundTransparency = 0.1,
tipTextColor = Color3.fromRGB(27, 42, 53),
tipTextTransparency = 0,
tipFont = Enum.Font.GothamSemibold,
tipCornerRadius = UDim.new(0.175, 0),
-- Dropdown settings
dropdownAlignment = "auto", -- 'left', 'mid', 'right' or 'auto' (auto is where the dropdown alignment matches the icons alignment)
dropdownMaxIconsBeforeScroll = 3,
dropdownMinWidth = 32,
dropdownSquareCorners = false,
dropdownBindToggleToIcon = true,
dropdownToggleOnLongPress = false,
dropdownToggleOnRightClick = false,
dropdownCloseOnTapAway = false,
dropdownHidePlayerlistOnOverlap = true,
dropdownListPadding = UDim.new(0, 2),
dropdownScrollBarColor = Color3.fromRGB(25, 25, 25),
dropdownScrollBarTransparency = 0.2,
dropdownScrollBarThickness = 4,
-- Menu settings
menuDirection = "auto", -- 'left', 'right' or 'auto' (for auto, if alignment is 'left' or 'mid', menuDirection will be 'right', else menuDirection is 'left')
menuMaxIconsBeforeScroll = 4,
menuBindToggleToIcon = true,
menuToggleOnLongPress = false,
menuToggleOnRightClick = false,
menuCloseOnTapAway = false,
menuScrollBarColor = Color3.fromRGB(25, 25, 25),
menuScrollBarTransparency = 0.2,
menuScrollBarThickness = 4,
},

-- Settings where toggleState doesn't matter (they have a singular state)
other = {
-- Caption settings
captionBackgroundColor = Color3.fromRGB(0, 0, 0),
captionBackgroundTransparency = 0.5,
captionTextColor = Color3.fromRGB(255, 255, 255),
captionTextTransparency = 0,
captionFont = Enum.Font.GothamSemibold,
captionOverlineColor = Color3.fromRGB(0, 170, 255),
captionOverlineTransparency = 0,
captionCornerRadius = UDim.new(0.25, 0),
-- Tip settings
tipBackgroundColor = Color3.fromRGB(255, 255, 255),
tipBackgroundTransparency = 0.1,
tipTextColor = Color3.fromRGB(27, 42, 53),
tipTextTransparency = 0,
tipFont = Enum.Font.GothamSemibold,
tipCornerRadius = UDim.new(0.175, 0),
-- Dropdown settings
dropdownAlignment = "auto", -- 'left', 'mid', 'right' or 'auto' (auto is where the dropdown alignment matches the icons alignment)
dropdownMaxIconsBeforeScroll = 3,
dropdownMinWidth = 32,
dropdownSquareCorners = false,
dropdownBindToggleToIcon = true,
dropdownToggleOnLongPress = false,
dropdownToggleOnRightClick = false,
dropdownCloseOnTapAway = false,
dropdownHidePlayerlistOnOverlap = true,
dropdownListPadding = UDim.new(0, 2),
dropdownScrollBarColor = Color3.fromRGB(25, 25, 25),
dropdownScrollBarTransparency = 0.2,
dropdownScrollBarThickness = 4,
-- Menu settings
menuDirection = "auto", -- 'left', 'right' or 'auto' (for auto, if alignment is 'left' or 'mid', menuDirection will be 'right', else menuDirection is 'left')
menuMaxIconsBeforeScroll = 4,
menuBindToggleToIcon = true,
menuToggleOnLongPress = false,
menuToggleOnRightClick = false,
menuCloseOnTapAway = false,
menuScrollBarColor = Color3.fromRGB(25, 25, 25),
menuScrollBarTransparency = 0.2,
menuScrollBarThickness = 4,
},

}
2 changes: 1 addition & 1 deletion src/Icon/VERSION.lua
Original file line number Diff line number Diff line change
@@ -1 +1 @@
return "v2.9.1"
return "v2.9.2"
79 changes: 70 additions & 9 deletions src/Icon/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,19 @@ local DEFAULT_FORCED_GROUP_VALUES = {}
local defaultThemeChanged = Signal.new()
local function topbarInsetChanged()
local topbarInset = guiService.TopbarInset
if topbarInset.Height == 0 then
return
end
local newDefaultTheme = nil
if topbarInset.Height > 36 then
if (topbarInset.Height > 36) then
newDefaultTheme = Themes["New_RobloxTopbar"]
else
newDefaultTheme = Themes["Old_RobloxTopbar"]
end
if newDefaultTheme ~= nil and DEFAULT_THEME ~= newDefaultTheme then
local oldDefaultTheme = DEFAULT_THEME
DEFAULT_THEME = newDefaultTheme
defaultThemeChanged:Fire()
defaultThemeChanged:Fire(oldDefaultTheme,newDefaultTheme)
end
end
pcall(topbarInsetChanged)
Expand Down Expand Up @@ -436,8 +440,11 @@ function Icon.new()
-- Apply start values
self:setName("UnnamedIcon")
self:setTheme(DEFAULT_THEME, true, true)
maid:give(defaultThemeChanged:Connect(function()
self:setTheme(DEFAULT_THEME, true, true)
maid:give(defaultThemeChanged:Connect(function(oldDefaultTheme,newDefaultTheme)
if oldDefaultTheme == newDefaultTheme then
return
end
self:setTheme(newDefaultTheme, true, true, oldDefaultTheme)
end))

local function iconTopbarInsetChanged()
Expand Down Expand Up @@ -930,6 +937,7 @@ function Icon:_updateAll(iconState, customTweenInfo)
-- It's important we adapt the size of anything that could be changed through Localization
-- In this case, the icon label, caption and tip
self:_updateIconSize()

self:_updateCaptionSize()
self:_updateTipSize()
end
Expand All @@ -948,23 +956,63 @@ function Icon:_updateStateOverlay(transparency, color)
stateOverlay.BackgroundColor3 = color or Color3.new(1, 1, 1)
end

function Icon:setTheme(theme, updateAfterSettingAll, isDefault)
local oldThemeBlacklistedSetings = {
"iconSize",
}

function Icon:setTheme(theme, updateAfterSettingAll, isDefault, oldTheme)
self._updateAfterSettingAll = updateAfterSettingAll
for settingsType, settingsDetails in pairs(theme) do
if settingsType == "toggleable" then
for settingName, settingValue in pairs(settingsDetails.deselected) do
if not self.lockedSettings[settingName] then
self:set(settingName, settingValue, "both")
local changedFromOldTheme = false
if oldTheme and table.find(oldThemeBlacklistedSetings,settingName) == nil then
-- Might not be found & will error
pcall(function()
local oldVal = self:get(settingName,"deselected")
if oldVal ~= oldTheme[settingsType]["deselected"][settingName] then
changedFromOldTheme = true
end
end)
end
if not self.lockedSettings[settingName] and changedFromOldTheme == false then
local iconStateToSet = "both"
pcall(function()
if settingsDetails["selected"][settingName] then
iconStateToSet = "deselected"
end
end)
self:set(settingName, settingValue, iconStateToSet)
end
end
for settingName, settingValue in pairs(settingsDetails.selected) do
if not self.lockedSettings[settingName] then
local changedFromOldTheme = false
if oldTheme and table.find(oldThemeBlacklistedSetings,settingName) == nil then
-- Might not be found & will error
pcall(function()
local oldVal = self:get(settingName,"selected")
if oldVal ~= oldTheme[settingsType]["selected"][settingName] then
changedFromOldTheme = true
end
end)
end
if not self.lockedSettings[settingName] and changedFromOldTheme == false then
self:set(settingName, settingValue, "selected")
end
end
else
for settingName, settingValue in pairs(settingsDetails) do
if not self.lockedSettings[settingName] then
local changedFromOldTheme = false
if oldTheme and table.find(oldThemeBlacklistedSetings,settingName) == nil then
-- Might not be found & will error
pcall(function()
local oldVal = self:get(settingName)
if oldVal ~= oldTheme[settingsType][settingName] then
changedFromOldTheme = true
end
end)
end
if not self.lockedSettings[settingName] and changedFromOldTheme == false then
local settingDetail = self._settingsDictionary[settingName]
if settingsType == "action" and settingDetail == nil then
settingDetail = {}
Expand All @@ -981,6 +1029,7 @@ function Icon:setTheme(theme, updateAfterSettingAll, isDefault)
end
if updateAfterSettingAll then
self:_updateAll()
self:_updateIconSize(nil,"hovering")
end
return self
end
Expand Down Expand Up @@ -1356,6 +1405,18 @@ function Icon:_updateIconSize(_, iconState)
iconImageRatio = self:get("iconImageRatio", iconState) or "_NIL",
iconLabelYScale = self:get("iconLabelYScale", iconState) or "_NIL",
}
if iconState == "hovering" and self._usingDefaultTheme then
values = {
iconImage = self:get("iconImage", iconState) or "_NIL",
iconText = self:get("iconText", iconState) or "_NIL",
iconFont = self:get("iconFont", iconState) or "_NIL",
iconSize = self:get("iconSize", nil) or "_NIL",
forcedIconSizeX = self:get("forcedIconSizeX", nil) or "_NIL",
iconImageYScale = self:get("iconImageYScale", nil) or "_NIL",
iconImageRatio = self:get("iconImageRatio", nil) or "_NIL",
iconLabelYScale = self:get("iconLabelYScale", nil) or "_NIL",
}
end
for k,v in pairs(values) do
if v == "_NIL" then
return
Expand Down

0 comments on commit 7d2329e

Please sign in to comment.