SHOW:
|
|
- or go back to the newest paste.
| 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 | GlueDialog_Show("ACCOUNT_MSG", "Selected : "..i+1.." Gender: "..gender);
| |
| 204 | GlueDialog_Show("ACCOUNT_MSG", "Selected : "..strupper(select(i+1, ...).."_"..gender));
| |
| 205 | _G["CharacterCreateRaceButton"..index.."NormalTexture"]:SetTexCoord(coords[1], coords[2], coords[3], coords[4]); | |
| 206 | _G["CharacterCreateRaceButton"..index.."PushedTexture"]:SetTexCoord(coords[1], coords[2], coords[3], coords[4]); | |
| 207 | button = _G["CharacterCreateRaceButton"..index]; | |
| 208 | button:Show(); | |
| 209 | if ( select(i+2, ...) == 1 ) then | |
| 210 | button.enable = true; | |
| 211 | SetButtonDesaturated(button); | |
| 212 | button.name = select(i, ...); | |
| 213 | button.tooltip = select(i, ...); | |
| 214 | else | |
| 215 | button.enable = false; | |
| 216 | SetButtonDesaturated(button, 1); | |
| 217 | button.name = select(i, ...); | |
| 218 | button.tooltip = _G[strupper(select(i+1, ...).."_".."DISABLED")]; | |
| 219 | end | |
| 220 | index = index + 1; | |
| 221 | end | |
| 222 | for i=CharacterCreate.numRaces + 1, MAX_RACES, 1 do | |
| 223 | _G["CharacterCreateRaceButton"..i]:Hide(); | |
| 224 | end | |
| 225 | end | |
| 226 | ||
| 227 | function CharacterCreateEnumerateClasses(...) | |
| 228 | CharacterCreate.numClasses = select("#", ...)/3;
| |
| 229 | if ( CharacterCreate.numClasses > MAX_CLASSES_PER_RACE ) then | |
| 230 | message("Too many classes! Update MAX_CLASSES_PER_RACE");
| |
| 231 | return; | |
| 232 | end | |
| 233 | local coords; | |
| 234 | local index = 1; | |
| 235 | local button; | |
| 236 | for i=1, select("#", ...), 3 do
| |
| 237 | coords = CLASS_ICON_TCOORDS[strupper(select(i+1, ...))]; | |
| 238 | _G["CharacterCreateClassButton"..index.."NormalTexture"]:SetTexCoord(coords[1], coords[2], coords[3], coords[4]); | |
| 239 | _G["CharacterCreateClassButton"..index.."PushedTexture"]:SetTexCoord(coords[1], coords[2], coords[3], coords[4]); | |
| 240 | button = _G["CharacterCreateClassButton"..index]; | |
| 241 | button:Show(); | |
| 242 | if ( (select(i+2, ...) == 1) and (IsRaceClassValid(CharacterCreate.selectedRace, index)) ) then | |
| 243 | button.enable = true; | |
| 244 | button:Enable(); | |
| 245 | SetButtonDesaturated(button); | |
| 246 | button.name = select(i, ...) | |
| 247 | button.tooltip = select(i, ...); | |
| 248 | _G["CharacterCreateClassButton"..index.."DisableTexture"]:Hide(); | |
| 249 | else | |
| 250 | button.enable = false; | |
| 251 | button:Disable(); | |
| 252 | SetButtonDesaturated(button, 1); | |
| 253 | button.name = select(i, ...) | |
| 254 | button.tooltip = _G[strupper(select(i+1, ...).."_".."DISABLED")]; | |
| 255 | _G["CharacterCreateClassButton"..index.."DisableTexture"]:Show(); | |
| 256 | end | |
| 257 | index = index + 1; | |
| 258 | end | |
| 259 | for i=CharacterCreate.numClasses + 1, MAX_CLASSES_PER_RACE, 1 do | |
| 260 | _G["CharacterCreateClassButton"..i]:Hide(); | |
| 261 | end | |
| 262 | end | |
| 263 | ||
| 264 | function SetCharacterRace(id) | |
| 265 | CharacterCreate.selectedRace = id; | |
| 266 | local selectedButton; | |
| 267 | for i=1, CharacterCreate.numRaces, 1 do | |
| 268 | local button = _G["CharacterCreateRaceButton"..i]; | |
| 269 | if ( i == id ) then | |
| 270 | _G["CharacterCreateRaceButton"..i.."Text"]:SetText(button.name); | |
| 271 | button:SetChecked(1); | |
| 272 | selectedButton = button; | |
| 273 | else | |
| 274 | _G["CharacterCreateRaceButton"..i.."Text"]:SetText("");
| |
| 275 | button:SetChecked(0); | |
| 276 | end | |
| 277 | end | |
| 278 | ||
| 279 | -- Set Faction | |
| 280 | local name, faction = GetFactionForRace(CharacterCreate.selectedRace); | |
| 281 | ||
| 282 | -- Set Race | |
| 283 | local race, fileString = GetNameForRace(); | |
| 284 | ||
| 285 | CharacterCreateRaceLabel:SetText(race); | |
| 286 | fileString = strupper(fileString); | |
| 287 | if ( GetSelectedSex() == SEX_MALE ) then | |
| 288 | gender = "MALE"; | |
| 289 | else | |
| 290 | gender = "FEMALE"; | |
| 291 | end | |
| 292 | local coords = RACE_ICON_TCOORDS[fileString.."_"..gender]; | |
| 293 | CharacterCreateRaceIcon:SetTexCoord(coords[1], coords[2], coords[3], coords[4]); | |
| 294 | local raceText = _G["RACE_INFO_"..fileString]; | |
| 295 | local abilityIndex = 1; | |
| 296 | local tempText = _G["ABILITY_INFO_"..fileString..abilityIndex]; | |
| 297 | abilityText = ""; | |
| 298 | while ( tempText ) do | |
| 299 | abilityText = abilityText..tempText.."\n\n"; | |
| 300 | abilityIndex = abilityIndex + 1; | |
| 301 | tempText = _G["ABILITY_INFO_"..fileString..abilityIndex]; | |
| 302 | end | |
| 303 | ||
| 304 | CharacterCreateRaceScrollFrameScrollBar:SetValue(0); | |
| 305 | CharacterCreateRaceText:SetText(GetFlavorText("RACE_INFO_"..strupper(fileString), GetSelectedSex()).."|n|n");
| |
| 306 | if ( abilityText and abilityText ~= "" ) then | |
| 307 | CharacterCreateRaceAbilityText:SetText(abilityText); | |
| 308 | else | |
| 309 | CharacterCreateRaceAbilityText:SetText("");
| |
| 310 | end | |
| 311 | ||
| 312 | -- Set backdrop colors based on faction | |
| 313 | local backdropColor = FACTION_BACKDROP_COLOR_TABLE[faction]; | |
| 314 | local frame; | |
| 315 | for index, value in pairs(FRAMES_TO_BACKDROP_COLOR) do | |
| 316 | frame = _G[value]; | |
| 317 | frame:SetBackdropColor(backdropColor[4], backdropColor[5], backdropColor[6]); | |
| 318 | end | |
| 319 | CharacterCreateConfigurationBackground:SetVertexColor(backdropColor[4], backdropColor[5], backdropColor[6]); | |
| 320 | ||
| 321 | local backgroundFilename = GetCreateBackgroundModel(); | |
| 322 | SetBackgroundModel(CharacterCreate, backgroundFilename); | |
| 323 | end | |
| 324 | ||
| 325 | function SetCharacterClass(id) | |
| 326 | CharacterCreate.selectedClass = id; | |
| 327 | for i=1, CharacterCreate.numClasses, 1 do | |
| 328 | local button = _G["CharacterCreateClassButton"..i]; | |
| 329 | if ( i == id ) then | |
| 330 | CharacterCreateClassName:SetText(button.name); | |
| 331 | button:SetChecked(1); | |
| 332 | else | |
| 333 | button:SetChecked(0); | |
| 334 | end | |
| 335 | end | |
| 336 | ||
| 337 | local className, classFileName, _, tank, healer, damage = GetSelectedClass(); | |
| 338 | local abilityIndex = 0; | |
| 339 | local tempText = _G["CLASS_INFO_"..classFileName..abilityIndex]; | |
| 340 | abilityText = ""; | |
| 341 | while ( tempText ) do | |
| 342 | abilityText = abilityText..tempText.."\n\n"; | |
| 343 | abilityIndex = abilityIndex + 1; | |
| 344 | tempText = _G["CLASS_INFO_"..classFileName..abilityIndex]; | |
| 345 | end | |
| 346 | local coords = CLASS_ICON_TCOORDS[classFileName]; | |
| 347 | CharacterCreateClassIcon:SetTexCoord(coords[1], coords[2], coords[3], coords[4]); | |
| 348 | CharacterCreateClassLabel:SetText(className); | |
| 349 | CharacterCreateClassRolesText:SetText(abilityText); | |
| 350 | CharacterCreateClassText:SetText(GetFlavorText("CLASS_"..strupper(classFileName), GetSelectedSex()).."|n|n");
| |
| 351 | CharacterCreateClassScrollFrameScrollBar:SetValue(0); | |
| 352 | end | |
| 353 | ||
| 354 | function CharacterCreate_OnChar() | |
| 355 | end | |
| 356 | ||
| 357 | function CharacterCreate_OnKeyDown(key) | |
| 358 | if ( key == "ESCAPE" ) then | |
| 359 | CharacterCreate_Back(); | |
| 360 | elseif ( key == "ENTER" ) then | |
| 361 | CharacterCreate_Okay(); | |
| 362 | elseif ( key == "PRINTSCREEN" ) then | |
| 363 | Screenshot(); | |
| 364 | end | |
| 365 | end | |
| 366 | ||
| 367 | function CharacterCreate_UpdateModel(self) | |
| 368 | UpdateCustomizationScene(); | |
| 369 | self:AdvanceTime(); | |
| 370 | end | |
| 371 | ||
| 372 | function CharacterCreate_Okay() | |
| 373 | if ( PAID_SERVICE_TYPE ) then | |
| 374 | GlueDialog_Show("CONFIRM_PAID_SERVICE");
| |
| 375 | else | |
| 376 | CreateCharacter(CharacterCreateNameEdit:GetText()); | |
| 377 | end | |
| 378 | PlaySound("gsCharacterCreationCreateChar");
| |
| 379 | end | |
| 380 | ||
| 381 | function CharacterCreate_Back() | |
| 382 | PlaySound("gsCharacterCreationCancel");
| |
| 383 | SetGlueScreen("charselect");
| |
| 384 | end | |
| 385 | ||
| 386 | function CharacterClass_OnClick(id) | |
| 387 | PlaySound("gsCharacterCreationClass");
| |
| 388 | local _,_,currClass = GetSelectedClass(); | |
| 389 | if ( currClass ~= id and IsRaceClassValid(GetSelectedRace(), id) ) then | |
| 390 | SetSelectedClass(id); | |
| 391 | SetCharacterClass(id); | |
| 392 | SetCharacterRace(GetSelectedRace()); | |
| 393 | CharacterChangeFixup(); | |
| 394 | end | |
| 395 | end | |
| 396 | ||
| 397 | function CharacterRace_OnClick(self, id) | |
| 398 | PlaySound("gsCharacterCreationClass");
| |
| 399 | if ( not self:GetChecked() ) then | |
| 400 | self:SetChecked(1); | |
| 401 | return; | |
| 402 | end | |
| 403 | if ( GetSelectedRace() ~= id ) then | |
| 404 | SetSelectedRace(id); | |
| 405 | SetCharacterRace(id); | |
| 406 | SetSelectedSex(GetSelectedSex()); | |
| 407 | SetCharacterCreateFacing(-15); | |
| 408 | CharacterCreateEnumerateClasses(GetAvailableClasses()); | |
| 409 | local _,_,classIndex = GetSelectedClass(); | |
| 410 | if ( PAID_SERVICE_TYPE ) then | |
| 411 | classIndex = PaidChange_GetCurrentClassIndex(); | |
| 412 | end | |
| 413 | SetCharacterClass(classIndex); | |
| 414 | ||
| 415 | -- Hair customization stuff | |
| 416 | CharacterCreate_UpdateHairCustomization(); | |
| 417 | ||
| 418 | CharacterChangeFixup(); | |
| 419 | end | |
| 420 | end | |
| 421 | ||
| 422 | function SetCharacterGender(sex) | |
| 423 | local gender; | |
| 424 | SetSelectedSex(sex); | |
| 425 | if ( sex == SEX_MALE ) then | |
| 426 | gender = "MALE"; | |
| 427 | CharacterCreateGender:SetText(MALE); | |
| 428 | CharacterCreateGenderButtonMale:SetChecked(1); | |
| 429 | CharacterCreateGenderButtonFemale:SetChecked(nil); | |
| 430 | elseif ( sex == SEX_FEMALE ) then | |
| 431 | gender = "FEMALE"; | |
| 432 | CharacterCreateGender:SetText(FEMALE); | |
| 433 | CharacterCreateGenderButtonMale:SetChecked(nil); | |
| 434 | CharacterCreateGenderButtonFemale:SetChecked(1); | |
| 435 | end | |
| 436 | ||
| 437 | -- Update race images to reflect gender | |
| 438 | CharacterCreateEnumerateRaces(GetAvailableRaces()); | |
| 439 | CharacterCreateEnumerateClasses(GetAvailableClasses()); | |
| 440 | SetCharacterRace(GetSelectedRace()); | |
| 441 | ||
| 442 | local _,_,classIndex = GetSelectedClass(); | |
| 443 | if ( PAID_SERVICE_TYPE ) then | |
| 444 | classIndex = PaidChange_GetCurrentClassIndex(); | |
| 445 | end | |
| 446 | SetCharacterClass(classIndex); | |
| 447 | ||
| 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 | CharacterChangeFixup(); | |
| 459 | end | |
| 460 | ||
| 461 | function CharacterCustomization_Left(id) | |
| 462 | PlaySound("gsCharacterCreationLook");
| |
| 463 | CycleCharCustomization(id, -1); | |
| 464 | end | |
| 465 | ||
| 466 | function CharacterCustomization_Right(id) | |
| 467 | PlaySound("gsCharacterCreationLook");
| |
| 468 | CycleCharCustomization(id, 1); | |
| 469 | end | |
| 470 | ||
| 471 | function CharacterCreate_Randomize() | |
| 472 | PlaySound("gsCharacterCreationLook");
| |
| 473 | RandomizeCharCustomization(); | |
| 474 | end | |
| 475 | ||
| 476 | function CharacterCreateRotateRight_OnUpdate(self) | |
| 477 | if ( self:GetButtonState() == "PUSHED" ) then | |
| 478 | SetCharacterCreateFacing(GetCharacterCreateFacing() + CHARACTER_FACING_INCREMENT); | |
| 479 | end | |
| 480 | end | |
| 481 | ||
| 482 | function CharacterCreateRotateLeft_OnUpdate(self) | |
| 483 | if ( self:GetButtonState() == "PUSHED" ) then | |
| 484 | SetCharacterCreateFacing(GetCharacterCreateFacing() - CHARACTER_FACING_INCREMENT); | |
| 485 | end | |
| 486 | end | |
| 487 | ||
| 488 | function CharacterCreate_UpdateHairCustomization() | |
| 489 | CharacterCustomizationButtonFrame3Text:SetText(_G["HAIR_"..GetHairCustomization().."_STYLE"]); | |
| 490 | CharacterCustomizationButtonFrame4Text:SetText(_G["HAIR_"..GetHairCustomization().."_COLOR"]); | |
| 491 | CharacterCustomizationButtonFrame5Text:SetText(_G["FACIAL_HAIR_"..GetFacialHairCustomization()]); | |
| 492 | end | |
| 493 | ||
| 494 | function SetButtonDesaturated(button, desaturated, r, g, b) | |
| 495 | if ( not button ) then | |
| 496 | return; | |
| 497 | end | |
| 498 | local icon = button:GetNormalTexture(); | |
| 499 | if ( not icon ) then | |
| 500 | return; | |
| 501 | end | |
| 502 | local shaderSupported = icon:SetDesaturated(desaturated); | |
| 503 | ||
| 504 | if ( not desaturated ) then | |
| 505 | r = 1.0; | |
| 506 | g = 1.0; | |
| 507 | b = 1.0; | |
| 508 | elseif ( not r or not shaderSupported ) then | |
| 509 | r = 0.5; | |
| 510 | g = 0.5; | |
| 511 | b = 0.5; | |
| 512 | end | |
| 513 | ||
| 514 | icon:SetVertexColor(r, g, b); | |
| 515 | end | |
| 516 | ||
| 517 | function GetFlavorText(tagname, sex) | |
| 518 | local primary, secondary; | |
| 519 | if ( sex == SEX_MALE ) then | |
| 520 | primary = ""; | |
| 521 | secondary = "_FEMALE"; | |
| 522 | else | |
| 523 | primary = "_FEMALE"; | |
| 524 | secondary = ""; | |
| 525 | end | |
| 526 | local text = _G[tagname..primary]; | |
| 527 | if ( (text == nil) or (text == "") ) then | |
| 528 | text = _G[tagname..secondary]; | |
| 529 | end | |
| 530 | return text; | |
| 531 | end | |
| 532 | ||
| 533 | function CharacterCreate_DeathKnightSwap(self) | |
| 534 | local _, classFilename = GetSelectedClass(); | |
| 535 | if ( classFilename == "DEATHKNIGHT" ) then | |
| 536 | if (self.currentModel ~= "DEATHKNIGHT") then | |
| 537 | self.currentModel = "DEATHKNIGHT"; | |
| 538 | self:SetNormalTexture("Interface\\Glues\\Common\\Glue-Panel-Button-Up-Blue");
| |
| 539 | self:SetPushedTexture("Interface\\Glues\\Common\\Glue-Panel-Button-Down-Blue");
| |
| 540 | self:SetHighlightTexture("Interface\\Glues\\Common\\Glue-Panel-Button-Highlight-Blue");
| |
| 541 | end | |
| 542 | else | |
| 543 | if (self.currentModel == "DEATHKNIGHT") then | |
| 544 | self.currentModel = nil; | |
| 545 | self:SetNormalTexture("Interface\\Glues\\Common\\Glue-Panel-Button-Up");
| |
| 546 | self:SetPushedTexture("Interface\\Glues\\Common\\Glue-Panel-Button-Down");
| |
| 547 | self:SetHighlightTexture("Interface\\Glues\\Common\\Glue-Panel-Button-Highlight");
| |
| 548 | end | |
| 549 | end | |
| 550 | end | |
| 551 | ||
| 552 | function CharacterChangeFixup() | |
| 553 | if ( PAID_SERVICE_TYPE ) then | |
| 554 | for i=1, MAX_CLASSES_PER_RACE, 1 do | |
| 555 | if (CharacterCreate.selectedClass ~= i) then | |
| 556 | local button = _G["CharacterCreateClassButton"..i]; | |
| 557 | button:Disable(); | |
| 558 | SetButtonDesaturated(button, true) | |
| 559 | end | |
| 560 | end | |
| 561 | ||
| 562 | for i=1, MAX_RACES, 1 do | |
| 563 | local allow = false; | |
| 564 | if ( PAID_SERVICE_TYPE == PAID_FACTION_CHANGE ) then | |
| 565 | local faction = GetFactionForRace(PaidChange_GetCurrentRaceIndex()); | |
| 566 | if ( (i == PaidChange_GetCurrentRaceIndex()) or ((GetFactionForRace(i) ~= faction) and (IsRaceClassValid(i,CharacterCreate.selectedClass))) ) then | |
| 567 | allow = true; | |
| 568 | end | |
| 569 | elseif ( PAID_SERVICE_TYPE == PAID_RACE_CHANGE ) then | |
| 570 | local faction = GetFactionForRace(PaidChange_GetCurrentRaceIndex()); | |
| 571 | if ( (i == PaidChange_GetCurrentRaceIndex()) or ((GetFactionForRace(i) == faction) and (IsRaceClassValid(i,CharacterCreate.selectedClass))) ) then | |
| 572 | allow = true | |
| 573 | end | |
| 574 | elseif ( PAID_SERVICE_TYPE == PAID_CHARACTER_CUSTOMIZATION ) then | |
| 575 | if ( i == CharacterCreate.selectedRace ) then | |
| 576 | allow = true | |
| 577 | end | |
| 578 | end | |
| 579 | if (not allow) then | |
| 580 | local button = _G["CharacterCreateRaceButton"..i]; | |
| 581 | button:Disable(); | |
| 582 | SetButtonDesaturated(button, true) | |
| 583 | end | |
| 584 | end | |
| 585 | end | |
| 586 | end |