alter-egoism/js/plugins/CBR_shop.js
2025-11-01 14:17:42 -05:00

860 lines
28 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

function CBR_Window_ShopHelp() {
this.initialize(...arguments);
}
function CBR_Window_ShopDo() {
this.initialize(...arguments);
}
(function () {
Scene_Shop.prototype.createDummyWindow = function () {
const rect = this.dummyWindowRect();
this._dummyWindow = new Window_Base(rect);
this._dummyWindow.hide();
this._dummyWindow.show = function () {};
this.addWindow(this._dummyWindow);
};
// // カテゴリウィンドウを消す
Scene_Shop.prototype.create = function () {
Scene_MenuBase.prototype.create.call(this);
this.createHelpWindow();
this.createCommandWindow();
this.createDummyWindow();
this.createBuyWindow();
this.createCategoryWindow();
this.createSellWindow();
this.createNumberWindow();
this.createGoldWindow();
this.createStatusWindow();
this.createDoWindow();
this._commandWindow.setBuyWindow(this._buyWindow);
this._commandWindow.setSellWindow(this._sellWindow);
this.addWindow(this._commandWindow);
this._commandWindow.select(0);
};
Scene_Shop.prototype.createBackground = function () {
this._backgroundSprite = new Sprite();
this._backgroundSprite.bitmap = ImageManager.loadSystem("shop_back");
this.addChild(this._backgroundSprite);
this._backgroundTextSprite = new Sprite(new Bitmap(Graphics.width, Graphics.height));
var b = this._backgroundTextSprite.bitmap;
b.fontFace = "serif";
b.fontSize = 32;
b.textColor = "#000000";
b.drawTextM("ショップ", 22, 20, 200, 22, "center");
this.addChild(this._backgroundTextSprite);
this._backgroundTextSprite2 = new Sprite(new Bitmap(200, 50));
var b2 = this._backgroundTextSprite2.bitmap;
b2.fontFace = "serif";
b2.fontSize = 18;
b2.textColor = "#000000";
b2.drawTextM("価格", 0, 0, 200, 50, "center");
this._backgroundTextSprite2.x = 524;
this._backgroundTextSprite2.y = 58;
this.addChild(this._backgroundTextSprite2);
this._backgroundTextSprite3 = new Sprite(new Bitmap(200, 50));
var b3 = this._backgroundTextSprite3.bitmap;
b3.fontFace = "serif";
b3.fontSize = 18;
b3.textColor = "#000000";
b3.drawTextM("所持数", 0, 0, 200, 50, "center");
this._backgroundTextSprite3.x = 614;
this._backgroundTextSprite3.y = 58;
this.addChild(this._backgroundTextSprite3);
};
Scene_Shop.prototype.createCommandWindow = function () {
const rect = this.commandWindowRect();
this._commandWindow = new Window_ShopCommand(rect);
this._commandWindow.setPurchaseOnly(this._purchaseOnly);
// this._commandWindow.y = this.mainAreaTop();
// this._commandWindow.setHandler("buy", this.commandSell.bind(this));
// this._commandWindow.setHandler("item", this.commandSell.bind(this));
// this._commandWindow.setHandler("weapon", this.commandSell.bind(this));
this._commandWindow.setHandler("cancel", this.popScene.bind(this));
//this.addWindow(this._commandWindow);
};
Scene_Shop.prototype.createDoWindow = function () {
const rect = this.doWindowRect();
this._doWindow = new CBR_Window_ShopDo(rect);
this._doWindow.hide();
this._doWindow.setHandler("ok", this.onDoOk.bind(this));
this._doWindow.setHandler("cancel", this.onDoCancel.bind(this));
this.addWindow(this._doWindow);
};
Scene_Shop.prototype.createBuyWindow = function () {
const rect = this.buyWindowRect();
this._buyWindow = new Window_ShopBuy(rect);
this._buyWindow.setupGoods(this._goods);
this._buyWindow.setHelpWindow(this._helpWindow);
this._buyWindow.setStatusWindow(this._statusWindow);
this._buyWindow.hide();
this._buyWindow.setHandler("ok", this.onBuyOk.bind(this));
//this._buyWindow.setHandler("cancel", this.onBuyCancel.bind(this));
this.addWindow(this._buyWindow);
};
Scene_Shop.prototype.onBuyOk = function () {
this._item = this._buyWindow.item();
this._buyWindow.hide();
this._numberWindow.setup(this._item, this.maxBuy(), this.buyingPrice());
this._numberWindow.setCurrencyUnit(this.currencyUnit());
this._numberWindow.show();
this._numberWindow.activate();
};
Scene_Shop.prototype.createSellWindow = function () {
const rect = this.sellWindowRect();
this._sellWindow = new Window_ShopSell(rect);
this._sellWindow.setHelpWindow(this._helpWindow);
this._sellWindow.hide();
this._sellWindow.setHandler("ok", this.onSellOk.bind(this));
// this._sellWindow.setHandler("cancel", this.onSellCancel.bind(this));
//this._categoryWindow.setItemWindow(this._sellWindow);
this.addWindow(this._sellWindow);
// if (!this._categoryWindow.needsSelection()) {
// this._sellWindow.y -= this._categoryWindow.height;
// this._sellWindow.height += this._categoryWindow.height;
// }
};
// 種類ウィンドウを非アクティブにする
Scene_Shop.prototype.onBuyOk = function () {
this._item = this._buyWindow.item();
//this._buyWindow.hide();
this._commandWindow.deactivate();
this._numberWindow.setup(this._item, this.maxBuy(), this.buyingPrice());
this._numberWindow.setCurrencyUnit(this.currencyUnit());
this._numberWindow.show();
this._numberWindow.activate();
};
Scene_Shop.prototype.onSellOk = function () {
this._item = this._sellWindow.item();
this._categoryWindow.hide();
//this._sellWindow.hide();
this._commandWindow.deactivate();
this._numberWindow.setup(this._item, this.maxSell(), this.sellingPrice());
this._numberWindow.setCurrencyUnit(this.currencyUnit());
this._numberWindow.show();
this._numberWindow.activate();
this._statusWindow.setItem(this._item);
this._statusWindow.show();
};
Scene_Shop.prototype.endNumberInput = function () {
//this._numberWindow.hide();
switch (this._commandWindow.currentSymbol()) {
case "buy":
this.activateBuyWindow();
break;
case "item":
this.activateSellWindow();
break;
case "weapon":
this.activateSellWindow();
break;
}
};
Scene_Shop.prototype.onNumberOk = function () {
this._numberWindow.deactivate();
this._doWindow.show();
this._doWindow.activate();
};
// 種類ウィンドウをアクティブにする
Scene_Shop.prototype.onDoOk = function () {
SoundManager.playShop();
switch (this._commandWindow.currentSymbol()) {
case "buy":
this.doBuy(this._numberWindow.number());
break;
case "item":
this.doSell(this._numberWindow.number());
break;
case "weapon":
this.doSell(this._numberWindow.number());
break;
}
this._doWindow.hide();
this._commandWindow.activate();
this.endNumberInput();
this._goldWindow.refresh();
this._statusWindow.refresh();
this._numberWindow.refresh_emp();
};
Scene_Shop.prototype.onDoCancel = function () {
this._doWindow.hide();
this._numberWindow.activate();
SoundManager.playCancel();
//this.endNumberInput();
};
Scene_Shop.prototype.onNumberCancel = function () {
this._numberWindow.refresh_emp();
this._commandWindow.activate();
SoundManager.playCancel();
this.endNumberInput();
};
// ##########################################################
// ############### 種類ウィンドウ #####################
// ##########################################################
Scene_Shop.prototype.commandWindowRect = function () {
const wx = 270;
const wy = -4;
const ww = 420;
const wh = 58 + 8;
return new Rectangle(wx, wy, ww, wh);
};
Window_ShopCommand.prototype.maxCols = function () {
return 3;
};
Window_ShopCommand.prototype.setSellWindow = function (sellWindow) {
this._sellWindow = sellWindow;
};
Window_ShopCommand.prototype.setBuyWindow = function (buyWindow) {
this._buyWindow = buyWindow;
};
Window_ShopCommand.prototype.select = function (index) {
this._index = index;
this.contents.clear();
this.contentsBack.clear();
this.drawAllItems();
this.refreshCursor();
this.callUpdateHelp();
if (this.showingIndx !== index) {
if (this._sellWindow && this._buyWindow) {
this.showingIndx = index;
if (index == 1 || index == 2) {
this._buyWindow.hide();
this._buyWindow.deactivate();
this._sellWindow.show();
this._sellWindow.refresh();
this._sellWindow.select(0);
this._sellWindow.activate();
var ary = [, "item", "weapon"];
this._sellWindow.setCategory(ary[index]);
this._sellWindow.callUpdateHelp();
} else {
this._sellWindow.hide();
this._sellWindow.deactivate();
this._buyWindow.setMoney($gameParty.gold());
this._buyWindow.show();
this._buyWindow.refresh();
this._buyWindow.select(0);
this._buyWindow.activate();
this._buyWindow.callUpdateHelp();
}
}
}
};
Window_ShopCommand.prototype.makeCommandList = function () {
this.addCommand(TextManager.buy, "buy");
this.addCommand("アイテム売却", "item");
this.addCommand("装備売却", "weapon");
};
Window_ShopCommand.prototype._refreshAllParts = function () {
this._padding = 0;
//this._refreshBack();
//this._refreshFrame();
this._refreshCursor();
this._refreshArrows();
this._refreshPauseSign();
};
//カーソルの変更
Window_ShopCommand.prototype.loadWindowskin = function () {
this.windowskin = ImageManager.loadSystem("Window");
this.menu_item_skin = ImageManager.loadSystem("menu_item_categoly_select");
this.menu_cursor_skin = ImageManager.loadSystem("menu_item_categoly_cursor");
if (!this.menu_item_skin.isReady()) {
this.menu_item_skin.addLoadListener(() => {
this.refresh(); // 画像がロードされたら再描画
});
return;
}
};
Window_ShopCommand.prototype.lineHeight = function () {
return 58;
};
Window_ShopCommand.prototype._refreshCursor = function () {
const drect = this._cursorRect.clone();
const srect = { x: 0, y: 0, width: 126, height: 58 };
const m = 0;
for (const child of this._cursorSprite.children) {
child.bitmap = this.menu_cursor_skin;
}
this._setRectPartsGeometry(this._cursorSprite, srect, drect, m);
};
//カーソルを微調整、あとカーソルを常に不透明に
Window_ShopCommand.prototype._updateCursor = function () {
this._cursorSprite.alpha = 255;
this._cursorSprite.visible = this.isOpen() && this.cursorVisible;
this._cursorSprite.x = this._cursorRect.x;
this._cursorSprite.y = this._cursorRect.y - 4;
};
//未選択コマンドの背景を画像に
Window_ShopCommand.prototype.drawItemBackground = function (index) {
const rect = this.itemRect(index);
if (this.menu_item_skin.isReady()) {
const bitmap = this.menu_item_skin;
const dx = rect.x;
const dy = rect.y;
const dw = rect.width;
const dh = rect.height;
this.contentsBack.blt(bitmap, 0, 0, 126, 58, dx, dy - 4, dw, dh);
}
};
//カーソルが来た時、アイテムの文字名の色を変更する
Window_ShopCommand.prototype.drawItem = function (index) {
const rect = this.itemLineRect(index);
const align = this.itemTextAlign();
this.resetTextColor();
if (index == this._index) {
this.changeTextColor("#000000");
}
this.changePaintOpacity(this.isCommandEnabled(index));
//文字をちょっと下にする
this.drawTextS(this.commandName(index), rect.x, rect.y + 8, rect.width, align);
};
//↑のセレクトでの不具合を出ないようにする
Window_ShopCommand.prototype.drawAllItems = function () {
const topIndex = this.topIndex();
for (let i = 0; i < this.maxVisibleItems(); i++) {
const index = topIndex + i;
if (this._list && index < this.maxItems()) {
//選択ちゅうだけ背景なくす
if (i != this._index) {
this.drawItemBackground(index);
}
this.drawItem(index);
}
}
};
// ##########################################################
// ############### 購入ウィンドウ #####################
// ##########################################################
Scene_Shop.prototype.buyWindowRect = function () {
const wx = 4;
const wy = 86;
const ww = 780 - 7;
const wh = 464;
return new Rectangle(wx, wy, ww, wh);
};
Window_ShopBuy.prototype._refreshAllParts = function () {
//this._refreshBack();
//this._refreshFrame();
this._refreshCursor();
this._refreshArrows();
this._refreshPauseSign();
};
Window_ShopBuy.prototype.numberWidth = function () {
return this.textWidth("000");
};
Window_ShopBuy.prototype.drawItem = function (index) {
const item = this.itemAt(index);
if (item) {
const numberWidth = this.numberWidth();
const rect = this.itemLineRect(index);
this.changePaintOpacity(this.isEnabled(item));
this.drawItemName(item, rect.x, rect.y, rect.width - numberWidth);
this.drawItemNumber(item, rect.x, rect.y, rect.width);
this.changeTextColor("#000000");
this.drawTextM(item.price, rect.x + 520, rect.y, 96, "right");
this.changePaintOpacity(1);
}
};
Window_ShopBuy.prototype.drawItemName = function (item, x, y, width) {
if (item) {
const iconY = y + (this.lineHeight() - ImageManager.iconHeight) / 2;
const delta = ImageManager.standardIconWidth - ImageManager.iconWidth;
const textMargin = ImageManager.standardIconWidth + 4;
const itemWidth = Math.max(0, width - textMargin);
this.resetTextColor();
//this.drawIcon(item.iconIndex, x + delta / 2, iconY);
this.changeTextColor("#000000");
this.contents.fontFace = "serif";
this.drawTextM(item.name, x + textMargin + 24 + 30, y, itemWidth);
this.resetTextColor();
}
};
Window_ShopBuy.prototype.drawItemNumber = function (item, x, y, width) {
// if (this.needsNumber()) {
this.changeTextColor("#000000");
this.drawTextS($gameParty.numItems(item), x - 30, y, width, "right");
this.resetTextColor();
// }
};
Window_ShopBuy.prototype.maxCols = function () {
return 1;
};
//カーソルの変更
Window_ShopBuy.prototype.loadWindowskin = function () {
this.windowskin = ImageManager.loadSystem("Window");
this.menu_cursor_skin = ImageManager.loadSystem("menu_item_selected");
this.menu_item_skin = ImageManager.loadSystem("menu_item_selected_2");
};
//56×200にする
Window_ShopBuy.prototype._refreshCursor = function () {
const drect = this._cursorRect.clone();
const srect = { x: 0, y: 40, width: 588, height: 40 };
const m = 0;
for (const child of this._cursorSprite.children) {
child.bitmap = this.menu_item_skin;
}
this._setRectPartsGeometry(this._cursorSprite, srect, drect, m);
};
//未選択コマンドの背景を画像に
Window_ShopBuy.prototype.drawItemBackground = function (index) {
const rect = this.itemRect(index);
if (this.menu_item_skin) {
const bitmap = this.menu_item_skin;
const dx = rect.x;
const dy = rect.y;
const dw = rect.width;
const dh = rect.height;
this.contentsBack.blt(bitmap, 0, 0, 588, 40, dx, dy, dw, dh);
}
};
// ##########################################################
// ############### 売却ウィンドウ #####################
// ##########################################################
Scene_Shop.prototype.sellWindowRect = function () {
const wx = 0;
const wy = 86;
const ww = 780 + 1;
const wh = 464;
return new Rectangle(wx, wy, ww, wh);
};
Window_ShopSell.prototype.drawItemName = function (item, x, y, width) {
if (item) {
const iconY = y + (this.lineHeight() - ImageManager.iconHeight) / 2;
const delta = ImageManager.standardIconWidth - ImageManager.iconWidth;
const textMargin = ImageManager.standardIconWidth + 4;
const itemWidth = Math.max(0, width - textMargin);
this.resetTextColor();
//this.drawIcon(item.iconIndex, x + delta / 2, iconY);
this.changeTextColor("#000000");
this.contents.fontFace = "serif";
this.drawTextM(item.name, x + textMargin + 24 + 30, y, itemWidth);
this.resetTextColor();
}
};
// Window_ShopSell.prototype.updateHelp = function () {
// this.setHelpWindowItem(this.item());
// };
Window_ShopSell.prototype.drawItem = function (index) {
const item = this.itemAt(index);
if (item) {
const numberWidth = this.numberWidth();
const rect = this.itemLineRect(index);
this.changePaintOpacity(this.isEnabled(item));
this.drawItemName(item, rect.x, rect.y, rect.width - numberWidth);
this.drawItemNumber(item, rect.x, rect.y, rect.width);
this.changeTextColor("#000000");
this.drawTextM(Math.floor(item.price / 2), rect.x + 520, rect.y, 96, "right");
this.changePaintOpacity(1);
}
};
// ##########################################################
// #################### ステータスウィンドウ ###################
// ##########################################################
Scene_Shop.prototype.createStatusWindow = function () {
const rect = this.statusWindowRect();
this._statusWindow = new Window_ShopStatus(rect);
this._statusWindow._isWindow = false;
this._statusWindow.hide();
this._statusWindow.show = function () {};
this.addWindow(this._statusWindow);
};
Scene_Shop.prototype.statusWindowRect = function () {
const ww = this.statusWidth();
const wh = 400;
const wx = Graphics.boxWidth - ww;
const wy = 300;
return new Rectangle(wx, wy, ww, wh);
};
// ##########################################################
// #################### 数値入力ウィンドウ ###################
// ##########################################################
Scene_Shop.prototype.numberWindowRect = function () {
const wx = 770;
const wy = 90;
const ww = 510;
const wh = 310;
return new Rectangle(wx, wy, ww, wh);
};
Scene_Shop.prototype.createNumberWindow = function () {
const rect = this.numberWindowRect();
this._numberWindow = new Window_ShopNumber(rect);
//this._numberWindow.hide();
this._numberWindow.setHandler("ok", this.onNumberOk.bind(this));
this._numberWindow.setHandler("cancel", this.onNumberCancel.bind(this));
this._numberWindow.refresh_emp();
this.addWindow(this._numberWindow);
};
Window_ShopNumber.prototype.refresh_emp = function () {
Window_Selectable.prototype.refresh.call(this);
this.contents.fontFace = "serif";
this.contents.fontSize = 18;
this.contents.textColor = "#000000";
this.drawItemBackground(0);
this.contents.textColor = "#000000";
this.drawTextM("所持金", 154, 24, 200, "center");
this.drawTextM("購入合計", 154, 54, 200, "center");
this.drawTextM("円", 326, 24, 200, "center");
this.drawTextM("円", 326, 54, 200, "center");
this.contents.textColor = "#FFFFFF";
this.drawTextS($gameParty.gold(), 95, 24, 300, "right");
};
const _Window_ShopNumber_update = Window_ShopNumber.prototype.update;
Window_ShopNumber.prototype.update = function () {
_Window_ShopNumber_update.apply(this, arguments);
if (this.active && TouchInput.isTriggered()) {
if (this.isTouchedInsideLeftArea()) {
} else if (this.isTouchedInsideFrame()) {
this.parent.parent.onNumberOk(); // 購入確定処理
}
}
};
Window_ShopNumber.prototype.isTouchedInsideLeftArea = function () {
// マウス左クリック押した瞬間を検出
if (TouchInput.isTriggered()) {
// 画面全体の座標
const mx = TouchInput.x;
const my = TouchInput.y;
// このウィンドウの内側座標に変換
const localX = mx - this.x - this.padding;
const localY = my - this.y - this.padding;
// 左
if (30 <= localX && localX <= 75 && 35 <= localY && localY <= 70) {
this.changeNumber(-1);
return true;
// 右
} else if (30 + 115 <= localX && localX <= 75 + 115 && 35 <= localY && localY <= 70) {
this.changeNumber(1);
return true;
// 上
} else if (90 <= localX && localX <= 125 && -10 <= localY && localY <= 35) {
this.changeNumber(10);
return true;
} else if (90 <= localX && localX <= 125 && -10 + 90 <= localY && localY <= 35 + 100) {
this.changeNumber(-10);
return true;
}
}
};
Window_ShopNumber.prototype.refresh = function () {
Window_Selectable.prototype.refresh.call(this);
this.contents.fontFace = "serif";
this.contents.fontSize = 18;
this.contents.textColor = "#000000";
this.drawItemBackground(0);
//this.drawCurrentItemName();
//this.drawMultiplicationSign();
this.drawNumber();
this.contents.fontSize = 18;
//this.drawHorzLine();
this.drawTotalPrice();
this.contents.textColor = "#000000";
this.drawTextM("所持金", 154, 24, 200, "center");
this.drawTextM("購入合計", 154, 54, 200, "center");
this.drawTextM("円", 326, 24, 200, "center");
this.drawTextM("円", 326, 54, 200, "center");
this.contents.textColor = "#FFFFFF";
this.drawTextS($gameParty.gold(), 95, 24, 300, "right");
};
Window_ShopNumber.prototype.drawNumber = function () {
this.contents.fontSize = 32;
const x = this.cursorX();
const y = this.itemNameY();
const width = this.cursorWidth() - this.itemPadding();
this.resetTextColor();
this.drawText(this._number, x + 12, y, width, "center");
};
Window_ShopNumber.prototype.cursorX = function () {
const padding = this.itemPadding();
return this.innerWidth - this.cursorWidth() - padding * 2 - 332;
};
Window_ShopNumber.prototype.playOkSound = function () {
SoundManager.playOk();
};
Window_ShopNumber.prototype.itemNameY = function () {
return Math.floor(this.innerHeight / 2 - this.lineHeight() * 1.5) - 29;
};
Window_ShopNumber.prototype.cursorWidth = function () {
const padding = this.itemPadding();
const digitWidth = this.textWidth("0");
return this.maxDigits() * digitWidth + padding * 2 + 20;
};
Window_ShopNumber.prototype.lineHeight = function () {
return 36 + 14;
};
// 購入額 売却額
Window_ShopNumber.prototype.drawCurrencyValue = function (value, unit, x, y, width) {
const unitWidth = Math.min(80, this.textWidth(unit));
this.resetTextColor();
this.drawTextS(value, x + 94, y - 83, 300, "right");
// this.changeTextColor(ColorManager.systemColor());
// this.drawText(unit, x + width - unitWidth, y, unitWidth, "right");
};
Window_ShopNumber.prototype._refreshAllParts = function () {
// this._refreshBack();
// this._refreshFrame();
this._refreshCursor();
this._refreshArrows();
this._refreshPauseSign();
};
// ##########################################################
// #################### はい・いいえウィンドウ ###################
// ##########################################################
Scene_Shop.prototype.doWindowRect = function () {
const wx = 800;
const wy = 270;
const ww = 450;
const wh = 90;
return new Rectangle(wx, wy, ww, wh);
};
CBR_Window_ShopDo.prototype = Object.create(Window_Command.prototype);
CBR_Window_ShopDo.prototype.constructor = CBR_Window_ShopDo;
CBR_Window_ShopDo.prototype.initialize = function (rect) {
Window_Command.prototype.initialize.call(this, rect);
//this.openness = 0;
this.deactivate();
};
CBR_Window_ShopDo.prototype.maxCols = function () {
return 2;
};
CBR_Window_ShopDo.prototype.makeCommandList = function () {
this.addCommand("購入", "ok");
this.addCommand("キャンセル", "cancel");
};
CBR_Window_ShopDo.prototype.drawItem = function (index) {
const rect = this.itemLineRect(index);
const align = this.itemTextAlign();
this.resetTextColor();
this.contents.fontFace = "serif";
this.contents.fontSize = 18;
if (this.index() === index) {
this.contents.textColor = "#000000";
} else {
this.contents.textColor = "#FFFFFF";
}
this.changePaintOpacity(this.isCommandEnabled(index));
if (this.parent && this.parent.parent._commandWindow.currentSymbol() !== "buy" && !index) {
this.drawTextM("売却", rect.x, rect.y, rect.width, align);
} else {
this.drawTextM(this.commandName(index), rect.x, rect.y, rect.width, align);
}
};
CBR_Window_ShopDo.prototype.select = function (index) {
this._index = index;
if (this._list) {
this.paint();
}
this.refreshCursor();
};
CBR_Window_ShopDo.prototype.playOkSound = function () {};
CBR_Window_ShopDo.prototype.loadWindowskin = function () {
this.windowskin = ImageManager.loadSystem("Window");
this._battlewindowskin = ImageManager.loadSystem("battle_command");
};
//無駄な物を削除
CBR_Window_ShopDo.prototype._refreshAllParts = function () {
// this._refreshBack();
// this._refreshFrame();
//this._refreshCursor();
//this._refreshArrows();
//this._refreshPauseSign();
};
//56×200にする
CBR_Window_ShopDo.prototype._refreshCursor = function () {
const drect = this._cursorRect.clone();
const srect = { x: 0, y: 0, width: 169, height: 58 };
const m = 4;
for (const child of this._cursorSprite.children) {
child.bitmap = this._battlewindowskin;
}
this._setRectPartsGeometry(this._cursorSprite, srect, drect, m);
};
//透明度を1に
CBR_Window_ShopDo.prototype._updateCursor = function () {
this._cursorSprite.alpha = 1;
this._cursorSprite.visible = this.isOpen() && this.cursorVisible;
this._cursorSprite.x = this._cursorRect.x;
this._cursorSprite.y = this._cursorRect.y;
};
//未選択コマンドの背景を画像に
CBR_Window_ShopDo.prototype.drawItemBackground = function (index) {
const rect = this.itemRect(index);
if (this._battlewindowskin) {
const bitmap = this._battlewindowskin;
const dx = rect.x;
const dy = rect.y;
const dw = rect.width;
const dh = rect.height;
this.contentsBack.blt(bitmap, 0, 58, 169, 58, dx, dy, dw, dh);
}
};
CBR_Window_ShopDo.prototype.itemHeight = function () {
return 58;
};
// ##########################################################
// #################### お金ウィンドウ ###################
// ##########################################################
Scene_Shop.prototype.createGoldWindow = function () {
const rect = this.goldWindowRect();
this._goldWindow = new Window_Gold(rect);
this._goldWindow.hide();
this.addWindow(this._goldWindow);
};
// ##########################################################
// #################### ヘルプウィンドウ #####################
// ##########################################################
Scene_Shop.prototype.helpWindowRect = function () {
const wx = 20;
const wy = 550;
const ww = 752;
const wh = 120;
return new Rectangle(wx, wy, ww, wh);
};
Scene_Shop.prototype.createHelpWindow = function () {
const rect = this.helpWindowRect();
this._helpWindow = new CBR_Window_ShopHelp(rect);
this.addWindow(this._helpWindow);
};
CBR_Window_ShopHelp.prototype = Object.create(Window_Help.prototype);
CBR_Window_ShopHelp.prototype.constructor = CBR_Window_ShopHelp;
CBR_Window_ShopHelp.prototype.loadWindowskin = function () {
this.windowskin = ImageManager.loadSystem("Window");
//this.CBR_back = ImageManager.loadSystem("battle_skill_help_window");
};
CBR_Window_ShopHelp.prototype._refreshAllParts = function () {
//this._refreshBack();
//this._refreshFrame();
this._refreshCursor();
this._refreshArrows();
this._refreshPauseSign();
};
// CBR_Window_ShopHelp.prototype.updateBackOpacity = function () {
// this.backOpacity = 255;
// };
CBR_Window_ShopHelp.prototype.refresh = function () {
const rect = this.baseTextRect();
this.contents.clear();
this.contents.fontFace = "serif";
this.contents.fontSize = 18;
this.contents.textColor = "#000000";
this.drawTextM("概要", rect.x + 4, rect.y - 3, 80, "center");
this.contents.textColor = "#FFFFFF";
this.drawTextExS(this._text, rect.x + 100, rect.y + 2, rect.width);
};
// ##########################################################
// #################### カテゴリーウィンドウ ##################
// ##########################################################
Scene_Shop.prototype.activateSellWindow = function () {
if (this._categoryWindow.needsSelection()) {
// this._categoryWindow.show();
}
this._sellWindow.refresh();
this._sellWindow.show();
this._sellWindow.activate();
this._statusWindow.hide();
};
Scene_Shop.prototype.commandSell = function () {
this._dummyWindow.hide();
this._sellWindow.show();
this._sellWindow.deselect();
this._sellWindow.refresh();
if (this._categoryWindow.needsSelection()) {
// this._categoryWindow.show();
// this._categoryWindow.activate();
} else {
this.onCategoryOk();
}
};
Scene_Shop.prototype.onSellCancel = function () {
this._sellWindow.deselect();
this._statusWindow.setItem(null);
this._helpWindow.clear();
if (this._categoryWindow.needsSelection()) {
//this._categoryWindow.activate();
} else {
this.onCategoryCancel();
}
};
})();