Advertisement
Guest User

Untitled

a guest
Feb 12th, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 44.85 KB | None | 0 0
  1. --[[
  2. © 2013 Slidefuse.net
  3. © 2015 Novabox.org
  4. --]]
  5.  
  6. local PANEL = {};
  7.  
  8. local forumLink = "http://gmod.novabox.org/forums/";
  9. local forumText = "Forum";
  10.  
  11. local steamGroupLink = "http://steamcommunity.com/groups/novabox";
  12. local steamGroupText = "Steam Group";
  13.  
  14. local contentLink = "http://gmod.novabox.org/forums/link-forums/content.45/"
  15. local contentText = "Server Content";
  16.  
  17. -- Called when the panel is initialized.
  18. function PANEL:Init()
  19. if (!Clockwork.theme:Call("PreCharacterMenuInit", self)) then
  20. local smallTextFont = Clockwork.option:GetFont("menu_text_small");
  21. local tinyTextFont = Clockwork.option:GetFont("menu_text_tiny");
  22. local hugeTextFont = Clockwork.option:GetFont("menu_text_huge");
  23. local scrH = ScrH();
  24. local scrW = ScrW();
  25.  
  26. self:SetPos(0, 0);
  27. self:SetSize(scrW, scrH);
  28. self:SetDrawOnTop(false);
  29. self:SetPaintBackground(false);
  30. self:SetMouseInputEnabled(true);
  31.  
  32. self.titleLabel = vgui.Create("cwLabelButton", self);
  33. self.titleLabel:SetDisabled(true);
  34. self.titleLabel:SetFont(hugeTextFont);
  35. self.titleLabel:SetText(string.upper(Schema:GetName()));
  36.  
  37. local schemaLogo = Clockwork.option:GetKey("schema_logo");
  38.  
  39. self.subLabel = vgui.Create("cwLabelButton", self);
  40. self.subLabel:SetDisabled(true);
  41. self.subLabel:SetFont(smallTextFont);
  42. self.subLabel:SetText(string.upper(Schema:GetDescription()));
  43. self.subLabel:SizeToContents();
  44.  
  45. if (schemaLogo == "") then
  46. self.titleLabel:SetVisible(true);
  47. self.titleLabel:SizeToContents();
  48. self.titleLabel:SetPos((scrW / 2) - (self.titleLabel:GetWide() / 2), scrH * 0.4);
  49. self.subLabel:SetPos((scrW / 2) - (self.subLabel:GetWide() / 2), self.titleLabel.y + self.titleLabel:GetTall() + 8);
  50. else
  51. self.titleLabel:SetVisible(false);
  52. self.titleLabel:SetSize(512, 256);
  53. self.titleLabel:SetPos((scrW / 2) - (self.titleLabel:GetWide() / 2), scrH * 0.4 - 128);
  54. self.subLabel:SetPos(self.titleLabel.x + (self.titleLabel:GetWide() / 2) - (self.subLabel:GetWide() / 2), self.titleLabel.y + self.titleLabel:GetTall() + 8);
  55. end;
  56.  
  57. self.authorLabel = vgui.Create("cwLabelButton", self);
  58. self.authorLabel:SetDisabled(true);
  59. self.authorLabel:SetFont(tinyTextFont);
  60. self.authorLabel:SetText("DEVELOPED BY "..string.upper(Schema:GetAuthor()));
  61. self.authorLabel:SizeToContents();
  62. self.authorLabel:SetPos(self.subLabel.x + (self.subLabel:GetWide() - self.authorLabel:GetWide()), self.subLabel.y + self.subLabel:GetTall() + 4);
  63.  
  64. self.forumButton = vgui.Create("cwLabelButton", self);
  65. self.forumButton:SetFont(smallTextFont);
  66. self.forumButton:SetText(forumText);
  67. self.forumButton:SetAlpha(0);
  68. self.forumButton:FadeIn(1);
  69. self.forumButton:SetCallback(function(panel)
  70. gui.OpenURL(forumLink)
  71. end);
  72. self.forumButton:SizeToContents();
  73. self.forumButton:SetMouseInputEnabled(true);
  74. self.forumButton:SetPos((ScrW() * 0.85) - self.forumButton:GetWide(), ScrH() * 0.6);
  75.  
  76. self.steamGroupButton = vgui.Create("cwLabelButton", self);
  77. self.steamGroupButton:SetFont(smallTextFont);
  78. self.steamGroupButton:SetText(steamGroupText);
  79. self.steamGroupButton:SetAlpha(0);
  80. self.steamGroupButton:FadeIn(1);
  81. self.steamGroupButton:SetCallback(function(panel)
  82. gui.OpenURL(steamGroupLink)
  83. end);
  84. self.steamGroupButton:SizeToContents();
  85. self.steamGroupButton:SetMouseInputEnabled(true);
  86. self.steamGroupButton:SetPos((ScrW() * 0.85) - self.steamGroupButton:GetWide(), ScrH() * 0.65);
  87.  
  88. self.contentButton = vgui.Create("cwLabelButton", self);
  89. self.contentButton:SetFont(smallTextFont);
  90. self.contentButton:SetText(contentText);
  91. self.contentButton:SetAlpha(0);
  92. self.contentButton:FadeIn(1);
  93. self.contentButton:SetCallback(function(panel)
  94. gui.OpenURL(contentLink)
  95. end);
  96. self.contentButton:SizeToContents();
  97. self.contentButton:SetMouseInputEnabled(true);
  98. self.contentButton:SetPos((ScrW() * 0.85) - self.contentButton:GetWide(), ScrH() * 0.7);
  99.  
  100. self.createButton = vgui.Create("cwLabelButton", self);
  101. self.createButton:SetFont(smallTextFont);
  102. self.createButton:SetText("New Citizen");
  103. self.createButton:FadeIn(0.5);
  104. self.createButton:SetCallback(function(panel)
  105. if (table.Count(Clockwork.character:GetAll()) >= Clockwork.player:GetMaximumCharacters()) then
  106. return Clockwork.character:SetFault("You cannot create any more characters!");
  107. end;
  108.  
  109. Clockwork.character:ResetCreationInfo();
  110. Clockwork.character:OpenNextCreationPanel();
  111. end);
  112. self.createButton:SizeToContents();
  113. self.createButton:SetMouseInputEnabled(true);
  114. self.createButton:SetPos(scrW * 0.25, 16);
  115.  
  116. self.loadButton = vgui.Create("cwLabelButton", self);
  117. self.loadButton:SetFont(smallTextFont);
  118. self.loadButton:SetText("Character List");
  119. self.loadButton:FadeIn(0.5);
  120. self.loadButton:SetCallback(function(panel)
  121. self:OpenPanel("cwCharacterList", nil, function(panel)
  122. Clockwork.character:RefreshPanelList();
  123. end);
  124. end);
  125. self.loadButton:SetDisabled(true)
  126. self.loadButton:SizeToContents();
  127. self.loadButton:SetMouseInputEnabled(true);
  128. self.loadButton:SetPos(scrW * 0.75, 16);
  129.  
  130. self.disconnectButton = vgui.Create("cwLabelButton", self);
  131. self.disconnectButton:SetFont(smallTextFont);
  132. self.disconnectButton:SetText("LEAVE");
  133. self.disconnectButton:FadeIn(0.5);
  134. self.disconnectButton:SetCallback(function(panel)
  135. if (Clockwork.Client:HasInitialized() and !Clockwork.character:IsMenuReset()) then
  136. Clockwork.character:SetPanelMainMenu();
  137. Clockwork.character:SetPanelOpen(false);
  138. else
  139. RunConsoleCommand("disconnect");
  140. end;
  141. end);
  142. self.disconnectButton:SizeToContents();
  143. self.disconnectButton:SetPos((scrW / 2) - (self.disconnectButton:GetWide() / 2), 16);
  144. self.disconnectButton:SetMouseInputEnabled(true);
  145.  
  146. self.previousButton = vgui.Create("cwLabelButton", self);
  147. self.previousButton:SetFont(tinyTextFont);
  148. self.previousButton:SetText("PREVIOUS CHARACTER");
  149. self.previousButton:SetCallback(function(panel)
  150. if (!Clockwork.character:IsCreationProcessActive()) then
  151. local activePanel = Clockwork.character:GetActivePanel();
  152.  
  153. if (activePanel and activePanel.OnPrevious) then
  154. activePanel:OnPrevious();
  155. end;
  156. else
  157. Clockwork.character:OpenPreviousCreationPanel()
  158. end;
  159. end);
  160. self.previousButton:SizeToContents();
  161. self.previousButton:SetMouseInputEnabled(true);
  162. self.previousButton:SetPos((scrW * 0.2) - (self.previousButton:GetWide() / 2), scrH * 0.9);
  163.  
  164. self.nextButton = vgui.Create("cwLabelButton", self);
  165. self.nextButton:SetFont(tinyTextFont);
  166. self.nextButton:SetText("NEXT CHARACTER");
  167. self.nextButton:SetCallback(function(panel)
  168. if (!Clockwork.character:IsCreationProcessActive()) then
  169. local activePanel = Clockwork.character:GetActivePanel();
  170.  
  171. if (activePanel and activePanel.OnNext) then
  172. activePanel:OnNext();
  173. end;
  174. else
  175. Clockwork.character:OpenNextCreationPanel()
  176. end;
  177. end);
  178. self.nextButton:SizeToContents();
  179. self.nextButton:SetMouseInputEnabled(true);
  180. self.nextButton:SetPos((scrW * 0.8) - (self.nextButton:GetWide() / 2), scrH * 0.9);
  181.  
  182. self.cancelButton = vgui.Create("cwLabelButton", self);
  183. self.cancelButton:SetFont(tinyTextFont);
  184. self.cancelButton:SetText("Back to Menu");
  185. self.cancelButton:SetCallback(function(panel)
  186. self:ReturnToMainMenu();
  187. end);
  188. self.cancelButton:SizeToContents();
  189. self.cancelButton:SetMouseInputEnabled(true);
  190. self.cancelButton:SetPos((scrW * 0.5) - (self.cancelButton:GetWide() / 2), scrH * 0.9);
  191.  
  192. self.characterModel = vgui.Create("cwCharacterModel", self);
  193. self.characterModel:SetSize(512, 512);
  194. self.characterModel:SetAlpha(0);
  195. self.characterModel:SetModel("models/error.mdl");
  196. self.createTime = SysTime();
  197.  
  198. Clockwork.theme:Call("PostCharacterMenuInit", self)
  199.  
  200. --[[timer.Simple(3.5, function()
  201. self:OpenPanel("cwCharacterList", nil, function(panel)
  202. Clockwork.character:RefreshPanelList();
  203. self.loadButton:SetDisabled(false)
  204. end);
  205. end)--]]
  206. end;
  207. end;
  208.  
  209. -- A function to fade in the model panel.
  210. function PANEL:FadeInModelPanel(model)
  211. local panel = Clockwork.character:GetActivePanel();
  212. local x, y = ScrW() - self.characterModel:GetWide() - 8, 16;
  213.  
  214. if (panel) then
  215. x, y = panel.x + panel:GetWide() - 16, panel.y - 80;
  216. end;
  217.  
  218. self.characterModel:SetPos(x, y);
  219.  
  220. if (self.characterModel:FadeIn(0.5)) then
  221. self:SetModelPanelModel(model);
  222. return true;
  223. else
  224. return false;
  225. end;
  226. end;
  227.  
  228. -- A function to fade out the model panel.
  229. function PANEL:FadeOutModelPanel()
  230. self.characterModel:FadeOut(0.5);
  231. end;
  232.  
  233. -- A function to set the model panel's model.
  234. function PANEL:SetModelPanelModel(model)
  235. if (self.characterModel.currentModel != model) then
  236. self.characterModel.currentModel = model;
  237. self.characterModel:SetModel(model);
  238. end;
  239.  
  240. local modelPanel = self.characterModel:GetModelPanel();
  241. local weaponModel = Clockwork.plugin:Call(
  242. "GetModelSelectWeaponModel", model
  243. );
  244. local sequence = Clockwork.plugin:Call(
  245. "GetModelSelectSequence", modelPanel.Entity, model
  246. );
  247.  
  248. if (weaponModel) then
  249. self.characterModel:SetWeaponModel(weaponModel);
  250. else
  251. self.characterModel:SetWeaponModel(false);
  252. end;
  253.  
  254. if (sequence) then
  255. modelPanel.Entity:ResetSequence(sequence);
  256. end;
  257. end;
  258.  
  259. -- A function to return to the main menu.
  260. function PANEL:ReturnToMainMenu()
  261. local panel = Clockwork.character:GetActivePanel();
  262.  
  263. if (panel) then
  264. panel:FadeOut(0.5, function()
  265. Clockwork.character.activePanel = nil;
  266. panel:Remove();
  267. self:FadeInTitle();
  268. end);
  269. else
  270. self:FadeInTitle();
  271. end;
  272.  
  273. self:FadeOutModelPanel();
  274. self:FadeOutNavigation();
  275. end;
  276.  
  277. --A function to fade out the navigation.
  278. function PANEL:FadeOutNavigation()
  279. self.previousButton:FadeOut(0.5);
  280. self.cancelButton:FadeOut(0.5);
  281. self.nextButton:FadeOut(0.5);
  282. end;
  283.  
  284. -- A function to fade in the navigation.
  285. function PANEL:FadeInNavigation()
  286. self.previousButton:FadeIn(0.5);
  287. self.cancelButton:FadeIn(0.5);
  288. self.nextButton:FadeIn(0.5);
  289. end;
  290.  
  291. -- A function to fade out the title.
  292. function PANEL:FadeOutTitle()
  293. self.subLabel:FadeOut(0.5);
  294. self.titleLabel:FadeOut(0.5);
  295. self.authorLabel:FadeOut(0.5);
  296. self.forumButton:FadeOut(0.5);
  297. self.steamGroupButton:FadeOut(0.5);
  298. self.contentButton:FadeOut(0.5);
  299. end;
  300.  
  301. -- A function to fade in the title.
  302. function PANEL:FadeInTitle()
  303. self.subLabel:FadeIn(0.5);
  304. self.forumButton:FadeIn(0.5);
  305. self.steamGroupButton:FadeIn(0.5);
  306. self.contentButton:FadeIn(0.5);
  307. self.titleLabel:FadeIn(0.5);
  308. self.authorLabel:FadeIn(0.5);
  309. end;
  310.  
  311. -- A function to open a panel.
  312. function PANEL:OpenPanel(vguiName, childData, Callback)
  313. if (!Clockwork.theme:Call("PreCharacterMenuOpenPanel", self, vguiName, childData, Callback)) then
  314. local panel = Clockwork.character:GetActivePanel();
  315.  
  316. if (panel) then
  317. panel:FadeOut(0.5, function()
  318. panel:Remove(); self.childData = childData;
  319.  
  320. Clockwork.character.activePanel = vgui.Create(vguiName, self);
  321. Clockwork.character.activePanel:SetAlpha(0);
  322. Clockwork.character.activePanel:FadeIn(0.5);
  323. Clockwork.character.activePanel:MakePopup();
  324. Clockwork.character.activePanel:SetPos(0, 64);
  325. Clockwork.character.activePanel:SetSize(ScrW(), ScrH()-64)
  326. Clockwork.character.activePanel:MakePopup()
  327.  
  328. if (Callback) then
  329. Callback(Clockwork.character.activePanel);
  330. end;
  331.  
  332. if (childData) then
  333. Clockwork.character.activePanel.bIsCreationProcess = true;
  334. Clockwork.character:FadeOutNavigation();
  335. end;
  336. end);
  337. else
  338. self.childData = childData;
  339. self:FadeOutTitle();
  340.  
  341. Clockwork.character.activePanel = vgui.Create(vguiName, self);
  342. Clockwork.character.activePanel:SetAlpha(0);
  343. Clockwork.character.activePanel:FadeIn(0.5);
  344. Clockwork.character.activePanel:SetPos(0, 64);
  345. Clockwork.character.activePanel:SetSize(ScrW(), ScrH()-64)
  346. Clockwork.character.activePanel:MakePopup()
  347.  
  348. if (Callback) then
  349. Callback(Clockwork.character.activePanel);
  350. end;
  351.  
  352. if (childData) then
  353. Clockwork.character.activePanel.bIsCreationProcess = true;
  354. Clockwork.character:FadeOutNavigation();
  355. end;
  356. end;
  357.  
  358. --[[ Fade out the model panel, we probably don't need it now! --]]
  359. self:FadeOutModelPanel();
  360.  
  361. Clockwork.theme:Call("PostCharacterMenuOpenPanel", self);
  362. end;
  363. end;
  364.  
  365. -- Called when the panel is painted.
  366. function PANEL:Paint(w, h)
  367. if (!Clockwork.theme:Call("PreCharacterMenuPaint", self)) then
  368. local schemaLogo = Clockwork.option:GetKey("schema_logo");
  369. local subLabelAlpha = self.subLabel:GetAlpha();
  370.  
  371. if (subLabelAlpha > 0) then
  372. if (!self.logoTextureID) then
  373. self.logoTextureID = Material("novabox/gui/banner.png");
  374. end;
  375.  
  376. surface.SetDrawColor(Color(0, 0, 0))
  377. surface.DrawRect(0, 0, w, h)
  378.  
  379. surface.SetDrawColor(255, 255, 255, math.min(self:GetAlpha(), subLabelAlpha));
  380. surface.SetMaterial(self.logoTextureID);
  381. surface.DrawTexturedRect(self.titleLabel.x, self.titleLabel.y, 512, 256);
  382. end;
  383.  
  384. Clockwork.theme:Call("PostCharacterMenuPaint", self)
  385. end;
  386.  
  387. local backgroundColor = Clockwork.option:GetColor("background");
  388. local foregroundColor = Clockwork.option:GetColor("foreground");
  389. local colorTargetID = Clockwork.option:GetColor("target_id");
  390. local tinyTextFont = Clockwork.option:GetFont("menu_text_tiny");
  391. local colorWhite = Clockwork.option:GetColor("white");
  392. local scrW, scrH = ScrW(), ScrH();
  393. local height = (self.createButton.y * 2) + self.createButton:GetTall();
  394. local x, y = x, 0;
  395.  
  396. Clockwork.kernel:DrawSimpleGradientBox(0, 0, y, scrW, height, Color(
  397. backgroundColor.r, backgroundColor.g, backgroundColor.b, 100
  398. ));
  399.  
  400. surface.SetDrawColor(
  401. foregroundColor.r, foregroundColor.g, foregroundColor.b, 200
  402. );
  403. surface.DrawRect(0, y + height, scrW, 1);
  404.  
  405. if (Clockwork.character:IsCreationProcessActive()) then
  406. local creationPanels = Clockwork.character:GetCreationPanels();
  407. local numCreationPanels = #creationPanels;
  408. local creationProgress = Clockwork.character:GetCreationProgress();
  409. local progressHeight = 20;
  410. local creationInfo = Clockwork.character:GetCreationInfo();
  411. local progressY = y + height + 1;
  412. local boxColor = Color(
  413. math.min(backgroundColor.r + 50, 255),
  414. math.min(backgroundColor.g + 50, 255),
  415. math.min(backgroundColor.b + 50, 255),
  416. 100
  417. );
  418.  
  419. Clockwork.kernel:DrawSimpleGradientBox(0, 0, progressY, scrW, progressHeight, boxColor);
  420. for i = 1, numCreationPanels do
  421. surface.SetDrawColor(
  422. foregroundColor.r, foregroundColor.g, foregroundColor.b, 150
  423. );
  424. surface.DrawRect((scrW / numCreationPanels) * i, progressY, 1, progressHeight);
  425. end;
  426. Clockwork.kernel:DrawSimpleGradientBox(
  427. 0, 0, progressY, (scrW / 100) * creationProgress, progressHeight, colorTargetID
  428. );
  429.  
  430. if (creationProgress > 0 and creationProgress < 100) then
  431. surface.SetDrawColor(
  432. foregroundColor.r, foregroundColor.g, foregroundColor.b, 200
  433. );
  434. surface.DrawRect((scrW / 100) * creationProgress, progressY, 1, progressHeight);
  435. end;
  436.  
  437. for i = 1, numCreationPanels do
  438. local Condition = creationPanels[i].Condition;
  439. local textX = (scrW / numCreationPanels) * (i - 0.5);
  440. local textY = progressY + (progressHeight / 2);
  441. local color = Color(colorWhite.r, colorWhite.g, colorWhite.b, 200);
  442.  
  443. if (Condition and !Condition(creationInfo)) then
  444. color = Color(colorWhite.r, colorWhite.g, colorWhite.b, 100);
  445. end;
  446.  
  447. Clockwork.kernel:DrawSimpleText(creationPanels[i].friendlyName, textX, textY - 1, color, 1, 1);
  448. end;
  449.  
  450. surface.SetDrawColor(
  451. foregroundColor.r, foregroundColor.g, foregroundColor.b, 200
  452. );
  453. surface.DrawRect(0, progressY + progressHeight, scrW, 1);
  454. end;
  455.  
  456. return true;
  457. end;
  458.  
  459. -- Called each frame.
  460. function PANEL:Think()
  461. if (!Clockwork.theme:Call("PreCharacterMenuThink", self)) then
  462. local characters = table.Count(Clockwork.character:GetAll());
  463. local bIsLoading = Clockwork.character:IsPanelLoading();
  464. local schemaLogo = Clockwork.option:GetKey("schema_logo");
  465. local activePanel = Clockwork.character:GetActivePanel();
  466. local fault = Clockwork.character:GetFault();
  467.  
  468. if (Clockwork.plugin:Call("ShouldDrawCharacterBackgroundBlur")) then
  469. Clockwork.kernel:RegisterBackgroundBlur(self, self.createTime);
  470. else
  471. Clockwork.kernel:RemoveBackgroundBlur(self);
  472. end;
  473.  
  474. if (self.characterModel) then
  475. if (!self.characterModel.currentModel
  476. or self.characterModel.currentModel == "models/error.mdl") then
  477. self.characterModel:SetAlpha(0);
  478. end;
  479. end;
  480.  
  481. if (!Clockwork.character:IsCreationProcessActive()) then
  482. if (activePanel) then
  483. if (activePanel.GetNextDisabled
  484. and activePanel:GetNextDisabled()) then
  485. self.nextButton:SetDisabled(true);
  486. else
  487. self.nextButton:SetDisabled(false);
  488. end;
  489.  
  490. if (activePanel.GetPreviousDisabled
  491. and activePanel:GetPreviousDisabled()) then
  492. self.previousButton:SetDisabled(true);
  493. else
  494. self.previousButton:SetDisabled(false);
  495. end;
  496. end;
  497. else
  498. local previousPanelInfo = Clockwork.character:GetPreviousCreationPanel();
  499.  
  500. if (previousPanelInfo) then
  501. self.previousButton:SetDisabled(false);
  502. else
  503. self.previousButton:SetDisabled(true);
  504. end;
  505.  
  506. self.nextButton:SetDisabled(false);
  507. end;
  508.  
  509. if (schemaLogo == "") then
  510. self.titleLabel:SetVisible(true);
  511. else
  512. self.titleLabel:SetVisible(false);
  513. end;
  514.  
  515. if (characters == 0 or bIsLoading) then
  516. self.loadButton:SetDisabled(true);
  517. else
  518. self.loadButton:SetDisabled(false);
  519. end;
  520.  
  521. if (characters >= Clockwork.player:GetMaximumCharacters()
  522. or Clockwork.character:IsPanelLoading()) then
  523. self.createButton:SetDisabled(true);
  524. else
  525. self.createButton:SetDisabled(false);
  526. end;
  527.  
  528. if (Clockwork.Client:HasInitialized() and !Clockwork.character:IsMenuReset()) then
  529. self.disconnectButton:SetVisible(true)
  530. self.disconnectButton:SetText("CANCEL");
  531. self.disconnectButton:SizeToContents();
  532. else
  533. self.disconnectButton:SetVisible(false)
  534. end;
  535.  
  536. if (self.animation) then
  537. self.animation:Run();
  538. end;
  539.  
  540. self:SetSize(ScrW(), ScrH());
  541.  
  542. Clockwork.theme:Call("PostCharacterMenuThink", self)
  543. end;
  544. end;
  545.  
  546. vgui.Register("cwCharacterMenu", PANEL, "DPanel");
  547.  
  548. --[[
  549. Add a hook to control clicking outside of the active panel.
  550. --]]
  551.  
  552. hook.Add("VGUIMousePressed", "Clockwork.character:VGUIMousePressed", function(panel, code)
  553. local characterPanel = Clockwork.character:GetPanel();
  554. local activePanel = Clockwork.character:GetActivePanel();
  555.  
  556. if (Clockwork.character:IsPanelOpen() and activePanel
  557. and characterPanel == panel) then
  558. activePanel:MakePopup();
  559. end;
  560. end);
  561.  
  562. local PANEL = {};
  563.  
  564. -- Called when the panel is initialized.
  565. function PANEL:Init()
  566. self.selectedIdx = 1;
  567.  
  568. self.characterPanels = {}
  569. self.isCharacterList = true
  570.  
  571. Clockwork.character:FadeInNavigation()
  572. end
  573.  
  574. -- Called when the panel is painted.
  575. function PANEL:Paint() end
  576.  
  577. -- A function to clear the panel's panels.
  578. function PANEL:Clear()
  579. for k, v in ipairs(self.characterPanels) do
  580. v:Remove()
  581. end
  582.  
  583. self.characterPanels = {}
  584. end
  585.  
  586. -- A function to add a panel to the panel.
  587. function PANEL:AddPanel(panel)
  588. table.insert(self.characterPanels, panel)
  589. end
  590.  
  591. -- Called each frame.
  592. function PANEL:Think()
  593. self:InvalidateLayout(true)
  594.  
  595. if (self.animation) then self.animation:Run() end
  596.  
  597. if (!self.choseFirst) then
  598. for k, v in ipairs(self.characterPanels) do
  599. v:SetVisible(false)
  600. v:KillFocus()
  601. if (k > 1) then continue end
  602. v:SetVisible(true)
  603. v:RequestFocus()
  604. end
  605. self.choseFirst = true
  606. end
  607.  
  608. end
  609.  
  610. -- A function to make the panel fade out.
  611. function PANEL:FadeOut(speed, Callback)
  612. if (self:GetAlpha() > 0 and (!self.animation or !self.animation:Active())) then
  613. self.animation = Derma_Anim("Fade Panel", self, function(panel, animation, delta, data)
  614. panel:SetAlpha(255 - (delta * 255));
  615.  
  616. if (animation.Finished) then
  617. panel:SetVisible(false);
  618. end;
  619.  
  620. if (animation.Finished and Callback) then
  621. Callback();
  622. end;
  623. end);
  624.  
  625. if (self.animation) then
  626. self.animation:Start(speed);
  627. end;
  628.  
  629. Clockwork.option:PlaySound("rollover");
  630. else
  631. self:SetVisible(false);
  632. self:SetAlpha(0);
  633.  
  634. if (Callback) then
  635. Callback();
  636. end;
  637. end;
  638. end;
  639.  
  640. -- A function to make the panel fade in.
  641. function PANEL:FadeIn(speed, Callback)
  642. if (self:GetAlpha() == 0 and (!self.animation or !self.animation:Active())) then
  643. self.animation = Derma_Anim("Fade Panel", self, function(panel, animation, delta, data)
  644. panel:SetVisible(true);
  645. panel:SetAlpha(delta * 255);
  646.  
  647. if (animation.Finished) then
  648. self.animation = nil;
  649. end;
  650.  
  651. if (animation.Finished and Callback) then
  652. Callback();
  653. end;
  654. end);
  655.  
  656. if (self.animation) then
  657. self.animation:Start(speed);
  658. end;
  659.  
  660. Clockwork.option:PlaySound("click_release");
  661. else
  662. self:SetVisible(true);
  663. self:SetAlpha(255);
  664.  
  665. if (Callback) then
  666. Callback();
  667. end;
  668. end;
  669. end;
  670.  
  671. -- Called when the layout should be performed.
  672. function PANEL:PerformLayout()
  673. self:SetPos(0, 64)
  674. self:SetSize(ScrW(), ScrH()-160)
  675. end
  676.  
  677. -- Reloads the selected idx
  678. function PANEL:Select()
  679. for k, v in ipairs(self.characterPanels) do
  680. v:SetVisible(false)
  681. v:KillFocus()
  682. if (k != self.selectedIdx) then continue end
  683. v:SetVisible(true)
  684. v:RequestFocus()
  685. end
  686. end
  687.  
  688. -- Called by the prev/next buttons :>
  689. function PANEL:OnPrevious()
  690. self.selectedIdx = math.Clamp(self.selectedIdx - 1, 1, #self.characterPanels)
  691. self:Select()
  692. end
  693.  
  694. function PANEL:OnNext()
  695. self.selectedIdx = math.Clamp(self.selectedIdx + 1, 1, #self.characterPanels)
  696. self:Select()
  697. end
  698.  
  699.  
  700. vgui.Register("cwCharacterList", PANEL, "EditablePanel");
  701.  
  702.  
  703. local PANEL = {}
  704.  
  705. -- Called when the panel is initialized.
  706. function PANEL:Init()
  707.  
  708. local smallTextFont = Clockwork.option:GetFont("menu_text_small");
  709. local tinyTextFont = Clockwork.option:GetFont("menu_text_tiny");
  710. local hugeTextFont = Clockwork.option:GetFont("menu_text_huge");
  711.  
  712. local buttonsList = {}
  713. local customData = self:GetParent().customData
  714. local colorWhite = Clockwork.option:GetColor("white")
  715. local buttonX = 20
  716. local buttonY = 0
  717.  
  718. for k, v in pairs(customData) do
  719. self[k] = v
  720. end
  721.  
  722. self:SetSize(ScrW(), ScrH()-64)
  723. self.buttonPanels = {}
  724.  
  725. self.characterModel = vgui.Create("cwCharacterModel", self)
  726. self.characterModel:SetModel(self.model)
  727. self.characterModel:SetPos(0, 32)
  728. self.characterModel:SetSize(ScrH()-64, ScrH()-64);
  729.  
  730. self.customData = self:GetParent().customData;
  731.  
  732. local modelPanel = self.characterModel:GetModelPanel();
  733. local sequence = Clockwork.plugin:Call(
  734. "GetCharacterPanelSequence", modelPanel.Entity, self.customData.charTable
  735. );
  736.  
  737. if (sequence) then
  738. modelPanel.Entity:ResetSequence(sequence);
  739. end;
  740.  
  741. self.characterBox = vgui.Create("DPanel", self)
  742. self.characterBox:SetPos(ScrH()/2, 32)
  743. self.characterBox:SetSize(ScrW() - (ScrH()/2) - 32, ScrH()-128)
  744. self.characterBox.Paint = function() end
  745.  
  746. self.nameLabel = vgui.Create("sfTitleGrad", self.characterBox)
  747. self.nameLabel:SetFont(hugeTextFont)
  748. self.nameLabel:SetText(self.name)
  749. self.nameLabel:SizeToContents()
  750.  
  751. self.factionLabel = vgui.Create("sfTitleGrad", self.characterBox)
  752. self.factionLabel:SetFont(smallTextFont)
  753. self.factionLabel:SetText(self.faction)
  754. self.factionLabel:SizeToContents()
  755.  
  756. self.descLabel = vgui.Create("sfTitleGrad", self.characterBox)
  757. self.descLabel:SetFont(smallTextFont)
  758. self.descLabel:SetText(self.details or "No Physical Description")
  759. self.descLabel:SizeToContents()
  760.  
  761. self.startButton = vgui.Create("cwEnterButton", self.characterBox)
  762. self.startButton:SetText("Enter the Universe as "..self.name)
  763. self.startButton:SetFont(smallTextFont)
  764. self.startButton:SetSize(512, 96)
  765. self.startButton:SetMouseInputEnabled(true)
  766. self.startButton:SetCallback(function(panel)
  767. Clockwork.datastream:Start("InteractCharacter", {characterID = self.characterID, action = "use"})
  768. surface.PlaySound("cwhlu/enter.mp3")
  769. end)
  770.  
  771. self.removeButton = vgui.Create("cwLabelButton", self.characterBox)
  772. self.removeButton:SetText("Remove this character from the Universe")
  773. self.removeButton:OverrideTextColor(Color(197, 90, 90))
  774. self.removeButton:SetFont(tinyTextFont)
  775. self.removeButton:SizeToContents()
  776.  
  777. self.removeButton:SetMouseInputEnabled(true)
  778. self.removeButton:SetCallback(function(action)
  779. Schema:DermaConfirm("Really remove this character from the universe?",
  780. function() Clockwork.datastream:Start("InteractCharacter", {characterID = self.characterID, action = "delete"}) Clockwork.character:GetPanel():ReturnToMainMenu() end,
  781. function() return end)
  782. end)
  783.  
  784. local wide = self.nameLabel:GetWide()
  785. self.nameLabel:SetPos(0, 0)
  786. local y = self.nameLabel:GetTall() + 12
  787.  
  788. self.factionLabel:SetPos(0, y)
  789. wide = math.max(wide, self.factionLabel:GetWide())
  790. y = y + self.factionLabel:GetTall() + 12
  791.  
  792. self.descLabel:SetPos(0, y)
  793. wide = math.max(wide, self.descLabel:GetWide())
  794. y = y + self.descLabel:GetTall() + 12
  795.  
  796. self.startButton:SetPos(0, y)
  797. wide = math.max(wide, self.startButton:GetWide())
  798. y = y + self.startButton:GetTall() + 12
  799.  
  800. self.removeButton:SetPos(0, y)
  801. wide = math.max(wide, self.removeButton:GetWide())
  802. y = y + self.removeButton:GetTall() + 7
  803.  
  804.  
  805. self.nameLabel:SetWide(wide)
  806. self.factionLabel:SetWide(wide)
  807. self.descLabel:SetWide(wide)
  808. self.startButton:SetWide(wide)
  809. self.removeButton:SetWide(wide)
  810. end
  811.  
  812. function PANEL:Paint()
  813. end
  814.  
  815. vgui.Register("cwCharacterPanel", PANEL, "DPanel")
  816.  
  817. local PANEL = {}
  818.  
  819. -- Called when the panel is initialized.
  820. function PANEL:Init()
  821.  
  822. local smallTextFont = Clockwork.option:GetFont("menu_text_small");
  823. local tinyTextFont = Clockwork.option:GetFont("menu_text_tiny");
  824. local hugeTextFont = Clockwork.option:GetFont("menu_text_huge");
  825.  
  826. local descExamples = {
  827. "'5.4\" Tall | White | Blue Eyes | Scar on right eye lid | Muscular Build'",
  828. "'Skimmed Skin | Bruise on right cheek bone | American accent | Black | Small build'"
  829. }
  830.  
  831. self.question = vgui.Create("cwLabelButton", self)
  832. self.question:SetFont(tinyTextFont)
  833. self.question:SetText("A brief physical description")
  834. self.question:FadeIn(0)
  835. self.question:SizeToContents()
  836.  
  837. self.DExample = vgui.Create("DLabel", self)
  838. self.DExample:SetFont(tinyTextFont)
  839. self.DExample:SetColor( Color(150, 150, 150, 255) )
  840. self.DExample:SetText("Ex: " .. table.Random(descExamples))
  841. self.DExample:SizeToContents()
  842.  
  843. self.info = Clockwork.character:GetCreationInfo()
  844.  
  845. self.descinput = vgui.Create("DTextEntry", self)
  846. self.descinput:SetFont(smallTextFont)
  847. self.descinput:SetText("")
  848.  
  849. self.nextbutton = vgui.Create("cwLabelButton", self)
  850. self.nextbutton:SetFont(hugeTextFont)
  851. self.nextbutton:SetText("Finish")
  852. self.nextbutton:FadeIn(0)
  853. self.nextbutton:SizeToContents()
  854. self.nextbutton:SetMouseInputEnabled(true)
  855. self.nextbutton.DoClick = function(p)
  856. Clockwork.character:OpenNextCreationPanel()
  857. end
  858.  
  859. self.prevbutton = vgui.Create("cwLabelButton", self)
  860. self.prevbutton:SetFont(tinyTextFont)
  861. self.prevbutton:SetText("Go Back")
  862. self.prevbutton:FadeIn(0)
  863. self.prevbutton:SizeToContents()
  864. self.prevbutton:SetMouseInputEnabled(true)
  865. self.prevbutton.DoClick = function(p)
  866. Clockwork.character:OpenPreviousCreationPanel()
  867. end
  868. self.prevbutton:SetPos(32, ScrH()-self.prevbutton:GetTall()-32)
  869.  
  870.  
  871. end
  872.  
  873. -- Called when the next button is pressed.
  874. function PANEL:OnNext()
  875. self.info.physDesc = string.Replace(self.descinput:GetValue(), '"', "'")
  876. end
  877.  
  878. -- Called when the panel is painted.
  879. function PANEL:Paint()
  880. local sw = self:GetWide()
  881. local sh = self:GetTall()
  882.  
  883. local y = (sh/2 - 128) + self.DExample:GetTall() + 16
  884. Clockwork.kernel:DrawGradient(GRADIENT_RIGHT, sw/4, y, sw/2, 64, Color(200, 200, 200, 70))
  885.  
  886. end
  887.  
  888. -- Called when the layout should be performed.
  889. function PANEL:PerformLayout()
  890. local sw = self:GetWide()
  891. local sh = self:GetTall()
  892.  
  893. self.question:SetPos(sw/4, sh/2 - 142 )
  894. self.DExample:SetPos(sw/4, sh/2 - 118 )
  895. local x = sw/4 + 16
  896. local y = (sh/2 - 128) + self.DExample:GetTall() + 32
  897. self.descinput:SetPos(x, y)
  898. self.descinput:SetSize(sw/2 - 32, 32)
  899.  
  900. y = y + 64
  901. self.nextbutton:SetPos(self:GetWide()/2 - self.nextbutton:GetWide()/2, y)
  902. end
  903.  
  904. vgui.Register("sfCharacterStageFour", PANEL, "sfFrame")
  905.  
  906. local PANEL = {};
  907.  
  908. -- Called when the panel is initialized.
  909. function PANEL:Init()
  910.  
  911. local smallTextFont = Clockwork.option:GetFont("menu_text_small");
  912. local tinyTextFont = Clockwork.option:GetFont("menu_text_tiny");
  913. local hugeTextFont = Clockwork.option:GetFont("menu_text_huge");
  914.  
  915. self.info = Clockwork.character:GetCreationInfo()
  916.  
  917. self.info.customizationOptions = {};
  918.  
  919. self.title = vgui.Create("cwLabelButton", self)
  920. self.title:SetFont(hugeTextFont)
  921. self.title:SetText("Choose your skin")
  922. self.title:FadeIn(0)
  923. self.title:SizeToContents()
  924.  
  925. self.skincharacterModel = vgui.Create("cwCharacterModel", self);
  926. self.skincharacterModel:SetPos(0, 0);
  927. self.skincharacterModel:SetModel(self.info.model);
  928.  
  929. self.skinbutton1 = vgui.Create("cwLabelButton", self)
  930. self.skinbutton1:SetFont(smallTextFont)
  931. self.skinbutton1:SetText("Skin No. 1")
  932. self.skinbutton1:FadeIn(0)
  933. self.skinbutton1:SizeToContents()
  934. self.skinbutton1:SetMouseInputEnabled(true)
  935. self.skinbutton1.DoClick = function(p)
  936. self.skincharacterModel:GetModelPanel().Entity:SetSkin(0);
  937. self.info.customizationOptions["Skin"] = 0;
  938. end
  939.  
  940. self.skinbutton2 = vgui.Create("cwLabelButton", self)
  941. self.skinbutton2:SetFont(smallTextFont)
  942. self.skinbutton2:SetText("Skin No. 2")
  943. self.skinbutton2:FadeIn(0)
  944. self.skinbutton2:SizeToContents()
  945. self.skinbutton2:SetMouseInputEnabled(true)
  946. self.skinbutton2.DoClick = function(p)
  947. self.skincharacterModel:GetModelPanel().Entity:SetSkin(1);
  948. self.info.customizationOptions["Skin"] = 1;
  949. end
  950.  
  951. self.skinbutton3 = vgui.Create("cwLabelButton", self)
  952. self.skinbutton3:SetFont(smallTextFont)
  953. self.skinbutton3:SetText("Skin No. 3")
  954. self.skinbutton3:FadeIn(0)
  955. self.skinbutton3:SizeToContents()
  956. self.skinbutton3:SetMouseInputEnabled(true)
  957. self.skinbutton3.DoClick = function(p)
  958. self.skincharacterModel:GetModelPanel().Entity:SetSkin(2);
  959. self.info.customizationOptions["Skin"] = 2;
  960. end
  961.  
  962. self.skinbutton4 = vgui.Create("cwLabelButton", self)
  963. self.skinbutton4:SetFont(smallTextFont)
  964. self.skinbutton4:SetText("Skin No. 4")
  965. self.skinbutton4:FadeIn(0)
  966. self.skinbutton4:SizeToContents()
  967. self.skinbutton4:SetMouseInputEnabled(true)
  968. self.skinbutton4.DoClick = function(p)
  969. self.skincharacterModel:GetModelPanel().Entity:SetSkin(3);
  970. self.info.customizationOptions["Skin"] = 3;
  971. end
  972.  
  973. self.skinbutton5 = vgui.Create("cwLabelButton", self)
  974. self.skinbutton5:SetFont(smallTextFont)
  975. self.skinbutton5:SetText("Skin No. 5")
  976. self.skinbutton5:FadeIn(0)
  977. self.skinbutton5:SizeToContents()
  978. self.skinbutton5:SetMouseInputEnabled(true)
  979. self.skinbutton5.DoClick = function(p)
  980. self.skincharacterModel:GetModelPanel().Entity:SetSkin(4);
  981. self.info.customizationOptions["Skin"] = 4;
  982. end
  983.  
  984. self.nextbutton = vgui.Create("cwLabelButton", self)
  985. self.nextbutton:SetFont(tinyTextFont)
  986. self.nextbutton:SetText("Select this Skin")
  987. self.nextbutton:FadeIn(0)
  988. self.nextbutton:SizeToContents()
  989. self.nextbutton:SetMouseInputEnabled(true)
  990. self.nextbutton.DoClick = function(p)
  991. Clockwork.character:OpenNextCreationPanel()
  992. end
  993.  
  994. end;
  995.  
  996. -- Called when the layout should be performed.
  997. function PANEL:PerformLayout(w, h)
  998.  
  999. self.title:SetPos(32, 32)
  1000. local y = self.title:GetTall() + 48
  1001.  
  1002. self.skincharacterModel:SetPos(0, 32)
  1003. self.skincharacterModel:SetSize(ScrH()-64, ScrH()-64)
  1004.  
  1005. local y = y + 508
  1006. self.nextbutton:SetPos(self:GetWide()/2 - self.nextbutton:GetWide()/2, y)
  1007.  
  1008. local y = y - 64
  1009. self.skinbutton1:SetPos(self:GetWide()/2 - self.skinbutton1:GetWide()/2, y)
  1010.  
  1011. local y = y - 64
  1012. self.skinbutton2:SetPos(self:GetWide()/2 - self.skinbutton2:GetWide()/2, y)
  1013.  
  1014. local y = y - 64
  1015. self.skinbutton3:SetPos(self:GetWide()/2 - self.skinbutton3:GetWide()/2, y)
  1016.  
  1017. local y = y - 64
  1018. self.skinbutton4:SetPos(self:GetWide()/2 - self.skinbutton4:GetWide()/2, y)
  1019.  
  1020. local y = y - 64
  1021. self.skinbutton5:SetPos(self:GetWide()/2 - self.skinbutton5:GetWide()/2, y)
  1022.  
  1023. end;
  1024.  
  1025. vgui.Register("sfCharacterStageThreeHalf", PANEL, "sfFrame")
  1026.  
  1027. local PANEL = {}
  1028.  
  1029. -- Called when the panel is initialized.
  1030. function PANEL:Init()
  1031.  
  1032. local smallTextFont = Clockwork.option:GetFont("menu_text_small");
  1033. local tinyTextFont = Clockwork.option:GetFont("menu_text_tiny");
  1034. local hugeTextFont = Clockwork.option:GetFont("menu_text_huge");
  1035.  
  1036. self.info = Clockwork.character:GetCreationInfo()
  1037.  
  1038. self.title = vgui.Create("cwLabelButton", self)
  1039. self.title:SetFont(hugeTextFont)
  1040. self.title:SetText("Choose your model")
  1041. self.title:FadeIn(0)
  1042. self.title:SizeToContents()
  1043.  
  1044. self.modelList = vgui.Create("sfModelList", self)
  1045. local lowerGender = string.lower(self.info.gender)
  1046.  
  1047. for k, v in pairs(Clockwork.faction.stored) do
  1048. if (v.isDefault) then
  1049. if (self.modelList and v.models[lowerGender]) then
  1050. for k2, v2 in pairs(v.models[lowerGender]) do
  1051. local paths = string.Explode("/", v2)
  1052. local name = paths[#paths]
  1053. local parts = string.Explode(".", name)
  1054. local name = parts[1]
  1055. local name = string.Replace(name, "_", "")
  1056. self.modelList.customData = {
  1057. name = name,
  1058. model = v2
  1059. }
  1060. local panel = vgui.Create("sfModelItem", self.modelList)
  1061. if (IsValid(panel)) then
  1062. self.modelList:AddPanel(panel)
  1063. end
  1064. end
  1065. end
  1066. end
  1067. end
  1068.  
  1069. self.nextbutton = vgui.Create("cwLabelButton", self)
  1070. self.nextbutton:SetFont(tinyTextFont)
  1071. self.nextbutton:SetText("Select this Model")
  1072. self.nextbutton:FadeIn(0)
  1073. self.nextbutton:SizeToContents()
  1074. self.nextbutton:SetMouseInputEnabled(true)
  1075. self.nextbutton.DoClick = function(p)
  1076. Clockwork.character:OpenNextCreationPanel()
  1077. end
  1078.  
  1079. self.prevbutton = vgui.Create("cwLabelButton", self)
  1080. self.prevbutton:SetFont(smallTextFont)
  1081. self.prevbutton:SetText("Go Back")
  1082. self.prevbutton:FadeIn(0)
  1083. self.prevbutton:SizeToContents()
  1084. self.prevbutton:SetMouseInputEnabled(true)
  1085. self.prevbutton.DoClick = function(p)
  1086. Clockwork.character:OpenPreviousCreationPanel()
  1087. end
  1088. self.prevbutton:SetPos(32, ScrH()-self.prevbutton:GetTall()-32)
  1089.  
  1090. end
  1091.  
  1092. -- Called when the panel is painted.
  1093. function PANEL:Paint() end
  1094.  
  1095. -- Called when the next button is pressed.
  1096. function PANEL:OnNext()
  1097. local smodel = self.modelList:GetSelectedModel().model
  1098. self.info.model = smodel
  1099. if (!self.info.model) then
  1100. Clockwork.character:SetFault("You did not choose a model, or the model that you chose is not valid!")
  1101. return false
  1102. end
  1103. return true
  1104. end
  1105.  
  1106. -- Called when the layout should be performed.
  1107. function PANEL:PerformLayout()
  1108. self.title:SetPos(32, 32)
  1109. local y = self.title:GetTall() + 48
  1110. self.modelList:SetPos(self:GetParent():GetWide()/8, y)
  1111. local y = y + self.modelList:GetTall() + 16
  1112. self.nextbutton:SetPos(self:GetWide()/2 - self.nextbutton:GetWide()/2, y)
  1113.  
  1114. end
  1115.  
  1116. vgui.Register("sfCharacterStageThree", PANEL, "sfFrame")
  1117.  
  1118. local PANEL = {}
  1119.  
  1120. PANEL.LastNames = {
  1121. "Petties","Leis","Gunther","Runnels","Shy","Stowe","Elswick","Landgraf","Toups","Maez","Riding","Ned","Gimenez",
  1122. "Elzey","Roll","Hillyer","Babineau","Evins","Devin","Ihle","Desalvo","Juliano","Stukes","Haubert","Delamora","Reddix",
  1123. "Willman","Espino","Castillo","Aberle","Riccio","Sweatt","Lagarde","Rowser","Arzu","Moultrie","Ferretti","Maier",
  1124. "Jacks","Lucero","Belgrave","Chynoweth","Monsour","Ellery","Tillson","Jorgensen","Jenks","Bufkin","Tillmon","Merlino",
  1125. "Bayn","Bearden","Ray","Craven","Finklestein","Rammist"}
  1126. PANEL.MaleNames = {
  1127. "Jamel","Filiberto","Fernando","Jerald","Barton","Kraig","Solomon","Walton","Rickey","Marlin","Ethan","Darius","Jack",
  1128. "Toney","Caleb","Mariano","Bradly","Claudio","Richie","Will","Anderson","Maria","Alexander","Jimmy","Dean","Gregorio",
  1129. "Dee","Myron","Hal","Hobert","Jeremiah","Wendell","William","Jan","Nathanial","Issac","Ray","Sean","Antonia","Blair",
  1130. "Stacey","Genaro","Freddie","Vincenzo","Damon","Terrence","Armand","Dorian","Lamont","Josef","Rorick","James","Steven",
  1131. "Dwayne","Bobby","Max"}
  1132. PANEL.FemaleNames = {
  1133. "Brittani","Mindi","Keira","Mari","Cecilia","Ilana","Mardell","Henriette","Virgina","Dottie","Retha","Angelique","Mahalia",
  1134. "Kallie","Clorinda","Grace","Alaine","Lyndsay","Wonda","Pilar","Estela","Shalon","Clarissa","Magnolia","Bree","Britta",
  1135. "Kristal","Paulette","Brandi","Jenette","Oralee","Aleen","Dawna","Hedwig","Charmaine","Shondra","Bethany","Ruthann",
  1136. "Tegan","Elva","Otelia","Meg","Belen","Xiomara","Tamara","Mariette","Toshiko","Danita","Delilah","Queenie"}
  1137. -- Called when the panel is initialized.
  1138. function PANEL:Init()
  1139.  
  1140. local hugeTextFont = Clockwork.option:GetFont("menu_text_huge")
  1141. local smallTextFont = Clockwork.option:GetFont("menu_text_small")
  1142. local mediumTextFont = Clockwork.option:GetFont("menu_text_medium")
  1143. local tinyTextFont = Clockwork.option:GetFont("menu_text_tiny")
  1144. local largeTextFont = Clockwork.option:GetFont("menu_text_big")
  1145.  
  1146. self.question = vgui.Create("cwLabelButton", self)
  1147. self.question:SetFont(largeTextFont)
  1148. self.question:SetText("What is your name?")
  1149. self.question:FadeIn(0)
  1150. self.question:SizeToContents()
  1151.  
  1152. self.info = Clockwork.character:GetCreationInfo()
  1153.  
  1154. self.fnameinput = vgui.Create("DTextEntry", self)
  1155. self.fnameinput:SetFont(largeTextFont)
  1156. if (self.info.gender == GENDER_FEMALE) then
  1157. self.fnameinput:SetText(self.FemaleNames[math.random(0,#self.FemaleNames)])
  1158. else
  1159. self.fnameinput:SetText(self.MaleNames[math.random(0,#self.MaleNames)])
  1160. end
  1161.  
  1162. self.lnameinput = vgui.Create("DTextEntry", self)
  1163. self.lnameinput:SetFont(largeTextFont)
  1164. self.lnameinput:SetText(self.LastNames[math.random(0,#self.LastNames)])
  1165.  
  1166.  
  1167. self.randomize = vgui.Create("cwLabelButton", self)
  1168. self.randomize:SetFont(smallTextFont)
  1169. self.randomize:SetText("Randomize")
  1170. self.randomize:FadeIn(0)
  1171. self.randomize:SizeToContents()
  1172. self.randomize:SetMouseInputEnabled(true)
  1173. self.randomize.DoClick = function(p)
  1174. if (self.info.gender == GENDER_FEMALE) then
  1175. self.fnameinput:SetText(self.FemaleNames[math.random(0,#self.FemaleNames)])
  1176. else
  1177. self.fnameinput:SetText(self.MaleNames[math.random(0,#self.MaleNames)])
  1178. end
  1179. self.lnameinput:SetText(self.LastNames[math.random(0,#self.LastNames)])
  1180. end
  1181.  
  1182. self.nextbutton = vgui.Create("cwLabelButton", self)
  1183. self.nextbutton:SetFont(smallTextFont)
  1184. self.nextbutton:SetText("Continue")
  1185. self.nextbutton:FadeIn(0)
  1186. self.nextbutton:SizeToContents()
  1187. self.nextbutton:SetMouseInputEnabled(true)
  1188. self.nextbutton.DoClick = function(p)
  1189. Clockwork.character:OpenNextCreationPanel()
  1190. end
  1191.  
  1192. self.prevbutton = vgui.Create("cwLabelButton", self)
  1193. self.prevbutton:SetFont(tinyTextFont)
  1194. self.prevbutton:SetText("Go Back")
  1195. self.prevbutton:FadeIn(0)
  1196. self.prevbutton:SizeToContents()
  1197. self.prevbutton:SetMouseInputEnabled(true)
  1198. self.prevbutton.DoClick = function(p)
  1199. Clockwork.character:OpenPreviousCreationPanel()
  1200. end
  1201. self.prevbutton:SetPos(32, ScrH()-self.prevbutton:GetTall()-32)
  1202.  
  1203. end
  1204.  
  1205. -- Called when the next button is pressed.
  1206. function PANEL:OnNext()
  1207. self.info.forename = string.Replace(self.fnameinput:GetValue(), '"', "'")
  1208. self.info.surname = string.Replace(self.lnameinput:GetValue(), '"', "'")
  1209.  
  1210. if (self.info.forename == "" or self.info.surname == "") then
  1211. Clockwork.character:SetFault("You did not choose a name, or the name that you chose is not valid!")
  1212. return false
  1213. end
  1214.  
  1215. if (string.find(self.info.forename, "[%p%s%d]") or string.find(self.info.surname, "[%p%s%d]")) then
  1216. Clockwork.character:SetFault("Your first ane last name must not contain punctuation, spaces or digits!")
  1217. return false
  1218. end
  1219.  
  1220. if (!string.find(self.info.forename, "[aeiou]") or !string.find(self.info.surname, "[aeiou]")) then
  1221. Clockwork.character:SetFault("Your first and last name must both contain at least one vowel!")
  1222. return false
  1223. end
  1224.  
  1225. if (string.len(self.info.forename) < 2 or string.len(self.info.surname) < 2) then
  1226. Clockwork.character:SetFault("Your first and last name must both be at least 2 characters long!")
  1227. return false
  1228. end
  1229.  
  1230. if (string.len(self.info.forename) > 16 or string.len(self.info.surname) > 16) then
  1231. Clockwork.character:SetFault("Your first and last name must not be greater than 16 characters long!")
  1232. return false
  1233. end
  1234.  
  1235. end
  1236.  
  1237. -- Called when the panel is painted.
  1238. function PANEL:Paint()
  1239. local sw = self:GetWide()
  1240. local sh = self:GetTall()
  1241.  
  1242. local y = (sh/2 - 128) + self.question:GetTall() + 16
  1243. Clockwork.kernel:DrawGradient(GRADIENT_RIGHT, sw/4, y, sw/2, 96, Color(200, 200, 200, 70))
  1244.  
  1245. end
  1246.  
  1247. -- Called when the layout should be performed.
  1248. function PANEL:PerformLayout()
  1249. local sw = self:GetWide()
  1250. local sh = self:GetTall()
  1251.  
  1252. self.question:SetPos(sw/4, sh/2 - 128)
  1253. local x = sw/4 + 16
  1254. local y = (sh/2 - 128) + self.question:GetTall() + 32
  1255. self.fnameinput:SetPos(x, y)
  1256. self.fnameinput:SetSize((sw/2 - 64)/2 - 16, 64)
  1257. self.lnameinput:SetPos(x + self.fnameinput:GetWide() + 16, y)
  1258. self.lnameinput:SetSize((sw/2 - 64)/2 - 16, 64)
  1259.  
  1260. self.nextbutton:SetPos(x + sw/2 - self.nextbutton:GetWide(), y + 104)
  1261. self.randomize:SetPos(sw/4, y + 84)
  1262. end
  1263.  
  1264. vgui.Register("sfCharacterStageTwo", PANEL, "sfFrame")
  1265.  
  1266. local PANEL = {}
  1267.  
  1268. -- Called when the panel is initialized.
  1269. function PANEL:Init()
  1270.  
  1271. self.info = Clockwork.character:GetCreationInfo();
  1272.  
  1273. self.male = vgui.Create("DImageButton", self)
  1274. self.male.m_Image:SetMaterial(Material("novabox/gui/charmale.png"))
  1275. self.male:SetSize(256, 256)
  1276. self.male:SetMouseInputEnabled(true)
  1277. self.male.DoClick = function(p)
  1278. self.gender = GENDER_MALE
  1279. Clockwork.character:OpenNextCreationPanel()
  1280. end
  1281.  
  1282. self.female = vgui.Create("DImageButton", self)
  1283. self.female.m_Image:SetMaterial(Material("novabox/gui/charfemale.png"))
  1284. self.female:SetSize(256, 256)
  1285. self.female:SetMouseInputEnabled(true)
  1286. self.female.DoClick = function(p)
  1287. self.gender = GENDER_FEMALE
  1288. Clockwork.character:OpenNextCreationPanel()
  1289. end
  1290. end
  1291.  
  1292. -- Called when the next button is pressed.
  1293. function PANEL:OnNext()
  1294.  
  1295. local gender = self.gender
  1296. for k, v in pairs(Clockwork.faction.stored) do
  1297. if (v.isDefault) then
  1298. self.info.faction = v.name
  1299. self.info.gender = gender
  1300. return true
  1301. end
  1302. end
  1303. return false
  1304. end
  1305.  
  1306. -- Called when the layout should be performed.
  1307. function PANEL:PerformLayout()
  1308. local sw = self:GetWide()
  1309. local sh = self:GetTall()
  1310.  
  1311. self.male:SetPos(sw/2 - 384, sh/2 - 128)
  1312. self.female:SetPos(sw/2 + 128, sh/2 - 128)
  1313. end
  1314.  
  1315. vgui.Register("sfCharacterStageOne", PANEL, "sfFrame")
  1316.  
  1317. Clockwork.datastream:Hook("cwCharacterRemove", function(data)
  1318. local characters = Clockwork.character:GetAll();
  1319. local characterID = data;
  1320.  
  1321. if (table.Count(characters) == 0) then
  1322. return;
  1323. end;
  1324.  
  1325.  
  1326. if (!characters[characterID]) then
  1327. return;
  1328. end;
  1329.  
  1330. characters[characterID] = nil;
  1331.  
  1332. if (!Clockwork.character:IsPanelLoading()) then
  1333. Clockwork.character:RefreshPanelList();
  1334. end;
  1335.  
  1336. if (Clockwork.character:GetPanelList()) then
  1337. if (table.Count(characters) == 0) then
  1338. Clockwork.character:GetPanel():ReturnToMainMenu();
  1339. end;
  1340. end;
  1341. end);
  1342.  
  1343. Clockwork.datastream:Hook("SetWhitelisted", function(data)
  1344. local whitelisted = Clockwork.character:GetWhitelisted();
  1345.  
  1346. for k, v in pairs(whitelisted) do
  1347. if (v == data[1]) then
  1348. if (!data[2]) then
  1349. whitelisted[k] = nil;
  1350.  
  1351. return;
  1352. end;
  1353. end;
  1354. end;
  1355.  
  1356. if (data[2]) then
  1357. whitelisted[#whitelisted + 1] = data[1];
  1358. end;
  1359. end);
  1360.  
  1361. Clockwork.datastream:Hook("CharacterAdd", function(data)
  1362. Clockwork.character:Add(data.characterID, data);
  1363.  
  1364. if (!Clockwork.character:IsPanelLoading()) then
  1365. Clockwork.character:RefreshPanelList();
  1366. end;
  1367. end);
  1368.  
  1369. Clockwork.datastream:Hook("CharacterMenu", function(data)
  1370. local menuState = data;
  1371.  
  1372. if (menuState == CHARACTER_MENU_LOADED) then
  1373. if (Clockwork.character:GetPanel()) then
  1374. Clockwork.character:SetPanelLoading(false);
  1375. Clockwork.character:RefreshPanelList();
  1376. end;
  1377. elseif (menuState == CHARACTER_MENU_CLOSE) then
  1378. Clockwork.character:SetPanelOpen(false);
  1379. elseif (menuState == CHARACTER_MENU_OPEN) then
  1380. Clockwork.character:SetPanelOpen(true);
  1381. end;
  1382. end);
  1383.  
  1384. Clockwork.datastream:Hook("cwCharacterOpen", function(data)
  1385. Clockwork.character:SetPanelOpen(true);
  1386.  
  1387. if (data) then
  1388. Clockwork.character.isMenuReset = true;
  1389. end;
  1390. end);
  1391.  
  1392. Clockwork.datastream:Hook("cwCharacterFinish", function(data)
  1393. if (data.bSuccess) then
  1394. Clockwork.character:SetPanelMainMenu();
  1395. Clockwork.character:SetPanelOpen(false, true);
  1396. Clockwork.character:SetFault(nil);
  1397. else
  1398. Clockwork.character:SetFault(data.fault);
  1399. end;
  1400. end);
  1401.  
  1402. Clockwork.character.creationPanels = {};
  1403. Clockwork.character:RegisterCreationPanel("Gender", "sfCharacterStageOne")
  1404. Clockwork.character:RegisterCreationPanel("Name", "sfCharacterStageTwo")
  1405. Clockwork.character:RegisterCreationPanel("Appearance", "sfCharacterStageThree")
  1406. Clockwork.character:RegisterCreationPanel("Customization", "sfCharacterStageThreeHalf")
  1407. Clockwork.character:RegisterCreationPanel("Personalization", "sfCharacterStageFour")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement