[staging_area_create_character] { interface = true; ////////////////////////////////////////////////////////////////////////////// // // Author(s): Witness (Lisa Hui) // Purpose : Alters the character selection system to hide the usage of // multiple templates used for determining the head selection. // // Versions : v2.2 [October 9, 2004] // - added a performance check in SyncTextureSelections$ to exit // immediately if there are no non-zero deltas (texture changes) // - moved constants to an #include file for easier editing/overriding // // v2.1 [September 26, 2004] // - added some DS vs DSLOA case handling to merge the interface differences // // v2.0 [August 15, 2004] // - fixed the skin desync problem caused occasional offsetting // caused by the formula for negative modulos // - optimized texture shifting count in the texture shifting function // // v1.0 [August 9, 2004] // - ported the script from single player to multiplayer selection menu // //---------------------------------------------------------------------------- // Version: 2.2 Date: October 9, 2004 //---------------------------------------------------------------------------- ////////////////////////////////////////////////////////////////////////////// skrit = [[ owner = UIWindow; //input property int shift$ = 0; //constants #include "k_inc_character" void Init$ { report.screen("character_select interface loaded"); //reset counters GameAuditor.Db.SetInt( "ui_delta_heroclth", 0 ); GameAuditor.Db.SetInt( "ui_delta_herohair", 0 ); GameAuditor.Db.SetInt( "ui_delta_heroskin", 0 ); //perform DS or DSLOA specific customizations if ( UIShell.FindUIWindow( "staging_character_dsx_import", "staging_area_select_character" ) == NULL ) { //DS //alter load character buttons to match DS format (in LOA format by default) UIWindow wnd$ = UIShell.FindUIWindow( "staging_character_import", "staging_area_create_character" ); if ( wnd$ != NULL ) { //move the ds char button wnd$.SetRect( 500, 740, 76, 92, false ); //hide the loa char button wnd$ = UIShell.FindUIWindow( "staging_character_dsx_import", "staging_area_create_character" ); wnd$.Enabled = false; wnd$.Visible = false; //change the ds char button text...English Only UIText txt$ = QueryDerivedText( UIShell.FindUIWindow( "staging_character_import_text", "staging_area_create_character" ) ); txt$.SetText( "Import From Single Player...", true ); } } } void SyncTextureSelections$( string shift_direction$, string next_direction$, UIWindow wnd$, bool end_at_start$ ) { report.screenf("character_select sync message: %s", shift_direction$); //get the accumulated deltas int delta_clth$ = GameAuditor.Db.GetInt( "ui_delta_heroclth" ); int delta_hair$ = GameAuditor.Db.GetInt( "ui_delta_herohair" ); int delta_skin$ = GameAuditor.Db.GetInt( "ui_delta_heroskin" ); int delta_zero$; //since the limits are preset, optimize deltas to result in the shortest number of shifts if ( delta_clth$ != 0 ) { int limit_mid$ = clothes$ / 2; if ( delta_clth$ > 0 ) { if ( delta_clth$ > limit_mid$ ) { //would be faster to shift in the opposite direction delta_clth$ = delta_clth$ - clothes$; } } else if ( delta_clth$ > ( 0 - limit_mid$ ) ) { //would be faster to shift in the opposite direction delta_clth$ = clothes$ + delta_clth$; } delta_zero$ = false; } else { delta_zero$ = true; } if ( delta_hair$ != 0 ) { int limit_mid$ = hairs$ / 2; if ( delta_hair$ > 0 ) { if ( delta_hair$ > limit_mid$ ) { //would be faster to shift in the opposite direction delta_hair$ = delta_hair$ - hairs$; } } else if ( delta_hair$ > ( 0 - limit_mid$ ) ) { //would be faster to shift in the opposite direction delta_hair$ = hairs$ + delta_hair$; } } else if ( delta_zero$ && ( delta_skin$ == 0 ) ) { //no synchronization necessary b/c all deltas are zero (no skin changes) //move to the next head if ( !end_at_start$ ) { int d_race$ = races$ * genders$; report.screenf("race shift: %d", d_race$); while ( d_race$ > 0 ) { Messenger.Notify( next_direction$, wnd$ ); d_race$ -= 1; } } return; } int jump$ = races$ * genders$; int d_clth$, d_hair$, d_skin$, d_race$; int count$ = 1; //( delta_clth$ == 0 && delta_hair$ == 0 && delta_skin$ == 0 ? heads$ - 1 : 1 ) while ( count$ < heads$ ) { d_race$ = jump$; report.screenf("race shift: %d", d_race$); while ( d_race$ > 0 ) { Messenger.Notify( shift_direction$, wnd$ ); d_race$ -= 1; } d_clth$ = delta_clth$; d_hair$ = delta_hair$; d_skin$ = delta_skin$; //sync clothing change if ( d_clth$ > 0 ) { while ( d_clth$ > 0 ) { Messenger.Notify( "char_next_shirt", wnd$ ); d_clth$ -= 1; } } else if ( d_clth$ < 0 ) { while ( d_clth$ < 0 ) { Messenger.Notify( "char_prev_shirt", wnd$ ); d_clth$ += 1; } } //sync hair color change if ( d_hair$ > 0 ) { while ( d_hair$ > 0 ) { Messenger.Notify( "char_next_hair", wnd$ ); d_hair$ -= 1; } } else if ( d_hair$ < 0 ) { while ( d_hair$ < 0 ) { Messenger.Notify( "char_prev_hair", wnd$ ); d_hair$ += 1; } } //sync skin color/face change if ( d_skin$ > 0 ) { while ( d_skin$ > 0 ) { Messenger.Notify( "char_next_face", wnd$ ); Messenger.Notify( "char_next_pants", wnd$ ); d_skin$ -= 1; } } else if ( d_skin$ < 0 ) { while ( d_skin$ < 0 ) { Messenger.Notify( "char_prev_face", wnd$ ); Messenger.Notify( "char_prev_pants", wnd$ ); d_skin$ += 1; } } count$ += 1; } if ( end_at_start$ ) { //next race d_race$ = 0; while ( d_race$ < races$ ) { Messenger.Notify( shift_direction$, wnd$ ); d_race$ += 1; } } //reset deltas GameAuditor.Db.SetInt( "ui_delta_heroclth", 0 ); GameAuditor.Db.SetInt( "ui_delta_herohair", 0 ); GameAuditor.Db.SetInt( "ui_delta_heroskin", 0 ); } void SyncNext$ { //flip the shift direction for shorter update path //string msg$ = ( shift$ < 0 ? "next_character" : "previous_character" ); UIWindow wnd$ = UIShell.FindUIWindow( "staging_create_character_ok", "staging_area_create_character" ); //sync selected race if ( shift$ < 0 ) { SyncTextureSelections$( "next_character", "previous_character", wnd$, true ); } else { SyncTextureSelections$( "previous_character", "next_character", wnd$, true ); } //continue to the next step Messenger.Notify( "on_change_map", wnd$ ); } void LoadRace$ { //flip the shift direction for shorter update path //string msg$ = ( shift$ < 0 ? "next_character" : "previous_character" ); UIWindow wnd$ = UIShell.FindUIWindow( "character_text", "staging_area_create_character" ); //synchronize textures with the rest of the characters in the same race if ( shift$ < 0 ) { SyncTextureSelections$( "next_character", "previous_character", wnd$, false ); Messenger.Notify( "next_character", wnd$ ); //next race } else { SyncTextureSelections$( "previous_character", "next_character", wnd$, false ); Messenger.Notify( "previous_character", wnd$ ); //next race } } void LoadHead$ { //synchronize textures with the rest of the characters in the same race //...just flip the shift direction! //- SyncTextureSelections$ ends up on the prev head when seeking forward //- SyncTextureSelections$ ends up on the next head when seeking backwards report.screenf("character_select - shift head: %d", shift$); //SyncTextureSelections$( ( shift$ < 0 ? "next_character" : "previous_character" ), // UIShell.FindUIWindow( "face_text", "staging_area_create_character" ), // false ); UIWindow wnd$ = UIShell.FindUIWindow( "face_text", "staging_area_create_character" ); if ( shift$ < 0 ) { SyncTextureSelections$( "next_character", "previous_character", wnd$, false ); } else { SyncTextureSelections$( "previous_character", "next_character", wnd$, false ); } } void ChangeSkin$ { int delta_old$ = GameAuditor.Db.GetInt( "ui_delta_heroskin" ); int delta_new$ = delta_old$ + shift$; if ( delta_new$ > 0 ) { if ( delta_new$ >= skins$ ) { delta_new$ %= skins$; } } else if ( delta_new$ < 0 ) { int skin_limit$ = 0 - skins$; while ( delta_new$ <= skin_limit$ ) { delta_new$ += skins$; } } GameAuditor.Db.SetInt( "ui_delta_heroskin", delta_new$ ); report.screenf("ChangeSkin$ - delta: %d", delta_new$); } void ChangeHair$ { int delta_old$ = GameAuditor.Db.GetInt( "ui_delta_herohair" ); int delta_new$ = delta_old$ + shift$; if ( delta_new$ > 0 ) { if ( delta_new$ >= hairs$ ) { delta_new$ %= hairs$; } } else if ( delta_new$ < 0 ) { int hairs_limit$ = 0 - hairs$; while ( delta_new$ <= hairs_limit$ ) { delta_new$ += hairs$; } } GameAuditor.Db.SetInt( "ui_delta_herohair", delta_new$ ); report.screenf("ChangeHair$ - delta: %d", delta_new$); } void ChangeClothes$ { int delta_old$ = GameAuditor.Db.GetInt( "ui_delta_heroclth" ); int delta_new$ = delta_old$ + shift$; if ( delta_new$ > 0 ) { if ( delta_new$ >= clothes$ ) { delta_new$ %= clothes$; } } else if ( delta_new$ < 0 ) { int clothes_limit$ = 0 - clothes$; while ( delta_new$ <= clothes_limit$ ) { delta_new$ += clothes$; } } GameAuditor.Db.SetInt( "ui_delta_heroclth", delta_new$ ); report.screenf("ChangeClothes$ - delta: %d", delta_new$); } ]]; [t:text,n:title] { alpha = 1.000000; common_control = false; common_template = ; draw_order = 68; font_color = -1; font_size = 12; font_type = b_gui_fnt_14p_copperplate-light; justify = left; rect = 44,76,200,92; text = "Create New Character"; texture = none; type = text; uvcoords = 0.000000,0.000000,1.000000,1.000000; wrap_mode = clamp; } [t:text,n:create_new_character_warning] { alpha = 1.000000; common_control = false; common_template = ; draw_order = 68; font_color = 0x00FF0000; font_size = 14; font_type = b_gui_fnt_12p_copperplate-light; justify = center; rect = 220,76,350,92; text = "Host requires new characters. If you want to play with an existing character, join a different game"; texture = none; type = text; uvcoords = 0.000000,0.000000,1.000000,1.000000; wrap_mode = clamp; } [t:text,n:character_name_text] { alpha = 1.000000; common_control = false; common_template = ; draw_order = 68; font_color = -1; font_size = 12; font_type = b_gui_fnt_12p_copperplate-light; justify = center; rect = 60,168,234,184; text = "Enter Hero Name"; texture = none; type = text; uvcoords = 0.000000,0.000000,1.000000,1.000000; wrap_mode = clamp; } [t:dialog_box,n:name_background] { alpha = 1.000000; common_control = true; common_template = cpbox; draw_order = 2; rect = 60,188,234,212; texture = none; uvcoords = 0.000000,0.000000,1.000000,1.000000; wrap_mode = clamp; } [t:edit_box,n:staging_char_name_edit_box] { alpha = 1.000000; clear_select = false; common_control = false; common_template = ; draw_order = 6; font_color = -1; font_size = 12; font_type = b_gui_fnt_12p_copperplate-light; max_string_size = 14; permanent_focus = false; rect = 64,192,230,208; text = ; texture = none; uvcoords = 0.000000,0.000000,1.000000,1.000000; wrap_mode = clamp; excluded_chars = [["<>:/\|?*.%;]]; max_pixels = 155; has_pixel_limit = true; [prompt] { texture=b_gui_fe_m_single_prompt; width=1; } [messages] { oneditselect = notify(staging_create_character_ok); } } [t:dialog_box,n:character_background] { alpha = 1.000000; common_control = true; common_template = cpbox; draw_order = 2; rect = 270,110,530,290; texture = none; uvcoords = 0.000000,0.000000,1.000000,1.000000; wrap_mode = clamp; } [t:listener,n:listener] { alpha = 1.000000; common_control = false; common_template = ; draw_order = 15; font_type = ; rect = 270,110,530,290; text = ; texture = none; uvcoords = 0.000000,0.000000,1.000000,1.000000; wrap_mode = clamp; [messages] { onshow = call(Init$); } } [t:dialog_box,n:appearance_background] { alpha = 1.000000; common_control = true; common_template = cpbox; draw_order = 2; rect = 566,110,740,290; texture = none; uvcoords = 0.000000,0.000000,1.000000,1.000000; wrap_mode = clamp; } //RACE [t:text,n:character_text] { alpha = 1.000000; common_control = false; common_template = ; draw_order = 68; font_color = -1; font_size = 12; font_type = b_gui_fnt_12p_copperplate-light; justify = center; rect = 602,128,704,144; text = "Race"; //"Character"; texture = none; type = text; uvcoords = 0.000000,0.000000,1.000000,1.000000; wrap_mode = clamp; } [t:button,n:button_prev_character] { alpha = 1.000000; common_control = true; common_template = left; draw_order = 18; rect = 586,128,602,144; uvcoords = 0.000000,0.000000,1.000000,1.000000; wrap_mode = clamp; [messages] { onbuttonpress=call(LoadRace$?shift=-1); } } [t:button,n:button_next_character] { alpha = 1.000000; common_control = true; common_template = right; draw_order = 18; rect = 704,128,720,144; uvcoords = 0.000000,0.000000,1.000000,1.000000; wrap_mode = clamp; [messages] { onbuttonpress=call(LoadRace$?shift=1); } } //GENDER [t:text,n:head_text] { alpha = 1.000000; common_control = false; common_template = ; draw_order = 68; font_color = -1; font_size = 12; font_type = b_gui_fnt_12p_copperplate-light; justify = center; rect = 602,154,704,170; text = "Gender"; //"Head"; texture = none; type = text; uvcoords = 0.000000,0.000000,1.000000,1.000000; wrap_mode = clamp; } [t:button,n:button_prev_head] { alpha = 1.000000; common_control = true; common_template = left; draw_order = 18; rect = 586,154,602,170; uvcoords = 0.000000,0.000000,1.000000,1.000000; wrap_mode = clamp; disable_color = 0x99555555; enabled = false; visible = false; } [t:window,n:stub_prev_head] { alpha = 1.000000; common_control = true; common_template = left; draw_order = 18; rect = 586,154,602,170; texture = b_gui_cmn_button_left_disabled; uvcoords = 0.000000,0.000000,1.000000,1.000000; wrap_mode = clamp; enabled = false; } [t:button,n:button_next_head] { alpha = 1.000000; common_control = true; common_template = right; draw_order = 18; rect = 704,154,720,170; uvcoords = 0.000000,0.000000,1.000000,1.000000; wrap_mode = clamp; disable_color = 0x99555555; enabled = false; visible = false; } [t:window,n:stub_next_head] { alpha = 1.000000; common_control = true; common_template = left; draw_order = 18; rect = 704,154,720,170; texture = b_gui_cmn_button_right_disabled; uvcoords = 0.000000,0.000000,1.000000,1.000000; wrap_mode = clamp; disable_color = 0x99555555; enabled = false; } //HEAD [t:text,n:face_text] { alpha = 1.000000; common_control = false; common_template = ; draw_order = 68; font_color = -1; font_size = 12; font_type = b_gui_fnt_12p_copperplate-light; justify = center; rect = 602,180,704,196; text = "Head"; //"Skin"; texture = none; type = text; uvcoords = 0.000000,0.000000,1.000000,1.000000; wrap_mode = clamp; } [t:button,n:button_prev_face] { alpha = 1.000000; common_control = true; common_template = left; draw_order = 18; rect = 586,180,602,196; uvcoords = 0.000000,0.000000,1.000000,1.000000; wrap_mode = clamp; disable_color = 0x99555555; [messages] { onbuttonpress=call(LoadHead$?shift=-1); } } [t:button,n:button_next_face] { alpha = 1.000000; common_control = true; common_template = right; draw_order = 18; rect = 704,180,720,196; uvcoords = 0.000000,0.000000,1.000000,1.000000; wrap_mode = clamp; disable_color = 0x99555555; [messages] { onbuttonpress=call(LoadHead$?shift=1); } } //HAIR [t:text,n:hair_text] { alpha = 1.000000; common_control = false; common_template = ; draw_order = 68; font_color = -1; font_size = 12; font_type = b_gui_fnt_12p_copperplate-light; justify = center; rect = 602,206,704,222; text = "Hair"; texture = none; type = text; uvcoords = 0.000000,0.000000,1.000000,1.000000; wrap_mode = clamp; } [t:button,n:button_prev_hair] { alpha = 1.000000; common_control = true; common_template = left; draw_order = 18; rect = 586,206,602,222; uvcoords = 0.000000,0.000000,1.000000,1.000000; wrap_mode = clamp; disable_color = 0x99555555; [messages] { onbuttonpress=notify(char_prev_hair) & call(ChangeHair$?shift=-1); } } [t:button,n:button_next_hair] { alpha = 1.000000; common_control = true; common_template = right; draw_order = 18; rect = 704,206,720,222; uvcoords = 0.000000,0.000000,1.000000,1.000000; wrap_mode = clamp; disable_color = 0x99555555; [messages] { onbuttonpress=notify(char_next_hair) & call(ChangeHair$?shift=1); } } //SKIN [t:text,n:shirt_text] { alpha = 1.000000; common_control = false; common_template = ; draw_order = 68; font_color = -1; font_size = 12; font_type = b_gui_fnt_12p_copperplate-light; justify = center; rect = 602,232,704,248; text = "Skin"; //"Shirt"; texture = none; type = text; uvcoords = 0.000000,0.000000,1.000000,1.000000; wrap_mode = clamp; } [t:button,n:button_prev_shirt] { alpha = 1.000000; common_control = true; common_template = left; draw_order = 18; rect = 586,232,602,248; uvcoords = 0.000000,0.000000,1.000000,1.000000; wrap_mode = clamp; disable_color = 0x99555555; [messages] { onbuttonpress=notify(char_prev_face) & notify(char_prev_pants) & call(ChangeSkin$?shift=-1); } } [t:button,n:button_next_shirt] { alpha = 1.000000; common_control = true; common_template = right; draw_order = 18; rect = 704,232,720,248; uvcoords = 0.000000,0.000000,1.000000,1.000000; wrap_mode = clamp; [messages] { onbuttonpress=notify(char_next_face) & notify(char_next_pants) & call(ChangeSkin$?shift=1); } } //CLOTHES [t:text,n:pants_text] { alpha = 1.000000; common_control = false; common_template = ; draw_order = 68; font_color = -1; font_size = 12; font_type = b_gui_fnt_12p_copperplate-light; justify = center; rect = 602,258,704,274; text = "Clothes"; //"Pants"; texture = none; type = text; uvcoords = 0.000000,0.000000,1.000000,1.000000; disable_color = 0x99555555; wrap_mode = clamp; } [t:button,n:button_prev_pants] { alpha = 1.000000; common_control = true; common_template = left; draw_order = 18; rect = 586,258,602,274; uvcoords = 0.000000,0.000000,1.000000,1.000000; wrap_mode = clamp; disable_color = 0x99555555; [messages] { onbuttonpress=notify(char_prev_shirt) & call(ChangeClothes$?shift=-1); } } [t:button,n:button_next_pants] { alpha = 1.000000; common_control = true; common_template = right; draw_order = 18; rect = 704,258,720,274; uvcoords = 0.000000,0.000000,1.000000,1.000000; wrap_mode = clamp; disable_color = 0x99555555; [messages] { onbuttonpress=notify(char_next_shirt) & call(ChangeClothes$?shift=1); } } //DONE [t:button,n:staging_create_character_ok] { alpha = 1.000000; common_control = true; common_template = button_4; draw_order = 18; rect = 252,308,392,324; uvcoords = 0.000000,0.000000,1.000000,1.000000; wrap_mode = clamp; disable_color = 0x99555555; [messages] { onbuttonpress=call(SyncNext$) & notify(staging_create_character_ok) & playsound(s_e_frontend_tiny_button); } [t:text,n:ok_text] { alpha = 1.000000; common_control = false; common_template = ; draw_order = 68; font_color = -1; font_size = 12; font_type = b_gui_fnt_12p_copperplate-light; justify = center; rect = 527,8,621,21; text = "Accept"; texture = none; type = text; uvcoords = 0.000000,0.000000,1.000000,1.000000; wrap_mode = clamp; } } [t:button,n:staging_create_character_cancel] { alpha = 1.000000; common_control = true; common_template = button_4; draw_order = 18; rect = 408,308,548,324; uvcoords = 0.000000,0.000000,1.000000,1.000000; wrap_mode = clamp; [messages] { onbuttonpress=notify(staging_create_character_cancel) & playsound(s_e_frontend_tiny_button); } [t:text,n:cancel_text] { alpha = 1.000000; common_control = false; common_template = ; draw_order = 68; font_color = -1; font_size = 12; font_type = b_gui_fnt_12p_copperplate-light; justify = center; rect = 527,8,621,21; text = "Cancel"; texture = none; type = text; uvcoords = 0.000000,0.000000,1.000000,1.000000; wrap_mode = clamp; } } [t:button,n:staging_character_import] { alpha = 1.000000; common_control = true; common_template = button_4; draw_order = 18; rect = 426,76,586,92; uvcoords = 0.000000,0.000000,1.000000,1.000000; wrap_mode = clamp; disable_color = 0x99555555; [messages] { onbuttonpress=playsound(s_e_frontend_tiny_button) & notify(staging_import_character); } [t:text,n:staging_character_import_text] { alpha = 1.000000; common_control = false; common_template = ; draw_order = 68; font_color = -1; font_size = 12; font_type = b_gui_fnt_12p_copperplate-light; justify = center; rect = 44,200,300,216; text = "Import DS Character..."; texture = none; type = text; uvcoords = 0.000000,0.000000,1.000000,1.000000; wrap_mode = clamp; } } [t:button,n:staging_character_dsx_import] { alpha = 1.000000; common_control = true; common_template = button_4; draw_order = 18; rect = 596,76,756,92; uvcoords = 0.000000,0.000000,1.000000,1.000000; wrap_mode = clamp; [messages] { onbuttonpress=playsound(s_e_frontend_tiny_button) & notify(staging_import_dsx_character); } [t:text,n:staging_character_dsx_import_text] { alpha = 1.000000; common_control = false; common_template = ; draw_order = 68; font_color = -1; font_size = 12; font_type = b_gui_fnt_12p_copperplate-light; justify = center; rect = 44,200,300,216; text = "Import DS LOA Character..."; texture = none; type = text; uvcoords = 0.000000,0.000000,1.000000,1.000000; wrap_mode = clamp; } } }