197 lines
No EOL
6 KiB
Text
197 lines
No EOL
6 KiB
Text
// ================================================================================
|
|
// Reset Password dialog
|
|
// ================================================================================
|
|
_dialog( ResetPassword, localize( "guis/mainmenu/resetpassword" ), _center( desktop, width ), _center( desktop, height ), 256, 118, "noMove", "dim" )
|
|
_input_dialog( ResetPassword )
|
|
_on_default( ResetPassword_Ok, ResetPassword_Cancel )
|
|
|
|
events {
|
|
onNamedEvent "onShow" {
|
|
callSuper();
|
|
setTabStop( 0 );
|
|
}
|
|
onPropertyChanged "gui.onConnectionLost" {
|
|
if( visible ) {
|
|
_close_input
|
|
}
|
|
}
|
|
}
|
|
_edit( ResetPassword_CDKey, _right( dlgResetPassword ) - 23, _top( dlgResetPassword ), 100, BUTTON_HEIGHT )
|
|
_clear_on_show
|
|
_advance_to_next_control_when_full( edtResetPassword_CDKeyChecksum )
|
|
_draw_right_edit_label( localize( "guis/mainmenu/cdkey" ), COLOR_TEXT, 100 )
|
|
properties {
|
|
float maxTextLength = 16;
|
|
float flags = immediate( flags ) | EF_UPPERCASE;
|
|
}
|
|
_end_edit
|
|
|
|
_edit( ResetPassword_CDKeyChecksum, _to_right_of( edtResetPassword_CDKey ) + 3, gui.edtResetPassword_CDKey.rect.y, 20, BUTTON_HEIGHT )
|
|
_clear_on_show
|
|
_advance_to_next_control_when_full( edtResetPassword_NewPassword )
|
|
properties {
|
|
float maxTextLength = 2;
|
|
float flags = immediate( flags ) | EF_UPPERCASE;
|
|
}
|
|
_end_edit
|
|
|
|
_edit( ResetPassword_NewPassword, _right( dlgResetPassword ), _to_bottom_of( edtResetPassword_CDKey ) + 3, 123, BUTTON_HEIGHT )
|
|
_clear_on_show
|
|
_draw_right_edit_label( localize( "guis/mainmenu/newpassword" ), COLOR_TEXT, 100 )
|
|
properties {
|
|
float password = true;
|
|
float maxTextLength = 20;
|
|
}
|
|
_end_edit
|
|
|
|
_edit( ResetPassword_ConfirmPassword, _right( dlgResetPassword ), _to_bottom_of( edtResetPassword_NewPassword ) + 3, 123, BUTTON_HEIGHT )
|
|
_clear_on_show
|
|
_draw_right_edit_label( localize( "guis/mainmenu/confirmpassword" ), COLOR_TEXT, 100 )
|
|
|
|
properties {
|
|
float password = true;
|
|
float maxTextLength = 20;
|
|
}
|
|
|
|
_end_edit
|
|
|
|
_button( ResetPassword_Ok, _to_left_of( btnResetPassword_Cancel ) - 6, _bottom( dlgResetPassword ), BUTTON_WIDTH, BUTTON_HEIGHT )
|
|
properties {
|
|
handle localizedText = localize( "guis/mainmenu/ok" );
|
|
float taskActive = 0;
|
|
float validation;
|
|
}
|
|
_button_action(
|
|
// validation
|
|
|
|
// validate key code
|
|
if ( compare( gui.edtResetPassword_CDKey.editText, "" ) ) {
|
|
_setup_confirmation_ok_error( localize( "guis/mainmenu/blankcdkey" ) )
|
|
_show_popup( confirmation )
|
|
return;
|
|
}
|
|
|
|
validation = sdnet.checkKey( gui.edtResetPassword_CDKey.editText, gui.edtResetPassword_CDKeyChecksum.editText );
|
|
if ( validation == false ) {
|
|
_setup_confirmation_ok_error( localize( "guis/mainmenu/cdkeychecksummismatch" ) )
|
|
_show_popup( confirmation )
|
|
return;
|
|
}
|
|
|
|
if ( compare( gui.edtResetPassword_NewPassword.editText, "" ) ) {
|
|
_setup_confirmation_ok_error( localize( "guis/mainmenu/blankpassword" ) )
|
|
_show_popup( confirmation )
|
|
|
|
return;
|
|
}
|
|
if ( compare( gui.edtResetPassword_NewPassword.editText, gui.edtResetPassword_ConfirmPassword.editText ) == 0 ) {
|
|
_setup_confirmation_ok_error( localize( "guis/mainmenu/confirmpasswordmismatch" ) )
|
|
_show_popup( confirmation )
|
|
return;
|
|
}
|
|
|
|
if ( sdnet.state != SS_ONLINE ) {
|
|
if ( sdnet.connect() == false ) {
|
|
// process error
|
|
_setup_confirmation_ok_error( localize( "guis/mainmenu/failedtoconnect" ) )
|
|
_show_popup( confirmation )
|
|
return;
|
|
}
|
|
taskActive = 1;
|
|
} else {
|
|
sdnet.accountResetPassword( gui.edtResetPassword_CDKey.editText, gui.edtResetPassword_NewPassword.editText );
|
|
if( sdnet.taskActive == false ) {
|
|
_close_popup
|
|
_setup_confirmation_ok_error( sdnet.taskResultMessage )
|
|
_show_popup( confirmation )
|
|
return;
|
|
}
|
|
taskActive = 2;
|
|
}
|
|
|
|
// finish the process
|
|
_show_popup( sdNetProgress )
|
|
|
|
)
|
|
events {
|
|
onPropertyChanged "sdnet.state" {
|
|
if ( sdnet.state == SS_INITIALIZED ) {
|
|
if ( taskActive == 1 ) {
|
|
taskActive = 0;
|
|
|
|
// process error
|
|
_setup_confirmation_ok_error( localize( "guis/mainmenu/failedtoconnect" ) )
|
|
_show_popup( confirmation )
|
|
}
|
|
}
|
|
if ( sdnet.state == SS_ONLINE ) {
|
|
if ( taskActive == 1 ) {
|
|
sdnet.accountResetPassword( gui.edtResetPassword_CDKey.editText, gui.edtResetPassword_NewPassword.editText );
|
|
if( sdnet.taskActive == false ) {
|
|
_close_popup
|
|
_setup_confirmation_ok_error( sdnet.taskResultMessage )
|
|
_show_popup( confirmation )
|
|
return;
|
|
}
|
|
taskActive = 2;
|
|
_show_popup( sdNetProgress );
|
|
}
|
|
}
|
|
}
|
|
onPropertyChanged "sdnet.taskActive" {
|
|
if ( sdnet.taskActive != 0 ) {
|
|
return;
|
|
}
|
|
if ( taskActive == 2 ) {
|
|
taskActive = 0;
|
|
|
|
// process result
|
|
if ( sdnet.taskErrorCode == SDNET_NO_ERROR ) {
|
|
sdnet.accountSetPassword( gui.edtResetPassword_NewPassword.editText );
|
|
|
|
taskActive = 3;
|
|
_show_popup( sdNetProgress )
|
|
sdnet.signIn();
|
|
return;
|
|
}
|
|
|
|
// process error
|
|
_setup_confirmation_ok_error( sdnet.taskResultMessage );
|
|
_show_popup( confirmation )
|
|
|
|
return;
|
|
}
|
|
if ( taskActive == 3 ) {
|
|
taskActive = 0;
|
|
|
|
// process result
|
|
if ( sdnet.taskErrorCode == SDNET_NO_ERROR ) {
|
|
_close_input
|
|
sdnet.initFriends();
|
|
sdnet.initTeams();
|
|
return;
|
|
}
|
|
|
|
// process error
|
|
_setup_confirmation_ok_error( sdnet.taskResultMessage );
|
|
_show_popup( confirmation )
|
|
|
|
return;
|
|
}
|
|
}
|
|
onPropertyChanged "gui.onConnectionLost" {
|
|
if ( taskActive > 0 ) {
|
|
taskActive = 0;
|
|
}
|
|
if ( gui.dlgResetPassword.visible > 0 ) {
|
|
_show_single_dialog( gameSettings )
|
|
}
|
|
}
|
|
}
|
|
_end_button
|
|
|
|
_button( resetPassword_Cancel, _right( dlgResetPassword ), _bottom( dlgResetPassword ), BUTTON_WIDTH, BUTTON_HEIGHT )
|
|
properties { handle localizedText = localize( "guis/mainmenu/cancel" ); }
|
|
_button_action( _close_input )
|
|
_end_button
|
|
_end_dialog |