dead-bunny/js/plugins/Nore_SlgCommandWindow.js
2025-01-12 01:21:39 -06:00

368 lines
11 KiB
JavaScript

var __extends =
(this && this.__extends) ||
(function () {
var extendStatics = function (d, b) {
extendStatics =
Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array &&
function (d, b) {
d.__proto__ = b;
}) ||
function (d, b) {
for (var p in b)
if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
};
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError(
"Class extends value " + String(b) + " is not a constructor or null"
);
extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype =
b === null
? Object.create(b)
: ((__.prototype = b.prototype), new __());
};
})();
var Nore;
(function (Nore) {
var Window_SlgCommand = /** @class */ (function (_super) {
__extends(Window_SlgCommand, _super);
function Window_SlgCommand() {
var _this = this;
var r = new Rectangle(0, Nore.TOP_Y + 2, Nore.MAIN_MENU_W + 1, 762);
_this = _super.call(this, r) || this;
_this.frameVisible = false;
//this.createBackground();
_this.padding = 0;
_this.backOpacity = 0;
_this.addChild(_this._windowContentsSprite);
_this.loadImage();
return _this;
}
Window_SlgCommand.prototype.loadImage = function () {
if (ConfigManager.language == "jp") {
ImageManager.loadSystem("button3");
} else {
ImageManager.loadSystem("button3_en");
}
};
Window_SlgCommand.prototype.itemRect = function (index) {
var r = _super.prototype.itemRect.call(this, index);
r.y += 10;
if (index >= 4) {
r.y += 11;
}
if (index >= 5) {
r.y += 11;
}
if (index >= 7) {
r.y += 11;
}
if (index >= 9) {
r.y += 11;
}
return r;
};
Window_SlgCommand.prototype.activate = function () {
_super.prototype.activate.call(this);
this.onUp();
};
Window_SlgCommand.prototype.deactivate = function () {
_super.prototype.deactivate.call(this);
this.onPush();
};
Window_SlgCommand.prototype.createBackground = function () {
var baseTexture = Nore.getSystemBaseTexture("menu");
if (!baseTexture) {
return;
}
var texture = new PIXI.Texture(
baseTexture,
new Rectangle(0, 0, 184, baseTexture.height)
);
this._bg = new PIXI.Sprite(texture);
this._bg.alpha = 0.5;
this._windowContentsBackSprite.addChild(this._bg);
};
Window_SlgCommand.prototype.itemHeight = function () {
return 69;
};
Window_SlgCommand.prototype.update = function () {
_super.prototype.update.call(this);
this.updateTutoArrow();
this.updateWheel();
this.updateTouchSave();
};
Window_SlgCommand.prototype.updateWheel = function () {
if (this._wheelWait > 0) {
this._wheelWait--;
return;
}
if (TouchInput.wheelY > 0) {
this._wheelWait = 2;
if (this.active) {
SoundManager.playCursor();
this.cursorDown(true);
}
} else if (TouchInput.wheelY < 0) {
this._wheelWait = 2;
if (this.active) {
SoundManager.playCursor();
this.cursorUp(true);
}
}
};
Window_SlgCommand.prototype.updateTouchSave = function () {
if (this.currentSymbol() != Nore.SlgCommand.save) {
return;
}
if (!TouchInput.isTriggered()) {
return;
}
if (TouchInput.y < 100) {
return;
}
if (TouchInput.x < 150) {
return;
}
SoundManager.playOk();
this.callOkHandler();
};
Window_SlgCommand.prototype.updateTutoArrow = function () {
var symbol = this.tutoArrowSymbol();
if (this._lastTutoSymbol != symbol) {
this.refresh();
}
};
Window_SlgCommand.prototype.refresh = function () {
if (this._tutoArrow) {
this.removeChild(this._tutoArrow);
}
this._windowContentsSprite.removeChildren();
this._buttonList = [];
_super.prototype.refresh.call(this);
this.drawTutoArrow();
};
Window_SlgCommand.prototype.drawTutoArrow = function () {
if (this._tutoArrow) {
this.removeChild(this._tutoArrow);
}
var symbol = this.tutoArrowSymbol();
this._lastTutoSymbol = symbol;
if (symbol == Nore.SlgCommand.none) {
return;
}
var index = this.findSymbol(symbol);
var rect = this.itemRect(index);
this.drawArrow(rect.x + 148, rect.y - 6);
};
Window_SlgCommand.prototype.tutoArrowSymbol = function () {
var tutorial = $gameTutorial.currentTutorial();
switch (tutorial) {
case Tutorial.AV:
case Tutorial.AV_2:
return Nore.SlgCommand.av;
case Tutorial.NEXT_DAY:
//return 1;
case Tutorial.FACILITY_1:
case Tutorial.FACILITY_2:
return Nore.SlgCommand.facility;
case Tutorial.BATTLE:
return Nore.SlgCommand.invasion;
case Tutorial.FORMATION:
return Nore.SlgCommand.formation;
case Tutorial.DECISIVE_BATTLE_1:
if ($gameSwitches.value(109)) {
return Nore.SlgCommand.decisiveBattle;
}
return Nore.SlgCommand.none;
}
return Nore.SlgCommand.none;
};
Window_SlgCommand.prototype.drawArrow = function (x, y) {
var baseTexture2 = Nore.getSystemBaseTexture("0213_sys");
var texture = new PIXI.Texture(baseTexture2);
var sprite = new PIXI.Sprite(texture);
sprite.x = x;
sprite.y = y;
this._tutoArrow = sprite;
this.addChild(sprite);
};
Window_SlgCommand.prototype.makeCommandList = function () {
this.addCommand(TextManager.charAv, Nore.SlgCommand.av, true);
this.addCommand(TextManager.charKigae, Nore.SlgCommand.kigae, true);
this.addCommand(
TextManager.charDousei,
Nore.SlgCommand.dousei,
this.isDouseiEnabled()
);
this.addCommand(TextManager.charStatus, Nore.SlgCommand.status, true);
this.addCommand(TextManager.facility, Nore.SlgCommand.facility, true);
this.addCommand(
TextManager._formation,
Nore.SlgCommand.formation,
this.isFormationEnabled()
);
this.addCommand(
TextManager.invasion,
Nore.SlgCommand.invasion,
this.isFormationEnabled()
);
this.addCommand(
TextManager.soupKichen,
Nore.SlgCommand.soupKichen,
this.isSoupKichenEnabled()
);
this.addCommand(
TextManager.decisiveBattle,
Nore.SlgCommand.decisiveBattle,
this.isDecisiveBattleEnabled()
);
this.addCommand(TextManager._save, Nore.SlgCommand.save, true);
};
Window_SlgCommand.prototype.isDouseiEnabled = function () {
return $slg.facilityInfo().hasDouseiRoom();
};
Window_SlgCommand.prototype.isDecisiveBattleEnabled = function () {
return $gameSwitches.value(109) && !$gameSwitches.value(9);
};
Window_SlgCommand.prototype.isSoupKichenEnabled = function () {
return true;
//return $slg.manInfo().soupKichen().level() >= 1;
};
Window_SlgCommand.prototype.isFormationEnabled = function () {
return $gameSwitches.value(211);
};
Window_SlgCommand.prototype.drawItem = function (index) {
var symbol = this.commandSymbol(index);
var rect = this.itemLineRect(index);
var align = this.itemTextAlign();
this.resetTextColor();
//this.changePaintOpacity(this.isCommandEnabled(index));
//this.drawText(this.commandName(index), rect.x, rect.y, rect.width, align);
var disable = !this.isCommandEnabled(index);
var pushed = false;
if (this.index() == index && !this.active) {
pushed = true;
}
var button = new Sprite_Button3(symbol, true, disable, pushed);
var left = rect.x + 8 + 9;
var yy = rect.y - 4;
button.x = left;
button.y = yy;
this._windowContentsSprite.addChild(button);
this._buttonList.push(button);
};
Window_SlgCommand.prototype.drawBackgroundRect = function () {};
Window_SlgCommand.prototype.select = function (index) {
_super.prototype.select.call(this, index);
if (!this._buttonList) {
return;
}
for (var i = 0; i < this._buttonList.length; i++) {
var button = this._buttonList[i];
if (i == index) {
button.select();
} else {
button.deselect();
button.deactivate();
}
}
if (index < 0) {
for (var i = 0; i < this._buttonList.length; i++) {
var button = this._buttonList[i];
button.activate();
}
}
};
Window_SlgCommand.prototype.currentSymbol = function () {
var symbol = _super.prototype.currentSymbol.call(this);
if (symbol == Nore.SlgCommand.soupKichen) {
if (!this.isSoupKichenEnabled()) {
return "";
}
}
if (symbol == Nore.SlgCommand.formation) {
if (!this.isFormationEnabled()) {
return "";
}
}
if (symbol == Nore.SlgCommand.invasion) {
if (!this.isFormationEnabled()) {
return "";
}
}
if (symbol == Nore.SlgCommand.decisiveBattle) {
if (!this.isDecisiveBattleEnabled()) {
return "";
}
}
return symbol;
};
Window_SlgCommand.prototype.cursorDown = function (wrap) {
var index = this.index();
var maxItems = this.maxItems();
var maxCols = this.maxCols();
if (index < maxItems - maxCols || (wrap && maxCols === 1)) {
var next = (index + maxCols) % maxItems;
for (var i = 0; i < 4; i++) {
if (!this._list[next].enabled) {
next++;
}
}
this.smoothSelect(next);
}
};
Window_SlgCommand.prototype.cursorUp = function (wrap) {
var index = Math.max(0, this.index());
var maxItems = this.maxItems();
var maxCols = this.maxCols();
if (index >= maxCols || (wrap && maxCols === 1)) {
var next = (index - maxCols + maxItems) % maxItems;
for (var i = 0; i < 4; i++) {
if (!this._list[next].enabled) {
next--;
}
}
this.smoothSelect(next);
}
};
Window_SlgCommand.prototype.setCursorRect = function () {};
Window_SlgCommand.prototype.onPush = function () {
if (!this._buttonList) {
return;
}
var index = this.index();
for (var i = 0; i < this._buttonList.length; i++) {
var button = this._buttonList[i];
if (i == index) {
button.push();
} else {
button.up();
}
}
};
Window_SlgCommand.prototype.onUp = function () {
if (!this._buttonList) {
return;
}
for (var i = 0; i < this._buttonList.length; i++) {
var button = this._buttonList[i];
button.up();
}
};
Window_SlgCommand.prototype.processCancel = function () {
SoundManager.playCancel();
this.updateInputData();
this.callCancelHandler();
};
return Window_SlgCommand;
})(Window_Command);
Nore.Window_SlgCommand = Window_SlgCommand;
})(Nore || (Nore = {}));