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

374 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 MEM_W = 185;
var CharCommand;
(function (CharCommand) {
CharCommand["av"] = "av";
CharCommand["kigae"] = "kigae";
CharCommand["status"] = "status";
})(CharCommand || (CharCommand = {}));
var Window_CharacterList = /** @class */ (function (_super) {
__extends(Window_CharacterList, _super);
function Window_CharacterList() {
var _this = this;
var y = Nore.TOP_Y;
var offset = 7 * 6;
var rect = new Rectangle(
140 + offset,
y,
1140 - offset + 8,
Graphics.height - y + 8
);
_this = _super.call(this, rect) || this;
_this.frameVisible = false;
_this.createBackground();
return _this;
}
Window_CharacterList.prototype.initialize = function (rect) {
_super.prototype.initialize.call(this, rect);
this.padding = 0;
this._additionalSprites = {};
this.contents.outlineWidth = 4;
this.contents.outlineColor = "rgba(0, 0, 0, 0.8)";
this.refresh();
};
Window_CharacterList.prototype.itemRect = function (index) {
var rect = _super.prototype.itemRect.call(this, index);
rect.x += 15;
rect.y += 20;
return rect;
};
Window_CharacterList.prototype.itemWidth = function () {
var w = _super.prototype.itemWidth.call(this);
return w - 5;
};
Window_CharacterList.prototype.createBackground = function () {
var baseTexture = Nore.getSystemBaseTexture("menu");
if (!baseTexture) {
return;
}
var texture = new PIXI.Texture(
baseTexture,
new Rectangle(184, 0, baseTexture.width - 184, baseTexture.height)
);
this._bg = new PIXI.Sprite(texture);
this._bg.x = 2;
this._bg.y = 2;
this._contentsBackSprite.addChild(this._bg);
};
Window_CharacterList.prototype.itemBackgroundSprite = function () {
var baseTexture = Nore.getSystemBaseTexture("menu2");
if (!baseTexture) {
return;
}
var texture = new PIXI.Texture(baseTexture, new Rectangle(0, 0, 143, 715));
var sprite = new PIXI.Sprite(texture);
return sprite;
};
Window_CharacterList.prototype.itemBackgroundSprite2 = function () {
var baseTexture = Nore.getSystemBaseTexture("menu2");
if (!baseTexture) {
return;
}
var y = 300;
var texture = new PIXI.Texture(
baseTexture,
new Rectangle(143, y, 143, 715 - y)
);
var sprite = new PIXI.Sprite(texture);
sprite.y = y;
sprite.blendMode = PIXI.BLEND_MODES.HARD_LIGHT;
sprite.alpha = 0.7;
return sprite;
};
Window_CharacterList.prototype.itemMaskSprite = function () {
var baseTexture = Nore.getSystemBaseTexture("menu2");
if (!baseTexture) {
return;
}
var y = 50;
var texture = new PIXI.Texture(
baseTexture,
new Rectangle(144, y, 139, 200 - y)
);
var sprite = new PIXI.Sprite(texture);
sprite.y = y;
return sprite;
};
Window_CharacterList.prototype.douseiSprite = function () {
var baseTexture = Nore.getSystemBaseTexture("menu2");
if (!baseTexture) {
return;
}
var texture = new PIXI.Texture(baseTexture, new Rectangle(150, 0, 75, 30));
var sprite = new PIXI.Sprite(texture);
return sprite;
};
Window_CharacterList.prototype.makeItems = function () {
this._dataList = [];
var list = this.getActorIdList();
for (var i = 0; i < list.length; i++) {
var actor = $gameActors.actor(list[i]);
this._dataList.push(actor);
}
};
Window_CharacterList.prototype.refresh = function () {
this.makeItems();
this.contents.clear();
this._windowContentsBackSprite2.removeChildren();
this._windowContentsSprite.removeChildren();
_super.prototype.refresh.call(this);
for (var i = 0; i < this._dataList.length; i++) {
var actor = this._dataList[i];
var rect = this.itemRect(i);
this.drawActor(actor, rect);
}
//this.drawLine(486);
};
Window_CharacterList.prototype.drawActor = function (a, rect) {
var actor = JsonEx.makeDeepCopy(a);
var bg = this.itemBackgroundSprite();
bg.x = rect.x + 4;
bg.y = rect.y;
this._windowContentsBackSprite.addChild(bg);
this.changePaintOpacity(this.isEnabled(actor));
var tachieX = rect.x + this.xPosByActor(actor.actorId()) - 74;
var faceId = this.actorFaceId(actor);
if (actor.getDefaultFaceId() > 1) {
faceId = actor.getDefaultFaceId();
}
actor.setHoppeId(this.hoppeId(actor));
var charRect = new Rectangle(rect.x + 16 - 22, 66, 139, 400);
var sprite = this.drawTachieActor(
actor,
this._windowContentsBackSprite,
tachieX,
rect.y - 108,
charRect,
faceId,
0.6,
false
);
var mask = this.itemMaskSprite();
mask.x = bg.x + 2;
mask.y += bg.y + 277;
this._windowContentsBackSprite.addChild(mask);
var bg2 = this.itemBackgroundSprite2();
bg2.x = bg.x;
bg2.y += bg.y;
this._windowContentsBackSprite.addChild(bg2);
var yy = rect.y + 400;
var xx = rect.x + 20;
this.drawDousei(actor, xx, yy);
yy += 60;
this.drawStatus(actor, xx, yy);
yy += 210;
this.drawSyusan(actor, xx, yy);
this.contents.fontSize = 22;
this.drawActorName(actor, xx - 10, rect.y + 2);
this.contents.fontSize = 20;
var hpSprite = new Nore.Sprite_ActorHp(actor);
hpSprite.x = rect.x + 24;
hpSprite.y = rect.y + 50;
this._windowContentsSprite.addChild(hpSprite);
};
Window_CharacterList.prototype.drawDousei = function (actor, x, y) {
if (!actor.dousei().isEnabled()) {
return;
}
this.contents.fontSize = 18;
if (actor.dousei().manId() > 0) {
if (ConfigManager.language == "jp") {
var s = this.douseiSprite();
s.x = x - 2;
s.y = y - 2;
this.addChild(s);
} else {
this.changeTextColor(ColorManager.crisisColor());
this.drawText(TextManager.cohabiting, x, y, 104);
}
this.changeTextColor(ColorManager.normalColor());
var manName = actor.dousei().manName();
this.drawText(manName, x, y + 24, 108, "right");
var friendshipLevel = actor.friendshipLevel(actor.dousei().manId());
var text = actor.getFriendshipLevelText(friendshipLevel);
this.drawText(text, x + 4, y + 24, 104, "left");
} else {
this.changeTextColor(ColorManager.normalColor());
//this.drawText('', x, y, 120);
}
};
Window_CharacterList.prototype.lineHeight = function () {
return 30;
};
Window_CharacterList.prototype.drawBackgroundRect = function (rect) {
_super.prototype.drawBackgroundRect.call(this, rect);
};
Window_CharacterList.prototype.placeBasicGauges = function (actor, x, y) {
this.placeGauge(actor, "hp", x, y);
this.placeGauge(actor, "mp", x, y + this.gaugeLineHeight());
};
Window_CharacterList.prototype.gaugeLineHeight = function () {
return 24;
};
Window_CharacterList.prototype.drawLabel = function (label, x, y) {
var baseTexture2 = Nore.getSystemBaseTexture("Battle");
var rect = new Rectangle(0, 0, 48, 24);
if (label == "HP") {
rect.y = 24;
}
if (label == "MP") {
rect.y = 48;
}
var texture = new PIXI.Texture(baseTexture2, rect);
var sprite = new PIXI.Sprite(texture);
sprite.x = x;
sprite.y = y + 22;
this._windowContentsSprite.addChild(sprite);
};
Window_CharacterList.prototype.getBgSprite = function (index, rect) {
var baseTexture2 = Nore.getSystemBaseTexture("back" + index);
var texture = new PIXI.Texture(
baseTexture2,
new Rectangle(0, 0, rect.width, 480)
);
var sprite = new PIXI.Sprite(texture);
return sprite;
};
Window_CharacterList.prototype.maxItems = function () {
if (!this._dataList) {
return 0;
}
return this._dataList.length;
};
Window_CharacterList.prototype.maxCols = function () {
return 7;
};
Window_CharacterList.prototype.itemHeight = function () {
return this.height - 30;
};
Window_CharacterList.prototype.drawSyusan = function (actor, xx, yy) {
this.drawIcon(Icon.baby, xx, yy);
this.drawText(actor.countSyusan(), xx + 50, yy, 52, "right");
};
Window_CharacterList.prototype.drawStatus = function (actor, xx, yy) {
this.changeTextColor(ColorManager.normalColor());
var list = Nore.$avParamManager.list();
for (var i = 0; i < list.length; i++) {
this.drawStatusOne(actor, xx, yy, i, list[i]);
}
};
Window_CharacterList.prototype.drawStatusOne = function (
actor,
x,
y,
index,
info
) {
this.contents.fontSize = 24;
var yy = y + index * 32;
var xx = x;
this.drawIcon(info.iconIndex(), xx, yy);
this.drawText(
Math.floor(actor.eroParam(info.type()) / 10),
xx + 50,
yy,
52,
"right"
);
};
Window_CharacterList.prototype.placeGauge = function (actor, type, x, y) {
var key = "actor%1-gauge-%2".format(actor.actorId(), type);
var sprite = this.createInnerSprite(key, Sprite_Gauge);
sprite.setup(actor, type);
sprite.move(x, y);
sprite.show();
};
Window_CharacterList.prototype.createInnerSprite = function (
key,
spriteClass
) {
var dict = this._additionalSprites;
if (dict[key]) {
return dict[key];
} else {
var sprite = new spriteClass();
dict[key] = sprite;
this.addInnerChild(sprite);
return sprite;
}
};
Window_CharacterList.prototype.selectedActor = function () {
return this._dataList[this.index()];
};
Window_CharacterList.prototype.selectActor = function (actorId) {
for (var i = 0; i < this._dataList.length; i++) {
var actor = this._dataList[i];
if (actor.actorId() == actorId) {
this.select(i);
return;
}
}
};
Window_CharacterList.prototype.setSlgType = function (type) {
this._slgType = type;
};
Window_CharacterList.prototype.isCurrentItemEnabled = function () {
var actor = this.selectedActor();
return this.isEnabled(actor);
};
Window_CharacterList.prototype.isEnabled = function (actor) {
if (this._slgType != Nore.SlgCommand.dousei) {
return true;
}
return actor.dousei().isEnabled();
};
Window_CharacterList.prototype.refreshCursor = function () {
if (this._cursorAll) {
this.refreshCursorForAll();
} else if (this.index() >= 0) {
var rect = this.itemRect(this.index());
this.setCursorRect(
rect.x - 6,
rect.y - 16,
rect.width + 4 + 8,
rect.height + 16
);
} else {
this.setCursorRect(0, 0, 0, 0);
}
};
Window_CharacterList.prototype.colSpacing = function () {
return 3;
};
return Window_CharacterList;
})(Nore.Window_MembersBase);