Advertisement
Guest User

f

a guest
Dec 14th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.31 KB | None | 0 0
  1. -- Called when the panel is initialized.
  2. function PANEL:Init()
  3. local smallTextFont = Clockwork.option:GetFont("menu_text_small");
  4. local factions = {};
  5.  
  6. for k, v in pairs(Clockwork.faction.stored) do
  7. if (!v.whitelist or Clockwork.character:IsWhitelisted(v.name)) then
  8. if (!Clockwork.faction:HasReachedMaximum(k)) then
  9. factions[#factions + 1] = v.name;
  10. end;
  11. end;
  12. end;
  13.  
  14. table.sort(factions, function(a, b)
  15. return a < b;
  16. end);
  17.  
  18. self.forcedFaction = nil;
  19. self.info = Clockwork.character:GetCreationInfo();
  20.  
  21. self.categoryList = vgui.Create("cwPanelList", self);
  22. self.categoryList:SetPadding(8);
  23. self.categoryList:SetSpacing(8);
  24. self.categoryList:SizeToContents();
  25.  
  26. self.settingsForm = vgui.Create("cwBasicForm");
  27. self.settingsForm:SetAutoSize(true);
  28. self.settingsForm:SetText(L("CreateCharacterStage1"));
  29. self.settingsForm:SetPadding(8);
  30. self.settingsForm:SetSpacing(8);
  31.  
  32. if (#factions > 1) then
  33. self.settingsForm:Help(L("CharacterMenuFactionHelp"));
  34. self.factionMultiChoice = self.settingsForm:ComboBox(L("CharacterMenuFaction"));
  35.  
  36. -- Called when an option is selected.
  37. self.factionMultiChoice.OnSelect = function(multiChoice, index, value, data)
  38. for k, v in pairs(Clockwork.faction.stored) do
  39. if (v.name == value) then
  40. if (IsValid(self.genderMultiChoice)) then
  41. self.genderMultiChoice:Clear();
  42. else
  43. self.genderMultiChoice = self.settingsForm:ComboBox(L("Gender"));
  44. self.settingsForm:Rebuild();
  45. end;
  46.  
  47. if (v.singleGender) then
  48. local index = self.genderMultiChoice:AddChoice(L(v.singleGender));
  49.  
  50. self.genderMultiChoice:ChooseOptionID(index);
  51. else
  52. self.genderMultiChoice:AddChoice(L(GENDER_FEMALE));
  53. self.genderMultiChoice:AddChoice(L(GENDER_MALE));
  54. end;
  55.  
  56. Clockwork.CurrentFactionSelected = {self, value};
  57.  
  58. break;
  59. end;
  60. end;
  61. end;
  62. elseif (#factions == 1) then
  63. for k, v in pairs(Clockwork.faction.stored) do
  64. if (v.name == factions[1]) then
  65. self.genderMultiChoice = self.settingsForm:ComboBox(L("Gender"));
  66.  
  67. if (v.singleGender) then
  68. local index = self.genderMultiChoice:AddChoice(L(v.singleGender));
  69.  
  70. self.genderMultiChoice:ChooseOptionID(index);
  71. else
  72. self.genderMultiChoice:AddChoice(L(GENDER_FEMALE));
  73. self.genderMultiChoice:AddChoice(L(GENDER_MALE));
  74. end;
  75.  
  76. Clockwork.CurrentFactionSelected = {self, v.name};
  77. self.forcedFaction = v.name;
  78.  
  79. break;
  80. end;
  81. end;
  82. end;
  83.  
  84. if (self.factionMultiChoice) then
  85. for k, v in pairs(factions) do
  86. self.factionMultiChoice:AddChoice(v);
  87. end;
  88. end;
  89.  
  90. self.customChoices = {};
  91.  
  92. Clockwork.plugin:Call("GetPersuasionChoices", self.customChoices);
  93.  
  94. if (self.customChoices) then
  95. self.customPanels = {};
  96.  
  97. for k2, v2 in pairs(self.customChoices) do
  98. if (!v2.type or string.lower(v2.type) == "combobox") then
  99. table.insert(self.customPanels, {v2, self.settingsForm:ComboBox(v2.name)});
  100.  
  101. for k3, v3 in ipairs(v2.choices) do
  102. self.customPanels[#self.customPanels][2]:AddChoice(v3)
  103. end;
  104. elseif (string.lower(v2.type) == "textentry") then
  105. table.insert(self.customPanels, {v2, self.settingsForm:TextEntry(v2.name)});
  106. end;
  107. end;
  108. end;
  109.  
  110. self.categoryList:AddItem(self.settingsForm);
  111. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement