//=============================================================================
// Fast Travel
// by Beenbaba
// Date: 10/11/2015 (english)
//=============================================================================
/*:
* @plugindesc Fast Travel
* @author beenbaba
*
* @param Location Name 1
* @desc Name to appear in menu
*
* @param Map ID 1
* @desc Map ID Location 1
*
* @param X Location 1
* @desc Map X Co-ordinate
*
* @param Y Location 1
* @desc Map Y Co-ordinate
*
* @param Picture Name 1
* @desc Name of Picture to load
*
*
* @param Location Name 2
* @desc Name to appear in menu
*
* @param Map ID 2
* @desc Map ID Location 2
*
* @param X Location 2
* @desc Map X Co-ordinate
*
* @param Y Location 2
* @desc Map Y Co-ordinate
*
* @param Picture Name 2
* @desc Name of Picture to load
*
* @param Location Name 3
* @desc Name to appear in menu
*
* @param Map ID 3
* @desc Map ID Location 2
*
* @param X Location 3
* @desc Map X Co-ordinate
*
* @param Y Location 3
* @desc Map Y Co-ordinate
*
* @param Picture Name 3
* @desc Name of Picture to load
*
*
* @help
* This Plugin allows you to set up fast travel locations and transfer the player
* to that location
*
* Plugin Commands
*
* FastTravel open
*
*/
//=============================================================================
// Declare function
//=============================================================================
(function() {
var parameters = PluginManager.parameters('BabaFastTravel');
var locName1 = String(parameters['Location Name 1'])
var Map1 = Number(parameters['Map ID 1']);
var Xloc1 = Number(parameters['X Location 1']);
var Yloc1 = Number(parameters['Y Location 1']);
var Pic1 = String(parameters['Picture Name 1']);
var locName2 = String(parameters['Location Name 2']);
var Map2 = Number(parameters['Map ID 2']);
var Xloc2 = Number(parameters['X Location 2']);
var Yloc2 = Number(parameters['Y Location 2']);
var Pic2 = String(parameters['Picture Name 2']);
var locName3 = String(parameters['Location Name 3']);
var Map3 = Number(parameters['Map ID 3']);
var Xloc3 = Number(parameters['X Location 3']);
var Yloc3 = Number(parameters['Y Location 3']);
var Pic3 = String(parameters['Picture Name 3']);
var travelList = [];
travelList.push([locName1, Map1, Xloc1, Yloc1, Pic1]);
travelList.push([locName2, Map2, Xloc2, Yloc2, Pic2]);
travelList.push([locName3, Map3, Xloc3, Yloc3, Pic3]);
console.log(travelList);
var _Game_Interpreter_pluginCommand =
Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function(command, args) {
_Game_Interpreter_pluginCommand.call(this, command, args);
if (command === 'FastTravel') {
switch (args[0]) {
case 'open':
SceneManager.push(Scene_FastTravel);
break;
}
}
};
function Scene_FastTravel() {
this.initialize.apply(this, arguments);
}
Scene_FastTravel.prototype = Object.create(Scene_MenuBase.prototype);
Scene_FastTravel.prototype.constructor = Scene_FastTravel;
Scene_FastTravel.prototype.initialize = function() {
Scene_MenuBase.prototype.initialize.call(this);
};
Scene_FastTravel.prototype.create = function() {
Scene_MenuBase.prototype.create.call(this);
this._indexWindow = new Window_FastTravelIndex(0, 0);
this._indexWindow.setHandler('cancel', this.popScene.bind(this));
this._indexWindow.setHandler('ok', this.OnFT.bind(this));
var wh = Graphics.boxHeight;
var ww = Graphics.boxWidth - this._indexWindow.width;
var wx = this._indexWindow.width;
this._statusWindow = new Window_FastTravelPicture(wx, 0, ww, wh);
this.addWindow(this._indexWindow);
this.addWindow(this._statusWindow);
this._indexWindow.setStatusWindow(this._statusWindow)
};
Scene_FastTravel.prototype.OnFT = function() {
var item = this._indexWindow.index();
console.log(item);
$gamePlayer.reserveTransfer(travelList[item][1], travelList[item][2], travelList[item][3]);
SceneManager.goto(Scene_Map);
};
function Window_FastTravelIndex() {
this.initialize.apply(this, arguments);
};
Window_FastTravelIndex.prototype = Object.create(Window_Selectable.prototype);
Window_FastTravelIndex.prototype.constructor = Window_FastTravelIndex;
Window_FastTravelIndex.lastTopRow = 0;
Window_FastTravelIndex.lastIndex = 0;
Window_FastTravelIndex.prototype.initialize = function(x, y) {
var width = Graphics.boxWidth / 3;
var height = Graphics.boxHeight;
Window_Selectable.prototype.initialize.call(this, x, y, width, height);
this.refresh();
this.setTopRow(Window_FastTravelIndex.lastTopRow);
this.select(Window_FastTravelIndex.lastIndex);
this.activate();
};
Window_FastTravelIndex.prototype.maxCols = function() {
return 1;
};
Window_FastTravelIndex.prototype.maxItems = function() {
return this._list ? this._list.length : 0;
};
Window_FastTravelIndex.prototype.setStatusWindow = function(statusWindow) {
this._statusWindow = statusWindow;
this.updateStatus();
};
Window_FastTravelIndex.prototype.update = function() {
Window_Selectable.prototype.update.call(this);
this.updateStatus();
};
Window_FastTravelIndex.prototype.updateStatus = function() {
if (this._statusWindow) {
var itemIndex = this._list[this.index()];
var item = this._list.indexOf(itemIndex);
this._statusWindow.setItem(item);
console.log(item);
}
};
Window_FastTravelIndex.prototype.refresh = function() {
this._list = [];
for (var i = 0; i < travelList.length; i++) {
var loc = travelList[0];
console.log(loc);
this._list.push(loc);
}
this.createContents();
this.drawAllItems();
};
Window_FastTravelIndex.prototype.drawItem = function(index) {
var loc = this._list[index];
var rect = this.itemRectForText(index);
this.drawText(loc, rect.x, rect.y, rect.width);
console.log(loc);
};
Window_FastTravelIndex.prototype.processCancel = function() {
Window_Selectable.prototype.processCancel.call(this);
Window_FastTravelIndex.lastTopRow = this.topRow();
Window_FastTravelIndex.lastIndex = this.index();
};
function Window_FastTravelPicture() {
this.initialize.apply(this, arguments);
}
Window_FastTravelPicture.prototype = Object.create(Window_Base.prototype);
Window_FastTravelPicture.prototype.constructor = Window_FastTravelPicture;
Window_FastTravelPicture.prototype.initialize = function(x, y, width, height) {
Window_Base.prototype.initialize.call(this, x, y, width, height);
};
Window_FastTravelPicture.prototype.setItem = function(item) {
if (this._item !== item) {
this._item = item;
this.refresh();
console.log(item);
}
};
Window_FastTravelPicture.prototype.refresh = function() {
this.contents.clear();
var item = this._item;
console.log(item);
this.drawPicture(travelList[item][4], 0, 0);
};
Window_FastTravelPicture.prototype.drawPicture = function(filename, x, y) {
var bitmap = ImageManager.loadPicture(filename);
this.contents.blt(bitmap, 0, 0, bitmap._canvas.width, bitmap._canvas.height, x, y);
};
})(); // dont touch this.
//=============================================================================
// END PLUGIN
//=============================================================================