How? I have this so far:
lua/skins/black_orange.lua
[quote]
local SKIN = {}
// These are used in the settings panel
SKIN.PrintName = "Black and Orange"
SKIN.Author = ""
SKIN.DermaVersion = 1
SKIN.colOutline = Color( 0, 0, 0, 20 )
// You can change the colours from the Default skin
SKIN.colPropertySheet = Color( 255, 127, 0, 255 )
SKIN.colTab = SKIN.colPropertySheet
SKIN.colTabText = Color( 0, 0, 0, 255 )
SKIN.colTabInactive = Color( 3, 3, 3, 200 )
SKIN.colTabShadow = Color( 255, 255, 255, 255 )
SKIN.fontButton = "Default"
SKIN.fontTab = "Default"
SKIN.bg_color = Color( 0, 0, 0, 180 )
SKIN.bg_color_sleep = Color( 0, 0, 0, 230 )
SKIN.bg_color_dark = Color( 15, 15, 15, 255 )
SKIN.bg_color_bright = Color( 255, 127, 0, 255 )
SKIN.listview_hover = Color( 200, 100, 0, 255 )
SKIN.listview_selected = Color( 0, 0, 0, 210 )
SKIN.control_color = Color( 200, 100, 0, 255 )
SKIN.control_color_highlight = Color( 222, 111, 0, 255 )
SKIN.control_color_active = Color( 188, 88, 0, 225 )
SKIN.control_color_bright = Color( 0, 0, 0, 255 )
SKIN.control_color_dark = Color( 8, 8, 8, 220 )
SKIN.text_bright = Color( 255, 255, 255, 255 )
SKIN.text_normal = Color( 255, 255, 255, 255 )
SKIN.text_dark = Color( 255, 255, 255, 255 )
SKIN.text_highlight = Color( 0, 0, 0, 20 )
SKIN.colCategoryText = Color( 0, 155, 155, 255 )
SKIN.colCategoryTextInactive = Color( 255, 255, 255, 255 )
SKIN.fontCategoryHeader = "TabLarge"
SKIN.colTextEntryTextHighlight = Color( 0, 0, 2, 255 )
SKIN.colTextEntryTextHighlight = Color( 0, 0, 2, 255 )
SKIN.colCategoryText = Color( 255, 255, 255, 255 )
SKIN.colCategoryTextInactive = Color( 200, 200, 200, 255 )
SKIN.fontCategoryHeader = "TabLarge"
SKIN.tooltip = Color( 255, 127, 0, 255 )
// Or any of the functions
function SKIN:DrawSquaredBox( x, y, w, h, color )
surface.SetDrawColor( color )
surface.DrawRect( x, y, w, h )
surface.SetDrawColor( self.colOutline )
surface.DrawOutlinedRect( x, y, w, h )
end
function SKIN:PaintFrame( panel )
local color = self.bg_color
self:DrawSquaredBox( 0, 0, panel:GetWide(), panel:GetTall(), color )
surface.SetDrawColor( 0, 0, 0, 75 )
surface.DrawRect( 0, 0, panel:GetWide(), 21 )
surface.SetDrawColor( self.colOutline )
surface.DrawRect( 0, 21, panel:GetWide(), 1 )
end
// Or just start a new skin from scratch by overriding the whole thing
//
// You need to add this to the bottom of your skin to register it in Derma.
// Parameters are name (which should have no spaces or special chacters), description, then the SKIN table
//
derma.DefineSkin( "black_orange", "A black and orange skin", SKIN )
[/quote]
lua/autorun/client/skinovr.lua
[quote]
--skin override for server
timer.Simple( 1, function()
function GAMEMODE:ForceDermaSkin()
return "black_orange";
end
end )
[/quote]
I want people to join my game and get a Q menu with an arbitrary skin...
So what's your actual problem then, any errors?
First guess is, you have a file in autorun/client where it belongs, but is there an AddCSLuaFile() call in a serverside file to actually send the client your file?
Well, it doesn't even work when I listen (I automatically run the file that way, right?). Skin is the same. No errors. There were errors until I timer'd it. I'm guessing that's cause the script runs before the GM initializes.
[editline]5th February 2014[/editline]
I'm hearing that there's a problem with GAMEMODE:ForceDermaSkin(), is this true?
[QUOTE=KD007;43794867]Well, it doesn't even work when I listen (I automatically run the file that way, right?).[/quote]
Yeah that should work then.
[QUOTE=KD007;43794867]There were errors until I timer'd it. I'm guessing that's cause the script runs before the GM initializes.[/quote]
If you want to use function GM: then it needs to be in the gamemode code, not in autorun. Use hook.Add instead.
[QUOTE=KD007;43794867]I'm hearing that there's a problem with GAMEMODE:ForceDermaSkin(), is this true?[/QUOTE]
I haven't used it myself, so I can't say. Put a print statement in there and see if it prints. I'll give it a try now.
[editline]5th February 2014[/editline]
[lua]hook.Add("ForceDermaSkin", "Foreskin", function()
print("FORCING DERMA SKIN")
return "black_orange"
end)[/lua]
This prints for me.
I added a print to the skin file and it didn't print. Then I realised, do lua files in the skins directory get included automatically? You probably need to actually include the skin file.
I'll do that now and report back.
[editline]5th February 2014[/editline]
You do have to include the skin file yourself, but I still can't get it to actually show.
This is my two files I was testing with, in singleplayer.
[b]lua/autorun/client/foreskin.lua[/b]
[lua]hook.Add("ForceDermaSkin", "Foreskin", function()
print("FORCING DERMA SKIN") --This does print ok
return "black_orange"
end)
include('skins/black_orange.lua')
concommand.Add("testorangeskin", function() --Just opens a dframe to see if our skin is working
local f = vgui.Create("DFrame")
f:SetSize(400,400)
f:Center()
f:MakePopup()
end)[/lua]
[b]lua/skins/black_orange.lua[/b] I've just changed everything to red to see if it even works, and added a print to DFrame paint (never prints)
[lua]local SKIN = {}
// These are used in the settings panel
SKIN.PrintName = "Black and Orange"
SKIN.Author = ""
SKIN.DermaVersion = 1
SKIN.colOutline = Color( 255, 0, 0, 20 )
// You can change the colours from the Default skin
SKIN.colPropertySheet = Color( 255, 0, 0, 20 )
SKIN.colTab = SKIN.colPropertySheet
SKIN.colTabText = Color( 255, 0, 0, 20 )
SKIN.colTabInactive = Color( 255, 0, 0, 20 )
SKIN.colTabShadow = Color( 255, 0, 0, 20 )
SKIN.fontButton = "Default"
SKIN.fontTab = "Default"
SKIN.bg_color = Color( 255, 0, 0, 20 )
SKIN.bg_color_sleep = Color( 255, 0, 0, 20 )
SKIN.bg_color_dark = Color( 255, 0, 0, 20 )
SKIN.bg_color_bright = Color( 255, 0, 0, 20 )
SKIN.listview_hover = Color( 255, 0, 0, 20 )
SKIN.listview_selected = Color( 255, 0, 0, 20 )
SKIN.control_color = Color( 255, 0, 0, 20 )
SKIN.control_color_highlight = Color( 255, 0, 0, 20 )
SKIN.control_color_active = Color( 255, 0, 0, 20 )
SKIN.control_color_bright = Color( 255, 0, 0, 20 )
SKIN.control_color_dark = Color( 255, 0, 0, 20 )
SKIN.text_bright = Color( 255, 0, 0, 20 )
SKIN.text_normal = Color( 255, 0, 0, 20 )
SKIN.text_dark = Color( 255, 0, 0, 20 )
SKIN.text_highlight = Color( 255, 0, 0, 20 )
SKIN.colCategoryText = Color( 255, 0, 0, 20 )
SKIN.colCategoryTextInactive = Color( 255, 0, 0, 20 )
SKIN.fontCategoryHeader = "TabLarge"
SKIN.colTextEntryTextHighlight = Color( 255, 0, 0, 20 )
SKIN.colTextEntryTextHighlight = Color( 255, 0, 0, 20 )
SKIN.colCategoryText = Color( 255, 255, 255, 255 )
SKIN.colCategoryTextInactive = Color( 200, 200, 200, 255 )
SKIN.fontCategoryHeader = "TabLarge"
SKIN.tooltip = Color( 255, 127, 0, 255 )
// Or any of the functions
function SKIN:DrawSquaredBox( x, y, w, h, color )
surface.SetDrawColor( color )
surface.DrawRect( x, y, w, h )
surface.SetDrawColor( self.colOutline )
surface.DrawOutlinedRect( x, y, w, h )
end
function SKIN:PaintFrame( panel )
print("PAINTING FRAME FROM SKIN") --this never prints
local color = self.bg_color
self:DrawSquaredBox( 0, 0, panel:GetWide(), panel:GetTall(), color )
surface.SetDrawColor( 0, 0, 0, 75 )
surface.DrawRect( 0, 0, panel:GetWide(), 21 )
surface.SetDrawColor( self.colOutline )
surface.DrawRect( 0, 21, panel:GetWide(), 1 )
end
// Or just start a new skin from scratch by overriding the whole thing
//
// You need to add this to the bottom of your skin to register it in Derma.
// Parameters are name (which should have no spaces or special chacters), description, then the SKIN table
//
derma.DefineSkin( "black_orange", "A black and orange skin", SKIN )
print("REGISTERED ORANGE_BLACK") --this does print after the file is included[/lua]
So unless I'm missing something, it seems the ForceDermaSkin does get called but it doesn't actually affect anything.
I'm going to try overriding derma.GetDefaultSkin and see if I have any luck.
[editline]5th February 2014[/editline]
I got it working! I just need to figure out what I did.... It was either removing the _ in black_orange, or calling derma.RefreshSkins()
[editline]5th February 2014[/editline]
Hmmm. The above code seems to work for me fine after restarting gmod,, without needing to call derma.RefreshSkins()
It affects the DFrame opened by the test command I added, but it doesn't affect the sandbox spawn menu for some reason.
Sorry, you need to Log In to post a reply to this thread.