查看: 79|回复: 0

[转载发布] RMMV基于托管网站的游戏版本更新检测

[复制链接]
  • TA的每日心情
    开心
    2024-5-10 09:55
  • 签到天数: 37 天

    连续签到: 3 天

    [LV.5]常住居民I

    2028

    主题

    32

    回帖

    7260

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    0
    卡币
    5184
    OK点
    16
    积分
    7260
    发表于 同元九百九十七年九月二日(秋) | 显示全部楼层 |阅读模式
    RMMV基于托管网站的游戏版本更新检测
    楼主没发过什么帖子,也不知道该说些啥,就是基于github或者coding的游戏版本检查,首先是在这些网站上拥有自己的仓库,然后发布page页,新建一个关于版本的文件,然后在rmmv中用插件进行判断,详细说明在demo中有写,依赖jquery,有不懂的回复说明。

    地址如下



    插件地址:https://ycxyi.github.io/plugs/Ycx_VersionCheck.js

    插件预览,记得有位大大说 document会覆盖,有建议可以及时提,谢谢。

    JAVASCRIPT 代码
    1. //=============================================================================
    2. // Ycx_VersionCheck.js
    3. //=============================================================================
    4. var Imported = Imported || {};
    5. Imported.Ycx_VersionCheck = true;
    6. var Ycx = Ycx || {};
    7. Ycx.CHECK = Ycx.CHECK || {};
    8. /*:
    9. * @plugindesc 基于代码托管网站的检测游戏版本插件 v1.0.0
    10. * @author ycx
    11. *
    12. * @param nowVersion
    13. * @desc 目前游戏版本
    14. * @default 1.0.0
    15. *
    16. *
    17. * @param urlText
    18. * @desc 检测版本的url地址
    19. * @default [url]http://ycxm.coding.me/jquery/version.txt[/url]
    20. *
    21. * @param showInTitle
    22. * @desc 菜单是否显示版本检查  false 不显示  true 显示
    23. * @default true
    24. *
    25. *  @param showInTitleText
    26. * @desc showInTitle为true,即要显示的标题命令文字
    27. * @default 版本检测
    28. *
    29. *  
    30. * @param urlOpen
    31. * @desc 有新版本则要打开的url地址
    32. * @default [url]http://ycxm.coding.me/jquery/version.rar[/url]
    33. *
    34. * @param startCheck
    35. * @desc 是否开始游戏就检查版本  false 不检查  true 检查
    36. * @default true
    37. *
    38. *
    39. * @help
    40. * ================================================================
    41. * 检测游戏版本
    42. * ================================================================
    43. *   依赖项:需要导入Jquery.js
    44. *
    45. *   nowVersion:当前游戏版本。
    46. *
    47. *   urlText:检测版本的url地址,代码托管网站的文件地址,得到的是版本号,不要写其他的。
    48. *   
    49. *   showInTitle:是否在标题显示版本检查这一项。  false 不显示  true 显示
    50. *
    51. *   showInTitleText:showInTitle为true时,即要显示的标题命令文字。
    52. *
    53. *   urlOpen:检测到有新版本则要打开的url地址,可打开官网之类。
    54. *
    55. *   startCheck:是否开始游戏就检查版本。   false 不检查  true 检查
    56. *
    57. *   插件命令:“命令 内容” 形式,示例如下:
    58. *       1. checkversion [url]http://ycxm.coding.me/jquery/version.txt[/url]      检测游戏版本
    59. *
    60. *       2. openurl  [url]https://www.baidu.com[/url]                             打开网址,可打开游戏官网等。
    61. *
    62. *  最后qq:1359762297
    63. *  ycx插件库:[url]https://github.com/ycxYI/plugs[/url](待更新)
    64. *
    65. */
    66.  
    67. Ycx.parameters = PluginManager.parameters('Ycx_VersionCheck');
    68. Ycx.nowVersion = String(Ycx.parameters['nowVersion'] || '1.0.0');
    69. Ycx.urlText = String(Ycx.parameters['urlText'] || 'http://ycxm.coding.me/jquery/version.txt');
    70. Ycx.showInTitle = String(Ycx.parameters['showInTitle'] || 'true');
    71. Ycx.showInTitleText = String(Ycx.parameters['showInTitleText'] || '版本检测');
    72. Ycx.urlOpen = String(Ycx.parameters['urlOpen'] || 'http://ycxm.coding.me/jquery/version.rar');
    73. Ycx.startCheck = String(Ycx.parameters['startCheck'] || 'true');
    74. //=============================================================================
    75. // SceneManager
    76. //=============================================================================
    77. SceneManager.openPopupBlockerMessage = function(){
    78.         this._scene.openPopupBlockerMessage();
    79. };
    80. //=============================================================================
    81. // Game_Interpreter
    82. //=============================================================================
    83. Ycx.CHECK.Game_Interpreter_pluginCommand =
    84.     Game_Interpreter.prototype.pluginCommand;
    85. Game_Interpreter.prototype.pluginCommand = function(command, args){
    86.     Ycx.CHECK.Game_Interpreter_pluginCommand.call(this, command, args)
    87.     if(command === 'checkversion')this.checkVersion(args);
    88.     if(command === 'openurl')this.openurl(args);
    89. };
    90. Game_Interpreter.prototype.checkVersion = function(args){
    91.     TouchInput.clear();
    92.     Input.clear();
    93.     var url = String(args[0]);
    94.     $(document).load(url, function(responseText, textStatus){
    95.         if(Ycx.nowVersion == responseText){
    96.             alert("已经是最新版本!");
    97.         }else{
    98.             if(confirm("存在最新版本是否更新?")){
    99.                 var win = window.open(url);
    100.                 if(win){
    101.                     win.focus();
    102.                 }else{
    103.                     SceneManager.openPopupBlockerMessage();
    104.                 }
    105.             }
    106.         }
    107.     });
    108. };
    109. Game_Interpreter.prototype.openurl = function(args){
    110.     TouchInput.clear();
    111.     Input.clear();
    112.     var url = String(args[0]);
    113.     var win = window.open(url);
    114.     if(win){
    115.         win.focus();
    116.     }else{
    117.         SceneManager.openPopupBlockerMessage();
    118.     }
    119. };
    120. //-----------------------------------------------------------------------------
    121. //开始检测
    122. //-----------------------------------------------------------------------------
    123. if(Ycx.startCheck == "true"){
    124.     $(document).load(Ycx.urlText, function(responseText, textStatus){
    125.         if(Ycx.nowVersion == responseText){
    126.             alert("已经是最新版本!");
    127.         }else{
    128.             if(confirm("存在最新版本是否更新?")){
    129.                 var win = window.open(Ycx.urlOpen);
    130.                 if(win){
    131.                     win.focus();
    132.                 }else{
    133.                     SceneManager.openPopupBlockerMessage();
    134.                 }
    135.             }
    136.         }
    137.     });
    138. }
    139. //-----------------------------------------------------------------------------
    140. // Scene_Title
    141. //-----------------------------------------------------------------------------
    142. Scene_Title.prototype.createCommandWindow = function(){
    143.     this._commandWindow = new Window_TitleCommand();
    144.     this._commandWindow.setHandler('newGame', this.commandNewGame.bind(this));
    145.     this._commandWindow.setHandler('continue', this.commandContinue.bind(this));
    146.     this._commandWindow.setHandler('options', this.commandOptions.bind(this));
    147.     if(Ycx.showInTitle == "true"){
    148.         this._commandWindow.setHandler('Check', this.versionCheck.bind(this));
    149.     }
    150.     this.addWindow(this._commandWindow);
    151. };
    152. Scene_Title.prototype.versionCheck = function(){
    153.     this._commandWindow.close();
    154.     $(document).load(Ycx.urlText, function(responseText, textStatus){
    155.         if(Ycx.nowVersion == responseText){
    156.             alert("已经是最新版本!");
    157.         }else{
    158.             if(confirm("存在最新版本是否更新?")){
    159.                 var win = window.open(Ycx.urlOpen);
    160.                 if(win){
    161.                     win.focus();
    162.                 }else{
    163.                     SceneManager.openPopupBlockerMessage();
    164.                 }
    165.             }
    166.         }
    167.     });
    168.     SceneManager.goto(Scene_Title);
    169. };
    170. //-----------------------------------------------------------------------------
    171. // Window_TitleCommand
    172. //-----------------------------------------------------------------------------
    173. Window_TitleCommand.prototype.makeCommandList = function(){
    174.     this.addCommand(TextManager.newGame, 'newGame');
    175.     this.addCommand(TextManager.continue_, 'continue', this.isContinueEnabled());
    176.     this.addCommand(TextManager.options, 'options');
    177.     if(Ycx.showInTitle == "true"){
    178.         this.addCommand(Ycx.showInTitleText, 'Check');
    179.     }
    180. };
    复制代码

                本帖来自P1论坛作者易大师,因Project1站服务器在国外有时候访问缓慢不方便作者交流学习,经联系P1站长fux2同意署名转载一起分享游戏制作经验,共同为国内独立游戏作者共同创造良好交流环境,原文地址:https://rpg.blue/forum.php?mod=viewthread&tid=398017  若有侵权,发帖作者可联系底部站长QQ在线咨询功能删除,谢谢。

    本帖子中包含更多资源

    您需要 登录 才可以下载或查看,没有账号?立即注册

    x
    天天去同能,天天有童年!
    回复 论坛版权

    使用道具 举报

    ahome_bigavatar:guest
    ahome_bigavatar:welcomelogin
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2024-5-20 11:30 , Processed in 0.048037 second(s), 42 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

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