- code style consistency
- removed unused vars for cvars that never existed
- slight optimization of loops
- merge settings categories into one
- force tool panel labels to fix colors on apply (to the best of ability)
- fix gear icon not applying to utilities tab
This commit is contained in:
worldspawn 2024-05-15 23:19:51 -06:00
parent 2124e64dd1
commit a1c373aeb0
8 changed files with 1056 additions and 1090 deletions

View File

@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2017 0x3bb Solutions Copyright (c) 2017-2024 0x3bb Solutions
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View File

@ -1,3 +1,2 @@
# [Themer](https://steamcommunity.com/sharedfiles/filedetails/?id=938347376) # [Themer](https://steamcommunity.com/sharedfiles/filedetails/?id=938347376)
Themer is a utility to replace derma themes on the fly without overwriting files. Themer is a utility to replace Derma themes or switch skins on the fly without overwriting files.

View File

@ -2,15 +2,16 @@
"description": "A tool to make derma skin application easier.", "description": "A tool to make derma skin application easier.",
"ignore": [ "ignore": [
"*.psd", "*.psd",
".git/*",
".gitignore",
"icon.jpg", "icon.jpg",
"themer.gma", "themer.gma",
"README.md" ".git/*",
".gitignore",
"README.md",
"LICENSE"
], ],
"logo": "icon.jpg", "logo": "icon.jpg",
"tags": ["build", "scenic"], "tags": ["build", "scenic"],
"title": "Themer", "title": "Themer",
"type": "tool", "type": "tool",
"workshopid": 938347376.0 "workshopid": 938347376
} }

View File

@ -5,20 +5,22 @@ AddCSLuaFile("themer/spawnmenu.lua")
if SERVER then if SERVER then
resource.AddWorkshop("938347376") resource.AddWorkshop("938347376")
return return
end end
include'skins/themer.lua'
surface.CreateFont("Themer.Title",{ include("skins/themer.lua")
surface.CreateFont("Themer.Title", {
font = "Roboto", font = "Roboto",
size = 48, size = 48,
weight = 400, weight = 400,
}) })
surface.CreateFont("Themer.Title2",{ surface.CreateFont("Themer.Title2", {
font = "Roboto", font = "Roboto",
size = 32, size = 32,
weight = 400, weight = 400,
}) })
include'themer/main.lua' include("themer/main.lua")

File diff suppressed because it is too large Load Diff

View File

@ -1,32 +1,43 @@
local function iconbrowser() local function iconbrowser()
local frame = vgui.Create("DFrame") local frame = vgui.Create("DFrame") do
frame:SetSize(400,300) frame:SetSize(400, 300)
frame:SetPos(5,ScrH()-305) frame:SetPos(5, ScrH() - 305)
frame:SetTitle("Icon Browser") frame:SetTitle("Icon Browser")
frame:MakePopup() frame:MakePopup()
frame:SetIcon("icon16/folder_picture.png") frame:SetIcon("icon16/folder_picture.png")
local path_pnl = vgui.Create("EditablePanel",frame) end
path_pnl:Dock(TOP)
path_pnl:DockMargin(4,0,4,4) local top_wrapper = vgui.Create("EditablePanel", frame) do
path_pnl:SetTall(24) top_wrapper:Dock(TOP)
local path = vgui.Create("DTextEntry",path_pnl) top_wrapper:DockMargin(4, 0, 4, 4)
top_wrapper:SetTall(24)
end
local path = vgui.Create("DTextEntry", top_wrapper) do
path:SetText("") path:SetText("")
path:Dock(FILL) path:Dock(FILL)
path:SetEditable(false) path:SetEditable(false)
local copy = vgui.Create("DButton",path_pnl) end
local copy = vgui.Create("DButton", top_wrapper) do
copy:Dock(RIGHT) copy:Dock(RIGHT)
copy:SetWide(24) copy:SetWide(24)
copy:SetImage("icon16/page_copy.png") copy:SetImage("icon16/page_copy.png")
copy:SetText("") copy:SetText("")
function copy:DoClick() function copy:DoClick()
SetClipboardText(path:GetText()) SetClipboardText(path:GetText())
end end
local browser = vgui.Create("DIconBrowser",frame) end
local browser = vgui.Create("DIconBrowser", frame) do
browser:Dock(FILL) browser:Dock(FILL)
browser:DockMargin(4,0,4,4) browser:DockMargin(4,0,4,4)
function browser:OnChange() function browser:OnChange()
path:SetText(self:GetSelectedIcon()) path:SetText(self:GetSelectedIcon())
end end
end
end end
concommand.Add("themer_iconbrowser",iconbrowser) concommand.Add("themer_iconbrowser", iconbrowser)

