· 6 years ago · May 27, 2019, 03:12 PM
1-- GB Radial Menu
2-- Adds a radial menu for easier tool-access
3-- Version 2008-10-30
4-- First internal release (FlyveHest)
5-- Version 2008-11-01
6-- Moved tools to a separate config file, so they are preserved in case of script upgrade
7-- Added GUI for editing which tools are in the radial menu (HOLY "#/& it took longer than projected!)
8-- Version 2008-11-02
9-- Apparently it is a REALLY bad idea to manipulate the array you are enumerating .. humdedum, major load bug fixed
10-- Renamed RCon to Con, don't know why I chose RCon to begin with :)
11-- You can now select if labels should be the same size (the size of the longest), or individually sized. (Actually spared a lot of calculations in the draw routine)
12-- A traceline can be drawn from screen-center to mouse cursor when selecting tools
13-- Version 2010-11-21
14-- Project taken over by Cmasta.
15-- Included Tool Finder Lua.
16-- Added Edit Tool Button
17-- Version 2012-11-26
18-- Updated by DeltaDesignRus to be Garrysmod13 compatible
19--[[
20 [Overhaul by Uke]
21Version 2017-12-3:
22 *Radial Menu:
23 *Changed: default alpha values to use configs' values
24 *SettingsMenu:
25 *Added: ability to change the opacity
26 *Added: border alpha multiplier
27 *Changed: skins also save border alpha multiplier
28 *Changed: color buttons show color and alpha difference
29 *Changed: presets show color and alpha difference
30Version 2016-9-4:
31 *Radial Menu:
32 *Fixed: command interpreter logic to only replace give in sandbox with gm_giveswep
33Version 2015-11-16:
34 *Radial Menu:
35 *Fixed: skins not loaded as skins
36 *Fixed: skinssettings not updateing on preset load
37 *SettingsMenu:
38 *Added: Indicators to see which preset has what skin settings stored
39 *Added: Reopen skin options on preset load to update the settings in that menu
40 *Utils:
41 *Chenged: skins won't save skin options anymore
42Version 2015-11-14:
43 *Radial Menu:
44 *Added: Function to bind a key to a specific preset.
45Version 2015-11-12:
46 *Radial Menu:
47 *Added: Some security to prevent the menu from giving errors for users who manually edited the settings textfiles or saving empty presets.
48 *Changed: Colorful Startup Message
49 SettingsMenu:
50 *Added: Preset Option "Save Shortcuts"
51 *Added: Preset Option "Save as Skin" which saves all settings but only loads specific ones.
52 *Added: Settings Menu for Skins
53 *Added: Icons for each Preset to visually emphasize it's type
54 *Added: Scrollwheel Support to scroll the settingmenu if the screen is to small. In addition to the existing drag function.
55 *Changed: "Also Save Customisations" button to "Save Settings"
56 *Fixed: When hovering over the corresponding buttons to a shortcut the shortcut used to be highlighted. That works again.
57 *Cookies!!! IYKWIM
58Version 2015-8-1:
59 Radial Menu changes:
60 *Fixed: Logical bug that prevents the use of sweps with "swep" in the name with the wep command thanks to DrSoaron
61Version 2015-3-23:
62 Radial Menu changes:
63 *Changed: seperated deadzone and radius
64 *Added: Indicators for deadzone and radius if you open the settings
65 *Fixed: The text rotation (from 180°-270° CCW)
66 SettingsMenu:
67 *Added: Slider for radius
68 *Added: Small text below the 'Close and Save' button because I think most people arent aware that the other close does also save
69 *Changed: Appearance of the sliders textentries
70 *Changed: Textentry field for the action if you close the menu
71 *Changed: Deadzone- (and radius-) slideers maximum is now the half of your minimum window size - 30
72 *Changed: Field Length sliders maximum is now the half of your minimum window size, minimum lowered
73 *Changed: Selected Inner/Outer Border and Spacing sliders Maximum raised to 10
74 *Changed: Text scale slider maximum raised to 2
75 *Changed: Renamed 'Expandable?' checkbox to 'Drag to Repeat?'
76 *Changed: Buttons 'Think' to 'PaintOver' hooks as they cause them to render white text somehow
77 *Changed: Reworked the credits a bit to poind out the reason for the order and updated to CMastas new account
78Version 2014-9-12d:
79 *Radial Menu:
80 Fixed: Text not rotating correctly if the rotation was 360 and a bit below.
81Version 2014-9-12c:
82 *Radial Menu:
83 Fixed: Rotated text aligning horizontally if the inner vertices reach the same position what they do if the inner border was set to 0.
84Version 2014-9-12b:
85 *bugfix
86Version 2014-9-12:
87 Find Tool:
88 *Added: Support for weapons if you're using it to select stuff.
89 *Added: Support for weapons if you're using it to select stuff.
90 *Added: Selecting stuff with the toolsearch now opens the corresponding options in the toolmenu.
91 *Added: Textentry now seperates numbers automatically with a space. (can now also find 'Expression 2' with 'e2' instead of 'e 2', etc.)
92 *Changed: Weapons and tools categories are now grey and right aligned.
93Version 2014-8-31:
94 Settingsmenu:
95 *Fixed: Bug where the radial menu is visually still open after closing the settings.
96Version 2014-8-24_d:
97 Radial Menu:
98 *Fixed: If you click a shortcut and close the menu it will no longer execute it twice
99 Settingsmenu:
100 *Fixed: Bug when you adjust the rotation and hold ctrl and shift only the shift label is highlighted
101Version 2014-8-24_b:
102 Radial Menu:
103 *Fixed: Error appearing if you delete all entries
104 Settingsmenu:
105 *Changed: Option to hold ctrl and shift while setting the angle now snaps to half the shifts steps
106Version 2014-8-24:
107 Radial Menu:
108 *Added: Made menu rotateable
109 *Added: Simple check if you got the current version
110 *Changed: Further improved the checking which shortcut is selected to work properly with a rotated menu
111 *Changed: The text now rotates visually with the shortcut instead of instantly rotate to its destination angle
112 SettingsMenu:
113 *Added: Button to change the rotation of the menu
114 *Added: Textentry to manually enter the rotation offset
115 *Added: Option to hold shift while setting the angle to snap to the required angle to get the next shortcut to the top
116 *Added: Option to hold ctrl while setting the angle to snap to 45° steps
117 *Added: Option to hold ctrl and shift while setting the angle to snap to 22.5° steps
118 *Added: Little info about the version on the credits tab
119 *Changed: Made the settingsmenu slightly taller to give the rotation button enough space to not unintentionally touch narby sliders
120 *Changed: The shortcut list now uses DScrollPane and DIconLayout instead of DPanelList
121 *Changed: The look of the scrollbars to fit my scheme
122 *Changed: Renamed 'Con' to 'Cmd'
123 *Changed: Improved the contrast of the credits text
124 Find Tool:
125 *Changed: The list now uses DScrollPane and DIconLayout instead of DPanelList
126 All:
127 *Changed: Entered all global variables into a global table
128Version 2014-6-29:
129 Radial Menu:
130 *Added: Per Shortcut Color
131 SettingsMenu:
132 *Added: RunOnConsole option which executes a command if you close the menu (useful to switching to the main-preset)
133 Find Tool:
134 *Added: Presets got a button to add them directly to the run on last textentry
135 *Added: Command to open them without the settingsmenu open
136 *Added: Pressing enter while writing selects the first found tool
137Version 2014-6-18:
138 Radial Menu changes:
139 *Changed: recognizing mouse clicks is now better
140Version 2014-6-17:
141 Radial Menu changes:
142 *Added: Changing font
143 *Added: Changing colors
144 *Added: Adjustable animation speed and color-chaning speed
145 *Added: Function to load other presets via the Radial Menu (like opening folders inside)
146 *Added: Support for the 'wep' command to make it shorter and widen compatibility (finally?)
147 SettingsMenu:
148 *Added: Tabs (Settings, Customisation, Presets, )
149 *Added: Presets
150 *Added: Options to make the text fit
151 *Added: Option to disable the outline of the text(for black text)
152 *Added: Added Text to the presets tab to explain how presets work
153 Find Tool:
154 *Added: Support for finding preset functions
155 Util:
156 *Added: Support for presets
157
158Version 2014-6-15:
159 [Metamists Update]
160 Radial Menu changes:
161 *Changed: Uses original function for running consolecommands again
162 *Changed: New method of changing the selected tool in the tools menu
163 *Changed: Arrows behavior inside the deadzone
164 *Changed: Font
165 *Added: Rotatable text
166 *Added: Animated fields
167 SettingsMenu:
168 *Added: Adjustable spacing between the fields
169 *Added: Options to rotate the text and adjust the spacing
170
171Version 2014-6-1_2:
172 Radial Menu changes:
173 *Changed: Now uses different function for running consolecommands allowing more like disconnect etc.
174 *Added: 'give' command gets automatically replaced with 'gm_giveswep' in sandbox
175Version 2014-6-1:
176 Radial Menu changes:
177 *Changed: Now uses fixed font instead of a variable one which could lead to a bug loading an invalid font
178 Find Tool:
179 *Added: Weapons to the search menu.
180 *Changed: Menu gets created/removed instead of visible/invisible
181 *Fixed: Failing timers
182 *Fixed: "lua/find_tool.lua:104: attempt to index a nil value" error
183Version 2014-5-31_2:
184 *Added: Support to load Settings and Tools from the old radial menu
185 *Changed: Settings are no longer wiped when encountering a new version
186 -instead it takes what it can get from the old config and inserts whats missing
187 -by keeping unnecessary settings for other versions for compatibility
188Version 2014-5-31:
189 Radial Menu changes:
190 *Added: Sounds to field dragging
191 SettingsMenu:
192 *Added: Option to turn of sounds
193Version 2014-5-30:
194 * Added: Chatmessage when running the first time
195 * Changed: settings files renamed due to incompatibility with old ones
196 Radial Menu changes:
197 * Change: Splitters are now feelds in between
198 * Added: Clickable and draggable menu fields
199 -Drag a field if its enagled for dragging to execute it multiple times
200 * Change: Traceline is now an arrow
201 * Added: Sounds to actions
202 * Added: Little helper in the bottom right corner to show available actions
203 SettingsMenu:
204 * Added: Radial Menu always shown when editing the options to see changes in realtime
205 * Added: Sizing Options for the fields
206 * Added: Rebind hotkey via button
207 * Changed: Hotkey is defined via botton but kept console command for compatibility
208 * Added: Dragging for toolslist buttons and
209 * Added: Radian menu selects the field corresponding to the selected/hovered tool in the toolslist
210 * Added: "Expandable?" option to the fields making them draggable
211 * Changed: Menu disables buttons you cant use (e.g. Delete if no tool is selected in the list)
212 * Changed: "Edit" button splits into "Save" and "Cancel" buttons on use
213 * Changed: Enabled close button in the top right corner; has same function as the "Close and Save" button
214 * Added: "Hide/Show Help" button
215 * Changed: "Tool" renamed to "Shortcut"
216 * Changed: Search Tool button no longer clears the textentry fields
217 Find Tool:
218 * Changed: Look to match the settings menu
219 * Changed: individually generated buttons to a scrollable list of buttons which supports 150(fixed for performance) instead of 19
220 * Added: you can also search for consolecommands
221 * Added: sorting tools and commands in the menu alphabetical and commands after tools
222 * Added: individual colors to command- and tool-result buttons
223 * Added: clicking a button also fills the name textentry with a possible name if the field was empty
224]]--
225// Show startup message VERSION 2.0
226if SERVER then
227MsgC( Color(0,160,255), "\n===============",Color(0,255,160),"[+]SERVER",Color(0,160,255),"===============\n" )
228else
229MsgC( Color(0,160,255), "\n===============",Color(0,255,160),"[+]CLIENT",Color(0,160,255),"===============\n" )
230end
231MsgC( Color(0,160,255), "GB RADIAL MENU (port by DeltaDesignRus)\n" )
232MsgC( Color(0,160,255), "By FlyveHest, Cmasta; ",Color(255,160,0),"overhauled by Uke\n" )
233MsgC( Color(0,160,255), "=======================================\n\n" )
234
235Radial = Radial or {}
236
237Radial.radialVersion = "2019-3-31" -- Used for config file checking
238
239Radial.currentRadialVersion = {["str"] = "", ["status"] = false}
240http.Fetch( "http://steamcommunity.com/sharedfiles/filedetails/?id=265292490",
241 function( body, len, headers, code )
242 for w in string.gmatch(body,"<div class=\"workshopItemDescription\" id=\"highlightContent\">Version: (.-)<br>") do
243 Radial.currentRadialVersion.str = string.Trim(w) or "nil"
244 break
245 end
246 if Radial.currentRadialVersion.str == Radial.radialVersion then
247 Radial.currentRadialVersion.status = 1
248 Msg("[GB-Radial] ");print("Your version is up-to-date.")
249 elseif Radial.currentRadialVersion.str == "nil" then
250 Radial.currentRadialVersion.status = -1
251 Msg("[GB-Radial] ");print("Failed checking for current version.")
252 else
253 Radial.currentRadialVersion.status = -1
254 Msg("[GB-Radial] ");print("You are running an outdated version.")
255 end
256 end,
257 function( error )
258 Radial.currentRadialVersion.status = -1
259 Radial.currentRadialVersion.str = "nil"
260 Msg("[GB-Radial] ");print("Failed checking for version. ("..error..")")
261 end
262)
263
264if SERVER then
265 AddCSLuaFile( "autorun/gb-radial.lua" )
266 AddCSLuaFile( "gb-radial-options.lua" )
267 AddCSLuaFile( "gb-radial-utils.lua" )
268 AddCSLuaFile( "Find_Tool.lua" )
269
270 --local tags_old = GetConVarString("sv_tags") --for people who like finding servers with this mod
271 --RunConsoleCommand("sv_tags", tags_old .. ",radial")
272 --seems like it has been removed already a while ago :/
273elseif CLIENT then
274 -- Variables used globally
275 Radial.radialConfig = {} -- Config object
276 local oldconfig = {}
277 Radial.radialConfigTools = {} -- Config object - Tools
278 Radial.radialToolPresets = {}
279 Radial.SToolButtons = {} -- Search Menu
280 Radial.radialMenuOpen = false -- Is the menu visible?
281 Radial.selectedListTool = nil -- made global for even more eyecandy
282 Radial.settingshovertool = nil
283 local dragging = false
284 local dragdist = 0
285 local dip = {}
286 local clickedon = ""
287 local st = 0
288 local screenCenterX = ScrW() / 2 -- X center
289 local screenCenterY = ScrH() / 2 -- Y center
290 local pi = 4 * math.atan2(1, 1) -- Pi (Yum :)
291 local radialEntrySize = 0 -- How many degrees does a menu entry span?
292 local radialMenuSelectedTool = 0 -- The currently selected tool
293 local tex = surface.GetTextureID( "vgui/cursors/arrow" )
294 local exist = false
295 local RadialDefaultFont = "DermaDefault"
296 local fonts = {"Arial","Arial Black","Akbar","Comic Sans MS","Coolvetica","Courier New","Impact","Lucida Console","Palatino Linotype","Tahoma","Times New Roman","Trebuchet MS","Verdana"}
297
298 local math = math
299 local surface = surface
300 local gui = gui
301 Radial.includedtoolsettings = {name = 1,exp = 1,rconcommand = 1,cr = 1, cg = 1, cb = 1, ca = 1, cal = 1}
302 Radial.presetsettingsblacklist = {save_custom = 1, save_tools = 1, save_skin = 1, ["gbr-skinvars"] = "isskin"}
303
304 local function resetradialmenu()
305
306 screenCenterX = ScrW() / 2
307 screenCenterY = ScrH() / 2
308
309 local tempPresets = table.Copy(Radial.radialConfigTools)
310
311 for k,v in pairs(tempPresets) do --same again
312 for k2,v2 in pairs(v) do
313 if Radial.includedtoolsettings[k2] ~= 1 then
314 tempPresets[k][k2] = nil
315 end
316 end
317 end
318
319 Radial.radialConfigTools = tempPresets
320 end
321
322
323 hook.Add("Radial.MenuOpen","push",function(px)
324 screenCenterX = math.Clamp(ScrW() / 2,(ScrW()+px)/2, ScrW())
325 Radial.CalculateMenuLayout()
326 end)
327
328 hook.Add("Radial.MenuClose","pull",function()
329 resetradialmenu()
330 end)
331
332 for i = 1, #fonts do
333 surface.CreateFont( fonts[i].."_work", {
334 font = fonts[i],
335 size = 18,
336 weight = 500,
337 blursize = 0,
338 scanlines = 0,
339 antialias = true,
340 underline = false,
341 italic = false,
342 strikeout = false,
343 symbol = false,
344 rotary = false,
345 shadow = false,
346 additive = false,
347 outline = false
348 } )
349
350 surface.CreateFont( "Radial.Default_"..fonts[i], {
351 font = fonts[i],
352 size = 100,
353 weight = 400,
354 blursize = 1,
355 scanlines = 0,
356 antialias = true,
357 underline = false,
358 italic = false,
359 strikeout = false,
360 symbol = false,
361 rotary = false,
362 shadow = false,
363 additive = false,
364 outline = false,
365 } )
366 end
367
368 -- Include Options menu LUA
369
370
371 --
372-- GB Radial Menu
373-- Options Menu
374--
375
376if CLIENT then
377
378 surface.CreateFont( "GBS-Tiny", {
379 font = "Arial",
380 size = 10,
381 weight = 200,
382 antialias = false,
383 outline = true,
384 } )
385
386 surface.CreateFont( "GBS-Credits", {
387 font = "Arial",
388 size = 14,
389 weight = 100,
390 antialias = true,
391 } )
392
393 surface.CreateFont( "GBS-Version", {
394 font = "Arial",
395 size = 13,
396 weight = 200,
397 antialias = false,
398 outline = true,
399 } )
400
401 local PANEL = {}
402
403
404 local reopen = false
405 if Radial.settingsPanelShown then --makes it easier to see results when the file got edited
406 reopen = true
407 if settingsPanel == nil then return end
408 settingsPanel:Close()
409 end
410
411 Radial.settingsPanelShown = false
412 --local settingsPanel
413 local settingsPanelTools
414 local settingsPanelToolsLabel
415 local Drag = 0
416 local LMP = 0
417 local hover = 0
418 local fonts = {"Arial","Arial Black","Akbar","Comic Sans MS","Coolvetica","Courier New","Impact","Lucida Console","Palatino Linotype","Tahoma","Times New Roman","Trebuchet MS","Verdana"}
419
420 local settingsPanelDeadzone
421 local settingsPanelRadius
422 local settingsPanelDrawTraceline
423 local setborder
424 local settingsPanelSplitterLength
425 local inradslider
426 local outrdslider
427 local cb
428 local asy
429 local asx
430 local olt
431 local settingsPanelRotateText
432 local scs
433 local cp
434 local dp
435 local tc
436 local ccs
437 local ans
438 local rocte
439
440 local math = math
441 local surface = surface
442 local gui = gui
443 local vgui = vgui
444
445 local cpa
446
447 local function GetCheckedValue(DCBL)
448 if DCBL:GetChecked() then return 1 end
449 return 0
450 end
451
452 --dynamic credits highlight a credit if the player is on the server as well as displaying the current name
453 local iuke = "76561198023595888"
454 steamworks.RequestPlayerInfo( iuke ) -- uke
455 local nuke = steamworks.GetPlayerName( iuke ) or "Uke"
456
457 local ifly = "76561197970388820"
458 steamworks.RequestPlayerInfo( ifly ) -- FlyveHest
459 local nfly = steamworks.GetPlayerName( ifly ) or "GB.FlyveHest"
460
461 local icma = "76561198000505378" --OLD: "76561197995197442"
462 steamworks.RequestPlayerInfo( icma ) -- Cmasta
463 local ncma = steamworks.GetPlayerName( icma ) or "Cmasta"
464
465 local iddr = "76561197985835543"
466 steamworks.RequestPlayerInfo( iddr ) -- deltadesignrus
467 local nddr = steamworks.GetPlayerName( iddr ) or "DeltaDesignRus"
468
469 local icav = "76561198010983183"
470 steamworks.RequestPlayerInfo( icav ) -- cavou
471 local ncav = steamworks.GetPlayerName( icav ) or "Cavou"
472
473 local imet = "76561198020019152"
474 steamworks.RequestPlayerInfo( imet ) -- metamist
475 local nmet = steamworks.GetPlayerName( imet ) or "Metamist"
476
477 -- Add the current toolset to the listbox
478 local function addToolsToListbox(listbox)
479 -- Add Shortcuts to listbox
480 local listboxTools = {}
481
482 for k,v in pairs(Radial.radialConfigTools) do
483
484 if v and v != nil and v != {} then
485 local mark = ""
486 if Radial.radialConfigTools[k].exp == 1 then mark = "*" end
487
488 listboxTools[k] = vgui.Create("DButton")
489 listboxTools[k]:SetDrawBorder(false)
490 listboxTools[k]:SetText(v.name..mark)
491 listboxTools[k]:SizeToContents()
492 local sx,sy = listbox:GetSize()
493 listboxTools[k]:SetSize(sx-20,16)
494 sx,sy = listboxTools[k]:GetSize()
495 listboxTools[k].OnMousePressed = function()
496
497 if Radial.selectedListTool ~= nil then
498 -- A Shortcut was selected prior
499 if Radial.selectedListTool ~= k then
500 listboxTools[Radial.selectedListTool]:SetSelected(false)
501 Radial.selectedListTool = k
502 listboxTools[Radial.selectedListTool]:SetSelected(true)
503 else --deselect
504 listboxTools[Radial.selectedListTool]:SetSelected(false)
505 Radial.selectedListTool = nil
506 end
507 else
508 -- No Shortcut was selected
509 Radial.selectedListTool = k
510 listboxTools[Radial.selectedListTool]:SetSelected(true)
511 end
512 if Drag == 0 and Radial.selectedListTool ~= nil then
513 Drag = Radial.selectedListTool
514 LMP = gui.MouseY()
515 end
516 end
517
518 listboxTools[k].Think = function()
519 if listboxTools[k].Hovered and Drag == 0 and Radial.selectedListTool ~= k then
520 Radial.settingshovertool = k
521 end
522 end
523
524 listboxTools[k].PaintOver = function()
525 if listboxTools[k].Hovered and Drag == 0 and Radial.selectedListTool ~= k then
526 listboxTools[k]:SetText(v.name..mark.." - click and hold to drag")
527 Radial.settingshovertool = k
528 elseif listboxTools[k].Hovered and Drag ~= 0 and Drag ~= k then
529 listboxTools[Radial.selectedListTool]:SetSelected(false)
530 local tempTool = Radial.radialConfigTools[Drag]
531 Radial.radialConfigTools[Drag] = Radial.radialConfigTools[k]
532 Radial.radialConfigTools[k] = tempTool
533 listboxTools[k]:SetSelected(true)
534 Radial.selectedListTool = k
535 Drag = Radial.selectedListTool
536
537 -- Clean and redraw the listbox
538 settingsPanelTools:Clear()
539
540 addToolsToListbox(settingsPanelTools)
541 Radial.CalculateMenuLayout()
542 elseif listboxTools[k] ~= nil then
543 listboxTools[k]:SetText(v.name..mark)
544 end
545
546 if not input.IsMouseDown( MOUSE_LEFT ) and Drag ~= 0 then
547 Drag = 0
548 end
549
550 if Drag ~= 0 and Drag == k then
551 listboxTools[k]:SetText("||[ "..v.name..mark.." ]||")
552 listboxTools[k]:SetColor(Color(0,160,255,255))
553 elseif Radial.selectedListTool == k then
554 listboxTools[k]:SetText("[ "..v.name..mark.." ]")
555 listboxTools[k]:SetColor(Color(00,160,255,255))
556 else
557 listboxTools[k]:SetColor(Color(0,0,0,255))
558 end
559 end
560
561 local but = vgui.Create( "DButton", listboxTools[k] )
562 local lbtb = listboxTools[k]
563 but:SetPos(sx-sy)
564 but:SetSize(sy,sy)
565 but:SetText("")
566 local wf = Material("models/wireframe")
567 but.Paint = function()
568 local w, h = but:GetSize()
569 w, h = w-3, h-3
570 local ho = but.Hovered and 0 or 1
571 local mh = 1-ho
572 if v.ca == 1 then
573 local hm4d2 = (h-4)/2
574 surface.SetDrawColor(Color(127,127,127,130+115*ho ))
575 surface.DrawRect(3,2,w-2,h-2)
576 surface.SetDrawColor(Color(v.cr,v.cg,v.cb,255*ho+v.cal*(1-ho) ))
577 surface.DrawRect(4,3+hm4d2,w-4,hm4d2+1)
578 surface.SetDrawColor(Color(v.cr,v.cg,v.cb,v.cal ))
579 surface.DrawRect(4,3,w-4,hm4d2)
580 else
581 local hm4d2 = (h-4)/2
582 surface.SetDrawColor(Color(v.cr,v.cg,v.cb,(255*ho+v.cal*(1-ho))/2 ))
583 surface.DrawRect(4,3+hm4d2,w-4,hm4d2+1)
584 surface.SetDrawColor(Color(v.cr,v.cg,v.cb,v.cal/2 ))
585 surface.DrawRect(4,3,w-4,hm4d2)
586 wf:SetVector( "$color", Vector(130*ho,130*ho,130*ho)/255)
587 surface.SetMaterial(wf)
588 surface.DrawTexturedRect(4,3,w-3,h-3)
589 end
590 end
591 but.DoClick = function()
592 if IsValid(cpa) and IsValid(cpa:Close()) then cpa:Close() end
593 cpa = vgui.Create("DFrame")
594 cpa:SetSize(200, 180)
595 local px,py = settingsPanel:GetPos()
596 cpa:SetPos(px+300+4,py)
597 cpa:SetDraggable(false)
598 cpa:SetTitle("Color: "..v.name)
599 cpa:SetVisible(true)
600 cpa:ShowCloseButton(true)
601 cpa:SetDeleteOnClose(true)
602
603 local cpc = vgui.Create("DCheckBoxLabel", cpa)
604 cpc:SetText("Use Custom Color")
605 cpc:SizeToContents()
606 cpc:SetPos(6, 30)
607 cpc:SetValue(v.ca)
608 cpc.OnChange = function()
609 v.ca = GetCheckedValue(cpc)
610 end
611
612 local cte = vgui.Create("DTextEntry", cpa)
613 cte:SetPos(6, 156)
614 cte:SetWide(186)
615 cte:SetTall(16)
616 cte:SetText( v.cr.." , "..v.cg.." , "..v.cb.." , "..v.cal)
617
618 local cpm = vgui.Create( "DColorMixer", cpa )
619 cpm:SetPos( 6,50 )
620 cpm:SetSize(186,100)
621 cpm:SetPalette( false )
622 cpm:SetWangs( false )
623 cpm:SetAlphaBar( true )
624 cpm:SetColor( Color( v.cr, v.cg, v.cb, v.cal ) )
625 cpm.ValueChanged = function()
626 v.cr = cpm.m_Color.r
627 v.cg = cpm.m_Color.g
628 v.cb = cpm.m_Color.b
629 v.cal = cpm.m_Color.a
630
631 cte:SetText( v.cr.." , "..v.cg.." , "..v.cb.." , "..v.cal)
632
633 end
634
635 cte.OnEnter = function()
636 local exp = string.Explode(",", string.Trim(cte:GetValue()))
637 local r = v.cr
638 local g = v.cg
639 local b = v.cb
640 local a = v.cal
641 for i = 1, #exp do
642 local int
643 if i == 1 then
644 local inti1 = exp[i]
645 local inti = tonumber(string.Trim(exp[i] or ""))
646 int = tonumber(string.Trim(exp[i] or "")) or r
647 v.cr = math.Clamp(int, 0, 255)
648 elseif i == 2 then
649 int = tonumber(string.Trim(exp[i] or "")) or g
650 v.cg = math.Clamp(int, 0, 255)
651 elseif i == 3 then
652 int = tonumber(string.Trim(exp[i] or "")) or b
653 v.cb = math.Clamp(int, 0, 255)
654 elseif i == 4 then
655 int = tonumber(string.Trim(exp[i] or "")) or a
656 v.cal = math.Clamp(int, 0, 255)
657 end
658 end
659 cte:SetText( v.cr.." , "..v.cg.." , "..v.cb.." , "..v.cal)
660 cpm:SetColor( Color( v.cr, v.cg, v.cb, v.cal ) )
661 cpm:ValueChanged()
662 end
663
664 cte.OnLoseFocus = function()
665 cte:SetText( v.cr.." , "..v.cg.." , "..v.cb.." , "..v.cal)
666 end
667
668 cpa:MakePopup()
669 end
670 end
671
672 -- Add the item to the listbox
673 listbox:Add(listboxTools[k])
674 end
675
676 -- If a Shortcut is selected, draw it
677 if Radial.selectedListTool ~= nil then
678 listboxTools[Radial.selectedListTool]:SetSelected(true)
679 end
680 end
681
682 --Set convar textbox to Shortcut convar
683 function Radial.PasteConvar( str2 , prestr, name )
684 settingsPanelAddToolsRconText:SetText( prestr .." ".. str2 )
685 --settingsPanelAddToolsNameText:SetText("")
686
687 if settingsPanelAddToolsNameText:GetValue() == "" then
688 settingsPanelAddToolsNameText:SetText( string.upper(string.sub(name,0,1))..string.sub(name,2,-1) )
689 settingsPanelAddToolsNameText:RequestFocus()
690 settingsPanelAddToolsNameText:SetCaretPos( name:len() )
691 end
692 end
693
694 function Radial.pasteroc( str )
695 if str == nil then return end
696 Radial.radialConfig["gbr-onclose"] = str
697 rocte:SetValue( str )
698 rocte:OnTextChanged()
699 end
700 function Radial.openRadialMenuConfig()
701 http.Fetch( "http://steamcommunity.com/sharedfiles/filedetails/?id=265292490",
702 function( body, len, headers, code )
703 for w in string.gfind(body,"<div class=\"workshopItemDescription\" id=\"highlightContent\">Version: (.-)<br>") do
704 Radial.currentRadialVersion.str = string.Trim(w) or "nil"
705 break
706 end
707 if Radial.currentRadialVersion.str == Radial.radialVersion then
708 Radial.currentRadialVersion.status = 1
709 elseif Radial.currentRadialVersion.str ~= "nil" then
710 Radial.currentRadialVersion.status = -1
711 end
712 end,
713 function( error )
714 end
715 )
716 -- Build our own menu, because the AddControl function doesn't seem to be able to call LUA functions, but only concommands :(
717 -- Do I have to tell you how "#/%&"%&"� annoying that is?
718 local settingsSizeX = 300 --200
719 local settingsSizeY = 630 --430
720 local objSizeX, objSizeY, objPosX, objPosY
721 local edited = 0
722
723 -- If the settings aren't shown yet, show them
724 if not Radial.settingsPanelShown or settingsPanel == nil then
725 Radial.settingsPanelShown = true
726 -- Base frame
727 settingsPanel = vgui.Create("DFrame")
728 settingsPanel:SetSize(settingsSizeX, settingsSizeY)
729 settingsPanel:SetDraggable(false)
730 settingsPanel:SetTitle("Radial Menu Settings")
731 settingsPanel:SetVisible(true)
732 settingsPanel:ShowCloseButton(true)
733 settingsPanel:SetDeleteOnClose(true)
734 --settingsPanel.Paint = function()
735 --end
736 tabSizeX = settingsSizeX -4
737
738 local PrS = vgui.Create( "DPropertySheet", settingsPanel )
739 PrS:SetPos( 0, 24 )
740
741 local sp = vgui.Create( "DFrame", settingsPanel)
742 local sp2 = vgui.Create( "DFrame", settingsPanel)
743 local sp3 = vgui.Create( "DFrame", settingsPanel)
744
745 local sp4 = vgui.Create( "DFrame", settingsPanel)
746 sp:SetTitle("")
747 sp:SetDraggable(false)
748 sp:ShowCloseButton(false)
749
750 sp2:SetTitle("")
751 sp2:SetDraggable(false)
752 sp2:ShowCloseButton(false)
753
754 sp3:SetTitle("")
755 sp3:SetDraggable(false)
756 sp3:ShowCloseButton(false)
757
758 sp4:SetTitle("")
759 sp4:SetDraggable(false)
760 sp4:ShowCloseButton(false)
761
762
763 sp:SetCursor( "sizens" )
764 sp2:SetCursor( "sizens" )
765 sp3:SetCursor( "sizens" )
766 sp4:SetCursor( "sizens" )
767
768 -- Deadzone?
769 --if true then --first tab
770 local outrdslider = vgui.Create("DNumSlider", sp)
771 outrdslider.TextArea:SetDrawBackground( true )
772 outrdslider.TextArea:SetWide(outrdslider.TextArea:GetWide()+20)
773 function outrdslider.TextArea:Paint( w, h )
774 local sx,sy = self:LocalToScreen(0,0)
775 render.SetScissorRect( sx,sy, sx+w-20,sy+h, true )
776 derma.SkinHook( "Paint", "TextEntry", self, w, h )
777 render.SetScissorRect( sx,sy, sx+w-20,sy+h, false )
778 surface.SetDrawColor(120,120,120,255)
779 surface.DrawOutlinedRect(0,0, w-20, h)
780 return false
781 end
782 local inradslider = vgui.Create("DNumSlider", sp)
783 inradslider.TextArea:SetDrawBackground( true )
784 inradslider.TextArea:SetWide(inradslider.TextArea:GetWide()+20)
785 function inradslider.TextArea:Paint( w, h )
786 local sx,sy = self:LocalToScreen(0,0)
787 render.SetScissorRect( sx,sy, sx+w-20,sy+h, true )
788 derma.SkinHook( "Paint", "TextEntry", self, w, h )
789 render.SetScissorRect( sx,sy, sx+w-20,sy+h, false )
790 surface.SetDrawColor(120,120,120,255)
791 surface.DrawOutlinedRect(0,0, w-20, h)
792 return false
793 end
794 local spacingslider = vgui.Create("DNumSlider", sp)
795 spacingslider.TextArea:SetDrawBackground( true )
796 spacingslider.TextArea:SetWide(spacingslider.TextArea:GetWide()+20)
797 function spacingslider.TextArea:Paint( w, h )
798 local sx,sy = self:LocalToScreen(0,0)
799 render.SetScissorRect( sx,sy, sx+w-20,sy+h, true )
800 derma.SkinHook( "Paint", "TextEntry", self, w, h )
801 render.SetScissorRect( sx,sy, sx+w-20,sy+h, false )
802 surface.SetDrawColor(120,120,120,255)
803 surface.DrawOutlinedRect(0,0, w-20, h)
804 return false
805 end
806
807 local maxrad = math.Min(ScrW(),ScrH())/2
808 local maxrad2 = maxrad - 30
809
810 settingsPanelDeadzone = vgui.Create("DNumSlider", sp)
811 settingsPanelDeadzone:SetText("Menu Deadzone")
812 settingsPanelDeadzone:SetPos(6, 10)
813 settingsPanelDeadzone:SetSize(tabSizeX - 12, 16)
814 settingsPanelDeadzone:SetMinMax(20, maxrad2)
815 settingsPanelDeadzone:SetDecimals(0)
816 settingsPanelDeadzone:SetValue(Radial.radialConfig["gbr-menudeadzone"])
817 settingsPanelDeadzone.OnValueChanged = function()
818 Radial.radialConfig["gbr-menudeadzone"] = settingsPanelDeadzone:GetValue()
819 settingsPanelDeadzone.Slider:SetSlideX( settingsPanelDeadzone.Scratch:GetFraction() )
820 Radial.CalculateMenuLayout()
821 end
822 settingsPanelDeadzone.TextArea:SetDrawBackground( true )
823 settingsPanelDeadzone.TextArea:SetWide(settingsPanelDeadzone.TextArea:GetWide()+20)
824 function settingsPanelDeadzone.TextArea:Paint( w, h )
825 local sx,sy = self:LocalToScreen(0,0)
826 render.SetScissorRect( sx,sy, sx+w-20,sy+h, true )
827 derma.SkinHook( "Paint", "TextEntry", self, w, h )
828 render.SetScissorRect( sx,sy, sx+w-20,sy+h, false )
829 surface.SetDrawColor(120,120,120,255)
830 surface.DrawOutlinedRect(0,0, w-20, h)
831 return false
832 end
833 objPosX, objPosY = settingsPanelDeadzone:GetPos() -- Used for placing the next component
834 objSizeX, objSizeY = settingsPanelDeadzone:GetSize() -- Used to scale size so it fills the entire window
835
836 settingsPanelRadius = vgui.Create("DNumSlider", sp)
837 settingsPanelRadius:SetText("Menu Radius")
838 settingsPanelRadius:SetPos(6, objPosY + objSizeY + 2)
839 settingsPanelRadius:SetSize(tabSizeX - 12, 16)
840 settingsPanelRadius:SetMinMax(0, maxrad2)
841 settingsPanelRadius:SetDecimals(0)
842 settingsPanelRadius:SetValue(Radial.radialConfig["gbr-menuradius"])
843 settingsPanelRadius.OnValueChanged = function()
844 Radial.radialConfig["gbr-menuradius"] = settingsPanelRadius:GetValue()
845 settingsPanelRadius.Slider:SetSlideX( settingsPanelRadius.Scratch:GetFraction() )
846 Radial.CalculateMenuLayout()
847 end
848 settingsPanelRadius.TextArea:SetDrawBackground( true )
849 settingsPanelRadius.TextArea:SetWide(settingsPanelRadius.TextArea:GetWide()+20)
850 function settingsPanelRadius.TextArea:Paint( w, h )
851 local sx,sy = self:LocalToScreen(0,0)
852 render.SetScissorRect( sx,sy, sx+w-20,sy+h, true )
853 derma.SkinHook( "Paint", "TextEntry", self, w, h )
854 render.SetScissorRect( sx,sy, sx+w-20,sy+h, false )
855 surface.SetDrawColor(120,120,120,255)
856 surface.DrawOutlinedRect(0,0, w-20, h)
857 return false
858 end
859 objPosX, objPosY = settingsPanelRadius:GetPos() -- Used for placing the next component
860
861 local rmat = Material("widgets/disc.png")
862 local bmat = Material("gui/npc.png")
863 local tmat = Material("gui/workshop_rocket.png")
864
865 local rotbut = vgui.Create( "DButton", sp )
866 local degent = vgui.Create( "DTextEntry", sp )
867 rotbut:SetPos( 134, objPosY + objSizeY + 12 )
868 rotbut.a = false
869 rotbut:SetText( "" )
870 rotbut:SetSize( 42, 42 )
871 rotbut.OnMousePressed = function()
872 rotbut.a = true
873 end
874
875 local gpx, gpy = 21, 21
876
877 local function padd( pan )
878 local lpx, lpy = pan:GetPos()
879 gpx, gpy = gpx + lpx, gpy + lpy
880 if pan.GetParent then
881 if pan:GetParent() then
882 padd( pan:GetParent() )
883 end
884 end
885 end
886 local function floor( x, n )
887 x = x or 0
888 n = n or 0
889 if n == 0 then return math.floor(x) end
890 return math.floor(x*n*10)/(n*10)
891 end
892
893 local function grid( x, n )
894 x = x or 0
895 n = n or 0
896 if n == 0 then return x end
897 return math.floor((x+n/2)/n)*n
898 end
899
900 rotbut.sh = 0
901 rotbut.ct = 0
902
903 local shiftdown
904 local ctrldown
905
906 rotbut.Think = function()
907 gpx, gpy = 21, 21
908
909 padd( rotbut )
910
911 if rotbut.a then
912 if not input.IsMouseDown( MOUSE_LEFT ) then rotbut.a = false; return end
913
914 shiftdown = (input.IsKeyDown( KEY_LSHIFT ) or input.IsKeyDown( KEY_RSHIFT ))
915 ctrldown = (input.IsKeyDown( KEY_LCONTROL ) or input.IsKeyDown( KEY_RCONTROL ))
916
917 if shiftdown then
918 if ctrldown then
919 rotbut.sh = ( 360 / math.Max(#Radial.radialConfigTools,2) ) / 2
920 else
921 rotbut.sh = 360 / math.Max(#Radial.radialConfigTools,2)
922 end
923 rotbut.ct = 0
924 elseif ctrldown then
925 rotbut.ct = 45
926 rotbut.sh = 0
927 else
928 rotbut.sh = 0
929 rotbut.ct = 0
930 end
931
932 Radial.radialConfig["gbr-rotate"] = floor(grid(360 - (math.deg(math.atan2(gui.MouseX() - gpx, gui.MouseY() - gpy)) + 180),rotbut.sh + rotbut.ct),2)
933 Radial.CalculateMenuLayout()
934 degent:SetText( Radial.radialConfig["gbr-rotate"] )
935 end
936
937 local x = rotbut.sh + rotbut.ct
938 if x == 0 or not rotbut.a then
939 rotbut:SetText( "0" )
940 rotbut:SetTextColor( Color(255,255,255,20) )
941 else
942 rotbut:SetText( tostring(floor(x,1)) )
943 rotbut:SetTextColor( Color(255,255,255,255) )
944 end
945 end
946
947 local rbx,rby = rotbut:GetPos()
948 degent:SetPos( rbx + 46, rby+8 )
949 degent:SetSize( 58, 16 )
950 degent:SetText( math.abs(floor(Radial.radialConfig["gbr-rotate"],2)) )
951 degent.OnEnter = function( self )
952 Radial.radialConfig["gbr-rotate"] = math.abs(floor(degent:GetFloat(),2))
953 degent:SetText( Radial.radialConfig["gbr-rotate"] )
954 Radial.CalculateMenuLayout()
955 end
956 degent.OnLoseFocus = function( self )
957 Radial.radialConfig["gbr-rotate"] = math.abs(floor(degent:GetFloat(),2))
958 degent:SetText( Radial.radialConfig["gbr-rotate"] )
959 Radial.CalculateMenuLayout()
960 end
961
962 local rsx, rsy = rotbut:GetSize()
963 rotbut.Paint = function()
964 surface.SetDrawColor(Color(0,0,0,255))
965 surface.SetMaterial(bmat)
966 local x= 4
967 surface.DrawTexturedRect(-x/2,-x/2,rsx+x,rsy+x)
968 surface.DrawTexturedRect(-x/2,-x/2,rsx+x,rsy+x)
969 surface.DrawTexturedRect(-x/2,-x/2,rsx+x,rsy+x)
970
971 if rotbut.a then
972 surface.SetDrawColor(Color(100,255,150,255))
973 elseif rotbut.Hovered then
974 surface.SetDrawColor(Color(255,255,255,255))
975 else
976 surface.SetDrawColor(Color(230,230,230,255))
977 end
978 surface.SetMaterial(rmat)
979 surface.DrawTexturedRectRotated(rsx/2,rsy/2,rsx,rsy,-Radial.radialConfig["gbr-rotate"])
980 --surface.DrawText()
981 end
982
983 local rbx,rby = degent:GetPos()
984
985 local ctla = vgui.Create( "DLabel", sp )
986 ctla:SetPos( rbx , rby+12 )
987 ctla:SetText( "CTRL" )
988 ctla:SetFont("GBS-Tiny")
989
990 ctla.PaintOver = function()
991 if ctrldown and rotbut.a then
992 ctla:SetTextColor( Color(100,255,150,220) )
993 else
994 ctla:SetTextColor( Color(255,255,255,80) )
995 end
996 end
997
998 local shla = vgui.Create( "DLabel", sp )
999 shla:SetPos( rbx + 24, rby+12 )
1000 shla:SetText( "SHIFT" )
1001 shla:SetFont("GBS-Tiny")
1002
1003 shla.PaintOver = function()
1004 if shiftdown and rotbut.a then
1005 shla:SetTextColor( Color(100,255,150,220) )
1006 else
1007 shla:SetTextColor( Color(255,255,255,80) )
1008 end
1009 end
1010
1011 local dla = vgui.Create( "DLabel", sp )
1012 dla:SetPos( rbx + 1, rby-14 )
1013 dla:SetText( "Rotation:" )
1014 dla:SetFont("GBS-Credits")
1015
1016 -- Draw traceline? (...but as arrow now)
1017 settingsPanelDrawTraceline = vgui.Create("DCheckBoxLabel", sp)
1018 settingsPanelDrawTraceline:SetText("Draw Arrow")
1019 settingsPanelDrawTraceline:SizeToContents()
1020 settingsPanelDrawTraceline:SetPos(6, objPosY + objSizeY + 12)
1021 settingsPanelDrawTraceline:SetValue(Radial.radialConfig["gbr-menushowtraceline"])
1022 settingsPanelDrawTraceline.OnChange = function()
1023 Radial.radialConfig["gbr-menushowtraceline"] = GetCheckedValue(settingsPanelDrawTraceline)
1024 Radial.CalculateMenuLayout()
1025 end
1026
1027 objSizeX, objSizeY = settingsPanelDrawTraceline:GetSize() -- Used for placing the next component
1028 objPosX, objPosY = settingsPanelDrawTraceline:GetPos() -- Used for placing the next component
1029
1030 -- Draw border?
1031 setborder = vgui.Create("DCheckBoxLabel", sp)
1032 setborder:SetText("Draw Border")
1033 setborder:SizeToContents()
1034 setborder:SetPos(6, objPosY + objSizeY + 4)
1035 setborder:SetValue(Radial.radialConfig["gbr-drawborder"])
1036 setborder.OnChange = function()
1037 Radial.radialConfig["gbr-drawborder"] = GetCheckedValue(setborder)
1038 Radial.CalculateMenuLayout()
1039 end
1040
1041 objSizeX, objSizeY = setborder:GetSize() -- Used for placing the next component
1042 objPosX, objPosY = setborder:GetPos() -- Used for placing the next component
1043
1044 local border_passes = vgui.Create("DNumSlider", sp)
1045 border_passes.TextArea:SetDrawBackground( true )
1046 border_passes.TextArea:SetWide(border_passes.TextArea:GetWide()+20)
1047 function border_passes.TextArea:Paint( w, h )
1048 local sx,sy = self:LocalToScreen(0,0)
1049 render.SetScissorRect( sx,sy, sx+w-20,sy+h, true )
1050 derma.SkinHook( "Paint", "TextEntry", self, w, h )
1051 render.SetScissorRect( sx,sy, sx+w-20,sy+h, false )
1052 surface.SetDrawColor(120,120,120,255)
1053 surface.DrawOutlinedRect(0,0, w-20, h)
1054 return false
1055 end
1056 border_passes:SetText("Border Multiplier")
1057 border_passes:SetPos(6, objPosY + objSizeY+6)
1058 border_passes:SetSize(tabSizeX - 12, 16)
1059 border_passes:SetMinMax(1, 255)
1060 border_passes:SetDecimals(0)
1061 border_passes:SetValue(Radial.radialConfig["gbr-borderpasses"])
1062 border_passes.OnValueChanged = function()
1063 Radial.radialConfig["gbr-borderpasses"] = border_passes:GetValue()
1064 border_passes.Slider:SetSlideX( border_passes.Scratch:GetFraction() )
1065 Radial.CalculateMenuLayout()
1066 end
1067
1068 objPosX, objPosY = border_passes:GetPos()
1069
1070 -- Splitterlength?
1071 settingsPanelSplitterLength = vgui.Create("DNumSlider", sp)
1072 settingsPanelSplitterLength:SetText("Field Length")
1073 settingsPanelSplitterLength:SetPos(6, objPosY + objSizeY+12)
1074 settingsPanelSplitterLength:SetSize(tabSizeX - 12, 16)
1075 settingsPanelSplitterLength:SetMinMax(0, maxrad)
1076 settingsPanelSplitterLength:SetDecimals(0)
1077 settingsPanelSplitterLength:SetValue(Radial.radialConfig["gbr-menusplitterlength"])
1078 settingsPanelSplitterLength.OnValueChanged = function()
1079 Radial.radialConfig["gbr-menusplitterlength"] = settingsPanelSplitterLength:GetValue()
1080 settingsPanelSplitterLength.Slider:SetSlideX( settingsPanelSplitterLength.Scratch:GetFraction() )
1081 Radial.CalculateMenuLayout()
1082 end
1083 settingsPanelSplitterLength.TextArea:SetDrawBackground( true )
1084 settingsPanelSplitterLength.TextArea:SetWide(settingsPanelSplitterLength.TextArea:GetWide()+20)
1085 function settingsPanelSplitterLength.TextArea:Paint( w, h )
1086 local sx,sy = self:LocalToScreen(0,0)
1087 render.SetScissorRect( sx,sy, sx+w-20,sy+h, true )
1088 derma.SkinHook( "Paint", "TextEntry", self, w, h )
1089 render.SetScissorRect( sx,sy, sx+w-20,sy+h, false )
1090 surface.SetDrawColor(120,120,120,255)
1091 surface.DrawOutlinedRect(0,0, w-20, h)
1092 return false
1093 end
1094
1095 objSizeX, objSizeY = settingsPanelSplitterLength:GetSize() -- Used for placing the next component
1096 objPosX, objPosY = settingsPanelSplitterLength:GetPos() -- Used for placing the next component
1097
1098 inradslider:SetText("|- Selected Inner Border")
1099 inradslider:SetPos(6, objPosY + objSizeY+2)
1100 inradslider:SetSize(tabSizeX - 12, 16)
1101 inradslider:SetMinMax(0, 10)
1102 inradslider:SetDecimals(2)
1103 inradslider:SetValue(Radial.radialConfig["gbr-selectedinner"])
1104 inradslider.OnValueChanged = function()
1105 Radial.radialConfig["gbr-selectedinner"] = inradslider:GetValue()
1106 inradslider.Slider:SetSlideX( inradslider.Scratch:GetFraction() )
1107 Radial.CalculateMenuLayout()
1108 end
1109
1110 objSizeX, objSizeY = inradslider:GetSize() -- Used for placing the next component
1111 objPosX, objPosY = inradslider:GetPos() -- Used for placing the next component
1112
1113 outrdslider:SetText("|- Selected Outer Border")
1114 outrdslider:SetPos(6, objPosY + objSizeY+2)
1115 outrdslider:SetSize(tabSizeX - 12, objSizeY)
1116 outrdslider:SetMinMax(0, 10)
1117 outrdslider:SetDecimals(2)
1118 outrdslider:SetValue(Radial.radialConfig["gbr-selectedouter"])
1119 outrdslider.OnValueChanged = function()
1120 Radial.radialConfig["gbr-selectedouter"] = outrdslider:GetValue()
1121 outrdslider.Slider:SetSlideX( outrdslider.Scratch:GetFraction() )
1122 Radial.CalculateMenuLayout()
1123 end
1124
1125 objSizeX, objSizeY = outrdslider:GetSize() -- Used for placing the next component
1126 objPosX, objPosY = outrdslider:GetPos() -- Used for placing the next component
1127
1128 spacingslider:SetText("`- Spacing")
1129 spacingslider:SetPos(6, objPosY + objSizeY+2)
1130 spacingslider:SetSize(tabSizeX - 12, 16)
1131 spacingslider:SetMinMax(0, 10)
1132 spacingslider:SetDecimals(2)
1133 spacingslider:SetValue(Radial.radialConfig["gbr-spacing"])
1134 spacingslider.OnValueChanged = function()
1135 Radial.radialConfig["gbr-spacing"] = spacingslider:GetValue()
1136 spacingslider.Slider:SetSlideX( spacingslider.Scratch:GetFraction() )
1137 Radial.CalculateMenuLayout()
1138 end
1139
1140 objPosX, objPosY = spacingslider:GetPos() -- Used for placing the next component
1141
1142 -- Shortcut Label
1143 settingsPanelToolsLabel = vgui.Create("DLabel", sp)
1144 settingsPanelToolsLabel:SetText("Shortcuts Setup")
1145 settingsPanelToolsLabel:SizeToContents()
1146 settingsPanelToolsLabel:SetPos(6, objPosY + objSizeY + 10)
1147
1148 objSizeX, objSizeY = settingsPanelToolsLabel:GetSize() -- Used for placing the next component
1149 objPosX, objPosY = settingsPanelToolsLabel:GetPos() -- Used for placing the next component
1150
1151 -- Shortcut Setup
1152
1153 sptil = vgui.Create("DScrollPanel", sp)
1154 sptil:SetPos(6, objPosY + objSizeY + 2)
1155 sptil:SetSize(tabSizeX - 12, 220)
1156
1157 function sptil:Paint()
1158 local w, h = sptil:GetSize()
1159 surface.SetTexture(surface.GetTextureID("gui/gradient"))
1160 surface.SetDrawColor(Color(255,255,255,180))
1161 surface.DrawTexturedRect(1,1,w-2,h-2)
1162 surface.SetDrawColor(Color(50,50,50,180))
1163 surface.DrawLine(0,0,0,h)
1164 surface.DrawLine(1,0,5,0)
1165 surface.DrawLine(1,h-1,5,h-1)
1166 end
1167 function sptil.VBar:Paint() end
1168 function sptil.VBar.btnUp:Paint()
1169 local w, h = self:GetSize()
1170 if self.Depressed then
1171 surface.SetDrawColor(Color(255,255,255,180))
1172 elseif self.Hovered then
1173 surface.SetDrawColor(Color(0,255,255,180))
1174 else
1175 surface.SetDrawColor(Color(50,50,50,180))
1176 end
1177 surface.DrawLine(w-1,0,w-1,h)
1178 surface.DrawLine(w-2,0,w-5,0)
1179 end
1180 function sptil.VBar.btnDown:Paint()
1181 local w, h = self:GetSize()
1182 if self.Depressed then
1183 surface.SetDrawColor(Color(255,255,255,180))
1184 elseif self.Hovered then
1185 surface.SetDrawColor(Color(0,255,255,180))
1186 else
1187 surface.SetDrawColor(Color(50,50,50,180))
1188 end
1189 surface.DrawLine(w-1,0,w-1,h)
1190 surface.DrawLine(w-2,h-1,w-5,h-1)
1191 end
1192 function sptil.VBar.btnGrip:Paint()
1193 local w, h = self:GetSize()
1194 if self.Depressed then
1195 surface.SetDrawColor(Color(255,255,255,180))
1196 elseif self.Hovered then
1197 surface.SetDrawColor(Color(0,255,255,180))
1198 else
1199 surface.SetDrawColor(Color(50,50,50,180))
1200 end
1201 surface.DrawLine(w-1,0,w-1,h)
1202 end
1203
1204 settingsPanelTools = vgui.Create("DIconLayout", sptil)
1205 settingsPanelTools:SetBorder( 6 )
1206 --settingsPanelTools:SetSpaceY( 12 )
1207 settingsPanelTools:SetPos(0,0)
1208 settingsPanelTools:SetSize(sptil:GetSize()) -- 220 px high
1209
1210 -- Add the current Shortcuts to the listbox
1211 addToolsToListbox(settingsPanelTools)
1212
1213 objSizeX, objSizeY = sptil:GetSize() -- Used for placing the next component
1214 objPosX, objPosY = sptil:GetPos() -- Used for placing the next component
1215
1216 local function Up()
1217 -- Check if the selected Shortcut is the first
1218 if Radial.selectedListTool ~= nil and Radial.selectedListTool > 1 then
1219 -- Not the first, we do a swap
1220 local tempTool = Radial.radialConfigTools[Radial.selectedListTool - 1]
1221 Radial.radialConfigTools[Radial.selectedListTool - 1] = Radial.radialConfigTools[Radial.selectedListTool]
1222 Radial.radialConfigTools[Radial.selectedListTool] = tempTool
1223
1224 Radial.selectedListTool = Radial.selectedListTool - 1
1225
1226 -- Clean and redraw the listbox
1227 settingsPanelTools:Clear()
1228
1229 addToolsToListbox(settingsPanelTools)
1230 Radial.CalculateMenuLayout()
1231 end
1232 end
1233
1234 local function Down()
1235 -- Check if the selected Shortcut is the last
1236 if Radial.selectedListTool ~= nil and Radial.selectedListTool < table.getn(Radial.radialConfigTools) then
1237 -- Not the last, we do a swap
1238 local tempTool = Radial.radialConfigTools[Radial.selectedListTool + 1]
1239 Radial.radialConfigTools[Radial.selectedListTool + 1] = Radial.radialConfigTools[Radial.selectedListTool]
1240 Radial.radialConfigTools[Radial.selectedListTool] = tempTool
1241
1242 Radial.selectedListTool = Radial.selectedListTool + 1
1243
1244 -- Clean and redraw the listbox
1245 settingsPanelTools:Clear()
1246 addToolsToListbox(settingsPanelTools)
1247 Radial.CalculateMenuLayout()
1248 end
1249 end
1250
1251 -- Add UP button
1252 local settingsPanelMoveUp = vgui.Create("DButton", sp)
1253 settingsPanelMoveUp:SetText( "Up" )
1254 settingsPanelMoveUp:SetPos(6, objPosY + objSizeY + 2) -- settingsPanelMoveUp:SetPos(6, objPosY + objSizeY + 2)
1255 objSizeX, objSizeY = settingsPanelMoveUp:GetSize() -- Used to scale size so it fills the entire window
1256 settingsPanelMoveUp:SetSize(92, objSizeY)
1257 settingsPanelMoveUp.DoClick = function()
1258 Up()
1259 end
1260
1261 objPosX, objPosY = settingsPanelMoveUp:GetPos() -- Used for placing the next component
1262
1263
1264 -- Add delete button
1265 local settingsPanelDelete = vgui.Create("DButton", sp)
1266 settingsPanelDelete:SetText("Delete")
1267 settingsPanelDelete:SetPos(tabSizeX/2-46, objPosY) -- settingsPanelDelete:SetPos(70, objPosY)
1268 settingsPanelDelete:SetSize(92, objSizeY)
1269 settingsPanelDelete.DoClick = function()
1270 -- Delete the selected Shortcut, if a Shortcut is selected
1271 if Radial.selectedListTool ~= nil then
1272 Radial.radialConfigTools[Radial.selectedListTool] = nil
1273
1274 -- Check if index is fragmented
1275 if not table.IsSequential(Radial.radialConfigTools) then
1276 -- Table needs to be reordered
1277 local tempToolTable = {}
1278 local tempToolTableCounter = 1
1279
1280 for k,v in pairs(Radial.radialConfigTools) do
1281 tempToolTable[tempToolTableCounter] = v
1282
1283 tempToolTableCounter = tempToolTableCounter + 1
1284 end
1285
1286 Radial.radialConfigTools = tempToolTable
1287 tempToolTable = nil
1288 end
1289
1290 -- No Shortcut is selected
1291 Radial.selectedListTool = nil
1292
1293 -- Clean and redraw the listbox
1294 settingsPanelTools:Clear()
1295
1296 addToolsToListbox(settingsPanelTools)
1297 Radial.CalculateMenuLayout()
1298 end
1299 end
1300
1301 ButtobjPosX, ButtobjPosY = settingsPanelTools:GetPos()
1302
1303 -- Add down button
1304 local settingsPanelMoveDown = vgui.Create("DButton", sp)
1305 settingsPanelMoveDown:SetText("Down")
1306 settingsPanelMoveDown:SetPos(tabSizeX-98, objPosY)
1307 settingsPanelMoveDown:SetSize(92, objSizeY)
1308 settingsPanelMoveDown.DoClick = function()
1309 Down()
1310 end
1311 settingsPanelMoveDown.PaintOver = function()
1312 if Radial.selectedListTool ~= nil and Radial.selectedListTool ~= 0 then
1313 settingsPanelMoveUp:SetDisabled( false )
1314 settingsPanelDelete:SetDisabled( false )
1315 settingsPanelMoveDown:SetDisabled( false )
1316 else
1317 settingsPanelMoveUp:SetDisabled( true )
1318 settingsPanelDelete:SetDisabled( true )
1319 settingsPanelMoveDown:SetDisabled( true )
1320 end
1321 end
1322 objSizeX, objSizeY = settingsPanelMoveUp:GetSize() -- Used for placing the next component
1323 objPosX, objPosY = settingsPanelMoveUp:GetPos() -- Used for placing the next component
1324
1325 -- Add Shortcuts label
1326 local settingsPanelAddToolsLabel = vgui.Create("DLabel", sp)
1327 settingsPanelAddToolsLabel:SetText("Add Shortcut")
1328 settingsPanelAddToolsLabel:SizeToContents()
1329 settingsPanelAddToolsLabel:SetPos(tabSizeX/2-settingsPanelAddToolsLabel:GetSize()/2, objSizeY + objPosY + 10)
1330
1331 objSizeX, objSizeY = settingsPanelAddToolsLabel:GetSize() -- Used for placing the next component
1332 objPosX, objPosY = settingsPanelAddToolsLabel:GetPos() -- Used for placing the next component
1333
1334 -- Add Shortcut Name Label
1335 local settingsPanelAddToolsNameLabel = vgui.Create("DLabel", sp)
1336 settingsPanelAddToolsNameLabel:SetText("Name")
1337 settingsPanelAddToolsNameLabel:SizeToContents()
1338 settingsPanelAddToolsNameLabel:SetPos(6, objPosY + objSizeY + 6)
1339
1340 objPosX, objPosY = settingsPanelAddToolsNameLabel:GetPos() -- Used for placing the next component
1341 objSizeX, objSizeY = settingsPanelAddToolsNameLabel:GetSize() -- Used for placing the next component
1342
1343 -- Add Shortcut Name Textentry
1344 settingsPanelAddToolsNameText = vgui.Create("DTextEntry", sp) --nolocal
1345 settingsPanelAddToolsNameText:SetPos(objSizeX + 9, objPosY - 2)
1346 settingsPanelAddToolsNameText:SetEnterAllowed(true)
1347 settingsPanelAddToolsNameText:SetTall(16)
1348 settingsPanelAddToolsNameText:SetWide(tabSizeX - 15 - objSizeX)
1349
1350
1351 objSizeX, objSizeY = settingsPanelAddToolsNameText:GetSize() -- Used for placing the next component
1352 objPosX, objPosY = settingsPanelAddToolsNameText:GetPos() -- Used for placing the next component
1353
1354 -- Add Con Command Label
1355 local settingsPanelAddToolsRconLabel = vgui.Create("DLabel", sp)
1356 settingsPanelAddToolsRconLabel:SetText("Cmd")
1357 settingsPanelAddToolsRconLabel:SizeToContents()
1358 settingsPanelAddToolsRconLabel:SetPos(6, objPosY + objSizeY + 6)
1359
1360 objPosX, objPosY = settingsPanelAddToolsRconLabel:GetPos() -- Used for placing the next component
1361 objSizeX, objSizeY = settingsPanelAddToolsRconLabel:GetSize() -- Used for placing the next component
1362
1363 -- Add Con Command Textentry
1364 settingsPanelAddToolsRconText = vgui.Create("DTextEntry", sp)
1365 settingsPanelAddToolsRconText:SetPos(objSizeX + 10, objPosY - 2)
1366 settingsPanelAddToolsRconText:SetEnterAllowed(true)
1367 settingsPanelAddToolsRconText:SetTall(16)
1368 settingsPanelAddToolsRconText:SetWide(tabSizeX - 16 - objSizeX)
1369 objPosX, objPosY = settingsPanelAddToolsRconText:GetPos() -- Used for placing the next component
1370 objSizeX, objSizeY = settingsPanelAddToolsRconText:GetSize() -- Used for placing the next component
1371
1372 local settingsPanelExp = vgui.Create("DCheckBoxLabel", sp)
1373 settingsPanelExp:SetPos(6, objPosY + objSizeY + 4)
1374 settingsPanelExp:SetValue(false)
1375 --settingsPanelExp:SetDisabled(true)
1376 settingsPanelExp:SetText("Drag to Repeat?")
1377 settingsPanelExp:SizeToContents()
1378
1379 objPosX, objPosY = settingsPanelAddToolsRconLabel:GetPos() -- Used for placing the next component
1380 --objSizeX, objSizeY = settingsPanelAddToolsRconLabel:GetSize() -- Used for placing the next component
1381
1382 -- Add Shortcut Button
1383 local settingsPanelAddTool = vgui.Create("DButton", sp)
1384 settingsPanelAddTool:SetText("Add")
1385 objSizeX, objSizeY = settingsPanelAddTool:GetSize()
1386 settingsPanelAddTool:SetPos(settingsPanelMoveDown:GetPos(), objPosY + objSizeY + 18) -- settingsPanelAddTool:SetPos(134, objPosY + objSizeY + 8)
1387 settingsPanelAddTool:SetSize(92, 22)
1388 settingsPanelAddTool.PaintOver = function()
1389 if settingsPanelAddToolsNameText:GetValue() ~= "" and settingsPanelAddToolsRconText:GetValue() ~= "" then
1390 settingsPanelAddTool:SetDisabled( false )
1391 else
1392 settingsPanelAddTool:SetDisabled( true )
1393 end
1394 end
1395 settingsPanelAddTool.DoClick = function()
1396 local toolName = settingsPanelAddToolsNameText:GetValue()
1397 local toolRCon = settingsPanelAddToolsRconText:GetValue()
1398 local toolExp = GetCheckedValue(settingsPanelExp)
1399 -- Do we have enough information to add a new Shortcut?
1400 if #toolName > 0 and #toolRCon > 0 then
1401 -- Yes we do, add a new Shortcut
1402 Radial.radialConfigTools[#Radial.radialConfigTools + 1] = { name = toolName, rconcommand = toolRCon, exp = toolExp, cr = 0, cg = 255, cb = 255, ca = 0, cal = 180}
1403
1404 -- Clean the entryfields
1405 settingsPanelAddToolsRconText:SetValue("")
1406 settingsPanelAddToolsNameText:SetValue("")
1407 settingsPanelExp:SetValue(false)
1408
1409 -- Clean and redraw the listbox
1410 settingsPanelTools:Clear()
1411
1412 addToolsToListbox(settingsPanelTools)
1413 end
1414 if edited ~= 0 and settingsPanelEditTool then
1415 settingsPanelEditTool:SetText("Edit Shortcut")
1416 edited = 0
1417 end
1418 Radial.CalculateMenuLayout()
1419 end
1420
1421 -- Cmasta's Find Shortcut Con Button
1422 local settingsPanelFindCon = vgui.Create("DButton", sp)
1423 settingsPanelFindCon:SetText("Function Search")
1424 settingsPanelFindCon:SetPos(settingsPanelDelete:GetPos(), objPosY + objSizeY + 18) -- settingsPanelFindCon:SetPos(70, objPosY + objSizeY + 2)
1425 objSizeX, objSizeY = settingsPanelFindCon:GetSize() -- Used for placing the next component
1426 settingsPanelFindCon:SetSize(92, 22)
1427 settingsPanelFindCon.DoClick = function()
1428 Radial.ToolSearch()
1429 if edited == 1 and settingsPanelEditTool then
1430 settingsPanelEditTool:SetText("Edit Shortcut")
1431 edited = 0
1432 end
1433 end
1434
1435 -- Cmasta's Edit Shortcut button
1436 local settingsPanelEditTool = vgui.Create("DButton", sp)
1437 settingsPanelEditTool:SetText("Edit Shortcut")
1438 settingsPanelEditTool:SetPos(6, objPosY + objSizeY + 18) -- settingsPanelEditTool:SetPos(6, objPosY + objSizeY + 2)
1439 objSizeX, objSizeY = settingsPanelEditTool:GetSize() -- Used for placing the next component
1440 settingsPanelEditTool:SetSize(92, 22)
1441
1442 local cedit = vgui.Create("DButton", sp)
1443 cedit:SetText("Cancel")
1444 cedit:SetPos(53, objPosY + objSizeY + 18) -- settingsPanelEditTool:SetPos(6, objPosY + objSizeY + 2)
1445 objSizeX, objSizeY = cedit:GetSize() -- Used for placing the next component
1446 cedit:SetSize(46, 22)
1447 cedit:SetVisible( false )
1448 cedit.DoClick = function()
1449 edited = 0
1450 settingsPanelAddToolsRconText:SetText("")
1451 settingsPanelAddToolsNameText:SetText("")
1452 settingsPanelExp:SetValue(false)
1453 settingsPanelEditTool:SetSize(92, 22)
1454 settingsPanelEditTool:SetText("Edit Shortcut")
1455 cedit:SetVisible( false )
1456 end
1457
1458 settingsPanelEditTool.DoClick = function()
1459 --EditTool()
1460 if Radial.selectedListTool ~= nil then
1461 if edited == 0 then
1462 edited = 1
1463 settingsPanelEditTool:SetSize(46, 22)
1464 settingsPanelAddToolsRconText:SetText(Radial.radialConfigTools[Radial.selectedListTool].rconcommand)
1465 settingsPanelAddToolsNameText:SetText(Radial.radialConfigTools[Radial.selectedListTool].name)
1466 settingsPanelExp:SetValue(Radial.radialConfigTools[Radial.selectedListTool].exp)
1467 settingsPanelEditTool:SetText("Save")
1468
1469 cedit:SetVisible( true )
1470
1471 elseif edited == 1 then
1472 edited = 0
1473 local TN = settingsPanelAddToolsNameText:GetValue()
1474 local TC = settingsPanelAddToolsRconText:GetValue()
1475 local TE = GetCheckedValue(settingsPanelExp)
1476
1477 settingsPanelAddToolsRconText:SetText("")
1478 settingsPanelAddToolsNameText:SetText("")
1479 settingsPanelExp:SetValue(false)
1480 Radial.radialConfigTools[Radial.selectedListTool] = { name = TN, rconcommand = TC, exp = TE, cr = Radial.radialConfigTools[Radial.selectedListTool].cr, cg = Radial.radialConfigTools[Radial.selectedListTool].cg, cb = Radial.radialConfigTools[Radial.selectedListTool].cb, ca = Radial.radialConfigTools[Radial.selectedListTool].ca}
1481
1482 settingsPanelTools:Clear()
1483 addToolsToListbox(settingsPanelTools)
1484 settingsPanelEditTool:SetSize(92, 22)
1485 settingsPanelEditTool:SetText("Edit Shortcut")
1486 cedit:SetVisible( false )
1487 Radial.CalculateMenuLayout()
1488 end
1489 end
1490 end
1491 settingsPanelEditTool.PaintOver = function()
1492 if edited == 0 then
1493 if Radial.selectedListTool == nil or Radial.selectedListTool == 0 then
1494 settingsPanelEditTool:SetDisabled( true )
1495 else
1496 settingsPanelEditTool:SetDisabled( false )
1497 end
1498 else
1499 if settingsPanelAddToolsNameText:GetValue() ~= "" and settingsPanelAddToolsRconText:GetValue() ~= "" then
1500 settingsPanelEditTool:SetDisabled( false )
1501 else
1502 settingsPanelEditTool:SetDisabled( true )
1503 end
1504 end
1505 end
1506
1507 objPosX, objPosY = settingsPanelEditTool:GetPos() -- Used for placing the next component
1508 objSizeX, objSizeY = settingsPanelEditTool:GetSize()
1509
1510 local roctel = vgui.Create("DLabel", sp)
1511 local plht = "Execute this command if you close the menu:"
1512 roctel:SetText(plht)
1513 roctel:SetColor(Color(255,255,255,120))
1514 roctel:SizeToContents()
1515 roctel:SetPos(6, objPosY + objSizeY + 12)
1516
1517 objPosX, objPosY = roctel:GetPos() -- Used for placing the next component
1518 objSizeX, objSizeY = roctel:GetSize()
1519
1520 local roctel2 = vgui.Create("DLabel", sp)
1521 local plht2 = "Useful to change (back) to another preset."
1522 roctel2:SetText(plht2)
1523 roctel2:SetColor(Color(0,0,0,120))
1524 roctel2:SizeToContents()
1525 roctel2:SetPos(6, objPosY + objSizeY + 2)
1526
1527 objPosX, objPosY = roctel2:GetPos() -- Used for placing the next component
1528 objSizeX, objSizeY = roctel2:GetSize()
1529
1530 rocte = vgui.Create("DTextEntry", sp)
1531 rocte:SetPos(6, objPosY + objSizeY + 3)
1532 rocte:SetEnterAllowed(true)
1533 rocte:SetTall(16)
1534 rocte:SetValue( Radial.radialConfig["gbr-onclose"] or "" )
1535 rocte:SetWide(tabSizeX +8)
1536 rocte.focus = false
1537
1538 function rocte:Paint( w, h )
1539 local sx,sy = self:LocalToScreen(0,0)
1540 render.SetScissorRect( sx,sy, sx+w-20,sy+h, true )
1541 derma.SkinHook( "Paint", "TextEntry", self, w, h )
1542 render.SetScissorRect( sx,sy, sx+w-20,sy+h, false )
1543 surface.SetDrawColor(120,120,120,255)
1544 surface.DrawOutlinedRect(0,0, w-20, h)
1545 return false
1546 end
1547
1548 objPosX, objPosY = rocte:GetPos() -- Used for placing the next component
1549 objSizeX, objSizeY = rocte:GetSize()
1550
1551 function rocte:OnGetFocus()
1552 if Radial.radialConfig["gbr-onclose"] == "" then
1553 self:SetTextColor(Color(0,0,0))
1554 self:SetText("")
1555 end
1556
1557 end
1558 function rocte:OnLoseFocus()
1559 if Radial.radialConfig["gbr-onclose"] == "" then
1560 self:SetTextColor(Color(180,180,180))
1561 self:SetText("e.g. load_preset ...")
1562 end
1563 end
1564 rocte:OnLoseFocus()
1565 rocte.OnChange = function()
1566 Radial.radialConfig["gbr-onclose"] = rocte:GetValue()
1567 end
1568
1569 local function closeop()
1570 -- Recalculate radial menu layout
1571
1572 -- Save setup
1573 Radial.saveConfig()
1574 Radial.saveTools()
1575
1576 if IsValid(cpa) then
1577 cpa:Close()
1578 end
1579
1580 -- Close the settingsPanel
1581 Radial.ToolFindPanelInvisible()
1582 hook.Call("Radial.MenuClose",{})
1583 hook.Remove("PostRenderVGUI","drawdebug") --#
1584 settingsPanel:Close()
1585 Radial.settingsPanelShown = false
1586 Radial.CalculateMenuLayout()
1587
1588 clickedon = ""
1589 dragging = false
1590
1591 -- Disable mouse cursor
1592 gui.EnableScreenClicker(false)
1593
1594 -- Hide menu
1595 Radial.radialMenuOpen = false
1596
1597 end
1598
1599 --objPosX, objPosY = settingsPanelEditTool:GetPos() -- Used for placing the next component
1600
1601 -- Save and close button
1602 local settingsPanelCloseButton = vgui.Create("DButton", sp)
1603 settingsPanelCloseButton:SetText(" Close and Save ")
1604 settingsPanelCloseButton:SetSize(92, 22)
1605 settingsPanelCloseButton:SetPos(settingsPanelDelete:GetPos(), objPosY + objSizeY + 24)
1606 settingsPanelCloseButton.DoClick = function()
1607 closeop()
1608 end
1609 settingsPanel.btnClose.DoClick = function ( button )
1610 closeop()
1611 end
1612
1613 objPosX, objPosY = settingsPanelCloseButton:GetPos() -- Used for placing the next component
1614 objSizeX, objSizeY = settingsPanelCloseButton:GetSize()
1615
1616 objPosX2, objPosY2 = settingsPanelCloseButton:GetPos() -- Used for placing the next component
1617 objSizeX2, objSizeY2 = settingsPanelCloseButton:GetSize()
1618
1619 local closeL = vgui.Create("DLabel", sp)
1620 local plht3 = "The close button at the top has the same function."
1621 closeL:SetText(plht3)
1622 --closeL:SetDisabled(false)
1623 closeL:SetMouseInputEnabled( true )
1624 closeL:SetColor(Color(0,0,0,80))
1625 closeL:SizeToContents()
1626 function closeL:PaintOver()
1627 if self.Hovered then
1628 self:SetText("(and always had)")
1629 else
1630 self:SetText(plht3)
1631 end
1632 end
1633 closeL:SetPos(6, objPosY + objSizeY)
1634
1635 objPosX, objPosY = closeL:GetPos() -- Used for placing the next component
1636 objSizeX, objSizeY = closeL:GetSize()
1637
1638 local setinfo = vgui.Create("DImageButton", sp)
1639 // Set the material - relative to /materials/ directory
1640 setinfo:SetSize(16, 16)
1641 setinfo:SetImage("icon16/information.png")
1642 if Radial.radialConfig["gbr-showhelp"] == 0 then
1643 setinfo:SetColor(Color(150,80,80,255))
1644 else
1645 setinfo:SetColor(Color(200,200,200,255))
1646 end
1647 setinfo:SetPos(tabSizeX - 56, objPosY2)
1648 objSizeX, objSizeY = setinfo:GetSize()
1649 setinfo.DoClick = function()
1650 if Radial.radialConfig["gbr-showhelp"] == 1 then
1651 Radial.radialConfig["gbr-showhelp"] = 0
1652 setinfo:SetColor(Color(150,80,80,255))
1653 else
1654 Radial.radialConfig["gbr-showhelp"] = 1
1655 setinfo:SetColor(Color(200,200,200,255))
1656 end
1657 end
1658 setinfo.Think = function()
1659
1660 if Radial.radialConfig["gbr-showhelp"] == 0 then
1661 if setinfo.Hovered then
1662 setinfo:SetColor(Color(255,175,175,255))
1663 else
1664 setinfo:SetColor(Color(150,80,80,255))
1665 end
1666 else
1667 if setinfo.Hovered then
1668 setinfo:SetColor(Color(255,255,255,255))
1669 else
1670 setinfo:SetColor(Color(200,200,200,255))
1671 end
1672 end
1673 end
1674 --objPosX, objPosY = setinfo:GetPos()
1675
1676 local setsounds = vgui.Create("DImageButton", sp)
1677 // Set the material - relative to /materials/ directory
1678 setsounds:SetSize(32, 32)
1679 if Radial.radialConfig["gbr-enablesounds"] == 0 then
1680 setsounds:SetImage("icon32/muted.png")
1681 else
1682 setsounds:SetImage("icon32/unmuted.png")
1683 end
1684 setsounds:SetPos(tabSizeX - 32, objPosY2 - 8)
1685 objSizeX, objSizeY = setsounds:GetSize()
1686 setsounds.DoClick = function()
1687 if Radial.radialConfig["gbr-enablesounds"] == 1 then
1688 Radial.radialConfig["gbr-enablesounds"] = 0
1689 setsounds:SetImage("icon32/muted.png")
1690 else
1691 Radial.radialConfig["gbr-enablesounds"] = 1
1692 setsounds:SetImage("icon32/unmuted.png")
1693 end
1694 end
1695 setsounds.Think = function()
1696 if setsounds.Hovered then
1697 setsounds:SetColor(Color(255,255,255,255))
1698 else
1699 setsounds:SetColor(Color(200,200,200,255))
1700 end
1701 if Radial.radialConfig["gbr-enablesounds"] == 0 then
1702 setsounds:SetImage("icon32/muted.png")
1703 else
1704 setsounds:SetImage("icon32/unmuted.png")
1705 end
1706 end
1707 objPosX, objPosY = setsounds:GetPos()
1708 --end
1709
1710 --if true then --second tab
1711 local fl = vgui.Create( "DLabel" ,sp2)
1712 fl:SetPos( 6, 5 )
1713 fl:SetText("Font:")
1714 cb = vgui.Create( "DComboBox" ,sp2)
1715 cb:SetPos( 6, 25 )
1716 cb:SetSize( tabSizeX-14, 20 )
1717 cb:SetValue( Radial.radialConfig["gbr-font"] or "Arial" )
1718 cb.OnSelect = function(panel, index, value)
1719 Radial.radialConfig["gbr-font"] = value
1720 end
1721 cb.Think = function()
1722 cb:SetValue( Radial.radialConfig["gbr-font"] or "Arial" )
1723 end
1724 for i = 1, #fonts do //Make a loop to create a bunch of panels inside of the DIconLayout
1725 local id = cb:AddChoice( fonts[i] )
1726 end
1727 cb.OpenMenu = function( pControlOpener )
1728
1729 if ( pControlOpener ) then
1730 if ( pControlOpener == cb.TextEntry ) then
1731 return
1732 end
1733 end
1734 if ( #cb.Choices == 0 ) then return end
1735 if ( IsValid( cb.Menu ) ) then
1736 cb.Menu:Remove()
1737 cb.Menu = nil
1738 end
1739 cb.Menu = DermaMenu()
1740
1741 for k, v in pairs( cb.Choices ) do
1742 local option = cb.Menu:AddOption( v, function() cb:ChooseOption( v, k ) end )
1743 option:SetFont(v.."_work")--applying the fonts for a preview
1744 end
1745
1746 local x, y = cb:LocalToScreen( 0, cb:GetTall() )
1747
1748 cb.Menu:SetMinimumWidth( cb:GetWide() )
1749 cb.Menu:Open( x, y, false, cb )
1750
1751
1752 end
1753 objSizeX2, objSizeY2 = cb:GetSize()
1754 objPosX2, objPosY2 = cb:GetPos()
1755
1756 asy = vgui.Create("DCheckBoxLabel", sp2)
1757 asy:SetText("Correct Height")
1758 asy:SizeToContents()
1759 asy:SetPos(tabSizeX/2, objPosY2 + objSizeY2 + 4)
1760 asy:SetValue(Radial.radialConfig["gbr-clampy"])
1761 asy.OnChange = function()
1762 Radial.radialConfig["gbr-clampy"] = GetCheckedValue(asy)
1763 Radial.CalculateMenuLayout()
1764 end
1765
1766 asx = vgui.Create("DCheckBoxLabel", sp2)
1767 asx:SetText("Make Width Fit")
1768 asx:SizeToContents()
1769 asx:SetPos(6, objPosY2 + objSizeY2 + 2)
1770 asx:SetValue(Radial.radialConfig["gbr-clampx"])
1771 asx.OnChange = function()
1772 Radial.radialConfig["gbr-clampx"] = GetCheckedValue(asx)
1773 if Radial.radialConfig["gbr-clampx"] == 1 then
1774 asy:SetDisabled(false)
1775 else
1776 asy:SetDisabled(true)
1777 end
1778 Radial.CalculateMenuLayout()
1779 end
1780 objSizeX2, objSizeY2 = asx:GetSize()
1781 objPosX2, objPosY2 = asx:GetPos()
1782
1783 olt = vgui.Create("DCheckBoxLabel", sp2)
1784 olt:SetText("Draw Outlined Text")
1785 olt:SizeToContents()
1786 olt:SetPos(6, objPosY2 + objSizeY2 + 2)
1787 olt:SetValue(Radial.radialConfig["gbr-outline"])
1788 olt.OnChange = function()
1789 Radial.radialConfig["gbr-outline"] = GetCheckedValue(olt)
1790 if Radial.radialConfig["gbr-clampx"] == 1 then
1791 asy:SetDisabled(false)
1792 else
1793 asy:SetDisabled(true)
1794 end
1795 Radial.CalculateMenuLayout()
1796 end
1797 if Radial.radialConfig["gbr-clampx"] == 1 then
1798 asy:SetDisabled(false)
1799 else
1800 asy:SetDisabled(true)
1801 end
1802 -- Rotate text?
1803 settingsPanelRotateText = vgui.Create("DCheckBoxLabel", sp2)
1804 settingsPanelRotateText:SetText("Rotate Text")
1805 settingsPanelRotateText:SizeToContents()
1806 settingsPanelRotateText:SetPos(tabSizeX/2, objPosY2 + objSizeY2 + 2)
1807 settingsPanelRotateText:SetValue(Radial.radialConfig["gbr-rotatetext"])
1808 settingsPanelRotateText.OnChange = function()
1809 Radial.radialConfig["gbr-rotatetext"] = GetCheckedValue(settingsPanelRotateText)
1810 Radial.CalculateMenuLayout()
1811 end
1812
1813 objSizeX2, objSizeY2 = olt:GetSize()
1814 objPosX2, objPosY2 = olt:GetPos()
1815
1816 scs = vgui.Create("DNumSlider", sp2)
1817 scs:SetText("Scale")
1818 scs:SetPos(6, objPosY2 + objSizeY2 + 2)
1819 scs:SetSize(settingsSizeX - 12, objSizeY2)
1820 scs:SetMinMax(0.1, 2)
1821 scs:SetDecimals(2)
1822 scs:SetValue(Radial.radialConfig["gbr-fontscale"])
1823 scs.OnValueChanged = function()
1824 Radial.radialConfig["gbr-fontscale"] = scs:GetValue()
1825 scs.Slider:SetSlideX( scs.Scratch:GetFraction() )
1826 Radial.CalculateMenuLayout()
1827 end
1828 scs.TextArea:SetDrawBackground( true )
1829 scs.TextArea:SetWide(scs.TextArea:GetWide()+20)
1830 function scs.TextArea:Paint( w, h )
1831 local sx,sy = self:LocalToScreen(0,0)
1832 render.SetScissorRect( sx,sy, sx+w-20,sy+h, true )
1833 derma.SkinHook( "Paint", "TextEntry", self, w, h )
1834 render.SetScissorRect( sx,sy, sx+w-20,sy+h, false )
1835 surface.SetDrawColor(120,120,120,255)
1836 surface.DrawOutlinedRect(0,0, w-20, h)
1837 return false
1838 end
1839
1840 objSizeX2, objSizeY2 = scs:GetSize()
1841 objPosX2, objPosY2 = scs:GetPos()
1842
1843 local hc = vgui.Create( "DLabel" ,sp2)
1844 hc:SetPos( 6, objPosY2 + objSizeY2 + 40 )
1845 hc:SetText("Highlight Color:")
1846 hc:SizeToContents()
1847
1848 objSizeX2, objSizeY2 = hc:GetSize()
1849 objPosX2, objPosY2 = hc:GetPos()
1850
1851 cp = vgui.Create( "DColorMixer", sp2 )
1852 cp:SetPos( 6,objPosY2 + objSizeY2 + 2 )
1853 cp:SetSize(settingsSizeX - 12,100)
1854 cp:SetPalette( false )
1855 cp:SetAlphaBar( true )
1856 cp:SetColor( Color( Radial.radialConfig["gbr-hr"],Radial.radialConfig["gbr-hg"],Radial.radialConfig["gbr-hb"],Radial.radialConfig["gbr-ha"] ) )
1857 cp.Think = function()
1858 Radial.radialConfig["gbr-hr"] = cp.m_Color.r
1859 Radial.radialConfig["gbr-hg"] = cp.m_Color.g
1860 Radial.radialConfig["gbr-hb"] = cp.m_Color.b
1861 Radial.radialConfig["gbr-ha"] = cp.m_Color.a
1862 end
1863 objSizeX2, objSizeY2 = cp:GetSize()
1864 objPosX2, objPosY2 = cp:GetPos()
1865
1866 local dc = vgui.Create( "DLabel" ,sp2)
1867 dc:SetPos( 6, objPosY2 + objSizeY2 + 20 )
1868 dc:SetText("Default Color:")
1869 dc:SizeToContents()
1870
1871 objSizeX2, objSizeY2 = dc:GetSize()
1872 objPosX2, objPosY2 = dc:GetPos()
1873
1874 dp = vgui.Create( "DColorMixer", sp2 )
1875 dp:SetPos( 6,objPosY2 + objSizeY2 + 2 )
1876 dp:SetSize(settingsSizeX - 12,100)
1877 dp:SetPalette( false )
1878 dp:SetAlphaBar( true )
1879 dp:SetColor( Color( Radial.radialConfig["gbr-dr"],Radial.radialConfig["gbr-dg"],Radial.radialConfig["gbr-db"],Radial.radialConfig["gbr-da"] ) )
1880 dp.Think = function()
1881 Radial.radialConfig["gbr-dr"] = dp.m_Color.r
1882 Radial.radialConfig["gbr-dg"] = dp.m_Color.g
1883 Radial.radialConfig["gbr-db"] = dp.m_Color.b
1884 Radial.radialConfig["gbr-da"] = dp.m_Color.a
1885 end
1886 objSizeX2, objSizeY2 = dp:GetSize()
1887 objPosX2, objPosY2 = dp:GetPos()
1888
1889 local tcl = vgui.Create( "DLabel" ,sp2)
1890 tcl:SetPos( 6, objPosY2 + objSizeY2 + 20 )
1891 tcl:SetText("Text Color:")
1892 tcl:SizeToContents()
1893
1894 objSizeX2, objSizeY2 = tcl:GetSize()
1895 objPosX2, objPosY2 = tcl:GetPos()
1896
1897 tc = vgui.Create( "DColorMixer", sp2 )
1898 tc:SetPos( 6,objPosY2 + objSizeY2 + 2 )
1899 tc:SetSize(settingsSizeX - 12,100)
1900 tc:SetPalette( false )
1901 tc:SetAlphaBar( true )
1902 tc:SetColor( Color( Radial.radialConfig["gbr-tr"],Radial.radialConfig["gbr-tg"],Radial.radialConfig["gbr-tb"],Radial.radialConfig["gbr-ta"] ) )
1903 tc.Think = function()
1904 Radial.radialConfig["gbr-tr"] = tc.m_Color.r
1905 Radial.radialConfig["gbr-tg"] = tc.m_Color.g
1906 Radial.radialConfig["gbr-tb"] = tc.m_Color.b
1907 Radial.radialConfig["gbr-ta"] = tc.m_Color.a
1908 end
1909 objSizeX2, objSizeY2 = tc:GetSize()
1910 objPosX2, objPosY2 = tc:GetPos()
1911
1912 ccs = vgui.Create("DNumSlider", sp2)
1913 ccs:SetText("Color Changing Speed")
1914 ccs:SetPos(6, objPosY2 + objSizeY2 + 30 )
1915 ccs:SetSize(settingsSizeX - 12, 20)
1916 ccs:SetMinMax(0.05, 1)
1917 ccs:SetDecimals(2)
1918 ccs:SetValue(Radial.radialConfig["gbr-colorspeed"])
1919 ccs.OnValueChanged = function()
1920 Radial.radialConfig["gbr-colorspeed"] = ccs:GetValue()
1921 --ccs.Slider:SetSlideX( scs.Scratch:GetFraction() )
1922 Radial.CalculateMenuLayout()
1923 end
1924 ccs.TextArea:SetDrawBackground( true )
1925 ccs.TextArea:SetWide(ccs.TextArea:GetWide()+20)
1926 function ccs.TextArea:Paint( w, h )
1927 local sx,sy = self:LocalToScreen(0,0)
1928 render.SetScissorRect( sx,sy, sx+w-20,sy+h, true )
1929 derma.SkinHook( "Paint", "TextEntry", self, w, h )
1930 render.SetScissorRect( sx,sy, sx+w-20,sy+h, false )
1931 surface.SetDrawColor(120,120,120,255)
1932 surface.DrawOutlinedRect(0,0, w-20, h)
1933 return false
1934 end
1935
1936 objSizeX2, objSizeY2 = ccs:GetSize()
1937 objPosX2, objPosY2 = ccs:GetPos()
1938
1939
1940 ans = vgui.Create("DNumSlider", sp2)
1941 ans:SetText("Animation Speed")
1942 ans:SetPos(6, objPosY2 + objSizeY2 + 4)
1943 ans:SetSize(settingsSizeX - 12, objSizeY2)
1944 ans:SetMinMax(0.05, 1)
1945 ans:SetDecimals(2)
1946 ans:SetValue(Radial.radialConfig["gbr-animspeed"])
1947 ans.OnValueChanged = function()
1948 Radial.radialConfig["gbr-animspeed"] = ans:GetValue()
1949 --ans.Slider:SetSlideX( scs.Scratch:GetFraction() )
1950 Radial.CalculateMenuLayout()
1951 end
1952 ans.TextArea:SetDrawBackground( true )
1953 ans.TextArea:SetWide(ans.TextArea:GetWide()+20)
1954 function ans.TextArea:Paint( w, h )
1955 local sx,sy = self:LocalToScreen(0,0)
1956 render.SetScissorRect( sx,sy, sx+w-20,sy+h, true )
1957 derma.SkinHook( "Paint", "TextEntry", self, w, h )
1958 render.SetScissorRect( sx,sy, sx+w-20,sy+h, false )
1959 surface.SetDrawColor(120,120,120,255)
1960 surface.DrawOutlinedRect(0,0, w-20, h)
1961 return false
1962 end
1963
1964 objSizeX2, objSizeY2 = ans:GetSize()
1965 objPosX2, objPosY2 = ans:GetPos()
1966 --end
1967
1968 --if true then --third tab
1969
1970 local pl = vgui.Create( "DLabel" ,sp3)
1971 pl:SetColor(Color(220,220,220,255))
1972 pl:SetPos( 6, 5 )
1973 pl:SetText("Presets:")
1974
1975 local prl = vgui.Create( "DScrollPanel", sp3 )
1976
1977 function prl:PerformLayout()
1978 local Wide = self:GetWide()
1979 local YPos = 0
1980
1981 self:Rebuild()
1982
1983 self.VBar:SetUp( self:GetTall(), self.pnlCanvas:GetTall() )
1984 YPos = self.VBar:GetOffset()
1985
1986 self.pnlCanvas:SetPos( 0, YPos )
1987 self.pnlCanvas:SetWide( Wide )
1988
1989 self:Rebuild()
1990 end
1991
1992 prl.VBar.Paint = function() end
1993 function prl.VBar.btnUp:Paint()
1994 local w, h = self:GetSize()
1995 if self.Depressed then
1996 surface.SetDrawColor(Color(255,255,255,180))
1997 elseif self.Hovered then
1998 surface.SetDrawColor(Color(0,255,255,180))
1999 else
2000 surface.SetDrawColor(Color(50,50,50,180))
2001 end
2002 surface.DrawLine(w-1,0,w-1,h)
2003 surface.DrawLine(w-2,0,w-5,0)
2004 end
2005 function prl.VBar.btnDown:Paint()
2006 local w, h = self:GetSize()
2007 if self.Depressed then
2008 surface.SetDrawColor(Color(255,255,255,180))
2009 elseif self.Hovered then
2010 surface.SetDrawColor(Color(0,255,255,180))
2011 else
2012 surface.SetDrawColor(Color(50,50,50,180))
2013 end
2014 surface.DrawLine(w-1,0,w-1,h)
2015 surface.DrawLine(w-2,h-1,w-5,h-1)
2016 end
2017 function prl.VBar.btnGrip:Paint()
2018 local w, h = self:GetSize()
2019 if self.Depressed then
2020 surface.SetDrawColor(Color(255,255,255,180))
2021 elseif self.Hovered then
2022 surface.SetDrawColor(Color(0,255,255,180))
2023 else
2024 surface.SetDrawColor(Color(50,50,50,180))
2025 end
2026 surface.DrawLine(w-1,0,w-1,h)
2027 end
2028 prl:SetSize( tabSizeX-14, 250 )
2029 prl:SetPos( 6, 25 )
2030 prl.Paint = function()
2031 local w, h = prl:GetSize()
2032 surface.SetTexture(surface.GetTextureID("gui/gradient"))
2033 surface.SetDrawColor(Color(255,255,255,180))
2034 surface.DrawTexturedRect(1,1,w-2,h-2)
2035 surface.SetDrawColor(Color(50,50,50,180))
2036 surface.DrawLine(0,0,0,h)
2037 surface.DrawLine(1,0,5,0)
2038 surface.DrawLine(1,h-1,5,h-1)
2039 end
2040
2041 local pList = vgui.Create( "DIconLayout", prl ) //Create the DIconLayout and put it inside of the Scroll Panel.
2042 local sx, sy = prl:GetSize()
2043 pList:SetSize( sx, sy )
2044 pList:SetPos( 0, 0 )
2045 pList:SetSpaceY( 5 )
2046 pList:SetSpaceX( 5 )
2047 pList:SetBorder(10)
2048 local prn = vgui.Create("DTextEntry", sp3)
2049 local savepre = vgui.Create("DButton", sp3)
2050
2051 local mat_preset = Material("icon16/brick.png")
2052 local mat_sett = Material("icon16/cog.png")
2053 local mat_tools = Material("icon16/wrench.png")
2054 local mat_skin = Material("icon16/palette.png")
2055
2056 local function paintkinsettings(x,y,tab,lft)
2057 surface.SetFont("DermaDefaultBold")
2058
2059 surface.SetDrawColor( 255, 255, 255, 255 )
2060 surface.SetMaterial(mat_skin)
2061 surface.DrawTexturedRect(x,y,16,16)
2062 surface.SetTextPos(18+x,y)
2063
2064 surface.SetTextColor(Color(255,255,255,100))
2065 surface.DrawText("[")
2066
2067 for i,k in ipairs(Radial.skinbutorder) do
2068 local v = tab[k]
2069
2070 if i == 8 then
2071 surface.DrawText(" ")
2072 end
2073
2074 if v != nil and type(v) != "string" then
2075 if type(v) == "table" then
2076 if v[1] then
2077 surface.SetTextColor(Color(0,200,0,80))
2078 surface.DrawText("Y")
2079 else
2080 surface.SetTextColor(Color(80,80,80,170))
2081 surface.DrawText("N")
2082 end
2083 elseif v then
2084 surface.SetTextColor(Color(0,200,0,80))
2085 surface.DrawText("Y")
2086 else
2087 surface.SetTextColor(Color(80,80,80,170))
2088 surface.DrawText("N")
2089 end
2090 end
2091 end
2092
2093 surface.SetTextColor(Color(255,255,255,100))
2094 surface.DrawText("]")
2095 end
2096
2097 function Radial.refreshpresetslist()
2098 pList:Clear()
2099 local ch = 0
2100 for k,v in pairs(Radial.radialToolPresets) do
2101 if k ~= "____last" then
2102 ch = ch + 1
2103 local ppr = pList:Add( "DPanel" )
2104 local delb = vgui.Create( "DButton", ppr )
2105 local hassettings = (v.s ~= {} and v.s ~= nil and v.s["gbr-font"] ~= nil)
2106 local isskin = hassettings and (v.s["isskin"] ~= nil and v.s["isskin"] == true) or false
2107 local hastools = (v.t ~= {} and v.t ~= nil and v.t[1] ~= nil)
2108 local add = 0
2109 if hassettings and hastools then
2110 add = 9
2111 surface.SetFont( v.s["gbr-font"].."_work" )
2112 elseif hassettings then
2113 add = 9
2114 surface.SetFont( "DermaDefault" )
2115 else
2116 add = 5
2117 surface.SetFont( "DermaDefault" )
2118 end
2119 local tx,ty = surface.GetTextSize(k)
2120 add = add + ty
2121 ppr:SetSize(pList:GetSize()-32 , 20+add)
2122 ppr.Depressed = false
2123 ppr.DepressedR = false
2124 ppr.Think = function()
2125 local lpr = ppr.Depressed
2126 if ppr.Hovered and input.IsMouseDown(MOUSE_LEFT) then
2127 ppr.Depressed = true
2128 elseif not input.IsMouseDown(MOUSE_LEFT) then
2129 ppr.Depressed = false
2130 end
2131
2132 local lprr = ppr.DepressedR
2133 if ppr.Hovered and input.IsMouseDown(MOUSE_RIGHT) then
2134 ppr.DepressedR = true
2135 elseif not input.IsMouseDown(MOUSE_RIGHT) then
2136 ppr.DepressedR = false
2137 end
2138
2139 if Radial.radialConfig["loaded_preset"] == k and Radial.radialConfig["loaded_preset"] ~= "" then
2140 ppr.dcol = {r = 130, g = 205, b = 162, a = 255}
2141 else
2142 ppr.dcol = {r = 50, g = 50, b = 50, a = 255}
2143 end
2144
2145 if ppr.Hovered and lprr ~= ppr.DepressedR and not ppr.DepressedR then
2146 prn:SetText(k)
2147 prn:OnTextChanged()
2148 savepre:SetDisabled( false )
2149 ppr.col = {r = 50, g = 200, b = 150, a = 255}
2150 end
2151
2152 if ppr.Hovered and lpr ~= ppr.Depressed and not ppr.Depressed then
2153 Radial.loadradialpreset(k)
2154
2155 if Radial.SkinSettings and Radial.SkinSettings:IsValid() then
2156 Radial.SkinSettings:Remove()
2157 Radial.ToggleSkinSettingsMenu()
2158 end
2159 ppr.col = {r = 0, g = 255, b = 255, a = 255}
2160 end
2161 end
2162 ppr.dcol = {r = 50, g = 50, b = 50, a = 255}
2163 ppr.col = {r = 50, g = 50, b = 50, a = 255}
2164 local w, h = ppr:GetSize()
2165
2166 local count = v.t != nil and #v.t or 0
2167
2168 ppr.Paint = function()
2169 ppr.col.r = Lerp(0.05,ppr.col.r,ppr.dcol.r)
2170 ppr.col.g = Lerp(0.05,ppr.col.g,ppr.dcol.g)
2171 ppr.col.b = Lerp(0.05,ppr.col.b,ppr.dcol.b)
2172 ppr.col.a = Lerp(0.05,ppr.col.a,ppr.dcol.a)
2173 surface.SetDrawColor(Color(ppr.col.r,ppr.col.g,ppr.col.b,ppr.col.a))
2174 surface.DrawRect(2,2,w-4,h-4)
2175 if hassettings then
2176 surface.SetTexture(surface.GetTextureID("gui/center_gradient"))
2177 local wd = w/2.6
2178 surface.SetDrawColor(Color(v.s["gbr-dr"],v.s["gbr-dg"],v.s["gbr-db"],255))
2179 surface.DrawTexturedRect(3,h-9,wd,3)
2180 surface.SetDrawColor(Color(v.s["gbr-tr"],v.s["gbr-tg"],v.s["gbr-tb"],255))
2181 surface.DrawTexturedRect(w-3-wd,h-9,wd,3)
2182 surface.SetDrawColor(Color(v.s["gbr-hr"],v.s["gbr-hg"],v.s["gbr-hb"],255))
2183 surface.DrawTexturedRect(w/2-wd/2,h-9,wd,3)
2184
2185 surface.SetDrawColor(Color(v.s["gbr-dr"],v.s["gbr-dg"],v.s["gbr-db"],v.s["gbr-da"]))
2186 surface.DrawTexturedRect(3,h-9,wd,6)
2187 surface.SetDrawColor(Color(v.s["gbr-tr"],v.s["gbr-tg"],v.s["gbr-tb"],v.s["gbr-ta"]))
2188 surface.DrawTexturedRect(w-3-wd,h-9,wd,6)
2189 surface.SetDrawColor(Color(v.s["gbr-hr"],v.s["gbr-hg"],v.s["gbr-hb"],v.s["gbr-ha"]))
2190 surface.DrawTexturedRect(w/2-wd/2,h-9,wd,6)
2191 end
2192
2193 if hassettings and hastools then
2194 surface.SetFont( v.s["gbr-font"].."_work" )
2195 surface.SetTextColor( 100, 255, 208, 255 )
2196 else
2197 surface.SetFont("DermaDefault" )
2198 surface.SetTextColor( 255, 255, 255, 255 )
2199 end
2200 local tx,ty = surface.GetTextSize(k)
2201 surface.SetTextPos( 6, 3 )
2202 surface.DrawText( k )
2203
2204 surface.SetDrawColor( 255, 255, 255, 255 )
2205 if isskin then
2206 surface.SetMaterial(mat_skin)
2207 elseif hassettings and hastools then
2208 surface.SetMaterial(mat_preset)
2209 elseif hastools then
2210 surface.SetMaterial(mat_tools)
2211 else
2212 surface.SetMaterial(mat_sett)
2213 end
2214 surface.DrawTexturedRect(8,4+ty,16,16)
2215
2216 surface.SetFont("DermaDefault" )
2217 surface.SetTextColor( 255, 255, 255, 255 )
2218 surface.SetTextPos( 26, 4+ty )
2219 local txt = ""
2220 if hastools then
2221 local s = "s"
2222 if count == 1 then s = "" end
2223 txt = count.." Shortcut"..s
2224 elseif isskin then
2225 txt = "Skin"
2226 else
2227 txt = "Settings"
2228 end
2229 surface.DrawText( txt )
2230 local px,_ = surface.GetTextSize(txt)
2231 if v.s and not isskin then if v.s["gbr-skinvars"] != nil then paintkinsettings(30+px,4+ty,v.s["gbr-skinvars"], true) end end
2232
2233 if ppr.Depressed then
2234 surface.SetDrawColor(Color(255,255,255,180))
2235 elseif ppr.Hovered or delb.Hovered then
2236 surface.SetDrawColor(Color(0,255,255,180))
2237 else
2238 surface.SetDrawColor(Color(50,50,50,180))
2239 end
2240 surface.DrawLine(0,0,0,h)
2241 surface.DrawLine(1,0,5,0)
2242 surface.DrawLine(1,h-1,5,h-1)
2243 surface.DrawLine(w-1,0,w-1,h)
2244 surface.DrawLine(w-2,0,w-6,0)
2245 surface.DrawLine(w-2,h-1,w-6,h-1)
2246 end
2247
2248 delb.ct = 0
2249 delb.rot = 0
2250 delb.conf = 0
2251 delb:SetPos( w-34, 2 )
2252 delb:SetSize( 32, 32 )
2253 delb:SetText("")
2254 delb.DoClick = function()
2255 if delb.conf == 0 then
2256 delb.conf = 1
2257 delb.ct = CurTime()+ 2.4
2258 elseif delb.conf == 1 and delb.rot >= 88 then
2259 Radial.radialToolPresets[k] = nil
2260 Radial.refreshpresetslist()
2261 Radial.savePresets()
2262 end
2263 end
2264 delb.lh = false
2265 delb.Think = function()
2266 delb.rot = Lerp(0.12, delb.rot, 90*delb.conf)
2267
2268 local lh = delb.lh
2269 delb.lh = delb.Hovered
2270
2271 if delb.conf >= 1 and ((delb.ct < CurTime() and delb.ct ~= 0) or (lh and not delb.lh)) then
2272 delb.ct = 0
2273 delb.conf = 0
2274 end
2275 end
2276 delb.Paint = function()
2277 surface.SetTexture(surface.GetTextureID("gui/close_32"))
2278 if delb.rot >= 88 then
2279 surface.SetDrawColor(Color(255,0,0,255))
2280 else
2281 local add = 0
2282 if delb.Hovered then add = 50 end
2283 local gb = (100+add)-((100+add)*(delb.rot/90))
2284 surface.SetDrawColor(Color(105*(delb.rot/90)+100+add,gb,gb,180))
2285 end
2286 surface.DrawTexturedRectRotated(29,3,32,32,delb.rot)
2287 end
2288 end
2289 end
2290 local ppr2 = pList:Add( "DLabel" )
2291 ppr2:SetColor(Color(0,0,0,255))
2292 local ppr = vgui.Create("DLabel", ppr2)
2293 ppr:SetPos(-1,-1)
2294 if ch == 1 then
2295 ppr:SetText(" "..ch.." Preset Available")
2296 ppr2:SetText(" "..ch.." Preset Available")
2297 elseif ch == 0 then
2298 ppr:SetText(" No Presets Available")
2299 ppr2:SetText(" No Presets Available")
2300 else
2301 ppr:SetText(" "..ch.." Presets Available")
2302 ppr2:SetText(" "..ch.." Presets Available")
2303 end
2304 ppr:SetSize(200,22)
2305 ppr2:SetSize(200,22)
2306 end
2307 Radial.refreshpresetslist()
2308
2309 local descl = vgui.Create("DLabel", sp3)
2310 descl:SetColor(Color(220,220,220,255))
2311 descl:SetText("Save Preset")
2312 descl:SizeToContents()
2313 objSizeX3, objSizeY3 = descl:GetSize()
2314 descl:SetPos(tabSizeX/2 - objSizeX3/2, 280)
2315
2316 objPosX3, objPosY3 = descl:GetPos()
2317 objSizeX3, objSizeY3 = descl:GetSize()
2318
2319 local lan = vgui.Create("DLabel", sp3)
2320 lan:SetColor(Color(220,220,220,255))
2321 lan:SetText("Name: ")
2322 lan:SizeToContents()
2323 lan:SetPos(6, objPosY3 + objSizeY3 + 3)
2324
2325 objPosX3, objPosY3 = lan:GetPos()
2326 objSizeX3, objSizeY3 = lan:GetSize()
2327
2328 prn:SetPos(8+objSizeX3, objPosY3)
2329 prn:SetEnterAllowed(true)
2330 prn:SetTall(16)
2331 prn:SetWide(tabSizeX - 16 - objSizeX3)
2332
2333 function prn:OnKeyCodeTyped(code)
2334 return 0
2335 end
2336
2337 prn.OnTextChanged = function()
2338 local car = prn:GetCaretPos()
2339 local txt = string.lower(prn:GetValue())
2340 prn:SetText(txt)
2341 prn:RequestFocus()
2342 prn:SetCaretPos(car)
2343 savepre:SetDisabled( txt == "" or txt == nil )
2344
2345 if txt == "____last" then
2346 prn.m_colText = Color(255,0,0,255)
2347 elseif Radial.radialToolPresets[txt] ~= nil then
2348 prn.m_colText = Color(255,150,0,255)
2349 else
2350 prn.m_colText = Color(0,0,0,255)
2351 end
2352 end
2353 savepre:SetDisabled( txt == "" or txt == nil )
2354
2355 local chs = vgui.Create("DCheckBoxLabel", sp3)
2356 local chs_s = vgui.Create("DCheckBoxLabel", sp3)
2357 local chs_skin = vgui.Create("DCheckBoxLabel", sp3)
2358
2359 chs:SetText("Save Settings")
2360 chs:SizeToContents()
2361 chs:SetPos(8+objSizeX3, objPosY3 + objSizeY3 + 8)
2362 chs:SetValue(Radial.radialConfig["save_custom"])
2363 chs.OnChange = function()
2364 Radial.radialConfig["save_custom"] = GetCheckedValue(chs)
2365 if Radial.radialConfig["save_custom"] == 1 then
2366
2367 else
2368 if Radial.radialConfig["save_tools"] != 1 then
2369 Radial.radialConfig["save_tools"] = 1
2370 chs_s:SetValue(Radial.radialConfig["save_tools"])
2371 end
2372 end
2373 end
2374
2375 chs_s:SetText("Save Shortcuts")
2376 chs_s:SizeToContents()
2377 chs_s:SetPos(8+objSizeX3, objPosY3 + objSizeY3 + 28)
2378 chs_s:SetValue(Radial.radialConfig["save_tools"])
2379 chs_s.OnChange = function()
2380 Radial.radialConfig["save_tools"] = GetCheckedValue(chs_s)
2381 if Radial.radialConfig["save_tools"] == 1 then
2382
2383 else
2384 if Radial.radialConfig["save_custom"] != 1 then
2385 Radial.radialConfig["save_custom"] = 1
2386 chs:SetValue(Radial.radialConfig["save_custom"])
2387 end
2388 end
2389 end
2390
2391 chs_skin:SetText("Save as Skin")
2392 chs_skin:SizeToContents()
2393 chs_skin:SetPos(8+objSizeX3, objPosY3 + objSizeY3 + 48)
2394 chs_skin:SetValue(Radial.radialConfig["save_skin"])
2395 chs_skin.OnChange = function()
2396 Radial.radialConfig["save_skin"] = GetCheckedValue(chs_skin)
2397
2398 if Radial.radialConfig["save_skin"] == 1 then
2399 chs:SetDisabled(true)
2400 chs_s:SetDisabled(true)
2401
2402 chs:SetChecked( false )
2403 chs_s:SetChecked( false )
2404 else
2405 chs:SetDisabled(false)
2406 chs_s:SetDisabled(false)
2407
2408 chs:SetValue(Radial.radialConfig["save_custom"])
2409 chs_s:SetValue(Radial.radialConfig["save_tools"])
2410 end
2411 end
2412
2413 chs_skin_Settings = vgui.Create("DButton",sp3)
2414 chs_skin_Settings:SetText("Skin Settings")
2415 --chs_skin_Settings:SizeToContents()
2416 chs_skin_Settings:SetPos(objSizeX3 +100, objPosY3 + objSizeY3 + 48)
2417 chs_skin_Settings:SetSize(66,15)
2418 function chs_skin_Settings:DoClick() Radial.ToggleSkinSettingsMenu() end
2419 function chs_skin_Settings:PaintOver(w,h)
2420 if Radial.SkinSettings and Radial.SkinSettings:IsValid() then
2421 surface.SetDrawColor(255,0,0,100)
2422 surface.DrawRect(0,0,w,h)
2423 end
2424 end
2425
2426 --Radial.ToggleSkinSettingsMenu()
2427 chs:OnChange() //for the check
2428 chs_skin:OnChange() //for disabling the buttons
2429 objPosY3 = objPosY3 +40
2430
2431 function but_savepresets()
2432 local txt = string.lower(prn:GetValue())
2433 if txt == "" or txt == nil then return end
2434
2435 if Radial.radialConfig["save_custom"] ~= 1 and Radial.radialConfig["save_tools"] ~= 1 and Radial.radialConfig["save_skin"] ~= 1 then return end
2436
2437 if txt == "____last" then
2438 prn:SetText("You Can't Touch This") --reserved for restoring the last used preset
2439 surface.PlaySound( "radial/1.mp3" ) --because why not?!
2440 prn.m_colText = Color(0,0,0,255)
2441 return
2442 end
2443
2444 if Radial.radialConfig["gbr-enablesounds"] == 1 then
2445 surface.PlaySound("garrysmod/content_downloaded.wav")
2446 end
2447
2448 Radial.radialToolPresets[txt] = {}
2449
2450
2451 if Radial.radialConfig["save_custom"] == 1 or Radial.radialConfig["save_skin"] == 1 then
2452 Radial.radialToolPresets[txt].s = table.Copy(Radial.radialConfig)
2453 Radial.radialToolPresets[txt].s["isskin"] = Radial.radialConfig["save_skin"] == 1 and true or false
2454 end
2455
2456 if Radial.radialConfig["save_tools"] == 1 and Radial.radialConfig["save_skin"] != 1 then
2457 Radial.radialToolPresets[txt].t = table.Copy(Radial.radialConfigTools)
2458 end
2459
2460 prn:SetText("")
2461 savepre:SetDisabled( txt == "" or txt == nil )
2462
2463 Radial.refreshpresetslist()
2464 Radial.savePresets()
2465 end
2466
2467 savepre.conf = 0
2468 savepre.ct = 0
2469 savepre:SetText("Save")
2470 savepre:SetPos(8+objSizeX3, objPosY3 + objSizeY3 +28)
2471 savepre:SetSize(93, 20)
2472 savepre.DoClick = function()
2473 local txt = string.lower(prn:GetValue())
2474 if Radial.radialToolPresets[txt] ~= nil then
2475 savepre.conf = savepre.conf + 1
2476 if savepre.conf == 1 then
2477 if Radial.radialConfig["gbr-enablesounds"] == 1 then
2478 surface.PlaySound("garrysmod/ui_click.wav")
2479 end
2480 savepre:SetText("Confirm")
2481 savepre.ct = CurTime() + 1.2
2482 elseif savepre.conf >= 2 then
2483 savepre.ct = 0
2484 savepre.conf = 0
2485 savepre:SetText("Save")
2486 but_savepresets()
2487 else
2488 savepre:SetText("Save")
2489 end
2490 else
2491 savepre:SetText("Save")
2492 but_savepresets()
2493 end
2494 end
2495 savepre.PaintOver = function(self,w,h)
2496 if savepre.ct < CurTime() and savepre.ct ~= 0 then
2497 savepre.ct = 0
2498 savepre.conf = 0
2499 savepre:SetText("Save")
2500 end
2501
2502 surface.DisableClipping(true)
2503 paintkinsettings(0,h+2,Radial.radialConfig["gbr-skinvars"],true)
2504 surface.DisableClipping(false)
2505 end
2506
2507 local cr = vgui.Create("DLabel", sp3)
2508 cr:SetText([[Click a preset to apply.
2509Rightclick selects the name for overwriting.
2510Create by typing a name and hit save.
2511If the name turns orange it means you're
2512about to overwrite an existing preset.
2513If presets without saved customisations are loaded
2514they will use the current settings without overwriting.
2515Click the upper right-hand corner
2516of a preset to request a delete.
2517If it turned red confirm by clicking again.
2518
2519Save Settings: Saves all Settings made in the menu
2520 but the Shortcuts.
2521Save Shortcuts: Saves the Shortcuts only.
2522Save as Skin: Saves the Settings but loads
2523 only specific Settings.
2524]])
2525 cr:SizeToContents()
2526 cr:SetColor(Color(180,220,220,220))
2527 cr:SetPos(6, objPosY3 + objSizeY3 +80)
2528
2529
2530 /*local disc = vgui.Create("DLabel", sp3)
2531 disc:SetText("This is BETA. It doing it's job but maybe it causes errors\nI didn't find yet. Also it's not quite optimized.")
2532 disc:SizeToContents()
2533 disc:SetPos(6, settingsSizeY-36)
2534 */
2535
2536
2537
2538 --end
2539
2540 --if true then --fourth tab
2541 local cr = vgui.Create("DLabel", sp4)
2542 cr:SetText("Hello "..LocalPlayer():Name()..[[,
2543and thank you for using this mod.
2544If you like it please give it a thumbs up
2545as I'm collecting for the achievements.
2546If not tell me what I could improve.
2547Either way please give me feedback if you feel like it.
2548I'm making it for the community so your feedback got
2549a somewhat high chance to take effect.
2550Examples:
2551-Adding Weapons (Hyper-Sniper)
2552-Opening the right tool in the toolsmenu (-|Sparky|-)
2553-Presets (Zero)
2554-Animated menu (and more!) (Metamist made this update)
2555-Per-Shortcut-Color ([PDi] Minolo)
2556-Using Toolsearch to switch tools (Walas)
2557-rotating the menu (Teh Engineer)
2558-binding keys to a specific preset (mundy.)
2559-being able to adjust opacity (Sgt.Panda)
2560-and lots of bugs reported by many people
2561-<here could be your suggestion>]])
2562 cr:SizeToContents()
2563 cr:SetColor(Color(255,255,255,120))
2564 cr:SetPos(6, 20)
2565
2566 local cr2 = vgui.Create("DLabel", sp4)
2567 cr2:SetText("[Overhaul by "..string.Replace(steamworks.GetPlayerName( iuke ),"[unknown]", "Uke").."]")
2568 cr2:SizeToContents()
2569 cr2:SetPos(6, settingsSizeY-160)
2570 cr2.ct = 0
2571
2572 local cr3 = vgui.Create("DLabel", sp4)
2573 cr3:SetText("\n\nMore Credits (chronological):\n\nOriginally created by "..string.Replace(steamworks.GetPlayerName( ifly ),"[unknown]", "GB.FlyveHest").." in 2008.")
2574 cr3:SizeToContents()
2575 cr3:SetPos(6, settingsSizeY-160)
2576
2577 local cr4 = vgui.Create("DLabel", sp4)
2578 cr4:SetText("\n\n\n\n\nTaken over by "..string.Replace(steamworks.GetPlayerName( icma ),"[unknown]", "Cmasta").." in 2010.")
2579 cr4:SizeToContents()
2580 cr4:SetPos(6, settingsSizeY-160)
2581
2582 local cr5 = vgui.Create("DLabel", sp4)
2583 cr5:SetText("\n\n\n\n\n\nAnd finally the GMod13 port by "..string.Replace(steamworks.GetPlayerName( iddr ),"[unknown]", "DeltaDesignRus").." (2012).")
2584 cr5:SizeToContents()
2585 cr5:SetPos(6, settingsSizeY-160)
2586 local cr6 = vgui.Create("DLabel", sp4)
2587
2588 cr6:SetText("\n\n\n\n\n\n\n\nThanks to "..string.Replace(steamworks.GetPlayerName( icav ),"[unknown]", "Cavou").." for helping me fixing bugs.")
2589 cr6:SizeToContents()
2590 cr6:SetColor(Color(90,90,90,80))
2591 cr6:SetPos(6, settingsSizeY-160)
2592
2593 local cr7 = vgui.Create("DLabel", sp4)
2594 cr7:SetText("\n\n\n\n\n\n\n\n\n\nAnd also a big thank you to "..string.Replace(steamworks.GetPlayerName( imet ),"[unknown]", "Metamist").." who animated \nthe menu, rotated the text and more.")
2595 cr7:SizeToContents()
2596 cr7:SetColor(Color(90,90,90,80))
2597 cr7:SetPos(6, settingsSizeY-160)
2598
2599 local cr8 = vgui.Create("DLabel", sp4)
2600 cr8:SetText("Comparing versions")
2601 cr8:SizeToContents()
2602 cr8:SetFont("GBS-Version")
2603 cr8:SetColor(Color(0,0,0,120))
2604 cr8:SetPos(6, settingsSizeY + 22)
2605 cr8:SetWrap( false )
2606 cr8.gotit = false
2607 function cr8:PaintOver()
2608 if cr8.gotit == true then cr8.PaintOver = function() end; return end
2609 local status = Radial.currentRadialVersion.status
2610 local version = Radial.currentRadialVersion.str
2611 if status == 1 then
2612 cr8:SetColor(Color(100,255,150,80))
2613 cr8:SetText(" Version: "..Radial.radialVersion)
2614 cr8:SizeToContents()
2615 cr8.gotit = true
2616 elseif status == -1 then
2617 if version == "nil" then
2618 cr8:SetColor(Color(255,255,150,80))
2619 cr8:SetText(" Version: "..Radial.radialVersion.." (comparison failed)")
2620 else
2621 cr8:SetColor(Color(255,100,50,80))
2622 cr8:SetText(" Version: "..Radial.radialVersion.." (new version: "..version..")")
2623 end
2624 cr8:SizeToContents()
2625 cr8.gotit = true
2626 else
2627 cr8:SetColor(Color(200,200,200,80))
2628 cr8:SetText(" Comparing versions"..string.rep(" .",(math.sin(SysTime()*1.6)+1)*2))
2629 cr8:SizeToContents()
2630 end
2631 local gx, gy = cr8:GetSize()
2632 cr8:SetSize(gx+5,gy+1)
2633 end
2634 --Radial.currentRadialVersion = {["str"] = "", ["status"] = false}
2635
2636 cr:SetFont("GBS-Credits")
2637 cr2:SetFont("GBS-Credits")
2638 cr3:SetFont("GBS-Credits")
2639 cr4:SetFont("GBS-Credits")
2640 cr5:SetFont("GBS-Credits")
2641 cr6:SetFont("GBS-Credits")
2642 cr7:SetFont("GBS-Credits")
2643
2644 cr:SizeToContents()
2645 cr2:SizeToContents()
2646 cr3:SizeToContents()
2647 cr4:SizeToContents()
2648 cr5:SizeToContents()
2649 cr6:SizeToContents()
2650 cr7:SizeToContents()
2651
2652 cr2.PaintOver = function()
2653 if cr2.ct < CurTime() then
2654 cr2:SetColor(Color(255,255,255,120))
2655 cr3:SetColor(Color(255,255,255,120))
2656 cr4:SetColor(Color(255,255,255,120))
2657 cr5:SetColor(Color(255,255,255,120))
2658 cr6:SetColor(Color(255,255,255,120))
2659 cr7:SetColor(Color(255,255,255,120))
2660
2661 for k,v in pairs(player.GetAll()) do
2662 if v:SteamID64() == iuke then
2663 cr2:SetColor(Color(100,255,150,255))
2664 elseif v:SteamID64() == ifly then
2665 cr3:SetColor(Color(100,255,150,255))
2666 elseif v:SteamID64() == icma then
2667 cr4:SetColor(Color(100,255,150,255))
2668 elseif v:SteamID64() == iddr then
2669 cr5:SetColor(Color(100,255,150,255))
2670 elseif v:SteamID64() == icav then
2671 cr6:SetColor(Color(100,255,150,255))
2672 elseif v:SteamID64() == imet then
2673 cr7:SetColor(Color(100,255,150,255))
2674 end
2675 end
2676
2677 cr2.ct= CurTime() + 5
2678 end
2679 end
2680
2681 --end
2682
2683 local res = {}
2684
2685 steamworks.VoteInfo( 265292490, function( result ) res = result end )
2686
2687 local ison = 0
2688
2689 local sp5 = vgui.Create( "DPanel", sp4)
2690 sp5:SetSize(tabSizeX,130)
2691 sp5:SetPos(0,300)
2692 sp5.ct = CurTime()+2
2693 local rup = 0
2694 local function Lerp2(a,b,c)
2695 a = a + math.abs(b)*0.01
2696 return b + math.Clamp(c-b,-a,a)
2697 end
2698
2699 local spawn = true
2700 local spawns = {}
2701 local spawns2 = {}
2702
2703 local cookie = {16,Material("gb-radial/cookie.png")}
2704 local special = {{16,Material("icon16/bug.png")},{16,Material("icon16/script_code.png")},{16,Material("icon16/lightbulb.png")},{24,Material("gb-radial/cookie_cute.png")},{16,Material("icon16/emoticon_wink.png")}}
2705 local ssc = 4
2706 local grav = Vector(0,90,0)
2707
2708 local function maximize(x)
2709 return (math.abs(x)^0.6 * (x < 0 and -1 or 1)) *6
2710 end
2711
2712 sp5.Paint = function()
2713 rup = Lerp2(1,rup,res.up or 0)
2714 local up = math.Clamp((tabSizeX-40)*(rup/1000) + ison,12,tabSizeX-40)
2715
2716 surface.SetTextColor( 200, 200, 200, 255 )
2717 surface.SetTextPos( 20, 4 )
2718 surface.DrawText( "Thumbs Counter:" )
2719
2720 local txt = ""
2721 surface.SetFont("DermaDefault")
2722 surface.SetTextColor( 180, 180, 180, 120 )
2723 if res.down == 0 or rup < res.up-1 then
2724 txt = "(takes a few seconds to update)"
2725 else
2726 txt = "If I'd share cookies "..res.down.." wouldn't get one."
2727 end
2728 local tsx,tsy = surface.GetTextSize(txt)
2729 surface.SetTextPos( tabSizeX-20-tsx, 48 )
2730 surface.DrawText( txt )
2731
2732 draw.RoundedBox( 4, 19, 19, tabSizeX-38, 26, Color(50,50,50,255) )
2733 draw.RoundedBox( 4, 20, 20, tabSizeX-40, 24, Color(150,150,150,255) )
2734
2735 surface.SetDrawColor( 255, 255, 255, 255 )
2736 local FT = FrameTime()
2737 local ST = SysTime()
2738 for sk,sms in ipairs(spawns) do
2739 surface.SetMaterial(sms.face)
2740
2741 surface.DisableClipping(true)
2742 surface.DrawTexturedRect(sms.pos.x, sms.pos.y, sms.size,sms.size)
2743 surface.DisableClipping(false)
2744
2745 sms.vel = sms.vel + grav * FT
2746
2747 sms.vel = sms.vel / (1+(sms.res*(FT^2)))
2748
2749 sms.pos = sms.pos + sms.vel*FT
2750
2751 if ST > sms.t or sms.pos.y > 500 then
2752 table.remove(spawns, sk)
2753 elseif sms.pos.y < 4 then
2754 table.insert(spawns2,sms)
2755 table.remove(spawns, sk)
2756 end
2757 end
2758
2759 if rup < 1000 then
2760 draw.RoundedBox( 4, 20, 20, up, 24, Color(0,255,0,255) )
2761 else
2762 local val = SysTime()*2.3%1
2763 draw.RoundedBox( 4, 20, 20, up, 24, HSVToColor(120 + 60*val,1-val,1) )
2764
2765 if val > 0.95 then
2766 if spawn then
2767 spawn = false
2768
2769 --surface.PlaySound("garrysmod/save_load"..math.random(1,4)..".wav")
2770
2771 local mx, my = sp5:CursorPos()
2772
2773 ftab = math.random(0,10) == 1 and special[math.random( 1, ssc )] or cookie
2774 local px, py = math.Rand(20,tabSizeX-6 -ftab[1]), math.Rand(20,32 -ftab[1])
2775
2776
2777
2778 local tab = {
2779 ["face"] = ftab[2],
2780 ["size"] = ftab[1],
2781 ["pos"] = Vector(px, py, 0),
2782 ["vel"] = Vector(maximize((mx-px)+math.Rand(-100,100)), maximize(math.Min(my-py,-1)+math.Rand(-100,100)), 0),
2783 ["res"] = 50,
2784 ["t"] = ST + 10
2785 }
2786
2787 table.insert(spawns,tab)
2788 end
2789 elseif spawn == false then
2790 spawn = true
2791 end
2792 end
2793
2794 draw.RoundedBox( 4, 21, 21, up-2, 11, Color(255,255,255,85) )
2795 surface.SetFont( "DermaDefault" )
2796 local txt = "["..((res.up or 0)+ison).." / 1000]"
2797 local tx,ty = surface.GetTextSize(txt)
2798
2799 surface.SetTextColor( 0, 0, 0, 255 )
2800 surface.SetTextPos( tabSizeX/2-tx/2 +1, 32 - ty/2 +1)
2801 surface.DrawText( txt )
2802 surface.SetTextPos( tabSizeX/2-tx/2 +1, 32 - ty/2 -1)
2803 surface.DrawText( txt )
2804 surface.SetTextPos( tabSizeX/2-tx/2 -1, 32 - ty/2 +1)
2805 surface.DrawText( txt )
2806 surface.SetTextPos( tabSizeX/2-tx/2 -1, 32 - ty/2 -1)
2807 surface.DrawText( txt )
2808 if ison == 1 then
2809 surface.SetTextColor( 0, 255, 160, 255 )
2810 else
2811 surface.SetTextColor( 255, 255, 255, 255 )
2812 end
2813 surface.SetTextPos( tabSizeX/2-tx/2, 32 - ty/2 )
2814 surface.DrawText( txt )
2815 surface.SetDrawColor( 255, 255, 255, 255 )
2816 for sk,sms in ipairs(spawns2) do
2817 surface.SetMaterial(sms.face)
2818
2819 surface.DisableClipping(true)
2820 surface.DrawTexturedRect(sms.pos.x, sms.pos.y, sms.size,sms.size)
2821 surface.DisableClipping(false)
2822
2823 sms.vel = sms.vel + grav * FT
2824
2825 sms.vel = sms.vel / (1+(sms.res*(FT^2)))
2826
2827 sms.pos = sms.pos + sms.vel*FT
2828
2829 if ST > sms.t or sms.pos.y > 500 then
2830 table.remove(spawns2, sk)
2831 end
2832 end
2833
2834 end
2835 sp5.PaintOver = function()
2836 if sp5.ct < CurTime() then
2837 steamworks.VoteInfo( 265292490, function( result ) res = result end )
2838 sp5.ct = CurTime()+2
2839 end
2840 end
2841
2842 local osw = vgui.Create("DButton", sp5)
2843 osw:SetFont("ChatFont")
2844 osw:SetColor(Color(160,160,160,255))
2845 osw:SetText("Vote")
2846 osw:SetPos(tabSizeX/2-40, 86)
2847 osw:SetSize(80, 24)
2848 osw.DoClick = function()
2849 steamworks.ViewFile( 265292490 )
2850 end
2851 osw.PaintOver = function()
2852 local lo = osw.on
2853 osw.on = osw.Hovered
2854
2855 if osw.Hovered then
2856 ison = 1
2857 osw:SetColor(Color(0,255,160,255))
2858 else
2859 ison = 0
2860 osw:SetColor(Color(160,160,160,255))
2861 end
2862 end
2863
2864
2865 function Radial.updatesettingsinalltabs()
2866 settingsPanelDeadzone:SetValue(Radial.radialConfig["gbr-menudeadzone"])
2867 settingsPanelRadius:SetValue(Radial.radialConfig["gbr-menuradius"])
2868 settingsPanelDrawTraceline:SetValue(Radial.radialConfig["gbr-menushowtraceline"])
2869 setborder:SetValue(Radial.radialConfig["gbr-drawborder"])
2870 settingsPanelSplitterLength:SetValue(Radial.radialConfig["gbr-menusplitterlength"])
2871 inradslider:SetValue(Radial.radialConfig["gbr-selectedinner"])
2872 outrdslider:SetValue(Radial.radialConfig["gbr-selectedouter"])
2873 spacingslider:SetValue(Radial.radialConfig["gbr-spacing"])
2874 cb:SetValue( Radial.radialConfig["gbr-font"] or "Arial" )
2875 asy:SetValue(Radial.radialConfig["gbr-clampy"])
2876 asx:SetValue(Radial.radialConfig["gbr-clampx"])
2877 asx:SetValue(Radial.radialConfig["gbr-clampx"])
2878 olt:SetValue(Radial.radialConfig["gbr-outline"])
2879 settingsPanelRotateText:SetValue(Radial.radialConfig["gbr-rotatetext"])
2880 scs:SetValue(Radial.radialConfig["gbr-fontscale"])
2881 cp:SetColor( Color( Radial.radialConfig["gbr-hr"],Radial.radialConfig["gbr-hg"],Radial.radialConfig["gbr-hb"],Radial.radialConfig["gbr-ha"] ) )
2882 dp:SetColor( Color( Radial.radialConfig["gbr-dr"],Radial.radialConfig["gbr-dg"],Radial.radialConfig["gbr-db"],Radial.radialConfig["gbr-da"] ) )
2883 tc:SetColor( Color( Radial.radialConfig["gbr-tr"],Radial.radialConfig["gbr-tg"],Radial.radialConfig["gbr-tb"],Radial.radialConfig["gbr-ta"] ) )
2884 ccs:SetValue(Radial.radialConfig["gbr-colorspeed"])
2885 ans:SetValue(Radial.radialConfig["gbr-animspeed"])
2886
2887 rocte:SetValue( Radial.radialConfig["gbr-onclose"] )
2888 end
2889
2890 local tsx, tsy = settingsPanelCloseButton:GetSize()
2891 local tpx, tpy = settingsPanelCloseButton:GetPos()
2892
2893 sp:SetSize(settingsSizeX,objSizeY+objPosY+32)
2894 PrS:SetSize(settingsSizeX,tsy+tpy+42)
2895 PrS:SetPadding(2)
2896
2897 settingsPanel:MakePopup()
2898 settingsPanel:SetSize(settingsSizeX,tsy+tpy+66)
2899 settingsPanel:SetPos(math.Clamp(40+(ScrW()-680),0,40), (ScrH()/2) - (objSizeY+objPosY+56)/2)
2900 local Sheet1 = PrS:AddSheet( "Settings", sp, "icon16/wrench.png", false, false)
2901 local Sheet2 = PrS:AddSheet( "Customisation", sp2, "icon16/palette.png", false, false)
2902 local Sheet3 = PrS:AddSheet( "Presets", sp3, "icon16/page_gear.png", false, false)
2903 local Sheet4 = PrS:AddSheet( "", sp4, "icon16/group.png", false, false)
2904
2905 function settingsPanel:Paint()
2906 local w, h = self:GetSize()
2907 draw.RoundedBox(4,0,0,w,h,Color(0,0,0,255))
2908 draw.RoundedBoxEx(4,0,0,w,24,Color(255,255,255,20),true,true,false,false)
2909 draw.RoundedBoxEx(4,1,1,w-2,h-1,Color(255,255,255,80),true,true,false,false)
2910 draw.RoundedBoxEx(4,2,2,w-4,h-4,Color(0,0,0,120),true,true,false,false)
2911 surface.SetDrawColor(Color(0,255,255,255))
2912 --surface.DrawRect(0,25,w,36)
2913 surface.SetDrawColor(Color(80,80,80,255))
2914 surface.SetTexture(surface.GetTextureID("gui/gradient_up"))
2915
2916 surface.DrawTexturedRect(0, 36, w,8)
2917
2918 if settingsPanel.Hovered and ScrH() < (sy+100) then
2919 local px,py = settingsPanel:GetPos()
2920 if input.IsMouseDown( MOUSE_LEFT ) then
2921 surface.SetDrawColor(Color(0,255,255,100))
2922 else
2923 surface.SetDrawColor(Color(80,80,80,200))
2924 end
2925 surface.SetTexture(surface.GetTextureID("engine/lightsprite"))
2926 surface.DrawTexturedRect(gui.MouseX() -8 -px, gui.MouseY() -8 -py, 16,16)
2927 end
2928 end
2929 --just in case its needed in th future
2930 function PrS.tabScroller.btnLeft:Paint()
2931 local w, h = self:GetSize()
2932 if self:IsDown() then
2933 surface.SetDrawColor(Color(0,200,200,220))
2934 elseif self.Hovered then
2935 surface.SetDrawColor(Color(0,120,120,220))
2936 else
2937 surface.SetDrawColor(Color(50,50,50,220))
2938 end
2939 draw.NoTexture()
2940 surface.DrawPoly({{ x = w, y = 2 },{ x = w, y = h-2 },{ x = 2, y = h/2 }})
2941
2942 end
2943 function PrS.tabScroller.btnRight:Paint()
2944 local w, h = self:GetSize()
2945 if self:IsDown() then
2946 surface.SetDrawColor(Color(0,200,200,220))
2947 elseif self.Hovered then
2948 surface.SetDrawColor(Color(0,120,120,220))
2949 else
2950 surface.SetDrawColor(Color(50,50,50,220))
2951 end
2952 draw.NoTexture()
2953 surface.DrawPoly({{ x = 0, y = 2 },{ x = w-2, y = h/2 },{ x = 0, y = h-2 }})
2954 end
2955
2956 function Sheet1.Tab:Paint()
2957 local w, h = self:GetSize()
2958 surface.SetTexture(surface.GetTextureID("gui/gradient_up"))
2959 if self:IsActive() then
2960 surface.SetDrawColor(Color(50,255,255,255))
2961 elseif self.Hovered then
2962 surface.SetDrawColor(Color(50,120,120,180))
2963 else
2964 surface.SetDrawColor(Color(0,0,0,0))
2965
2966 end
2967 surface.DrawTexturedRect(2, 12, w-5,8)
2968 end
2969 function Sheet2.Tab:Paint()
2970 local w, h = self:GetSize()
2971 surface.SetTexture(surface.GetTextureID("gui/gradient_up"))
2972 if self:IsActive() then
2973 surface.SetDrawColor(Color(50,255,255,255))
2974 elseif self.Hovered then
2975 surface.SetDrawColor(Color(50,120,120,180))
2976 else
2977 surface.SetDrawColor(Color(0,0,0,0))
2978
2979 end
2980 surface.DrawTexturedRect(2, 12, w-5,8)
2981 end
2982 function Sheet3.Tab:Paint()
2983 local w, h = self:GetSize()
2984 surface.SetTexture(surface.GetTextureID("gui/gradient_up"))
2985 if self:IsActive() then
2986 surface.SetDrawColor(Color(50,255,255,255))
2987 elseif self.Hovered then
2988 surface.SetDrawColor(Color(50,120,120,180))
2989 else
2990 surface.SetDrawColor(Color(0,0,0,0))
2991
2992 end
2993 surface.DrawTexturedRect(2, 12, w-5,8)
2994 end
2995 function Sheet4.Tab:Paint()
2996 local w, h = self:GetSize()
2997 surface.SetTexture(surface.GetTextureID("gui/gradient_up"))
2998 if self:IsActive() then
2999 surface.SetDrawColor(Color(50,255,255,255))
3000 elseif self.Hovered then
3001 surface.SetDrawColor(Color(50,120,120,180))
3002 else
3003 surface.SetDrawColor(Color(0,0,0,0))
3004
3005 end
3006 surface.DrawTexturedRect(2, 12, w-5,8)
3007 end
3008
3009 local t = SysTime()
3010 local dragpnl = false
3011 local md = input.IsMouseDown( MOUSE_LEFT )
3012 local sx,sy = settingsPanel:GetSize()
3013 local mdy = 0
3014 local sty= 0
3015 local fy= 0
3016 local bo = 10
3017
3018 local maxsp = 0
3019 local dir = 0
3020 local ti = SysTime()
3021 local st = SysTime()
3022
3023
3024 function settingsPanel:OnMouseWheeled(dlta)
3025 if ScrH() < (sy+100) then
3026 local px,py = settingsPanel:GetPos()
3027
3028 self:SetPos(px,math.Clamp(py+dlta*20,math.Min(-(sy-ScrH()+50),ScrH()/2+sy/2+50),math.Max(50,ScrH()/2-sy/2-50)))
3029 end
3030 end
3031
3032 settingsPanel.Think = function()
3033 lt = t
3034 t = SysTime()
3035 local px,py = settingsPanel:GetPos()
3036 local scx,scy = ScrW(), ScrH()
3037 local lmy = my
3038 mx, my = gui.MousePos( )
3039
3040 local lmd = md
3041 md = input.IsMouseDown( MOUSE_LEFT )
3042
3043 local min,max = math.Min(-(sy-scy+50),ScrH()/2+sy/2+50), math.Max(50,ScrH()/2-sy/2-50)
3044
3045 if ScrH() < (sy+100) then
3046 if (settingsPanel.Hovered or sp.Hovered or sp2.Hovered or sp3.Hovered or sp4.Hovered or PrS.Hovered) then
3047 if md and lmd ~= md then
3048 dragpnl = true
3049 mdy = my - py
3050 sty = my
3051 maxsp = 0
3052 st = SysTime()
3053 end
3054 end
3055 if md and dragpnl == true then
3056 gui.SetMousePos(math.Clamp(gui.MouseX(),0,ScrW()),math.Clamp(gui.MouseY(),0,ScrH()))
3057 settingsPanel:SetPos(px,math.Clamp(my-mdy,min,max))
3058 if maxsp == 0 then
3059 maxsp = math.abs( lmy - my )
3060 elseif my > 5 and my < (ScrH() - 5) then
3061 maxsp = (maxsp + math.abs( lmy - my ))/2
3062 end
3063 if mx >= px and mx <= px+sx then
3064 if my < bo and py > min then
3065 mdy = mdy+math.max(3,maxsp)
3066 elseif my > scy-bo and py < max then
3067 mdy = mdy-math.max(3,maxsp)
3068 end
3069 end
3070 ti = SysTime()
3071 fy = my
3072 else
3073 dragpnl = false
3074 if maxsp > 1 then
3075 settingsPanel:SetPos(px,math.Clamp(py+(((fy-sty)/(ti-st))*(t-lt)),min,max))
3076 end
3077 fy = Lerp(0.07,fy,sty)
3078 end
3079 end
3080
3081
3082
3083 sp.Paint = function()
3084 local px,py = settingsPanel:GetPos()
3085 local spx,spy = sp:GetPos()
3086 if sp.Hovered and ScrH() < (sy+100) then
3087 if input.IsMouseDown( MOUSE_LEFT ) then
3088 surface.SetDrawColor(Color(0,255,255,100))
3089 else
3090 surface.SetDrawColor(Color(80,80,80,200))
3091 end
3092 surface.SetTexture(surface.GetTextureID("engine/lightsprite"))
3093 surface.DrawTexturedRect(gui.MouseX() -8 -px-spx, gui.MouseY() -8 -py-spy-24, 16,16)
3094 end
3095 end
3096 sp2.Paint = function()
3097 local px,py = settingsPanel:GetPos()
3098 local spx,spy = sp2:GetPos()
3099 if sp2.Hovered and ScrH() < (sy+100) then
3100 if input.IsMouseDown( MOUSE_LEFT ) then
3101 surface.SetDrawColor(Color(0,255,255,100))
3102 else
3103 surface.SetDrawColor(Color(80,80,80,200))
3104 end
3105 surface.SetTexture(surface.GetTextureID("engine/lightsprite"))
3106 surface.DrawTexturedRect(gui.MouseX() -8 -px-spx, gui.MouseY() -8 -py-spy-24, 16,16)
3107 end
3108 end
3109 end
3110 sp3.Paint = function()
3111 local px,py = settingsPanel:GetPos()
3112 local spx,spy = sp3:GetPos()
3113 if sp3.Hovered and ScrH() < (sy+100) then
3114 if input.IsMouseDown( MOUSE_LEFT ) then
3115 surface.SetDrawColor(Color(0,255,255,100))
3116 else
3117 surface.SetDrawColor(Color(80,80,80,200))
3118 end
3119 surface.SetTexture(surface.GetTextureID("engine/lightsprite"))
3120 surface.DrawTexturedRect(gui.MouseX() -8 -px-spx, gui.MouseY() -8 -py-spy-24, 16,16)
3121 end
3122 end
3123 sp4.Paint = function()
3124 local px,py = settingsPanel:GetPos()
3125 local spx,spy = sp4:GetPos()
3126 if sp4.Hovered and ScrH() < (sy+100) then
3127 if input.IsMouseDown( MOUSE_LEFT ) then
3128 surface.SetDrawColor(Color(0,255,255,100))
3129 else
3130 surface.SetDrawColor(Color(80,80,80,200))
3131 end
3132 surface.SetTexture(surface.GetTextureID("engine/lightsprite"))
3133 surface.DrawTexturedRect(gui.MouseX() -8 -px-spx, gui.MouseY() -8 -py-spy-24, 16,16)
3134 end
3135 end
3136
3137 hook.Add("PostRenderVGUI","drawdebug",function()
3138 if not IsValid(settingsPanel) then return end
3139 local px,py = settingsPanel:GetPos()
3140 local scx,scy = ScrW(), ScrH()
3141 --local mx, my = gui.MousePos( )
3142 local min,max = math.Min(-(sy-scy+50),ScrH()/2+sy/2+50), math.Max(50,ScrH()/2-sy/2-50)
3143 --local mind, maxd = math.Clamp((math.abs(py-min))/bo,0,1), math.Clamp((math.abs(py-max))/bo,0,1)
3144
3145 --local up,dn = math.Clamp((my+bo-scy)/30,0,1), math.Clamp((bo-my)/30,0,1)
3146 if py == min and dragpnl then
3147 surface.SetTexture(surface.GetTextureID("engine/lightsprite"))
3148 surface.SetDrawColor(Color(55,190,255,255))
3149 surface.DrawTexturedRect(px,-bo*1.01,sx,bo*2)
3150 elseif py == max and dragpnl then
3151 surface.SetTexture(surface.GetTextureID("engine/lightsprite"))
3152 surface.SetDrawColor(Color(55,190,255,255))
3153 surface.DrawTexturedRect(px,scy-bo*0.99,sx,bo*2)
3154 end
3155 end)
3156
3157 local px,py = settingsPanel:GetPos()
3158 local sx,sy = settingsPanel:GetSize()
3159
3160 hook.Call("Radial.MenuOpen",{},px+sx)
3161 end
3162 end
3163
3164 --if reopen then
3165 timer.Simple(0.1,function() if reopen then Radial.openRadialMenuConfig() end end)
3166 --end
3167 -- Options menu drawing
3168 function Radial.OptionsMenu(optionsPanel)
3169 -- Spacing
3170 optionsPanel:AddControl("Label", { Text = "" })
3171 local DButton = vgui.Create("DButton", optionsPanel)
3172 DButton:SetText(" Open Radial Menu Settings ")
3173 DButton:SizeToContentsX()
3174 DButton:SetPos(7,20)
3175 DButton.DoClick = Radial.openRadialMenuConfig
3176 end
3177
3178 function Radial.refreshsettingstoolslist()
3179 if not IsValid(settingsPanelTools) then return end
3180 Radial.updatesettingsinalltabs()
3181 settingsPanelTools:Clear()
3182 addToolsToListbox(settingsPanelTools)
3183 end
3184
3185 -- Actual options menu adding
3186 hook.Add("PopulateToolMenu","AddMeIntoTheOptions",function()
3187 spawnmenu.AddToolMenuOption("Options", "Overhauled Radial Menu", "Radial.MenuSettings", "Settings", "", "", Radial.OptionsMenu, {})
3188 end)
3189
3190end
3191
3192if Radial.settingsPanelShown == 1 then --modding it with gmod in windowed mode
3193 Radial.openRadialMenuConfig() --and the options menu open is just super comfortable now
3194end
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206 --
3207-- GB Radial.. Menu
3208-- Utils
3209--
3210
3211if CLIENT then
3212
3213 function Radial.saveConfig()
3214 local configFile = util.TableToKeyValues(table.Sanitise(Radial.radialConfig))
3215 file.Write("gb-radial-config_2014.txt", configFile)
3216 end
3217
3218 function Radial.savePresets()
3219 local tempPresets = table.Copy(Radial.radialToolPresets)
3220
3221 for k,v in pairs(tempPresets) do --here im filtering information which is unnecessary to save like the position of each field
3222 if v["t"] != nil then
3223 for k2,v2 in pairs(v["t"]) do --because the part for the animations need to store those information
3224 for k3, v3 in pairs(v2) do
3225 if Radial.includedtoolsettings[k3] ~= 1 then
3226 tempPresets[k]["t"][k2][k3] = nil
3227 end
3228 end
3229 end
3230 end
3231
3232 if v["s"] != nil then
3233 for k2,v2 in pairs(v["s"]) do
3234 if Radial.presetsettingsblacklist[k2] == 1 or v["s"][Radial.presetsettingsblacklist[k2]] == true then
3235 tempPresets[k]["s"][k2] = nil
3236 end
3237 end
3238 end
3239 end
3240
3241 local configFile = util.TableToKeyValues(table.Sanitise(tempPresets))
3242 file.Write("gb-radial-tool-presets_2014.txt", configFile)
3243 end
3244
3245 function Radial.saveTools()
3246 local tempPresets = table.Copy(Radial.radialConfigTools)
3247
3248 for k,v in pairs(tempPresets) do --same again
3249 for k2,v2 in pairs(v) do
3250 if Radial.includedtoolsettings[k2] ~= 1 then
3251 tempPresets[k][k2] = nil
3252 end
3253 end
3254 end
3255
3256 local configFile = util.TableToKeyValues(table.Sanitise(tempPresets))
3257 file.Write("gb-radial-config-tools_2014.txt", configFile)
3258 end
3259end
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275 -- Include Search Menu Lua
3276 if CLIENT then
3277 local FrameWidth = 400
3278 local ItemHeight = 16
3279 local MaxItems = 150
3280 local findPanelShown = false
3281 local Selection
3282 local colorscheme = {
3283 ["[TOOL]"] = {Color(0,0,0,255),Color(255,170,0,150),Color(255,170,0,255),Color(255,200,10,255)},
3284 ["[CMD]"] = {Color(0,0,0,255),Color(0,180,255,150),Color(0,180,255,255),Color(10,255,255,255)},
3285 ["[WEAP]"] = {Color(0,0,0,255),Color(255,110,0,150),Color(255,110,0,255),Color(255,140,10,255)},
3286 ["[PRESET]"] = {Color(0,0,0,255),Color(110,255,0,150),Color(110,255,0,255),Color(140,255,10,255)}
3287 }
3288
3289 local function ButtonPaint(de,txt,tcol,col,cat)
3290 local w,h = de:GetWide(), de:GetTall()
3291 surface.SetDrawColor(col)
3292 draw.RoundedBox( 4, 0, 0, w, h, Color( 0, 0, 0, 255 ) )
3293 draw.RoundedBox( 4, 1, 1, w-2, h-2, col)
3294 if cat ~= nil and cat ~= "" then
3295 local tcol2 = Color(tcol.r, tcol.g, tcol.b, 120)
3296 draw.DrawText("{"..cat.."}" , "DermaDefault", w-20, 0, tcol2,2)
3297 end
3298 draw.DrawText(txt , "DermaDefault", 10, 0, tcol,4)
3299 end
3300
3301 local function CreateVGUI()
3302 findPanelShown = true
3303 local FindPanel = vgui.Create( "DFrame" )
3304 FindPanel:SetSize( FrameWidth, 400 )
3305 FindPanel:SetTitle( "" )
3306 FindPanel:SetDeleteOnClose( true )
3307 FindPanel:ShowCloseButton( true )
3308 FindPanel:SetDraggable( false )
3309 FindPanel:SetSizable( false )
3310 FindPanel:MakePopup()
3311 FindPanel:SetPos( ScrW()/2 - FrameWidth* .5, math.Clamp( ScrH() - 32 - FindPanel:GetTall(), 0, ScrH() ) )
3312 FindPanel:SetKeyboardInputEnabled( true )
3313 FindPanel:SetMouseInputEnabled( true )
3314 FindPanel.btnClose.DoClick = function ( button )
3315 findPanelShown = false
3316 FindPanel:Close()
3317 end
3318
3319 local FlIl = vgui.Create( "DScrollPanel", FindPanel )
3320 FlIl:SetSize( FindPanel:GetWide() - 16, 16*19 )
3321 FlIl:SetPos( 8, 72 )
3322
3323 local ButList = {}
3324 FlIl.Think = function()
3325 local LY = FlIl.rly
3326 local CY = FlIl.VBar:GetOffset()
3327 FlIl.rly = CY
3328 if LY ~= CY then
3329 for k,v in pairs(ButList) do
3330 v.Hovered = false
3331 end
3332 end
3333 end
3334
3335 FindEntry = vgui.Create( "DTextEntry" )
3336 FindEntry:SetParent( FindPanel )
3337 FindEntry:SetPos( 80, 36 )
3338 FindEntry:SetSize( 96, 24 )
3339 FindEntry:SetValue( "" )
3340 local TOOLS = {}
3341 for k,v in pairs(spawnmenu.GetTools()) do
3342 if v.Label ~= "#spawnmenu.utilities_tab" and v.Label ~= "Options" then
3343 for k2,v2 in pairs(v.Items) do
3344 for k3,v3 in pairs(v2) do
3345 if type(v3) == "table" then
3346 v3["Category"] = v2.ItemName or v2.Text or ""
3347 TOOLS[v3.ItemName or v3.Text or k3] = v3
3348 end
3349 end
3350 end
3351 end
3352 end
3353 FindEntry.OnEnter = function()
3354 FindPanel:Close()
3355 findPanelShown = false
3356
3357 local CaretPos = FindEntry:GetCaretPos()
3358 FindEntry:SetText( "" )
3359 FindEntry:OnValueChange()
3360 FindEntry:SetCaretPos(0)
3361
3362 FindEntry:RequestFocus( )
3363 if Selection == nil or Selection == {} then return end
3364
3365 if Radial.settingsPanelShown then
3366 Radial.PasteConvar(tostring(Selection[ 1 ]), Selection[ 3 ], Selection.Name)
3367 else
3368 Radial.MyRunConsoleCommand(Selection[ 3 ] .." ".. tostring(Selection[ 1 ]) )
3369 end
3370 end
3371
3372 FindEntry:RequestFocus( )
3373 local WEAPONS = list.Get( "Weapon" )
3374
3375 local CMDS,_ = concommand.GetTable()
3376 local cmdlist = "undo,gm_spawn,gm_spawnsent,gm_spawnswep,gm_spawnvehicle,lua_openscript,lua_openscript_cl,record,stop,kill,jpeg,retry,god,noclip,use,quit,disconnect"
3377 local tmpcmds = string.Explode(",",cmdlist)
3378
3379 for _,v in pairs(tmpcmds) do
3380 CMDS[v] = {}
3381 end
3382
3383 for k,v in pairs( list.Get( "Vehicles" ) ) do
3384 CMDS["gm_spawnvehicle "..k] = {}
3385 end
3386
3387 local ResultLabel2 = vgui.Create( "DLabel" )
3388 ResultLabel2:SetParent( FindPanel )
3389 ResultLabel2:SetPos( FindPanel:GetWide() * .5 - 56, FindPanel:GetTall() - 24 )
3390 ResultLabel2:SetSize( 128, 16 )
3391 ResultLabel2:SetText( "" )
3392
3393 local TitleLabel = vgui.Create( "DLabel" )
3394 TitleLabel:SetParent( FindPanel )
3395 TitleLabel:SetPos( 24, 8 )
3396 TitleLabel:SetSize( 64, 16 )
3397 TitleLabel:SetText( "Function Search" )
3398 TitleLabel:SizeToContents()
3399
3400 local Label = vgui.Create( "DLabel" )
3401 Label:SetParent( FindPanel )
3402 Label:SetPos( 16, 40 )
3403 Label:SetSize( 64, 16 )
3404 Label:SetText( "Search for:" )
3405
3406 local FindList = vgui.Create("DIconLayout", FlIl)
3407 FindList:SetPos(0,0)
3408 FindList:SetSize(FlIl:GetSize())
3409
3410 FindList.Paint = function()
3411 draw.RoundedBox( 4, 0,0, FindList:GetWide(),FindList:GetTall(), Color(0,0,0,160))
3412 end
3413
3414 local function RefreshButtons( res )
3415 ButList = {}
3416 if res == nil or res == {} then return end
3417 local Size = table.Count( res )
3418 if Size > 0 then
3419 local Text = "Listed " .. tostring( math.Min(MaxItems,Size) ) .. "/" .. tostring( Size ) .." results."
3420 ResultLabel2:SetText( Text )
3421 ResultLabel2:SizeToContents()
3422 else
3423 ResultLabel2:SetText( "" )
3424 end
3425
3426 FindList:Clear()
3427 local ch = 0
3428 for k2,v2 in ipairs(res) do
3429 ch = ch + 1
3430 local Txt = ""
3431 ButList[k2] = vgui.Create("DButton")
3432 ButList[k2]:SetDrawBorder(false)
3433 ButList[k2]:SizeToContents()
3434 local sx, sy = FindList:GetSize()
3435 ButList[k2]:SetSize( sx, 15 )
3436 Txt = ""..v2[2].." "..v2.Name
3437 local Cat = v2.Cat or ""
3438 ButList[k2]:SetText("")
3439 ButList[k2].DoClick = function()
3440 if Radial.settingsPanelShown then
3441 Radial.PasteConvar(tostring(v2[ 1 ]), v2[ 3 ], v2.Name) --Write Convar to textbox in options menu. Cmasta.
3442 else
3443 Radial.MyRunConsoleCommand(v2[ 3 ] .." ".. tostring(v2[ 1 ]) )
3444 end
3445 findPanelShown = false
3446 FindPanel:Close()
3447 end
3448 ButList[k2].Paint = function()
3449 ButList[k2]:SetText("")
3450 if ButList[k2].Depressed || ButList[k2].m_bSelected then
3451 ButtonPaint(ButList[k2],Txt,colorscheme[v2[2]][1],colorscheme[v2[2]][4],Cat)
3452 elseif ButList[k2].Hovered then
3453 ButtonPaint(ButList[k2],Txt,colorscheme[v2[2]][1],colorscheme[v2[2]][3],Cat)
3454 else
3455 ButtonPaint(ButList[k2],Txt,colorscheme[v2[2]][1],colorscheme[v2[2]][2],Cat)
3456 end
3457 end
3458
3459 if Radial.settingsPanelShown and v2[2] == "[PRESET]" then
3460 Radial.pasteroc( str )
3461 local but = vgui.Create("DImageButton", ButList[k2])
3462 but:SetPos(350,0)
3463 but:SetSize( 16, 16 )
3464 but:SetImage( "icon16/script_add.png" )
3465 but.DoClick = function()
3466 FindPanel:Close()
3467 findPanelShown = false
3468 Radial.pasteroc(v2[ 3 ].." "..tostring(v2[ 1 ]))
3469 end
3470 end
3471
3472 -- Add the item to the listbox
3473 FindList:Add(ButList[k2])
3474 if ch >= MaxItems then break end
3475 end
3476 end
3477
3478 FindEntry.OnTextChanged = function() --instead of ~:Think()
3479 local Value = FindEntry:GetValue()
3480 Value = string.gsub( Value, "(%D)(%d)", "%1 %2" )
3481 Value = string.gsub( Value, "(%d)(%D)", "%1 %2" )
3482
3483 local Explode = string.Explode( " " , Value )
3484 if not ( FindEntry.Value == Value ) then
3485
3486 FindEntry.Value = Value
3487
3488 local Results = {}
3489 local Results1 = {}
3490 local ResultsW = {}
3491 local ResultsP = {}
3492 if not ( Value == "" ) then
3493
3494 if TOOLS then
3495
3496 for Tool, v2 in pairs( TOOLS ) do
3497
3498 local Found = true
3499 local Cat = v2.Category or ""
3500 local Name = v2.Text or v2.ItemName
3501 if Name ~= nil then
3502 local prefix = "[TOOL]"
3503 if string.sub(Name, 0,1) == "#" then --make nicer names
3504 local ex = string.Explode(".", Name)
3505 if #ex > 1 then
3506 Name = string.upper(string.sub(ex[2], 0,1))..string.sub(ex[2], 2,-1)
3507 else
3508 Name = string.upper(string.gsub(string.sub(Name, 0,2),"#",""))..string.sub(Name, 3,-1)
3509 end
3510 end
3511
3512 for j, c in pairs( Explode ) do
3513
3514 if not string.find( string.lower( prefix..Name..Cat ), string.lower( tostring(c) ) ,0,true) then
3515
3516 Found = false
3517
3518 end
3519
3520 end
3521
3522 if Found then
3523
3524 table.insert(Results, { Tool, prefix, "gmod_tool", Name = Name, Desc = prefix..Tool, Cat = Cat})
3525
3526 end
3527 end
3528 end
3529
3530 end
3531 table.SortByMember(Results, "Name", true)
3532
3533 if WEAPONS then
3534
3535 for k, v2 in pairs( WEAPONS ) do
3536
3537 local Found = true
3538 local Cat = v2.Category or ""
3539 local Name = v2.PrintName
3540 local Weap = v2.ClassName
3541
3542 if Name ~= nil and name ~= "" and Weap ~= nil then
3543 local prefix = "[WEAP]"
3544 for j, c in pairs( Explode ) do
3545
3546 if not string.find( string.lower( prefix..Name ), string.lower( tostring(c) ) ,0,true) then
3547
3548 Found = false
3549
3550 end
3551
3552 end
3553
3554 if Found then
3555
3556 table.insert(ResultsW, { Weap, prefix, "wep", Name = Name, Desc = prefix..Weap, Cat = Cat })
3557
3558 end
3559 end
3560
3561 end
3562 table.SortByMember(ResultsW, "Name", true)
3563 table.Add(Results,ResultsW)
3564 end
3565
3566 if CMDS and Radial.settingsPanelShown then
3567
3568 for Cmd, _ in pairs( CMDS ) do
3569
3570 local Found = true
3571
3572 local Name = Cmd
3573 local Category = "Consolecommand"
3574 if Name ~= nil then
3575 local prefix = "[CMD]"
3576 for j, c in pairs( Explode ) do
3577
3578 if not string.find( string.lower( prefix..Name ), string.lower( c ) ,0,true) then
3579
3580 Found = false
3581
3582 end
3583
3584 end
3585
3586 if Found then
3587
3588 table.insert(Results1, { "", prefix, Cmd, Name = Name, Desc = prefix..Cmd })
3589
3590 end
3591 end
3592 end
3593 table.SortByMember(Results1, "Name", true)
3594 table.Add(Results,Results1)
3595 end
3596
3597 if Radial.radialToolPresets and Radial.settingsPanelShown then
3598
3599 for k, _ in pairs( Radial.radialToolPresets ) do
3600
3601 local Found = true
3602 local Name = k
3603
3604 if Name ~= nil and name ~= "" then
3605 local prefix = "[PRESET]"
3606 for j, c in pairs( Explode ) do
3607
3608 if not string.find( string.lower( prefix..Name ), string.lower( tostring(c) ) ,0,true) then
3609
3610 Found = false
3611
3612 end
3613
3614 end
3615
3616 if Found then
3617
3618 table.insert(ResultsP, { Name, prefix, "load_preset", Name = Name, Desc = prefix..Name })
3619
3620 end
3621 end
3622
3623 end
3624 table.SortByMember(ResultsP, "Name", true)
3625 table.Add(Results,ResultsP)
3626 end
3627 end
3628 Selection = Results[1]
3629 RefreshButtons(Results)
3630
3631 end
3632
3633 end
3634
3635 end
3636
3637 function Radial.ToolFindPanelInvisible()
3638 if FindPanel == nil then return end
3639 FindPanel:Close()
3640 findPanelShown = false
3641 end
3642
3643 function Radial.ToolSearch()
3644
3645 if not findPanelShown then
3646
3647 CreateVGUI()
3648
3649 end
3650
3651 end
3652
3653 concommand.Add("tool_search", Radial.ToolSearch)
3654 end
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669 do
3670
3671 -- Config Setup, check for an existing config
3672 if file.Exists("gb-radial-config_2014.txt","DATA") then
3673 exist = true
3674 -- Config files exists, read and parse
3675 local configFile = file.Read("gb-radial-config_2014.txt","DATA")
3676
3677 -- Check that we read something, and that there's actually data in our variable
3678 if (configFile and #configFile > 0) then
3679 Radial.radialConfig = table.DeSanitise(util.KeyValuesToTable(configFile))
3680 end
3681 elseif file.Exists("gb-radial-config.txt","DATA") then
3682 -- Config files exists, read and parse
3683 local configFile = file.Read("gb-radial-config.txt","DATA")
3684
3685 -- Check that we read something, and that there's actually data in our variable
3686 if (configFile and #configFile > 0) then
3687 Radial.radialConfig = table.DeSanitise(util.KeyValuesToTable(configFile))
3688 end
3689 end
3690 end
3691 --Tools now checked seperately in case one file exists alonse for some reason
3692
3693 do
3694 local function load_config_tools(configFile)
3695 if (configFile and #configFile > 0) then
3696 local tools = table.DeSanitise(util.KeyValuesToTable(configFile))
3697
3698 for k, v in pairs(tools) do --making sure everything is in (some code is dependent on the existence of those values. else it will error)
3699 tools[k].name = tools[k].name or ""
3700 tools[k].rconcommand = tools[k].rconcommand or ""
3701 tools[k].exp = tools[k].exp or 0
3702 tools[k].cr = tools[k].cr or 0
3703 tools[k].cg = tools[k].cg or 0
3704 tools[k].cb = tools[k].cb or 0
3705 tools[k].cal = tools[k].cal or 180
3706 tools[k].ca = tools[k].ca or 0
3707 end
3708
3709 Radial.radialConfigTools = tools
3710 tools = nil
3711 end
3712 end
3713
3714 if file.Exists("gb-radial-config-tools_2014.txt","DATA") then
3715 load_config_tools(file.Read("gb-radial-config-tools_2014.txt","DATA"))
3716 elseif file.Exists("gb-radial-config-tools.txt","DATA") then
3717 load_config_tools(file.Read("gb-radial-config-tools.txt","DATA"))
3718 end
3719 end
3720
3721 if file.Exists("gb-radial-tool-presets_2014.txt","DATA") then
3722 local configFile = file.Read("gb-radial-tool-presets_2014.txt","DATA")
3723 if (configFile and #configFile > 0) then
3724 Radial.radialToolPresets = table.DeSanitise(util.KeyValuesToTable(configFile))
3725 end
3726
3727 for k,v in pairs(Radial.radialToolPresets) do
3728 Radial.radialToolPresets[k].s = Radial.radialToolPresets[k].s or {}
3729 --Radial.radialToolPresets[k].s["isskin"] = Radial.radialToolPresets[k].s["isskin"] or false
3730
3731 Radial.radialToolPresets[k].t = Radial.radialToolPresets[k].t or {}
3732 end
3733 end
3734
3735 -- Check if we read and parsed the config, and if not, create a default valued one
3736 -- We do this now anyways
3737 -- Default Config
3738 --lets see what we can use from the old version
3739 if true then
3740 Radial.radialConfig["gbr-version"] = Radial.radialVersion -- Used for config file checking
3741 Radial.radialConfig["gbr-menudeadzone"] = Radial.radialConfig["gbr-menudeadzone"] or 60 -- Defines the "dead area" around the screen center, where you can't select anything
3742 Radial.radialConfig["gbr-menuradius"] = Radial.radialConfig["gbr-menuradius"] or Radial.radialConfig["gbr-menudeadzone"] or 60 -- Defines the radius of the menu
3743 Radial.radialConfig["gbr-menusplitterlength"] = Radial.radialConfig["gbr-menusplitterlength"] or 60 -- The lenght of the split-lines between menu items
3744 Radial.radialConfig["gbr-menushowtraceline"] = Radial.radialConfig["gbr-menushowtraceline"] or 0
3745 Radial.radialConfig["gbr-rotatetext"] = Radial.radialConfig["gbr-rotatetext"] or 1
3746 Radial.radialConfig["gbr-spacing"] = Radial.radialConfig["gbr-spacing"] or 0.7
3747 Radial.radialConfig["gbr-selectedinner"] = Radial.radialConfig["gbr-selectedinner"] or 1.2
3748 Radial.radialConfig["gbr-selectedouter"] = Radial.radialConfig["gbr-selectedouter"] or 1.2
3749 Radial.radialConfig["gbr-showhelp"] = Radial.radialConfig["gbr-showhelp"] or 1
3750 Radial.radialConfig["gbr-drawborder"] = Radial.radialConfig["gbr-drawborder"] or 0
3751 Radial.radialConfig["gbr-borderpasses"] = Radial.radialConfig["gbr-borderpasses"] or 2
3752 Radial.radialConfig["gbr-boudkey"] = Radial.radialConfig["gbr-boudkey"] or 0
3753 Radial.radialConfig["gbr-enablesounds"] = Radial.radialConfig["gbr-enablesounds"] or 1
3754
3755 Radial.radialConfig["gbr-font"] = Radial.radialConfig["gbr-font"] or "Arial"
3756 Radial.radialConfig["gbr-fontscale"] = Radial.radialConfig["gbr-fontscale"] or 0.2
3757 Radial.radialConfig["gbr-clampx"] = Radial.radialConfig["gbr-clampx"] or 1
3758 Radial.radialConfig["gbr-clampy"] = Radial.radialConfig["gbr-clampy"] or 0
3759 Radial.radialConfig["gbr-outline"] = Radial.radialConfig["gbr-outline"] or 1
3760
3761 Radial.radialConfig["loaded_preset"] = Radial.radialConfig["loaded_preset"] or ""
3762 Radial.radialConfig["save_custom"] = Radial.radialConfig["save_custom"] or 1
3763 Radial.radialConfig["save_tools"] = Radial.radialConfig["save_tools"] or 1
3764 Radial.radialConfig["save_skin"] = Radial.radialConfig["save_skin"] or 0
3765
3766 Radial.radialConfig["gbr-hr"] = Radial.radialConfig["gbr-hr"] or 0
3767 Radial.radialConfig["gbr-hg"] = Radial.radialConfig["gbr-hg"] or 255
3768 Radial.radialConfig["gbr-hb"] = Radial.radialConfig["gbr-hb"] or 255
3769 Radial.radialConfig["gbr-ha"] = Radial.radialConfig["gbr-ha"] or 250
3770
3771 Radial.radialConfig["gbr-dr"] = Radial.radialConfig["gbr-dr"] or 50
3772 Radial.radialConfig["gbr-dg"] = Radial.radialConfig["gbr-dg"] or 50
3773 Radial.radialConfig["gbr-db"] = Radial.radialConfig["gbr-db"] or 50
3774 Radial.radialConfig["gbr-da"] = Radial.radialConfig["gbr-da"] or 250
3775
3776 Radial.radialConfig["gbr-tr"] = Radial.radialConfig["gbr-tr"] or 255
3777 Radial.radialConfig["gbr-tg"] = Radial.radialConfig["gbr-tg"] or 255
3778 Radial.radialConfig["gbr-tb"] = Radial.radialConfig["gbr-tb"] or 255
3779 Radial.radialConfig["gbr-ta"] = Radial.radialConfig["gbr-ta"] or 255
3780
3781 Radial.radialConfig["gbr-colorspeed"] = Radial.radialConfig["gbr-colorspeed"] or 0.3
3782 Radial.radialConfig["gbr-animspeed"] = Radial.radialConfig["gbr-animspeed"] or 0.2
3783
3784 Radial.radialConfig["gbr-onclose"] = Radial.radialConfig["gbr-onclose"] or ""
3785
3786 Radial.radialConfig["gbr-rotate"] = Radial.radialConfig["gbr-rotate"] or 0
3787
3788 Radial.radialConfig["isskin"] = Radial.radialConfig["isskin"] or false
3789
3790 Radial["gbr-skinvars_NAMES"] = {
3791 ["font"] = "Text Appearance",
3792 ["gbr-rotatetext"] = "Text Rotation",
3793
3794 ["shape"] = "Menu Shape",
3795 ["gbr-rotate"] = "Menu Rotation Offset",
3796
3797 ["color"] = "Color Settings",
3798
3799 ["amin"] = "Animation Settings",
3800
3801
3802 ["gbr-showhelp"] = "Helper",
3803 ["gbr-enablesounds"] = "Sound",
3804
3805 ["gbr-menushowtraceline"] = "Arrow",
3806 ["gbr-onclose"] = "Command On Menu Closing",
3807 }
3808
3809 Radial.radialConfig["gbr-skinvars"] = Radial.radialConfig["gbr-skinvars"] or {
3810 ["general"] = "General:",
3811 ["font"] = { true,
3812 {
3813 "gbr-font",
3814 "gbr-fontscale",
3815 "gbr-outline",
3816 }
3817 },
3818 ["gbr-rotatetext"] = false,
3819
3820 ["shape"] = { true,
3821 {
3822 "gbr-spacing",
3823 "gbr-selectedinner",
3824 "gbr-selectedouter",
3825 "gbr-drawborder",
3826 "gbr-borderpasses",
3827 "gbr-menudeadzone",
3828 "gbr-menuradius",
3829 "gbr-menusplitterlength",
3830 "gbr-clampx",
3831 "gbr-clampy",
3832 }
3833 },
3834 ["gbr-rotate"] = true,
3835
3836 ["color"] = { true,
3837 {
3838 "gbr-hr",
3839 "gbr-hg",
3840 "gbr-hb",
3841 "gbr-ha",
3842
3843 "gbr-dr",
3844 "gbr-dg",
3845 "gbr-db",
3846 "gbr-da",
3847
3848 "gbr-tr",
3849 "gbr-tg",
3850 "gbr-tb",
3851 "gbr-ta",
3852 }
3853 },
3854 ["amin"] = { true, //actually anim but well it's just internal
3855 {
3856 "gbr-colorspeed",
3857 "gbr-animspeed",
3858 }
3859 },
3860
3861 ["misc"] = "Misc.:",
3862 ["gbr-showhelp"] = false,
3863 ["gbr-enablesounds"] = false,
3864
3865 ["gbr-menushowtraceline"] = false,
3866 ["gbr-onclose"] = false,
3867
3868 }
3869
3870 Radial.SkinVars = {}
3871 function Radial.LoadSkinVars()
3872 for k,v in pairs(Radial.radialConfig["gbr-skinvars"]) do
3873 if type(v) == "boolean" then
3874 Radial.SkinVars[k] = v
3875 elseif type(v) == "table" then
3876 for i,j in pairs(v[2]) do
3877 Radial.SkinVars[j] = v[1]
3878 end
3879 end
3880 end
3881 end
3882 Radial.LoadSkinVars()
3883
3884 Radial.skinbutorder = {"general","font","gbr-rotatetext","shape","gbr-rotate","color","amin","misc","gbr-showhelp","gbr-enablesounds","gbr-menushowtraceline","gbr-onclose"}
3885
3886 Radial.SkinSettings = nil
3887 function Radial.ToggleSkinSettingsMenu()
3888 if Radial.SkinSettings and Radial.SkinSettings:IsValid() then Radial.SkinSettings:Remove() return end
3889 Radial.SkinSettings = vgui.Create("DFrame")
3890 local ssf = Radial.SkinSettings
3891 ssf:SetSize(300,400)
3892 ssf:SetTitle("[Radial Menu] Skin Override Settings")
3893 ssf:Center()
3894 ssf:MakePopup()
3895 ssf:SetScreenLock(true)
3896 function ssf:Think()
3897 if settingsPanel == nil or not settingsPanel:IsValid() then self:Remove() end
3898 end
3899
3900 local lbl = vgui.Create("DLabel",ssf)
3901 lbl:SetPos(4,30)
3902 lbl:SetText("Here you can specify what settings a skin preset can load.\nIt has still all settings stored.")
3903 lbl:SizeToContents()
3904
3905 local YP = 30+lbl:GetTall()
3906
3907 local scp = vgui.Create("DScrollPanel",ssf)
3908 --scp:DockPadding(5,5,5,5)
3909 scp:SetPos(4,YP)
3910 scp:SetSize(292,396-YP)
3911 function scp:Paint(w,h)
3912 surface.SetDrawColor(255,255,255,20)
3913 surface.DrawRect(0,0,w,h)
3914 end
3915
3916 local sp = vgui.Create("DListLayout",scp)
3917 sp:SetSize(292,100)
3918 --sp:Dock(TOP)
3919
3920 for _,k in pairs(Radial.skinbutorder) do
3921 local v = Radial.radialConfig["gbr-skinvars"][k]
3922
3923 if type(v) == "string" then
3924 local sl = sp:Add("DLabel")
3925 sl:SetText(v)
3926 sl:SizeToContents()
3927 sl:DockMargin(20,20,20,10)
3928
3929 elseif type(v) == "boolean" then
3930 local cbl = sp:Add("DCheckBoxLabel")
3931 cbl:SetText(Radial["gbr-skinvars_NAMES"][k] or k)
3932 cbl:SizeToContents()
3933 cbl:DockMargin(10,5,10,5)
3934
3935 cbl:SetValue(v)
3936
3937 function cbl:OnChange()
3938 Radial.SkinVars[k] = self:GetChecked()
3939 Radial.radialConfig["gbr-skinvars"][k] = Radial.SkinVars[k]
3940 end
3941
3942 elseif type(v) == "table" then
3943 local cbl = sp:Add("DCheckBoxLabel")
3944 cbl:SetText(Radial["gbr-skinvars_NAMES"][k] or k)
3945 cbl:SizeToContents()
3946 cbl:DockMargin(10,5,10,5)
3947
3948 cbl:SetValue(v[1])
3949
3950 function cbl:OnChange()
3951 local chkd = self:GetChecked()
3952 for i,j in ipairs(v[2]) do
3953 Radial.SkinVars[j] = chkd
3954 end
3955 Radial.radialConfig["gbr-skinvars"][k][1] = chkd
3956 end
3957 end
3958 end
3959 sp:SizeToContentsY()
3960 end
3961 --this way it also keeps config settings which arent used in this version in case some versions of this mod
3962 --differ from each other they can all use the same config (only bad if the same setting does different things)
3963 --if Radial.radialConfig["gbr-boudkey"] == 0 and not exist then
3964 -- chat.AddText(Color(120,120,120,255),"\n[",Color(0,255,255,255),"Overhauled Radial Menu",Color(120,120,120,255),"]\n", Color(255,255,255,255),"No keybinding set. Open \"Q>Options>GB Radial Menu\" to change it.\n")
3965 --end
3966 end
3967
3968 Radial.saveConfig()
3969
3970 -- Default Tools, only set these if they haven't been loaded before
3971 if table.Count(Radial.radialConfigTools) == 0 then
3972 Radial.radialConfigTools[1] = { name = "Phys Gun", rconcommand = "use weapon_physgun", exp = 0 }
3973 Radial.radialConfigTools[2] = { name = "Undo", rconcommand = "undo", exp = 1 }
3974 Radial.radialConfigTools[3] = { name = "Remover", rconcommand = "gmod_tool remover", exp = 0 }
3975 Radial.radialConfigTools[4] = { name = "EGP", rconcommand = "gmod_tool wire_egp", exp = 0 }
3976 Radial.radialConfigTools[5] = { name = "E2", rconcommand = "gmod_tool wire_expression2", exp = 0 }
3977 Radial.radialConfigTools[6] = { name = "PodCtrl", rconcommand = "gmod_tool wire_pod", exp = 0 }
3978 Radial.radialConfigTools[7] = { name = "EyePod", rconcommand = "gmod_tool wire_eyepod", exp = 0 }
3979 Radial.radialConfigTools[8] = { name = "CamCtrl", rconcommand = "gmod_tool wire_cam", exp = 0 }
3980 Radial.radialConfigTools[9] = { name = "WireADV", rconcommand = "gmod_tool wire_adv", exp = 0 }
3981 Radial.radialConfigTools[10] = { name = "Spawn Seat", rconcommand = "gm_spawnvehicle Seat_Airboat", exp = 0 }
3982
3983 for k,v in pairs(Radial.radialConfigTools) do
3984 Radial.radialConfigTools[k].exp = Radial.radialConfigTools[k].exp or 0
3985 Radial.radialConfigTools[k].cr = Radial.radialConfigTools[k].cr or 0
3986 Radial.radialConfigTools[k].cg = Radial.radialConfigTools[k].cg or 255
3987 Radial.radialConfigTools[k].cb = Radial.radialConfigTools[k].cb or 255
3988 Radial.radialConfigTools[k].cal = Radial.radialConfigTools[k].cal or 180
3989 Radial.radialConfigTools[k].ca = Radial.radialConfigTools[k].ca or 0
3990 end
3991
3992 -- Save the tool setup
3993 Radial.saveTools()
3994 else --if loading the old tools we need to give them a value
3995 local gottosave = false
3996 for k,v in pairs(Radial.radialConfigTools) do
3997 Radial.radialConfigTools[k].exp = Radial.radialConfigTools[k].exp or 0
3998 Radial.radialConfigTools[k].cr = Radial.radialConfigTools[k].cr or 0
3999 Radial.radialConfigTools[k].cg = Radial.radialConfigTools[k].cg or 255
4000 Radial.radialConfigTools[k].cb = Radial.radialConfigTools[k].cb or 255
4001 Radial.radialConfigTools[k].cal = Radial.radialConfigTools[k].cal or 180
4002 Radial.radialConfigTools[k].ca = Radial.radialConfigTools[k].ca or 0
4003 end
4004 if gottosave then
4005 Radial.saveTools()
4006 end
4007 end
4008
4009 if table.Count(Radial.radialToolPresets) == 0 then
4010 Radial.radialToolPresets["____last"] = {t = table.Copy(Radial.radialConfigTools), s = table.Copy(Radial.radialConfig)}
4011 Radial.radialToolPresets["Default"] = {t = table.Copy(Radial.radialConfigTools), s = table.Copy(Radial.radialConfig)}
4012 Radial.savePresets()
4013 end
4014
4015 if (Radial.radialConfig["gbr-boudkey"] ~= 0 and Radial.radialConfig["gbr-boudkey"] ~= nil and Radial.radialConfig["gbr-boudkey"] < 10003) or (Radial.radialConfig["gbr-boudkey"] >= 10000 and Radial.radialConfig["gbr-boudkey"] < 10003 ) then
4016 if input.LookupBinding( "+gb-radial" ) == nil or input.LookupBinding( "+gb-radial" ) == "" then
4017 local str = input.GetKeyName( Radial.radialConfig["gbr-boudkey"] )
4018 if str == nil or str == "" then str = "NONE" end
4019
4020 str = language.GetPhrase( str )
4021 chat.AddText(Color(120,120,120,255),"\n[",Color(0,255,255,255),"Overhauled Radial Menu",Color(120,120,120,255),"]\n", Color(255,255,255,255)," The function for your keybind got disabled due to a bug .\n Into your console enter: \"",Color(255,190,0,255),"bind <YOURKEY> +gb-radial", Color(255,255,255,255),"\" to bind it to a key.\nI apologize for this circumstance.")
4022 end
4023 if Radial.radialConfig["gbr-boudkey"] < 10000 then
4024 Radial.radialConfig["gbr-boudkey"] = 10000
4025 else
4026 Radial.radialConfig["gbr-boudkey"] = Radial.radialConfig["gbr-boudkey"] + 1
4027 end
4028 print("You'll receive this message "..(10003-Radial.radialConfig["gbr-boudkey"]).." more times if you dont bind it.")
4029 Radial.saveConfig()
4030 end
4031
4032 function Radial.loadradialpreset(pre)
4033 if Radial.radialToolPresets[pre] == nil or Radial.radialToolPresets[pre] == {} then return end
4034 Radial.radialToolPresets["____last"] = {t = table.Copy(Radial.radialConfigTools), s = table.Copy(Radial.radialConfig)}
4035
4036 local hassettings = (Radial.radialToolPresets[pre].s ~= {} and Radial.radialToolPresets[pre].s ~= nil and Radial.radialToolPresets[pre].s["gbr-font"] ~= nil)
4037 local isskin = hassettings and (Radial.radialToolPresets[pre].s["isskin"] ~= nil and Radial.radialToolPresets[pre].s["isskin"] == true) or false
4038 local hastools = (Radial.radialToolPresets[pre].t ~= {} and Radial.radialToolPresets[pre].t ~= nil and Radial.radialToolPresets[pre].t[1] ~= nil)
4039 if not hassettings and not hastools then return end
4040 if hastools then
4041 Radial.radialConfigTools = table.Copy(Radial.radialToolPresets[pre].t)
4042
4043 for k,v in pairs(Radial.radialConfigTools) do
4044 Radial.radialConfigTools[k].exp = Radial.radialConfigTools[k].exp or 0
4045 Radial.radialConfigTools[k].cr = Radial.radialConfigTools[k].cr or 0
4046 Radial.radialConfigTools[k].cg = Radial.radialConfigTools[k].cg or 255
4047 Radial.radialConfigTools[k].cb = Radial.radialConfigTools[k].cb or 255
4048 Radial.radialConfigTools[k].cal = Radial.radialConfigTools[k].cal or 180
4049 Radial.radialConfigTools[k].ca = Radial.radialConfigTools[k].ca or 0
4050 end
4051 end
4052
4053 if hassettings then
4054 if isskin then
4055 local tbl = {}
4056 setmetatable(tbl, debug.getmetatable(Radial.radialToolPresets[pre].s))
4057 for k,v in pairs(Radial.radialToolPresets[pre].s) do
4058 if Radial.SkinVars[k] and Radial.SkinVars[k] == true then
4059 print(k,v)
4060 tbl[k] = v
4061 end
4062 end
4063 table.Merge( Radial.radialConfig, tbl )
4064 else
4065 table.Merge( Radial.radialConfig, table.Copy(Radial.radialToolPresets[pre].s) )
4066 Radial.LoadSkinVars()
4067 end
4068 end
4069 Radial.selectedListTool = nil
4070 Radial.settingshovertool = nil
4071 radialMenuSelectedTool = 0
4072 Radial.refreshsettingstoolslist()
4073 Radial.CalculateMenuLayout()
4074 Radial.savePresets()
4075 end
4076
4077 function Radial.MyRunConsoleCommand(str1)
4078 local cmds = string.Explode(";", string.Trim(str1))
4079 for i = 1, #cmds do
4080 local str = string.Trim(cmds[i])
4081 if str ~= "" and str ~= nil and str ~= " " then
4082 local exp = string.Explode(" ", string.Trim(str))
4083
4084 if string.lower(exp[1]) == "wep" then --support for wep from other older versions of this mod for compatibility and shortening
4085 str = string.gsub( str , "wep", "", 1 )
4086 str = "give "..str.."; use "..str
4087 elseif exp[1] == "load_preset" then
4088 if exp[2] == nil then return end
4089 Radial.loadradialpreset(exp[2])
4090 return
4091 end
4092
4093 if engine.ActiveGamemode() == "sandbox" and string.match(string.lower(str), "^give%W") then
4094 str = "gm_giveswep"..string.sub(str, 5, -1) --if we're in sanbox use the sandboxs give function
4095 end --which also gives adminweapons if you're one
4096 local toolname = ""
4097
4098 local exp = string.Explode(";",str)
4099 for _,v in pairs(exp) do
4100 local ex2 = string.Explode(" ",string.Trim(v))
4101 if string.find(ex2[1],"gmod_tool") then
4102 toolname = ex2[2]
4103 else
4104 MsgC(Color(0,255,255,0),"\n"..v.."\n")
4105 LocalPlayer():ConCommand( string.Trim( v ) ) --this one got no blacklisted commands like disconnect or quit
4106 end --if you'd like to make shortcuts for them
4107
4108 end
4109
4110 if toolname ~= "" then
4111 local tool = weapons.GetStored("gmod_tool").Tool[ toolname ]
4112
4113 if tool then
4114 local tab = g_SpawnMenu:GetToolMenu()
4115
4116 if not IsValid( tab ) then return end
4117 tab:SwitchToName( tool.Tab or "#spawnmenu.tools_tab" )
4118
4119 spawnmenu.ActivateTool( toolname )
4120 end
4121 end
4122 end
4123 end
4124 end
4125
4126 local spacing
4127
4128 -- Calculate positions for the various radial menu entries
4129 function Radial.CalculateMenuLayout()
4130
4131
4132 local angle = Radial.radialConfig["gbr-rotate"] -- Our starting angle
4133
4134 local spa = 0
4135 if #Radial.radialConfigTools == 3 then
4136 spa = 20
4137 elseif #Radial.radialConfigTools <= 2 then
4138 spa = 60
4139 end
4140
4141 spacing = Radial.radialConfig["gbr-spacing"]+spa
4142
4143 local longestName = 0 -- The length of the longest name, used to calculate x/y position
4144 radialEntrySize = 360 / math.Max(table.getn(Radial.radialConfigTools),2)
4145
4146 -- Find the pixelsize of the largest word, to get an even circle
4147
4148 for key,value in pairs(Radial.radialConfigTools) do
4149 -- Is this the longest name yet?
4150 surface.SetFont(tostring(RadialDefaultFont))
4151 tw, th = surface.GetTextSize(value.name)
4152
4153 if key == radialMenuSelectedTool then
4154 value.r = Radial.radialConfig["gbr-hr"]
4155 value.g = Radial.radialConfig["gbr-hg"]
4156 value.b = Radial.radialConfig["gbr-hb"]
4157 value.a = Radial.radialConfig["gbr-ha"]
4158 else
4159 value.r = Radial.radialConfig["gbr-dr"]
4160 value.g = Radial.radialConfig["gbr-dg"]
4161 value.b = Radial.radialConfig["gbr-db"]
4162 value.a = Radial.radialConfig["gbr-da"]
4163 end
4164 if tw > longestName then longestName = tw end
4165 end
4166
4167 longestName = longestName + 8
4168
4169 -- Loop through all tools, and calculate span-angle, x/y position and menu-splitter
4170 for key,value in pairs(Radial.radialConfigTools) do
4171 Radial.radialConfig["loaded_preset"] = ""
4172 value.minangle = angle - (radialEntrySize / 2) + spacing
4173
4174 value.maxangle = angle + (radialEntrySize / 2) - spacing
4175
4176 value.angle = (value.minangle + value.maxangle)/2
4177
4178 if value.minangle < 0 then value.minangle = 360 + value.minangle; value.angle = 0 end -- First tool MinAngle will always dip below 0, and have to "wrap" down from 360
4179
4180 tw, th = surface.GetTextSize(value.name)
4181
4182 local inex = Radial.radialConfig["gbr-selectedinner"]
4183 local oute = Radial.radialConfig["gbr-selectedouter"]
4184
4185 value.xpos = screenCenterX - ((Radial.radialConfig["gbr-menuradius"] + (Radial.radialConfig["gbr-menusplitterlength"]/2)) * math.sin((360 - angle) * (pi / 180))) -- X position of the menu point text
4186 value.ypos = screenCenterY - ((Radial.radialConfig["gbr-menuradius"] + (Radial.radialConfig["gbr-menusplitterlength"]/2)) * math.cos((360 - angle) * (pi / 180))) -- Y position of the menu point text
4187
4188 local inrad = Radial.radialConfig["gbr-menuradius"]
4189 local outrd = Radial.radialConfig["gbr-menusplitterlength"] + Radial.radialConfig["gbr-menuradius"]
4190 local outrd2 = Radial.radialConfig["gbr-menusplitterlength"] * oute + Radial.radialConfig["gbr-menuradius"]
4191
4192 value.xpos2 = screenCenterX - ((inrad*inex)+outrd2) * 0.5 * math.sin((360 - angle) * (pi / 180)) -- X position of the menu point text
4193 value.ypos2 = screenCenterY - ((inrad*inex)+outrd2) * 0.5 * math.cos((360 - angle) * (pi / 180)) -- Y position of the menu point text
4194
4195 value.menusplitxinner = screenCenterX - (inrad * math.sin((360 - value.minangle) * (pi / 180))) -- Used to draw a split-line from center-screen, 100 pixels out
4196 value.menusplityinner = screenCenterY - (inrad * math.cos((360 - value.minangle) * (pi / 180))) -- -O-
4197 value.menusplitxouter = screenCenterX - (outrd * math.sin((360 - value.minangle) * (pi / 180))) -- -O-
4198 value.menusplityouter = screenCenterY - (outrd * math.cos((360 - value.minangle) * (pi / 180))) -- -O-
4199
4200 value.menusplitxinner2= screenCenterX - (inrad * math.sin((360 - value.maxangle) * (pi / 180))) -- Used to draw a split-line from center-screen, 100 pixels out
4201 value.menusplityinner2= screenCenterY - (inrad * math.cos((360 - value.maxangle) * (pi / 180))) -- -O-
4202 value.menusplitxouter2= screenCenterX - (outrd * math.sin((360 - value.maxangle) * (pi / 180))) -- -O-
4203 value.menusplityouter2= screenCenterY - (outrd * math.cos((360 - value.maxangle) * (pi / 180))) -- -O-
4204
4205 value.menusplitxinner3 = screenCenterX - ((inrad*inex) * math.sin((360 - value.minangle) * (pi / 180))) -- Used to draw a split-line from center-screen, 100 pixels out
4206 value.menusplityinner3 = screenCenterY - ((inrad*inex) * math.cos((360 - value.minangle) * (pi / 180))) -- -O-
4207 value.menusplitxinner4 = screenCenterX - ((inrad*inex) * math.sin((360 - value.maxangle) * (pi / 180))) -- Used to draw a split-line from center-screen, 100 pixels out
4208 value.menusplityinner4 = screenCenterY - ((inrad*inex) * math.cos((360 - value.maxangle) * (pi / 180))) -- -O-
4209
4210 value.menusplitxouter3 = screenCenterX - (outrd2 * math.sin((360 - value.minangle) * (pi / 180))) -- Used to draw a split-line from center-screen, 100 pixels out
4211 value.menusplityouter3 = screenCenterY - (outrd2 * math.cos((360 - value.minangle) * (pi / 180))) -- -O-
4212 value.menusplitxouter4 = screenCenterX - (outrd2 * math.sin((360 - value.maxangle) * (pi / 180))) -- Used to draw a split-line from center-screen, 100 pixels out
4213 value.menusplityouter4 = screenCenterY - (outrd2 * math.cos((360 - value.maxangle) * (pi / 180))) -- -O-
4214
4215 tw, th = surface.GetTextSize(value.name)
4216
4217 value.labelwidth = longestName
4218 value.labelheight = th
4219
4220 -- Increase the angle
4221 angle = angle + radialEntrySize
4222 end
4223 end
4224
4225 -- Calculate the menu layout
4226 Radial.CalculateMenuLayout()
4227
4228 -- Functions to show and hide the menu
4229 function Radial.ShowRadialMenu(ply,cmd,args,argstr)
4230 clickedon = ""
4231 -- Enable mouse cursor
4232 if args != nil then
4233 local argc = #args-1
4234 if argc > 0 then
4235 local preset = ""
4236 local n2 = ""
4237 local name = "("
4238 for i = 1, #args-1 do
4239 name = name..".-"..args[i]
4240 n2 = n2.." "..args[i]
4241 end
4242 name = name..")"
4243
4244 for k,v in pairs(Radial.radialToolPresets) do
4245 for w in string.gmatch(k,name) do
4246 preset = k
4247 break
4248 end
4249 end
4250 if preset != "" then
4251 Radial.loadradialpreset(preset)
4252 else
4253 MsgC(Color(255,0,0),"[GB-Radial] No preset found for: "..n2)
4254 end
4255 end
4256 end
4257
4258 gui.EnableScreenClicker(true)
4259
4260 -- Set cursor centerscreen
4261 --gui.SetMousePos(screenCenterX, screenCenterY) --#
4262
4263 -- Show menu
4264 screenCenterX = ScrW() / 2
4265 screenCenterY = ScrH() / 2
4266 Radial.radialMenuOpen = true
4267 end
4268
4269 function Radial.HideRadialMenu()
4270 if Radial.settingsPanelShown then return end
4271
4272 if radialMenuSelectedTool > 0 and clickedon ~= radialMenuSelectedTool then
4273 -- Yes there is, select the tool
4274 Radial.MyRunConsoleCommand(Radial.radialConfigTools[radialMenuSelectedTool].rconcommand)
4275 if Radial.radialConfig["gbr-enablesounds"] == 1 then
4276 sound.Play( "ui/buttonclick.wav" , LocalPlayer():GetShootPos(), 60, 100, 0.2)
4277 end
4278 -- Now we dont have a selected tool
4279 radialMenuSelectedTool = 0
4280 end
4281
4282 if Radial.radialConfig["gbr-onclose"] ~= nil and Radial.radialConfig["gbr-onclose"] ~= "" then
4283 Radial.MyRunConsoleCommand(Radial.radialConfig["gbr-onclose"])
4284 end
4285
4286 -- Is there an active tool?
4287
4288 clickedon = ""
4289 dragging = false
4290
4291 -- Disable mouse cursor
4292 gui.EnableScreenClicker(false)
4293
4294 -- Hide menu
4295 Radial.radialMenuOpen = false
4296
4297 end
4298
4299 local DrawText = surface.DrawText
4300 local SetTextColor = surface.SetTextColor
4301 local SetFont = surface.SetFont
4302 local SetTextPos = surface.SetTextPos
4303 local PopModelMatrix = cam.PopModelMatrix
4304 local PushModelMatrix = cam.PushModelMatrix
4305
4306 local function drawRotatedText(text, x, y, xScale, yScale, angle, centered)
4307 local matrix = Matrix()
4308 local matrixAngle = Angle(0, 0, 0)
4309 local matrixScale = Vector(0, 0, 0)
4310 local matrixTranslation = Vector(0, 0, 0)
4311
4312 matrixAngle.y = math.floor( angle )
4313 matrix:SetAngles(matrixAngle)
4314
4315 matrixTranslation.x = math.floor( x )
4316 matrixTranslation.y = math.floor( y )
4317
4318 if centered then
4319 local sizeX, sizeY = surface.GetTextSize( text )
4320 sizeX = sizeX * xScale
4321 sizeY = sizeY * yScale
4322
4323 matrixTranslation.x = math.floor( matrixTranslation.x - math.sin( math.rad( -angle + 90 ) ) * sizeX / 2 - math.sin( math.rad( -angle ) ) * sizeY / 2)
4324 matrixTranslation.y = math.floor( matrixTranslation.y - math.cos( math.rad( -angle + 90 ) ) * sizeX / 2 - math.cos( math.rad( -angle ) ) * sizeY / 2)
4325 end
4326 matrix:SetTranslation(matrixTranslation)
4327
4328 matrixScale.x = xScale
4329 matrixScale.y = yScale
4330 matrix:Scale(matrixScale)
4331
4332 SetTextPos(0, 0)
4333
4334 PushModelMatrix(matrix)
4335 DrawText(text)
4336 PopModelMatrix()
4337 end
4338
4339 function draw.Circle( x, y, radius, seg ) --from: http://wiki.garrysmod.com/page/surface/DrawPoly
4340 local cir = {}
4341
4342 table.insert( cir, { x = x, y = y, u = 0.5, v = 0.5 } )
4343 for i = 0, seg do
4344 local a = math.rad( ( i / seg ) * -360 )
4345 table.insert( cir, { x = x + math.sin( a ) * radius, y = y + math.cos( a ) * radius, u = math.sin( a ) / 2 + 0.5, v = math.cos( a ) / 2 + 0.5 } )
4346 end
4347
4348 local a = math.rad( 0 ) -- This is need for non absolute segment counts
4349 table.insert( cir, { x = x + math.sin( a ) * radius, y = y + math.cos( a ) * radius, u = math.sin( a ) / 2 + 0.5, v = math.cos( a ) / 2 + 0.5 } )
4350
4351 surface.DrawPoly( cir )
4352 end
4353
4354
4355 -- Print text in a RoundedBox, centered at required coordinates, using given color
4356 function Radial.DrawRadialMenuItem(itemText, itemXpos, itemYpos, labelWidth, labelHeight, textColor, itemAng, fieldWidth)
4357 if not itemText then return end
4358
4359 if Radial.radialConfig["gbr-font"] == nil or Radial.radialConfig["gbr-font"] == "" then return end
4360 SetFont( "Radial.Default_"..Radial.radialConfig["gbr-font"] )
4361 local ang = 0
4362
4363 if Radial.radialConfig["gbr-rotatetext"] == 1 then
4364 ang = math.NormalizeAngle( itemAng - 180 )
4365 if ang >= 89 or ang <= -89 then ang = ang - 180 end
4366 end
4367
4368 local xScale = Radial.radialConfig["gbr-fontscale"]
4369 local yScale = Radial.radialConfig["gbr-fontscale"]
4370
4371 local sizeX, sizeY = surface.GetTextSize( itemText )
4372
4373 if Radial.radialConfig["gbr-clampx"] == 1 then
4374 --xScale = xScale * (fieldWidth / sizeX)
4375 xScale = math.Clamp((fieldWidth / sizeX) * 0.2,0,xScale)
4376 if Radial.radialConfig["gbr-clampy"] == 1 then
4377 yScale = xScale
4378 end
4379 end
4380
4381 local itemX = itemXpos
4382 local itemY = itemYpos
4383
4384 if Radial.radialConfig["gbr-outline"] == 1 then
4385 SetTextColor( Color(0, 0, 0, 255) )
4386 drawRotatedText(itemText, itemX+1, itemY+1, xScale, yScale, ang, true)
4387 drawRotatedText(itemText, itemX+1, itemY-1, xScale, yScale, ang, true)
4388 drawRotatedText(itemText, itemX-1, itemY+1, xScale, yScale, ang, true)
4389 drawRotatedText(itemText, itemX-1, itemY-1, xScale, yScale, ang, true)
4390 end
4391 SetTextColor( textColor )
4392 drawRotatedText(itemText, itemX, itemY, xScale, yScale, ang, true)
4393 end
4394
4395 local ft = VGUIFrameTime()
4396 function Radial.DrawRadialMenu(paint)
4397 --local = true
4398 -- Do not draw the menu if it is not shown
4399 radialMenuSelectedTool = 0
4400 if not Radial.radialMenuOpen then return end
4401 local dt = (VGUIFrameTime() - ft)*33
4402 ft = VGUIFrameTime()
4403
4404 if Radial.settingsPanelShown then
4405
4406 draw.NoTexture()
4407 surface.SetDrawColor(255,255,255,40)
4408 draw.Circle( screenCenterX, screenCenterY, Radial.radialConfig["gbr-menuradius"], 36 )
4409 surface.SetDrawColor(0,0,0,80)
4410 draw.Circle( screenCenterX, screenCenterY, Radial.radialConfig["gbr-menudeadzone"], 36 )
4411 end
4412
4413 -- Is the distance from screen-center to the cursor larger than the set deadspace?
4414 if Radial.settingsPanelShown and (Radial.selectedListTool ~= nil or Radial.settingshovertool ~= nil) then
4415 radialMenuSelectedTool = Radial.selectedListTool or Radial.settingshovertool
4416 Radial.settingshovertool = nil
4417 elseif dragging then
4418 radialMenuSelectedTool = dl
4419 elseif math.Dist(screenCenterX, screenCenterY, gui.MouseX(), gui.MouseY()) > Radial.radialConfig["gbr-menudeadzone"] then
4420 -- We have moved out of the deadzone
4421 -- Calculate the angle from screen-center to the mousecursor, so we can determine which radial element the cursor is over
4422 local radialSelectAngle = 360 - (math.deg(math.atan2(gui.MouseX() - screenCenterX, gui.MouseY() - screenCenterY)) + 180) -- Manipulate the degrees, so we get 0 to be upwards, and increasing clockwise
4423
4424 -- Loop tools them and find out which one is active
4425
4426 local es = (radialEntrySize/2) - spacing
4427 local sa = radialSelectAngle
4428
4429 for key,value in pairs(Radial.radialConfigTools) do
4430 local da = math.abs((value.angle-sa + 180) % 360 - 180) --thanks to wiremod for indirectly helping me ;D
4431 if da < es then
4432 radialMenuSelectedTool = key
4433 end
4434 end
4435 else
4436 -- We are in the deadzone, no tools are selected
4437 radialMenuSelectedTool = 0
4438 end
4439
4440 -- Draw the tool menu entries
4441 local ch = 0
4442 for key,value in pairs(Radial.radialConfigTools) do
4443 ch = ch + 1
4444 if not value == nil then continue end
4445 local sp = {
4446 {x = value.menusplitxouter2, y = value.menusplityouter2},
4447 {x = value.menusplitxinner2, y = value.menusplityinner2},
4448 {x = value.menusplitxinner, y = value.menusplityinner},
4449 {x = value.menusplitxouter, y = value.menusplityouter},
4450 }
4451 draw.NoTexture()
4452 --surface.SetDrawColor(Radial.radialConfig["gbr-dr"], Radial.radialConfig["gbr-dg"], Radial.radialConfig["gbr-db"], 180)
4453
4454 local colspeed = Radial.radialConfig["gbr-colorspeed"]*dt
4455
4456 if key == radialMenuSelectedTool then
4457 -- This is the selected tool
4458 -- Draw the splitter-poly, if the user wants to
4459 sp = {
4460 {x = value.menusplitxouter4, y = value.menusplityouter4},
4461 {x = value.menusplitxinner4, y = value.menusplityinner4},
4462 {x = value.menusplitxinner3, y = value.menusplityinner3},
4463 {x = value.menusplitxouter3, y = value.menusplityouter3},
4464 }
4465 value.r = Lerp( colspeed, value.r, Radial.radialConfig["gbr-hr"] )
4466 value.g = Lerp( colspeed, value.g, Radial.radialConfig["gbr-hg"] )
4467 value.b = Lerp( colspeed, value.b, Radial.radialConfig["gbr-hb"] )
4468 value.a = Lerp( colspeed, value.a, Radial.radialConfig["gbr-ha"] )
4469 else
4470 if value.ca == 1 then
4471 value.r = Lerp( colspeed, value.r, value.cr )
4472 value.g = Lerp( colspeed, value.g, value.cg )
4473 value.b = Lerp( colspeed, value.b, value.cb )
4474 value.a = Lerp( colspeed, value.a, value.cal )
4475 else
4476 value.r = Lerp( colspeed, value.r, Radial.radialConfig["gbr-dr"] )
4477 value.g = Lerp( colspeed, value.g, Radial.radialConfig["gbr-dg"] )
4478 value.b = Lerp( colspeed, value.b, Radial.radialConfig["gbr-db"] )
4479 value.a = Lerp( colspeed, value.a, Radial.radialConfig["gbr-da"] )
4480 end
4481 end
4482
4483 surface.SetDrawColor(value.r, value.g, value.b, value.a)
4484 value.visualVertexData = value.visualVertexData or sp
4485
4486 local animSpeed = Radial.radialConfig["gbr-animspeed"]*dt
4487 value.visualVertexData = {
4488 { x = Lerp( animSpeed, value.visualVertexData[1].x, sp[1].x ), y = Lerp( animSpeed, value.visualVertexData[1].y, sp[1].y ) },
4489 { x = Lerp( animSpeed, value.visualVertexData[2].x, sp[2].x ), y = Lerp( animSpeed, value.visualVertexData[2].y, sp[2].y ) },
4490 { x = Lerp( animSpeed, value.visualVertexData[3].x, sp[3].x ), y = Lerp( animSpeed, value.visualVertexData[3].y, sp[3].y ) },
4491 { x = Lerp( animSpeed, value.visualVertexData[4].x, sp[4].x ), y = Lerp( animSpeed, value.visualVertexData[4].y, sp[4].y ) },
4492 }
4493
4494 local vvd = value.visualVertexData
4495
4496 local tang = Vector(vvd[4].x-vvd[1].x,vvd[4].y-vvd[1].y,0):Angle().y %360 - 180
4497
4498 surface.DrawPoly(vvd)
4499
4500 if (clickedon ~= key and Radial.radialConfig["gbr-drawborder"] == 1) or (clickedon == key and Radial.radialConfig["gbr-drawborder"] == 0) then
4501 if key == radialMenuSelectedTool then
4502 value.r = Lerp( colspeed, value.r, Radial.radialConfig["gbr-hr"] )
4503 value.g = Lerp( colspeed, value.g, Radial.radialConfig["gbr-hg"] )
4504 value.b = Lerp( colspeed, value.b, Radial.radialConfig["gbr-hb"] )
4505 value.a = Lerp( colspeed, value.a, Radial.radialConfig["gbr-ha"] )
4506 else
4507 if value.ca == 1 then
4508 value.r = Lerp( colspeed, value.r, value.cr )
4509 value.g = Lerp( colspeed, value.g, value.cg )
4510 value.b = Lerp( colspeed, value.b, value.cb )
4511 value.a = Lerp( colspeed, value.a, value.cal )
4512 else
4513 value.r = Lerp( colspeed, value.r, Radial.radialConfig["gbr-dr"] )
4514 value.g = Lerp( colspeed, value.g, Radial.radialConfig["gbr-dg"] )
4515 value.b = Lerp( colspeed, value.b, Radial.radialConfig["gbr-db"] )
4516 value.a = Lerp( colspeed, value.a, Radial.radialConfig["gbr-da"] )
4517 end
4518 end
4519 if paint then
4520 /*local alpha,pct = 0,value.a/255
4521 for I = 1, Radial.radialConfig["gbr-borderpasses"] do
4522 alpha = alpha+255*(pct/I)
4523 end*/
4524 --
4525 alpha = math.min(255,value.a*Radial.radialConfig["gbr-borderpasses"])
4526
4527 surface.SetDrawColor(value.r, value.g, value.b, alpha)
4528 --for I = 1, Radial.radialConfig["gbr-borderpasses"] do
4529 surface.DrawLine( vvd[1].x, vvd[1].y, vvd[2].x, vvd[2].y )
4530 surface.DrawLine( vvd[2].x, vvd[2].y, vvd[3].x, vvd[3].y )
4531 surface.DrawLine( vvd[3].x, vvd[3].y, vvd[4].x, vvd[4].y )
4532 surface.DrawLine( vvd[4].x, vvd[4].y, vvd[1].x, vvd[1].y )
4533 --end
4534 end
4535 end
4536
4537 local posX = (math.floor(vvd[ 1 ].x) + math.floor(vvd[ 2 ].x)) / 2
4538 local posY = (math.floor(vvd[ 1 ].y) + math.floor(vvd[ 2 ].y)) / 2
4539 local pos2X = (math.floor(vvd[ 3 ].x) + math.floor(vvd[ 4 ].x)) / 2
4540 local pos2Y = (math.floor(vvd[ 3 ].y) + math.floor(vvd[ 4 ].y)) / 2
4541
4542 local fposX = (posX + pos2X) / 2
4543 local fposY = (posY + pos2Y) / 2
4544
4545 local fieldWidth = 0
4546 if Radial.radialConfig["gbr-clampx"] == 1 then
4547 fieldWidth = (Vector( vvd[3].x - vvd[2].x, vvd[3].y - vvd[2].y, 0 ):Length() + Vector( vvd[1].x - vvd[4].x, vvd[1].y - vvd[4].y, 0 ):Length()) * 2
4548 end
4549
4550 if paint then
4551 Radial.DrawRadialMenuItem(value.name, fposX, fposY, value.labelwidth, value.labelheight, Color(Radial.radialConfig["gbr-tr"], Radial.radialConfig["gbr-tg"], Radial.radialConfig["gbr-tb"], Radial.radialConfig["gbr-ta"] ), tang, fieldWidth)
4552 end
4553 end
4554
4555 if dragging then
4556 local function sign (xy,w)
4557 if xy > w then return w elseif xy < -w then return -w else return 0 end
4558 end
4559
4560 local mx = gui.MouseX()
4561 local my = gui.MouseY()
4562 local dx = dip.x
4563 local dy = dip.y
4564 local ddx= mx-dx
4565 local ddy= my-dy
4566 local ax = 1
4567 local add = 0
4568 local cmd = Radial.radialConfigTools[dl].rconcommand
4569 local lst = st
4570 if string.find(cmd,"spawn") or string.find(cmd,"create") then
4571 st = math.Clamp(1+math.floor(math.abs(ddx)/64),0,6)
4572 else
4573 st = 1+math.floor(math.abs(ddx)/64)
4574 end
4575 if Radial.radialConfig["gbr-enablesounds"] == 1 then
4576 if st > lst then
4577 sound.Play( "buttons/lightswitch2.wav" , LocalPlayer():GetShootPos(), 60, 255, 0.3)
4578 elseif st < lst then
4579 sound.Play( "buttons/blip1.wav" , LocalPlayer():GetShootPos(), 60, 200, 0.1)
4580 end
4581 end
4582 if paint then
4583 surface.SetDrawColor(Color(0,0,0,255))
4584 surface.DrawOutlinedRect(dx-4,dy-4,8,8)
4585 if sign(ddy,4) ~= 0 then
4586 if sign(ddy,1) == 1 then add = 1 end
4587 surface.DrawLine(dx,dy+sign(ddy,4),dx,my+add)
4588 surface.DrawLine(dx-1,dy+sign(ddy,4),dx-1,my+add)
4589 ax = 0
4590 end
4591 surface.DrawLine(dx+4*sign(ddx,1)*ax,my,mx,my)
4592 --surface.DrawLine(dx,my-1*sign(ddy,1),mx,my-1*sign(ddy,1))
4593
4594 surface.SetFont( "DermaDefault" )
4595 surface.SetTextColor( 0, 0, 0, 255 )
4596
4597 for j = 1, st-1, 1 do
4598 local sx = dx+64*j*sign(ddx,1)
4599 local sd = sign(ddy,-1)
4600 local sy = my+(7+add)*sd
4601 local txt = j+1
4602 surface.DrawLine(sx,my+add*sd,sx,sy)
4603 local tsx, tsy = surface.GetTextSize(txt)
4604 surface.SetTextPos(sx-tsx/2, sy-tsy/2 + 6*sd)
4605 surface.DrawText(txt)
4606 end
4607
4608 local tx = 6
4609 local ty = 7
4610
4611 if Radial.radialConfig["gbr-outline"] == 1 then
4612 surface.SetTextPos(dx+tx+1, dy-ty+1)
4613 surface.DrawText(tostring(st))
4614 surface.SetTextPos(dx+tx+1, dy-ty-1)
4615 surface.DrawText(tostring(st))
4616 surface.SetTextPos(dx+tx-1, dy-ty+1)
4617 surface.DrawText(tostring(st))
4618 surface.SetTextPos(dx+tx-1, dy-ty-1)
4619 surface.DrawText(tostring(st))
4620 end
4621
4622 surface.SetTextColor( Radial.radialConfig["gbr-hr"], Radial.radialConfig["gbr-hg"], Radial.radialConfig["gbr-hb"], 255 )
4623 surface.SetTextPos(dx+tx, dy-ty)
4624 surface.DrawText(tostring(st))
4625
4626 surface.SetDrawColor(Color(Radial.radialConfig["gbr-hr"], Radial.radialConfig["gbr-hg"], Radial.radialConfig["gbr-hb"],180))
4627 surface.DrawRect(dx-3,dy-3,6,6)
4628 end
4629 end
4630
4631 -- Draw a line from screen-center to mouse cursor, if enabled
4632 if Radial.radialConfig["gbr-menushowtraceline"] == 1 and paint then
4633 surface.SetDrawColor(255, 255, 255, 180)
4634 local mx, my
4635 if dragging then
4636 mx, my = dip.x, dip.y
4637 else
4638 mx, my = gui.MouseX() , gui.MouseY()
4639 end
4640 local ang = Vector(mx - screenCenterX, my - screenCenterY, 0):Angle().y
4641
4642 local dist = math.min( Vector( screenCenterX, screenCenterY, 0 ):Distance( Vector( mx, my, 0) ), Radial.radialConfig["gbr-menudeadzone"]-20)
4643
4644 local x = screenCenterX - (dist * math.sin((270-ang) * (pi / 180)))
4645 local y = screenCenterY - (dist * math.cos((270-ang) * (pi / 180)))
4646 --surface.DrawLine(screenCenterX, screenCenterY, x, y)
4647 surface.SetTexture( tex )
4648 surface.DrawTexturedRectRotated( x, y, 32, 32, 225-ang )
4649 end
4650
4651 if Radial.radialConfig["gbr-showhelp"] == 1 and paint then
4652 local txt1 = ""
4653 local txt2 = ""
4654 local txt3 = ""
4655 local tcol = Color(255,255,255,255)
4656 local col = Color(80,80,80,180)
4657 if Radial.settingsPanelShown then
4658 tcol = Color(255,180,0,255)
4659 col = Color(20,20,20,180)
4660 end
4661
4662 --Radial.radialConfigTools[radialMenuSelectedTool].
4663 if radialMenuSelectedTool ~= 0 and radialMenuSelectedTool ~= nil and Radial.radialConfigTools[radialMenuSelectedTool] ~= nil then
4664 if Radial.radialConfigTools[radialMenuSelectedTool].exp == 1 then
4665 if dragging then
4666 txt1 = "Release to execute. [Left Mouse]"
4667 txt2 = "Click to cancel. [Right Mouse]"
4668 txt3 = "Close to cancel. [Menu]"
4669 else
4670 txt1 = "Hold to drag. [Left Mouse]"
4671 if not Radial.settingsPanelShown then
4672 txt2 = "Click to open options menu. [Right Mouse]"
4673 else
4674 txt2 = "[Menu actions disabled.]"
4675 end
4676 if clickedon == radialMenuSelectedTool then
4677 txt3 = ""
4678 else
4679 txt3 = "Close to execute. [Menu]"
4680 end
4681 end
4682 else
4683 txt1 = "Click to execute. [Left Mouse]"
4684 if not Radial.settingsPanelShown then
4685 txt2 = "Click to open options menu. [Right Mouse]"
4686 else
4687 txt2 = "[Menu actions disabled.]"
4688 end
4689 if clickedon == radialMenuSelectedTool then
4690 txt3 = ""
4691 else
4692 txt3 = "Close to execute. [Menu]"
4693 end
4694 end
4695 elseif paint then
4696 if clickedon ~= 0 and clickedon ~= nil then
4697 txt1 = "Click to deselect. [Left Mouse]"
4698 else
4699 txt1 = "Move cursor over an action."
4700 end
4701 if not Radial.settingsPanelShown then
4702 txt2 = "Click to open options menu. [Right Mouse]"
4703 else
4704 txt2 = "[Menu actions disabled.]"
4705 end
4706 txt3 = ""
4707 end
4708
4709 if paint then
4710 local sx, sy = ScrW(), ScrH()
4711
4712 surface.SetFont( "DermaDefault" )
4713 surface.SetTextColor( tcol )
4714
4715 local tsx, tsy = surface.GetTextSize(txt1)
4716 draw.RoundedBoxEx( 8, sx-40-tsx, sy - 100, 30+tsx,4+tsy, col,true,true,true,false)
4717 surface.SetTextPos(sx-25-tsx, sy - 98)
4718 surface.DrawText(tostring(txt1))
4719
4720 local tsx, tsy = surface.GetTextSize(txt2)
4721 draw.RoundedBoxEx( 8, sx-40-tsx, sy - 80, 30+tsx,4+tsy, col,true,false,true,false)
4722 surface.SetTextPos(sx-25-tsx, sy - 78)
4723 surface.DrawText(tostring(txt2))
4724
4725 local tsx, tsy = surface.GetTextSize(txt3)
4726 draw.RoundedBoxEx( 8, sx-40-tsx, sy - 60, 30+tsx,4+tsy, col,true,false,true,true)
4727 surface.SetTextPos(sx-25-tsx, sy - 58)
4728 surface.DrawText(tostring(txt3))
4729 end
4730 end
4731
4732 end
4733
4734 local function drawmenu()
4735 Radial.DrawRadialMenu(true)
4736 end
4737 local function calcmenu()
4738 Radial.DrawRadialMenu(false)
4739 end
4740
4741 -- Add hook to paint the radial menu
4742 hook.Add("HUDPaint", "Radial.DrawRadialMenu", drawmenu)
4743 hook.Add("Think", "Radial.DrawRadialMenu", calcmenu) --makes it a bit smoother
4744 local ld = false
4745 local rd = false
4746
4747 -- Capture both left and right-click (to override left, and open settings menu on right
4748 function Radial.CaptureMouseClicks()
4749 -- Do not do any of this if the menu is not shown
4750 if not Radial.radialMenuOpen then return end
4751
4752 lld = ld
4753 lrd = rd
4754 ld = input.IsMouseDown( MOUSE_LEFT )
4755 rd = input.IsMouseDown( MOUSE_RIGHT )
4756
4757 LDown = lld ~= ld and ld
4758 RDown = lrd ~= rd and rd
4759 -- Handle different clicktypes
4760 if LDown then
4761 if not Radial.settingsPanelShown and Radial.radialMenuOpen then
4762 clickedon = radialMenuSelectedTool
4763 if radialMenuSelectedTool ~= nil and radialMenuSelectedTool ~= 0 then
4764 if Radial.radialConfigTools[radialMenuSelectedTool].exp == 1 then
4765 dragging = true
4766 st = 0
4767 dl = radialMenuSelectedTool
4768 dip = {x = gui.MouseX(), y = gui.MouseY()}
4769 else
4770 Radial.MyRunConsoleCommand(Radial.radialConfigTools[radialMenuSelectedTool].rconcommand)
4771 if Radial.radialConfig["gbr-enablesounds"] == 1 then
4772 sound.Play( "ui/buttonclickrelease.wav" , LocalPlayer():GetShootPos(), 60, 100, 0.1)
4773 end
4774 end
4775 end
4776 end
4777 return true
4778 elseif RDown then
4779 -- Right click, open the config menu
4780 if not dragging then
4781 Radial.openRadialMenuConfig()
4782 if Radial.radialConfig["gbr-enablesounds"] == 1 then
4783 sound.Play( "ui/buttonrollover.wav" , LocalPlayer():GetShootPos(), 60, 100, 0.5)
4784 end
4785 else --cancel dragging
4786 gui.SetMousePos(dip.x, dip.y)
4787 dragging = false
4788 if Radial.radialConfig["gbr-enablesounds"] == 1 then
4789 sound.Play( "buttons/blip1.wav" , LocalPlayer():GetShootPos(), 60, 200, 0.1)
4790 end
4791 end
4792 return true
4793 end
4794 end
4795 local cando = true
4796 function Radial.CaptureMouseRelease()
4797 if not input.IsMouseDown( MOUSE_LEFT ) and dragging then
4798 gui.SetMousePos(dip.x, dip.y)
4799 local cmd = Radial.radialConfigTools[dl].rconcommand
4800 if string.find(cmd,"spawn") or string.find(cmd,"create") then --making spawning less spammy but keeping it still useful
4801 local function doitnowgoddamnit()
4802 Radial.MyRunConsoleCommand(cmd)
4803 end
4804 local function redo()
4805 cando = true
4806 end
4807 if cando then
4808 cando = false
4809 for i = 1, st, 1 do
4810 timer.Simple(i*0.2,doitnowgoddamnit)
4811 end
4812 timer.Simple((st+1)*0.2,redo)
4813 end
4814 else
4815 for i = 1, st, 1 do
4816 Radial.MyRunConsoleCommand(cmd)
4817 end
4818 end
4819 if Radial.radialConfig["gbr-enablesounds"] == 1 then
4820 sound.Play( "ui/buttonclickrelease.wav" , LocalPlayer():GetShootPos(), 60, 100, 0.1)
4821 end
4822 dragging = false --#
4823 end
4824 end
4825 hook.Add("Think", "Radial.CaptureMouseClicks", Radial.CaptureMouseClicks)
4826
4827 hook.Add("Think", "Radial.CaptureMouseRelease", Radial.CaptureMouseRelease)
4828
4829 -- Add con commands to show/hide the menu
4830 hook.Add("Think","Radial.MenuOpenHook",function()
4831 local opener = Radial.settingsPanelShown
4832 if not Radial.radialMenuOpen and opener then
4833 Radial.ShowRadialMenu()
4834 end
4835 end)
4836
4837 concommand.Add("+gb-radial", Radial.ShowRadialMenu) --for backward-compatibility
4838 concommand.Add("-gb-radial", Radial.HideRadialMenu)
4839end