ZcheK

ZcheK
Regular
Joined
Feb 22, 2016
Messages
96
Reaction score
24
First Language
English
Primarily Uses
I can't seem to get the custom notifications working. I add this plugin command: this.newNotif(Strength Up!)


But nothing happens, am I doing something wrong?
 

STORMFATH3R

Developer
Member
Joined
Feb 26, 2015
Messages
19
Reaction score
10
First Language
English
Primarily Uses
RMMV
@ZcheK You just add the desired notification as a script, Here is a screenshot.Example.png
 

Lecode

(─‿‿─)
Regular
Joined
Dec 18, 2013
Messages
490
Reaction score
676
First Language
French
Primarily Uses
N/A
I can't seem to get the custom notifications working. I add this plugin command: this.newNotif(Strength Up!)


But nothing happens, am I doing something wrong?

Hello. Simply put Strengh Up! inside double quotes and use the script command instead. :)


this.newNotif("Strength Up!");


@Seshi:


var text = "6:00 AM";
this.newNotif(text);


Is enough.
 
Last edited by a moderator:

ZcheK

ZcheK
Regular
Joined
Feb 22, 2016
Messages
96
Reaction score
24
First Language
English
Primarily Uses
2 more questions.


1) I think someone asked already, but can you use this to show variables?


2) Is there a way to disable sounds?
 

Lecode

(─‿‿─)
Regular
Joined
Dec 18, 2013
Messages
490
Reaction score
676
First Language
French
Primarily Uses
N/A
Updated to 1.3:


HWox4FF.png



/*
# - 1.0 : Initial release
# - 1.1 : Bugfix
# - 1.2 : Bugfix ( Enable Command )
# - 1.3 : The notification visual is now a window,
#         allowing some escape codes to work:
#         \v[x], \c[x], \n[x], \p[x], \i[x] and \g
#         Long notifications are splitted in multiple notifications
#         when you use a new line or "|"*/



I also added an addon. 

1) I think someone asked already, but can you use this to show variables?

Yes, now you can. Use \V[x].

2) Is there a way to disable sounds?

Set false at the parameters.
 
Last edited by a moderator:

Logan C.

Regular
Regular
Joined
Oct 25, 2015
Messages
73
Reaction score
20
First Language
English
I get an error the moment i take an item:


"LeUtilites is not defined"
 

Logan C.

Regular
Regular
Joined
Oct 25, 2015
Messages
73
Reaction score
20
First Language
English
Sorry, can you correct me? I'm trying to add an icon, calling this script command:
this.newNotif('\i[10] Hello');


Text is there but no icon.
 
Last edited by a moderator:

Lecode

(─‿‿─)
Regular
Joined
Dec 18, 2013
Messages
490
Reaction score
676
First Language
French
Primarily Uses
N/A
You need to set double quotes and double backslashes.


this.newNotif("\\i[10] Hello");


It's a general rule for escape codes on native strings ^^.
 

bluebooth

Regular
Regular
Joined
Nov 12, 2015
Messages
95
Reaction score
123
First Language
English
Primarily Uses
N/A
Here's a complete closed-captioning file for all default sounds (plus some custom).  Anyone is welcome to use this in their own projects (with Lecode's Closed Captioning addon).  I'd love for someone more competent at CC to go through and improve some of these descriptions.  Accessibility is something that really hasn't been tackled much in games yet, and it excites me that we're in a position to push this field forward.

View attachment Notif_ClosedCaptions.json
 

bluebooth

Regular
Regular
Joined
Nov 12, 2015
Messages
95
Reaction score
123
First Language
English
Primarily Uses
N/A
Hey, thanks for the fixes!


I'll use that as a base and do CC for the default music next.
 

Kyuukon

主人公
Regular
Joined
Aug 22, 2013
Messages
2,278
Reaction score
1,151
First Language
Spanish
Primarily Uses
RMMV
Hi, is there a way to draw the item icon next to the item name automatically when obtaining one? D:
 
Last edited by a moderator:

gendfleur

Even Satanists have standards.
Regular
Joined
Jul 14, 2013
Messages
55
Reaction score
11
First Language
English
Primarily Uses
hey! i love this plugin, and i ESPECIALLY love the closed captions plugin, but it's not working for me for some reason :/ every time i play a bgm/bgs/se there's no popup. the notifications plugin is working just fine, and i'm not getting an error message, it's just not working. i have an incredibly stripped-down demo (one actor, three events that are player-action to play a bgm, a bgs, and a se) that's here (20mb) if you want to check that out


thanks for the plugin! :)
 

bluebooth

Regular
Regular
Joined
Nov 12, 2015
Messages
95
Reaction score
123
First Language
English
Primarily Uses
N/A
@gendfleur


Hey, so I originally sent my updated/slightly abused changes to Notifications System and Closed Captioning to our beloved LeCode, but I haven't heard back from him.  I ended up merging the two scripts into one (both sets of plugin options are still available).  I'm glad to see all the interest here for the plugin, so I've posted my unofficial version of the plugin below.

