Advertisement
Skt16

CharacterCreate.LUA

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