Last active
March 27, 2021 21:10
-
-
Save aoitaku/6b6bbd6b3676fa8eedd11fb580083840 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//============================================================================= | |
// Lunatlazur_EventCommandSkip.js | |
// ---------------------------------------------------------------------------- | |
// Copyright (c) 2018 Taku Aoi | |
// This plugin is released under the zlib/libpng License. | |
// http://zlib.net/zlib_license.html | |
// ---------------------------------------------------------------------------- | |
// Version | |
// 1.0.0 2018/04/01 | |
// ---------------------------------------------------------------------------- | |
// [Web] : https://lunatlazur.com/ | |
// [Twitter]: https://twitter.com/lunatlazur/ | |
// [GitHub] : https://github.com/Lunatlazur/ | |
//============================================================================= | |
/*:ja | |
* @plugindesc イベントコマンドスキッププラグイン | |
* @author あおいたく | |
* @help このプラグインはCtrlキーを押すことでイベントコマンドをスキップ | |
* できるようにします。 | |
* | |
* プラグインコマンド一覧 | |
* ********************** | |
* | |
* スキップの開始 | |
* ============== | |
* | |
* スキップの開始 | |
* | |
* スキップを開始します。 | |
* | |
* | |
* スキップの中断 | |
* ============== | |
* | |
* スキップの中断 | |
* | |
* スキップを中断します。 | |
* | |
* | |
* スキップの切替 | |
* ============== | |
* | |
* スキップの切替 | |
* | |
* スキップ中でないならスキップを開始し、スキップ中ならスキップを中断します。 | |
* | |
* | |
* スキップ有効化 | |
* ============== | |
* | |
* スキップ有効化 | |
* | |
* イベントコマンドおよびキー入力によるスキップを有効化します。 | |
* | |
* | |
* スキップ無効化 | |
* ============== | |
* | |
* スキップ無効化 | |
* | |
* イベントコマンドおよびキー入力によるスキップを無効化します。 | |
* | |
* | |
* 変更履歴 | |
* ******** | |
* | |
* 1.0.0 2018/04/01: | |
* - 公開 | |
* 1.1.0 2021/03/28: | |
* - スキップの有効/無効を切り替えできるように | |
* | |
*/ | |
(function () { | |
const pluginName = 'Lunatlazur_EventCommandSkip'; | |
class SkipManager { | |
static init() { | |
this._skipping = false; | |
this._skipEnabled = true; | |
} | |
static isSkipping() { | |
return this._skipping; | |
} | |
static startSkip() { | |
this._skipping = true; | |
} | |
static cancelSkip() { | |
this._skipping = false; | |
} | |
static toggleSkip() { | |
this._skipping = !this._skipping; | |
} | |
static enableSkip() { | |
this._skipEnabled = true; | |
} | |
static disableSkip() { | |
this._skipEnabled = false; | |
} | |
static canSkip() { | |
return this._skipEnabled; | |
} | |
} | |
SkipManager.init(); | |
function isSkipping() { | |
return SkipManager.isSkipping() || (SkipManager.canSkip() && Input.isPressed('control')); | |
} | |
function isSkipInterrupting() { | |
return (Input.isTriggered('ok') || | |
Input.isTriggered('cancel') || | |
TouchInput.isTriggered() || | |
TouchInput.isCancelled()); | |
} | |
const _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand; | |
Game_Interpreter.prototype.pluginCommand = function (command, args) { | |
_Game_Interpreter_pluginCommand.apply(this, arguments); | |
switch ((command || '').toUpperCase()) { | |
case 'START_SKIP': | |
case 'スキップの開始': | |
SkipManager.startSkip(); | |
break; | |
case 'CANCEL_SKIP': | |
case 'スキップの中断': | |
SkipManager.cancelSkip(); | |
break; | |
case 'TOGGLE_SKIP': | |
case 'スキップの切替': | |
SkipManager.toggleSkip(); | |
break; | |
case 'ENABLE_SKIP': | |
case 'スキップ有効化': | |
SkipManager.enableSkip(); | |
break; | |
case 'DISABLE_SKIP': | |
case 'スキップ無効化': | |
SkipManager.disableSkip(); | |
break; | |
} | |
}; | |
const _Window_Message_updateWait = Window_Message.prototype.updateWait; | |
Window_Message.prototype.updateWait = function () { | |
if (SkipManager.canSkip() && !this.isClosed() && !$gameMessage.isChoice() && this.visible) { | |
if (SkipManager.isSkipping() && isSkipInterrupting()) { | |
SkipManager.cancelSkip(); | |
return true; | |
} | |
if (Input.isTriggered('ok') || Input.isTriggered('cancel') || TouchInput.isTriggered()) { | |
this._showFast = true; | |
} | |
if (isSkipping()) { | |
this._waitCount = 0; | |
} | |
} | |
return _Window_Message_updateWait.apply(this, arguments); | |
}; | |
const _Window_Message_isTriggered = Window_Message.prototype.isTriggered; | |
Window_Message.prototype.isTriggered = function () { | |
return _Window_Message_isTriggered.apply(this, arguments) || isSkipping(); | |
}; | |
const _Game_Screen_movePicture = Game_Screen.prototype.movePicture; | |
Game_Screen.prototype.movePicture = function (pictureId, origin, x, y, scaleX, scaleY, opacity, blendMode, duration) { | |
_Game_Screen_movePicture.call(this, pictureId, origin, x, y, scaleX, scaleY, opacity, blendMode, isSkipping() ? 2 : duration); | |
}; | |
const _Game_Screen_startFadeIn = Game_Screen.prototype.startFadeIn; | |
Game_Screen.prototype.startFadeIn = function (duration) { | |
_Game_Screen_startFadeIn.call(this, isSkipping() ? 2 : duration); | |
}; | |
const _Game_Screen_startFadeOut = Game_Screen.prototype.startFadeOut; | |
Game_Screen.prototype.startFadeOut = function (duration) { | |
_Game_Screen_startFadeOut.call(this, isSkipping() ? 2 : duration); | |
}; | |
if (Game_Screen.prototype.startTransition) { | |
const _Game_Screen_startTransition = Game_Screen.prototype.startTransition; | |
Game_Screen.prototype.startTransition = function (isFadingIn, isFilledWhite, name, duration) { | |
_Game_Screen_startTransition.call(this, isFadingIn, isFilledWhite, name, isSkipping() ? 2 : duration); | |
}; | |
} | |
const _Game_Interpreter_wait = Game_Interpreter.prototype.wait; | |
Game_Interpreter.prototype.wait = function (duration) { | |
_Game_Interpreter_wait.call(this, isSkipping() ? 2 : duration); | |
}; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment