Guest User

CharacterCreate.lua

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