Hi!
I am using many different plugins, including yanfly's Battle Engine core. These plugins use mouse cursors as ways to hover over and select things in the battle scene, like so:
Code:
//=============================================================================
// TouchInput
//=============================================================================
Yanfly.BEC.TouchInput_onMouseMove = TouchInput._onMouseMove;
TouchInput._onMouseMove = function(event) {
Yanfly.BEC.TouchInput_onMouseMove.call(this, event);
this._mouseOverX = Graphics.pageToCanvasX(event.pageX);
this._mouseOverY = Graphics.pageToCanvasY(event.pageY);
};
TDDP's
plugin and its
Documentationhas all of the features I need and it works great on the map, however, on the battle screen nothing picks up the Touch input _onMouseMove() for the other plugins. It is replacing the cursor which is great but nothing is picking up the coordinates anymore.
I believe this part of the code is where this happens though, you might prove me wrong. It replaces the default function with another.
JavaScript:
//=============================================================================
// TouchInput modifications
//=============================================================================
/**
* Alias and extend initialize() with _setupCursorIconObject()
*/
var _TouchInput_initialize = TouchInput.initialize;
TouchInput.initialize = function() {
this._setupCursorIconObject();
_TouchInput_initialize.call(this);
};
/**
* Setup cursorIcon object
*/
TouchInput._setupCursorIconObject = function() {
this.cursorIcon = new Sprite();
this.cursorIcon.drawIcon = Window_Base.prototype.drawIcon;
this.cursorIcon.bitmap = new Bitmap(Window_Base._iconWidth, Window_Base._iconHeight);
this.cursorIcon.contents = this.cursorIcon.bitmap;
this.cursorIcon.iconIndex = null;
}
/**
* Alias and extend _onMouseMove() to use new function _checkCursorStatus()
*/
var _TouchInput_onMouseMove = TouchInput._onMouseMove;
TouchInput._onMouseMove = function(event) {
_TouchInput_onMouseMove.call(this, event);
this._checkCursorStatus(event.pageX, event.pageY);
};
/**
* Check cursor's status and whether to alter cursor
* @method _checkCursorStatus
* @param pageX {Number} Mouse page X coordinate
* @param pageY {Number} Mouse page Y coordinate
*/
TouchInput._checkCursorStatus = function(pageX, pageY) {
// Check for events under mouse and perform actions, and get event in result
var overEvents = this._checkForEventUnderMouse(pageX, pageY);
// Update cursor icon position
if (this.cursorIcon.iconIndex) {
this.cursorIcon.x = Graphics.pageToCanvasX(pageX) +
(this.cursorIcon.customOffsetX !== null ? this.cursorIcon.customOffsetX : $.iconOffsetX);
this.cursorIcon.y = Graphics.pageToCanvasY(pageY) +
(this.cursorIcon.customOffsetY !== null ? this.cursorIcon.customOffsetY : $.iconOffsetY);
this.cursorIcon.visible = true;
}
// Check if leave activate is to be triggered for a previously active event
this._activeEvents = this._activeEvents || [];
while (this._activeEvents.length > 0) {
var activeEvent = this._activeEvents.shift();
if (activeEvent.TDDP_MS.leaveActivate) {
if (!overEvents || overEvents.length == 0 || overEvents.indexOf(activeEvent) == -1) {
activeEvent.start();
}
}
}
// Reset active events if new over events
this._activeEvents = overEvents || this._activeEvents;
}
/**
* Alias and extend update() to store last event coords for checking if cursor has left an event
*/
var _TouchInput_update = TouchInput.update;
TouchInput.update = function() {
_TouchInput_update.call(this);
if (this._lastEventPageX == this._curEventPageX && this._lastEventPageY == this._curEventPageY) {
this._checkCursorStatus(this._lastEventPageX, this._lastEventPageY);
}
this._lastEventPageX = this._curEventPageX;
this._lastEventPageY = this._curEventPageY;
}
I would really like if I could just get it to call the normal mouse move in addition to the new one if that was possible or something similar. I just want the other plugins that might use the touch input mouse moved function to be compatible in some way.
The fix of turning the cursor off/on for battles with a switch is the ultimate nuke option but I would take that if nothing else works.
I am definitely willing to commission here, even if its a small fix!
Thank you!