Advertisement
Guest User

CharacterCreate.lua

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