Skip to content
This repository has been archived by the owner on Jun 30, 2024. It is now read-only.

Commit

Permalink
Merge branch 'master' into merge-master-191022
Browse files Browse the repository at this point in the history
  • Loading branch information
matsuyuki-a committed Oct 22, 2019
2 parents b0a5faf + dd7f7b8 commit c733d96
Show file tree
Hide file tree
Showing 8 changed files with 6,107 additions and 1,474 deletions.
7,512 changes: 6,051 additions & 1,461 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"lerna": "^3.13.1",
"npm-run-all": "^4.1.3",
"devDependencies": {
"lerna": "^3.14.1",
"lerna": "^3.18.2",
"npm-run-all": "^4.1.5"
}
}
2 changes: 1 addition & 1 deletion packages/build-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"@types/node": "^10.5.1",
"@types/shelljs": "^0.8.0",
"@wwawing/html-generator": "git+https://[email protected]/WWAWing/html-generator.git#include-lib",
"@wwawing/engine": "3.2.1",
"@wwawing/engine": "3.2.2",
"@wwawing/assets": "0.0.0",
"@wwawing/loader": "0.0.0",
"@wwawing/debug-server": "0.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/engine/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wwawing/engine",
"version": "3.2.1",
"version": "3.2.2",
"description": "World Wide Adventure: an RPG Engine.",
"main": "wwa.js",
"scripts": {
Expand Down
3 changes: 3 additions & 0 deletions packages/engine/src/wwa_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,9 @@ export class WWAConsts {
static IMGPOS_DEFAULT_BATTLE_EFFECT_X: number = 3;
static IMGPOS_DEFAULT_BATTLE_EFFECT_Y: number = 3;

static IMGPOS_DEFAULT_ITEMBOX_BACKGROUND_X: number = 1;
static IMGPOS_DEFAULT_ITEMBOX_BACKGROUND_Y: number = 2;

static DEFAULT_DISABLE_SAVE: boolean = false;
static DEFAULT_OLDMAP: boolean = false;
static DEFAULT_OBJECT_NO_COLLAPSE: boolean = false;
Expand Down
41 changes: 38 additions & 3 deletions packages/engine/src/wwa_main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,13 @@ export class WWA {

private _isActive: boolean;

/**
* $imgframe で変更可能なアイテムボックスの画像位置(チップ単位)
* TODO: 将来はセーブデータに含まれるようになるので、 WWADataに移す。
* @see https://github.com/WWAWing/WWAWing/issues/156
*/
private _itemboxBackgroundPos : {x: number, y: number};

/**
* 背景パーツ番号として添字を与えると
* パーツが配置されている(X,Y)座標をビットパターンに変換したものの配列を見ることができます。
Expand Down Expand Up @@ -311,6 +318,10 @@ export class WWA {

this._wwaData = e.data.wwaData;
this._wwaData.isItemEffectEnabled = itemEffectEnabled;
this._itemboxBackgroundPos = {
x: Consts.IMGPOS_DEFAULT_ITEMBOX_BACKGROUND_X,
y: Consts.IMGPOS_DEFAULT_ITEMBOX_BACKGROUND_Y
};
try {
if (this._hasTitleImg) {
util.$id("version").textContent += (
Expand Down Expand Up @@ -344,7 +355,11 @@ export class WWA {

var escapedFilename: string = this._wwaData.mapCGName.replace("(", "\\(").replace(")", "\\)");
Array.prototype.forEach.call(util.$qsAll("div.item-cell"), (node: HTMLElement) => {
node.style.backgroundPosition = "-40px -80px";
node.style.backgroundPosition = `-${
this._itemboxBackgroundPos.x * Consts.CHIP_SIZE
}px -${
this._itemboxBackgroundPos.y * Consts.CHIP_SIZE
}px`;
node.style.backgroundImage = "url(" + escapedFilename + ")";
});
Array.prototype.forEach.call(util.$qsAll("div.wide-cell-row"), (node: HTMLElement) => {
Expand Down Expand Up @@ -2322,7 +2337,11 @@ export class WWA {
this._player.addItem(
partsID, this._wwaData.objectAttribute[partsID][Consts.ATR_NUMBER], false,
this._wwaData.isItemEffectEnabled ? {
screenPixelCoord: new Coord(screenXPixel, screenYPixel)
screenPixelCoord: new Coord(screenXPixel, screenYPixel),
itemBoxBackgroundImageCoord: new Coord(
this._itemboxBackgroundPos.x * Consts.CHIP_SIZE,
this._itemboxBackgroundPos.y * Consts.CHIP_SIZE
)
} : undefined
);
this.setPartsOnPosition(PartsType.OBJECT, 0, pos);
Expand Down Expand Up @@ -2502,7 +2521,11 @@ export class WWA {
var screenYPixel = (pos.y - screenTopCoord.y) * Consts.CHIP_SIZE;
this._player.addItem(
this._wwaData.objectAttribute[this._yesNoChoicePartsID][Consts.ATR_ITEM], 0, false, this._wwaData.isItemEffectEnabled ? {
screenPixelCoord: new Coord(screenXPixel, screenYPixel)
screenPixelCoord: new Coord(screenXPixel, screenYPixel),
itemBoxBackgroundImageCoord: new Coord(
this._itemboxBackgroundPos.x * Consts.CHIP_SIZE,
this._itemboxBackgroundPos.y * Consts.CHIP_SIZE
)
} : undefined
);
}
Expand Down Expand Up @@ -4154,6 +4177,18 @@ font-weight: bold;
public isConsoleOutputMode(): boolean {
return this._useConsole;
}

/**
* アイテムボックスの背景画像を置き換えます。
* 単位は、利用している画像の左上のチップを(x, y)=(0, 0)とするチップ単位です。
* @param pos 置き換えるアイテムボックスの背景の画像の、WWAで利用している画像内における位置
*/
public setItemboxBackgroundPosition(pos: { x: number, y: number}): void {
this._itemboxBackgroundPos = pos;
Array.prototype.forEach.call(util.$qsAll("div.item-cell"), (node: HTMLElement) => {
node.style.backgroundPosition = `-${pos.x * Consts.CHIP_SIZE}px -${pos.y * Consts.CHIP_SIZE}px`;
});
}
};

var isCopyRightClick = false;
Expand Down
5 changes: 2 additions & 3 deletions packages/engine/src/wwa_message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,8 @@ export class Macro {
node.style.backgroundPosition = "-" + x + "px -" + y + "px";
});
} else if (type === MacroImgFrameIndex.ITEM_BG) {
Array.prototype.forEach.call(util.$qsAll("div.item-cell"), (node: HTMLElement) => {
node.style.backgroundPosition = "-" + x + "px -" + y + "px";
});
this._wwa.setItemboxBackgroundPosition({x: posX, y: posY});

} else if (type === MacroImgFrameIndex.MAIN_FRAME) {
this._wwa.setFrameCoord(new Coord(posX, posY));
} else {
Expand Down
14 changes: 10 additions & 4 deletions packages/engine/src/wwa_parts_player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,7 @@ export class Player extends PartsObject {
* - insertPos: アニメーションが走るアイテムボックスを指定します。 1以上12以下です。
* - itemScreenPixelCoord: アニメーションの起点になる画面座標(フィールド上のアイテム地点)です。
* - itemBoxScreenPixelCoord: アニメーションの終点になる画面座標(アイテムボックス)です。
* - itemBoxBackgroundImageCoord: アイテムボックスの背景画像の画像内座標(px単位)です。
* - overwrittenObjectId: 上書きされる物体パーツのIDを指定すると、上書き演出になります。
*
* @param animationOption オブジェクトがあるとアニメーションが走ります。
Expand All @@ -542,6 +543,7 @@ export class Player extends PartsObject {
insertPos: number/*1-12*/,
itemScreenPixelCoord: Coord,
itemBoxScreenPixelCoord: Coord,
itemBoxBackgroundImageCoord: Coord,
overwrittenObjectId?: number
}): void {
for (let i = 0; i < this._itemBoxElement.length; i++) {
Expand Down Expand Up @@ -569,8 +571,8 @@ export class Player extends PartsObject {
const dy = animationOption.itemScreenPixelCoord.y - animationOption.itemBoxScreenPixelCoord.y;
const durationMs = (-dx) * Consts.DEFAULT_FRAME_INTERVAL / Consts.ITEM_EFFECT_SPEED_PIXEL_PER_FRAME;
const useBlank = animationOption.overwrittenObjectId === 0 || animationOption.overwrittenObjectId === undefined;
const overwrittenCx = useBlank ? 40 : this._wwa.getObjectCropXById(animationOption.overwrittenObjectId);
const overwrittenCy = useBlank ? 80 : this._wwa.getObjectCropYById(animationOption.overwrittenObjectId);
const overwrittenCx = useBlank ? animationOption.itemBoxBackgroundImageCoord.x : this._wwa.getObjectCropXById(animationOption.overwrittenObjectId);
const overwrittenCy = useBlank ? animationOption.itemBoxBackgroundImageCoord.y : this._wwa.getObjectCropYById(animationOption.overwrittenObjectId);
targetItemBoxElement.style.left = dx + "px";
targetItemBoxElement.style.top = dy + "px";
window.setTimeout(() => this.startItemEffect(
Expand Down Expand Up @@ -662,9 +664,12 @@ export class Player extends PartsObject {
* @param objID 持たせる物体パーツの番号
* @param itemPos アイテムボックス格納位置
* @param isOverwrite itemPosが0でない場合に使用される上書き設定。詳しくはdoc本文を参照
* @param animationOption オブジェクトが与えられる場合は 画面座標 screenPixelCoord からアイテムボックスまでのアニメーションが発生します。
* @param animationOption オブジェクトが与えられる場合は 画面座標 screenPixelCoord からアイテムボックスまでのアニメーションが発生します。また、itemBoxBackgroundImageCoord をアイテムボックス背景画像のゲーム使用画像内座標[px]として利用します。
*/
public addItem(objID: number, itemPos: number = 0, isOverwrite: boolean = false, animationOption?: { screenPixelCoord: Coord }): void {
public addItem(objID: number, itemPos: number = 0, isOverwrite: boolean = false, animationOption?: {
screenPixelCoord: Coord,
itemBoxBackgroundImageCoord: Coord
}): void {
var insertPos: number;
var oldInsertPos: number;
var oldObjID: number;
Expand Down Expand Up @@ -716,6 +721,7 @@ export class Player extends PartsObject {
this.updateItemBox(animationOption ? {
insertPos,
itemScreenPixelCoord: animationOption.screenPixelCoord,
itemBoxBackgroundImageCoord: animationOption.itemBoxBackgroundImageCoord,
itemBoxScreenPixelCoord: new Coord(
Consts.MAP_WINDOW_WIDTH + (insertPos - 1) % 3 * Consts.CHIP_SIZE,
Consts.ITEMBOX_TOP_Y + Math.floor((insertPos - 1) / 3) * Consts.CHIP_SIZE),
Expand Down

0 comments on commit c733d96

Please sign in to comment.