Advertisement
Guest User

CharacterCreate.lua

a guest
Feb 23rd, 2015
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 17.87 KB | None | 0 0
  1. CHARACTER_FACING_INCREMENT = 2;
  2. MAX_RACES = 14;
  3. MAX_CLASSES_PER_RACE = 10;
  4. NUM_CHAR_CUSTOMIZATIONS = 5;
  5. MIN_CHAR_NAME_LENGTH = 2;
  6. CHARACTER_CREATE_ROTATION_START_X = nil;
  7. CHARACTER_CREATE_INITIAL_FACING = nil;
  8.  
  9. PAID_CHARACTER_CUSTOMIZATION = 1;
  10. PAID_RACE_CHANGE = 2;
  11. PAID_FACTION_CHANGE = 3;
  12. PAID_SERVICE_CHARACTER_ID = nil;
  13. PAID_SERVICE_TYPE = nil;
  14.  
  15. FACTION_BACKDROP_COLOR_TABLE = {
  16.     ["Alliance"] = {0.5, 0.5, 0.5, 0.09, 0.09, 0.19},
  17.     ["Horde"] = {0.5, 0.2, 0.2, 0.19, 0.05, 0.05},
  18. };
  19. FRAMES_TO_BACKDROP_COLOR = {
  20.     "CharacterCreateCharacterRace",
  21.     "CharacterCreateCharacterClass",
  22. --  "CharacterCreateCharacterFaction",
  23.     "CharacterCreateNameEdit",
  24. };
  25. RACE_ICON_TCOORDS = {
  26.     ["HUMAN_MALE"]      = {0, 0.125, 0, 0.25},
  27.     ["DWARF_MALE"]      = {0.125, 0.25, 0, 0.25},
  28.     ["GNOME_MALE"]      = {0.25, 0.375, 0, 0.25},
  29.     ["NIGHTELF_MALE"]   = {0.375, 0.5, 0, 0.25},
  30.    
  31.     ["TAUREN_MALE"]     = {0, 0.125, 0.25, 0.5},
  32.     ["SCOURGE_MALE"]    = {0.125, 0.25, 0.25, 0.5},
  33.     ["TROLL_MALE"]      = {0.25, 0.375, 0.25, 0.5},
  34.     ["ORC_MALE"]        = {0.375, 0.5, 0.25, 0.5},
  35.  
  36.     ["HUMAN_FEMALE"]    = {0, 0.125, 0.5, 0.75},  
  37.     ["DWARF_FEMALE"]    = {0.125, 0.25, 0.5, 0.75},
  38.     ["GNOME_FEMALE"]    = {0.25, 0.375, 0.5, 0.75},
  39.     ["NIGHTELF_FEMALE"] = {0.375, 0.5, 0.5, 0.75},
  40.    
  41.     ["TAUREN_FEMALE"]   = {0, 0.125, 0.75, 1.0},  
  42.     ["SCOURGE_FEMALE"]  = {0.125, 0.25, 0.75, 1.0},
  43.     ["TROLL_FEMALE"]    = {0.25, 0.375, 0.75, 1.0},
  44.     ["ORC_FEMALE"]      = {0.375, 0.5, 0.75, 1.0},
  45.  
  46.     ["BLOODELF_MALE"]   = {0.5, 0.625, 0.25, 0.5},
  47.     ["BLOODELF_FEMALE"] = {0.5, 0.625, 0.75, 1.0},
  48.  
  49.     ["DRAENEI_MALE"]    = {0.5, 0.625, 0, 0.25},
  50.     ["DRAENEI_FEMALE"]  = {0.5, 0.625, 0.5, 0.75},
  51.    
  52.     -- CUSTOM START
  53.     ["NAGA_MALE"]   = {0.5, 0.625, 0, 0.25},
  54.     ["NAGA_FEMALE"] = {0.5, 0.625, 0.5, 0.75},
  55.    
  56.     ["VRYKUL_MALE"] = {0.5, 0.625, 0, 0.25},
  57.     ["VRYKUL_FEMALE"]   = {0.5, 0.625, 0.5, 0.75},
  58.    
  59.     ["TUSKARR_MALE"]    = {0.5, 0.625, 0, 0.25},
  60.     ["TUSKARR_FEMALE"]  = {0.5, 0.625, 0.5, 0.75},
  61.    
  62.     ["TAUNKA_MALE"] = {0.5, 0.625, 0, 0.25},
  63.     ["TAUNKA_FEMALE"]   = {0.5, 0.625, 0.5, 0.75},
  64.     -- CUSTOM END
  65. };
  66. CLASS_ICON_TCOORDS = {
  67.     ["WARRIOR"] = {0, 0.25, 0, 0.25},
  68.     ["MAGE"]    = {0.25, 0.49609375, 0, 0.25},
  69.     ["ROGUE"]   = {0.49609375, 0.7421875, 0, 0.25},
  70.     ["DRUID"]   = {0.7421875, 0.98828125, 0, 0.25},
  71.     ["HUNTER"]  = {0, 0.25, 0.25, 0.5},
  72.     ["SHAMAN"]  = {0.25, 0.49609375, 0.25, 0.5},
  73.     ["PRIEST"]  = {0.49609375, 0.7421875, 0.25, 0.5},
  74.     ["WARLOCK"] = {0.7421875, 0.98828125, 0.25, 0.5},
  75.     ["PALADIN"] = {0, 0.25, 0.5, 0.75},
  76.     ["DEATHKNIGHT"] = {0.25, 0.49609375, 0.5, 0.75},
  77. };
  78.  
  79. function CharacterCreate_OnLoad(self)
  80.     self:SetSequence(0);
  81.     self:SetCamera(0);
  82.  
  83.     CharacterCreate.numRaces = 0;
  84.     CharacterCreate.selectedRace = 0;
  85.     CharacterCreate.numClasses = 0;
  86.     CharacterCreate.selectedClass = 0;
  87.     CharacterCreate.selectedGender = 0;
  88.  
  89.     SetCharCustomizeFrame("CharacterCreate");
  90.  
  91.     for i=1, NUM_CHAR_CUSTOMIZATIONS, 1 do
  92.         _G["CharacterCustomizationButtonFrame"..i.."Text"]:SetText(_G["CHAR_CUSTOMIZATION"..i.."_DESC"]);
  93.     end
  94.  
  95.     -- Color edit box backdrop
  96.     local backdropColor = FACTION_BACKDROP_COLOR_TABLE["Alliance"];
  97.     CharacterCreateNameEdit:SetBackdropBorderColor(backdropColor[1], backdropColor[2], backdropColor[3]);
  98.     CharacterCreateNameEdit:SetBackdropColor(backdropColor[4], backdropColor[5], backdropColor[6]);
  99. end
  100.  
  101. function CharacterCreate_OnShow()
  102.     for i=1, MAX_CLASSES_PER_RACE, 1 do
  103.         local button = _G["CharacterCreateClassButton"..i];
  104.         button:Enable();
  105.         SetButtonDesaturated(button, false)
  106.     end
  107.     for i=1, MAX_RACES, 1 do
  108.         local button = _G["CharacterCreateRaceButton"..i];
  109.         button:Enable();
  110.         SetButtonDesaturated(button, false)
  111.     end
  112.  
  113.     if ( PAID_SERVICE_TYPE ) then
  114.         CustomizeExistingCharacter( PAID_SERVICE_CHARACTER_ID );
  115.         CharacterCreateNameEdit:SetText( PaidChange_GetName() );
  116.     else
  117.         --randomly selects a combination
  118.         ResetCharCustomize();
  119.         CharacterCreateNameEdit:SetText("");
  120.         CharCreateRandomizeButton:Show();
  121.     end
  122.  
  123.     CharacterCreateEnumerateRaces(GetAvailableRaces());
  124.     SetCharacterRace(GetSelectedRace());
  125.    
  126.     CharacterCreateEnumerateClasses(GetAvailableClasses());
  127.     local_,_,index = GetSelectedClass();
  128.     SetCharacterClass(index);
  129.  
  130.     SetCharacterGender(GetSelectedSex())
  131.    
  132.     -- Hair customization stuff
  133.     CharacterCreate_UpdateHairCustomization();
  134.  
  135.     SetCharacterCreateFacing(-15);
  136.    
  137.     if ( ALLOW_RANDOM_NAME_BUTTON ) then
  138.         CharacterCreateRandomName:Show();
  139.     end
  140.    
  141.     -- setup customization
  142.     CharacterChangeFixup();
  143. end
  144.  
  145. function CharacterCreate_OnHide()
  146.     PAID_SERVICE_CHARACTER_ID = nil;
  147.     PAID_SERVICE_TYPE = nil;
  148. end
  149.  
  150. function CharacterCreateFrame_OnMouseDown(button)
  151.     if ( button == "LeftButton" ) then
  152.         CHARACTER_CREATE_ROTATION_START_X = GetCursorPosition();
  153.         CHARACTER_CREATE_INITIAL_FACING = GetCharacterCreateFacing();
  154.     end
  155. end
  156.  
  157. function CharacterCreateFrame_OnMouseUp(button)
  158.     if ( button == "LeftButton" ) then
  159.         CHARACTER_CREATE_ROTATION_START_X = nil
  160.     end
  161. end
  162.  
  163. function CharacterCreateFrame_OnUpdate()
  164.     if ( CHARACTER_CREATE_ROTATION_START_X ) then
  165.         local x = GetCursorPosition();
  166.         local diff = (x - CHARACTER_CREATE_ROTATION_START_X) * CHARACTER_ROTATION_CONSTANT;
  167.         CHARACTER_CREATE_ROTATION_START_X = GetCursorPosition();
  168.         SetCharacterCreateFacing(GetCharacterCreateFacing() + diff);
  169.     end
  170. end
  171.  
  172. function CharacterCreateEnumerateRaces(...)
  173.     CharacterCreate.numRaces = select("#", ...)/3;
  174.     if ( CharacterCreate.numRaces > MAX_RACES ) then
  175.         message("Too many races!  Update MAX_RACES");
  176.         return;
  177.     end
  178.     local coords;
  179.     local index = 1;
  180.     local button;
  181.     local gender;
  182.     local selectedSex = GetSelectedSex();
  183.     if ( selectedSex == SEX_MALE ) then
  184.         gender = "MALE";
  185.     elseif ( selectedSex == SEX_FEMALE ) then
  186.         gender = "FEMALE";
  187.     end
  188.     for i=1, select("#", ...), 3 do
  189.         coords = RACE_ICON_TCOORDS[strupper(select(i+1, ...).."_"..gender)];
  190.         _G["CharacterCreateRaceButton"..index.."NormalTexture"]:SetTexCoord(coords[1], coords[2], coords[3], coords[4]);
  191.         _G["CharacterCreateRaceButton"..index.."PushedTexture"]:SetTexCoord(coords[1], coords[2], coords[3], coords[4]);
  192.         button = _G["CharacterCreateRaceButton"..index];
  193.         button:Show();
  194.         if ( select(i+2, ...) == 1 ) then
  195.             button.enable = true;
  196.             SetButtonDesaturated(button);
  197.             button.name = select(i, ...)
  198.             button.tooltip = select(i, ...);
  199.         else
  200.             button.enable = false;
  201.             SetButtonDesaturated(button, 1);
  202.             button.name = select(i, ...)
  203.             button.tooltip = _G[strupper(select(i+1, ...).."_".."DISABLED")];
  204.         end
  205.         index = index + 1;
  206.     end
  207.     for i=CharacterCreate.numRaces + 1, MAX_RACES, 1 do
  208.         _G["CharacterCreateRaceButton"..i]:Hide();
  209.     end
  210. end
  211.  
  212. function CharacterCreateEnumerateClasses(...)
  213.     CharacterCreate.numClasses = select("#", ...)/3;
  214.     if ( CharacterCreate.numClasses > MAX_CLASSES_PER_RACE ) then
  215.         message("Too many classes!  Update MAX_CLASSES_PER_RACE");
  216.         return;
  217.     end
  218.     local coords;
  219.     local index = 1;
  220.     local button;
  221.     for i=1, select("#", ...), 3 do
  222.         coords = CLASS_ICON_TCOORDS[strupper(select(i+1, ...))];
  223.         _G["CharacterCreateClassButton"..index.."NormalTexture"]:SetTexCoord(coords[1], coords[2], coords[3], coords[4]);
  224.         _G["CharacterCreateClassButton"..index.."PushedTexture"]:SetTexCoord(coords[1], coords[2], coords[3], coords[4]);
  225.         button = _G["CharacterCreateClassButton"..index];
  226.         button:Show();
  227.         if ( (select(i+2, ...) == 1) and (IsRaceClassValid(CharacterCreate.selectedRace, index)) ) then
  228.             button.enable = true;
  229.             button:Enable();
  230.             SetButtonDesaturated(button);
  231.             button.name = select(i, ...)
  232.             button.tooltip = select(i, ...);
  233.             _G["CharacterCreateClassButton"..index.."DisableTexture"]:Hide();
  234.         else
  235.             button.enable = false;
  236.             button:Disable();
  237.             SetButtonDesaturated(button, 1);
  238.             button.name = select(i, ...)
  239.             button.tooltip = _G[strupper(select(i+1, ...).."_".."DISABLED")];
  240.             _G["CharacterCreateClassButton"..index.."DisableTexture"]:Show();
  241.         end
  242.         index = index + 1;
  243.     end
  244.     for i=CharacterCreate.numClasses + 1, MAX_CLASSES_PER_RACE, 1 do
  245.         _G["CharacterCreateClassButton"..i]:Hide();
  246.     end
  247. end
  248.  
  249. function SetCharacterRace(id)
  250.     CharacterCreate.selectedRace = id;
  251.     local selectedButton;
  252.     for i=1, CharacterCreate.numRaces, 1 do
  253.         local button = _G["CharacterCreateRaceButton"..i];
  254.         if ( i == id ) then
  255.             _G["CharacterCreateRaceButton"..i.."Text"]:SetText(button.name);
  256.             button:SetChecked(1);
  257.             selectedButton = button;
  258.         else
  259.             _G["CharacterCreateRaceButton"..i.."Text"]:SetText("");
  260.             button:SetChecked(0);
  261.         end
  262.     end
  263.  
  264.     -- Set Faction
  265.     local name, faction = GetFactionForRace(CharacterCreate.selectedRace);
  266.  
  267.     -- Set Race
  268.     local race, fileString = GetNameForRace();
  269.  
  270.     CharacterCreateRaceLabel:SetText(race);
  271.     fileString = strupper(fileString);
  272.     if ( GetSelectedSex() == SEX_MALE ) then
  273.         gender = "MALE";
  274.     else
  275.         gender = "FEMALE";
  276.     end
  277.     local coords = RACE_ICON_TCOORDS[fileString.."_"..gender];
  278.     CharacterCreateRaceIcon:SetTexCoord(coords[1], coords[2], coords[3], coords[4]);
  279.     local raceText = _G["RACE_INFO_"..fileString];
  280.     local abilityIndex = 1;
  281.     local tempText = _G["ABILITY_INFO_"..fileString..abilityIndex];
  282.     abilityText = "";
  283.     while ( tempText ) do
  284.         abilityText = abilityText..tempText.."\n\n";
  285.         abilityIndex = abilityIndex + 1;
  286.         tempText = _G["ABILITY_INFO_"..fileString..abilityIndex];
  287.     end
  288.  
  289.     CharacterCreateRaceScrollFrameScrollBar:SetValue(0);
  290.     CharacterCreateRaceText:SetText(GetFlavorText("RACE_INFO_"..strupper(fileString), GetSelectedSex()).."|n|n");
  291.     if ( abilityText and abilityText ~= "" ) then
  292.         CharacterCreateRaceAbilityText:SetText(abilityText);
  293.     else
  294.         CharacterCreateRaceAbilityText:SetText("");
  295.     end
  296.  
  297.     -- Set backdrop colors based on faction
  298.     local backdropColor = FACTION_BACKDROP_COLOR_TABLE[faction];
  299.     local frame;
  300.     for index, value in pairs(FRAMES_TO_BACKDROP_COLOR) do
  301.         frame = _G[value];
  302.         frame:SetBackdropColor(backdropColor[4], backdropColor[5], backdropColor[6]);
  303.     end
  304.     CharacterCreateConfigurationBackground:SetVertexColor(backdropColor[4], backdropColor[5], backdropColor[6]);
  305.  
  306.     local backgroundFilename = GetCreateBackgroundModel();
  307.     SetBackgroundModel(CharacterCreate, backgroundFilename);
  308. end
  309.  
  310. function SetCharacterClass(id)
  311.     CharacterCreate.selectedClass = id;
  312.     for i=1, CharacterCreate.numClasses, 1 do
  313.         local button = _G["CharacterCreateClassButton"..i];
  314.         if ( i == id ) then
  315.             CharacterCreateClassName:SetText(button.name);
  316.             button:SetChecked(1);
  317.         else
  318.             button:SetChecked(0);
  319.         end
  320.     end
  321.    
  322.     local className, classFileName, _, tank, healer, damage = GetSelectedClass();
  323.     local abilityIndex = 0;
  324.     local tempText = _G["CLASS_INFO_"..classFileName..abilityIndex];
  325.     abilityText = "";
  326.     while ( tempText ) do
  327.         abilityText = abilityText..tempText.."\n\n";
  328.         abilityIndex = abilityIndex + 1;
  329.         tempText = _G["CLASS_INFO_"..classFileName..abilityIndex];
  330.     end
  331.     local coords = CLASS_ICON_TCOORDS[classFileName];
  332.     CharacterCreateClassIcon:SetTexCoord(coords[1], coords[2], coords[3], coords[4]);
  333.     CharacterCreateClassLabel:SetText(className);
  334.     CharacterCreateClassRolesText:SetText(abilityText);
  335.     CharacterCreateClassText:SetText(GetFlavorText("CLASS_"..strupper(classFileName), GetSelectedSex()).."|n|n");
  336.     CharacterCreateClassScrollFrameScrollBar:SetValue(0);
  337. end
  338.  
  339. function CharacterCreate_OnChar()
  340. end
  341.  
  342. function CharacterCreate_OnKeyDown(key)
  343.     if ( key == "ESCAPE" ) then
  344.         CharacterCreate_Back();
  345.     elseif ( key == "ENTER" ) then
  346.         CharacterCreate_Okay();
  347.     elseif ( key == "PRINTSCREEN" ) then
  348.         Screenshot();
  349.     end
  350. end
  351.  
  352. function CharacterCreate_UpdateModel(self)
  353.     UpdateCustomizationScene();
  354.     self:AdvanceTime();
  355. end
  356.  
  357. function CharacterCreate_Okay()
  358.     if ( PAID_SERVICE_TYPE ) then
  359.         GlueDialog_Show("CONFIRM_PAID_SERVICE");
  360.     else
  361.         CreateCharacter(CharacterCreateNameEdit:GetText());
  362.     end
  363.     PlaySound("gsCharacterCreationCreateChar");
  364. end
  365.  
  366. function CharacterCreate_Back()
  367.     PlaySound("gsCharacterCreationCancel");
  368.     SetGlueScreen("charselect");
  369. end
  370.  
  371. function CharacterClass_OnClick(id)
  372.     PlaySound("gsCharacterCreationClass");
  373.     local _,_,currClass = GetSelectedClass();
  374.     if ( currClass ~= id and IsRaceClassValid(GetSelectedRace(), id) ) then
  375.         SetSelectedClass(id);
  376.         SetCharacterClass(id);
  377.         SetCharacterRace(GetSelectedRace());
  378.         CharacterChangeFixup();
  379.     end
  380. end
  381.  
  382. function CharacterRace_OnClick(self, id)
  383.     PlaySound("gsCharacterCreationClass");
  384.     if ( not self:GetChecked() ) then
  385.         self:SetChecked(1);
  386.         return;
  387.     end
  388.     if ( GetSelectedRace() ~= id ) then
  389.         SetSelectedRace(id);
  390.         SetCharacterRace(id);
  391.         SetSelectedSex(GetSelectedSex());
  392.         SetCharacterCreateFacing(-15);
  393.         CharacterCreateEnumerateClasses(GetAvailableClasses());
  394.         local _,_,classIndex = GetSelectedClass();
  395.         if ( PAID_SERVICE_TYPE ) then
  396.             classIndex = PaidChange_GetCurrentClassIndex();
  397.         end
  398.         SetCharacterClass(classIndex);
  399.        
  400.         -- Hair customization stuff
  401.         CharacterCreate_UpdateHairCustomization();
  402.            
  403.         CharacterChangeFixup();
  404.     end
  405. end
  406.  
  407. function SetCharacterGender(sex)
  408.     local gender;
  409.     SetSelectedSex(sex);
  410.     if ( sex == SEX_MALE ) then
  411.         gender = "MALE";
  412.         CharacterCreateGender:SetText(MALE);
  413.         CharacterCreateGenderButtonMale:SetChecked(1);
  414.         CharacterCreateGenderButtonFemale:SetChecked(nil);
  415.     elseif ( sex == SEX_FEMALE ) then
  416.         gender = "FEMALE";
  417.         CharacterCreateGender:SetText(FEMALE);
  418.         CharacterCreateGenderButtonMale:SetChecked(nil);
  419.         CharacterCreateGenderButtonFemale:SetChecked(1);
  420.     end
  421.  
  422.     -- Update race images to reflect gender
  423.     CharacterCreateEnumerateRaces(GetAvailableRaces());
  424.     CharacterCreateEnumerateClasses(GetAvailableClasses());
  425.     SetCharacterRace(GetSelectedRace());
  426.    
  427.     local _,_,classIndex = GetSelectedClass();
  428.     if ( PAID_SERVICE_TYPE ) then
  429.         classIndex = PaidChange_GetCurrentClassIndex();
  430.     end
  431.     SetCharacterClass(classIndex);
  432.  
  433.     CharacterCreate_UpdateHairCustomization();
  434.  
  435.     -- Update right hand race portrait to reflect gender change
  436.     -- Set Race
  437.     local race, fileString = GetNameForRace();
  438.     CharacterCreateRaceLabel:SetText(race);
  439.     fileString = strupper(fileString);
  440.     local coords = RACE_ICON_TCOORDS[fileString.."_"..gender];
  441.     CharacterCreateRaceIcon:SetTexCoord(coords[1], coords[2], coords[3], coords[4]);
  442.    
  443.     CharacterChangeFixup();
  444. end
  445.  
  446. function CharacterCustomization_Left(id)
  447.     PlaySound("gsCharacterCreationLook");
  448.     CycleCharCustomization(id, -1);
  449. end
  450.  
  451. function CharacterCustomization_Right(id)
  452.     PlaySound("gsCharacterCreationLook");
  453.     CycleCharCustomization(id, 1);
  454. end
  455.  
  456. function CharacterCreate_Randomize()
  457.     PlaySound("gsCharacterCreationLook");
  458.     RandomizeCharCustomization();
  459. end
  460.  
  461. function CharacterCreateRotateRight_OnUpdate(self)
  462.     if ( self:GetButtonState() == "PUSHED" ) then
  463.         SetCharacterCreateFacing(GetCharacterCreateFacing() + CHARACTER_FACING_INCREMENT);
  464.     end
  465. end
  466.  
  467. function CharacterCreateRotateLeft_OnUpdate(self)
  468.     if ( self:GetButtonState() == "PUSHED" ) then
  469.         SetCharacterCreateFacing(GetCharacterCreateFacing() - CHARACTER_FACING_INCREMENT);
  470.     end
  471. end
  472.  
  473. function CharacterCreate_UpdateHairCustomization()
  474.     CharacterCustomizationButtonFrame3Text:SetText(_G["HAIR_"..GetHairCustomization().."_STYLE"]);
  475.     CharacterCustomizationButtonFrame4Text:SetText(_G["HAIR_"..GetHairCustomization().."_COLOR"]);
  476.     CharacterCustomizationButtonFrame5Text:SetText(_G["FACIAL_HAIR_"..GetFacialHairCustomization()]);      
  477. end
  478.  
  479. function SetButtonDesaturated(button, desaturated, r, g, b)
  480.     if ( not button ) then
  481.         return;
  482.     end
  483.     local icon = button:GetNormalTexture();
  484.     if ( not icon ) then
  485.         return;
  486.     end
  487.     local shaderSupported = icon:SetDesaturated(desaturated);
  488.  
  489.     if ( not desaturated ) then
  490.         r = 1.0;
  491.         g = 1.0;
  492.         b = 1.0;
  493.     elseif ( not r or not shaderSupported ) then
  494.         r = 0.5;
  495.         g = 0.5;
  496.         b = 0.5;
  497.     end
  498.    
  499.     icon:SetVertexColor(r, g, b);
  500. end
  501.  
  502. function GetFlavorText(tagname, sex)
  503.     local primary, secondary;
  504.     if ( sex == SEX_MALE ) then
  505.         primary = "";
  506.         secondary = "_FEMALE";
  507.     else
  508.         primary = "_FEMALE";
  509.         secondary = "";
  510.     end
  511.     local text = _G[tagname..primary];
  512.     if ( (text == nil) or (text == "") ) then
  513.         text = _G[tagname..secondary];
  514.     end
  515.     return text;
  516. end
  517.  
  518. function CharacterCreate_DeathKnightSwap(self)
  519.     local _, classFilename = GetSelectedClass();
  520.     if ( classFilename == "DEATHKNIGHT" ) then
  521.         if (self.currentModel ~= "DEATHKNIGHT") then
  522.             self.currentModel = "DEATHKNIGHT";
  523.             self:SetNormalTexture("Interface\\Glues\\Common\\Glue-Panel-Button-Up-Blue");
  524.             self:SetPushedTexture("Interface\\Glues\\Common\\Glue-Panel-Button-Down-Blue");
  525.             self:SetHighlightTexture("Interface\\Glues\\Common\\Glue-Panel-Button-Highlight-Blue");
  526.         end
  527.     else
  528.         if (self.currentModel == "DEATHKNIGHT") then
  529.             self.currentModel = nil;
  530.             self:SetNormalTexture("Interface\\Glues\\Common\\Glue-Panel-Button-Up");
  531.             self:SetPushedTexture("Interface\\Glues\\Common\\Glue-Panel-Button-Down");
  532.             self:SetHighlightTexture("Interface\\Glues\\Common\\Glue-Panel-Button-Highlight");
  533.         end
  534.     end
  535. end
  536.  
  537. function CharacterChangeFixup()
  538.     if ( PAID_SERVICE_TYPE ) then
  539.         for i=1, MAX_CLASSES_PER_RACE, 1 do
  540.             if (CharacterCreate.selectedClass ~= i) then
  541.                 local button = _G["CharacterCreateClassButton"..i];
  542.                 button:Disable();
  543.                 SetButtonDesaturated(button, true)
  544.             end
  545.         end
  546.  
  547.         for i=1, MAX_RACES, 1 do
  548.             local allow = false;
  549.             if ( PAID_SERVICE_TYPE == PAID_FACTION_CHANGE ) then
  550.                 local faction = GetFactionForRace(PaidChange_GetCurrentRaceIndex());
  551.                 if ( (i == PaidChange_GetCurrentRaceIndex()) or ((GetFactionForRace(i) ~= faction) and (IsRaceClassValid(i,CharacterCreate.selectedClass))) ) then
  552.                     allow = true;
  553.                 end
  554.             elseif ( PAID_SERVICE_TYPE == PAID_RACE_CHANGE ) then
  555.                 local faction = GetFactionForRace(PaidChange_GetCurrentRaceIndex());
  556.                 if ( (i == PaidChange_GetCurrentRaceIndex()) or ((GetFactionForRace(i) == faction) and (IsRaceClassValid(i,CharacterCreate.selectedClass))) ) then
  557.                     allow = true
  558.                 end
  559.             elseif ( PAID_SERVICE_TYPE == PAID_CHARACTER_CUSTOMIZATION ) then
  560.                 if ( i == CharacterCreate.selectedRace ) then
  561.                     allow = true
  562.                 end
  563.             end
  564.             if (not allow) then
  565.                 local button = _G["CharacterCreateRaceButton"..i];
  566.                 button:Disable();
  567.                 SetButtonDesaturated(button, true)
  568.             end
  569.         end
  570.     end
  571. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement