STV_StageSelector


SUBMITTED BY: uuuuuu

DATE: Oct. 24, 2016, 7:04 p.m.

FORMAT: Text only

SIZE: 29.8 kB

HITS: 187

  1. //=============================================================================
  2. // STV_StageSelector.js
  3. //=============================================================================
  4. /*:
  5. * @plugindesc v1.1 - STV_StageSelector
  6. * || This will add a level selector to your Project
  7. * @author SkottyTV || Special Thanks: Lantiz
  8. *
  9. * @param ----- Window -----
  10. *
  11. * @param Show Window
  12. * @desc Show or Hide Window Skin
  13. * TRUE = show window / FALSE = hide window
  14. * @default TRUE
  15. *
  16. * @param Background Picture
  17. * @desc The Background Picture in img/pictures/
  18. * (leave empty for no Background Picture)
  19. * @default
  20. *
  21. * @param Backbar Color
  22. * @desc The default Backbar Color
  23. * (default 15)
  24. * @default 15
  25. *
  26. * @param ----- Text -----
  27. *
  28. * @param Chapter Text
  29. * @desc Default Text for "Chapter"
  30. * @default Chapter
  31. *
  32. * @param Transfer Text
  33. * @desc Default Text for "Start"
  34. * @default Transfer
  35. *
  36. * @param Back Text
  37. * @desc Default Text for "Back"
  38. * @default Back
  39. *
  40. * @param Info Text
  41. * @desc Default Text for "Info"
  42. * @default Info
  43. *
  44. * @param ----- Icons -----
  45. *
  46. * @param Completed Icon
  47. * @desc Default Icon for completed levels
  48. * @default 87
  49. *
  50. * @param --- Functions ---
  51. *
  52. * @param Show Level ID
  53. * @desc Show Level ID in front of name
  54. * TRUE = show, FALSE = hide
  55. * @default TRUE
  56. *
  57. * @param Transfer Direction
  58. * @desc Direction the Player looks after Transfer
  59. * 2 = down, 4 = left, 6 = right, 8 = up, 0 = as before
  60. * @default 0
  61. *
  62. * @param Transfer Type
  63. * @desc The Type of the Transfer
  64. * 0 = Fade Black, 1 = Fade White, 2 = none/instant
  65. * @default 0
  66. *
  67. * @help
  68. *
  69. * ////////////////////////////////////////////////////////////////////////////
  70. * ----------------------------- Terms of Usage: ------------------------------
  71. * ////////////////////////////////////////////////////////////////////////////
  72. * Feel free to use this Plugin in 1. Non-Commercial Games, 2. Commercial Games
  73. * However it would be nice to give proper Credits to "SkottyTV"
  74. * Also a free copy of your Game would be a nice move :)
  75. *
  76. * Many Thanks to the Forum User "Lantiz" !
  77. *
  78. * Have Fun And Enjoy! :)
  79. *
  80. *
  81. *
  82. * ////////////////////////////////////////////////////////////////////////////
  83. * --------------------------------- Updates:----------------------------------
  84. * ////////////////////////////////////////////////////////////////////////////
  85. *
  86. * Update v1.0
  87. * - Basic Functionality
  88. * - Bug fixes
  89. * - upgrades
  90. *
  91. * Updated v1.1
  92. * - Bug Fixes
  93. *
  94. *
  95. * ////////////////////////////////////////////////////////////////////////////
  96. * -------------------------------- Commands: ---------------------------------
  97. * ////////////////////////////////////////////////////////////////////////////
  98. * Plugin Command:
  99. * StageSelector open # Opens the Stage Selector.
  100. * StageSelector reveal 1 3 # Shows Stage 1 Level 3 inside StageSelector.
  101. * StageSelector complete 2 5 # Completes Level 5 of Stage 2.
  102. *
  103. * Event Note:
  104. * <STVSS start> # This Event will be the start position
  105. * of the Player after the Transfer.
  106. * Map Note:
  107. * <STVSS Stage: 1,4> # This Map will be Stage 1, Level 4.
  108. * <STVSS Info> # Start of all Infos.
  109. * Some Info here # The Info Text.
  110. * </STVSS Info> # End of all Infos.
  111. *
  112. *
  113. * ////////////////////////////////////////////////////////////////////////////
  114. * -------------------------- Examples / Tutorials: ---------------------------
  115. * ////////////////////////////////////////////////////////////////////////////
  116. *
  117. * For a Map notebox it could look like this:
  118. *
  119. * <STVSS Stage: 1,3>
  120. * <STVSS Info>
  121. * This is Stage 1 Level 3.
  122. * This is some colored \c[2]Info \c[0]Text.
  123. * You can even put Variables \V[1] here!
  124. * </STVSS Info>
  125. *
  126. *
  127. */
  128. // ----------------------------------------------------------------------------------------------------------------------------
  129. // STV_SkillSystem Parameters
  130. // ----------------------------------------------------------------------------------------------------------------------------
  131. var stv_StageSelector_parameters = PluginManager.parameters('STV_StageSelector');
  132. // ----- Window -----
  133. var stv_StageSelector_showWindow = String(stv_StageSelector_parameters['Show Window'] || 'TRUE');
  134. var stv_StageSelector_bgPicture = String(stv_StageSelector_parameters['Background Picture'] || '');
  135. var stv_StageSelector_backBarColor = Number(stv_StageSelector_parameters['Backbar Color'] || 15);
  136. // ----- Text -----
  137. var stv_StageSelector_chapterText = String(stv_StageSelector_parameters['Chapter Text'] || 'Chapter');
  138. var stv_StageSelector_transferText = String(stv_StageSelector_parameters['Transfer Text'] || 'Transfer');
  139. var stv_StageSelector_backText = String(stv_StageSelector_parameters['Back Text'] || 'Back');
  140. var stv_StageSelector_descText = String(stv_StageSelector_parameters['Info Text'] || 'Info');
  141. // --- Icons ---
  142. var stv_StageSelector_completedIcon = Number(stv_StageSelector_parameters['Completed Icon'] || 87);
  143. // --- Functions ---
  144. var stv_StageSelector_showLevelId = String(stv_StageSelector_parameters['Show Level ID'] || 'TRUE');
  145. var stv_StageSelector_transferDirection = Number(stv_StageSelector_parameters['Transfer Direction'] || 0);
  146. var stv_StageSelector_transferType = Number(stv_StageSelector_parameters['Transfer Type'] || 0);
  147. // ----------------------------------------------------------------------------------------------------------------------------
  148. // Scene MonsterCardsManager create
  149. // ----------------------------------------------------------------------------------------------------------------------------
  150. Scene_StageSelector = function() {
  151. this.initialize.apply(this, arguments);
  152. };
  153. Scene_StageSelector.prototype = Object.create(Scene_MenuBase.prototype);
  154. Scene_StageSelector.prototype.constructor = Scene_StageSelector;
  155. Scene_StageSelector.prototype.initialize = function() {
  156. Scene_MenuBase.prototype.initialize.call(this);
  157. };
  158. Scene_StageSelector.prototype.createBackground = function() {
  159. this._backgroundSprite = new Sprite();
  160. this._backgroundSprite.move(0, 0, Graphics.width, Graphics.height);
  161. this._backgroundSprite.bitmap = SceneManager.backgroundBitmap();
  162. this.addChild(this._backgroundSprite);
  163. if (stv_StageSelector_bgPicture){
  164. this._foregroundSprite = new Sprite();
  165. this._foregroundSprite.move(0, 0, Graphics.width, Graphics.height);
  166. this._foregroundSprite.bitmap = ImageManager.loadPicture(stv_StageSelector_bgPicture);
  167. this.addChild(this._foregroundSprite);
  168. }
  169. };
  170. Scene_StageSelector.prototype.create = function() {
  171. Scene_MenuBase.prototype.create.call(this);
  172. this.createWindowPositions();
  173. this.createChapterWindow();
  174. this.createLevelWindow();
  175. this.createInfoWindow();
  176. this.createCommandWindow();
  177. if(stv_StageSelector_showWindow != "TRUE"){
  178. this._chapterWindow.opacity = 0;
  179. this._levelWindow.opacity = 0;
  180. this._infoWindow.opacity = 0;
  181. this._commandWindow.opacity = 0;
  182. }
  183. };
  184. // ----------------------------------------------------------------------------------------------------------------------------
  185. // Create Window Positions
  186. // ----------------------------------------------------------------------------------------------------------------------------
  187. Scene_StageSelector.prototype.createWindowPositions = function() {
  188. var maxWidth = Graphics.boxWidth,
  189. maxHeight = Graphics.boxHeight;
  190. var cX = 0,
  191. cY = 0,
  192. cW = maxWidth,
  193. cH = (maxHeight/4);
  194. this._chapterWindow = new Window_StageSelector_Chapter(cX, cY, cW, cH);
  195. var lX = cX,
  196. lY = cH,
  197. lW = cW/3,
  198. lH = maxHeight-cH;
  199. this._levelWindow = new Window_StageSelector_Level(lX, lY, lW, lH);
  200. var iX = lW,
  201. iY = lY,
  202. iW = cW-lW,
  203. iH = lH;
  204. this._infoWindow = new Window_StageSelector_Info(iX, iY, iW, iH);
  205. var hX = iX,
  206. hY = maxHeight - 75,
  207. hW = iW,
  208. hH = 75;
  209. this._commandWindow = new Window_StageSelector_Command(hX, hY, hW, hH);
  210. };
  211. // ----------------------------------------------------------------------------------------------------------------------------
  212. // Refresh Windows
  213. // ----------------------------------------------------------------------------------------------------------------------------
  214. Scene_StageSelector.prototype.refreshWindows = function() {
  215. this._chapterWindow.refresh();
  216. this._levelWindow.refresh();
  217. this._infoWindow.refresh();
  218. this._commandWindow.refresh();
  219. };
  220. // ----------------------------------------------------------------------------------------------------------------------------
  221. // Setup Chapter Window
  222. // ----------------------------------------------------------------------------------------------------------------------------
  223. Scene_StageSelector.prototype.createChapterWindow = function() {
  224. this._chapterWindow.setHandler('ok', this.selectChapter.bind(this));
  225. this._chapterWindow.setHandler('cancel', this.popScene.bind(this));
  226. this._chapterWindow.setLevelWindow(this._levelWindow);
  227. this.addWindow(this._chapterWindow);
  228. this._chapterWindow.activate();
  229. };
  230. // ----------------------------------------------------------------------------------------------------------------------------
  231. // Setup Level Window
  232. // ----------------------------------------------------------------------------------------------------------------------------
  233. Scene_StageSelector.prototype.createLevelWindow = function() {
  234. this._levelWindow.setHandler('ok', this.selectLevel.bind(this));
  235. this._levelWindow.setHandler('cancel', this.cancelLevel.bind(this));
  236. this._levelWindow.setInfoWindow(this._infoWindow);
  237. this.addWindow(this._levelWindow);
  238. };
  239. // ----------------------------------------------------------------------------------------------------------------------------
  240. // Setup Info Window
  241. // ----------------------------------------------------------------------------------------------------------------------------
  242. Scene_StageSelector.prototype.createInfoWindow = function() {
  243. this.addWindow(this._infoWindow);
  244. };
  245. // ----------------------------------------------------------------------------------------------------------------------------
  246. // Setup Command Window
  247. // ----------------------------------------------------------------------------------------------------------------------------
  248. Scene_StageSelector.prototype.createCommandWindow = function() {
  249. this._commandWindow.setHandler('start', this.startLevel.bind(this));
  250. this._commandWindow.setHandler('cancel', this.cancelCommand.bind(this));
  251. this.addWindow(this._commandWindow);
  252. this._commandWindow.deactivate();
  253. this._commandWindow.hide();
  254. };
  255. // ----------------------------------------------------------------------------------------------------------------------------
  256. // On Chapter Select
  257. // ----------------------------------------------------------------------------------------------------------------------------
  258. Scene_StageSelector.prototype.selectChapter = function() {
  259. if (this._chapterWindow._list[0]) {
  260. this._chapterWindow.deactivate();
  261. this._levelWindow.activate();
  262. } else {
  263. this.popScene();
  264. }
  265. };
  266. // ----------------------------------------------------------------------------------------------------------------------------
  267. // On Level Select
  268. // ----------------------------------------------------------------------------------------------------------------------------
  269. Scene_StageSelector.prototype.selectLevel = function() {
  270. this._levelWindow.deactivate();
  271. this._commandWindow.show();
  272. this._commandWindow.activate();
  273. };
  274. // ----------------------------------------------------------------------------------------------------------------------------
  275. // On Start Select
  276. // ----------------------------------------------------------------------------------------------------------------------------
  277. Scene_StageSelector.prototype.startLevel = function() {
  278. this.popScene();
  279. $stv_stageselector.transfer($stv_stageselector.selectedLevel);
  280. };
  281. // ----------------------------------------------------------------------------------------------------------------------------
  282. // On Command Cancel
  283. // ----------------------------------------------------------------------------------------------------------------------------
  284. Scene_StageSelector.prototype.cancelCommand = function() {
  285. this._commandWindow.deactivate();
  286. this._commandWindow.hide();
  287. this._levelWindow.activate();
  288. };
  289. // ----------------------------------------------------------------------------------------------------------------------------
  290. // On Level Cancel
  291. // ----------------------------------------------------------------------------------------------------------------------------
  292. Scene_StageSelector.prototype.cancelLevel = function() {
  293. this._chapterWindow.activate();
  294. this._levelWindow.deactivate();
  295. this._levelWindow.select(0);
  296. };
  297. // ----------------------------------------------------------------------------------------------------------------------------
  298. // Fill Chapter Window
  299. // ----------------------------------------------------------------------------------------------------------------------------
  300. function Window_StageSelector_Chapter() {
  301. this.initialize.apply(this, arguments);
  302. }
  303. Window_StageSelector_Chapter.prototype = Object.create(Window_Selectable.prototype);
  304. Window_StageSelector_Chapter.prototype.constructor = Window_StageSelector_Chapter;
  305. Window_StageSelector_Chapter.lastTopRow = 0;
  306. Window_StageSelector_Chapter.lastIndex = 0;
  307. Window_StageSelector_Chapter.prototype.initialize = function(x, y, width, height) {
  308. Window_Selectable.prototype.initialize.call(this, x, y, width, height);
  309. this.refresh();
  310. this.setTopRow(Window_StageSelector_Chapter.lastTopRow);
  311. this.select(Window_StageSelector_Chapter.lastIndex);
  312. };
  313. Window_StageSelector_Chapter.prototype.maxCols = function() {
  314. return 4;
  315. };
  316. Window_StageSelector_Chapter.prototype.maxItems = function() {
  317. return this._list ? this._list.length : 0;
  318. };
  319. Window_StageSelector_Chapter.prototype.update = function() {
  320. Window_Selectable.prototype.update.call(this);
  321. this.updateStatus();
  322. };
  323. Window_StageSelector_Chapter.prototype.refresh = function() {
  324. this._list = [];
  325. for (var i = 1; i < $stv_stageselector._stageList.length; i++) {
  326. var stage = $stv_stageselector._stageList[i];
  327. for (var j = 1; j < stage.length; j++) {
  328. if (stage[j]._revealed) {
  329. this._list.push(stage);
  330. break;
  331. }
  332. }
  333. }
  334. this.contents.clear();
  335. this.drawAllItems();
  336. };
  337. Window_StageSelector_Chapter.prototype.drawItem = function(index) {
  338. var stage = this._list[index],
  339. rect = this.itemRect(index);
  340. this.drawText(stv_StageSelector_chapterText + " " + stage[0], rect.x, rect.y, rect.width, 'center');
  341. };
  342. Window_StageSelector_Chapter.prototype.setLevelWindow = function(window) {
  343. this._levelWindow = window;
  344. this.updateStatus();
  345. };
  346. Window_StageSelector_Chapter.prototype.updateStatus = function() {
  347. var chapter = this._list[this.index()];
  348. $stv_stageselector.selectedChapter = chapter;
  349. if (this._levelWindow) this._levelWindow.setChapter(chapter);
  350. };
  351. // ----------------------------------------------------------------------------------------------------------------------------
  352. // Fill Level Window
  353. // ----------------------------------------------------------------------------------------------------------------------------
  354. function Window_StageSelector_Level() {
  355. this.initialize.apply(this, arguments);
  356. }
  357. Window_StageSelector_Level.prototype = Object.create(Window_Selectable.prototype);
  358. Window_StageSelector_Level.prototype.constructor = Window_StageSelector_Level;
  359. Window_StageSelector_Level.lastTopRow = 0;
  360. Window_StageSelector_Level.lastIndex = 0;
  361. Window_StageSelector_Level.prototype.initialize = function(x, y, width, height) {
  362. Window_Selectable.prototype.initialize.call(this, x, y, width, height);
  363. this.setTopRow(Window_StageSelector_Level.lastTopRow);
  364. this.select(Window_StageSelector_Level.lastIndex);
  365. };
  366. Window_StageSelector_Level.prototype.maxCols = function() {
  367. return 1;
  368. };
  369. Window_StageSelector_Level.prototype.maxItems = function() {
  370. return this._list ? this._list.length : 0;
  371. };
  372. Window_StageSelector_Level.prototype.update = function() {
  373. Window_Selectable.prototype.update.call(this);
  374. this.updateStatus();
  375. };
  376. Window_StageSelector_Level.prototype.refresh = function() {
  377. this._list = [];
  378. if (this._chapter) {
  379. for (var i = 1; i < this._chapter.length; i++) {
  380. var level = this._chapter[i];
  381. if (level._revealed) this._list.push(level);
  382. }
  383. this.contents.clear();
  384. this.drawAllItems();
  385. }
  386. };
  387. Window_StageSelector_Level.prototype.drawItem = function(index) {
  388. var level = this._list[index],
  389. rect = this.itemRect(index),
  390. levelNr = "";
  391. if (stv_StageSelector_showLevelId == "TRUE") levelNr = "%1: ".format((level._levelId).padZero(3));
  392. this.drawText(levelNr, rect.x, rect.y);
  393. this.drawText(level.displayName, rect.x + this.textWidth(levelNr), rect.y, this.contents.width - 40 - this.textWidth(levelNr));
  394. if (level._completed) this.drawIcon(stv_StageSelector_completedIcon, rect.x + rect.width - 32, rect.y + 2, "center");
  395. };
  396. Window_StageSelector_Level.prototype.setChapter = function(chapter) {
  397. this._chapter = chapter;
  398. this.refresh();
  399. };
  400. Window_StageSelector_Level.prototype.setInfoWindow = function(window) {
  401. this._infoWindow = window;
  402. this.updateStatus();
  403. };
  404. Window_StageSelector_Level.prototype.updateStatus = function() {
  405. var level = this._list[this.index()];
  406. $stv_stageselector.selectedLevel = level;
  407. if (this._infoWindow) this._infoWindow.setLevel(level);
  408. };
  409. // ----------------------------------------------------------------------------------------------------------------------------
  410. // Fill Info Window
  411. // ----------------------------------------------------------------------------------------------------------------------------
  412. function Window_StageSelector_Info() {
  413. this.initialize.apply(this, arguments);
  414. }
  415. Window_StageSelector_Info.prototype = Object.create(Window_Base.prototype);
  416. Window_StageSelector_Info.prototype.constructor = Window_StageSelector_Info;
  417. Window_StageSelector_Info.prototype.initialize = function(x, y, width, height) {
  418. Window_Base.prototype.initialize.call(this, x, y, width, height);
  419. };
  420. Window_StageSelector_Info.prototype.update = function() {
  421. Window_Base.prototype.update.call(this);
  422. };
  423. Window_StageSelector_Info.prototype.setLevel = function(level) {
  424. this._level = level;
  425. this.refresh();
  426. };
  427. Window_StageSelector_Info.prototype.drawHead = function() {
  428. this.contents.clear();
  429. this.contents.paintOpacity = 180;
  430. this.contents.fillRect(0, 0, this.contents.width, this.lineHeight(), this.textColor(stv_StageSelector_backBarColor));
  431. this.contents.paintOpacity = 255;
  432. if (this._level._completed) {
  433. this.drawIcon(stv_StageSelector_completedIcon, 0, 2);
  434. this.drawIcon(stv_StageSelector_completedIcon, this.contents.width - 32, 2);
  435. }
  436. this.drawText(this._level.displayName, (this.contents.width/2) - (this.textWidth(this._level.displayName)/2), 0);
  437. };
  438. Window_StageSelector_Info.prototype.drawDesc = function() {
  439. this.drawText(stv_StageSelector_descText, (this.contents.width/2) - (this.textWidth(stv_StageSelector_descText)/2), this.lineHeight()*2);
  440. this.contents.fillRect(0, this.lineHeight()*3, this.contents.width, 1, this.textColor(0));
  441. this.drawTextEx(this._level._desc, 0, this.lineHeight()*2);
  442. };
  443. Window_StageSelector_Info.prototype.refresh = function() {
  444. if (this._level) {
  445. this.drawHead();
  446. this.drawDesc();
  447. }
  448. };
  449. // ----------------------------------------------------------------------------------------------------------------------------
  450. // Fill Command Window 2
  451. // ----------------------------------------------------------------------------------------------------------------------------
  452. function Window_StageSelector_Command() {
  453. this.initialize.apply(this, arguments);
  454. }
  455. Window_StageSelector_Command.prototype = Object.create(Window_HorzCommand.prototype);
  456. Window_StageSelector_Command.prototype.constructor = Window_StageSelector_Command;
  457. Window_StageSelector_Command.prototype.initialize = function(x, y, width, height) {
  458. Window_HorzCommand.prototype.initialize.call(this, x, y, width, height);
  459. };
  460. Window_StageSelector_Command.prototype.maxCols = function() {
  461. return 2;
  462. };
  463. Window_StageSelector_Command.prototype.windowWidth = function() {
  464. return (Graphics.boxWidth/3)*2;
  465. };
  466. Window_StageSelector_Command.prototype.makeCommandList = function() {
  467. this.addCommand(stv_StageSelector_transferText, 'start');
  468. this.addCommand(stv_StageSelector_backText, 'cancel');
  469. };
  470. // ----------------------------------------------------------------------------------------------------------------------------
  471. // Alias methods
  472. // ----------------------------------------------------------------------------------------------------------------------------
  473. STV_StageSelector_PluginCommand = Game_Interpreter.prototype.pluginCommand;
  474. STV_StageSelector_Create = DataManager.createGameObjects;
  475. STV_StageSelector_Save = DataManager.makeSaveContents;
  476. STV_StageSelector_Load = DataManager.extractSaveContents;
  477. // ----------------------------------------------------------------------------------------------------------------------------
  478. // DataManager
  479. // ----------------------------------------------------------------------------------------------------------------------------
  480. var $stv_stageselector = null;
  481. DataManager.makeSaveContents = function() {
  482. contents = STV_StageSelector_Save.call(this);
  483. contents.stvstageselector = $stv_stageselector;
  484. return contents;
  485. };
  486. DataManager.extractSaveContents = function(contents) {
  487. STV_StageSelector_Load.call(this, contents);
  488. $stv_stageselector = contents.stvstageselector;
  489. };
  490. DataManager.createGameObjects = function() {
  491. STV_StageSelector_Create.call(this);
  492. $stv_stageselector = new STV_StageSelector();
  493. };
  494. // ----------------------------------------------------------------------------------------------------------------------------
  495. // STV_StageSelector Functions
  496. // ----------------------------------------------------------------------------------------------------------------------------
  497. function STV_StageSelector() {
  498. this.initialize.apply(this, arguments);
  499. }
  500. STV_StageSelector.prototype.initialize = function() {
  501. this.selectedChapter = null;
  502. this.selectedLevel = null;
  503. this.setup();
  504. };
  505. // Setup
  506. STV_StageSelector.prototype.setup = function() {
  507. this.createMapList();
  508. this.createStageList();
  509. this._mapList = [null]; //delete Map List after needed for more Memory
  510. };
  511. // Get Maps
  512. STV_StageSelector.prototype.getMaps = function(filename) {
  513. var fs = require('fs');
  514. var dir = window.location.pathname.replace(/(\/www|)\/[^\/]*$/, '/');
  515. if (dir.match(/^\/([A-Z]\:)/)) {
  516. dir = dir.slice(1);
  517. }
  518. filename = decodeURIComponent(dir) + 'data/' + filename;
  519. return JsonEx.parse(fs.readFileSync(filename, 'utf8'));
  520. };
  521. // Create Map List
  522. STV_StageSelector.prototype.createMapList = function() {
  523. this._mapList = [null];
  524. for (var i = 1; i < $dataMapInfos.length; i++) {
  525. var filename = 'Map%1.json'.format(i.padZero(3));
  526. this._mapList.push(this.getMaps(filename));
  527. }
  528. };
  529. // Create Stage List
  530. STV_StageSelector.prototype.createStageList = function() {
  531. this._stageList = [null];
  532. for (var i = 1; i < $dataMapInfos.length; i++) {
  533. var note = this._mapList[i].note,
  534. desc = "";
  535. if (note.match(/<STVSS Info>((.|\n)*?)<\/STVSS Info>/g)) {
  536. desc = String(RegExp.$1);
  537. }
  538. if (note.match(/<(?:STVSS STAGE):[ ](.*)>/i)) {
  539. var string = String(RegExp.$1).split(","),
  540. stage = Number(string[0]),
  541. level = Number(string[1]);
  542. if (!this._stageList[stage]) this._stageList[stage] = [];
  543. this._stageList[stage][0] = stage;
  544. this._stageList[stage][level] = {};
  545. this._stageList[stage][level].displayName = this._mapList[i].displayName;
  546. this._stageList[stage][level].events = this._mapList[i].events;
  547. this._stageList[stage][level].note = this._mapList[i].note;
  548. this._stageList[stage][level].bgm = this._mapList[i].bgm;
  549. this._stageList[stage][level].bgs = this._mapList[i].bgs;
  550. this._stageList[stage][level]._desc = desc;
  551. this._stageList[stage][level]._revealed = false;
  552. this._stageList[stage][level]._completed = false;
  553. this._stageList[stage][level]._mapId = i;
  554. this._stageList[stage][level]._levelId = level;
  555. this._stageList[stage][level]._stageId = stage;
  556. }
  557. }
  558. };
  559. // Transfer Player to Level
  560. STV_StageSelector.prototype.transfer = function(level) {
  561. for (var i = 1; i < level.events.length; i++) {
  562. if (level.events[1]) {
  563. var note = level.events[i].note;
  564. if (note.match(/<STVSS START>/i)) {
  565. var mapId = level._mapId,
  566. x = level.events[i].x,
  567. y = level.events[i].y,
  568. dir = stv_StageSelector_transferDirection,
  569. type = stv_StageSelector_transferType;
  570. $gamePlayer.reserveTransfer(mapId, x, y, dir, type);
  571. break;
  572. }
  573. }
  574. }
  575. };
  576. // Complete Level
  577. STV_StageSelector.prototype.completeLevel = function(stageId, levelId) {
  578. if (this._stageList[stageId][levelId]) {
  579. this._stageList[stageId][levelId]._completed = true;
  580. }
  581. };
  582. // Reveal Level
  583. STV_StageSelector.prototype.revealLevel = function(stageId, levelId) {
  584. if (this._stageList[stageId][levelId]) {
  585. this._stageList[stageId][levelId]._revealed = true;
  586. }
  587. };
  588. // ----------------------------------------------------------------------------------------------------------------------------
  589. // Plugin Commands
  590. // ----------------------------------------------------------------------------------------------------------------------------
  591. Game_Interpreter.prototype.pluginCommand = function(command, args) {
  592. STV_StageSelector_PluginCommand.call(this, command, args);
  593. if (command === 'StageSelector') {
  594. switch (args[0]) {
  595. case 'open':
  596. SceneManager.push(Scene_StageSelector);
  597. break;
  598. case 'complete':
  599. $stv_stageselector.completeLevel(args[1], args[2]);
  600. break;
  601. case 'reveal':
  602. $stv_stageselector.revealLevel(args[1], args[2]);
  603. break;
  604. }
  605. }
  606. };

comments powered by Disqus