|
1 | | -//============================================================================= |
2 | | -// main.js |
3 | | -//============================================================================= |
| 1 | +const $priorityScripts = [ |
| 2 | + {"name":"pixi","path":"js/libs/"}, |
| 3 | + {"name":"pixi-tilemap","path":"js/libs/"}, |
| 4 | + {"name":"lz-string","path":"js/libs/"}, |
| 5 | + {"name":"iphone-inline-video.browser","path":"js/libs/"}, |
| 6 | + |
| 7 | + {"path":"js/rpg_managers/","name":"DataManager"}, |
| 8 | + {"path":"js/rpg_managers/","name":"ConfigManager"}, |
| 9 | + {"path":"js/rpg_managers/","name":"StorageManager"}, |
| 10 | + {"path":"js/rpg_managers/","name":"ImageManager"}, |
| 11 | + {"path":"js/rpg_managers/","name":"AudioManager"}, |
| 12 | + {"path":"js/rpg_managers/","name":"SoundManager"}, |
| 13 | + {"path":"js/rpg_managers/","name":"TextManager"}, |
| 14 | + {"path":"js/rpg_managers/","name":"SceneManager"}, |
| 15 | + {"path":"js/rpg_managers/","name":"BattleManager"}, |
| 16 | + {"path":"js/rpg_managers/","name":"PluginManager"}, |
4 | 17 |
|
5 | | -PluginManager.setup($plugins); |
| 18 | + {"path":"js/rpg_objects/","name":"Game_Temp"}, |
| 19 | + {"path":"js/rpg_objects/","name":"Game_System"}, |
| 20 | + {"path":"js/rpg_objects/","name":"Game_Timer"}, |
| 21 | + {"path":"js/rpg_objects/","name":"Game_Message"}, |
| 22 | + {"path":"js/rpg_objects/","name":"Game_Switches"}, |
| 23 | + {"path":"js/rpg_objects/","name":"Game_Variables"}, |
| 24 | + {"path":"js/rpg_objects/","name":"Game_SelfSwitches"}, |
| 25 | + {"path":"js/rpg_objects/","name":"Game_Screen"}, |
| 26 | + {"path":"js/rpg_objects/","name":"Game_Picture"}, |
| 27 | + {"path":"js/rpg_objects/","name":"Game_Item"}, |
| 28 | + {"path":"js/rpg_objects/","name":"Game_Action"}, |
| 29 | + {"path":"js/rpg_objects/","name":"Game_ActionResult"}, |
| 30 | + {"path":"js/rpg_objects/","name":"Game_BattlerBase"}, |
| 31 | + {"path":"js/rpg_objects/","name":"Game_Battler"}, |
| 32 | + {"path":"js/rpg_objects/","name":"Game_Actor"}, |
| 33 | + {"path":"js/rpg_objects/","name":"Game_Enemy"}, |
| 34 | + {"path":"js/rpg_objects/","name":"Game_Actors"}, |
| 35 | + {"path":"js/rpg_objects/","name":"Game_Unit"}, |
| 36 | + {"path":"js/rpg_objects/","name":"Game_Party"}, |
| 37 | + {"path":"js/rpg_objects/","name":"Game_Troop"}, |
| 38 | + {"path":"js/rpg_objects/","name":"Game_Map"}, |
| 39 | + {"path":"js/rpg_objects/","name":"Game_CommonEvent"}, |
| 40 | + {"path":"js/rpg_objects/","name":"Game_CharacterBase"}, |
| 41 | + {"path":"js/rpg_objects/","name":"Game_Character"}, |
| 42 | + {"path":"js/rpg_objects/","name":"Game_Player"}, |
| 43 | + {"path":"js/rpg_objects/","name":"Game_Follower"}, |
| 44 | + {"path":"js/rpg_objects/","name":"Game_Followers"}, |
| 45 | + {"path":"js/rpg_objects/","name":"Game_Vehicle"}, |
| 46 | + {"path":"js/rpg_objects/","name":"Game_Event"}, |
| 47 | + {"path":"js/rpg_objects/","name":"Game_Interpreter"}, |
6 | 48 |
|
7 | | -window.onload = function() { |
8 | | - SceneManager.run(Scene_Boot); |
| 49 | + {"path":"js/rpg_scenes/","name":"","name":"Scene_Base"}, |
| 50 | + {"path":"js/rpg_scenes/","name":"Scene_Boot"}, |
| 51 | + {"path":"js/rpg_scenes/","name":"Scene_Title"}, |
| 52 | + {"path":"js/rpg_scenes/","name":"Scene_Map"}, |
| 53 | + {"path":"js/rpg_scenes/","name":"Scene_MenuBase"}, |
| 54 | + {"path":"js/rpg_scenes/","name":"Scene_Menu"}, |
| 55 | + {"path":"js/rpg_scenes/","name":"Scene_ItemBase"}, |
| 56 | + {"path":"js/rpg_scenes/","name":"Scene_Item"}, |
| 57 | + {"path":"js/rpg_scenes/","name":"Scene_Skill"}, |
| 58 | + {"path":"js/rpg_scenes/","name":"Scene_Equip"}, |
| 59 | + {"path":"js/rpg_scenes/","name":"Scene_Status"}, |
| 60 | + {"path":"js/rpg_scenes/","name":"Scene_Options"}, |
| 61 | + {"path":"js/rpg_scenes/","name":"Scene_File"}, |
| 62 | + {"path":"js/rpg_scenes/","name":"Scene_Save"}, |
| 63 | + {"path":"js/rpg_scenes/","name":"Scene_Load"}, |
| 64 | + {"path":"js/rpg_scenes/","name":"Scene_GameEnd"}, |
| 65 | + {"path":"js/rpg_scenes/","name":"Scene_Shop"}, |
| 66 | + {"path":"js/rpg_scenes/","name":"Scene_Name"}, |
| 67 | + {"path":"js/rpg_scenes/","name":"Scene_Debug"}, |
| 68 | + {"path":"js/rpg_scenes/","name":"Scene_Battle"}, |
| 69 | + {"path":"js/rpg_scenes/","name":"Scene_Gameover"}, |
| 70 | + |
| 71 | + {"path":"js/rpg_sprites/","name":"","name":"Sprite_Base"}, |
| 72 | + {"path":"js/rpg_sprites/","name":"Sprite_Button"}, |
| 73 | + {"path":"js/rpg_sprites/","name":"Sprite_Character"}, |
| 74 | + {"path":"js/rpg_sprites/","name":"Sprite_Battler"}, |
| 75 | + {"path":"js/rpg_sprites/","name":"Sprite_Actor"}, |
| 76 | + {"path":"js/rpg_sprites/","name":"Sprite_Enemy"}, |
| 77 | + {"path":"js/rpg_sprites/","name":"Sprite_Animation"}, |
| 78 | + {"path":"js/rpg_sprites/","name":"","name":"Sprite_Damage"}, |
| 79 | + {"path":"js/rpg_sprites/","name":"Sprite_StateIcon"}, |
| 80 | + {"path":"js/rpg_sprites/","name":"Sprite_StateOverlay"}, |
| 81 | + {"path":"js/rpg_sprites/","name":"Sprite_Weapon"}, |
| 82 | + {"path":"js/rpg_sprites/","name":"Sprite_Balloon"}, |
| 83 | + {"path":"js/rpg_sprites/","name":"Sprite_Picture"}, |
| 84 | + {"path":"js/rpg_sprites/","name":"Sprite_Timer"}, |
| 85 | + {"path":"js/rpg_sprites/","name":"Sprite_Destination"}, |
| 86 | + {"path":"js/rpg_sprites/","name":"Spriteset_Base"}, |
| 87 | + {"path":"js/rpg_sprites/","name":"Spriteset_Map"}, |
| 88 | + {"path":"js/rpg_sprites/","name":"Spriteset_Battle"}, |
| 89 | + |
| 90 | + {"path":"js/rpg_windows/","name":"Window_Base"}, |
| 91 | + {"path":"js/rpg_windows/","name":"Window_Selectable"}, |
| 92 | + {"path":"js/rpg_windows/","name":"Window_Command"}, |
| 93 | + {"path":"js/rpg_windows/","name":"Window_HorzCommand"}, |
| 94 | + {"path":"js/rpg_windows/","name":"Window_Help"}, |
| 95 | + {"path":"js/rpg_windows/","name":"Window_Gold"}, |
| 96 | + {"path":"js/rpg_windows/","name":"Window_MenuCommand"}, |
| 97 | + {"path":"js/rpg_windows/","name":"Window_MenuStatus"}, |
| 98 | + {"path":"js/rpg_windows/","name":"Window_MenuActor"}, |
| 99 | + {"path":"js/rpg_windows/","name":"Window_ItemCategory"}, |
| 100 | + {"path":"js/rpg_windows/","name":"","name":"Window_ItemList"}, |
| 101 | + {"path":"js/rpg_windows/","name":"Window_SkillType"}, |
| 102 | + {"path":"js/rpg_windows/","name":"","name":"Window_SkillStatus"}, |
| 103 | + {"path":"js/rpg_windows/","name":"Window_SkillList"}, |
| 104 | + {"path":"js/rpg_windows/","name":"Window_EquipStatus"}, |
| 105 | + {"path":"js/rpg_windows/","name":"Window_EquipCommand"}, |
| 106 | + {"path":"js/rpg_windows/","name":"Window_EquipSlot"}, |
| 107 | + {"path":"js/rpg_windows/","name":"","name":"Window_EquipItem"}, |
| 108 | + {"path":"js/rpg_windows/","name":"Window_Status"}, |
| 109 | + {"path":"js/rpg_windows/","name":"Window_Options"}, |
| 110 | + {"path":"js/rpg_windows/","name":"Window_SavefileList"}, |
| 111 | + {"path":"js/rpg_windows/","name":"Window_ShopCommand"}, |
| 112 | + {"path":"js/rpg_windows/","name":"Window_ShopBuy"}, |
| 113 | + {"path":"js/rpg_windows/","name":"Window_ShopSell"}, |
| 114 | + {"path":"js/rpg_windows/","name":"Window_ShopNumber"}, |
| 115 | + {"path":"js/rpg_windows/","name":"Window_ShopStatus"}, |
| 116 | + {"path":"js/rpg_windows/","name":"Window_NameEdit"}, |
| 117 | + {"path":"js/rpg_windows/","name":"Window_NameInput"}, |
| 118 | + {"path":"js/rpg_windows/","name":"Window_ChoiceList"}, |
| 119 | + {"path":"js/rpg_windows/","name":"Window_NumberInput"}, |
| 120 | + {"path":"js/rpg_windows/","name":"Window_EventItem"}, |
| 121 | + {"path":"js/rpg_windows/","name":"Window_Message"}, |
| 122 | + {"path":"js/rpg_windows/","name":"Window_ScrollText"}, |
| 123 | + {"path":"js/rpg_windows/","name":"Window_MapName"}, |
| 124 | + {"path":"js/rpg_windows/","name":"Window_BattleLog"}, |
| 125 | + {"path":"js/rpg_windows/","name":"Window_PartyCommand"}, |
| 126 | + {"path":"js/rpg_windows/","name":"Window_ActorCommand"}, |
| 127 | + {"path":"js/rpg_windows/","name":"Window_BattleStatus"}, |
| 128 | + {"path":"js/rpg_windows/","name":"Window_BattleActor"}, |
| 129 | + {"path":"js/rpg_windows/","name":"Window_BattleEnemy"}, |
| 130 | + {"path":"js/rpg_windows/","name":"Window_BattleSkill"}, |
| 131 | + {"path":"js/rpg_windows/","name":"Window_BattleItem"}, |
| 132 | + {"path":"js/rpg_windows/","name":"","name":"Window_TitleCommand"}, |
| 133 | + {"path":"js/rpg_windows/","name":"Window_GameEnd"}, |
| 134 | + {"path":"js/rpg_windows/","name":"","name":"Window_DebugRange"}, |
| 135 | + {"path":"js/rpg_windows/","name":"Window_DebugEdit"}, |
| 136 | + |
| 137 | + {"path":"js/rpg_core/","name":"ProgressWatcher"}, |
| 138 | + {"path":"js/rpg_core/","name":"JsExtensions"}, |
| 139 | + {"path":"js/rpg_core/","name":"Utils"}, |
| 140 | + {"path":"js/rpg_core/","name":"CacheEntry"}, |
| 141 | + {"path":"js/rpg_core/","name":"CacheMap"}, |
| 142 | + {"path":"js/rpg_core/","name":"ImageCache"}, |
| 143 | + {"path":"js/rpg_core/","name":"RequestQueue"}, |
| 144 | + {"path":"js/rpg_core/","name":"Point"}, |
| 145 | + {"path":"js/rpg_core/","name":"Rectangle"}, |
| 146 | + {"path":"js/rpg_core/","name":"Bitmap"}, |
| 147 | + {"path":"js/rpg_core/","name":"Graphics"}, |
| 148 | + {"path":"js/rpg_core/","name":"Input"}, |
| 149 | + {"path":"js/rpg_core/","name":"TouchInput"}, |
| 150 | + {"path":"js/rpg_core/","name":"Sprite"}, |
| 151 | + {"path":"js/rpg_core/","name":"Tilemap"}, |
| 152 | + {"path":"js/rpg_core/","name":"ShaderTilemap"}, |
| 153 | + {"path":"js/rpg_core/","name":"TilingSprite"}, |
| 154 | + {"path":"js/rpg_core/","name":"ScreenSprite"}, |
| 155 | + {"path":"js/rpg_core/","name":"Window"}, |
| 156 | + {"path":"js/rpg_core/","name":"WindowLayer"}, |
| 157 | + {"path":"js/rpg_core/","name":"Weather"}, |
| 158 | + {"path":"js/rpg_core/","name":"ToneFilter"}, |
| 159 | + {"path":"js/rpg_core/","name":"ToneSprite"}, |
| 160 | + {"path":"js/rpg_core/","name":"Stage"}, |
| 161 | + {"path":"js/rpg_core/","name":"WebAudio"}, |
| 162 | + {"path":"js/rpg_core/","name":"Html5Audio"}, |
| 163 | + {"path":"js/rpg_core/","name":"JsonEx"}, |
| 164 | + {"path":"js/rpg_core/","name":"Decrypter"}, |
| 165 | + {"path":"js/rpg_core/","name":"ResourceHandler"} |
| 166 | + |
| 167 | +]; |
| 168 | + |
| 169 | +//----------------------------------------------------------------------------- |
| 170 | +// PluginManager |
| 171 | +// |
| 172 | +// The static class that manages the plugins. |
| 173 | + |
| 174 | +function PluginManager() { |
| 175 | + throw new Error('This is a static class'); |
| 176 | +} |
| 177 | + |
| 178 | +PluginManager._path = 'js/plugins/'; |
| 179 | +PluginManager._scripts = []; |
| 180 | +PluginManager._errorUrls = []; |
| 181 | +PluginManager._parameters = {}; |
| 182 | +PluginManager._scriptsToLoadLength = $priorityScripts.length + $plugins.filter((plugin) => plugin.status === true).length; |
| 183 | +PluginManager._scriptsLoadedLength = 0; |
| 184 | + |
| 185 | +PluginManager.init = function(priorities, plugins) { |
| 186 | + PluginManager.setupCounter(); |
| 187 | + PluginManager.setupPriorities(priorities); |
| 188 | + window.setTimeout( () => PluginManager.setup(plugins), 10); |
| 189 | +}; |
| 190 | + |
| 191 | +PluginManager.setupCounter = function() { |
| 192 | + var counter = document.createElement('div'); |
| 193 | + var counterInner = document.createElement('div'); |
| 194 | + var counterSpan = document.createElement('span'); |
| 195 | + counter.id = "counter"; |
| 196 | + counterInner.id = 'counter--inner'; |
| 197 | + counterInner.innerHTML = "Loading "; |
| 198 | + counterSpan.id = 'counter--count'; |
| 199 | + counterSpan.innerHTML = '1%'; |
| 200 | + counter.appendChild(counterInner); |
| 201 | + counterInner.appendChild(counterSpan); |
| 202 | + document.body.appendChild(counter); |
| 203 | +}; |
| 204 | + |
| 205 | +PluginManager.updateCounter = function() { |
| 206 | + var counter = document.getElementById('counter--count'); |
| 207 | + if (counter) counter.innerHTML = Math.floor((this._scriptsLoadedLength / this._scriptsToLoadLength) * 100) + '%'; |
| 208 | +}; |
| 209 | + |
| 210 | +PluginManager.removeCounter = function() { |
| 211 | + var counter = document.getElementById('counter'); |
| 212 | + document.body.removeChild(counter); |
| 213 | +}; |
| 214 | + |
| 215 | +PluginManager.setupPriorities = function(scripts) { |
| 216 | + $priorityScripts.forEach(function(script) { |
| 217 | + this.loadScript(script.name + '.js', script.path); |
| 218 | + this._scripts.push(script.name); |
| 219 | + }, this); |
9 | 220 | }; |
| 221 | + |
| 222 | +PluginManager.setup = function(plugins) { |
| 223 | + plugins.forEach(function(plugin) { |
| 224 | + if (plugin.status && !this._scripts.includes(plugin.name)) { |
| 225 | + this.setParameters(plugin.name, plugin.parameters); |
| 226 | + this.loadScript(plugin.name + '.js'); |
| 227 | + this._scripts.push(plugin.name); |
| 228 | + } |
| 229 | + }, this); |
| 230 | +}; |
| 231 | + |
| 232 | +PluginManager.checkErrors = function() { |
| 233 | + var url = this._errorUrls.shift(); |
| 234 | + if (url) { |
| 235 | + throw new Error('Failed to load: ' + url); |
| 236 | + } |
| 237 | +}; |
| 238 | + |
| 239 | +PluginManager.parameters = function(name) { |
| 240 | + return this._parameters[name.toLowerCase()] || {}; |
| 241 | +}; |
| 242 | + |
| 243 | +PluginManager.setParameters = function(name, parameters) { |
| 244 | + this._parameters[name.toLowerCase()] = parameters; |
| 245 | +}; |
| 246 | + |
| 247 | +PluginManager.loadScript = function(name, path) { |
| 248 | + var url; |
| 249 | + var script = document.createElement('script'); |
| 250 | + if (path) { |
| 251 | + url = path + name; |
| 252 | + } else { |
| 253 | + url = this._path + name; |
| 254 | + } |
| 255 | + script.type = 'text/javascript'; |
| 256 | + script.src = url; |
| 257 | + script.async = false; |
| 258 | + script.onerror = this.onError.bind(this); |
| 259 | + script.onload = this.onLoad.bind(this); |
| 260 | + script._url = url; |
| 261 | + document.body.appendChild(script); |
| 262 | +}; |
| 263 | + |
| 264 | +PluginManager.onError = function(e) { |
| 265 | + this._errorUrls.push(e.target._url); |
| 266 | +}; |
| 267 | + |
| 268 | +PluginManager.onLoad = function(e) { |
| 269 | + this._scriptsLoadedLength++; |
| 270 | + this.updateCounter(); |
| 271 | + if (this._scriptsLoadedLength === this._scriptsToLoadLength) { |
| 272 | + this.removeCounter(); |
| 273 | + PIXI.settings.SCALE_MODE = PIXI.SCALE_MODES.NEAREST; |
| 274 | + PIXI.settings.ROUND_PIXELS = true; |
| 275 | + SceneManager.run(Scene_Boot); |
| 276 | + } |
| 277 | +}; |
| 278 | + |
| 279 | +PluginManager.init($priorityScripts, $plugins); |
0 commit comments