设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
12
返回列表 发新帖
楼主: 萌新一个人
打印 上一主题 下一主题

[有事请教] 用了Online_Chat.js网络插件聊天白屏

[复制链接]

Lv3.寻梦者

梦石
0
星屑
1419
在线时间
198 小时
注册时间
2021-8-19
帖子
43
11
 楼主| 发表于 2021-10-12 17:56:09 | 只看该作者
百里_飞柳 发表于 2021-10-12 17:24
我觉得报错原因是 Scene_Battle 里面没有这个聊天框
但是它是实时接收更新聊天文本的
导致182行提取的chat ...

有道理,如果按照你说的方法说,直接扔掉要怎么表达啊,代码   谢谢大佬了
回复

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
1419
在线时间
198 小时
注册时间
2021-8-19
帖子
43
12
 楼主| 发表于 2021-10-13 14:07:41 | 只看该作者
  1. var Imported = Imported || {};
  2. Imported.Online_Login_Core = true;

  3. (function () {
  4. var Nasty = Nasty || {};
  5. //=============================================================================
  6. // Online Login Core
  7. // Version: 1.1.5 - Added Password Reset Logic
  8. // Version: 1.1.4 - Added event switches for when users login multiple times
  9. // Version: 1.1.3
  10. //=============================================================================

  11. //=============================================================================
  12. /*:
  13. * @plugindesc Login window for Neldersons Online Core
  14. *<Online_Login_Core>
  15. * @author Nelderson and SirMcPotato/Vinxce
  16. *
  17. * @param Force Login on Startup
  18. * @desc Make the title screen into a login screen
  19. * @default true
  20. *
  21. * @param socket.io connection
  22. * @desc Automatically connects to socket once signed in.
  23. * @default true
  24. *
  25. * @param Switch on First Shutdown
  26. * @desc Original user that is logged in will have this switch flipped
  27. * @default 1
  28. *
  29. * @param Switch on Second Shutdown
  30. * @desc Second user that is logged in will have this switch flipped
  31. * @default 2
  32. *
  33. * @help
  34. * ============================================================================
  35. * Introduction and Instructions
  36. * ============================================================================
  37. * You can use the login window in two ways.
  38. *
  39. *  1.  Set Force login on Startup parameter to true:
  40. *      This will force the login screen on startup.
  41. *
  42. *  2.  Set Force login on Startup parameter to false:
  43. *      You can use this plugin command to pop up the
  44. *      login window at any point in your game:
  45. *
  46. *         Online_Login
  47. *
  48. *   The socket.io connection parameter refers to if you
  49. *   want to automatically upgrade to sockets after login.
  50. *
  51. */
  52. //=============================================================================
  53. Nasty.Parameters = $plugins.filter(function(p)
  54.                 { return p.description.contains('<Online_Login_Core>');})[0].parameters;


  55.                 var Nel_online_login_core_plugincomm_alias = Game_Interpreter.prototype.pluginCommand;
  56.     Game_Interpreter.prototype.pluginCommand = function(command, args) {
  57.         Nel_online_login_core_plugincomm_alias.call(this, command, args);
  58.         if (command.toUpperCase() === 'ONLINE_LOGIN') {
  59.                                         if ($gameNetwork._token===0){
  60.                                                 SceneManager.goto(MMO_Scene_Title);
  61.                                         }
  62.         }
  63.       };

  64.         //----------------------------------------------------------------------------
  65.         // MMO_Scene_Title
  66.         //
  67.         // Title scene including login form.
  68.   //----------------------------------------------------------------------------

  69.         function MMO_Scene_Title() {
  70.             this.initialize.apply(this, arguments);
  71.         }

  72.         MMO_Scene_Title.prototype = Object.create(Scene_Base.prototype);
  73.         MMO_Scene_Title.prototype.constructor = MMO_Scene_Title;

  74.         MMO_Scene_Title.prototype.initialize = function() {
  75.             Scene_Base.prototype.initialize.call(this);
  76.         };

  77.         MMO_Scene_Title.prototype.reBindInput = function() {
  78.                 Input.initialize();
  79.         };

  80.         MMO_Scene_Title.prototype.create = function() {
  81.             Scene_Base.prototype.create.call(this);
  82.             this.createBackground();
  83.         };

  84.         MMO_Scene_Title.prototype.start = function() {
  85.             Scene_Base.prototype.start.call(this);
  86.             SceneManager.clearStack();
  87.             this.playTitleMusic();
  88.             this.startFadeIn(this.fadeSpeed(), false);
  89.             this.createLoginForm();
  90.         };

  91.         MMO_Scene_Title.prototype.update = function() {
  92.             Scene_Base.prototype.update.call(this);
  93.         };

  94.         MMO_Scene_Title.prototype.isBusy = function() {
  95.             return Scene_Base.prototype.isBusy.call(this);
  96.         };

  97.         MMO_Scene_Title.prototype.terminate = function() {
  98.             Scene_Base.prototype.terminate.call(this);
  99.             SceneManager.snapForBackground();
  100.         };


  101.         MMO_Scene_Title.prototype.createRegistrationForm = function() {
  102.                 $("#ErrorPrinter").html(
  103.                         '<div id="RegisterForm" class="panel panel-primary" style="width:'+(Graphics.boxWidth - (Graphics.boxWidth / 3))+'px">'+
  104.                                 '<div class="panel-heading">注册账号</div>'+
  105.                                 '<div class="panel-body">'+
  106.                                         '<div id="loginErrBox"></div>'+
  107.                                   '<div class="form-group">'+
  108.                                     '<input type="text" id="regUsername" name="username" placeholder="输入用户名" class="form-control"/>'+
  109.                                   '</div>'+
  110.                                           '<div class="form-group">'+
  111.                             '<input type="text" name="email" id="regEmail"  placeholder="电子邮件地址 随便填" class="form-control"/>'+
  112.                                   '</div>'+
  113.                                           '<div class="form-group">'+
  114.                             '<input type="password" name="password" id="regPassword" placeholder="输入密码" class="form-control"/>'+
  115.                                           '</div>'+
  116.                                           '<button id="btnSubmit"type="submit" class="btn btn-default">提交</button>'+
  117.                                                 '<button id ="btnCancel" type="button" class="btn btn-primary">取消</button>'+
  118.                                 '</div>'+
  119.                         '</div>');

  120.                         var that = this;
  121.                         $(".form-control").keypress(function(e){
  122.                                 if (e.which == 13) { //enter
  123.                                         that.registerAttempt();
  124.                                 }
  125.                         });
  126.       $("#regUsername").tap(function(){$("#regUsername").focus();});
  127.       $("#regEmail").tap(function(){$("#regEmail").focus();});
  128.       $("#regPassword").tap(function(){$("#regPassword").focus();});
  129.       $("#btnSubmit").bind("click touchstart",function(){that.registerAttempt();});
  130.       $("#btnCancel").bind("click touchstart",function(){that.createLoginForm();});

  131.                 };
  132.         // Testing purpose, need to be rewritten into something more modulable,
  133.         // maybe using template file?
  134.         // Can be wise to work on a set of sprite-based form inputs for
  135.         // a better visual integration.
  136.         MMO_Scene_Title.prototype.createLoginForm = function() {
  137.                 $("#ErrorPrinter").html(
  138.                         '<div id="LoginForm" class="panel panel-primary" style="width:'+(Graphics.boxWidth - (Graphics.boxWidth / 3))+'px">'+
  139.                                 '<div class="panel-heading">登陆</div>'+
  140.                                 '<div class="panel-body">'+
  141.                                         '<div id="loginErrBox"></div>'+
  142.                                         '<div class="input-group">'+
  143.                                                 '<span class="input-group-addon" id="username-addon"><i class="fa fa-user"></i></span>'+
  144.                                                 '<input type="text" class="form-control login-input" id="inputUsername" placeholder="用户名" aria-describedby="username-addon">'+
  145.                                         '</div><br>'+
  146.                                         '<div class="input-group">'+
  147.                                                 '<span class="input-group-addon" id="password-addon"><i class="fa fa-lock"></i></span>'+
  148.                                                 '<input type="password" class="form-control login-input" id="inputPassword" placeholder="密码" aria-describedby="password-addon">'+
  149.                                         '</div><br>'+
  150.                                         '<button id="btnConnect" class="btn btn-primary">登陆</button>'+
  151.                                         '<button id="btnRegister" class="btn btn-default">注册</button>'+
  152.           '<button id="btnForgotPassword" class="btn btn-link btn-sm">找回密码?</button>'+
  153.                                 '</div>'+
  154.                         '</div>');

  155.                 //Bind commands
  156.                 var that = this;
  157.                 $(".login-input").keypress(function(e){
  158.                         if (e.which == 13) { //enter
  159.                                 that.connectAttempt();
  160.                         }
  161.                 });
  162.     $("#inputUsername").tap(function(){$("#inputUsername").focus();});
  163.     $("#inputPassword").tap(function(){$("#inputPassword").focus();});
  164.                 $("#btnConnect").bind("click touchstart",function(){that.connectAttempt();});
  165.                 $("#btnRegister").bind("click touchstart",function(){that.createRegistrationForm();});
  166.     $("#btnForgotPassword").bind("click touchstart",function(){that.createLostPasswordForm();});
  167.     $("#inputUsername").focus();
  168.         };

  169.         MMO_Scene_Title.prototype.createActivationForm = function() {
  170.                 $("#ErrorPrinter").html(
  171.                         '<div id="ActivationForm" class="panel panel-primary" style="width:'+(Graphics.boxWidth - (Graphics.boxWidth / 3))+'px">'+
  172.                                 '<div class="panel-heading">Activation</div>'+
  173.                                 '<div class="panel-body">'+
  174.                                         '<div id="loginErrBox"></div>'+
  175.                                         '<div class="input-group">'+
  176.                                         '</div><br>'+
  177.                                         '<button id="btnActLogin" class="btn btn-primary">Login</button>'+
  178.                                 '</div>'+
  179.                         '</div>');

  180.                 //Bind commands
  181.                 var that = this;
  182.                 $(".login-input").keypress(function(e){
  183.                         if (e.which == 13) { //enter
  184.                                 that.createLoginForm();
  185.                         }
  186.                 });
  187.     $("#btnActLogin").bind("click touchstart",function(){that.createLoginForm();});
  188.         };

  189.         MMO_Scene_Title.prototype.displayError = function(msg) {
  190.                 $("#loginErrBox").html('<div class="alert alert-danger fade in">'+msg+'</div>');
  191.         };
复制代码
回复

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
1419
在线时间
198 小时
注册时间
2021-8-19
帖子
43
13
 楼主| 发表于 2021-10-13 14:14:18 | 只看该作者
  1. var Imported = Imported || {};
  2. Imported.Online_Login_Core = true;

  3. (function () {
  4. var Nasty = Nasty || {};
  5. //=============================================================================
  6. // Online Login Core
  7. // Version: 1.1.5 - Added Password Reset Logic
  8. // Version: 1.1.4 - Added event switches for when users login multiple times
  9. // Version: 1.1.3
  10. //=============================================================================

  11. //=============================================================================
  12. /*:
  13. * @plugindesc Login window for Neldersons Online Core
  14. *<Online_Login_Core>
  15. * @author Nelderson and SirMcPotato/Vinxce
  16. *
  17. * @param Force Login on Startup
  18. * @desc Make the title screen into a login screen
  19. * @default true
  20. *
  21. * @param socket.io connection
  22. * @desc Automatically connects to socket once signed in.
  23. * @default true
  24. *
  25. * @param Switch on First Shutdown
  26. * @desc Original user that is logged in will have this switch flipped
  27. * @default 1
  28. *
  29. * @param Switch on Second Shutdown
  30. * @desc Second user that is logged in will have this switch flipped
  31. * @default 2
  32. *
  33. * @help
  34. * ============================================================================
  35. * Introduction and Instructions
  36. * ============================================================================
  37. * You can use the login window in two ways.
  38. *
  39. *  1.  Set Force login on Startup parameter to true:
  40. *      This will force the login screen on startup.
  41. *
  42. *  2.  Set Force login on Startup parameter to false:
  43. *      You can use this plugin command to pop up the
  44. *      login window at any point in your game:
  45. *
  46. *         Online_Login
  47. *
  48. *   The socket.io connection parameter refers to if you
  49. *   want to automatically upgrade to sockets after login.
  50. *
  51. */
  52. //=============================================================================
  53. Nasty.Parameters = $plugins.filter(function(p)
  54.                 { return p.description.contains('<Online_Login_Core>');})[0].parameters;


  55.                 var Nel_online_login_core_plugincomm_alias = Game_Interpreter.prototype.pluginCommand;
  56.     Game_Interpreter.prototype.pluginCommand = function(command, args) {
  57.         Nel_online_login_core_plugincomm_alias.call(this, command, args);
  58.         if (command.toUpperCase() === 'ONLINE_LOGIN') {
  59.                                         if ($gameNetwork._token===0){
  60.                                                 SceneManager.goto(MMO_Scene_Title);
  61.                                         }
  62.         }
  63.       };

  64.         //----------------------------------------------------------------------------
  65.         // MMO_Scene_Title
  66.         //
  67.         // Title scene including login form.
  68.   //----------------------------------------------------------------------------

  69.         function MMO_Scene_Title() {
  70.             this.initialize.apply(this, arguments);
  71.         }

  72.         MMO_Scene_Title.prototype = Object.create(Scene_Base.prototype);
  73.         MMO_Scene_Title.prototype.constructor = MMO_Scene_Title;

  74.         MMO_Scene_Title.prototype.initialize = function() {
  75.             Scene_Base.prototype.initialize.call(this);
  76.         };

  77.         MMO_Scene_Title.prototype.reBindInput = function() {
  78.                 Input.initialize();
  79.         };

  80.         MMO_Scene_Title.prototype.create = function() {
  81.             Scene_Base.prototype.create.call(this);
  82.             this.createBackground();
  83.         };

  84.         MMO_Scene_Title.prototype.start = function() {
  85.             Scene_Base.prototype.start.call(this);
  86.             SceneManager.clearStack();
  87.             this.playTitleMusic();
  88.             this.startFadeIn(this.fadeSpeed(), false);
  89.             this.createLoginForm();
  90.         };

  91.         MMO_Scene_Title.prototype.update = function() {
  92.             Scene_Base.prototype.update.call(this);
  93.         };

  94.         MMO_Scene_Title.prototype.isBusy = function() {
  95.             return Scene_Base.prototype.isBusy.call(this);
  96.         };

  97.         MMO_Scene_Title.prototype.terminate = function() {
  98.             Scene_Base.prototype.terminate.call(this);
  99.             SceneManager.snapForBackground();
  100.         };


  101.         MMO_Scene_Title.prototype.createRegistrationForm = function() {
  102.                 $("#ErrorPrinter").html(
  103.                         '<div id="RegisterForm" class="panel panel-primary" style="width:'+(Graphics.boxWidth - (Graphics.boxWidth / 3))+'px">'+
  104.                                 '<div class="panel-heading">注册账号</div>'+
  105.                                 '<div class="panel-body">'+
  106.                                         '<div id="loginErrBox"></div>'+
  107.                                   '<div class="form-group">'+
  108.                                     '<input type="text" id="regUsername" name="username" placeholder="输入用户名" class="form-control"/>'+
  109.                                   '</div>'+
  110.                                           '<div class="form-group">'+
  111.                             '<input type="text" name="email" id="regEmail"  placeholder="电子邮件地址 随便填" class="form-control"/>'+
  112.                                   '</div>'+
  113.                                           '<div class="form-group">'+
  114.                             '<input type="password" name="password" id="regPassword" placeholder="输入密码" class="form-control"/>'+
  115.                                           '</div>'+
  116.                                           '<button id="btnSubmit"type="submit" class="btn btn-default">提交</button>'+
  117.                                                 '<button id ="btnCancel" type="button" class="btn btn-primary">取消</button>'+
  118.                                 '</div>'+
  119.                         '</div>');

  120.                         var that = this;
  121.                         $(".form-control").keypress(function(e){
  122.                                 if (e.which == 13) { //enter
  123.                                         that.registerAttempt();
  124.                                 }
  125.                         });
  126.       $("#regUsername").tap(function(){$("#regUsername").focus();});
  127.       $("#regEmail").tap(function(){$("#regEmail").focus();});
  128.       $("#regPassword").tap(function(){$("#regPassword").focus();});
  129.       $("#btnSubmit").bind("click touchstart",function(){that.registerAttempt();});
  130.       $("#btnCancel").bind("click touchstart",function(){that.createLoginForm();});

  131.                 };
  132.         // Testing purpose, need to be rewritten into something more modulable,
  133.         // maybe using template file?
  134.         // Can be wise to work on a set of sprite-based form inputs for
  135.         // a better visual integration.
  136.         MMO_Scene_Title.prototype.createLoginForm = function() {
  137.                 $("#ErrorPrinter").html(
  138.                         '<div id="LoginForm" class="panel panel-primary" style="width:'+(Graphics.boxWidth - (Graphics.boxWidth / 3))+'px">'+
  139.                                 '<div class="panel-heading">登陆</div>'+
  140.                                 '<div class="panel-body">'+
  141.                                         '<div id="loginErrBox"></div>'+
  142.                                         '<div class="input-group">'+
  143.                                                 '<span class="input-group-addon" id="username-addon"><i class="fa fa-user"></i></span>'+
  144.                                                 '<input type="text" class="form-control login-input" id="inputUsername" placeholder="用户名" aria-describedby="username-addon">'+
  145.                                         '</div><br>'+
  146.                                         '<div class="input-group">'+
  147.                                                 '<span class="input-group-addon" id="password-addon"><i class="fa fa-lock"></i></span>'+
  148.                                                 '<input type="password" class="form-control login-input" id="inputPassword" placeholder="密码" aria-describedby="password-addon">'+
  149.                                         '</div><br>'+
  150.                                         '<button id="btnConnect" class="btn btn-primary">登陆</button>'+
  151.                                         '<button id="btnRegister" class="btn btn-default">注册</button>'+
  152.           '<button id="btnForgotPassword" class="btn btn-link btn-sm">找回密码?</button>'+
  153.                                 '</div>'+
  154.                         '</div>');

  155.                 //Bind commands
  156.                 var that = this;
  157.                 $(".login-input").keypress(function(e){
  158.                         if (e.which == 13) { //enter
  159.                                 that.connectAttempt();
  160.                         }
  161.                 });
  162.     $("#inputUsername").tap(function(){$("#inputUsername").focus();});
  163.     $("#inputPassword").tap(function(){$("#inputPassword").focus();});
  164.                 $("#btnConnect").bind("click touchstart",function(){that.connectAttempt();});
  165.                 $("#btnRegister").bind("click touchstart",function(){that.createRegistrationForm();});
  166.     $("#btnForgotPassword").bind("click touchstart",function(){that.createLostPasswordForm();});
  167.     $("#inputUsername").focus();
  168.         };

  169.         MMO_Scene_Title.prototype.createActivationForm = function() {
  170.                 $("#ErrorPrinter").html(
  171.                         '<div id="ActivationForm" class="panel panel-primary" style="width:'+(Graphics.boxWidth - (Graphics.boxWidth / 3))+'px">'+
  172.                                 '<div class="panel-heading">Activation</div>'+
  173.                                 '<div class="panel-body">'+
  174.                                         '<div id="loginErrBox"></div>'+
  175.                                         '<div class="input-group">'+
  176.                                         '</div><br>'+
  177.                                         '<button id="btnActLogin" class="btn btn-primary">Login</button>'+
  178.                                 '</div>'+
  179.                         '</div>');

  180.                 //Bind commands
  181.                 var that = this;
  182.                 $(".login-input").keypress(function(e){
  183.                         if (e.which == 13) { //enter
  184.                                 that.createLoginForm();
  185.                         }
  186.                 });
  187.     $("#btnActLogin").bind("click touchstart",function(){that.createLoginForm();});
  188.         };

  189.         MMO_Scene_Title.prototype.displayError = function(msg) {
  190.                 $("#loginErrBox").html('<div class="alert alert-danger fade in">'+msg+'</div>');
  191.         };

  192.         MMO_Scene_Title.prototype.displayInfo = function(msg) {
  193.                 $("#loginErrBox").html('<div class="alert alert-info fade in">'+msg+'</div>');
  194.         };

  195.   MMO_Scene_Title.prototype.displaySuccess = function(msg) {
  196.                 $("#loginErrBox").html('<div class="alert alert-success fade in">'+msg+'</div>');
  197.         };

  198.   MMO_Scene_Title.prototype.createLostPasswordForm = function() {
  199.                 $("#ErrorPrinter").html(
  200.                         '<div id="LostPasswordFrom" class="panel panel-primary" style="width:'+(Graphics.boxWidth - (Graphics.boxWidth / 3))+'px">'+
  201.                                 '<div class="panel-heading">忘记密码 输入电子邮件</div>'+
  202.                                 '<div class="panel-body">'+
  203.                                         '<div id="loginErrBox"></div>'+
  204.                                           '<div class="form-group">'+
  205.                             '<input type="text" name="email" id="inputEmailLP"  placeholder="电子邮件地址" class="form-control"/>'+
  206.                                   '</div>'+
  207.                                           '<button id="btnSubmitLP"type="submit" class="btn btn-primary">提交</button>'+
  208.                                                 '<button id ="btnCancelLP" type="button" class="btn btn-default">取消</button>'+
  209.                                 '</div>'+
  210.                         '</div>');

  211.                         var that = this;
  212.                         $(".form-control").keypress(function(e){
  213.                                 if (e.which == 13) { //enter
  214.                                         that.lostPasswordRequest();
  215.                                 }
  216.                         });
  217.       $("#inputEmailLP").tap(function(){$("#inputEmailLP").focus();});
  218.       $("#btnSubmitLP").bind("click touchstart",function(){that.lostPasswordRequest();});
  219.       $("#btnCancelLP").bind("click touchstart",function(){that.createLoginForm();});
  220.       $("#inputEmailLP").focus();
  221.                 };

  222.     MMO_Scene_Title.prototype.createResetPasswordForm = function() {
  223.                   $("#ErrorPrinter").html(
  224.                           '<div id="PasswordResetForm" class="panel panel-primary" style="width:'+(Graphics.boxWidth - (Graphics.boxWidth / 3))+'px">'+
  225.                                   '<div class="panel-heading">Password Reset</div>'+
  226.                                   '<div class="panel-body">'+
  227.                                           '<div id="loginErrBox"></div>'+
  228.                                             '<div class="form-group">'+
  229.                               '<input type="password" name="password" id="inputPasswordCP"  placeholder="New Password" class="form-control"/>'+
  230.                                     '</div>'+
  231.             '<div class="form-group">'+
  232.           '<input type="password" name="password" id="inputPasswordConfirmCP"  placeholder="Confirm Password" class="form-control"/>'+
  233.           '</div>'+
  234.                                             '<button id="btnChangeCP"type="submit" class="btn btn-primary">Change</button>'+
  235.                                                   '<button id ="btnCancelCP" type="button" class="btn btn-default">Cancel</button>'+
  236.                                   '</div>'+
  237.                           '</div>');

  238.                           var that = this;
  239.                           $(".form-control").keypress(function(e){
  240.                                   if (e.which == 13) { //enter
  241.                                           that.changePasswordRequest();
  242.                                   }
  243.                           });
  244.         $("#inputPasswordCP").tap(function(){$("#inputEmailLP").focus();});
  245.         $("#inputPasswordConfirmCP").tap(function(){$("#inputEmailLP").focus();});
  246.         $("#btnChangeCP").bind("click touchstart",function(){that.changePasswordRequest();});
  247.         $("#btnCancelCP").bind("click touchstart",function(){that.createLoginForm();});
  248.         $("#inputPasswordCP").focus();
  249.                   };

  250.       MMO_Scene_Title.prototype.changePasswordRequest = function(){
  251.                     var that = this;
  252.         var pass1 = $("#inputPasswordCP").val();
  253.         var pass2 = $("#inputPasswordConfirmCP").val();
  254.         if (pass1.length === 0)
  255.                             return this.displayError("You must provide a new password!");
  256.         if (pass2.length === 0)
  257.                       return this.displayError("You must confirm your password!");
  258.         if (pass1!==pass2)
  259.           return this.displayError("Passwords do not match!");
  260.         this.displayInfo('Connecting <i class="fa fa-spin fa-spinner"></i>');

  261.         shapwd = CryptoJS.SHA1(pass1+$gameNetwork._firstHash).toString(CryptoJS.enc.Hex);

  262.         $.post($gameNetwork._serverURL+'/resetpassword', {
  263.             password: shapwd,
  264.             tempHash: $gameSystem._tempPasswordHash,
  265.             tempName: $gameSystem._tempPasswordName
  266.           }).done(function (data) {
  267.             if (data.err) return that.displayError("Error : "+data.err);
  268.             that.createLoginForm();
  269.             that.displaySuccess("Password Changed Successfully");
  270.           });
  271.       };

  272.     MMO_Scene_Title.prototype.lostPasswordRequest = function(){
  273.                   var that = this;
  274.                   var email = $("#inputEmailLP").val();
  275.       if (email.length === 0)
  276.                           return this.displayError("You must provide a username!");
  277.       this.displayInfo('Connecting <i class="fa fa-spin fa-spinner"></i>');

  278.       $.post($gameNetwork._serverURL+'/lostpassword', {
  279.         email: email,
  280.       }).done(function (data) {
  281.         if (data.err) return that.displayError("Error : "+data.err);
  282.         that.createLoginForm();
  283.         that.displayInfo("Check email for temporary password");
  284.       });
  285.     };

  286.         MMO_Scene_Title.prototype.connectAttempt = function(){
  287.                 var that = this;
  288.                 var username = $("#inputUsername").val();
  289.                 var password = $("#inputPassword").val();

  290.                 if (username.length === 0)
  291.                         return this.displayError("You must provide a username!");
  292.                 if (password.length === 0)
  293.                         return this.displayError("You must provide a password!");

  294.                 shapwd = CryptoJS.SHA1(password+$gameNetwork._firstHash).toString(CryptoJS.enc.Hex);
  295.                 this.displayInfo('Connecting <i class="fa fa-spin fa-spinner"></i>');
  296.         $.post($gameNetwork._serverURL+'/login', {
  297.                                         username: username,
  298.                                         password: shapwd
  299.       }).done(function (data) {
  300.                                 if (data.err)
  301.                                                 return that.displayError("Error : "+data.err);
  302.         if (data.temp){
  303.           //Make Password reset form
  304.           $gameSystem._tempPasswordName = data.name;
  305.           $gameSystem._tempPasswordHash = data.temp;
  306.           that.createResetPasswordForm();
  307.         }
  308.                                         if (data.token) {
  309.                                                 $gameNetwork._token = data.token;
  310.                                                 var ioFlag = String(Nasty.Parameters['socket.io connection']);
  311.                                                 $("#ErrorPrinter").fadeOut({duration: 1000}).html("");
  312.             if (ioFlag==='true'){
  313.                                                         $gameNetwork.connectSocket('main','/');
  314.               $gameNetwork._socket.main.on('firstShutDown',function(data){
  315.                 $gameSwitches.setValue(Number(Nasty.Parameters['Switch on First Shutdown']),true);
  316.               });
  317.               $gameNetwork._socket.main.on('secondShutDown',function(data){
  318.                 $gameSwitches.setValue(Number(Nasty.Parameters['Switch on Second Shutdown']),true);
  319.               });
  320.                                                 }
  321.             $gameNetwork.connectSocketsAfterLogin();
  322.             that.fadeOutAll();
  323.                                           SceneManager.goto(Scene_Map);
  324.                                                 return that.displayInfo("Ok : "+data.msg);
  325.                                         }
  326.       });
  327.         };

  328.         MMO_Scene_Title.prototype.registerAttempt = function(){
  329.                 var that = this;
  330.                 var username = $("#regUsername").val();
  331.                 var password = $("#regPassword").val();
  332.                 var email = $("#regEmail").val();
  333.                 if (username.length === 0) return this.displayError("You must provide a username!");
  334.                 if (password.length === 0) return this.displayError("You must provide a password!");
  335.                 if (email.length === 0) return this.displayError("You must provide a valid Email!");

  336.                 this.displayInfo('Connecting <i class="fa fa-spin fa-spinner"></i>');

  337.                 //POST FOR REGISTER
  338.                 $.post($gameNetwork._serverURL + '/register', {
  339.                         username: username,
  340.                         password: password,
  341.                         email: email
  342.         }).done(function (result) {
  343.                 var data = result.pageData;
  344.                 if (data.err)
  345.                         return that.displayError("Error : "+data.err);
  346.                 if (data.msg) {
  347.                                 that.createActivationForm();
  348.                         that.displayInfo("Check your email for the activation link!");
  349.                 }
  350.         });
  351.         };

  352.         MMO_Scene_Title.prototype.createBackground = function() {
  353.                 var startupFlag = String(Nasty.Parameters['Force Login on Startup']);
  354.                 if (startupFlag==='true'){
  355.             this._backSprite1 = new Sprite(ImageManager.loadTitle1($dataSystem.title1Name));
  356.             this._backSprite2 = new Sprite(ImageManager.loadTitle2($dataSystem.title2Name));
  357.             this.addChild(this._backSprite1);
  358.             this.addChild(this._backSprite2);
  359.                         this.centerSprite(this._backSprite1);
  360.             this.centerSprite(this._backSprite2);
  361.                         this.createForeground();
  362.                 }else{
  363.                         this._backgroundSprite = new Sprite();
  364.             this._backgroundSprite.bitmap = SceneManager.backgroundBitmap();
  365.             this.addChild(this._backgroundSprite);
  366.                 }
  367.         };

  368.         MMO_Scene_Title.prototype.createForeground = function() {
  369.             this._gameTitleSprite = new Sprite(new Bitmap(Graphics.width, Graphics.height));
  370.             this.addChild(this._gameTitleSprite);
  371.             if ($dataSystem.optDrawTitle) {
  372.                 this.drawGameTitle();
  373.             }
  374.         };

  375.         MMO_Scene_Title.prototype.drawGameTitle = function() {
  376.             var x = 10;
  377.             var y = Graphics.height / 2;
  378.             var maxWidth = Graphics.width - x * 1;
  379.             var text = $dataSystem.gameTitle;
  380.             this._gameTitleSprite.bitmap.outlineColor = 'black';
  381.             this._gameTitleSprite.bitmap.outlineWidth = 8;
  382.             this._gameTitleSprite.bitmap.fontSize = 72;
  383.             this._gameTitleSprite.bitmap.drawText(text, x, y, maxWidth, 48, 'center');
  384.         };

  385.         MMO_Scene_Title.prototype.centerSprite = function(sprite) {
  386.             sprite.x = Graphics.width / 2;
  387.             sprite.y = Graphics.height / 2;
  388.             sprite.anchor.x = 0.5;
  389.             sprite.anchor.y = 0.5;
  390.         };

  391.         MMO_Scene_Title.prototype.playTitleMusic = function() {
  392.             AudioManager.playBgm($dataSystem.titleBgm);
  393.             AudioManager.stopBgs();
  394.             AudioManager.stopMe();
  395.         };

  396.   //----------------------------------------------------------------------------
  397.         //
  398.         // Override of Scene_Boot.start, for calling our own Scene_Title!
  399.         //

  400. var Nel__SceneBase_Boot_alias_MMO_Login = Scene_Boot.prototype.start;

  401.         Scene_Boot.prototype.start = function() {
  402.                 var startupFlag = String(Nasty.Parameters['Force Login on Startup']);
  403.                 if (startupFlag==='false'){
  404.                         Nel__SceneBase_Boot_alias_MMO_Login.call(this);
  405.                 }
  406.                 else{
  407.             Scene_Base.prototype.start.call(this);
  408.             SoundManager.preloadImportantSounds();
  409.             if (DataManager.isBattleTest()) {
  410.                 DataManager.setupBattleTest();
  411.                 SceneManager.goto(Scene_Battle);
  412.             } else if (DataManager.isEventTest()) {
  413.                 DataManager.setupEventTest();
  414.                 SceneManager.goto(Scene_Map);
  415.             } else {
  416.                 this.checkPlayerLocation();
  417.                 DataManager.setupNewGame();
  418.                 SceneManager.goto(MMO_Scene_Title);
  419.             }
  420.             this.updateDocumentTitle();
  421.                 }
  422.         };

  423.     //-----------------------------------------------------------------------------
  424.         //
  425.         // Overriding 'Input._onKeyDown' to pass 'event' as parameter
  426.         // to 'Input._shouldPreventDefault'
  427.         //

  428.         Input._onKeyDown = function(event) {
  429.             if (this._shouldPreventDefault(event)) {
  430.                 event.preventDefault();
  431.             }
  432.             if (event.keyCode === 144) {    // Numlock
  433.                 this.clear();
  434.             }
  435.             var buttonName = this.keyMapper[event.keyCode];
  436.             if (buttonName) {
  437.                 this._currentState[buttonName] = true;
  438.             }
  439.         };

  440.     //-----------------------------------------------------------------------------
  441.         //
  442.         // Overriding Input._shouldPreventDefault to allow the use of the 'backspace key'
  443.         // in input forms.
  444.         //

  445.         Input._shouldPreventDefault = function(e) {
  446.             switch (e.keyCode) {
  447.                     case 8:     // backspace
  448.                             if ($(e.target).is("input, textarea"))
  449.                                     break;
  450.                     case 33:    // pageup
  451.                     case 34:    // pagedown
  452.                     case 37:    // left arrow
  453.                     case 38:    // up arrow
  454.                     case 39:    // right arrow
  455.                     case 40:    // down arrow
  456.                         return true;
  457.             }
  458.             return false;
  459.         };


  460. })();
复制代码
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-5-22 03:30

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表