take rand att from folder with rmb, will do similar thing for slots later

This commit is contained in:
Darsu 2023-10-08 04:39:32 +07:00
parent f71e555ccd
commit a00428d835
2 changed files with 32 additions and 1 deletions

View File

@ -736,3 +736,8 @@ L["settings.developer.presets_clear.desc"] = "Clear presets, all icons and defau
L["settings.developer.clear"] = "Clear"
L["settings.developer.print"] = "Print to Console"
L["settings.developer.reload"] = "Reload"
-- october 8
L["customize.hint.randomize"] = "Random folder attachment"

View File

@ -10,6 +10,7 @@ local ARC9ScreenScale = ARC9.ScreenScale
local clicksound = "arc9/newui/uimouse_click.ogg"
local foldersound = "arc9/newui/uimouse_click_forward.ogg"
local backsound = "arc9/newui/uimouse_click_return.ogg"
local tabsound = "arc9/newui/uimouse_click_tab.ogg"
local function spacer(self, scroll, margin)
local spacer = vgui.Create("DPanel", scroll)
@ -191,12 +192,37 @@ local function enterfolder(self, scroll, slottbl, fname)
enterfolder(self, scroll, slottbl, self2.folder)
surface.PlaySound(foldersound)
end
if kc == MOUSE_RIGHT then
local randompool = {}
for _, v in ipairs(self.BottomBarAtts) do
local atbl = ARC9.GetAttTable(v.att)
local checkfolder = self2.folder
local pathprefix = string.Implode("/", self.BottomBarPath)
if pathprefix != "" then checkfolder = pathprefix .. "/" .. self2.folder end
if atbl.Folder == checkfolder or (self2.folder == "!favorites" and ARC9.Favorites[v.att]) then
table.insert(randompool, atbl)
randompool[#randompool].fuckthis = v.slot
end
end
local thatatt = randompool[math.random(0, #randompool)]
if thatatt then
self:Attach(thatatt.fuckthis, thatatt.ShortName, true)
end
surface.PlaySound(tabsound)
end
end
folderbtn.Think = function(self2)
if !IsValid(self) then return end
if self2:IsHovered() then
self.CustomizeHints["customize.hint.select"] = "customize.hint.select"
-- self.CustomizeHints["customize.hint.deselect"] = "customize.hint.randomize"
self.CustomizeHints["customize.hint.deselect"] = "customize.hint.randomize"
end
end
end