pony-celes/www/js/plugins/MOG_MenuParticles.js
2023-12-31 23:21:30 -06:00

389 lines
12 KiB
JavaScript

//===========================================================================
// MOG_MenuParticles.js
// Translate to Japanese : fungamemake.com
//===========================================================================
/*:
* @plugindesc (v1.1) Adiciona partículas nas cenas menu.
* @author Moghunter
*
* @param Number of Particles
* @desc Definição do numero de partículas.
* @default 15
*
* @param Disable Scenes
* @desc Definição das cenas que terão o efeito desativado.
* Scene_Name1 , Scene_Name2 , Scene_Name3 ...
* @default Scene_Test1,Scene_Test2,Scene_Test3
*
* @param Unique Particles
* @desc Cada cena terá uma imagem de partícula diferente.
* @default false
*
* @param X-Axis Speed
* @desc Definição da velocidade de deslize na horizontal.
* @default 0
*
* @param Y-Axis Speed
* @desc Definição da velocidade de deslize na vertical.
* @default -1
*
* @param Rotation Speed
* @desc Definição da velocidade da rotação.
* @default 1
*
* @param Blend Mode
* @desc Definição do modo Blend.
* @default 1
*
* @help
* ===========================================================================
* +++ MOG - Menu Particles (v1.1) +++
* By Moghunter
* https://atelierrgss.wordpress.com/
* ===========================================================================
* Adiciona partículas nas cenas menu
* É possivel ativar uma partícula diferente para cada cena ou desativar a
* partícula em cenas especificas.
* ===========================================================================
* As imagens das patículas deverão ficar na paste /img/menus/
* ===========================================================================
* No caso da opção Unique Particles estiver ativada cada partícula deverá
* seguir essa nomeação.
*
* SCENE_NAME + _par.png
*
* Exemplo.
*
* Scene_Menu_par.png
* Scene_Item_par.png
* Scene_Skill_par.png
* etc...
* ===========================================================================
* HISTÓRICO
* ===========================================================================
* (v1.1) - Correção da função UNIQUE PARTICLES.
*
*/
/*:ja
* @plugindesc (v1.1) メニューにパーティクルを追加します。
* @author Moghunter
*
* @param Number of Particles
* @text パーティクル量
* @default 15
*
* @param Unique Particles
* @text シーン別パーティクルの有効化
* @type boolean
* @on 有効
* @off 無効
* @default false
*
* @param Disable Scenes
* @text 無効にするシーン
* @desc 例:Scene_Menu, Scene_Item, Scene_Skill, Scene_Equip, Scene_Status, Scene_Options, Scene_Save, Scene_GameEnd
* @default Scene_Menu,Scene_Item,Scene_Skill,Scene_Equip,Scene_Status,Scene_Options,Scene_Save,Scene_GameEnd
*
* @param X-Axis Speed
* @text X方向移動速度
* @desc 正:右 / 負:左
* @default 0
*
* @param Y-Axis Speed
* @text Y方向移動速度
* @desc 正:下 / 負:上
* @default -1
*
* @param Rotation Speed
* @text 回転速度
* @desc 正:時計回り / 負:反時計回り。絶対値が大きいほど高速。
* @default 1
*
* @param Blend Mode
* @text 合成方法
* @desc 0:通常 / 1:加算 / 2:乗算
* @type select
* @option 通常
* @value 0
* @option 加算
* @value 1
* @option 乗算
* @value 2
* @default 1
*
* @help
* 翻訳:ムノクラ
* https://fungamemake.com/
* https://twitter.com/munokura/
*
* ===========================================================================
* +++ MOG - Menu Particles (v1.1) +++
* By Moghunter
* https://atelierrgss.wordpress.com/
* ===========================================================================
* メニューにパーティクルを追加します。
* シーン別に異なるパーティクルを有効/無効にできます。
* ===========================================================================
* 必要な画像ファイルを下記に保存して下さい。
* /img/menus/
*
* デフォルトのパーティクル画像ファイルが必要です。
* Particles.png
*
* ===========================================================================
* シーン別パーティクルが有効の場合、
* 各パーティクル画像ファイル名は下記の法則に従って下さい。
*
* Scene_Name + _par.png
*
* 例
*
* Scene_Menu_par.png
* Scene_Item_par.png
* Scene_Skill_par.png
* Scene_Equip_par.png
* Scene_Status_par.png
* Scene_Options_par.png
* Scene_Save_par.png
* Scene_GameEnd_par.png
*
* ===========================================================================
* 更新履歴
* ===========================================================================
* (v1.1) - シーン別パーティクル機能修正
*
*/
//===========================================================================
// ** PLUGIN PARAMETERS
//===========================================================================
var Imported = Imported || {};
Imported.MOG_MenuParticles = true;
var Moghunter = Moghunter || {};
Moghunter.parameters = PluginManager.parameters("MOG_MenuParticles");
Moghunter.mpart_selfpart = String(
Moghunter.parameters["Unique Particles"] || "false"
);
Moghunter.mpart_skipscenes = Object(
Moghunter.parameters["Disable Scenes"] || []
);
Moghunter.mpart_ox = Number(Moghunter.parameters["X-Axis Speed"] || 0);
Moghunter.mpart_oy = Number(Moghunter.parameters["Y-Axis Speed"] || -1);
Moghunter.mpart_a = Number(Moghunter.parameters["Rotation Speed"] || 1);
Moghunter.mpart_number = Number(
Moghunter.parameters["Number of Particles"] || 15
);
Moghunter.mpart_blendMode = Number(Moghunter.parameters["Blend Mode"] || 1);
SceneManager._mpart = false;
//===========================================================================
// ** ImageManager
//===========================================================================
//==============================
// * Menus
//==============================
ImageManager.loadMenus = function (filename) {
return this.loadBitmap("img/menus/", filename, 0, true);
};
//===========================================================================
// ** Game System
//===========================================================================
//==============================
// * Get Par Array
//==============================
Game_System.prototype.get_par_array = function (object, value, type) {
if (value.length === 0) {
return;
}
var s = value.split(",");
if (type === 0) {
for (var i = 0; i < s.length; i++) {
object.push(String(s[i]));
}
} else {
for (var i = 0; i < s.length; i++) {
object.push(Number(s[i]));
}
}
};
//===========================================================================
// ** Scene MenuBase
//===========================================================================
//==============================
// * Skip Particles
//==============================
Scene_MenuBase.prototype.skip_particles = function () {
if (!SceneManager._scene) {
return false;
}
this._mb_skip_scenes = [];
$gameSystem.get_par_array(
this._mb_skip_scenes,
Moghunter.mpart_skipscenes,
0
);
for (var i = 0; i < this._mb_skip_scenes.length; i++) {
if (this._mb_skip_scenes[i] === SceneManager._scene.constructor.name) {
return true;
}
}
return false;
};
//==============================
// * Create
//==============================
var _alias_mog_mpart_scbase_createBackground =
Scene_MenuBase.prototype.createBackground;
Scene_MenuBase.prototype.createBackground = function () {
SceneManager._mpart = false;
_alias_mog_mpart_scbase_createBackground.call(this);
if (!this.skip_particles()) {
this.create_mparticles();
}
};
//==============================
// * Terminate
//==============================
var _alias_mog_mpart_scmb_terminate = Scene_MenuBase.prototype.terminate;
Scene_MenuBase.prototype.terminate = function () {
_alias_mog_mpart_scmb_terminate.call(this);
SceneManager._mpart = false;
};
//==============================
// * Set Particle Img
//==============================
Scene_MenuBase.prototype.set_particle_img = function () {
if (this._self_par && SceneManager._scene) {
return SceneManager._scene.constructor.name + "_par";
}
return "Particles";
};
//==============================
// * Create Mbackground
//==============================
Scene_MenuBase.prototype.create_mparticles = function () {
this._self_par = false;
SceneManager._mpart = true;
if (String(Moghunter.mpart_selfpart) === "true") {
this._self_par = true;
}
this._sprite_particles = [];
this._sprite_particles_data = [];
this._nw = [0, 0];
if (Moghunter.mpart_ox > 0) {
this._nw[0] = -(Graphics.boxWidth / 3);
}
if (Moghunter.mpart_ox < 0) {
this._nw[0] = Graphics.boxWidth / 3;
}
this._nw[1] = Math.abs(this._nw[0]);
for (i = 0; i < Moghunter.mpart_number; i++) {
this._sprite_particles.push(
new Sprite(ImageManager.loadMenus(this.set_particle_img()))
);
this.addChild(this._sprite_particles[i]);
this._sprite_particles_data[i] = [];
this.reset_particles(i);
this._sprite_particles[i].x = Math.randomInt(Graphics.boxWidth);
this._sprite_particles[i].y = Math.randomInt(Graphics.boxHeight);
this._sprite_particles[i].opacity = 0;
this._sprite_particles[i].blendMode = Moghunter.mpart_blendMode;
}
};
//==============================
// * Reset Particles
//==============================
Scene_MenuBase.prototype.reset_particles = function (i) {
this._sprite_particles_data[i][0] =
(Math.random() * 2 + 0.4) * Moghunter.mpart_ox;
this._sprite_particles_data[i][1] =
(Math.random() * 2 + 0.4) * Moghunter.mpart_oy;
this._sprite_particles_data[i][2] = Math.random() * Moghunter.mpart_a * 0.01;
this._sprite_particles[i].opacity = 0;
this._sprite_particles[i].x = this._nw[0] + Math.randomInt(Graphics.boxWidth);
var pz = Math.random() * 0.5 * 1;
this._sprite_particles[i].scale = new PIXI.Point(
0.5 + Number(pz),
0.5 + Number(pz)
);
if (Moghunter.mpart_oy < 0) {
this._sprite_particles[i].y =
Graphics.boxHeight + this._sprite_particles[i].height * 3;
} else if (Moghunter.mpart_oy > 0) {
this._sprite_particles[i].y = -this._sprite_particles[i].height * 3;
} else {
this._sprite_particles[i].y = Math.randomInt(Graphics.boxHeight);
}
if (
this._sprite_particles_data[i][0] == 0 &&
this._sprite_particles_data[i][1] == 0
) {
this._sprite_particles[i].x = -Graphics.width;
}
};
//==============================
// * Update
//==============================
var _mog_mpart_scbase_update = Scene_MenuBase.prototype.update;
Scene_MenuBase.prototype.update = function () {
_mog_mpart_scbase_update.call(this);
if (SceneManager._mpart) {
this.update_particles();
}
};
//==============================
// * Update Particles
//==============================
Scene_MenuBase.prototype.update_particles = function () {
for (var i = 0; i < this._sprite_particles.length; i++) {
this._sprite_particles[i].x += this._sprite_particles_data[i][0];
this._sprite_particles[i].y += this._sprite_particles_data[i][1];
this._sprite_particles[i].opacity += 4;
this._sprite_particles[i].rotation += this._sprite_particles_data[i][2];
if (this.need_reset_particles(i)) {
this.reset_particles(i);
}
}
};
//==============================
// * Need Reset Particles
//==============================
Scene_MenuBase.prototype.need_reset_particles = function (i) {
if (
this._sprite_particles[i].x <
-this._nw[1] - this._sprite_particles[i].width * 3
) {
return true;
}
if (
this._sprite_particles[i].x >
this._nw[1] + Graphics.boxWidth + this._sprite_particles[i].width * 3
) {
return true;
}
if (this._sprite_particles[i].y < -this._sprite_particles[i].height * 3) {
return true;
}
if (
this._sprite_particles[i].y >
Graphics.boxHeight + this._sprite_particles[i].height * 3
) {
return true;
}
return false;
};