Advertisement
Guest User

CharacterCreate.lua

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