Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Called when the panel is initialized.
- function PANEL:Init()
- local smallTextFont = Clockwork.option:GetFont("menu_text_small");
- local factions = {};
- for k, v in pairs(Clockwork.faction.stored) do
- if (!v.whitelist or Clockwork.character:IsWhitelisted(v.name)) then
- if (!Clockwork.faction:HasReachedMaximum(k)) then
- factions[#factions + 1] = v.name;
- end;
- end;
- end;
- table.sort(factions, function(a, b)
- return a < b;
- end);
- self.forcedFaction = nil;
- self.info = Clockwork.character:GetCreationInfo();
- self.categoryList = vgui.Create("cwPanelList", self);
- self.categoryList:SetPadding(8);
- self.categoryList:SetSpacing(8);
- self.categoryList:SizeToContents();
- self.settingsForm = vgui.Create("cwBasicForm");
- self.settingsForm:SetAutoSize(true);
- self.settingsForm:SetText(L("CreateCharacterStage1"));
- self.settingsForm:SetPadding(8);
- self.settingsForm:SetSpacing(8);
- if (#factions > 1) then
- self.settingsForm:Help(L("CharacterMenuFactionHelp"));
- self.factionMultiChoice = self.settingsForm:ComboBox(L("CharacterMenuFaction"));
- -- Called when an option is selected.
- self.factionMultiChoice.OnSelect = function(multiChoice, index, value, data)
- for k, v in pairs(Clockwork.faction.stored) do
- if (v.name == value) then
- if (IsValid(self.genderMultiChoice)) then
- self.genderMultiChoice:Clear();
- else
- self.genderMultiChoice = self.settingsForm:ComboBox(L("Gender"));
- self.settingsForm:Rebuild();
- end;
- if (v.singleGender) then
- local index = self.genderMultiChoice:AddChoice(L(v.singleGender));
- self.genderMultiChoice:ChooseOptionID(index);
- else
- self.genderMultiChoice:AddChoice(L(GENDER_FEMALE));
- self.genderMultiChoice:AddChoice(L(GENDER_MALE));
- end;
- Clockwork.CurrentFactionSelected = {self, value};
- break;
- end;
- end;
- end;
- elseif (#factions == 1) then
- for k, v in pairs(Clockwork.faction.stored) do
- if (v.name == factions[1]) then
- self.genderMultiChoice = self.settingsForm:ComboBox(L("Gender"));
- if (v.singleGender) then
- local index = self.genderMultiChoice:AddChoice(L(v.singleGender));
- self.genderMultiChoice:ChooseOptionID(index);
- else
- self.genderMultiChoice:AddChoice(L(GENDER_FEMALE));
- self.genderMultiChoice:AddChoice(L(GENDER_MALE));
- end;
- Clockwork.CurrentFactionSelected = {self, v.name};
- self.forcedFaction = v.name;
- break;
- end;
- end;
- end;
- if (self.factionMultiChoice) then
- for k, v in pairs(factions) do
- self.factionMultiChoice:AddChoice(v);
- end;
- end;
- self.customChoices = {};
- Clockwork.plugin:Call("GetPersuasionChoices", self.customChoices);
- if (self.customChoices) then
- self.customPanels = {};
- for k2, v2 in pairs(self.customChoices) do
- if (!v2.type or string.lower(v2.type) == "combobox") then
- table.insert(self.customPanels, {v2, self.settingsForm:ComboBox(v2.name)});
- for k3, v3 in ipairs(v2.choices) do
- self.customPanels[#self.customPanels][2]:AddChoice(v3)
- end;
- elseif (string.lower(v2.type) == "textentry") then
- table.insert(self.customPanels, {v2, self.settingsForm:TextEntry(v2.name)});
- end;
- end;
- end;
- self.categoryList:AddItem(self.settingsForm);
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement