Advertisement
Guest User

Untitled

a guest
Dec 13th, 2019
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 44.50 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. NUM_PREVIEW_FRAMES = 14;
  9. local featureIndex = 1
  10. local FeatureType = 1
  11.  
  12. CHAR_CREATE_MORE_INFO = "More Info";
  13. CUSTOMIZE = "Next";
  14. NEXT = "Next";
  15. FINISH = "Finish";
  16.  
  17. PAID_CHARACTER_CUSTOMIZATION = 1;
  18. PAID_RACE_CHANGE = 2;
  19. PAID_FACTION_CHANGE = 3;
  20. PAID_SERVICE_CHARACTER_ID = nil;
  21. PAID_SERVICE_TYPE = nil;
  22.  
  23. PREVIEW_FRAME_HEIGHT = 130;
  24. PREVIEW_FRAME_X_OFFSET = 19;
  25. PREVIEW_FRAME_Y_OFFSET = -7;
  26.  
  27. FACTION_BACKDROP_COLOR_TABLE = {
  28. ["Alliance"] = {0.5, 0.5, 0.5, 0.09, 0.09, 0.19, 0, 0, 0.2, 0.29, 0.33, 0.91},
  29. ["Horde"] = {0.5, 0.2, 0.2, 0.19, 0.05, 0.05, 0.2, 0, 0, 0.90, 0.05, 0.07},
  30. ["Player"] = {0.2, 0.5, 0.2, 0.05, 0.2, 0.05, 0.05, 0.2, 0.05, 1, 1, 1},
  31. };
  32. FRAMES_TO_BACKDROP_COLOR = {
  33. "CharacterCreateCharacterRace",
  34. "CharacterCreateCharacterClass",
  35. -- "CharacterCreateCharacterFaction",
  36. "CharacterCreateNameEdit",
  37. };
  38. RACE_ICON_TCOORDS = {
  39. ["HUMAN_MALE"] = {0, 0.125, 0, 0.25},
  40. ["DWARF_MALE"] = {0.125, 0.25, 0, 0.25},
  41. ["GNOME_MALE"] = {0.25, 0.375, 0, 0.25},
  42. ["NIGHTELF_MALE"] = {0.375, 0.5, 0, 0.25},
  43.  
  44. ["TAUREN_MALE"] = {0, 0.125, 0.25, 0.5},
  45. ["SCOURGE_MALE"] = {0.125, 0.25, 0.25, 0.5},
  46. ["TROLL_MALE"] = {0.25, 0.375, 0.25, 0.5},
  47. ["ORC_MALE"] = {0.375, 0.5, 0.25, 0.5},
  48.  
  49. ["HUMAN_FEMALE"] = {0, 0.125, 0.5, 0.75},
  50. ["DWARF_FEMALE"] = {0.125, 0.25, 0.5, 0.75},
  51. ["GNOME_FEMALE"] = {0.25, 0.375, 0.5, 0.75},
  52. ["NIGHTELF_FEMALE"] = {0.375, 0.5, 0.5, 0.75},
  53.  
  54. ["TAUREN_FEMALE"] = {0, 0.125, 0.75, 1.0},
  55. ["SCOURGE_FEMALE"] = {0.125, 0.25, 0.75, 1.0},
  56. ["TROLL_FEMALE"] = {0.25, 0.375, 0.75, 1.0},
  57. ["ORC_FEMALE"] = {0.375, 0.5, 0.75, 1.0},
  58.  
  59. ["BLOODELF_MALE"] = {0.5, 0.625, 0.25, 0.5},
  60. ["BLOODELF_FEMALE"] = {0.5, 0.625, 0.75, 1.0},
  61.  
  62. ["DRAENEI_MALE"] = {0.5, 0.625, 0, 0.25},
  63. ["DRAENEI_FEMALE"] = {0.5, 0.625, 0.5, 0.75},
  64. };
  65. CLASS_ICON_TCOORDS = {
  66. ["WARRIOR"] = {0, 0.25, 0, 0.25},
  67. ["MAGE"] = {0.25, 0.49609375, 0, 0.25},
  68. ["ROGUE"] = {0.49609375, 0.7421875, 0, 0.25},
  69. ["DRUID"] = {0.7421875, 0.98828125, 0, 0.25},
  70. ["HUNTER"] = {0, 0.25, 0.25, 0.5},
  71. ["SHAMAN"] = {0.25, 0.49609375, 0.25, 0.5},
  72. ["PRIEST"] = {0.49609375, 0.7421875, 0.25, 0.5},
  73. ["WARLOCK"] = {0.7421875, 0.98828125, 0.25, 0.5},
  74. ["PALADIN"] = {0, 0.25, 0.5, 0.75},
  75. ["DEATHKNIGHT"] = {0.25, 0.49609375, 0.5, 0.75},
  76. ["DEMONHUNTER"] = {0.49609375, 0.7421875, 0.5, 0.75},
  77. };
  78. MODEL_CAMERA_CONFIG = {
  79. [2] = {
  80. ["Draenei"] = { tx = 0.191, ty = -0.015, tz = 2.302, cz = 2.160, distance = 1.116, light = 0.80 },
  81. ["NightElf"] = { tx = 0.095, ty = -0.008, tz = 2.240, cz = 2.045, distance = 0.830, light = 0.85 },
  82. ["Scourge"] = { tx = 0.094, ty = -0.172, tz = 1.675, cz = 1.478, distance = 0.691, light = 0.80 },
  83. ["Orc"] = { tx = 0.346, ty = -0.001, tz = 1.878, cz = 1.793, distance = 1.074, light = 0.80 },
  84. ["Gnome"] = { tx = 0.051, ty = 0.015, tz = 0.845, cz = 0.821, distance = 0.821, light = 0.85 },
  85. ["Dwarf"] = { tx = 0.037, ty = 0.009, tz = 1.298, cz = 1.265, distance = 0.839, light = 0.85 },
  86. ["Tauren"] = { tx = 0.516, ty = -0.003, tz = 1.654, cz = 1.647, distance = 1.266, light = 0.80 },
  87. ["Troll"] = { tx = 0.402, ty = 0.016, tz = 2.076, cz = 1.980, distance = 0.943, light = 0.75 },
  88. ["BloodElf"] = { tx = 0.009, ty = -0.120, tz = 1.914, cz = 1.712, distance = 0.727, light = 0.80 },
  89. ["Human"] = { tx = 0.055, ty = 0.006, tz = 1.863, cz = 1.749, distance = 0.714, light = 0.75 },
  90. },
  91. [3] = {
  92. ["Draenei"] = { tx = 0.155, ty = 0.009, tz = 2.177, cz = 1.971, distance = 0.734, light = 0.75 },
  93. ["NightElf"] = { tx = 0.071, ty = 0.034, tz = 2.068, cz = 2.055, distance = 0.682, light = 0.85 },
  94. ["Scourge"] = { tx = 0.198, ty = 0.001, tz = 1.669, cz = 1.509, distance = 0.563, light = 0.75 },
  95. ["Orc"] = { tx = -0.069, ty = -0.007, tz = 1.863, cz = 1.718, distance = 0.585, light = 0.75 },
  96. ["Gnome"] = { tx = 0.031, ty = 0.009, tz = 0.787, cz = 0.693, distance = 0.726, light = 0.85 },
  97. ["Dwarf"] = { tx = -0.060, ty = -0.010, tz = 1.326, cz = 1.343, distance = 0.720, light = 0.80 },
  98. ["Tauren"] = { tx = 0.337, ty = -0.008, tz = 1.918, cz = 1.855, distance = 0.891, light = 0.75 },
  99. ["Troll"] = { tx = 0.031, ty = -0.082, tz = 2.226, cz = 2.248, distance = 0.674, light = 0.75 },
  100. ["BloodElf"] = { tx = -0.072, ty = 0.009, tz = 1.789, cz = 1.792, distance = 0.717, light = 0.80 },
  101. ["Human"] = { tx = -0.044, ty = -0.015, tz = 1.755, cz = 1.689, distance = 0.612, light = 0.75 },
  102. }
  103. };
  104.  
  105. BANNER_DEFAULT_TEXTURE_COORDS = {0.109375, 0.890625, 0.201171875, 0.80078125};
  106. BANNER_DEFAULT_SIZE = {200, 308};
  107.  
  108. CHAR_CUSTOMIZE_HAIR_COLOR = 4;
  109.  
  110. function CharacterCreate_OnLoad(self)
  111. self:RegisterEvent("RANDOM_CHARACTER_NAME_RESULT");
  112. self:RegisterEvent("GLUE_UPDATE_EXPANSION_LEVEL");
  113.  
  114. self:SetSequence(0);
  115. self:SetCamera(0);
  116.  
  117. CharacterCreate.numRaces = 0;
  118. CharacterCreate.selectedRace = 0;
  119. CharacterCreate.numClasses = 0;
  120. CharacterCreate.selectedClass = 0;
  121. CharacterCreate.selectedGender = 0;
  122.  
  123. SetCharCustomizeFrame("CharacterCreate");
  124.  
  125. for i=1, NUM_CHAR_CUSTOMIZATIONS, 1 do
  126. _G["CharCreateCustomizationButton"..i].text:SetText(_G["CHAR_CUSTOMIZATION"..i.."_DESC"]);
  127. end
  128.  
  129. -- Color edit box backdrop
  130. local backdropColor = FACTION_BACKDROP_COLOR_TABLE["Alliance"];
  131. CharacterCreateNameEdit:SetBackdropBorderColor(backdropColor[1], backdropColor[2], backdropColor[3]);
  132. CharacterCreateNameEdit:SetBackdropColor(backdropColor[4], backdropColor[5], backdropColor[6]);
  133.  
  134. CharacterCreateFrame.state = "CLASSRACE";
  135.  
  136. CharCreatePreviewFrame.previews = { };
  137. end
  138.  
  139. function CharCustomizeButtonClick(id)
  140. CycleCharCustomization(id, 1);
  141. --[[FeatureType = id
  142. for i=1,5 do
  143. _G["CharCreateCustomizationButton"..i]:SetChecked(0);
  144. end
  145. _G["CharCreateCustomizationButton"..id]:SetChecked(1);]]
  146.  
  147. end
  148.  
  149. function CharacterCreate_OnShow()
  150. for i=1, MAX_CLASSES_PER_RACE, 1 do
  151. local button = _G["CharCreateClassButton"..i];
  152. button:Enable();
  153. SetButtonDesaturated(button, false)
  154. end
  155. for i=1, MAX_RACES, 1 do
  156. local button = _G["CharCreateRaceButton"..i];
  157. button:Enable();
  158. SetButtonDesaturated(button, false)
  159. end
  160.  
  161. if ( PAID_SERVICE_TYPE ) then
  162. CustomizeExistingCharacter( PAID_SERVICE_CHARACTER_ID );
  163. CharacterCreateNameEdit:SetText( PaidChange_GetName() );
  164. else
  165. --randomly selects a combination
  166. ResetCharCustomize();
  167. CharacterCreateNameEdit:SetText("");
  168. CharCreateRandomizeButton:Show();
  169. end
  170.  
  171. CharacterCreateEnumerateRaces(GetAvailableRaces());
  172. SetCharacterRace(GetSelectedRace());
  173.  
  174. CharacterCreateEnumerateClasses(GetAvailableClasses());
  175. local_,_,index = GetSelectedClass();
  176. SetCharacterClass(index);
  177.  
  178. if ( GetSelectedRace() == TUSKARR_RACE_ID ) then
  179. SetCharacterGender(SEX_MALE);
  180. CharCreateMaleButton:SetChecked(1);
  181. CharCreateFemaleButton:SetChecked(0);
  182. else
  183. SetCharacterGender(GetSelectedSex());
  184. end
  185.  
  186. -- Hair customization stuff
  187. CharacterCreate_UpdateHairCustomization();
  188.  
  189. SetCharacterCreateFacing(-15);
  190.  
  191. -- setup customization
  192. CharacterChangeFixup();
  193.  
  194. --SetFaceCustomizeCamera(false);
  195. end
  196.  
  197. function CharacterCreate_OnHide()
  198. PAID_SERVICE_CHARACTER_ID = nil;
  199. PAID_SERVICE_TYPE = nil;
  200. if ( CharacterCreateFrame.state == "CUSTOMIZATION" ) then
  201. CharacterCreate_Back();
  202. end
  203. -- character previews will need to be redone if coming back to character create. One reason is all the memory used for
  204. -- tracking the frames (on the c side) will get released if the user returns to the login screen
  205. CharCreatePreviewFrame.rebuildPreviews = true;
  206. end
  207.  
  208. function CharacterCreate_OnEvent(event, arg1, arg2, arg3)
  209. if ( event == "RANDOM_CHARACTER_NAME_RESULT" ) then
  210. if ( arg1 == 0 ) then
  211. -- Failed. Generate a random name locally.
  212. CharacterCreateNameEdit:SetText(GenerateRandomName());
  213. else
  214. -- Succeeded. Use what the server sent.
  215. CharacterCreateNameEdit:SetText(arg2);
  216. end
  217. CharacterCreateRandomName:Enable();
  218. CharCreateOkayButton:Enable();
  219. PlaySound("gsCharacterCreationLook");
  220. elseif ( event == "GLUE_UPDATE_EXPANSION_LEVEL" ) then
  221. -- Expansion level changed while online, so enable buttons as needed
  222. if ( CharacterCreateFrame:IsShown() ) then
  223. CharacterCreateEnumerateRaces(GetAvailableRaces());
  224. CharacterCreateEnumerateClasses(GetAvailableClasses());
  225. end
  226. end
  227. end
  228.  
  229. function CharacterCreateFrame_OnMouseDown(button)
  230. if ( button == "LeftButton" ) then
  231. CHARACTER_CREATE_ROTATION_START_X = GetCursorPosition();
  232. CHARACTER_CREATE_INITIAL_FACING = GetCharacterCreateFacing();
  233. end
  234. end
  235.  
  236. function CharacterCreateFrame_OnMouseUp(button)
  237. if ( button == "LeftButton" ) then
  238. CHARACTER_CREATE_ROTATION_START_X = nil
  239. end
  240. end
  241.  
  242. function CharacterCreateFrame_OnUpdate(self, elapsed)
  243. if ( CHARACTER_CREATE_ROTATION_START_X ) then
  244. local x = GetCursorPosition();
  245. local diff = (x - CHARACTER_CREATE_ROTATION_START_X) * CHARACTER_ROTATION_CONSTANT;
  246. CHARACTER_CREATE_ROTATION_START_X = GetCursorPosition();
  247. SetCharacterCreateFacing(GetCharacterCreateFacing() + diff);
  248. CharCreate_RotatePreviews();
  249. end
  250. CharacterCreateWhileMouseDown_Update(elapsed);
  251. end
  252.  
  253. function CharacterCreateEnumerateRaces(...)
  254. CharacterCreate.numRaces = select("#", ...)/3;
  255. if ( CharacterCreate.numRaces > MAX_RACES ) then
  256. message("Too many races! Update MAX_RACES");
  257. return;
  258. end
  259. local coords;
  260. local index = 1;
  261. local button;
  262. local gender;
  263. local selectedSex = GetSelectedSex();
  264. if ( selectedSex == SEX_MALE ) then
  265. gender = "MALE";
  266. else
  267. gender = "FEMALE";
  268. end
  269. for i=1, select("#", ...), 3 do
  270. local name = select(i, ...);
  271. if ( index == TUSKARR_RACE_ID ) then
  272. coords = RACE_ICON_TCOORDS[strupper(select(i+1, ...).."_MALE")];
  273. else
  274. coords = RACE_ICON_TCOORDS[strupper(select(i+1, ...).."_"..gender)];
  275. end
  276. _G["CharCreateRaceButton"..index.."NormalTexture"]:SetTexCoord(coords[1], coords[2], coords[3], coords[4]);
  277. _G["CharCreateRaceButton"..index.."PushedTexture"]:SetTexCoord(coords[1], coords[2], coords[3], coords[4]);
  278. button = _G["CharCreateRaceButton"..index];
  279. if ( not button ) then
  280. return;
  281. end
  282. button.nameFrame.text:SetText(name);
  283. --button.nameFrame.text:SetText(tostring(index));
  284. if ( select(i+2, ...) == 1 and name ~= "Worgen"--[[ and (name ~= "Goblin"or gender == "MALE")]]) then
  285. button:Enable();
  286. SetButtonDesaturated(button);
  287. button.name = name;
  288. button.tooltip = name;
  289. else
  290. button:Disable();
  291. SetButtonDesaturated(button, 1);
  292. button.name = name;
  293. local disabledReason = _G[strupper(select(i+1, ...).."_".."DISABLED")];
  294. if ( disabledReason ) then
  295. button.tooltip = name.."|n"..disabledReason;
  296. else
  297. button.tooltip = nil;
  298. end
  299. end
  300. index = index + 1;
  301. end
  302. for i=CharacterCreate.numRaces + 1, MAX_RACES, 1 do
  303. _G["CharCreateRaceButton"..i]:Hide();
  304. end
  305. end
  306.  
  307. function CharacterCreateEnumerateClasses(...)
  308. CharacterCreate.numClasses = select("#", ...)/3;
  309. if ( CharacterCreate.numClasses > MAX_CLASSES_PER_RACE ) then
  310. message("Too many classes! Update MAX_CLASSES_PER_RACE");
  311. return;
  312. end
  313. local coords;
  314. local index = 1;
  315. local button;
  316. for i=1, select("#", ...), 3 do
  317. coords = CLASS_ICON_TCOORDS[strupper(select(i+1, ...))];
  318. _G["CharCreateClassButton"..index.."NormalTexture"]:SetTexCoord(coords[1], coords[2], coords[3], coords[4]);
  319. _G["CharCreateClassButton"..index.."PushedTexture"]:SetTexCoord(coords[1], coords[2], coords[3], coords[4]);
  320. button = _G["CharCreateClassButton"..index];
  321. button:Show();
  322. button.nameFrame.text:SetText(select(i, ...));
  323. if ( select(i+2, ...) == 1 ) then
  324. if (IsRaceClassValid(CharacterCreate.selectedRace, index)) then
  325. button:Enable();
  326. SetButtonDesaturated(button);
  327. button.tooltip = nil;
  328. _G["CharCreateClassButton"..index.."DisableTexture"]:Hide();
  329. else
  330. button:Disable();
  331. SetButtonDesaturated(button, 1);
  332. button.tooltip = CLASS_DISABLED;
  333. _G["CharCreateClassButton"..index.."DisableTexture"]:Show();
  334. end
  335. else
  336. button:Disable();
  337. SetButtonDesaturated(button, 1);
  338. button.tooltip = _G[strupper(select(i+1, ...).."_".."DISABLED")];
  339. _G["CharCreateClassButton"..index.."DisableTexture"]:Show();
  340. end
  341. index = index + 1;
  342. end
  343. for i=CharacterCreate.numClasses + 1, MAX_CLASSES_PER_RACE, 1 do
  344. _G["CharCreateClassButton"..i]:Hide();
  345. end
  346. end
  347.  
  348. function SetCharacterRace(id)
  349.  
  350. CharacterCreate.selectedRace = id;
  351. for i=1, CharacterCreate.numRaces, 1 do
  352. local button = _G["CharCreateRaceButton"..i];
  353. if ( i == id ) then
  354. button:SetChecked(1);
  355. else
  356. button:SetChecked(0);
  357. end
  358. end
  359.  
  360. local name, faction = GetFactionForRace(CharacterCreate.selectedRace);
  361.  
  362. -- during a paid service we have to set alliance/horde for neutral races
  363. -- hard-coded for Pandaren because of alliance/horde pseudo buttons
  364. local canProceed = true;
  365. if ( id == TUSKARR_RACE_ID and PAID_SERVICE_TYPE ) then
  366. --[[
  367. --local currentFaction = PaidChange_GetCurrentFaction();
  368. if ( PaidChange_GetCurrentRaceIndex() == TUSKARR_RACE_ID and PAID_SERVICE_TYPE == PAID_FACTION_CHANGE ) then
  369. -- this is an original pandaren staying or becoming selected
  370. -- check the pseudo-buttons
  371. faction = PandarenFactionButtons_GetSelectedFaction();
  372. --if ( faction == currentFaction ) then
  373. canProceed = false;
  374. --end
  375. else
  376. -- for faction change use the opposite faction of current character
  377. if ( PAID_SERVICE_TYPE == PAID_FACTION_CHANGE ) then
  378. --if ( currentFaction == "Horde" ) then
  379. faction = "Alliance";
  380. --elseif ( currentFaction == "Alliance" ) then
  381. -- faction = "Horde";
  382. --end
  383. -- for race change and customization use the same faction as current character
  384. else
  385. faction = "Alliance";
  386. end
  387. end
  388. ]]
  389. faction = "Alliance";
  390. else
  391. PandarenFactionButtons_ClearSelection();
  392. end
  393. CharCreate_EnableNextButton(canProceed);
  394.  
  395. -- Set background
  396. local backgroundFilename = GetCreateBackgroundModel(faction);
  397. if CharacterCreate.selectedClass == 11 then
  398. backgroundFilename = "DEMONHUNTER"
  399. end
  400. SetBackgroundModel(CharacterCreate, backgroundFilename);
  401.  
  402. if faction == nil then
  403. faction = "Alliance";
  404. end
  405.  
  406. -- Set backdrop colors based on faction
  407. local backdropColor = FACTION_BACKDROP_COLOR_TABLE[faction];
  408. CharCreateRaceFrame.factionBg:SetGradient("VERTICAL", 0, 0, 0, backdropColor[7], backdropColor[8], backdropColor[9]);
  409. CharCreateClassFrame.factionBg:SetGradient("VERTICAL", 0, 0, 0, backdropColor[7], backdropColor[8], backdropColor[9]);
  410. CharCreateCustomizationFrame.factionBg:SetGradient("VERTICAL", 0, 0, 0, backdropColor[7], backdropColor[8], backdropColor[9]);
  411. CharCreatePreviewFrame.factionBg:SetGradient("VERTICAL", 0, 0, 0, backdropColor[7], backdropColor[8], backdropColor[9]);
  412. CharCreateCustomizationFrameBanner:SetVertexColor(backdropColor[10], backdropColor[11], backdropColor[12]);
  413. CharacterCreateNameEdit:SetBackdropColor(backdropColor[4], backdropColor[5], backdropColor[6]);
  414. CharCreateRaceInfoFrame.factionBg:SetGradient("VERTICAL", 0, 0, 0, backdropColor[7], backdropColor[8], backdropColor[9]);
  415. CharCreateClassInfoFrame.factionBg:SetGradient("VERTICAL", 0, 0, 0, backdropColor[7], backdropColor[8], backdropColor[9]);
  416.  
  417. -- race info
  418. local frame = CharCreateRaceInfoFrame;
  419. local race, fileString = GetNameForRace();
  420. frame.title:SetText(race);
  421. fileString = strupper(fileString);
  422. local gender;
  423. if ( GetSelectedSex() == SEX_MALE ) then
  424. gender = "MALE";
  425. else
  426. gender = "FEMALE";
  427. end
  428. local raceText = _G["RACE_INFO_"..fileString];
  429. local abilityIndex = 1;
  430. local tempText = _G["ABILITY_INFO_"..fileString..abilityIndex];
  431. abilityText = "";
  432. while ( tempText ) do
  433. abilityText = abilityText..tempText.."\n\n";
  434. abilityIndex = abilityIndex + 1;
  435. tempText = _G["ABILITY_INFO_"..fileString..abilityIndex];
  436. end
  437. CharCreateRaceInfoFrameScrollFrameScrollBar:SetValue(0);
  438. CharCreateRaceInfoFrame.scrollFrame.scrollChild.infoText:SetText(GetFlavorText("RACE_INFO_"..strupper(fileString), GetSelectedSex()).."|n|n");
  439. if ( abilityText and abilityText ~= "" ) then
  440. CharCreateRaceInfoFrame.scrollFrame.scrollChild.bulletText:SetText(abilityText);
  441. else
  442. CharCreateRaceInfoFrame.scrollFrame.scrollChild.bulletText:SetText("");
  443. end
  444.  
  445. -- Altered form
  446. --[[if (HasAlteredForm()) then
  447. SetPortraitTexture(CharacterCreateAlternateFormTopPortrait, 22, GetSelectedSex());
  448. SetPortraitTexture(CharacterCreateAlternateFormBottomPortrait, 23, GetSelectedSex());
  449. CharacterCreateAlternateFormTop:Show();
  450. CharacterCreateAlternateFormBottom:Show();
  451. if( IsViewingAlteredForm() ) then
  452. CharacterCreateAlternateFormTop:SetChecked(false);
  453. CharacterCreateAlternateFormBottom:SetChecked(true);
  454. else
  455. CharacterCreateAlternateFormTop:SetChecked(true);
  456. CharacterCreateAlternateFormBottom:SetChecked(false);
  457. end
  458. else
  459. CharacterCreateAlternateFormTop:Hide();
  460. CharacterCreateAlternateFormBottom:Hide();
  461. end]]
  462. end
  463.  
  464. function SetCharacterClass(id)
  465. CharacterCreate.selectedClass = id;
  466. for i=1, CharacterCreate.numClasses, 1 do
  467. local button = _G["CharCreateClassButton"..i];
  468. if ( i == id ) then
  469. button:SetChecked(1);
  470. else
  471. button:SetChecked(0);
  472. button.selection:Hide();
  473. end
  474. end
  475.  
  476. -- class info
  477. local frame = CharCreateClassInfoFrame;
  478. local className, classFileName, _, tank, healer, damage = GetSelectedClass();
  479. local abilityIndex = 0;
  480. if not (classFileName) then
  481. classFileName = "Goblin"
  482. end
  483. local tempText = _G["CLASS_INFO_"..classFileName..abilityIndex];
  484. abilityText = "";
  485. while ( tempText ) do
  486. abilityText = abilityText..tempText.."\n\n";
  487. abilityIndex = abilityIndex + 1;
  488. tempText = _G["CLASS_INFO_"..classFileName..abilityIndex];
  489. end
  490. CharCreateClassInfoFrame.title:SetText(className);
  491. CharCreateClassInfoFrame.scrollFrame.scrollChild.bulletText:SetText(abilityText);
  492. local textt = GetFlavorText("CLASS_"..strupper(classFileName), GetSelectedSex())
  493. if not textt then
  494. textt = "Not implemented."
  495. end
  496. CharCreateClassInfoFrame.scrollFrame.scrollChild.infoText:SetText(textt.."|n|n");
  497. CharCreateClassInfoFrameScrollFrameScrollBar:SetValue(0);
  498. end
  499.  
  500. function CharacterCreate_OnChar()
  501. end
  502.  
  503. function CharacterCreate_OnKeyDown(key)
  504. if ( key == "ESCAPE" ) then
  505. CharacterCreate_Back();
  506. elseif ( key == "ENTER" ) then
  507. CharacterCreate_Forward();
  508. elseif ( key == "PRINTSCREEN" ) then
  509. Screenshot();
  510. end
  511. end
  512.  
  513. function CharacterCreate_UpdateModel(self)
  514. UpdateCustomizationScene();
  515. self:AdvanceTime();
  516. end
  517.  
  518. function CharacterCreate_Finish()
  519. PlaySound("gsCharacterCreationCreateChar");
  520.  
  521. -- If something disabled this button, ignore this message.
  522. -- This can happen if you press enter while it's disabled, for example.
  523. if ( not CharCreateOkayButton:IsEnabled() ) then
  524. return;
  525. end
  526.  
  527. --[[if GetCVar("realmList") ~= GLOBAL_REALMLIST then
  528. message("You are not connecting to "..GLOBAL_REALMLIST.." thus new characters cannot be created. Close WoW and uninstall this custom patch to continue.")
  529. return;
  530. end]]
  531.  
  532. if ( PAID_SERVICE_TYPE ) then
  533. GlueDialog_Show("CONFIRM_PAID_SERVICE");
  534. else
  535. -- if using templates, pandaren must pick a faction
  536. local _, faction = GetFactionForRace(CharacterCreate.selectedRace);
  537. --if ( IsUsingCharacterTemplate() and ( faction ~= "Alliance" and faction ~= "Horde" ) ) then
  538. -- CharacterTemplateConfirmDialog:Show();
  539. --else
  540. CreateCharacter(CharacterCreateNameEdit:GetText());
  541. --end
  542. end
  543. end
  544.  
  545. function CharacterCreate_Back()
  546. if ( CharacterCreateFrame.state == "CUSTOMIZATION" ) then
  547. PlaySound("gsCharacterCreationCancel");
  548. CharacterCreateFrame.state = "CLASSRACE"
  549. CharCreateClassFrame:Show();
  550. CharCreateRaceFrame:Show();
  551. CharCreateMoreInfoButton:Show();
  552. CharCreateCustomizationFrame:Hide();
  553. CharCreatePreviewFrame:Hide();
  554. CharCreateOkayButton:SetText(NEXT);
  555. CharacterCreateNameEdit:Hide();
  556. CharacterCreateRandomName:Hide();
  557.  
  558. CharCreateOkayButton:Enable()
  559.  
  560. --back to awesome gear
  561. --SetSelectedPreviewGearType(1);
  562.  
  563. -- back to normal camera
  564. --SetFaceCustomizeCamera(false);
  565.  
  566. return;
  567. end
  568.  
  569. PlaySound("gsCharacterCreationCancel");
  570. CHARACTER_SELECT_BACK_FROM_CREATE = true;
  571. SetGlueScreen("charselect");
  572. end
  573.  
  574. function CharacterCreate_UpdateFacialHairCustomization()
  575. if ( GetFacialHairCustomization() == "NONE" ) then
  576. CharacterCustomizationButtonFrame5:Hide();
  577. CharCreateRandomizeButton:SetPoint("TOP", "CharacterCustomizationButtonFrame5", "BOTTOM", 0, -5);
  578. else
  579. CharacterCustomizationButtonFrame5Text:SetText(_G["FACIAL_HAIR_"..GetFacialHairCustomization()]);
  580. CharacterCustomizationButtonFrame5:Show();
  581. CharCreateRandomizeButton:SetPoint("TOP", "CharacterCustomizationButtonFrame5", "BOTTOM", 0, -5);
  582. end
  583. end
  584.  
  585. function CharacterCreate_UpdateHairCustomization()
  586. CharacterCustomizationButtonFrame3Text:SetText(_G["HAIR_"..GetHairCustomization().."_STYLE"]);
  587. CharacterCustomizationButtonFrame4Text:SetText(_G["HAIR_"..GetHairCustomization().."_COLOR"]);
  588. end
  589.  
  590. function CharacterCreate_Forward()
  591. if ( CharacterCreateFrame.state == "CLASSRACE" ) then
  592. CharacterCreateFrame.state = "CUSTOMIZATION"
  593. PlaySound("gsCharacterSelectionCreateNew");
  594. CharCreateClassFrame:Hide();
  595. CharCreateRaceFrame:Hide();
  596. CharCreateMoreInfoButton:Hide();
  597. CharCreateCustomizationFrame:Show();
  598. --CharCreatePreviewFrame:Show();
  599. CharacterTemplateConfirmDialog:Hide();
  600.  
  601. CharCreate_PrepPreviewModels();
  602. if ( CharacterCreateFrame.customizationType ) then
  603. CharCreate_ResetFeaturesDisplay();
  604. else
  605. CharCreateSelectCustomizationType(1);
  606. end
  607.  
  608. CharCreateOkayButton:SetText(FINISH);
  609. CharacterCreateNameEdit:Show();
  610. if ( CharacterCreateNameEdit ) then
  611. CharacterCreateRandomName:Show();
  612. end
  613.  
  614.  
  615. --You just went to customization mode - show the boring start gear
  616. --SetSelectedPreviewGearType(0);
  617.  
  618. -- set cam
  619. --[[if (CharacterCreateFrame.customizationType and CharacterCreateFrame.customizationType > 1) then
  620. SetFaceCustomizeCamera(true);
  621. else
  622. SetFaceCustomizeCamera(false);
  623. end]]
  624. else
  625. CharacterCreate_Finish();
  626. end
  627. end
  628.  
  629. function CharCreateCustomizationFrame_OnShow ()
  630. -- reset size/tex coord to default to facilitate switching between genders for Pandaren
  631. CharCreateCustomizationFrameBanner:SetSize(BANNER_DEFAULT_SIZE[1], BANNER_DEFAULT_SIZE[2]);
  632. CharCreateCustomizationFrameBanner:SetTexCoord(BANNER_DEFAULT_TEXTURE_COORDS[1], BANNER_DEFAULT_TEXTURE_COORDS[2], BANNER_DEFAULT_TEXTURE_COORDS[3], BANNER_DEFAULT_TEXTURE_COORDS[4]);
  633.  
  634. -- check each button and hide it if there are no values select
  635. local resize = 0;
  636. local lastGood = 0;
  637. local isSkinVariantHair = false --GetSkinVariationIsHairColor(CharacterCreate.selectedRace);
  638. local isDefaultSet = 0;
  639. local checkedButton = 1;
  640.  
  641. -- check if this was set, if not, default to 1
  642. if ( CharacterCreateFrame.customizationType == 0 or CharacterCreateFrame.customizationType == nil ) then
  643. CharacterCreateFrame.customizationType = 1;
  644. end
  645. for i=1, NUM_CHAR_CUSTOMIZATIONS, 1 do
  646. if ( ( --[[GetNumFeatureVariationsForType(i)]]5 <= 1 ) or ( isSkinVariantHair and i == CHAR_CUSTOMIZE_HAIR_COLOR ) ) then
  647. resize = resize + 1;
  648. _G["CharCreateCustomizationButton"..i]:Hide();
  649. else
  650. _G["CharCreateCustomizationButton"..i]:Show();
  651. --_G["CharCreateCustomizationButton"..i]:SetChecked(0); -- we will handle default selection
  652. -- this must be done since a selected button can 'disappear' when swapping genders
  653. if ( isDefaultSet == 0 and CharacterCreateFrame.customizationType == i) then
  654. isDefaultSet = 1;
  655. checkedButton = i;
  656. end
  657. -- set your anchor to be the last good, this currently means button 1 HAS to be shown
  658. if (i > 1) then
  659. _G["CharCreateCustomizationButton"..i]:SetPoint( "TOP",_G["CharCreateCustomizationButton"..lastGood]:GetName() , "BOTTOM");
  660. end
  661. lastGood = i;
  662. end
  663. end
  664.  
  665. if (isDefaultSet == 0) then
  666. CharacterCreateFrame.customizationType = lastGood;
  667. checkedButton = lastGood;
  668. end
  669. --_G["CharCreateCustomizationButton"..checkedButton]:SetChecked(1);
  670.  
  671. if (resize > 0) then
  672. -- we need to resize and remap the banner texture
  673. local buttonx, buttony = CharCreateCustomizationButton1:GetSize()
  674. local screenamount = resize*buttony;
  675. print(screenamount);
  676. local frameX, frameY = CharCreateCustomizationFrameBanner:GetSize();
  677. local pctShrink = .2*resize;
  678. local uvXDefaultSize = BANNER_DEFAULT_TEXTURE_COORDS[2] - BANNER_DEFAULT_TEXTURE_COORDS[1];
  679. local uvYDefaultSize = BANNER_DEFAULT_TEXTURE_COORDS[4] - BANNER_DEFAULT_TEXTURE_COORDS[3];
  680. local newYUV = pctShrink*uvYDefaultSize + BANNER_DEFAULT_TEXTURE_COORDS[3];
  681. -- end coord stay the same
  682. CharCreateCustomizationFrameBanner:SetTexCoord(BANNER_DEFAULT_TEXTURE_COORDS[1], BANNER_DEFAULT_TEXTURE_COORDS[2], newYUV, BANNER_DEFAULT_TEXTURE_COORDS[4]);
  683. print(pctShrink);
  684. CharCreateCustomizationFrameBanner:SetSize(frameX, frameY - screenamount);
  685. print(CharCreateCustomizationFrameBanner:GetTexCoord());
  686. end
  687.  
  688. CharCreateRandomizeButton:SetPoint("TOP", _G["CharCreateCustomizationButton"..lastGood]:GetName(), "BOTTOM", 0, 0);
  689. end
  690.  
  691. function CharacterClass_OnClick(self, id)
  692. if( self:IsEnabled() ) then
  693. PlaySound("gsCharacterCreationClass");
  694. local _,_,currClass = GetSelectedClass();
  695. if ( currClass ~= id ) then
  696. SetSelectedClass(id);
  697. SetCharacterClass(id);
  698. SetCharacterRace(GetSelectedRace());
  699. CharacterChangeFixup();
  700. else
  701. self:SetChecked(1);
  702. end
  703. else
  704. self:SetChecked(0);
  705. end
  706. end
  707.  
  708. function CharacterRace_OnClick(self, id, forceSelect)
  709. if( self:IsEnabled() ) then
  710. PlaySound("gsCharacterCreationClass");
  711. if ( GetSelectedRace() ~= id or forceSelect ) then
  712. SetSelectedRace(id);
  713. SetCharacterRace(id);
  714. if ( id == TUSKARR_RACE_ID ) then
  715. SetCharacterGender(SEX_MALE);
  716. else
  717. SetCharacterGender(GetSelectedSex());
  718. end
  719. SetCharacterCreateFacing(-15);
  720. CharacterCreateEnumerateClasses(GetAvailableClasses());
  721. local _,_,classIndex = GetSelectedClass();
  722. if ( PAID_SERVICE_TYPE ) then
  723. classIndex = PaidChange_GetCurrentClassIndex();
  724. SetSelectedClass(classIndex); -- selecting a race would have changed class to default
  725. end
  726. if (id == 12) then
  727. SetCharacterClass(6)
  728. else
  729. SetCharacterClass(classIndex);
  730. end
  731.  
  732. -- Hair customization stuff
  733. CharacterCreate_UpdateHairCustomization();
  734.  
  735. CharacterChangeFixup();
  736. else
  737. self:SetChecked(1);
  738. end
  739. else
  740. self:SetChecked(0);
  741. end
  742. end
  743.  
  744. function SetCharacterGender(sex)
  745. local gender;
  746.  
  747. if ( sex == SEX_MALE or GetSelectedRace() == TUSKARR_RACE_ID ) then
  748. CharCreateMaleButton:SetChecked(1);
  749. CharCreateFemaleButton:SetChecked(0);
  750. sex = SEX_MALE
  751. else
  752. CharCreateMaleButton:SetChecked(0);
  753. CharCreateFemaleButton:SetChecked(1);
  754. end
  755. SetSelectedSex(sex);
  756.  
  757. -- Update race images to reflect gender
  758. CharacterCreateEnumerateRaces(GetAvailableRaces());
  759. CharacterCreateEnumerateClasses(GetAvailableClasses());
  760. SetCharacterRace(GetSelectedRace());
  761.  
  762. local _,_,classIndex = GetSelectedClass();
  763. if ( PAID_SERVICE_TYPE ) then
  764. classIndex = PaidChange_GetCurrentClassIndex();
  765. PandarenFactionButtons_SetTextures();
  766. end
  767. SetCharacterClass(classIndex);
  768.  
  769. CharacterCreate_UpdateHairCustomization();
  770. CharacterChangeFixup();
  771.  
  772. -- Update preview models if on customization step
  773. if ( CharCreatePreviewFrame:IsShown() ) then
  774. CharCreateCustomizationFrame_OnShow(); -- buttons may need to reset for dirty Pandarens
  775. CharCreate_PrepPreviewModels();
  776. CharCreate_ResetFeaturesDisplay();
  777. end
  778. end
  779.  
  780. function CharacterCustomization_Left(id)
  781. PlaySound("gsCharacterCreationLook");
  782. CycleCharCustomization(id, -1);
  783. end
  784.  
  785. function CharacterCustomization_Right(id)
  786. PlaySound("gsCharacterCreationLook");
  787. CycleCharCustomization(id, 1);
  788. end
  789.  
  790. function CharacterCreate_Randomize()
  791. PlaySound("gsCharacterCreationLook");
  792. RandomizeCharCustomization();
  793. CharCreate_ResetFeaturesDisplay();
  794. end
  795.  
  796. function CharacterCreateRotateRight_OnUpdate(self)
  797. if ( self:GetButtonState() == "PUSHED" ) then
  798. SetCharacterCreateFacing(GetCharacterCreateFacing() + CHARACTER_FACING_INCREMENT);
  799. CharCreate_RotatePreviews();
  800. end
  801. end
  802.  
  803. function CharacterCreateRotateLeft_OnUpdate(self)
  804. if ( self:GetButtonState() == "PUSHED" ) then
  805. SetCharacterCreateFacing(GetCharacterCreateFacing() - CHARACTER_FACING_INCREMENT);
  806. CharCreate_RotatePreviews();
  807. end
  808. end
  809.  
  810. function CharacterCreate_UpdateHairCustomization()
  811. CharCreateCustomizationButton3.text:SetText(_G["HAIR_"..GetHairCustomization().."_STYLE"]);
  812. CharCreateCustomizationButton4.text:SetText(_G["HAIR_"..GetHairCustomization().."_COLOR"]);
  813. CharCreateCustomizationButton5.text:SetText(_G["FACIAL_HAIR_"..GetFacialHairCustomization()]);
  814. end
  815.  
  816. function SetButtonDesaturated(button, desaturated)
  817. if ( not button ) then
  818. return;
  819. end
  820. local icon = button:GetNormalTexture();
  821. if ( not icon ) then
  822. return;
  823. end
  824.  
  825. icon:SetDesaturated(desaturated);
  826. end
  827.  
  828. function GetFlavorText(tagname, sex)
  829. local primary, secondary;
  830. if ( sex == SEX_MALE ) then
  831. primary = "";
  832. secondary = "_FEMALE";
  833. else
  834. primary = "_FEMALE";
  835. secondary = "";
  836. end
  837. local text = _G[tagname..primary];
  838. if ( (text == nil) or (text == "") ) then
  839. text = _G[tagname..secondary];
  840. end
  841. return text;
  842. end
  843.  
  844. function CharacterCreate_DeathKnightSwap(self)
  845. local _, classFilename = GetSelectedClass();
  846. if ( classFilename == "DEATHKNIGHT" ) then
  847. if (self.currentModel ~= "DEATHKNIGHT") then
  848. self.currentModel = "DEATHKNIGHT";
  849. self:SetNormalTexture("Interface\\Glues\\Common\\Glue-Panel-Button-Up-Blue");
  850. self:SetPushedTexture("Interface\\Glues\\Common\\Glue-Panel-Button-Down-Blue");
  851. self:SetHighlightTexture("Interface\\Glues\\Common\\Glue-Panel-Button-Highlight-Blue");
  852. end
  853. else
  854. if (self.currentModel == "DEATHKNIGHT") then
  855. self.currentModel = nil;
  856. self:SetNormalTexture("Interface\\Glues\\Common\\Glue-Panel-Button-Up");
  857. self:SetPushedTexture("Interface\\Glues\\Common\\Glue-Panel-Button-Down");
  858. self:SetHighlightTexture("Interface\\Glues\\Common\\Glue-Panel-Button-Highlight");
  859. end
  860. end
  861. end
  862.  
  863. function CharacterChangeFixup()
  864. if ( PAID_SERVICE_TYPE ) then
  865. -- no class changing as a paid service
  866. CharCreateClassFrame:SetAlpha(0.5);
  867. for i=1, MAX_CLASSES_PER_RACE, 1 do
  868. if (CharacterCreate.selectedClass ~= i) then
  869. local button = _G["CharCreateClassButton"..i];
  870. button:Disable();
  871. SetButtonDesaturated(button, true);
  872. end
  873. end
  874.  
  875. local numAllowedRaces = 0;
  876. for i=1, MAX_RACES, 1 do
  877. local allow = false;
  878. if ( PAID_SERVICE_TYPE == PAID_FACTION_CHANGE ) then
  879. --[[local faction = PaidChange_GetCurrentFaction();
  880. if ( (i == PaidChange_GetCurrentRaceIndex()) or ((GetFactionForRace(i) ~= faction) and (IsRaceClassValid(i,CharacterCreate.selectedClass))) ) then
  881. allow = true;
  882. end]]
  883. if ( i == CharacterCreate.selectedRace ) then
  884. allow = true
  885. end
  886. elseif ( PAID_SERVICE_TYPE == PAID_RACE_CHANGE ) then
  887. --[[local faction = PaidChange_GetCurrentFaction();
  888. if ( (i == PaidChange_GetCurrentRaceIndex()) or ((GetFactionForRace(i) == faction or IsNeutralRace(i)) and (IsRaceClassValid(i,CharacterCreate.selectedClass))) ) then
  889. allow = true
  890. end]]
  891. if ( i == CharacterCreate.selectedRace ) then
  892. allow = true
  893. end
  894. elseif ( PAID_SERVICE_TYPE == PAID_CHARACTER_CUSTOMIZATION ) then
  895. if ( i == CharacterCreate.selectedRace ) then
  896. allow = true
  897. end
  898. end
  899. if (not allow) then
  900. local button = _G["CharCreateRaceButton"..i];
  901. button:Disable();
  902. SetButtonDesaturated(button, true);
  903. else
  904. numAllowedRaces = numAllowedRaces + 1;
  905. end
  906. end
  907. if ( numAllowedRaces > 1 ) then
  908. CharCreateRaceButtonsFrame:SetAlpha(1);
  909. else
  910. CharCreateRaceButtonsFrame:SetAlpha(0.5);
  911. end
  912. else
  913. CharCreateRaceButtonsFrame:SetAlpha(1);
  914. CharCreateClassFrame:SetAlpha(1);
  915. end
  916. end
  917.  
  918. function CharCreateSelectCustomizationType(newType)
  919. -- deselect previous type selection
  920. if ( CharacterCreateFrame.customizationType and CharacterCreateFrame.customizationType ~= newType ) then
  921. --_G["CharCreateCustomizationButton"..CharacterCreateFrame.customizationType]:SetChecked(0);
  922. end
  923. --_G["CharCreateCustomizationButton"..newType]:SetChecked(1);
  924. CharacterCreateFrame.customizationType = newType;
  925. CharCreate_ResetFeaturesDisplay();
  926.  
  927. --[[if (newType > 1) then
  928. SetFaceCustomizeCamera(true);
  929. else
  930. SetFaceCustomizeCamera(false);
  931. end]]
  932. end
  933.  
  934. function CharCreate_ResetFeaturesDisplay()
  935. --SetPreviewFramesFeature(CharacterCreateFrame.customizationType);
  936. -- set the previews scrollframe container height
  937. -- since the first and the last previews need to be in the center position when scrolled all the way
  938. -- to the top or to the bottom, there will be gaps of height equal to 2 previews on each side
  939. local numTotalButtons = 4--GetNumFeatureVariations() + 4;
  940. CharCreatePreviewFrame.scrollFrame.container:SetHeight(numTotalButtons * PREVIEW_FRAME_HEIGHT - PREVIEW_FRAME_Y_OFFSET);
  941.  
  942. for _, previewFrame in pairs(CharCreatePreviewFrame.previews) do
  943. previewFrame.featureType = 0;
  944. end
  945.  
  946. CharCreate_DisplayPreviewModels();
  947. end
  948.  
  949. function CharCreate_PrepPreviewModels(reloadModels)
  950. local displayFrame = CharCreatePreviewFrame;
  951.  
  952. -- clear models if rebuildPreviews got flagged
  953. local rebuildPreviews = displayFrame.rebuildPreviews;
  954. displayFrame.rebuildPreviews = nil;
  955.  
  956. -- need to reload models class was swapped to or from DK
  957. local classSwap = false;
  958. local _, class = GetSelectedClass();
  959. if ( class == "DEATHKNIGHT" or displayFrame.lastClass == "DEATHKNIGHT" ) and ( class ~= displayFrame.lastClass ) then
  960. classSwap = true;
  961. end
  962.  
  963. -- always clear the featureType
  964. for index, previewFrame in pairs(displayFrame.previews) do
  965. previewFrame.featureType = 0;
  966. -- force model reload if class changed
  967. if ( classSwap ) then
  968. previewFrame.race = nil;
  969. previewFrame.gender = nil;
  970. end
  971. if ( rebuildPreviews ) then
  972. --SetPreviewFrame(previewFrame.model:GetName(), index);
  973. end
  974. end
  975. end
  976.  
  977. function CharCreate_DisplayPreviewModels(selectionIndex)
  978. if ( not selectionIndex ) then
  979. selectionIndex = featureIndex--GetSelectedFeatureVariation();
  980. end
  981.  
  982. local displayFrame = CharCreatePreviewFrame;
  983. local previews = displayFrame.previews;
  984. local numVariations = 8--GetNumFeatureVariations();
  985. local currentFeatureType = CharacterCreateFrame.customizationType;
  986.  
  987. local race = GetSelectedRace();
  988. local gender = GetSelectedSex();
  989.  
  990. -- get data for target/camera/light
  991. local _, raceFileName = GetNameForRace();
  992. --[[if ( IsViewingAlteredForm() ) then
  993. raceFileName = raceFileName.."Alt";
  994. end]]
  995. local config = MODEL_CAMERA_CONFIG[gender][raceFileName];
  996.  
  997. -- selection index is the center preview
  998. -- there are 2 previews above and 2 below, and will pad it out to 1 more on each side, for a total of 7 previews to set up
  999. for index = selectionIndex - 3, selectionIndex + 3 do
  1000. -- there is empty space both at the beginning and at end of the list, each gap the height of 2 previews
  1001. if ( index > 0 and index <= numVariations ) then
  1002. local previewFrame = previews[index];
  1003. -- create button if we don't have it yet
  1004. if ( not previewFrame ) then
  1005. previewFrame = CreateFrame("BUTTON", "PreviewFrame"..index, displayFrame.scrollFrame.container, "CharCreatePreviewFrameTemplate");
  1006. -- index + 1 because of 2 gaps at the top and -1 for the current preview
  1007. previewFrame:SetPoint("TOPLEFT", PREVIEW_FRAME_X_OFFSET, (index + 1) * -PREVIEW_FRAME_HEIGHT + PREVIEW_FRAME_Y_OFFSET);
  1008. previewFrame.button.index = index;
  1009. previews[index] = previewFrame;
  1010. --SetPreviewFrame(previewFrame.model:GetName(), index);
  1011. -- no texture as of yet
  1012. --previewFrame:SetNormalTexture("Interface\\Glues\\CharacterCreate\\UI-CharacterCreate-Classes")
  1013. end
  1014. -- load model if needed, may have been cleared by different race/gender selection
  1015. if ( previewFrame.race ~= race or previewFrame.gender ~= gender ) then
  1016. --SetPreviewFrameModel(index);
  1017. previewFrame.race = race;
  1018. previewFrame.gender = gender;
  1019. -- apply settings
  1020. local model = previewFrame.model;
  1021. --model:SetCustomCamera(cameraID);
  1022. local scale = 1--model:GetWorldScale();
  1023. --model:SetCameraTarget(config.tx * scale, config.ty * scale, config.tz * scale);
  1024. --model:SetCameraDistance(config.distance * scale);
  1025. local cx, cy, cz = model:GetPosition()
  1026. --model:SetCameraPosition(cx, cy, config.cz * scale);
  1027. model:SetLight(1, 0, 0, 0, 0, config.light, 1.0, 1.0, 1.0);
  1028. end
  1029. -- need to reset the model if it was last used to preview a different feature
  1030. if ( previewFrame.featureType ~= currentFeatureType ) then
  1031. --ResetPreviewFrameModel(index);
  1032. --ShowPreviewFrameVariation(index);
  1033. previewFrame.featureType = currentFeatureType;
  1034. end
  1035. previewFrame:Show();
  1036. else
  1037. -- need to hide tail previews when going to features with fewer styles
  1038. if ( previews[index] ) then
  1039. previews[index]:Hide();
  1040. end
  1041. end
  1042. end
  1043. displayFrame.border.number:SetText("Option "..selectionIndex.." ");
  1044. displayFrame.selectionIndex = selectionIndex;
  1045. CharCreate_RotatePreviews();
  1046. CharCreatePreviewFrame_UpdateStyleButtons();
  1047. -- scroll to center the selection
  1048. if ( not displayFrame.animating ) then
  1049. displayFrame.scrollFrame:SetVerticalScroll((selectionIndex - 1) * PREVIEW_FRAME_HEIGHT);
  1050. end
  1051. end
  1052.  
  1053.  
  1054. function CharCreate_RotatePreviews()
  1055. if ( CharCreatePreviewFrame:IsShown() ) then
  1056. local facing = ((GetCharacterCreateFacing())/ -180) * math.pi;
  1057. local previews = CharCreatePreviewFrame.previews;
  1058. --CharCreatePreviewFrame.selectionIndex = 0;
  1059. for index = CharCreatePreviewFrame.selectionIndex - 3, CharCreatePreviewFrame.selectionIndex + 3 do
  1060. local previewFrame = previews[index];
  1061. if ( previewFrame ) then -- and previewFrame.model:HasCustomCamera()
  1062. --previewFrame.model:SetCameraFacing(facing);
  1063. end
  1064. end
  1065. end
  1066. end
  1067.  
  1068. function CharCreate_ChangeFeatureVariation(delta)
  1069. local numVariations = 8--GetNumFeatureVariations();
  1070. local startIndex = featureIndex--GetSelectedFeatureVariation();
  1071. local endIndex = startIndex + delta;
  1072. if ( endIndex < 1 or endIndex > numVariations ) then
  1073. return;
  1074. end
  1075. PlaySound("gsCharacterCreationClass");
  1076. featureIndex = endIndex
  1077. CharCreatePreviewFrame_SelectFeatureVariation(endIndex);
  1078. end
  1079.  
  1080. function CharCreatePreviewFrameButton_OnClick(self)
  1081. PlaySound("gsCharacterCreationClass");
  1082. CharCreatePreviewFrame_SelectFeatureVariation(self.index);
  1083. end
  1084.  
  1085. function CharCreatePreviewFrame_SelectFeatureVariation(endIndex)
  1086. local self = CharCreatePreviewFrame;
  1087. if ( self.animating ) then
  1088. if ( not self.queuedIndex ) then
  1089. self.queuedIndex = endIndex;
  1090. end
  1091. else
  1092. local startIndex = featureIndex--GetSelectedFeatureVariation();
  1093. --SelectFeatureVariation(endIndex);
  1094. for i=1,endIndex do
  1095. CycleCharCustomization(FeatureType, 1);
  1096. end
  1097. CharCreatePreviewFrame_UpdateStyleButtons();
  1098. featureIndex = endIndex
  1099. CharCreatePreviewFrame_StartAnimating(startIndex, endIndex);
  1100. end
  1101. end
  1102.  
  1103. function CharCreatePreviewFrame_StartAnimating(startIndex, endIndex)
  1104. local self = CharCreatePreviewFrame;
  1105. if ( self.animating ) then
  1106. return;
  1107. else
  1108. self.startIndex = startIndex;
  1109. self.currentIndex = startIndex;
  1110. self.endIndex = endIndex;
  1111. self.queuedIndex = nil;
  1112. self.direction = 1;
  1113. if ( self.startIndex > self.endIndex ) then
  1114. self.direction = -1;
  1115. end
  1116. self.movedTotal = 0;
  1117. self.moveUntilUpdate = PREVIEW_FRAME_HEIGHT;
  1118. self.animating = true;
  1119. end
  1120. end
  1121.  
  1122. function CharCreatePreviewFrame_StopAnimating()
  1123. local self = CharCreatePreviewFrame;
  1124. if ( self.animating ) then
  1125. self.animating = false;
  1126. end
  1127. end
  1128.  
  1129. local ANIMATION_SPEED = 5;
  1130. function CharCreatePreviewFrame_OnUpdate(self, elapsed)
  1131. if ( self.animating ) then
  1132. local moveIncrement = PREVIEW_FRAME_HEIGHT * elapsed * ANIMATION_SPEED;
  1133. self.movedTotal = self.movedTotal + moveIncrement;
  1134. self.scrollFrame:SetVerticalScroll((self.startIndex - 1) * PREVIEW_FRAME_HEIGHT + self.movedTotal * self.direction);
  1135. self.moveUntilUpdate = self.moveUntilUpdate - moveIncrement;
  1136. if ( self.moveUntilUpdate <= 0 ) then
  1137. self.currentIndex = self.currentIndex + self.direction;
  1138. self.moveUntilUpdate = PREVIEW_FRAME_HEIGHT;
  1139. -- reset movedTotal to account for rounding errors
  1140. self.movedTotal = abs(self.startIndex - self.currentIndex) * PREVIEW_FRAME_HEIGHT;
  1141. CharCreate_DisplayPreviewModels(self.currentIndex);
  1142. end
  1143. if ( self.currentIndex == self.endIndex ) then
  1144. self.animating = false;
  1145. CharCreate_DisplayPreviewModels();
  1146. if ( self.queuedIndex ) then
  1147. local newIndex = self.queuedIndex;
  1148. self.queuedIndex = nil;
  1149. --SelectFeatureVariation(newIndex);
  1150. featureIndex = newIndex
  1151. CycleCharCustomization(FeatureType, featureIndex);
  1152. CharCreatePreviewFrame_UpdateStyleButtons();
  1153. CharCreatePreviewFrame_StartAnimating(self.endIndex, newIndex);
  1154. end
  1155. end
  1156. end
  1157. end
  1158.  
  1159. function CharCreatePreviewFrame_UpdateStyleButtons()
  1160. local selectionIndex = math.random(1,5)--GetSelectedFeatureVariation();
  1161. local numVariations = 8--GetNumFeatureVariations();
  1162. if ( selectionIndex == 1 ) then
  1163. CharCreateStyleUpButton:Enable();
  1164. CharCreateStyleUpButton.arrow:SetDesaturated(true);
  1165. else
  1166. CharCreateStyleUpButton:Enable();
  1167. CharCreateStyleUpButton.arrow:SetDesaturated(false);
  1168. end
  1169. if ( selectionIndex == numVariations ) then
  1170. CharCreateStyleDownButton:Disable();
  1171. CharCreateStyleDownButton.arrow:SetDesaturated(true);
  1172. else
  1173. CharCreateStyleDownButton:Disable(true);
  1174. CharCreateStyleDownButton.arrow:SetDesaturated(false);
  1175. end
  1176. end
  1177.  
  1178. local TotalTime = 0;
  1179. local KeepScrolling = nil;
  1180. local TIME_TO_SCROLL = 0.5;
  1181. function CharacterCreateWhileMouseDown_OnMouseDown(direction)
  1182. TIME_TO_SCROLL = 0.5;
  1183. TotalTime = 0;
  1184. KeepScrolling = direction;
  1185. end
  1186. function CharacterCreateWhileMouseDown_OnMouseUp()
  1187. KeepScrolling = nil;
  1188. end
  1189. function CharacterCreateWhileMouseDown_Update(elapsed)
  1190. if ( KeepScrolling ) then
  1191. TotalTime = TotalTime + elapsed;
  1192. if ( TotalTime >= TIME_TO_SCROLL ) then
  1193. CharCreate_ChangeFeatureVariation(KeepScrolling);
  1194. TIME_TO_SCROLL = 0.25;
  1195. TotalTime = 0;
  1196. end
  1197. end
  1198. end
  1199.  
  1200. -- pandaren stuff related to faction change
  1201. function CharCreate_EnableNextButton(enabled)
  1202. local button = CharCreateOkayButton;
  1203. if enabled then
  1204. button:Enable();
  1205. else
  1206. button:Disable();
  1207. end
  1208. button.Arrow:SetDesaturated(not enabled);
  1209. if enabled then
  1210. button.TopGlow:Hide();
  1211. button.BottomGlow:Hide();
  1212. else
  1213. button.TopGlow:Show();
  1214. button.BottomGlow:Show();
  1215. end
  1216. end
  1217.  
  1218. function PandarenFactionButtons_OnLoad(self)
  1219. self.PandarenButton = CharCreateRaceButton6;
  1220. end
  1221.  
  1222. function PandarenFactionButtons_Show()
  1223. local frame = CharCreatePandarenFactionFrame;
  1224. -- set the name
  1225. local raceName = GetNameForRace();
  1226. frame.AllianceButton.nameFrame.text:SetText(raceName);
  1227. frame.AllianceButton.tooltip = raceName;
  1228. frame.HordeButton.nameFrame.text:SetText(raceName);
  1229. frame.HordeButton.tooltip = raceName;
  1230. -- set the texture
  1231. PandarenFactionButtons_SetTextures();
  1232. -- set selected button
  1233. local faction = PaidChange_GetCurrentFaction();
  1234. -- deselect first in case of multiple pandaren faction changes
  1235. PandarenFactionButtons_ClearSelection();
  1236. frame[faction.."Button"]:SetChecked(1);
  1237. -- show the frame on top of the normal pandaren button
  1238. frame:Show();
  1239. frame:SetFrameLevel(frame.PandarenButton:GetFrameLevel() + 2);
  1240. CharCreate_EnableNextButton(false);
  1241. end
  1242.  
  1243. function PandarenFactionButtons_Hide()
  1244. CharCreatePandarenFactionFrame:Hide();
  1245. CharCreate_EnableNextButton(true);
  1246. end
  1247.  
  1248. function PandarenFactionButtons_SetTextures()
  1249. local gender = "MALE";
  1250. local coords = RACE_ICON_TCOORDS["TUSKARR_"..gender];
  1251. CharCreatePandarenFactionFrameAllianceButtonNormalTexture:SetTexCoord(coords[1], coords[2], coords[3], coords[4]);
  1252. CharCreatePandarenFactionFrameAllianceButtonPushedTexture:SetTexCoord(coords[1], coords[2], coords[3], coords[4]);
  1253. CharCreatePandarenFactionFrameHordeButtonNormalTexture:SetTexCoord(coords[1], coords[2], coords[3], coords[4]);
  1254. CharCreatePandarenFactionFrameHordeButtonPushedTexture:SetTexCoord(coords[1], coords[2], coords[3], coords[4]);
  1255. end
  1256.  
  1257. function PandarenFactionButtons_ClearSelection()
  1258. CharCreatePandarenFactionFrame.AllianceButton:SetChecked(0);
  1259. CharCreatePandarenFactionFrame.HordeButton:SetChecked(0);
  1260. end
  1261.  
  1262. function PandarenFactionButtons_GetSelectedFaction()
  1263. if ( CharCreatePandarenFactionFrame.AllianceButton:GetChecked() ) then
  1264. return "Alliance";
  1265. elseif ( CharCreatePandarenFactionFrame.HordeButton:GetChecked() ) then
  1266. return "Horde";
  1267. end
  1268. end
  1269.  
  1270. function PandarenFactionButton_OnClick(self)
  1271. PandarenFactionButtons_ClearSelection();
  1272. self:SetChecked(1);
  1273. CharacterRace_OnClick(CharCreatePandarenFactionFrame.PandarenButton, CharCreatePandarenFactionFrame.PandarenButton:GetID(), true);
  1274. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement