//=============================================================================
// OutlineThicknessPlugin.js
//=============================================================================

/*:
 * @plugindesc Customize outline thickness and color in Save/Load screen and other scenes.
 * @author OpenAI
 * 
 * @param SaveLoadOutlineThickness
 * @desc Outline thickness value for Save/Load screen. Default is 5.
 * @default 5
 *
 * @param SaveLoadOutlineColor
 * @desc Outline color value for Save/Load screen. Default is rgba(0,0,0,0.5).
 * @default rgba(0,0,0,0.5)
 *
 * @param OtherScenesOutlineThickness
 * @desc Outline thickness value for other scenes. Default is 0.
 * @default 0
 *
 * @param OtherScenesOutlineColor
 * @desc Outline color value for other scenes. Default is rgba(0,0,0,0.5).
 * @default rgba(0,0,0,0.5)
 *
 * @help English：This plugin allows you to customize the outline thickness and color in the Save/Load screen and other scenes.
 * 
 * Plugin Command:
 *   SetSaveLoadOutlineThickness <value>
 *     - Set the outline thickness for Save/Load screen to the specified value.
 *     - Example: SetSaveLoadOutlineThickness 8
 *   SetSaveLoadOutlineColor <value>
 *     - Set the outline color for Save/Load screen to the specified value.
 *     - Example: SetSaveLoadOutlineColor rgba(0,0,0,0.87)
 *   SetOtherScenesOutlineThickness <value>
 *     - Set the outline thickness for other scenes to the specified value.
 *     - Example: SetOtherScenesOutlineThickness 1
 *   SetOtherScenesOutlineColor <value>
 *     - Set the outline color for other scenes to the specified value.
 *     - Example: SetOtherScenesOutlineColor rgba(0,0,0,0.5)
 * 
 *日本語：このプラグインでは、Save/Load画面や他のシーンでのアウトラインの太さと色をカスタマイズできます。
 *
 *プラグインコマンド:
 *SetSaveLoadOutlineThickness <value>
 *- Save/Load画面のアウトラインの太さを指定した値に設定します。
 *- 例: SetSaveLoadOutlineThickness 8
 *SetSaveLoadOutlineColor <value>
 *- Save/Load画面のアウトラインの色を指定した値に設定します。
 *- 例: SetSaveLoadOutlineColor rgba(0,0,0,0.87)
 *SetOtherScenesOutlineThickness <value>
 *- 他のシーンのアウトラインの太さを指定した値に設定します。
 *- 例: SetOtherScenesOutlineThickness 1
 *SetOtherScenesOutlineColor <value>
 *- 他のシーンのアウトラインの色を指定した値に設定します。
 *- 例: SetOtherScenesOutlineColor rgba(0,0,0,0.5)
 */

(function() {
    // Read plugin parameters
    var parameters = PluginManager.parameters('OutlineThicknessPlugin');
    var saveLoadOutlineThickness = parseInt(parameters['SaveLoadOutlineThickness']) || 5;
    var saveLoadOutlineColor = String(parameters['SaveLoadOutlineColor']) || 'rgba(0,0,0,0.5)';
    var otherScenesOutlineThickness = parseInt(parameters['OtherScenesOutlineThickness']) || 0;
    var otherScenesOutlineColor = String(parameters['OtherScenesOutlineColor']) || 'rgba(0,0,0,0.5)';

    // Override Bitmap.prototype.drawText to customize outline thickness and color
    var _Bitmap_drawText = Bitmap.prototype.drawText;
    Bitmap.prototype.drawText = function(text, x, y, maxWidth, lineHeight, align) {
        if (SceneManager._scene instanceof Scene_Load || SceneManager._scene instanceof Scene_Save) {
            this.outlineWidth = saveLoadOutlineThickness;
            this.outlineColor = saveLoadOutlineColor;
            _Bitmap_drawText.call(this, text, x, y, maxWidth, lineHeight, align);
            this.outlineWidth = 0; // Reset outline width after drawing text
            this.outlineColor = 'rgba(0,0,0,0.5)'; // Reset outline color after drawing text
        } else {
            this.outlineWidth = otherScenesOutlineThickness;
            this.outlineColor = otherScenesOutlineColor;
            _Bitmap_drawText.call(this, text, x, y, maxWidth, lineHeight, align);
            this.outlineWidth = 0; // Reset outline width after drawing text
            this.outlineColor = 'rgba(0,0,0,0.5)'; // Reset outline color after drawing text
        }
    };

    // Register plugin command
    var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
    Game_Interpreter.prototype.pluginCommand = function(command, args) {
        _Game_Interpreter_pluginCommand.call(this, command, args);
        if (command === 'SetSaveLoadOutlineThickness') {
            saveLoadOutlineThickness = parseInt(args[0]) || 5;
        }
        if (command === 'SetSaveLoadOutlineColor') {
            saveLoadOutlineColor = String(args[0]) || 'rgba(0,0,0,0.5)';
        }
        if (command === 'SetOtherScenesOutlineThickness') {
            otherScenesOutlineThickness = parseInt(args[0]) || 0;
        }
        if (command === 'SetOtherScenesOutlineColor') {
            otherScenesOutlineColor = String(args[0]) || 'rgba(0,0,0,0.5)';
        }
    };
})();