View File

@ -1,12 +1,4 @@
include("themer/iconbrowser.lua") -- {{ cvars
include("themer/spawnmenu.lua")
--[[
File: themer/main.lua
Info: This file loads everything and contains the main code of stuff
--]]
--cvars
local themer_enabled = CreateClientConVar("themer_enabled", "1", true) local themer_enabled = CreateClientConVar("themer_enabled", "1", true)
local derma_skinname = CreateClientConVar("derma_skinname", "gmoddefault", true) local derma_skinname = CreateClientConVar("derma_skinname", "gmoddefault", true)
local themer_skin = CreateClientConVar("themer_skin", "themer", true) local themer_skin = CreateClientConVar("themer_skin", "themer", true)
@ -22,8 +14,12 @@ local themer_icon_cars = CreateClientConVar("themer_icon_cars", "ico
local themer_icon_pp = CreateClientConVar("themer_icon_pp", "icon16/image.png", true) local themer_icon_pp = CreateClientConVar("themer_icon_pp", "icon16/image.png", true)
local themer_icon_dupes = CreateClientConVar("themer_icon_dupes", "icon16/brick_link.png", true) local themer_icon_dupes = CreateClientConVar("themer_icon_dupes", "icon16/brick_link.png", true)
local themer_icon_saves = CreateClientConVar("themer_icon_saves", "icon16/disk.png", true) local themer_icon_saves = CreateClientConVar("themer_icon_saves", "icon16/disk.png", true)
-- }}}
-- helpers include("themer/iconbrowser.lua")
include("themer/spawnmenu.lua")
-- {{{ helpers
local function getupvalues(f) local function getupvalues(f)
local i, t = 0, {} local i, t = 0, {}
@ -36,11 +32,12 @@ local function getupvalues(f)
return t return t
end end
-- }}}
--Main loading
local function ColorHack() local function ColorHack()
local DMenuOption = table.Copy(vgui.GetControlTable("DMenuOption")) local DMenuOption = table.Copy(vgui.GetControlTable("DMenuOption"))
local DComboBox = table.Copy(vgui.GetControlTable("DComboBox")) local DComboBox = table.Copy(vgui.GetControlTable("DComboBox"))
DMenuOption.Init = function(self) DMenuOption.Init = function(self)
self:SetContentAlignment(4) self:SetContentAlignment(4)
self:SetTextInset(30,0) self:SetTextInset(30,0)
@ -71,10 +68,11 @@ local function ColorHack()
return self:SetTextStyleColor(skin.Colours.Label.Dark) return self:SetTextStyleColor(skin.Colours.Label.Dark)
end end
derma.DefineControl( "DComboBox", "", DComboBox, "DButton" ) derma.DefineControl("DComboBox", "", DComboBox, "DButton")
local DProperties = table.Copy(vgui.GetControlTable("DProperties")) local DProperties = table.Copy(vgui.GetControlTable("DProperties"))
local tblCategory = getupvalues(DProperties.GetCategory).tblCategory local tblCategory = getupvalues(DProperties.GetCategory).tblCategory
DProperties.GetCategory = function(self, name, bCreate) DProperties.GetCategory = function(self, name, bCreate)
local cat = self.Categories[name] local cat = self.Categories[name]
if IsValid(cat) then return cat end if IsValid(cat) then return cat end
@ -98,114 +96,154 @@ local function ColorHack()
local DTree_Node_Button = table.Copy(vgui.GetControlTable("DTree_Node_Button")) local DTree_Node_Button = table.Copy(vgui.GetControlTable("DTree_Node_Button"))
DTree_Node_Button.UpdateColours = function(self, skin) DTree_Node_Button.UpdateColours = function(self, skin)
-- m_bSelectable is false on this for some reason -- m_bSelectable is false on this for some reason
if self.m_bSelected then return self:SetTextStyleColor( skin.Colours.Tree.Selected ) end if self.m_bSelected then
if self.Hovered then return self:SetTextStyleColor( skin.Colours.Tree.Hover ) end return self:SetTextStyleColor(skin.Colours.Tree.Selected)
return self:SetTextStyleColor( skin.Colours.Tree.Normal )
end end
derma.DefineControl( "DTree_Node_Button", "Tree Node Button", DTree_Node_Button, "DButton" ) if self.Hovered then
return self:SetTextStyleColor(skin.Colours.Tree.Hover)
end
return self:SetTextStyleColor(skin.Colours.Tree.Normal)
end
derma.DefineControl("DTree_Node_Button", "Tree Node Button", DTree_Node_Button, "DButton")
end end
hook.Add("ForceDermaSkin","Themer",function() hook.Add("ForceDermaSkin", "Themer", function()
if themer_enabled:GetBool() then return themer_skin:GetString() or "themer" end if themer_enabled:GetBool() then
return themer_skin:GetString() or "themer"
end
end) end)
concommand.Add("themer_refresh_derma",function() concommand.Add("themer_refresh_derma",function()
include("skins/themer.lua") include("skins/themer.lua")
derma.RefreshSkins() derma.RefreshSkins()
ColorHack() ColorHack()
for k,v in pairs(hook.GetTable()["ForceDermaSkin"]) do local hooks = hook.GetTable()
if k ~= "Themer" then for name in pairs(hooks.ForceDermaSkin) do
hook.Remove("ForceDermaSkin", k) if name == "Themer" then continue end
hook.Remove("ForceDermaSkin", name)
end
if IsValid(g_SpawnMenu) then
for _, tab in ipairs(g_SpawnMenu.ToolMenu.Items) do
local tool_panel = tab.Panel
if IsValid(tool_panel) and IsValid(tool_panel.Content) then
tool_panel = tool_panel.Content:GetCanvas()
end
if IsValid(tool_panel) then
for _, panel in ipairs(tool_panel:GetChildren()) do
local function recurse(c)
if #c == 0 then return end
for _, panel in ipairs(c) do
panel:InvalidateLayout()
recurse(panel:GetChildren())
end
end
for _, item in ipairs(panel.Items) do
recurse(item:GetChildren())
end
end
end
end end
end end
end) end)
hook.Add("SpawnMenuOpen","Themer.IconHack",function() hook.Add("SpawnMenuOpen", "Themer.IconHack", function()
local ToolMenu = g_SpawnMenu.ToolMenu local ToolMenuItems = g_SpawnMenu.ToolMenu.Items
for k,v in pairs(ToolMenu.Items) do for _, item in ipairs(ToolMenuItems) do
if v.Name == "Options" then if item.Name == "Options" then
v.Tab.Image:SetImage(themer_options_gear:GetBool() and "icon16/cog.png" or "icon16/wrench.png") item.Tab.Image:SetImage(themer_options_gear:GetBool() and "icon16/cog.png" or "icon16/wrench.png")
end end
if v.Name == "Utilities" then if item.Name == "Utilities" then
v.Tab.Image:SetImage(themer_options_gear:GetBool() and "icon16/cog.png" or "icon16/page_white_wrench.png") item.Tab.Image:SetImage(themer_options_gear:GetBool() and "icon16/cog.png" or "icon16/page_white_wrench.png")
end end
end end
local SpawnTabs = g_SpawnMenu.CreateMenu.Items local SpawnTabs = g_SpawnMenu.CreateMenu.Items
for k,v in pairs(SpawnTabs) do for _, tab in ipairs(SpawnTabs) do
if v.Name == "#spawnmenu.content_tab" then if tab.Name == "#spawnmenu.content_tab" then
v.Tab.Image:SetImage(Material(themer_icon_spawnlists:GetString()):IsError() and "icon16/application_view_tile.png" or themer_icon_spawnlists:GetString()) tab.Tab.Image:SetImage(Material(themer_icon_spawnlists:GetString()):IsError() and "icon16/application_view_tile.png" or themer_icon_spawnlists:GetString())
--While we're here local spawnlists = tab.Panel:GetChildren()[1].ContentNavBar.Tree.RootNode.ChildNodes:GetChildren()
local spawnlists = v.Panel:GetChildren()[1].ContentNavBar.Tree.RootNode.ChildNodes:GetChildren() for _, list in pairs(spawnlists) do
for _,n in pairs(spawnlists) do if list:GetText() == "Your Spawnlists" then
if n:GetText() == "Your Spawnlists" then list:SetIcon(themer_spawnlist_icons:GetBool() and "icon16/folder_page.png" or "icon16/folder.png")
n:SetIcon(themer_spawnlist_icons:GetBool() and "icon16/folder_page.png" or "icon16/folder.png")
end end
if n:GetText() == "Browse" then if list:GetText() == "Browse" then
n:SetIcon(themer_spawnlist_icons:GetBool() and "icon16/folder_brick.png" or "icon16/cog.png") list:SetIcon(themer_spawnlist_icons:GetBool() and "icon16/folder_brick.png" or "icon16/cog.png")
end end
if n:GetText() == "Browse Materials" then if list:GetText() == "Browse Materials" then
n:SetIcon(themer_spawnlist_icons:GetBool() and "icon16/folder_image.png" or "icon16/picture_empty.png") list:SetIcon(themer_spawnlist_icons:GetBool() and "icon16/folder_image.png" or "icon16/picture_empty.png")
end end
if n:GetText() == "Browse Sounds" then if list:GetText() == "Browse Sounds" then
n:SetIcon(themer_spawnlist_icons:GetBool() and "icon16/folder_bell.png" or "icon16/sound.png") list:SetIcon(themer_spawnlist_icons:GetBool() and "icon16/folder_bell.png" or "icon16/sound.png")
end end
end end
end end
if v.Name == "#spawnmenu.category.weapons" then if tab.Name == "#spawnmenu.category.weapons" then
v.Tab.Image:SetImage(Material(themer_icon_weapons:GetString()):IsError() and "icon16/gun.png" or themer_icon_weapons:GetString()) tab.Tab.Image:SetImage(Material(themer_icon_weapons:GetString()):IsError() and "icon16/gun.png" or themer_icon_weapons:GetString())
end end
if v.Name == "#spawnmenu.category.entities" then if tab.Name == "#spawnmenu.category.entities" then
v.Tab.Image:SetImage(Material(themer_icon_ents:GetString()):IsError() and "icon16/bricks.png" or themer_icon_ents:GetString()) tab.Tab.Image:SetImage(Material(themer_icon_ents:GetString()):IsError() and "icon16/bricks.png" or themer_icon_ents:GetString())
end end
if v.Name == "#spawnmenu.category.npcs" then if tab.Name == "#spawnmenu.category.npcs" then
v.Tab.Image:SetImage(Material(themer_icon_npcs:GetString()):IsError() and "icon16/group.png" or themer_icon_npcs:GetString()) tab.Tab.Image:SetImage(Material(themer_icon_npcs:GetString()):IsError() and "icon16/group.png" or themer_icon_npcs:GetString())
end end
if v.Name == "#spawnmenu.category.vehicles" then if tab.Name == "#spawnmenu.category.vehicles" then
v.Tab.Image:SetImage(Material(themer_icon_cars:GetString()):IsError() and "icon16/car.png" or themer_icon_cars:GetString()) tab.Tab.Image:SetImage(Material(themer_icon_cars:GetString()):IsError() and "icon16/car.png" or themer_icon_cars:GetString())
end end
if v.Name == "#spawnmenu.category.postprocess" then if tab.Name == "#spawnmenu.category.postprocess" then
v.Tab.Image:SetImage(Material(themer_icon_pp:GetString()):IsError() and "icon16/image.png" or themer_icon_pp:GetString()) tab.Tab.Image:SetImage(Material(themer_icon_pp:GetString()):IsError() and "icon16/image.png" or themer_icon_pp:GetString())
end end
if v.Name == "#spawnmenu.category.dupes" then if tab.Name == "#spawnmenu.category.dupes" then
v.Tab.Image:SetImage(Material(themer_icon_dupes:GetString()):IsError() and "icon16/brick_link.png" or themer_icon_dupes:GetString()) tab.Tab.Image:SetImage(Material(themer_icon_dupes:GetString()):IsError() and "icon16/brick_link.png" or themer_icon_dupes:GetString())
end end
if v.Name == "#spawnmenu.category.saves" then if tab.Name == "#spawnmenu.category.saves" then
v.Tab.Image:SetImage(Material(themer_icon_saves:GetString()):IsError() and "icon16/disk.png" or themer_icon_saves:GetString()) tab.Tab.Image:SetImage(Material(themer_icon_saves:GetString()):IsError() and "icon16/disk.png" or themer_icon_saves:GetString())
end end
end end
end) end)
hook.Add("Initialize","Themer",function() hook.Add("Initialize", "Themer", function()
timer.Simple(0,function() timer.Simple(0, function()
ColorHack() ColorHack()
for k,v in pairs(hook.GetTable()["ForceDermaSkin"]) do
if k ~= "Themer" then local hooks = hook.GetTable()
hook.Remove("ForceDermaSkin", k) for name in pairs(hooks.ForceDermaSkin) do
end if name == "Themer" then continue end
hook.Remove("ForceDermaSkin", name)
end end
end) end)
end) end)
for k,v in pairs(hook.GetTable()["ForceDermaSkin"]) do do
if k ~= "Themer" then local hooks = hook.GetTable()
hook.Remove("ForceDermaSkin", k) for name in pairs(hooks.ForceDermaSkin) do
end if name == "Themer" then continue end
end
if hook.GetTable()["OnGamemodeLoaded"] and hook.GetTable()["OnGamemodeLoaded"]["CreateMenuBar"] then hook.Remove("ForceDermaSkin", name)
local oldCreateMenuBar = oldCreateMenuBar or hook.GetTable()["OnGamemodeLoaded"]["CreateMenuBar"] end
hook.Add( "OnGamemodeLoaded", "CreateMenuBar", function()
if hooks.OnGamemodeLoaded and hooks.OnGamemodeLoaded.CreateMenuBar then
_G.__themer_oldCreateMenuBar = _G.__themer_oldCreateMenuBar or hooks.OnGamemodeLoaded.CreateMenuBar
local oldCreateMenuBar = _G.__themer_oldCreateMenuBar
hook.Add("OnGamemodeLoaded", "CreateMenuBar", function()
ColorHack() ColorHack()
oldCreateMenuBar() oldCreateMenuBar()
end) end)
end
end end