/*
#=============================================================================
# Notifications System
# LeNotifications.js
# By Lecode (full original script), Michael Morris (fixes, expansion)
# Version 1.04
#-----------------------------------------------------------------------------
# TERMS OF USE
#-----------------------------------------------------------------------------
# - Credit required
# - Keep this header
# - Contact me for commercial use
#=============================================================================
*/
var Imported = Imported || {};
Imported.Lecode_Notifications = true;
/*:
* @plugindesc Show some notifications according to different events in game
* @author Lecode, Michael Morris (https://www.patreon.com/bluebooth)
* @version 1.07
*
* Expansion and bug-fixes for Lecode's LeNotifications.js plugin. Maximum
* limit for currently displayed notifications added, bugfix for notifications
* showing when enabled was set to false, volume fix for multiple notifs playing
* sound at once. Merged with LeNotifsClosedCaptioning.js to get rid of namespace
* related crashes. CC now works properly. Added CC support for ME. Added Option
* for CC to Options Menu. Notifs now cleared between scene changes to avoid some
* notif issues (items thinking they're visible when they aren't, etc.). Notifs now
* shift position to avoid covering message box (and this shift is compatible with
* move ins and outs).
*
* @param Background Color
* @desc CSS Format
* Default: Black ( #000000 )
* @default #000000
*
* @param Text Color
* @desc CSS Format
* Default: White ( #FFFFFF )
* @default #FFFFFF
*
* @param Font Size
* @desc Font size
* Default: 18
* @default 18
*
* @param Font Italic ?
* @desc Font italic ?
* Default: false
* @default false
*
* @param Text Outline Color
* @desc Text Outline Color
* Default: None ( # )
* @default #
*
* @param Text Outline Width
* @desc Text Outline Width
* Default: 0
* @default 0
*
* @param Opacity
* @desc Layout's opacity (0-255)
* Default: 180
* @default 180
*
* @param Position
* @desc Layout's position. top-left, bottom-left, top-right, bottom-right
* Default: top-left
* @default top-left
*
* @param Left-Right Padding
* @desc Horizontal padding
* Default: 4
* @default 4
*
* @param Up-Down Padding
* @desc Vertical padding
* Default: 4
* @default 4
*
* @param Move Speed
* @desc The move speed
* Default: 6
* @default 6
*
* @param Fade Speed
* @desc The fade speed
* Default: 4
* @default 4
*
* @param Life Time
* @desc Duration (in frames)
* Default: 200
* @default 200
*
* @param Life Time Auto ?
* @desc If true, the life time is based on the length of the text.
* ( So, the previous param doesn't matter)
* Default: true
* @default true
*
* @param Sound Filename
* @desc Sound to play when a notification appears. Leave empty to play no sound.
* Default: Book1
* @default Book1
*
* @param Maximum Notifs
* @desc The maximum number of notifs to display at once on screen. Prevents notifs taking up too much of the screen.
* Default: 4
* @default 4
*
* @param Notif Gain Gold
* @desc Set false to disable.
* Default: Gold: +[value]
* @default Gold: +[value]
*
* @param Notif Lose Gold
* @desc Set false to disable.
* Default: Gold: -[value]
* @default Gold: -[value]
*
* @param Notif Gain Item
* @desc Set false to disable.
* Default: Obtained [name] x[amount]
* @default Obtained [name] x[amount]
*
* @param Notif Lose Item
* @desc Set false to disable.
* Default: Lost [name] x[amount]
* @default Lost [name] x[amount]
*
* @param Notif Gain Exp
* @desc Set false to disable.
* Default: [name]: +[value] Exp
* @default [name]: +[value] Exp
*
* @param Notif Lose Exp
* @desc Set false to disable.
* Default: [name]: -[value] Exp
* @default [name]: -[value] Exp
*
* @param Notif LevelUp
* @desc Set false to disable.
* Default: [name]: level up !
* @default [name]: level up !
*
* @param Notif LevelDown
* @desc Set false to disable.
* Default: [name]: level down !
* @default [name]: level down !
*
* @param Notif BGM
* @desc Set 'false' to disable
* Default: Now Playing \C[1]'[name]'\C[0]. [caption]
* @default Now Playing \C[1]'[name]'\C[0]. [caption]
*
* @param Notif BGS
* @desc Set 'false' to disable
* Default: Ambient sound:'[name]'. [caption]
* @default Ambient sound:'[name]'. [caption]
*
* @param Notif SE
* @desc Set 'false' to disable
* Default: SE:'[name]'. [caption]
* @default SE:'[name]'. [caption]
*
* @param Notif ME
* @desc Set 'false' to disable
* Default: Jingle:'[name]'. [caption]
* @default Jingle:'[name]'. [caption]
*
* @param Enable Closed Captioning
* @desc Set to 'true' to enable closed captioning for sounds. Overridden for any of Notif BGM, BGS, SE being false.
* Default: false
* @default false
*
* @param Debug Mode
* @desc Enable to activate console variable logging. Use for debugging odd behaviour.
* true to enable console variable logging.
* @default false
*
* @help
* Plugin Commands:
* -> Notification Clear ( Delete all notifications )
* -> Notification Enable true/false ( Enable or disable notifications )
* -> Notification Position value ( Change next notifications position )
* -> Notification TextColor value ( Change text color )
* -> Notification FontSize value ( Change font size )
* -> Notification FontItalic true/false ( Change text italic property )
* -> Notification OutlineColor value ( Change outline color set value to '' to remove )
* -> Notification OutlineWidth value ( Change outline width )
* -> Notification ResetParameters ( Reset all parameters )
* Script call:
* -> this.newNotif(text) ( Draw a custom text )
*/
//#=============================================================================

(function() {
/*-------------------------------------------------------------------------
* Get Parameters
-------------------------------------------------------------------------*/
var parameters = PluginManager.parameters('LeNotifications');
var pBgColor = String(parameters['Background Color'] || '#000000');
var pTextColor = String(parameters['Text Color'] || '#FFFFFF');
var pFontSize = Number(parameters['Font Size'] || 18);
var pFontItalic = ((parameters['Font Italic ?'] || 'false') === 'true');
var pTextOutlineColor = String(parameters['Text Outline Color'] || '#');
var pTextOutlineWidth = Number(parameters['Text Outline Width'] || 0);
var pOpacity = Number(parameters['Opacity'] || 180);
var pPos = String(parameters['Position'] || 'top-left');
var pXPadding = Number(parameters['Left-Right Padding'] || 4);
var pYPadding = Number(parameters['Up-Down Padding'] || 4);
var pMoveSpeed = Number(parameters['Move Speed'] || 6);
var pFadeSpeed = Number(parameters['Fade Speed'] || 6);
var pLifeTime = Number(parameters['Life Time'] || 200);
var pLifeTimeAuto = eval(((parameters['Life Time Auto ?'] || 'true') === 'true'));
var pSoundFile = String(parameters['Sound Filename'] || 'Book1');
var pMaxNotifs = Number(parameters['Maximum Notifs'] || 4);
var pNotifGainGold = String(parameters['Notif Gain Gold'] || 'Gold: +[value]');
var pNotifLoseGold = String(parameters['Notif Lose Gold'] || 'Gold: -[value]');
var pNotifGainItem = String(parameters['Notif Gain Item'] || 'Obtained [name] x[amount]');
var pNotifLoseItem = String(parameters['Notif Lose Item'] || 'Lost [name] x[amount]');
var pNotifGainExp = String(parameters['Notif Gain Exp'] || '[name]: +[value] Exp');
var pNotifLoseExp = String(parameters['Notif Lose Exp'] || '[name]: -[value] Exp');
var pNotifLevelUp = String(parameters['Notif LevelUp'] || '[name]: level up !');
var pNotifLevelDown = String(parameters['Notif LevelDown'] || '[name]: level down !');
var pNotifBgm = String(parameters['Notif BGM'] || "Playing '[name].' [caption]");
var pNotifBgs = String(parameters['Notif BSE'] || "Playing '[name].' [caption]");
var pNotifSe = String(parameters['Notif SE'] || "Playing '[name].' [caption]");
var pNotifMe = String(parameters['Notif ME'] || "Playing '[name].' [caption]");
var pEnableCC = String(parameters['Enable Closed Captioning'] || 'false');
var pDebugging = eval(String(parameters['Debug Mode'] || 'false'));

var _ccData = false;
var request = new XMLHttpRequest();
request.open('GET', "data/Notif_ClosedCaptions.json");
request.overrideMimeType('application/json');
request.onload = function() { _createCC(JSON.parse(request.responseText)); }
request.onerror = function() { throw new Error('There was an error loading the file ' + url); }
request.send();

var _createCC = function(data) {
if (pDebugging) {
console.log(data);
}
_ccData = data;
};

//=============================================================================
// Window_Options
//=============================================================================

var bbs_lenotif_Window_Options_addGeneralOptions =
Window_Options.prototype.addGeneralOptions;
Window_Options.prototype.addGeneralOptions = function() {
bbs_lenotif_Window_Options_addGeneralOptions.call(this);
this.addCommand('Closed Captioning?', 'closedCaptioning');
};

//=============================================================================
// ConfigManager
//=============================================================================

getDefaultCCOption = function() {
if (pEnableCC.match(/true/i)) {
return true;
} else if (pEnableCC.match(/false/i)) {
return false;
} else {
return Utils.isNwjs();
}
};

ConfigManager.closedCaptioning = getDefaultCCOption();

var bbs_lenotif_Configmanager_makeData = ConfigManager.makeData;
ConfigManager.makeData = function() {
var config = bbs_lenotif_Configmanager_makeData.call(this);
config.closedCaptioning = this.closedCaptioning;
return config;
};

var bbs_lenotif_Configmanager_applyData = ConfigManager.applyData;
ConfigManager.applyData = function(config) {
bbs_lenotif_Configmanager_applyData.call(this, config);
this.closedCaptioning = this.readConfigCC(config, 'closedCaptioning');
};

ConfigManager.readConfigCC = function(config, name) {
var value = config[name];
if (value !== undefined) {
return value;
} else {
return getDefaultCCOption();
}
};

/*-------------------------------------------------------------------------
* Notification Item Bitmap <- Bitmap
-------------------------------------------------------------------------*/
function LeNotifItemBitmap(type,w,h) {
Bitmap.call(this,w,h);
//- Set bitmap properties according to type
this.textColor = pTextColor;
this.fontSize = pFontSize;
this.fontItalic = pFontItalic;
this.outlineColor = pTextOutlineColor;
this.OutlineWidth = pTextOutlineWidth;
};

//- Heritage (Bitmap)
LeNotifItemBitmap.prototype = Object.create(Bitmap.prototype);
LeNotifItemBitmap.prototype.constructor = LeNotifItemBitmap;

/*-------------------------------------------------------------------------
* Notification Item <- Sprite
-------------------------------------------------------------------------*/
function LeNotifItem(text,type) {
this.initialize.apply(this, arguments);
};

//---- Heritage (Sprite)
LeNotifItem.prototype = Object.create(Sprite.prototype);
LeNotifItem.prototype.constructor = LeNotifItem;

//---- Initialization
LeNotifItem.prototype.initialize = function(text,type) {
Sprite.prototype.initialize.call(this, new LeNotifItemBitmap(type,1,1));
this.text = text;
this.type = type;
this.destX = 0;
this.destY = 0;
this.offsetX = 0;
this.offsetY = 0;
this.canFade = false;
this.canDecreaseLifeTime = false;
this.onScene = false;
this.dead = false;
this.msgBoxOffsetOn = false;
this.lastNodeWindowStatus = false;
this.setLifeTime();
this.createBitmap();
this.iniPosition();
};

//---- Set Life Time
LeNotifItem.prototype.setLifeTime = function() {
if (pLifeTimeAuto) {
this.lifeTime = this.text.length*12;
} else {
this.lifeTime = pLifeTime;
}
};

//---- Create Bitmap
LeNotifItem.prototype.createBitmap = function() {
var w = this.bitmap.measureTextWidth(this.text);
w += pXPadding*2;
var h = this.bitmap.fontSize + pYPadding*2;
this.bitmap = new LeNotifItemBitmap(this.typpe,w,h);
this.bitmap.fillAll(pBgColor);
this.opacity = pOpacity;
h = this.bitmap.fontSize + 2;
this.bitmap.drawText(this.text,pXPadding,pYPadding,w,h);
};

//---- Initialize Position
LeNotifItem.prototype.iniPosition = function() {
switch (pPos) {
case 'top-left':
this.x = -this.width;
this.y = 0;
this.destX = 0;
this.destY = this.y;
break;
case 'bottom-left':
this.x = -this.width;
this.y = Graphics.height - this.height;
this.destX = 0;
this.destY = this.y;
break;
case 'top-right':
this.x = Graphics.width;
this.y = 0;
this.destX = Graphics.width - this.width;
this.destY = this.y;
break;
case 'bottom-right':
this.x = Graphics.width;
this.y = Graphics.height - this.height;
this.destX = Graphics.width - this.width;
this.destY = this.y;
break;
}
};

//---- Update
LeNotifItem.prototype.update = function() {
Sprite.prototype.update.call(this);
this.updateMove();
this.updateLifeTime();
this.updateFade();
};

//---- Check for offset.
LeNotifItem.prototype.updateObstacleOffsetXY = function() {

// Only process when a. we have not yet accounted for offset, and b. game message is visible.
if (this.lastGameMsgStatus != $gameMessage.isBusy() || SceneManager._scene._nodeWindowOpen != this.lastNodeWindowStatus) {
// Only process when a. we have not yet accounted for offset, and b. game message is visible.
if ($gameMessage.isBusy() || SceneManager._scene._nodeWindowOpen === true) {

// Account for different pPos.
switch (pPos) {
case 'top-left':
if ($gameMessage.positionType() === 0) {
this.offsetY = 200;
}
break;
case 'bottom-left':
if ($gameMessage.positionType() === 2) {
this.offsetY = -200;
}
break;
case 'top-right':
if ($gameMessage.positionType() === 0) {
this.offsetY = 200;
}
break;
case 'bottom-right':
if ($gameMessage.positionType() === 2) {
this.offsetY = -200;
}
break;
};

// Cover for Node status window.
if($gameSwitches.value(742) === true) {
this.offsetY = 128;
}

// Correct Destination values for potential x/y value jump to avoid obscuring dialogue/location window.
this.x = this.x + this.offsetX;
this.y = this.y + this.offsetY;
this.destX = this.destX + this.offsetX;
this.destY = this.destY + this.offsetY;

}
else {
// Correct Destination values for potential x/y value jump to avoid obscuring dialogue/location window.
this.x = this.x - this.offsetX;
this.y = this.y - this.offsetY;
this.destX = this.destX - this.offsetX;
this.destY = this.destY - this.offsetY;
this.offsetY = 0;
}
}

this.lastNodeWindowStatus = SceneManager._scene._nodeWindowOpen;
this.lastGameMsgStatus = $gameMessage.isBusy();
}


//---- Update Move
LeNotifItem.prototype.updateMove = function() {

// Set offset if applicable.
this.updateObstacleOffsetXY();

if (pDebugging) {
console.log(this.x);
console.log(this.y);
console.log(this.destX);
console.log(this.destY);
}

if (this.moveFinished()) {
return;
}
//- Moving x
if (this.destX > this.x) {
this.x += pMoveSpeed;
if (this.x > this.destX) this.x = this.destX;
} else {
this.x -= pMoveSpeed;
if (this.x < this.destX) this.x = this.destX;
}
//- Moving y
if (this.destY > this.y) {
this.y += pMoveSpeed;
if (this.y > this.destY) this.y = this.destY;
} else {
this.y -= pMoveSpeed;
if (this.y < this.destY) this.y = this.destY;
}
//- Call onMoveFinished
if (this.moveFinished()) {
this.onMoveFinished();
}
};

//---- Move Finished ?
LeNotifItem.prototype.moveFinished = function() {
if (this.x == this.destX && this.y == this.destY) {
return true;
} else {
return false;
}
};

//---- When move is finished
LeNotifItem.prototype.onMoveFinished = function() {
this.canDecreaseLifeTime = true;
};

//---- Update life time
LeNotifItem.prototype.updateLifeTime = function() {
if (!this.canDecreaseLifeTime) {
return;
}
this.lifeTime -= 1;
if (this.lifeTime <= 0) {
this.onDeath();
}
};

//---- When dead
LeNotifItem.prototype.onDeath = function() {
this.canDecreaseLifeTime = false;
this.canFade = true;
};

//---- Update Fade
LeNotifItem.prototype.updateFade = function() {
if (!this.canFade) {
return;
}
this.opacity -= pFadeSpeed;
if (this.opacity <= 0) {
this.opacity = 0;
this.canFade = false;
this.onFadeFinished();
}
};

//---- When fade is finished
LeNotifItem.prototype.onFadeFinished = function() {
this.visible = false;
this.dead = true;
};

//---- Shift Down
LeNotifItem.prototype.shiftDown = function(y) {
this.y += y;
this.destY += y;
};


/*-------------------------------------------------------------------------
* Notification Manager
-------------------------------------------------------------------------*/
function LeNotifManager() {
throw new Error('This is a static class');
};

LeNotifManager.allNotifs = new Array();
LeNotifManager.displayedNotifs = new Array();
LeNotifManager.enabled = true;

//---- New Notification
LeNotifManager.add = function(text, type) {
if (!this.enabled) {
if (pDebugging) {
console.log("LeNotif disabled, ignoring add request");
}
return;
}

type = (typeof type !== 'undefined') ? type : "default";
notif = new LeNotifItem(text,type);

if (this.displayedNotifs.length < pMaxNotifs) {
this.addDisplayNotif(notif);
} else {
this.allNotifs.push(notif);
this.logNotifs();
}

};

LeNotifManager.addDisplayNotif = function(notif) {
// Coordinate positioning only matters for displayed notifs.
if (pPos == 'top-left' || pPos == 'top-right') {
this.displayedNotifs.forEach(function(n) {
n.shiftDown(notif.height);
});
} else if (pPos == 'bottom-left' || pPos == 'bottom-right') {
var y = 0;
this.displayedNotifs.forEach(function(n) {
y += n.height;
});
notif.shiftDown(-y);
}
this.displayedNotifs.push(notif);
this.logNotifs();
};

//---- Update
LeNotifManager.update = function() {
this.addNotifsToScene();
this.displayedNotifs.forEach(function(n) {
n.update;
});
this.removeDeadNotifs();
};

//---- Add notifs to Scene_Map
LeNotifManager.addNotifsToScene = function() {
var currNotifs = this.displayedNotifs.length;

this.displayedNotifs.forEach(function(n) {
if (!n.onScene && SceneManager._scene instanceof Scene_Map) {
n.onScene = true;
SceneManager._scene.addChild(n);

//- Play a sound if enabled.
if (pSoundFile) {
var audio = {};
audio.name = pSoundFile;
audio.pitch = 100;
audio.volume = (90 + ConfigManager.seVolume) / 2;
audio.pan = 0;

// Fix so that LeNotif does not report the sound it plays when adding a notification.
var oldNotifStatus = LeNotifManager.enabled;
LeNotifManager.enabled = false;

// Volume magnification fix when multiple notifs are added at once.
audio.volume = audio.volume / currNotifs;
AudioManager.playSe(audio);
LeNotifManager.enabled = oldNotifStatus;
}
}
});
};

//---- Remove dead notifs
LeNotifManager.removeDeadNotifs = function() {
var toDelete = [];
this.displayedNotifs.forEach(function(n) {
if (n.dead) {
SceneManager._scene.removeChild(n);
toDelete.push(n);
}
});

for(var i = 0; i < toDelete.length; i++){
var n = toDelete;
var index = this.displayedNotifs.indexOf(n);
this.compactNotifs(index,n);
this.displayedNotifs.splice(index,1);
}

// Push waiting notifs into displayedNotifs while room is available.
while (this.displayedNotifs.length < pMaxNotifs) {
if (this.allNotifs.length <= 0) {
if (pDebugging) {
console.log("Nothing to add");
}
break;
}

// Push head to displayed notifs, then pop head.
var head = this.allNotifs[0];
this.addDisplayNotif(head);
this.allNotifs.pop();
}

this.logNotifs();
};

//---- Compact notification when some are removed
LeNotifManager.compactNotifs = function(index,notif) {
if (pPos == 'top-left' || pPos == 'top-right') {
this.displayedNotifs.forEach(function(n) {
if (n.y > notif.y) {
n.shiftDown(-notif.height);
}
});
}
else if (pPos == 'bottom-left' || pPos == 'bottom-right') {
this.displayedNotifs.forEach(function(n) {
if (n.y < notif.y) {
n.shiftDown(notif.height);
}
});
}
};

//---- Clear
LeNotifManager.clear = function() {
// Only displayedNotifs children of scene.
this.displayedNotifs.forEach(function(n) {
SceneManager._scene.removeChild(n);
});

this.displayedNotifs = [];
this.allNotifs = [];
};

//---- Log Notifs
LeNotifManager.logNotifs = function() {
if (pDebugging) {
console.log("Displayed Notifs");
for (var i=0; i < this.displayedNotifs.length; i++) {
console.log(this.displayedNotifs.text);
}

console.log("All Notifs");
for (var j=0; j < this.allNotifs.length; j++) {
console.log(this.allNotifs[j].text);
}
}
};

/*-------------------------------------------------------------------------
* Scene_Base
-------------------------------------------------------------------------*/
var oldTerminate_SB = Scene_Base.prototype.terminate;
Scene_Base.prototype.terminate = function() {
// Prevent array confusion by clearing LeNotifManager during scene changes.
oldTerminate_SB.call(this);
LeNotifManager.clear();
};

/*-------------------------------------------------------------------------
* Game_Map
-------------------------------------------------------------------------*/
//---- Update
var oldUpdateFunc_GM = Game_Map.prototype.update;
Game_Map.prototype.update = function(sceneActive) {
oldUpdateFunc_GM.call(this,sceneActive);
if (sceneActive) {
LeNotifManager.update();
}
};


/*-------------------------------------------------------------------------
* Game_Interpreter
-------------------------------------------------------------------------*/
//---- Plugin Command
var old_pluginCommand = Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function(command, args) {
old_pluginCommand.call(this, command, args);
if (command === 'Notification') {
switch (args[0]) {
case 'Clear':
LeNotifManager.clear();
break;
case 'Enable':
LeNotifManager.enabled = eval(String(args[1]).toLowerCase());
if (pDebugging) {
console.log("LeNotifManager: set enabled = " + LeNotifManager.enabled);
}
break;
case 'Position':
pPos = String(args[1]);
break;
case 'TextColor':
pTextColor = String(args[1]);
break;
case 'FontSize':
pFontSize = Number(args[1]);
break;
case 'FontItalic':
pFontItalic = eval(String(args[1]).toLowerCase());
break;
case 'OutlineColor':
pTextOutlineColor = String(args[1]);
break;
case 'OutlineWidth':
pTextOutlineWidth = Number(args[1]);
break;
case 'ResetParameters':
pPos = String(parameters['Position'] || 'top-left');
pTextColor = String(parameters['Text Color'] || '#FFFFFF');
pFontSize = Number(parameters['Font Size'] || 18);
pFontItalic = eval(parameters['Font Italic ?'] || 'false');
pTextOutlineColor = String(parameters['Text Outline Color'] || '#');
pTextOutlineWidth = Number(parameters['Text Outline Width'] || 0);
break;
}
}
};

//---- Script Call
Game_Interpreter.prototype.newNotif = function(text,type) {
LeNotifManager.add(text,type);
};

/*-------------------------------------------------------------------------
* Game_Party
-------------------------------------------------------------------------*/
//---- Gain/Lose Gold
var oldGainGold_method = Game_Party.prototype.gainGold;
Game_Party.prototype.gainGold = function(amount) {
oldGainGold_method.call(this,amount);

if (!LeNotifManager.enabled) { return; }

var text = '';
if (amount > 0) {
if (pNotifGainGold === 'false') { return; }
text = pNotifGainGold.replace('[value]',String(amount));
} else if (amount < 0) {
if (pNotifLoseGold === 'false') { return; }
text = pNotifLoseGold.replace('[value]',String(-amount));
}
LeNotifManager.add(text,"gold");
};

//---- Gain/Lose Item
var oldGainItem_method = Game_Party.prototype.gainItem;
Game_Party.prototype.gainItem = function(item, amount, includeEquip) {
oldGainItem_method.call(this,item,amount,includeEquip);

if (!LeNotifManager.enabled) { return; }
if ( item == undefined || item.name == undefined) {
return;
}

var text = '';
if (amount > 0) {
if (pNotifGainItem === 'false') { return; }
text = pNotifGainItem.replace('[amount]',String(amount));
} else if (amount < 0) {
if (pNotifLoseItem === 'false') { return; }
text = pNotifLoseItem.replace('[amount]',String(-amount));
}

text = text.replace('[name]',item.name);
LeNotifManager.add(text,"item");
};


/*-------------------------------------------------------------------------
* Game_Interpreter
-------------------------------------------------------------------------*/
//---- Change EXP
var oldCommand315_method = Game_Interpreter.prototype.command315;
Game_Interpreter.prototype.command315 = function() {
oldCommand315_method.call(this);
var value = this.operateValue(this._params[2], this._params[3], this._params[4]);

if (!LeNotifManager.enabled) { return; }

var text = '';
if (value > 0) {
if (pNotifGainExp === 'false') { return true; }
text = pNotifGainExp.replace('[value]',String(value));
} else if (value < 0) {
if (pNotifLoseExp === 'false') { return true; }
text = pNotifLoseExp.replace('[value]',String(-value));
}

if(this._params[0] === 0 && this._params[1] === 0) {
text = text.replace('[name]','Party');
LeNotifManager.add(text,"exp");
} else {
this.iterateActorEx(this._params[0], this._params[1], function(actor) {
var text_i = text.replace('[name]',actor.name());
LeNotifManager.add(text_i,"exp");
}.bind(this));
}
return true;
};


/*-------------------------------------------------------------------------
* Game_Actor
-------------------------------------------------------------------------*/
//---- Level Up
var oldLevelUp_method = Game_Actor.prototype.levelUp;
Game_Actor.prototype.levelUp = function() {
oldLevelUp_method.call(this);

if (!LeNotifManager.enabled) { return; }
if (pNotifLevelUp === 'false') {
return;
}

var text = pNotifLevelUp.replace('[name]',this.name());
LeNotifManager.add(text,"levelup");
};

//---- Level Down
var oldLevelDown_method = Game_Actor.prototype.levelDown;
Game_Actor.prototype.levelDown = function() {
oldLevelDown_method.call(this);

if (!LeNotifManager.enabled) { return; }
if (pNotifLevelDown === 'false') {
return;
}

var text = pNotifLevelDown.replace('[name]',this.name());
LeNotifManager.add(text,"leveldown");
};


/*-------------------------------------------------------------------------
* AudioManager
-------------------------------------------------------------------------*/
//---- Play BGM
var oldPlayBgm_method = AudioManager.playBgm;
AudioManager.playBgm = function(bgm, pos) {
oldPlayBgm_method.call(this, bgm, pos);
if (pNotifBgm === 'false' || bgm == undefined || bgm.name == undefined) {
return;
}

if (SceneManager._scene instanceof Scene_Map) {
if (!ConfigManager.closedCaptioning) {
var text = pNotifBgm.replace('[name]', bgm.name);
text = text.replace('[caption]', '');
LeNotifManager.add(text,"bgm");
}
else {
var caption = _ccData[bgm.name];
if(caption == undefined || caption == null) return;
var text = pNotifBgm.replace('[name]', bgm.name);
text = text.replace('[caption]', caption);
LeNotifManager.add(text,"bgm");
}
}
};

//---- Play BGS
var oldPlayBgs_method = AudioManager.playBgs;
AudioManager.playBgs = function(bgs, pos) {
oldPlayBgs_method.call(this, bgs, pos);
if (pNotifBgs === 'false' || bgs == undefined || bgs.name == undefined) {
return;
}

if (SceneManager._scene instanceof Scene_Map) {
if (!ConfigManager.closedCaptioning) {
var text = pNotifBgs.replace('[name]', bgs.name);
text = text.replace('[caption]', '');
LeNotifManager.add(text, "bgs");
}
else {
var caption = _ccData[bgs.name];
if(caption == undefined || caption == null) return;
var text = pNotifBgs.replace('[name]', bgs.name);
text = text.replace('[caption]', caption);
LeNotifManager.add(text,"bgs");
}
}
};

//---- Play ME
var oldPlayMe_method = AudioManager.playMe;
AudioManager.playMe = function(me) {
oldPlayMe_method.call(this, me);
if (pNotifMe === 'false' || me == undefined || me.name == undefined) {
return;
}

if (SceneManager._scene instanceof Scene_Map) {
if (!ConfigManager.closedCaptioning) {
var text = pNotifMe.replace('[name]', me.name);
text = text.replace('[caption]', '');
LeNotifManager.add(text, "me");
}
else {
var caption = _ccData[me.name];
if(caption == undefined || caption == null) return;
var text = pNotifMe.replace('[name]', me.name);
text = text.replace('[caption]', caption);
LeNotifManager.add(text, "me");
}
}
};

//---- Play SE
var oldPlaySe_method = AudioManager.playSe;
AudioManager.playSe = function(se) {
oldPlaySe_method.call(this, se);
if (pNotifSe === 'false' || se == undefined || se.name == undefined) {
return;
}

if (SceneManager._scene instanceof Scene_Map) {
if (!ConfigManager.closedCaptioning) {
var text = pNotifBgm.replace('[name]', se.name);
text = text.replace('[caption]', '');
LeNotifManager.add(text, "se");
}
else {
var caption = _ccData[se.name];
if(caption == undefined || caption == null) return;
var text = pNotifSe.replace('[name]', se.name);
text = text.replace('[caption]', caption);
LeNotifManager.add(text, "se");
}
}
};

/*-------------------------------------------------------------------------
* Game_Actor
-------------------------------------------------------------------------*/
//---- Change Equipment
var oldChangeEquip_method = Game_Actor.prototype.changeEquip;
Game_Actor.prototype.changeEquip = function(slotId, item) {
var oldNotifStatus = LeNotifManager.enabled;

LeNotifManager.enabled = false;
oldChangeEquip_method.call(this,slotId,item);
LeNotifManager.enabled = oldNotifStatus;
};

//---- Force Change Equipment
var oldForceChangeEquip_method = Game_Actor.prototype.forceChangeEquip;
Game_Actor.prototype.forceChangeEquip = function(slotId, item) {
var oldNotifStatus = LeNotifManager.enabled;

LeNotifManager.enabled = false;
oldForceChangeEquip_method.call(this,slotId,item);
LeNotifManager.enabled = oldNotifStatus;
};

//---- Trade Item with Party
var oldTradewithParty_method = Game_Actor.prototype.tradeItemWithParty;
Game_Actor.prototype.tradeItemWithParty = function(newItem, oldItem) {
var oldNotifStatus = LeNotifManager.enabled;

LeNotifManager.enabled = false;
var bool = oldTradewithParty_method.call(this,newItem,oldItem);
LeNotifManager.enabled = oldNotifStatus;
return bool;
};

//---- Handle Yanfly's methods

if (Imported.YEP_ItemCore === true) {

var oldInitIndepenEquips_method = Game_Actor.prototype.initIndependentEquips;
Game_Actor.prototype.initIndependentEquips = function(equips) {
var oldNotifStatus = LeNotifManager.enabled;

LeNotifManager.enabled = false;
oldInitIndepenEquips_method.call(this,equips);
LeNotifManager.enabled = oldNotifStatus;
};

var oldChangeEquipById_method = Game_Actor.prototype.changeEquipById;
Game_Actor.prototype.changeEquipById = function(etypeId, itemId) {
var oldNotifStatus = LeNotifManager.enabled;

LeNotifManager.enabled = false;
oldChangeEquipById_method.call(this,etypeId,itemId);
LeNotifManager.enabled = oldNotifStatus;
};

} //-Yanfly check

})();






