| "use strict"; |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| const DotMoveSystem_DecideTriggerExPluginName = document.currentScript ? decodeURIComponent(document.currentScript.src.match(/^.*\/(.+)\.js$/)[1]) : "DotMoveSystem_DecideTriggerEx"; |
| var DotMoveSystem; |
| (function (DotMoveSystem) { |
| var DecideTriggerEx; |
| (function (DecideTriggerEx) { |
| function mixin(dest, src) { |
| for (const name of Object.getOwnPropertyNames(src.prototype)) { |
| if (name === "constructor") |
| continue; |
| const value = Object.getOwnPropertyDescriptor(src.prototype, name) || Object.create(null); |
| Object.defineProperty(dest.prototype, name, value); |
| } |
| } |
| if (typeof PluginManager.registerCommand !== "undefined") { |
| PluginManager.registerCommand(DotMoveSystem_DecideTriggerExPluginName, "ChangePopupParameter", function (args) { |
| const eventId = parseInt(args.EventId); |
| const popupParams = PopupParameter.fromParams(JSON.parse(args.PopupParameter)); |
| let event; |
| if (eventId === 0) { |
| event = $gameMap.event(this.eventId()); |
| } |
| else { |
| event = $gameMap.event(eventId); |
| } |
| event.changePopupParams(popupParams); |
| }); |
| } |
| |
| if (Utils.RPGMAKER_NAME === "MV") { |
| Spriteset_Map.prototype.findTargetSprite = function (target) { |
| return this._characterSprites.find((sprite) => sprite.checkCharacter(target)); |
| }; |
| Sprite_Character.prototype.checkCharacter = function (character) { |
| return this._character === character; |
| }; |
| Window_Base.prototype.textSizeEx = function (text) { |
| if (text) { |
| this.resetFontSettings(); |
| var textState = { index: 0, x: 0, y: 0, left: 0 }; |
| textState.undrawing = true; |
| textState.text = this.convertEscapeCharacters(text); |
| |
| textState.height = this.calcTextHeight(textState, false); |
| while (textState.index < textState.text.length) { |
| this.processCharacter(textState); |
| } |
| return { width: textState.x, height: textState.height }; |
| } |
| else { |
| return { width: 0, height: 0 }; |
| } |
| }; |
| |
| Window_Base.prototype.processNormalCharacter = function (textState) { |
| var c = textState.text[textState.index++]; |
| var w = this.textWidth(c); |
| if (!textState.undrawing) { |
| this.contents.drawText(c, textState.x, textState.y, w * 2, textState.height); |
| } |
| textState.x += w; |
| }; |
| } |
| class PopupParameter { |
| constructor(balloonId, iconNumber, imageFileName, windowText, windowTextFontSize, windowTextFontFace, windowSkinFileName) { |
| this.balloonId = balloonId != null ? balloonId : 0; |
| this.iconNumber = iconNumber != null ? iconNumber : 0; |
| this.imageFileName = imageFileName != null ? imageFileName : ""; |
| this.windowText = windowText != null ? windowText : ""; |
| this.windowTextFontSize = windowTextFontSize != null ? windowTextFontSize : 0; |
| this.windowTextFontFace = windowTextFontFace != null ? windowTextFontFace : ""; |
| this.windowSkinFileName = windowSkinFileName != null ? windowSkinFileName : ""; |
| } |
| static fromParams(params) { |
| const balloonId = params.BalloonId != null ? parseInt(params.BalloonId) : undefined; |
| const iconNumber = params.IconNumber; |
| const imageFileName = params.ImageFileName; |
| const windowText = params.WindowText; |
| const windowTextFontSize = params.WindowTextFontSize != null ? parseInt(params.WindowTextFontSize) : undefined; |
| const windowTextFontFace = params.WindowTextFontFace; |
| const windowSkinFileName = params.WindowSkinFileName; |
| return new PopupParameter(balloonId, iconNumber, imageFileName, windowText, windowTextFontSize, windowTextFontFace, windowSkinFileName); |
| } |
| } |
| DecideTriggerEx.PopupParameter = PopupParameter; |
| class PluginParams { |
| constructor() { |
| const params = PluginManager.parameters(DotMoveSystem_DecideTriggerExPluginName); |
| this.decideTriggerAreaWidth = parseFloat(params.DecideTriggerAreaWidth); |
| if (params.DefaultPopupParameter) { |
| this.defaultPopupParameter = PopupParameter.fromParams(JSON.parse(params.DefaultPopupParameter)); |
| } |
| else { |
| this.defaultPopupParameter = new PopupParameter(); |
| } |
| } |
| } |
| DecideTriggerEx.PluginParams = PluginParams; |
| const PP = new PluginParams(); |
| class Circle { |
| constructor(...args) { |
| this.initialize(...args); |
| } |
| get x() { return this._x; } |
| set x(_x) { this._x = _x; } |
| get y() { return this._y; } |
| set y(_y) { this._y = _y; } |
| get d() { return this._d; } |
| set d(_d) { this._d = _d; } |
| get r() { return this.d / 2; } |
| initialize(x, y, d) { |
| this._x = x; |
| this._y = y; |
| this._d = d; |
| } |
| isCollidedCircle(circle) { |
| const pos = new DotMoveSystem.DotMovePoint(this.x, this.y); |
| const far = pos.calcFar(new DotMoveSystem.DotMovePoint(circle.x, circle.y)); |
| return far < this.r + circle.r; |
| } |
| } |
| DecideTriggerEx.Circle = Circle; |
| class DecideTriggerArea extends Game_Character { |
| constructor(...args) { |
| super(...args); |
| } |
| get type() { return this._type; } |
| get owner() { return this._owner; } |
| initialize(...args) { |
| const [type, owner] = args; |
| super.initialize(); |
| this._type = type; |
| this._owner = owner; |
| } |
| update() { |
| super.update(); |
| const ownerPos = this._owner.positionPoint(); |
| const x = ownerPos.x - (this.width() - this._owner.width()) / 2; |
| const y = ownerPos.y - (this.height() - this._owner.height()) / 2; |
| this.setPositionPoint(new DotMoveSystem.DotMovePoint(x, y)); |
| } |
| width() { |
| return PP.decideTriggerAreaWidth; |
| } |
| height() { |
| return PP.decideTriggerAreaWidth; |
| } |
| } |
| DecideTriggerEx.DecideTriggerArea = DecideTriggerArea; |
| class PlayerDotMoveTempData_Mixin extends DotMoveSystem.PlayerDotMoveTempData { |
| initialize(character) { |
| PlayerDotMoveTempData_Mixin._initialize.call(this, character); |
| this._decideTriggerCollidedEventIds = []; |
| this._remainDisableTouchEventTime = 0; |
| } |
| get decideTriggerCollidedEventIds() { return this._decideTriggerCollidedEventIds; } |
| set decideTriggerCollidedEventIds(_decideTriggerCollidedEventIds) { this._decideTriggerCollidedEventIds = _decideTriggerCollidedEventIds; } |
| get remainDisableTouchEventTime() { return this._remainDisableTouchEventTime; } |
| set remainDisableTouchEventTime(_remainDisableTouchEventTime) { this._remainDisableTouchEventTime = _remainDisableTouchEventTime; } |
| } |
| PlayerDotMoveTempData_Mixin._initialize = DotMoveSystem.PlayerDotMoveTempData.prototype.initialize; |
| mixin(DotMoveSystem.PlayerDotMoveTempData, PlayerDotMoveTempData_Mixin); |
| class EventDotMoveTempData_Mixin extends DotMoveSystem.EventDotMoveTempData { |
| get decideTriggerArea() { return this._decideTriggerArea; } |
| set decideTriggerArea(_decideTriggerArea) { this._decideTriggerArea = _decideTriggerArea; } |
| } |
| mixin(DotMoveSystem.EventDotMoveTempData, EventDotMoveTempData_Mixin); |
| class Game_Character_Mixin extends Game_Character { |
| onPress() { |
| } |
| onClick() { |
| } |
| } |
| mixin(Game_Character, Game_Character_Mixin); |
| class Game_Player_Mixin extends Game_Player { |
| update(sceneActive) { |
| Game_Player_Mixin._update.call(this, sceneActive); |
| if (sceneActive) { |
| this.updateDecideTriggerEvent(); |
| this.updateDisableTouchEventTimer(); |
| } |
| } |
| updateDisableTouchEventTimer() { |
| if ($gameMap.isEventRunning()) { |
| this.dotMoveTempData().remainDisableTouchEventTime = 10; |
| } |
| else { |
| if (this.dotMoveTempData().remainDisableTouchEventTime > 0) { |
| this.dotMoveTempData().remainDisableTouchEventTime--; |
| } |
| } |
| } |
| updateDecideTriggerEvent() { |
| if ($gameMap.isEventRunning()) |
| return; |
| const tempData = this.dotMoveTempData(); |
| const lastDecideTriggerCollidedEventIds = tempData.decideTriggerCollidedEventIds; |
| this.checkDecideTriggerEventProcess(); |
| const decideTriggerCollidedEventIds = tempData.decideTriggerCollidedEventIds; |
| for (const eventId of decideTriggerCollidedEventIds) { |
| const event = $gameMap.event(eventId); |
| if (!event) |
| continue; |
| event.setDecidablePopupVisible(true); |
| } |
| for (const eventId of lastDecideTriggerCollidedEventIds) { |
| if (!decideTriggerCollidedEventIds.includes(eventId)) { |
| const event = $gameMap.event(eventId); |
| if (!event) |
| continue; |
| event.setDecidablePopupVisible(false); |
| } |
| } |
| } |
| checkDecideTriggerEventProcess() { |
| const eventIds = []; |
| const dir = this.direction(); |
| eventIds.push(...this.checkDecideTriggerEventInternal(this._realX, this._realY, dir)); |
| let currentPoint = this.positionPoint(); |
| while (true) { |
| let nextPoint = DotMoveSystem.DotMoveUtils.nextPointWithDirection(currentPoint, dir); |
| let nextX = Math.round(nextPoint.x); |
| let nextY = Math.round(nextPoint.y); |
| if ($gameMap.isCounter(nextX, nextY)) { |
| eventIds.push(...this.checkDecideTriggerEventInternal(nextX, nextY, dir)); |
| } |
| else { |
| break; |
| } |
| currentPoint = nextPoint; |
| } |
| const uniqEventIds = []; |
| for (const id of eventIds) { |
| if (!uniqEventIds.includes(id)) |
| uniqEventIds.push(id); |
| } |
| this.dotMoveTempData().decideTriggerCollidedEventIds = uniqEventIds; |
| } |
| checkDecideTriggerEventInternal(x, y, d) { |
| const eventIds = []; |
| for (const result of this.mover().checkHitCharacters(x, y, d, DecideTriggerArea)) { |
| const event = result.targetObject.owner; |
| if (!event) |
| continue; |
| if (!this.isTowardDirectionToCharacter(event)) |
| continue; |
| if (!(event.isTriggerIn([0]) && event.isNormalPriority())) |
| continue; |
| if (event.isEventPageEmpty(0)) |
| continue; |
| const subjectRect = result.subjectRect; |
| const targetRect = result.targetRect; |
| const circle1 = new Circle(subjectRect.x + subjectRect.width / 2, subjectRect.y + subjectRect.height / 2, 1); |
| const circle2 = new Circle(targetRect.x + targetRect.width / 2, targetRect.y + targetRect.height / 2, PP.decideTriggerAreaWidth); |
| if (!circle1.isCollidedCircle(circle2)) |
| continue; |
| eventIds.push(event.eventId()); |
| } |
| for (const result of this.mover().checkHitCharacters(x, y, this._direction, Game_Event)) { |
| const event = result.targetObject; |
| if (!(event.isTriggerIn([0]) && !event.isNormalPriority())) |
| continue; |
| if (result.collisionLengthX() >= event.widthArea() && result.collisionLengthY() >= event.heightArea()) { |
| eventIds.push(event.eventId()); |
| } |
| } |
| return eventIds; |
| } |
| isTowardDirectionToCharacter(character) { |
| let towardDir; |
| const sx = this.deltaRealXFrom(character.centerRealX()); |
| const sy = this.deltaRealYFrom(character.centerRealY()); |
| if (Math.abs(sx) > Math.abs(sy)) { |
| towardDir = sx > 0 ? 4 : 6; |
| } |
| else { |
| towardDir = sy > 0 ? 8 : 2; |
| } |
| return this._direction === towardDir; |
| } |
| triggerButtonAction() { |
| if (Input.isTriggered("ok")) { |
| if (this.getOnOffVehicle()) { |
| return true; |
| } |
| this.checkEventTriggerHere([0]); |
| if ($gameMap.setupStartingEvent()) { |
| return true; |
| } |
| this.checkEventTriggerThere([0, 1, 2], { isDecide: true }); |
| if ($gameMap.setupStartingEvent()) { |
| return true; |
| } |
| } |
| return false; |
| } |
| checkEventTriggerThere(triggers, opt = {}) { |
| var _a; |
| const isDecide = (_a = opt.isDecide) !== null && _a !== void 0 ? _a : false; |
| if (isDecide) { |
| if (!this.canStartLocalEvents()) |
| return; |
| if (!triggers.includes(0)) |
| return; |
| this.startMapEventDecideTriggerEx(); |
| } |
| else { |
| Game_Player_Mixin._checkEventTriggerThere.call(this, triggers); |
| } |
| } |
| startMapDecideEventByTouch(event) { |
| if (this.dotMoveTempData().remainDisableTouchEventTime > 0) |
| return; |
| if (!this.canStartLocalEvents()) |
| return; |
| if ($gameMap.isEventRunning()) |
| return; |
| const eventIds = this.dotMoveTempData().decideTriggerCollidedEventIds; |
| if (!eventIds.includes(event.eventId())) |
| return; |
| event.start(); |
| } |
| startMapEventDecideTriggerEx() { |
| if ($gameMap.isEventRunning()) |
| return; |
| const eventIds = this.dotMoveTempData().decideTriggerCollidedEventIds; |
| for (const eventId of eventIds) { |
| const event = $gameMap.event(eventId); |
| if (event) |
| event.start(); |
| } |
| } |
| } |
| Game_Player_Mixin._update = Game_Player.prototype.update; |
| Game_Player_Mixin._checkEventTriggerThere = Game_Player.prototype.checkEventTriggerThere; |
| mixin(Game_Player, Game_Player_Mixin); |
| class Game_Event_Mixin extends Game_Event { |
| initMembers() { |
| Game_Event_Mixin._initMembers.call(this); |
| this._popupDelayTime = 0; |
| this._decidablePopupVisible = false; |
| this._popupIcon = 0; |
| this._decidableBalloonId = 0; |
| this._popupImageFileName = ""; |
| this._popupWindowText = ""; |
| this._popupWindowTextFontSize = 0; |
| this._popupWindowTextFontFace = ""; |
| this._popupWindowSkinFileName = ""; |
| this._popupSettingChanged = false; |
| } |
| update() { |
| Game_Event_Mixin._update.call(this); |
| if (this._decidableBalloonId > 0) |
| this.updateDecideBalloon(); |
| if (this._popupDelayTime > 0) |
| this._popupDelayTime--; |
| const tempData = this.dotMoveTempData(); |
| tempData.decideTriggerArea.update(); |
| } |
| isLocked() { |
| return this._locked; |
| } |
| changePopupIcon(iconIndex) { |
| this._popupIcon = iconIndex; |
| } |
| changePopupWindowText(text) { |
| this._popupWindowText = text; |
| } |
| changePopupImage(imageFileName) { |
| this._popupImageFileName = imageFileName; |
| } |
| changePopupBalloon(balloonId) { |
| this._decidableBalloonId = balloonId; |
| } |
| changePopupWindowSkin(windowSkinFileName) { |
| this._popupWindowSkinFileName = windowSkinFileName; |
| } |
| clearPopupSetting() { |
| this.changePopupParams(new PopupParameter()); |
| } |
| applyPopupSetting() { |
| this.refresh(); |
| this._needUpdatePopupObject = true; |
| } |
| changePopupParams(popupParams) { |
| this._popupIcon = popupParams.iconNumber; |
| this._decidableBalloonId = popupParams.balloonId; |
| this._popupImageFileName = popupParams.imageFileName; |
| this._popupWindowText = popupParams.windowText; |
| this._popupWindowTextFontSize = popupParams.windowTextFontSize; |
| this._popupWindowTextFontFace = popupParams.windowTextFontFace; |
| this._popupWindowSkinFileName = popupParams.windowSkinFileName; |
| this._needUpdatePopupObject = true; |
| } |
| checkNeedUpdatePopupObject() { |
| if (this._needUpdatePopupObject) { |
| this._needUpdatePopupObject = false; |
| return true; |
| } |
| return false; |
| } |
| startPopupDelay() { |
| this._popupDelayTime = 30; |
| } |
| updateDecideBalloon() { |
| if (this.isDecidablePopupVisible()) { |
| if (!this.isBalloonPlaying()) { |
| if (Utils.RPGMAKER_NAME === "MZ") { |
| $gameTemp.requestBalloon(this, this._decidableBalloonId); |
| } |
| else { |
| |
| this.requestBalloon(this._decidableBalloonId); |
| } |
| } |
| } |
| } |
| setDecidablePopupVisible(visible) { |
| this._decidablePopupVisible = visible; |
| } |
| isDecidablePopupVisible() { |
| if ($gameMap.isEventRunning()) |
| return false; |
| if (this._popupDelayTime > 0) |
| return false; |
| return this._decidablePopupVisible; |
| } |
| popupIcon() { |
| return this._popupIcon; |
| } |
| popupImageFileName() { |
| return this._popupImageFileName; |
| } |
| popupWindowText() { |
| return this._popupWindowText; |
| } |
| popupWindowTextFontSize() { |
| return this._popupWindowTextFontSize; |
| } |
| popupWindowTextFontFace() { |
| return this._popupWindowTextFontFace; |
| } |
| popupWindowSkinFileName() { |
| return this._popupWindowSkinFileName; |
| } |
| refresh() { |
| Game_Event_Mixin._refresh.call(this); |
| if (!this._popupSettingChanged) { |
| this._popupSettingChanged = true; |
| this.resetPopupSetting(); |
| } |
| } |
| resetPopupSetting() { |
| const values = this.getAnnotationValues(0); |
| if (values.popupIcon) |
| this._popupIcon = parseInt(values.popupIcon); |
| if (values.popupBalloon) |
| this._decidableBalloonId = parseInt(values.popupBalloon); |
| if (values.popupImage) |
| this._popupImageFileName = values.popupImage.replace(/^\s+/, ""); |
| if (values.popupWindowText) |
| this._popupWindowText = values.popupWindowText.replace(/^\s+/, ""); |
| if (values.popupWindowTextFontSize) |
| this._popupWindowTextFontSize = parseInt(values.popupWindowTextFontSize); |
| if (values.popupWindowTextFontFace) |
| this._popupWindowTextFontFace = values.popupWindowTextFontFace.replace(/^\s+/, ""); |
| if (values.popupWindowSkin) { |
| this._popupWindowSkinFileName = values.popupWindowSkin.replace(/^\s+/, ""); |
| } |
| else { |
| this._popupWindowSkinFileName = PP.defaultPopupParameter.windowSkinFileName; |
| } |
| if (!this.isNeedPopupObject() && this._decidableBalloonId === 0 && !values.unuseDefault) { |
| this._popupIcon = PP.defaultPopupParameter.iconNumber; |
| this._decidableBalloonId = PP.defaultPopupParameter.balloonId; |
| this._popupImageFileName = PP.defaultPopupParameter.imageFileName; |
| this._popupWindowText = PP.defaultPopupParameter.windowText; |
| } |
| } |
| createDotMoveTempData() { |
| const tempData = Game_Event_Mixin._createTempData.call(this); |
| tempData.decideTriggerArea = new DecideTriggerArea("circle", this); |
| return tempData; |
| } |
| isNeedPopupObject() { |
| if (this._popupIcon > 0) |
| return true; |
| if (this._popupImageFileName !== "") |
| return true; |
| if (this._popupWindowText !== "") |
| return true; |
| return false; |
| } |
| start() { |
| Game_Event_Mixin._start.call(this); |
| this.startPopupDelay(); |
| } |
| isEventPageEmpty(page) { |
| const eventData = this.event(); |
| if (eventData) { |
| const pageList = eventData.pages[page].list; |
| for (let i = 0; i < pageList.length; i++) { |
| if (!(pageList[i].code === 0 || pageList[i].code === 108 || pageList[i].code === 408)) { |
| return false; |
| } |
| } |
| } |
| return true; |
| } |
| onClick() { |
| Game_Character.prototype.onClick(); |
| $gamePlayer.startMapDecideEventByTouch(this); |
| if (this.isLocked()) { |
| $gameTemp.clearDestination(); |
| } |
| } |
| } |
| Game_Event_Mixin._initMembers = Game_Event.prototype.initMembers; |
| Game_Event_Mixin._refresh = Game_Event.prototype.refresh; |
| Game_Event_Mixin._update = Game_Event.prototype.update; |
| Game_Event_Mixin._createTempData = Game_Event.prototype.createDotMoveTempData; |
| Game_Event_Mixin._start = Game_Event.prototype.start; |
| mixin(Game_Event, Game_Event_Mixin); |
| class Game_Map_Mixin extends Game_Map { |
| allCharacters() { |
| const characters = Game_Map_Mixin._allCharacters.call(this); |
| for (const event of this.events()) { |
| characters.add(event.dotMoveTempData().decideTriggerArea); |
| } |
| return characters; |
| } |
| } |
| Game_Map_Mixin._allCharacters = Game_Map.prototype.allCharacters; |
| mixin(Game_Map, Game_Map_Mixin); |
| let baseSpriteClass; |
| if (Utils.RPGMAKER_NAME === "MZ") { |
| baseSpriteClass = Sprite; |
| } |
| else { |
| |
| baseSpriteClass = Sprite_Base; |
| } |
| class Sprite_Icon extends baseSpriteClass { |
| setIconIndex(iconIndex) { |
| if (iconIndex > 0) { |
| if (!this.bitmap) { |
| this.bitmap = ImageManager.loadSystem("IconSet"); |
| } |
| const iconFrame = this.iconFrame(iconIndex); |
| this.setFrame(iconFrame.x, iconFrame.y, iconFrame.width, iconFrame.height); |
| } |
| else { |
| this.bitmap = null; |
| } |
| } |
| iconFrame(iconIndex) { |
| let pw, ph; |
| if (Utils.RPGMAKER_NAME === "MZ") { |
| pw = ImageManager.iconWidth; |
| ph = ImageManager.iconHeight; |
| } |
| else { |
| pw = 32; |
| ph = 32; |
| } |
| const sx = (iconIndex % 16) * pw; |
| const sy = Math.floor(iconIndex / 16) * ph; |
| return new Rectangle(sx, sy, pw, ph); |
| } |
| } |
| DecideTriggerEx.Sprite_Icon = Sprite_Icon; |
| class Window_Popup extends Window_Base { |
| initialize(rect) { |
| if (Utils.RPGMAKER_NAME === "MZ") { |
| super.initialize(rect); |
| } |
| else { |
| |
| super.initialize(rect.x, rect.y, rect.width, rect.height); |
| } |
| this._text = ""; |
| this._textFontSize = 0; |
| this._textFontFace = ""; |
| this.downArrowVisible = true; |
| } |
| get text() { |
| return this._text; |
| } |
| set text(_text) { |
| this._text = _text; |
| this.refresh(); |
| } |
| get textFontSize() { |
| return this._textFontSize; |
| } |
| set textFontSize(_textFontSize) { |
| this._textFontSize = _textFontSize; |
| this.refresh(); |
| } |
| get textFontFace() { |
| return this._textFontFace; |
| } |
| set textFontFace(_textFontFace) { |
| this._textFontFace = _textFontFace; |
| this.refresh(); |
| } |
| refresh() { |
| this.contents.clear(); |
| if (Utils.RPGMAKER_NAME === "MZ") { |
| this.contentsBack.clear(); |
| } |
| const { width, height } = this.textSizeEx(this._text); |
| this.width = width + this.padding * 2; |
| this.height = height + this.padding * 2; |
| this.drawTextEx(this._text, 0, 0, this.width); |
| } |
| _refreshArrows() { |
| super._refreshArrows(); |
| this._downArrowSprite.y += 16; |
| } |
| resetFontSettings() { |
| this.contents.fontFace = this.realTextFontFace(); |
| this.contents.fontSize = this.realTextFontSize(); |
| this.resetTextColor(); |
| } |
| realTextFontSize() { |
| if (this._textFontSize === 0) { |
| if (Utils.RPGMAKER_NAME === "MZ") { |
| return $gameSystem.mainFontSize(); |
| } |
| else { |
| |
| return this.standardFontSize(); |
| } |
| } |
| return this._textFontSize; |
| } |
| realTextFontFace() { |
| if (this._textFontFace === "") { |
| if (Utils.RPGMAKER_NAME === "MZ") { |
| return $gameSystem.mainFontFace(); |
| } |
| else { |
| |
| return this.standardFontFace(); |
| } |
| } |
| return this._textFontFace; |
| } |
| } |
| DecideTriggerEx.Window_Popup = Window_Popup; |
| class Sprite_Character_Mixin extends Sprite_Character { |
| initMembers() { |
| Sprite_Character_Mixin._initMembers.call(this); |
| this._pressed = false; |
| } |
| update() { |
| Sprite_Character_Mixin._update.call(this); |
| this.processTouch(); |
| } |
| character() { |
| return this._character; |
| } |
| processTouch() { |
| if (this.isClickEnabled()) { |
| if (this.isBeingTouched()) { |
| if (TouchInput.isTriggered()) { |
| this._pressed = true; |
| this.onPress(); |
| } |
| } |
| else { |
| this._pressed = false; |
| } |
| if (this._pressed && TouchInput.isReleased()) { |
| this._pressed = false; |
| this.onClick(); |
| } |
| } |
| else { |
| this._pressed = false; |
| } |
| } |
| isPressed() { |
| return this._pressed; |
| } |
| isClickEnabled() { |
| return this.worldVisible; |
| } |
| isBeingTouched() { |
| const touchPos = new Point(TouchInput.x, TouchInput.y); |
| const localPos = this.worldTransform.applyInverse(touchPos); |
| return this.hitTest(localPos.x, localPos.y); |
| } |
| hitTest(x, y) { |
| const width = this.spriteWidth(); |
| const height = this.spriteHeight(); |
| const rect = new Rectangle(-this.anchor.x * width, -this.anchor.y * height, width, height); |
| return rect.contains(x, y); |
| } |
| spriteWidth() { |
| if (this._bushDepth > 0 && this._upperBody && this._lowerBody) { |
| return this._upperBody.width; |
| } |
| else { |
| return this.width; |
| } |
| } |
| spriteHeight() { |
| if (this._bushDepth > 0 && this._upperBody && this._lowerBody) { |
| return this._upperBody.height + this._lowerBody.height; |
| } |
| else { |
| return this.width; |
| } |
| } |
| onPress() { |
| this._character.onPress(); |
| } |
| onClick() { |
| this._character.onClick(); |
| } |
| } |
| Sprite_Character_Mixin._initMembers = Sprite_Character.prototype.initMembers; |
| Sprite_Character_Mixin._update = Sprite_Character.prototype.update; |
| mixin(Sprite_Character, Sprite_Character_Mixin); |
| class Scene_Map_Mixin extends Scene_Map { |
| processMapTouch() { |
| Scene_Map_Mixin._processMapTouch.call(this); |
| const characterSprites = this._spriteset.characterSprites(); |
| for (const characterSprite of characterSprites) { |
| characterSprite.processTouch(); |
| } |
| } |
| checkCharacterEventStarted() { |
| const characterSprites = this._spriteset.characterSprites(); |
| let startEvent = false; |
| const eventIds = $gamePlayer.dotMoveTempData().decideTriggerCollidedEventIds; |
| for (const characterSprite of characterSprites) { |
| if (characterSprite.isPressed()) { |
| const character = characterSprite.character(); |
| if ((character instanceof Game_Event) && eventIds.includes(character.eventId())) { |
| startEvent = true; |
| } |
| } |
| } |
| return startEvent; |
| } |
| onMapTouch() { |
| const startEvent = this.checkCharacterEventStarted(); |
| if (!startEvent) { |
| |
| if (typeof $virtualStickController !== "undefined") { |
| return; |
| } |
| Scene_Map_Mixin._onMapTouch.call(this); |
| } |
| } |
| } |
| Scene_Map_Mixin._processMapTouch = Scene_Map.prototype.processMapTouch; |
| Scene_Map_Mixin._onMapTouch = Scene_Map.prototype.onMapTouch; |
| mixin(Scene_Map, Scene_Map_Mixin); |
| class Spriteset_Map_Mixin extends Spriteset_Map { |
| initialize() { |
| this._popupObjects = new Map(); |
| Spriteset_Map_Mixin._initialize.call(this); |
| } |
| update() { |
| Spriteset_Map_Mixin._update.call(this); |
| this.updatePopupObjects(); |
| } |
| characterSprites() { |
| return this._characterSprites; |
| } |
| updatePopupObjects() { |
| const characters = this._characterSprites.map(sprite => sprite.character()); |
| const events = characters.filter(character => character instanceof Game_Event); |
| for (const event of events) { |
| if (!this._popupObjects.has(event)) { |
| if (event.isNeedPopupObject()) { |
| const popupObject = this.createPopupObject(event); |
| this._popupObjects.set(event, popupObject); |
| this._tilemap.addChild(popupObject); |
| } |
| } |
| else { |
| if (event.checkNeedUpdatePopupObject()) { |
| const oldPopupObject = this._popupObjects.get(event); |
| this._tilemap.removeChild(oldPopupObject); |
| this._popupObjects.delete(event); |
| if (event.isNeedPopupObject()) { |
| const newPopupObject = this.createPopupObject(event); |
| this._popupObjects.set(event, newPopupObject); |
| this._tilemap.addChild(newPopupObject); |
| } |
| } |
| } |
| } |
| for (const event of this._popupObjects.keys()) { |
| const popupObject = this._popupObjects.get(event); |
| if (events.includes(event)) { |
| this.updatePopupObject(event, popupObject); |
| } |
| else { |
| this._tilemap.removeChild(popupObject); |
| this._popupObjects.delete(event); |
| } |
| } |
| } |
| createPopupObject(event) { |
| const popupIcon = event.popupIcon(); |
| const popupImageFileName = event.popupImageFileName(); |
| const popupWindowText = event.popupWindowText(); |
| const popupWindowSkinFileName = event.popupWindowSkinFileName(); |
| let popupObject; |
| if (popupIcon > 0) { |
| const sprite = new Sprite_Icon(); |
| sprite.setIconIndex(popupIcon); |
| sprite.hide(); |
| popupObject = sprite; |
| } |
| else if (popupImageFileName !== "") { |
| const sprite = new baseSpriteClass(); |
| sprite.bitmap = ImageManager.loadPicture(popupImageFileName); |
| sprite.hide(); |
| popupObject = sprite; |
| } |
| else if (popupWindowText !== "") { |
| const rect = new Rectangle(0, 0, Graphics.boxWidth, 128); |
| const window = new Window_Popup(rect); |
| if (popupWindowSkinFileName !== "") { |
| window.windowskin = ImageManager.loadSystem(popupWindowSkinFileName); |
| } |
| window.text = popupWindowText; |
| window.textFontSize = event.popupWindowTextFontSize(); |
| window.textFontFace = event.popupWindowTextFontFace(); |
| window.hide(); |
| popupObject = window; |
| } |
| if (!popupObject) |
| throw new Error("Create popup object failed."); |
| popupObject.z = 7; |
| return popupObject; |
| } |
| updatePopupObject(event, popupObject) { |
| if (event.isDecidablePopupVisible()) { |
| const characterSprite = this.findTargetSprite(event); |
| if (characterSprite && (characterSprite instanceof Sprite_Character)) { |
| popupObject.x = characterSprite.x - popupObject.width / 2; |
| popupObject.y = characterSprite.y - characterSprite.height - popupObject.height; |
| popupObject.show(); |
| } |
| } |
| else { |
| popupObject.hide(); |
| } |
| } |
| } |
| Spriteset_Map_Mixin._initialize = Spriteset_Map.prototype.initialize; |
| Spriteset_Map_Mixin._update = Spriteset_Map.prototype.update; |
| mixin(Spriteset_Map, Spriteset_Map_Mixin); |
| class Game_Interpreter_Mixin extends Game_Interpreter { |
| event() { |
| return $gameMap.event(this._eventId); |
| } |
| } |
| mixin(Game_Interpreter, Game_Interpreter_Mixin); |
| })(DecideTriggerEx = DotMoveSystem.DecideTriggerEx || (DotMoveSystem.DecideTriggerEx = {})); |
| })(DotMoveSystem || (DotMoveSystem = {})); |
|
|