- 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

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

View File

@ -1,24 +1,26 @@
AddCSLuaFile("skins/themer.lua") AddCSLuaFile("skins/themer.lua")
AddCSLuaFile("themer/main.lua") AddCSLuaFile("themer/main.lua")
AddCSLuaFile("themer/iconbrowser.lua") AddCSLuaFile("themer/iconbrowser.lua")
AddCSLuaFile("themer/spawnmenu.lua") AddCSLuaFile("themer/spawnmenu.lua")
if SERVER then if SERVER then
resource.AddWorkshop("938347376") resource.AddWorkshop("938347376")
return
end return
include'skins/themer.lua' end
surface.CreateFont("Themer.Title",{ include("skins/themer.lua")
font = "Roboto",
size = 48, surface.CreateFont("Themer.Title", {
weight = 400, font = "Roboto",
}) size = 48,
weight = 400,
surface.CreateFont("Themer.Title2",{ })
font = "Roboto",
size = 32, surface.CreateFont("Themer.Title2", {
weight = 400, font = "Roboto",
}) size = 32,
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)
path:SetText("") top_wrapper:SetTall(24)
path:Dock(FILL) end
path:SetEditable(false)
local copy = vgui.Create("DButton",path_pnl) local path = vgui.Create("DTextEntry", top_wrapper) do
copy:Dock(RIGHT) path:SetText("")
copy:SetWide(24) path:Dock(FILL)
copy:SetImage("icon16/page_copy.png") path:SetEditable(false)
copy:SetText("") end
function copy:DoClick()
SetClipboardText(path:GetText()) local copy = vgui.Create("DButton", top_wrapper) do
end copy:Dock(RIGHT)
local browser = vgui.Create("DIconBrowser",frame) copy:SetWide(24)
browser:Dock(FILL) copy:SetImage("icon16/page_copy.png")
browser:DockMargin(4,0,4,4) copy:SetText("")
function browser:OnChange()
path:SetText(self:GetSelectedIcon()) function copy:DoClick()
end SetClipboardText(path:GetText())
end end
end
concommand.Add("themer_iconbrowser",iconbrowser)
local browser = vgui.Create("DIconBrowser", frame) do
browser:Dock(FILL)
browser:DockMargin(4,0,4,4)
function browser:OnChange()
path:SetText(self:GetSelectedIcon())
end
end
end
concommand.Add("themer_iconbrowser", iconbrowser)

View File

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

View File

@ -1,199 +1,215 @@
local themer_enabled = GetConVar("themer_enabled") 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_spawnlist_icons = GetConVar("themer_spawnlist_icons")
local themer_merge_options = GetConVar("themer_merge_options")
local themer_spawnlist_icons = GetConVar("themer_spawnlist_icons") local themer_icon_spawnlists = GetConVar("themer_icon_spawnlists")
local themer_icon_weapons = GetConVar("themer_icon_weapons")
local themer_icon_spawnlists = GetConVar("themer_icon_spawnlists") local themer_icon_ents = GetConVar("themer_icon_ents")
local themer_icon_weapons = GetConVar("themer_icon_weapons") local themer_icon_npcs = GetConVar("themer_icon_npcs")
local themer_icon_ents = GetConVar("themer_icon_ents") local themer_icon_cars = GetConVar("themer_icon_cars")
local themer_icon_npcs = GetConVar("themer_icon_npcs") local themer_icon_pp = GetConVar("themer_icon_pp")
local themer_icon_cars = GetConVar("themer_icon_cars") local themer_icon_dupes = GetConVar("themer_icon_dupes")
local themer_icon_pp = GetConVar("themer_icon_pp") local themer_icon_saves = GetConVar("themer_icon_saves")
local themer_icon_dupes = GetConVar("themer_icon_dupes")
local themer_icon_saves = GetConVar("themer_icon_saves") local function MakeMenu(panel)
local info = panel:Help([[This menu lets you select a custom skin for most elements. The spawnmenu is most noticable.
local function MakeMenu(panel) All skins will be from any addons or server downloads, or any custom ones you've made/downloaded manually.
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. 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.]]) local enabled = panel:CheckBox("Use Custom Skin", "themer_enabled")
panel:CheckBox("Use Custom Skin","themer_enabled") local files = {}
local files = {} for _, filename in ipairs(file.Find("materials/gwenskin/*.png", "GAME")) do
filename = filename:gsub(".png", "")
for _,f in pairs(file.Find("materials/gwenskin/*.png","GAME")) do files[filename] = true
f = f:gsub(".png","") end
files[f] = true for _, filename in ipairs(file.Find("materials/gwenskin/*.png", "THIRDPARTY")) do
end filename = filename:gsub(".png", "")
for _,f in pairs(file.Find("materials/gwenskin/*.png","THIRDPARTY")) do files[filename] = true
f = f:gsub(".png","") end
files[f] = true
end local filelist = panel:ComboBox("Skin Image:", "derma_skinname")
for filename in next, files do
local filelist = panel:ComboBox("Skin Image:","derma_skinname") filelist:AddChoice(filename)
for f,_ in pairs(files) do end
filelist:AddChoice(f)
end local skin_help = panel:Help("Alternatively, you can select a typical skin, which may have other features or better compatibiliy.")
panel:Help([[Alternatively, you can select a full built skin, which may have other features or better compatibiliy.]]) local skinlist = panel:ComboBox("Skin:", "themer_skin")
for name in next, derma.SkinList do
local skinlist = panel:ComboBox("Skin:","themer_skin") skinlist:AddChoice(name)
for f,_ in pairs(derma.SkinList) do end
skinlist:AddChoice(f)
end local refresh = panel:Button("Refresh Lists")
refresh.DoClick = function()
local refresh = panel:Button("Refresh Lists") filelist:Clear()
refresh.DoClick = function(s) skinlist:Clear()
filelist:Clear() files = {}
skinlist:Clear()
files = {} for _, filename in ipairs(file.Find("materials/gwenskin/*.png", "GAME")) do
filename = filename:gsub(".png", "")
for _,f in pairs(file.Find("materials/gwenskin/*.png","GAME")) do files[filename] = true
f = f:gsub(".png","") end
files[f] = true for _, filename in ipairs(file.Find("materials/gwenskin/*.png", "THIRDPARTY")) do
end filename = filename:gsub(".png", "")
for _,f in pairs(file.Find("materials/gwenskin/*.png","THIRDPARTY")) do files[filename] = true
f = f:gsub(".png","") end
files[f] = true
end for filename in next, files do
filelist:AddChoice(filename)
for f,_ in pairs(files) do end
filelist:AddChoice(f)
end for name in next, derma.SkinList do
skinlist:AddChoice(name)
for f,_ in pairs(derma.SkinList) do end
skinlist:AddChoice(f) end
end refresh:SetIcon("icon16/arrow_refresh.png")
end
refresh:SetIcon("icon16/arrow_refresh.png") if GAMEMODE.IsSandboxDerived then
local reload = panel:Button("Reload Spawnmenu", "spawnmenu_reload")
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:SetTooltip("Only do this if you really have to, as in 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)
local path_pnl = vgui.Create("EditablePanel",panel) ctrl:Dock(TOP)
path_pnl:DockMargin(0,0,0,4) end
path_pnl:SetTall(24) end
cat_ib:AddItem(path_pnl)
local path = vgui.Create("DTextEntry",path_pnl) local top_wrapper = vgui.Create("EditablePanel", iconbrowser) do
path:SetText("") top_wrapper:DockMargin(0, 0, 0, 4)
path:Dock(FILL) top_wrapper:SetTall(24)
path:SetEditable(false) iconbrowser:AddItem(top_wrapper)
local copy = vgui.Create("DButton",path_pnl) end
copy:Dock(RIGHT)
copy:SetWide(24) local path = vgui.Create("DTextEntry", top_wrapper) do
copy:SetImage("icon16/page_copy.png") path:SetText("")
copy:SetText("") path:Dock(FILL)
function copy:DoClick() path:SetEditable(false)
SetClipboardText(path:GetText()) end
end
local browser = vgui.Create("DIconBrowser",panel) local copy = vgui.Create("DButton", top_wrapper) do
browser:SetTall(250) copy:Dock(RIGHT)
browser:DockMargin(0,0,0,4) copy:SetWide(24)
function browser:OnChange() copy:SetImage("icon16/page_copy.png")
path:SetText(self:GetSelectedIcon()) copy:SetText("")
end function copy:DoClick()
cat_ib:AddItem(browser) SetClipboardText(path:GetText())
end
panel:TextEntry("#spawnmenu.content_tab", "themer_icon_spawnlists") end
panel:TextEntry("#spawnmenu.category.weapons", "themer_icon_weapons")
panel:TextEntry("#spawnmenu.category.entities", "themer_icon_ents") local browser = vgui.Create("DIconBrowser", iconbrowser) do
panel:TextEntry("#spawnmenu.category.npcs", "themer_icon_npcs") browser:SetTall(250)
panel:TextEntry("#spawnmenu.category.vehicles", "themer_icon_cars") browser:DockMargin(0, 0, 0, 4)
panel:TextEntry("#spawnmenu.category.postprocess", "themer_icon_pp") function browser:OnChange()
panel:TextEntry("#spawnmenu.category.dupes", "themer_icon_dupes") path:SetText(self:GetSelectedIcon())
panel:TextEntry("#spawnmenu.category.saves", "themer_icon_saves") end
end iconbrowser:AddItem(browser)
end
local function About(panel)
local title = vgui.Create("DLabel",panel) panel:TextEntry("#spawnmenu.content_tab", "themer_icon_spawnlists")
title:Dock(TOP) panel:TextEntry("#spawnmenu.category.weapons", "themer_icon_weapons")
title:SetFont("Themer.Title") panel:TextEntry("#spawnmenu.category.entities", "themer_icon_ents")
title:SetText("Themer") panel:TextEntry("#spawnmenu.category.npcs", "themer_icon_npcs")
title:SizeToContents() panel:TextEntry("#spawnmenu.category.vehicles", "themer_icon_cars")
title:DockMargin(8,8,8,8) panel:TextEntry("#spawnmenu.category.postprocess", "themer_icon_pp")
title:SetDark() panel:TextEntry("#spawnmenu.category.dupes", "themer_icon_dupes")
panel:TextEntry("#spawnmenu.category.saves", "themer_icon_saves")
local github = panel:Button("GitHub") end
github:SetIcon("icon16/world_link.png")
github.DoClick = function(s) gui.OpenURL("https://github.com/wrldspawn/Themer") end local function About(panel)
end local title = vgui.Create("DLabel", panel) do
title:Dock(TOP)
hook.Add("PopulateToolMenu","Themer.ToolMenu",function() title:SetFont("Themer.Title")
spawnmenu.AddToolMenuOption("Theming","Theming","\1Theme Options","Theme Options","","",MakeMenu) title:SetText("Themer")
spawnmenu.AddToolMenuOption("Theming","Configuration","Icons","Icons","","",IconSettings) title:SizeToContents()
spawnmenu.AddToolMenuOption("Theming","Misc","About","About","","",About) title:DockMargin(8, 8, 8, 8)
title:SetDark()
for k,v in pairs(spawnmenu.GetTools()) do end
if v.Name == "Theming" then
v.Icon = "icon16/palette.png" local github = panel:Button("GitHub") do
end github:SetIcon("icon16/world_link.png")
end github.DoClick = function()
end) gui.OpenURL("https://github.com/wrldspawn/Themer")
end
--External Settings Menu end
local function ExtSettings() end
local frame = vgui.Create("DFrame")
frame:SetSize(384,768) hook.Add("PopulateToolMenu", "Themer.ToolMenu", function()
frame:SetPos(ScrW()-432,ScrH()/2-256) spawnmenu.AddToolMenuOption("Theming", "Theming", "Theme Options", "Theme Options", "", "", MakeMenu)
frame:SetTitle("Themer Settings") spawnmenu.AddToolMenuOption("Theming", "Theming", "\xe2\x80\x8bIcons", "\xe2\x80\x8bIcons", "", "", IconSettings)
frame:SetIcon("icon16/palette.png") spawnmenu.AddToolMenuOption("Theming", "Theming", "\xe2\x80\x8b\xe2\x80\x8bAbout", "\xe2\x80\x8b\xe2\x80\x8bAbout", "", "", About)
frame:MakePopup()
for _, tab in ipairs(spawnmenu.GetTools()) do
local tabs = vgui.Create("DPropertySheet",frame) if tab.Name == "Theming" then
tabs:Dock(FILL) tab.Icon = "icon16/palette.png"
elseif tab.Name == "Utilities" and themer_options_gear:GetBool() then
-- Main Area -- tab.Icon = "icon16/cog.png"
local main = vgui.Create("DForm",tabs) end
MakeMenu(main) end
main:SetName("Theme Options") end)
tabs:AddSheet("Theme Options",main,"icon16/palette.png")
-- External Settings Menu
--Icons-- local function ExtSettings()
local icons = vgui.Create("DForm",tabs) local frame = vgui.Create("DFrame") do
IconSettings(icons) frame:SetSize(384, 768)
icons:SetName("Icons") frame:SetPos(ScrW() - 432, (ScrH() / 2) - 256)
tabs:AddSheet("Icons",icons,"icon16/pictures.png") frame:SetTitle("Themer Settings")
frame:SetIcon("icon16/palette.png")
--About-- frame:MakePopup()
local about = vgui.Create("DForm",tabs) end
About(about)
about:SetName("About") local tabs = vgui.Create("DPropertySheet", frame)
tabs:AddSheet("About",about,"icon16/information.png") tabs:Dock(FILL)
end
local main = vgui.Create("DForm", tabs)
concommand.Add("themer_settings",ExtSettings) MakeMenu(main)
main:SetName("Theme Options")
tabs:AddSheet("Theme Options", main, "icon16/palette.png")
local icons = vgui.Create("DForm", tabs)
IconSettings(icons)
icons:SetName("Icons")
tabs:AddSheet("Icons", icons, "icon16/pictures.png")
local about = vgui.Create("DForm", tabs) do
About(about)
about:SetName("About")
tabs:AddSheet("About", about, "icon16/information.png")
end
end
concommand.Add("themer_settings", ExtSettings)