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

66 lines
2.3 KiB
JavaScript

Window.prototype._createBackSprite = function () {
this._backSprite = new Sprite();
this._backSprite.addChild(new TilingSprite());
this._backSprite.addChild(new Sprite());
this._backSprite.addChild(new Sprite());
this._container.addChild(this._backSprite);
};
Window.prototype._refreshBack = function () {
var m = this._margin;
var w = Math.max(0, this._width - m * 2);
var h = Math.max(0, this._height - m * 2);
var sprite = this._backSprite;
var tilingSprite = sprite.children[0];
// [Note] We use 95 instead of 96 here to avoid blurring edges.
var sprite2 = sprite.children[1];
sprite2.bitmap = this._windowskin;
sprite2.setFrame(0, 0, 95, 95);
sprite2.move(m, m);
sprite2.scale.x = w / 95;
sprite2.scale.y = h / 95;
tilingSprite.bitmap = this._windowskin;
tilingSprite.setFrame(0, 96, 96, 96);
tilingSprite.move(0, 0, w, h);
tilingSprite.scale.x = 1 / sprite.scale.x;
tilingSprite.scale.y = 1 / sprite.scale.y;
//tilingSprite.alpha = 0.8
//sprite2.alpha = 0.2
sprite.setColorTone(this._colorTone);
var mm = 10;
var sumiSprite = sprite.children[2];
sumiSprite.removeChildren();
if (this._isNoSumi) {
return;
}
var baseTexture = Nore.getSystemBaseTexture("Window_sumi");
var ww = baseTexture.width / 2;
var hh = baseTexture.height / 2;
{
var texture = new PIXI.Texture(baseTexture, new Rectangle(0, 0, ww, hh));
var spriteOption1 = new PIXI.Sprite(texture);
spriteOption1.x = mm;
spriteOption1.y = mm;
sumiSprite.addChild(spriteOption1);
}
{
var texture = new PIXI.Texture(baseTexture, new Rectangle(ww, 0, ww, hh));
var spriteOption2 = new PIXI.Sprite(texture);
spriteOption2.x = this._width - mm - ww;
spriteOption2.y = mm;
sumiSprite.addChild(spriteOption2);
}
{
var texture = new PIXI.Texture(baseTexture, new Rectangle(0, hh, ww, hh));
var spriteOption2 = new PIXI.Sprite(texture);
spriteOption2.x = mm;
spriteOption2.y = this._height - mm - hh;
sumiSprite.addChild(spriteOption2);
}
{
var texture = new PIXI.Texture(baseTexture, new Rectangle(ww, hh, ww, hh));
var spriteOption2 = new PIXI.Sprite(texture);
spriteOption2.x = this._width - mm - ww;
spriteOption2.y = this._height - mm - hh;
sumiSprite.addChild(spriteOption2);
}
};