Please try this and let me know if you are still getting errors.


View attachment LeNotifications.js
 
Last edited by a moderator:

DarkRafa

Warper
Member
Joined
Jan 26, 2013
Messages
4
Reaction score
0
First Language
Brazilian
Primarily Uses
What's up guys.... really nice job here.
So, i used this incredible plugin a few time and i have one little request to upgraded in it: a skill notification, with your own sound preferably.
You guys can do it??
If the plugin already can do this, please, show me because i've searched and a found nothing! And well... i'm Layman! The Layman :thumbsup-left:

Thank you so much anyway!
 

bluebooth

Regular
Regular
Joined
Nov 12, 2015
Messages
95
Reaction score
123
First Language
English
Primarily Uses
N/A
What's up guys.... really nice job here.
So, i used this incredible plugin a few time and i have one little request to upgraded in it: a skill notification, with your own sound preferably.
You guys can do it??
If the plugin already can do this, please, show me because i've searched and a found nothing! And well... i'm Layman! The Layman :thumbsup-left:

Thank you so much anyway!

Hey, Layman! What do you mean by skill notification? Do you want a notification to appear when a new skill is learned or forgotten, or for when a skill is used?
 

Latest Threads

Latest Posts

Latest Profile Posts

How it feels right now with Advent resources and Sleigh the Competition event screenshots coming in.
WindRyder_ChristmasIncoming.png
So, apparently, Glow-in-the-Dark cats exist.

Are Sir Oinkers and the fairy responsible for all those dead uhm sleeping monsters?
Well, they now can be in your game, thanks to Day 4's content!
1701691228682.png

Forum statistics

Threads
136,736
Messages
1,269,346
Members
180,456
Latest member
nosebleedfreak
Top