View File

@ -2,9 +2,7 @@ local themer_enabled = GetConVar("themer_enabled")
local derma_skinname = GetConVar("derma_skinname") local derma_skinname = GetConVar("derma_skinname")
local themer_skin = GetConVar("themer_skin") local themer_skin = GetConVar("themer_skin")
local themer_tweaks_uselabel = GetConVar("themer_tweaks_uselabel")
local themer_options_gear = GetConVar("themer_options_gear") local themer_options_gear = GetConVar("themer_options_gear")
local themer_merge_options = GetConVar("themer_merge_options")
local themer_spawnlist_icons = GetConVar("themer_spawnlist_icons") local themer_spawnlist_icons = GetConVar("themer_spawnlist_icons")
local themer_icon_spawnlists = GetConVar("themer_icon_spawnlists") local themer_icon_spawnlists = GetConVar("themer_icon_spawnlists")
@ -17,103 +15,113 @@ local themer_icon_dupes = GetConVar("themer_icon_dupes")
local themer_icon_saves = GetConVar("themer_icon_saves") local themer_icon_saves = GetConVar("themer_icon_saves")
local function MakeMenu(panel) local function MakeMenu(panel)
panel:Help([[This menu lets you select a custom skin for most elements. The spawnmenu is most noticable. local info = panel:Help([[This menu lets you select a custom skin for most elements. The spawnmenu is most noticable.
All skins will be from any addons or server downloads, or any custom ones you've made/downloaded manually. All skins will be from any addons or server downloads, or any custom ones you've made/downloaded manually.
If you're working on a skin and colors aren't updating, reapply changes. If you're working on a skin and colors aren't updating, reapply changes.
All changes require applying changes.]]) All changes require applying changes.]])
panel:CheckBox("Use Custom Skin","themer_enabled") local enabled = panel:CheckBox("Use Custom Skin", "themer_enabled")
local files = {} local files = {}
for _,f in pairs(file.Find("materials/gwenskin/*.png","GAME")) do for _, filename in ipairs(file.Find("materials/gwenskin/*.png", "GAME")) do
f = f:gsub(".png","") filename = filename:gsub(".png", "")
files[f] = true files[filename] = true
end end
for _,f in pairs(file.Find("materials/gwenskin/*.png","THIRDPARTY")) do for _, filename in ipairs(file.Find("materials/gwenskin/*.png", "THIRDPARTY")) do
f = f:gsub(".png","") filename = filename:gsub(".png", "")
files[f] = true files[filename] = true
end end
local filelist = panel:ComboBox("Skin Image:","derma_skinname") local filelist = panel:ComboBox("Skin Image:", "derma_skinname")
for f,_ in pairs(files) do for filename in next, files do
filelist:AddChoice(f) filelist:AddChoice(filename)
end end
panel:Help([[Alternatively, you can select a full built skin, which may have other features or better compatibiliy.]]) local skin_help = panel:Help("Alternatively, you can select a typical skin, which may have other features or better compatibiliy.")
local skinlist = panel:ComboBox("Skin:","themer_skin") local skinlist = panel:ComboBox("Skin:", "themer_skin")
for f,_ in pairs(derma.SkinList) do for name in next, derma.SkinList do
skinlist:AddChoice(f) skinlist:AddChoice(name)
end end
local refresh = panel:Button("Refresh Lists") local refresh = panel:Button("Refresh Lists")
refresh.DoClick = function(s) refresh.DoClick = function()
filelist:Clear() filelist:Clear()
skinlist:Clear() skinlist:Clear()
files = {} files = {}
for _,f in pairs(file.Find("materials/gwenskin/*.png","GAME")) do for _, filename in ipairs(file.Find("materials/gwenskin/*.png", "GAME")) do
f = f:gsub(".png","") filename = filename:gsub(".png", "")
files[f] = true files[filename] = true
end end
for _,f in pairs(file.Find("materials/gwenskin/*.png","THIRDPARTY")) do for _, filename in ipairs(file.Find("materials/gwenskin/*.png", "THIRDPARTY")) do
f = f:gsub(".png","") filename = filename:gsub(".png", "")
files[f] = true files[filename] = true
end end
for f,_ in pairs(files) do for filename in next, files do
filelist:AddChoice(f) filelist:AddChoice(filename)
end end
for f,_ in pairs(derma.SkinList) do for name in next, derma.SkinList do
skinlist:AddChoice(f) skinlist:AddChoice(name)
end end
end end
refresh:SetIcon("icon16/arrow_refresh.png") refresh:SetIcon("icon16/arrow_refresh.png")
local reload = panel:Button("Reload Spawnmenu","spawnmenu_reload") if GAMEMODE.IsSandboxDerived then
reload:SetTooltip("Only do this if you really have to, as in things aren't updating.") local reload = panel:Button("Reload Spawnmenu", "spawnmenu_reload")
reload:SetTooltip("Only do this if you really have to, such as if things aren't updating.")
reload:SetIcon("icon16/application_view_tile.png") reload:SetIcon("icon16/application_view_tile.png")
end
local apply = panel:Button("Apply Changes","themer_refresh_derma") local apply = panel:Button("Apply Changes", "themer_refresh_derma")
apply:SetIcon("icon16/tick.png") apply:SetIcon("icon16/tick.png")
end end
local function IconSettings(panel) local function IconSettings(panel)
panel:Help([[Why only be limited to just the theme? Here you can set icons for spawnmenu tabs and such. panel:Help([[Why only be limited to just the theme? Here you can set icons for spawnmenu tabs and such.
Note: Spawnmenu tabs for addons (Pill Pack, simfphys vehicles, SCars, etc) will not be changable. Note: Spawnmenu tabs for addons (Pill Pack, SCars, etc) will not be changable.
All of these require reopening (not reloading) of the spawnmenu to apply changes.]]) All of these require reopening (not reloading) of the spawnmenu to apply changes.]])
panel:CheckBox("Use Gear icon for Options tab","themer_options_gear") panel:CheckBox("Use Gear icon for Options tab", "themer_options_gear")
panel:CheckBox("Better Spawnlist Icons","themer_spawnlist_icons") panel:CheckBox("Better Spawnlist Icons", "themer_spawnlist_icons")
panel:ControlHelp("Changes \"Your Spawnlists\" and \"Browse\" icons to more suitable icons.") panel:ControlHelp('Changes "Your Spawnlists" and "Browse" icons to more suitable icons.')
local ib = panel:Button("Popout Icon Browser","themer_iconbrowser") local open_iconbrowser = panel:Button("Popout Icon Browser", "themer_iconbrowser")
ib:SetIcon("icon16/folder_picture.png") open_iconbrowser:SetIcon("icon16/folder_picture.png")
local cat_ib = vgui.Create("DCollapsibleCategory",panel) local iconbrowser = vgui.Create("DCollapsibleCategory", panel) do
cat_ib:Dock(TOP) iconbrowser:Dock(TOP)
cat_ib:DockMargin(4,4,4,4) iconbrowser:DockMargin(4, 4, 4, 4)
cat_ib:SetExpanded(false) iconbrowser:SetExpanded(false)
cat_ib:SetLabel("Icon Browser") iconbrowser:SetLabel("Icon Browser")
cat_ib.Header:SetIcon("icon16/folder_picture.png") iconbrowser.Header:SetIcon("icon16/folder_picture.png")
cat_ib.AddItem = function(cat,ctrl) ctrl:SetParent(cat) ctrl:Dock(TOP) end iconbrowser.AddItem = function(self, ctrl)
ctrl:SetParent(self)
ctrl:Dock(TOP)
end
end
local path_pnl = vgui.Create("EditablePanel",panel) local top_wrapper = vgui.Create("EditablePanel", iconbrowser) do
path_pnl:DockMargin(0,0,0,4) top_wrapper:DockMargin(0, 0, 0, 4)
path_pnl:SetTall(24) top_wrapper:SetTall(24)
cat_ib:AddItem(path_pnl) iconbrowser:AddItem(top_wrapper)
local path = vgui.Create("DTextEntry",path_pnl) end
local path = vgui.Create("DTextEntry", top_wrapper) do
path:SetText("") path:SetText("")
path:Dock(FILL) path:Dock(FILL)
path:SetEditable(false) path:SetEditable(false)
local copy = vgui.Create("DButton",path_pnl) end
local copy = vgui.Create("DButton", top_wrapper) do
copy:Dock(RIGHT) copy:Dock(RIGHT)
copy:SetWide(24) copy:SetWide(24)
copy:SetImage("icon16/page_copy.png") copy:SetImage("icon16/page_copy.png")
@ -121,13 +129,16 @@ All of these require reopening (not reloading) of the spawnmenu to apply changes
function copy:DoClick() function copy:DoClick()
SetClipboardText(path:GetText()) SetClipboardText(path:GetText())
end end
local browser = vgui.Create("DIconBrowser",panel) end
local browser = vgui.Create("DIconBrowser", iconbrowser) do
browser:SetTall(250) browser:SetTall(250)
browser:DockMargin(0,0,0,4) browser:DockMargin(0, 0, 0, 4)
function browser:OnChange() function browser:OnChange()
path:SetText(self:GetSelectedIcon()) path:SetText(self:GetSelectedIcon())
end end
cat_ib:AddItem(browser) iconbrowser:AddItem(browser)
end
panel:TextEntry("#spawnmenu.content_tab", "themer_icon_spawnlists") panel:TextEntry("#spawnmenu.content_tab", "themer_icon_spawnlists")
panel:TextEntry("#spawnmenu.category.weapons", "themer_icon_weapons") panel:TextEntry("#spawnmenu.category.weapons", "themer_icon_weapons")
@ -140,60 +151,65 @@ All of these require reopening (not reloading) of the spawnmenu to apply changes
end end
local function About(panel) local function About(panel)
local title = vgui.Create("DLabel",panel) local title = vgui.Create("DLabel", panel) do
title:Dock(TOP) title:Dock(TOP)
title:SetFont("Themer.Title") title:SetFont("Themer.Title")
title:SetText("Themer") title:SetText("Themer")
title:SizeToContents() title:SizeToContents()
title:DockMargin(8,8,8,8) title:DockMargin(8, 8, 8, 8)
title:SetDark() title:SetDark()
end
local github = panel:Button("GitHub") local github = panel:Button("GitHub") do
github:SetIcon("icon16/world_link.png") github:SetIcon("icon16/world_link.png")
github.DoClick = function(s) gui.OpenURL("https://github.com/wrldspawn/Themer") end github.DoClick = function()
gui.OpenURL("https://github.com/wrldspawn/Themer")
end
end
end end
hook.Add("PopulateToolMenu","Themer.ToolMenu",function() hook.Add("PopulateToolMenu", "Themer.ToolMenu", function()
spawnmenu.AddToolMenuOption("Theming","Theming","\1Theme Options","Theme Options","","",MakeMenu) spawnmenu.AddToolMenuOption("Theming", "Theming", "Theme Options", "Theme Options", "", "", MakeMenu)
spawnmenu.AddToolMenuOption("Theming","Configuration","Icons","Icons","","",IconSettings) spawnmenu.AddToolMenuOption("Theming", "Theming", "\xe2\x80\x8bIcons", "\xe2\x80\x8bIcons", "", "", IconSettings)
spawnmenu.AddToolMenuOption("Theming","Misc","About","About","","",About) spawnmenu.AddToolMenuOption("Theming", "Theming", "\xe2\x80\x8b\xe2\x80\x8bAbout", "\xe2\x80\x8b\xe2\x80\x8bAbout", "", "", About)
for k,v in pairs(spawnmenu.GetTools()) do for _, tab in ipairs(spawnmenu.GetTools()) do
if v.Name == "Theming" then if tab.Name == "Theming" then
v.Icon = "icon16/palette.png" tab.Icon = "icon16/palette.png"
elseif tab.Name == "Utilities" and themer_options_gear:GetBool() then
tab.Icon = "icon16/cog.png"
end end
end end
end) end)
--External Settings Menu -- External Settings Menu
local function ExtSettings() local function ExtSettings()
local frame = vgui.Create("DFrame") local frame = vgui.Create("DFrame") do
frame:SetSize(384,768) frame:SetSize(384, 768)
frame:SetPos(ScrW()-432,ScrH()/2-256) frame:SetPos(ScrW() - 432, (ScrH() / 2) - 256)
frame:SetTitle("Themer Settings") frame:SetTitle("Themer Settings")
frame:SetIcon("icon16/palette.png") frame:SetIcon("icon16/palette.png")
frame:MakePopup() frame:MakePopup()
end
local tabs = vgui.Create("DPropertySheet",frame) local tabs = vgui.Create("DPropertySheet", frame)
tabs:Dock(FILL) tabs:Dock(FILL)
-- Main Area -- local main = vgui.Create("DForm", tabs)
local main = vgui.Create("DForm",tabs)
MakeMenu(main) MakeMenu(main)
main:SetName("Theme Options") main:SetName("Theme Options")
tabs:AddSheet("Theme Options",main,"icon16/palette.png") tabs:AddSheet("Theme Options", main, "icon16/palette.png")
--Icons-- local icons = vgui.Create("DForm", tabs)
local icons = vgui.Create("DForm",tabs)
IconSettings(icons) IconSettings(icons)
icons:SetName("Icons") icons:SetName("Icons")
tabs:AddSheet("Icons",icons,"icon16/pictures.png") tabs:AddSheet("Icons", icons, "icon16/pictures.png")
--About-- local about = vgui.Create("DForm", tabs) do
local about = vgui.Create("DForm",tabs)
About(about) About(about)
about:SetName("About") about:SetName("About")
tabs:AddSheet("About",about,"icon16/information.png") tabs:AddSheet("About", about, "icon16/information.png")
end
end end
concommand.Add("themer_settings",ExtSettings) concommand.Add("themer_settings", ExtSettings)