You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ycrpg/js/plugins/SF_SceneActor.js

993 lines
34 KiB
JavaScript

3 years ago
//=============================================================================
// Salted Fish Plugins - Scene Actor
// SF_SceneActor.js
//=============================================================================
"use strict";
var Imported = Imported || {};
Imported.SF_SceneActor = true;
var SF_Plugins = SF_Plugins || {};
//=============================================================================
/*:
* @plugindesc Scene Actor
* @author Salted Fish
*/
3 years ago
//=============================================================================
(function () {
var SF_SceneActor = {};
SF_Plugins.SF_SceneActor = SF_SceneActor;
SF_SceneActor.version = 1.0;
// Bitmap.prototype.drawTextEx = function (text, x, y) {
// if (text) {
// var textState = {
// index: 0, x: x, y: y, left: x
// };
// textState.text = this.convertEscapeCharacters(text);
// } else {
// return 0;
// }
// };
// Bitmap.prototype.convertEscapeCharacters = function (text) {
// text = text.replace(/\\/g, '\x1b');
// text = text.replace(/\x1b\x1b/g, '\\');
// text = text.replace(/\x1bV\[(\d+)\]/gi, function () {
// return $gameVariables.value(parseInt(arguments[1]));
// }.bind(this));
// text = text.replace(/\x1bV\[(\d+)\]/gi, function () {
// return $gameVariables.value(parseInt(arguments[1]));
// }.bind(this));
// text = text.replace(/\x1bN\[(\d+)\]/gi, function () {
// return this.actorName(parseInt(arguments[1]));
// }.bind(this));
// text = text.replace(/\x1bP\[(\d+)\]/gi, function () {
// return this.partyMemberName(parseInt(arguments[1]));
// }.bind(this));
// text = text.replace(/\x1bG/gi, TextManager.currencyUnit);
// return text;
// };
Game_Actor.prototype.equipSlots = function () {
var slots = [1, 2, 3, 4, 5, 6, 7, 7];
slots = slots.map(function (id) {
return id;
});
3 years ago
if (slots.length >= 2 && this.isDualWield()) {
slots[1] = 1;
}
return slots;
};
//=============================================================================
// Window_ActorSelect
//=============================================================================
function Window_ActorSelect() {
this.initialize.apply(this, arguments);
}
Window_ActorSelect.prototype = Object.create(Window_Base.prototype);
Window_ActorSelect.prototype.constructor = Window_ActorSelect;
Window_ActorSelect.prototype._refreshBack = function () {
// nothing to do
};
3 years ago
Window_ActorSelect.prototype._refreshFrame = function () {
// nothing to do
};
3 years ago
Window_ActorSelect.prototype.standardPadding = function () {
return 0;
};
3 years ago
Window_ActorSelect.prototype.initialize = function () {
Window_Base.prototype.initialize.call(this, 0, 0, Graphics.boxWidth, Graphics.boxHeight);
this._actorList = [];
this._actorBitmap = {};
for (var i = 0; i < $dataActors.length; i++) {
if ($dataActors[i]) {
var actor = $gameActors.actor($dataActors[i].id);
this._actorList.push(actor);
this._actorBitmap[actor.faceName()] = ImageManager.loadFace(actor.faceName());
}
}
this._pageNumber = 0;
this._pageSize = 12;
this._maxPage = Math.ceil(this._actorList.length / this._pageSize);
this._faceBackBitmap = ImageManager.loadSceneActorSelect("face_back");
3 years ago
this._handler = null;
};
Window_ActorSelect.prototype.refresh = function () {
this.contents.clear();
this.drawAllItems();
};
Window_ActorSelect.prototype.drawAllItems = function () {
var index = this._pageNumber * this._pageSize;
for (var i = 0; i < this._pageSize; i++) {
if (index < this._actorList.length) {
this.drawItem(index);
}
index++;
}
};
3 years ago
Window_ActorSelect.prototype.drawItem = function (index) {
var actor = this._actorList[index];
var rect = this.itemRect(index);
this.contents.blt(
this._faceBackBitmap,
0,
0,
this._faceBackBitmap.width,
this._faceBackBitmap.height,
rect.x,
rect.y
);
3 years ago
this.drawActorFace(actor, rect.x, rect.y, rect.width, rect.width);
this.drawActorName(actor, rect.x, rect.y + rect.width, rect.width, rect.height - rect.width);
};
3 years ago
Window_ActorSelect.prototype.drawActorFace = function (actor, x, y, width, height) {
var faceIndex = actor.faceIndex();
var bitmap = this._actorBitmap[actor.faceName()];
var pw = Window_Base._faceWidth;
var ph = Window_Base._faceHeight;
var sx = (faceIndex % 4) * pw;
3 years ago
var sy = Math.floor(faceIndex / 4) * ph;
this.contents.blt(bitmap, sx, sy, pw, ph, x, y, width, height);
};
3 years ago
Window_ActorSelect.prototype.drawActorName = function (actor, x, y, width, height) {
this.changeTextColor(this.normalColor());
this.contents.fontSize = 20;
this.contents.drawText(actor.name(), x, y, width, height, "center");
};
3 years ago
Window_ActorSelect.prototype.itemRect = function (index) {
var rect = new Rectangle();
var i = index - this._pageNumber * this._pageSize;
rect.width = 124;
rect.height = 160;
rect.x = (i % 6) * (rect.width + 33) + 58;
rect.y = Math.floor(i / 6) * (rect.height + 40) + 93;
return rect;
};
3 years ago
Window_ActorSelect.prototype.maxPage = function () {
return this._maxPage;
};
3 years ago
Window_ActorSelect.prototype.pageNumber = function () {
return this._pageNumber;
};
3 years ago
Window_ActorSelect.prototype.setPageNumber = function (pageNumber) {
this._pageNumber = pageNumber;
this.refresh();
};
3 years ago
Window_ActorSelect.prototype.update = function () {
Window_Base.prototype.update.call(this);
if (this.isOpenAndActive()) {
this.updateInput();
}
};
3 years ago
Window_ActorSelect.prototype.updateInput = function () {
if (TouchInput.isTriggered()) {
var x = this.canvasToLocalX(TouchInput.x);
var y = this.canvasToLocalY(TouchInput.y);
var index = this.hitTest(x, y);
if (index >= 0 && index < this._pageSize) {
this.callHandler(index + this._pageNumber * this._pageSize);
}
}
};
3 years ago
Window_ActorSelect.prototype.hitTest = function (x, y) {
x = x - 58;
y = y - 93;
if (x < 0 || y < 0) {
return -1;
}
var col = Math.floor(x / (124 + 33));
var row = Math.floor(y / (160 + 40));
var dx = x - col * (124 + 33);
var dy = y - row * (160 + 40);
if (dx < 0 || dy < 0 || dx > 124 || dy > 160 || col >= 6 || row >= 2) {
return -1;
}
return row * 6 + col;
};
3 years ago
Window_ActorSelect.prototype.callHandler = function (index) {
if (index >= 0 && index < this._actorList.length) {
if (this._handler) {
this._handler(this._actorList[index]);
}
}
};
3 years ago
Window_ActorSelect.prototype.setHandler = function (handler) {
this._handler = handler;
};
3 years ago
//=============================================================================
// Scene_ActorSelect
//=============================================================================
function Scene_ActorSelect() {
this.initialize.apply(this, arguments);
}
window.Scene_ActorSelect = Scene_ActorSelect;
Scene_ActorSelect.prototype = Object.create(Scene_MenuBase.prototype);
Scene_ActorSelect.prototype.constructor = Scene_ActorSelect;
Scene_ActorSelect.prototype.createBackground = function () {
this._backgroundSprite = new Sprite();
this._backgroundSprite.bitmap = ImageManager.loadSceneActorSelect("background");
3 years ago
this.addChild(this._backgroundSprite);
};
3 years ago
Scene_ActorSelect.prototype.initialize = function () {
Scene_MenuBase.prototype.initialize.call(this);
};
3 years ago
Scene_ActorSelect.prototype.create = function () {
Scene_MenuBase.prototype.create.call(this);
this.createActorSelectWindow();
this.createCancelButton();
this.createPageButtons();
};
3 years ago
Scene_ActorSelect.prototype.start = function () {
Scene_MenuBase.prototype.start.call(this);
this._actorSelectWindow.setPageNumber(0);
this.updatePageButtons();
this.updatePageNumber();
};
3 years ago
Scene_ActorSelect.prototype.createActorSelectWindow = function () {
this._actorSelectWindow = new Window_ActorSelect();
this._actorSelectWindow.setHandler(this.onActorSelect.bind(this));
this.addChild(this._actorSelectWindow);
};
3 years ago
Scene_ActorSelect.prototype.onActorSelect = function (actor) {
SF_SceneActor._actorSelected = actor;
SceneManager.push(Scene_Actor);
};
3 years ago
Scene_ActorSelect.prototype.createCancelButton = function () {
this._cancelButton = new Sprite_SFButton();
var bitmap = ImageManager.loadSceneActorSelect("cancel");
3 years ago
this._cancelButton.setColdBitmap(bitmap);
this._cancelButton.setHotBitmap(bitmap);
this._cancelButton.setClickHandler(this.onCancelButtonClick.bind(this));
this._cancelButton.refresh();
this._cancelButton.move(21, 7);
this.addChild(this._cancelButton);
};
3 years ago
Scene_ActorSelect.prototype.onCancelButtonClick = function () {
this.popScene();
};
3 years ago
Scene_ActorSelect.prototype.updatePageButtons = function () {
var num = this._actorSelectWindow.pageNumber();
var max = this._actorSelectWindow.maxPage();
if (num == 0) {
this._pageUpButton.deactivate();
this._pageUpButton.visible = false;
} else {
this._pageUpButton.activate();
this._pageUpButton.visible = true;
}
if (num == max - 1) {
this._pageDownButton.deactivate();
this._pageDownButton.visible = false;
} else {
this._pageDownButton.activate();
this._pageDownButton.visible = true;
}
};
3 years ago
Scene_ActorSelect.prototype.updatePageNumber = function () {
var num = this._actorSelectWindow.pageNumber();
var bitmap = this._pageNumberText.bitmap;
bitmap.clear();
bitmap.fontSize = 16;
bitmap.drawText(num + 1, 0, 0, bitmap.width, bitmap.height, "center");
};
3 years ago
Scene_ActorSelect.prototype.createPageButtons = function () {
this._pageUpButton = new Sprite_SFButton();
var bitmap = ImageManager.loadSceneActorSelect("page_up");
3 years ago
this._pageUpButton.setColdBitmap(bitmap);
this._pageUpButton.setHotBitmap(bitmap);
this._pageUpButton.setClickHandler(this.onPageUpButtonClick.bind(this));
this._pageUpButton.refresh();
this._pageUpButton.move(442, 493);
this.addChild(this._pageUpButton);
this._pageDownButton = new Sprite_SFButton();
var bitmap = ImageManager.loadSceneActorSelect("page_down");
3 years ago
this._pageDownButton.setColdBitmap(bitmap);
this._pageDownButton.setHotBitmap(bitmap);
this._pageDownButton.setClickHandler(this.onPageDownButtonClick.bind(this));
this._pageDownButton.refresh();
this._pageDownButton.move(544, 493);
this.addChild(this._pageDownButton);
this._pageNumberContainer = new PIXI.Container();
this._pageNumberContainer.position.set(493, 493);
this._pageNumberBackSprite = new Sprite(ImageManager.loadSceneActorSelect("num_back"));
3 years ago
this.addChild(this._pageNumberContainer);
this._pageNumberContainer.addChild(this._pageNumberBackSprite);
this._pageNumberText = new Sprite(new Bitmap(40, 40));
this._pageNumberText.move(0, 0);
this._pageNumberContainer.addChild(this._pageNumberText);
};
3 years ago
Scene_ActorSelect.prototype.onPageUpButtonClick = function () {
this._actorSelectWindow.setPageNumber(this._actorSelectWindow.pageNumber() - 1);
this.updatePageButtons();
this.updatePageNumber();
};
3 years ago
Scene_ActorSelect.prototype.onPageDownButtonClick = function () {
this._actorSelectWindow.setPageNumber(this._actorSelectWindow.pageNumber() + 1);
this.updatePageButtons();
this.updatePageNumber();
};
3 years ago
//=============================================================================
// Window_ActorProps
//=============================================================================
function Window_ActorProps() {
this.initialize.apply(this, arguments);
}
Window_ActorProps.prototype = Object.create(Window_Base.prototype);
Window_ActorProps.prototype.constructor = Window_ActorProps;
Window_ActorProps.prototype._refreshBack = function () {
// nothing to do here
};
3 years ago
Window_ActorProps.prototype._refreshFrame = function () {
this._windowFrameSprite.bitmap = ImageManager.loadSceneActor("actor_prop");
};
3 years ago
Window_ActorProps.prototype.initialize = function () {
Window_Base.prototype.initialize.apply(this, arguments);
this._key_position = {
mhp: [70, 96],
mmp: [300, 96],
atk: [70, 120],
mat: [300, 120],
def: [70, 144],
mdf: [300, 144],
agi: [70, 168],
cri: [300, 168],
hit: [70, 192],
eva: [300, 192],
};
3 years ago
this._actor = null;
this._states = [];
this._statePage = 0;
this._stateMaxPage = 0;
this._stateMaxInPage = 6;
this._iconBitmap = ImageManager.loadSystem("IconSet");
3 years ago
this._stateWidth = 133;
this._stateHeight = 44;
this._statePaddingX = 35;
this._statePaddingY = 18;
};
3 years ago
Window_ActorProps.prototype.standardPadding = function () {
return 0;
};
3 years ago
Window_ActorProps.prototype.setActor = function (actor) {
this._actor = actor;
this.refresh();
};
3 years ago
Window_ActorProps.prototype.refresh = function () {
if (!this._actor) {
return;
}
3 years ago
this.contents.clear();
this.contents.fontSize = 18;
for (var key in this._key_position) {
this.drawActorParam(this._actor, key);
}
this._states = this._actor.states();
this._statePage = 0;
this._stateMaxPage = Math.floor(this._states.length / this._stateMaxInPage);
this.drawActorStatePage();
};
3 years ago
Window_ActorProps.prototype.drawActorParam = function (actor, key) {
var x = this._key_position[key][0];
var y = this._key_position[key][1];
var value = actor[key];
var text = "";
if (value < 1) {
text = value.toFixed(2);
} else {
text = value.toString();
}
this.contents.drawText(text, x, y, 180, 24, "right");
};
3 years ago
Window_ActorProps.prototype.getStateRect = function (index) {
var i = index - this._statePage * this._stateMaxInPage;
var sw = this._stateWidth;
var sh = this._stateHeight;
var x = 23 + (i % 3) * (sw + this._statePaddingX);
var y = 278 + Math.floor(i / 3) * (sh + this._statePaddingY);
return new Rectangle(x, y, sw, sh);
};
3 years ago
Window_ActorProps.prototype.drawActorStatePage = function () {
var pw = Window_Base._iconWidth;
var ph = Window_Base._iconHeight;
this.contents.fontSize = 32;
for (var i = 0; i < this._stateMaxInPage; i++) {
var index = this._statePage * this._stateMaxInPage + i;
var rect = this.getStateRect(index);
this.contents.clearRect(rect.x, rect.y, rect.width, rect.height);
if (index < this._states.length) {
var state = this._states[index];
var iconIndex = state.iconIndex;
var sx = (iconIndex % 116) * pw;
3 years ago
var sy = Math.floor(iconIndex / 16) * ph;
this.contents.blt(
this._iconBitmap,
sx,
sy,
pw,
ph,
rect.x,
rect.y,
this._stateHeight,
this._stateHeight
);
3 years ago
var text = state.name;
this.contents.drawText(
text,
rect.x + this._stateHeight,
rect.y,
rect.width - this._stateHeight,
this._stateHeight,
"left"
);
3 years ago
}
}
};
3 years ago
//=============================================================================
// Window_ActorSkill
//=============================================================================
function Window_ActorSkill() {
this.initialize.apply(this, arguments);
}
Window_ActorSkill.prototype = Object.create(Window_Base.prototype);
Window_ActorSkill.prototype.constructor = Window_ActorSkill;
Window_ActorSkill.prototype._refreshBack = function () {
// nothing to do here
};
3 years ago
Window_ActorSkill.prototype._refreshFrame = function () {
this._windowFrameSprite.bitmap = ImageManager.loadSceneActor("actor_skill");
};
3 years ago
Window_ActorSkill.prototype.initialize = function () {
Window_Base.prototype.initialize.apply(this, arguments);
this._actor = null;
this._skillPage = 0;
this._skillMaxPage = 0;
this._skillMaxInPage = 18;
this._skillWidth = 142;
this._skillHeight = 35;
this._skillPaddingX = 9;
this._skillPaddingY = 17;
this._iconBitmap = ImageManager.loadSystem("IconSet");
this._skillBackBitmap = ImageManager.loadSceneActor("skill_back");
3 years ago
this._skillHandler = null;
this.createPageButtons();
};
3 years ago
Window_ActorSkill.prototype.standardPadding = function () {
return 0;
};
3 years ago
Window_ActorSkill.prototype.createPageButtons = function () {
var bitmap = null;
bitmap = ImageManager.loadSceneActor("skill_page_up");
3 years ago
this._pageUpButton = new Sprite_SFButton();
this._pageUpButton.setColdBitmap(bitmap);
this._pageUpButton.setHotBitmap(bitmap);
this._pageUpButton.setClickHandler(this.onPageUpButtonClick.bind(this));
this._pageUpButton.refresh();
this._pageUpButton.move(214, 372);
this.addChild(this._pageUpButton);
bitmap = ImageManager.loadSceneActor("skill_page_down");
3 years ago
this._pageDownButton = new Sprite_SFButton();
this._pageDownButton.setColdBitmap(bitmap);
this._pageDownButton.setHotBitmap(bitmap);
this._pageDownButton.setClickHandler(this.onPageDownButtonClick.bind(this));
this._pageDownButton.refresh();
this._pageDownButton.move(258, 372);
this.addChild(this._pageDownButton);
this._pageUpButton.visible = false;
this._pageDownButton.visible = false;
this._pageNumberContainer = new PIXI.Container();
this._pageNumberContainer.position.set(236, 372);
this._pageNumberBackSprite = new Sprite(ImageManager.loadSceneActor("skill_page_number_back"));
3 years ago
this.addChild(this._pageNumberContainer);
this._pageNumberContainer.addChild(this._pageNumberBackSprite);
this._pageNumberText = new Sprite(new Bitmap(22, 22));
this._pageNumberText.move(0, 0);
this._pageNumberText.bitmap.fontSize = 14;
this._pageNumberContainer.addChild(this._pageNumberText);
};
3 years ago
Window_ActorSkill.prototype.onPageUpButtonClick = function () {
this._skillPage--;
this.refresh();
};
3 years ago
Window_ActorSkill.prototype.onPageDownButtonClick = function () {
this._skillPage++;
this.refresh();
};
3 years ago
Window_ActorSkill.prototype.setActor = function (actor) {
this._actor = actor;
this._skillList = this._actor.skills().filter(function (skill) {
return !!skill && this._actor.noHiddenSkillConditionsMet(skill);
}, this);
this._skillPage = 0;
this._skillMaxPage = Math.ceil(this._skillList.length / this._skillMaxInPage);
this.refresh();
};
3 years ago
Window_ActorSkill.prototype.refresh = function () {
if (!this._actor) {
return;
}
3 years ago
this.contents.clear();
this.drawActorSkillPage();
this.updatePageButtons();
this.updatePageNumber();
};
3 years ago
Window_ActorSkill.prototype.updatePageButtons = function () {
this._pageUpButton.visible = this._skillPage > 0;
this._pageDownButton.visible = this._skillPage < this._skillMaxPage - 1;
if (this._pageUpButton.visible) {
this._pageUpButton.activate();
} else {
this._pageUpButton.deactivate();
}
if (this._pageDownButton.visible) {
this._pageDownButton.activate();
} else {
this._pageDownButton.deactivate();
}
};
3 years ago
Window_ActorSkill.prototype.updatePageNumber = function () {
this._pageNumberText.bitmap.clear();
this._pageNumberText.bitmap.drawText(this._skillPage + 1, 0, 0, 22, 22, "center");
};
3 years ago
Window_ActorSkill.prototype.getSkillRect = function (index) {
var i = index - this._skillPage * this._skillMaxInPage;
var sw = this._skillWidth;
var sh = this._skillHeight;
var x = 23 + (i % 3) * (sw + this._skillPaddingX);
var y = 62 + Math.floor(i / 3) * (sh + this._skillPaddingY);
return new Rectangle(x, y, sw, sh);
};
3 years ago
Window_ActorSkill.prototype.drawActorSkillPage = function () {
var pw = Window_Base._iconWidth;
var ph = Window_Base._iconHeight;
this.contents.fontSize = 24;
var index = this._skillPage * this._skillMaxInPage;
for (var i = 0; i < this._skillMaxInPage && index < this._skillList.length; i++, index++) {
var rect = this.getSkillRect(index);
this.contents.clearRect(rect.x, rect.y, rect.width, rect.height);
this.contents.blt(
this._skillBackBitmap,
0,
0,
this._skillBackBitmap.width,
this._skillBackBitmap.height,
rect.x,
rect.y,
rect.width,
rect.height
3 years ago
);
var skill = this._skillList[index];
var iconIndex = skill.iconIndex;
var sx = (iconIndex % 16) * pw;
3 years ago
var sy = Math.floor(iconIndex / 16) * ph;
this.contents.blt(this._iconBitmap, sx, sy, pw, ph, rect.x, rect.y, this._skillHeight, this._skillHeight);
var text = skill.name;
this.contents.drawText(
text,
rect.x + this._skillHeight,
rect.y,
rect.width - this._skillHeight,
this._skillHeight,
"left"
);
3 years ago
}
};
3 years ago
Window_ActorSkill.prototype.update = function () {
Window_Base.prototype.update.apply(this, arguments);
if (this.isOpenAndActive()) {
this.updateInput();
}
};
3 years ago
Window_ActorSkill.prototype.updateInput = function () {
if (TouchInput.isTriggered()) {
var x = this.canvasToLocalX(TouchInput.x);
var y = this.canvasToLocalY(TouchInput.y);
var index = this.hitTest(x, y);
if (index >= 0) {
index = index + this._skillPage * this._skillMaxInPage;
if (index < this._skillList.length) {
var skill = this._skillList[index];
this.callSkillHandler(skill);
}
}
}
};
3 years ago
Window_ActorSkill.prototype.callSkillHandler = function (skill) {
if (skill && this._skillHandler) {
this._skillHandler(skill);
}
};
3 years ago
Window_ActorSkill.prototype.setSkillHandler = function (handler) {
this._skillHandler = handler;
};
3 years ago
Window_ActorSkill.prototype.hitTest = function (x, y) {
x = x - 23;
y = y - 62;
if (x < 0 || y < 0) {
return -1;
}
3 years ago
var row = Math.floor(y / (this._skillHeight + this._skillPaddingY));
var col = Math.floor(x / (this._skillWidth + this._skillPaddingX));
var dx = x - col * (this._skillWidth + this._skillPaddingX);
var dy = y - row * (this._skillHeight + this._skillPaddingY);
if (dx < 0 || dy < 0 || dx > this._skillWidth || dy > this._skillHeight || row >= 6 || col >= 3) {
return -1;
}
3 years ago
var index = row * 3 + col;
return index;
};
3 years ago
//=============================================================================
// Window_SkillPopup
//=============================================================================
function Window_SkillPopup() {
this.initialize.apply(this, arguments);
}
Window_SkillPopup.prototype = Object.create(Window_Base.prototype);
Window_SkillPopup.prototype.constructor = Window_SkillPopup;
Window_SkillPopup.prototype._refreshBack = function () {
// nothing to do
};
3 years ago
Window_SkillPopup.prototype._refreshFrame = function () {
this._windowFrameSprite.bitmap = ImageManager.loadSceneActor("skill_pop_window_back");
};
3 years ago
Window_SkillPopup.prototype.initialize = function () {
Window_Base.prototype.initialize.apply(this, arguments);
this._actor = null;
this._skill = null;
this._action = null;
this._cancelHandler = null;
this._useHandler = null;
this._faceBackBitmap = ImageManager.loadSceneActor("skill_pop_face_back");
3 years ago
this.createCancelButton();
this.createUseButton();
};
3 years ago
Window_SkillPopup.prototype.standardPadding = function () {
return 0;
};
3 years ago
Window_SkillPopup.prototype.setActor = function (actor) {
this._actor = actor;
this._action = new Game_Action(actor);
};
3 years ago
Window_SkillPopup.prototype.setSkill = function (skill) {
this._skill = skill;
this._action.setItemObject(skill);
this.refresh();
};
3 years ago
Window_SkillPopup.prototype.setCancelHandler = function (handler) {
this._cancelHandler = handler;
this._cancelButton.setClickHandler(this._cancelHandler);
};
3 years ago
Window_SkillPopup.prototype.setUseHandler = function (handler) {
this._useHandler = handler;
this._useButton.setClickHandler(this.callUseHandler.bind(this));
};
3 years ago
Window_SkillPopup.prototype.callUseHandler = function () {
if (this._useHandler) {
this._useHandler();
}
};
3 years ago
Window_SkillPopup.prototype.createCancelButton = function () {
this._cancelButton = new Sprite_SFButton();
var bitmap = ImageManager.loadSceneActor("skill_pop_cancel");
3 years ago
this._cancelButton.setColdBitmap(bitmap);
this._cancelButton.setHotBitmap(bitmap);
this._cancelButton.setClickHandler(this._cancelHandler);
this._cancelButton.move(670, 0);
this._cancelButton.refresh();
this.addChild(this._cancelButton);
};
3 years ago
Window_SkillPopup.prototype.createUseButton = function () {
this._useButton = new Sprite_SFButton();
var bitmap = ImageManager.loadSceneActor("skill_pop_use");
3 years ago
this._useButton.setColdBitmap(bitmap);
this._useButton.setHotBitmap(bitmap);
this._useButton.setClickHandler(this._useHandler);
this._useButton.move(592, 313);
this._useButton.refresh();
this.addChild(this._useButton);
};
3 years ago
Window_SkillPopup.prototype.refresh = function () {
this._cancelButton.refresh();
this._useButton.refresh();
this.contents.clear();
if (!this._actor || !this._skill) {
return;
}
3 years ago
this.refreshSkill();
if (this._actor.canUse(this._skill)) {
this._useButton.visible = true;
this._useButton.activate();
} else {
this._useButton.visible = false;
this._useButton.deactivate();
}
};
3 years ago
Window_SkillPopup.prototype.refreshSkill = function () {
var text = this._skill.name;
this.contents.fontSize = 20;
this.contents.drawText(text, 18, 17, this.contentsWidth(), 20, "left");
3 years ago
this.contents.fontSize = 16;
text = this._skill.description;
var lines = text.split("\n");
3 years ago
var y = 60;
for (var i = 0; i < lines.length; i++) {
this.contents.drawText(lines[i], 36, y, this.contentsWidth(), 20, "left");
3 years ago
y += 20;
}
};
3 years ago
//=============================================================================
// Scene_Actor
//=============================================================================
function Scene_Actor() {
this.initialize.apply(this, arguments);
}
window.Scene_Actor = Scene_Actor;
Scene_Actor.prototype = Object.create(Scene_MenuBase.prototype);
Scene_Actor.prototype.constructor = Scene_Actor;
Scene_Actor.prototype.initialize = function () {
Scene_MenuBase.prototype.initialize.call(this);
this._iconBitmap = ImageManager.loadSystem("IconSet");
this._childStatus = "prop"; // prop skill equip skill_popup
};
3 years ago
Scene_Actor.prototype.create = function () {
Scene_MenuBase.prototype.create.call(this);
this._actor = SF_SceneActor._actorSelected || $gameParty.menuActor();
this.createNameSprite();
this.createActorContainer();
this.createStatusWindow();
this.createCancelButton();
this.createSkillWindow();
//this.createEquipWindow();
//this.createTabButton();
};
3 years ago
Scene_Actor.prototype.start = function () {
Scene_MenuBase.prototype.start.call(this);
this._statusWindow.setActor(this._actor);
this._skillWindow.setActor(this._actor);
this._skillPopup.setActor(this._actor);
this._childStatus = "skill";
3 years ago
this.updateChildrenList();
};
3 years ago
Scene_Actor.prototype.createBackground = function () {
this._backgroundSprite = new Sprite();
this._backgroundSprite.bitmap = ImageManager.loadSceneActor("background");
};
3 years ago
Scene_Actor.prototype.createNameSprite = function () {
this._nameSprite = new Sprite();
this._nameSprite.bitmap = new Bitmap(230, 47);
this._nameSprite.bitmap.fontSize = 32;
this._nameSprite.bitmap.textColor = "#ffffff";
3 years ago
this._nameSprite.move(45, 73);
this._nameSprite.bitmap.drawText(this._actor.name(), 0, 0, 230, 47, "center");
};
3 years ago
Scene_Actor.prototype.createActorContainer = function () {
this._actorContainer = new PIXI.Container();
this._actorContainer.x = 52;
this._actorContainer.y = 139;
var slots = this._actor.equipSlots();
for (var i = 0; i < slots; i++) {
// not completely sure what this does
}
};
3 years ago
Scene_Actor.prototype.createStatusWindow = function () {
this._statusWindow = new Window_ActorProps(487, 86, 495, 417);
};
3 years ago
Scene_Actor.prototype.createSkillWindow = function () {
this._skillWindow = new Window_ActorSkill(487, 86, 495, 417);
this._skillWindow.setSkillHandler(this.onSkillOk.bind(this));
this._skillPopup = new Window_SkillPopup(166, 83, 707, 363);
this._skillPopup.setCancelHandler(this.onSkillCancel.bind(this));
this._skillPopup.setUseHandler(this.onSkillUse.bind(this));
this._skillPopBack = new Sprite();
this._skillPopBackBitmap = ImageManager.loadSceneActor("skill_pop_back");
};
3 years ago
Scene_Actor.prototype.createCancelButton = function () {
this._cancelButton = new Sprite_SFButton();
var bitmap = ImageManager.loadSceneActor("cancel");
3 years ago
this._cancelButton.setColdBitmap(bitmap);
this._cancelButton.setHotBitmap(bitmap);
this._cancelButton.setClickHandler(this.onCancelButtonClick.bind(this));
this._cancelButton.move(21, 7);
this._cancelButton.refresh();
};
3 years ago
Scene_Actor.prototype.onCancelButtonClick = function () {
this.popScene();
};
3 years ago
Scene_Actor.prototype.onSkillOk = function (skill) {
this._skillPopBack.bitmap = Bitmap.snap(this);
this._skillPopBack.bitmap.blt(
this._skillPopBackBitmap,
0,
0,
this._skillPopBackBitmap.width,
this._skillPopBackBitmap.height,
0,
0
);
3 years ago
this._skillPopup.setSkill(skill);
this._childStatus = "skill_popup";
3 years ago
this.updateChildrenList();
};
3 years ago
Scene_Actor.prototype.onSkillCancel = function () {
this._childStatus = "skill";
3 years ago
this.updateChildrenList();
};
3 years ago
Scene_Actor.prototype.onSkillUse = function (skill) {
var action = new Game_Action(this._actor);
this._childStatus = "skill";
3 years ago
this.updateChildrenList();
};
3 years ago
Scene_Actor.prototype.useSkill = function (action) {
this._actor.useItem(action.item());
this.a;
};
3 years ago
Scene_Actor.prototype.updateChildrenList = function () {
this.removeChildren();
switch (this._childStatus) {
case "prop":
3 years ago
this.addBackChildren();
this.addChild(this._statusWindow);
break;
case "skill":
3 years ago
this.addBackChildren();
this.addChild(this._skillWindow);
break;
case "equip":
3 years ago
this.addBackChildren();
this.addChild(this._equipWindow);
break;
case "skill_popup":
3 years ago
this.addChild(this._skillPopBack);
this.addChild(this._skillPopup);
break;
default:
this.popScene();
}
};
3 years ago
Scene_Actor.prototype.addBackChildren = function () {
this.addChild(this._backgroundSprite);
this.addChild(this._cancelButton);
this.addChild(this._nameSprite);
this.addChild(this._actorContainer);
};
})();