Ark's Save Engine (complete)
JS Plugins In DevelopmentThis is the code I use to get the serialized screenshot:
var snap = SceneManager.snap(); var urlData = snap._canvas.toDataURL();You can resize it by creating a new bitmap after the first line, then doing a .blt on it, specifying the size you want.
Edit: Also check the .resize method on the Bitmap class, maybe that can be used.
Something like this:
var snap = SceneManager.snap(); var resized = new Bitmap(256, 143); resized.blt(snap, 0, 0, snap._canvas.width, snap._canvas.height, 0, 0, 256, 143); var urlData = resized._canvas.toDataURL();You then save this urlData on the save file header (by aliasing the DataManager.makeSavefileInfo method);
I believe you can then load it like this:
var bitmap = new Bitmap(256, 143);bitmap.load(urlData);I didn't really test any of this.
var snap = SceneManager.snap(); var urlData = snap._canvas.toDataURL();You can resize it by creating a new bitmap after the first line, then doing a .blt on it, specifying the size you want.
Edit: Also check the .resize method on the Bitmap class, maybe that can be used.
Something like this:
var snap = SceneManager.snap(); var resized = new Bitmap(256, 143); resized.blt(snap, 0, 0, snap._canvas.width, snap._canvas.height, 0, 0, 256, 143); var urlData = resized._canvas.toDataURL();You then save this urlData on the save file header (by aliasing the DataManager.makeSavefileInfo method);
I believe you can then load it like this:
var bitmap = new Bitmap(256, 143);bitmap.load(urlData);I didn't really test any of this.
It seems to save, but the display is empty..
And exiting out of the scene causes this crash.
An error occured while saving the screenshot Errorfile:///X:/SkyDrive/_RMMV%20Projects/Projects/Prequel%20Project/img/Screenshots/map_2015_11_25_13_0_27_221_3464.png Failed to load resource: net::ERR_FILE_NOT_FOUND2/X:/SkyDrive/_RMMV%20Projects/Projects/Prequel%20Project/js/plugins/GALV_MagicShards.js:789 testrpg_managers.js:1620 Error: Failed to load: img/Screenshots/map_2015_11_25_13_0_27_221_3464.png at Function.ImageManager.isReady (rpg_managers.js:790) at Scene_Menu.Scene_Base.isReady (rpg_scenes.js:33) at Function.SceneManager.updateScene (rpg_managers.js:1669) at Function.SceneManager.updateMain (/X:/SkyDrive/_RMMV%20Projects/Projects/Prequel%20Project/js/plugins/TDDP_FluidTimestep.js:108) at Function.SceneManager.update (/X:/SkyDrive/_RMMV%20Projects/Projects/Prequel%20Project/js/plugins/TDDP_FluidTimestep.js:86) It is very possible that another plugin is conflicting. Trying to isolate it now.
Edit:
Clean Project... Still errors.
And exiting out of the scene causes this crash.
An error occured while saving the screenshot Errorfile:///X:/SkyDrive/_RMMV%20Projects/Projects/Prequel%20Project/img/Screenshots/map_2015_11_25_13_0_27_221_3464.png Failed to load resource: net::ERR_FILE_NOT_FOUND2/X:/SkyDrive/_RMMV%20Projects/Projects/Prequel%20Project/js/plugins/GALV_MagicShards.js:789 testrpg_managers.js:1620 Error: Failed to load: img/Screenshots/map_2015_11_25_13_0_27_221_3464.png at Function.ImageManager.isReady (rpg_managers.js:790) at Scene_Menu.Scene_Base.isReady (rpg_scenes.js:33) at Function.SceneManager.updateScene (rpg_managers.js:1669) at Function.SceneManager.updateMain (/X:/SkyDrive/_RMMV%20Projects/Projects/Prequel%20Project/js/plugins/TDDP_FluidTimestep.js:108) at Function.SceneManager.update (/X:/SkyDrive/_RMMV%20Projects/Projects/Prequel%20Project/js/plugins/TDDP_FluidTimestep.js:86) It is very possible that another plugin is conflicting. Trying to isolate it now.
Edit:
Clean Project... Still errors.
Code:
An error occured while saving the screenshot Errorfile:///X:/SkyDrive/_RMMV%20Projects/Projects/Clean/img/Screenshots/map_2015_11_25_13_5_50_965_1683.png Failed to load resource: net::ERR_FILE_NOT_FOUNDrpg_managers.js:1618 Error: Failed to load: img/Screenshots/map_2015_11_25_13_5_50_965_1683.png at Function.ImageManager.isReady (rpg_managers.js:790) at Scene_Menu.Scene_Base.isReady (rpg_scenes.js:33) at Function.SceneManager.updateScene (rpg_managers.js:1667) at Function.SceneManager.updateMain (rpg_managers.js:1641) at Function.SceneManager.update (rpg_managers.js:1576)
I updated the plugin, and now it have configurable parameters and one less issue to bother us. More infos in the first post.
@Hudell
Thank you very much Hudell. Ou obrigado, já que pelo visto você também fala português e meu inglês é uma droga hehe...
Should I talk in english with you or portuguese? I think the moderators can think it's wrong if I start to speak in portuguese here, so... >_<
When you say
var oldMakeSavefileInfo = DataManager.makeSavefileInfo;DataManager.makeSavefileInfo = function() {var info = oldMakeSavefileInfo.call(this); info.location = urlData;return info;}; I did not tested it yet, but this was what I can think by now... I will be testing as long as I can.
So, If I do that, I should load the image that way?
Window_SavefileStatus.prototype.drawScreenshot = function(info, x, y) { if (info && info.characters) { var bitmap = new Bitmap(256, 143); bitmap.addLoadListener(function() { bitmap.load(urlData); }.bind(this)); } };@Roguedeus
You will have to rename your game folders so it do not have spaces or symbols. You have two folders with spaces in the name. It's an issue that I yet have to solve.
The folders that you have to rename are:
Sorry for this incovinience. ><
@Hudell
Thank you very much Hudell. Ou obrigado, já que pelo visto você também fala português e meu inglês é uma droga hehe...
Should I talk in english with you or portuguese? I think the moderators can think it's wrong if I start to speak in portuguese here, so... >_<
When you say
Are saying me to do this?
var oldMakeSavefileInfo = DataManager.makeSavefileInfo;DataManager.makeSavefileInfo = function() {var info = oldMakeSavefileInfo.call(this); info.location = urlData;return info;}; I did not tested it yet, but this was what I can think by now... I will be testing as long as I can.
So, If I do that, I should load the image that way?
Window_SavefileStatus.prototype.drawScreenshot = function(info, x, y) { if (info && info.characters) { var bitmap = new Bitmap(256, 143); bitmap.addLoadListener(function() { bitmap.load(urlData); }.bind(this)); } };@Roguedeus
You will have to rename your game folders so it do not have spaces or symbols. You have two folders with spaces in the name. It's an issue that I yet have to solve.
The folders that you have to rename are:
and
Or wait until I solve the problem. Hudell is helpping me with this. ^^
Sorry for this incovinience. ><
You have to call the .load outside of the load listener, or it will never be called.
Code:
Window_SavefileStatus.prototype.drawScreenshot = function(info, x, y) { if (info && info.characters) { var bitmap = new Bitmap(256, 143); bitmap.addLoadListener(function(){}.bind(this)); bitmap.load(urlData); } };
@Hudell
Hmmmmmmmm.... Having problem to load the thumbnail.
Code:
////////////////////////////////////NEW METHOD//////////////////////////////////// var ark_urlData = undefined; Scene_File.generateFileData = function () { var snap = SceneManager.snap(); var resized = new Bitmap(256, 143); resized.blt(snap, 0, 0, snap._canvas.width, snap._canvas.height, 0, 0, 256, 143); ark_urlData = resized._canvas.toDataURL(); }//(...)//var oldMakeSavefileInfo = DataManager.makeSavefileInfo; DataManager.makeSavefileInfo = function() { var info = oldMakeSavefileInfo.call(this); info.location = $dataMap.displayName != "" ? $dataMap.displayName : $dataMapInfos[$gameMap.mapId()].name; info.level = $gameParty.members()[0].level; info.gold = $gameParty.gold(); info.map_id = $gameMap.mapId(); info.svactors = $gameSystem.svactorlist(); info.thumbnail = ark_urlData; //NEW METHOD return info; }; //(...)//Scene_Map.prototype.callMenu = function() { Scene_File.generateFileData(); // NEW METHOD TO GENERATE THE SCREENSHOT console.log(ark_urlData) SoundManager.playOk(); SceneManager.push(Scene_Menu); Window_MenuCommand.initCommandPosition(); $gameTemp.clearDestination(); this._mapNameWindow.hide(); this._waitCount = 2;};//(...)//Window_SavefileStatus.prototype.drawScreenshot = function(info, x, y) { if (info && info.characters) { if (info.thumbnail != undefined || info.thumbnail != null) { var bitmap = new Bitmap(256, 143); bitmap.addLoadListener(function(){}.bind(this)); bitmap.load(info.thumbnail);} } };Trying to figure out what is wrong. :/
Hmmmmmmmm.... Having problem to load the thumbnail.
////////////////////////////////////NEW METHOD//////////////////////////////////// var ark_urlData = undefined; Scene_File.generateFileData = function () { var snap = SceneManager.snap(); var resized = new Bitmap(256, 143); resized.blt(snap, 0, 0, snap._canvas.width, snap._canvas.height, 0, 0, 256, 143); ark_urlData = resized._canvas.toDataURL(); }//(...)//var oldMakeSavefileInfo = DataManager.makeSavefileInfo; DataManager.makeSavefileInfo = function() { var info = oldMakeSavefileInfo.call(this); info.location = $dataMap.displayName != "" ? $dataMap.displayName : $dataMapInfos[$gameMap.mapId()].name; info.level = $gameParty.members()[0].level; info.gold = $gameParty.gold(); info.map_id = $gameMap.mapId(); info.svactors = $gameSystem.svactorlist(); info.thumbnail = ark_urlData; //NEW METHOD return info; }; //(...)//Scene_Map.prototype.callMenu = function() { Scene_File.generateFileData(); // NEW METHOD TO GENERATE THE SCREENSHOT console.log(ark_urlData) SoundManager.playOk(); SceneManager.push(Scene_Menu); Window_MenuCommand.initCommandPosition(); $gameTemp.clearDestination(); this._mapNameWindow.hide(); this._waitCount = 2;};//(...)//Window_SavefileStatus.prototype.drawScreenshot = function(info, x, y) { if (info && info.characters) { if (info.thumbnail != undefined || info.thumbnail != null) { var bitmap = new Bitmap(256, 143); bitmap.addLoadListener(function(){}.bind(this)); bitmap.load(info.thumbnail);} } };Trying to figure out what is wrong. :/
***********UPDATE*****************
Well, the error message stopped when I changed "bitmap.load" for "Bitmap.load", but no picture appears :/
And it seems that Bitmap.load works with urls.
Are we trying to get a url or to redraw the image pixel per pixel?
Because I think that if we store the image code, pixel per pixel, and find a way to load it from the save file, we would come with a solution. I was researching for some information that could help, and just find some treads about "context" things....
this http://stackoverflow.com/questions/10855189/get-pixels-of-a-bitmap-with-javascript
and http://mrcoles.com/blog/making-images-byte-by-byte-javascript/
I tryied, but I can't understand what to do. :/
In the Bitmap.snap, on game core, I found:
Bitmap.snap = function(stage) { var width = Graphics.width; var height = Graphics.height; var bitmap = new Bitmap(width, height); var context = bitmap._context; var renderTexture = new PIXI.RenderTexture(width, height); if (stage) { renderTexture.render(stage); stage.worldTransform.identity(); } if (Graphics.isWebGL()) { var gl = renderTexture.renderer.gl; var webGLPixels = new Uint8Array(4 * width * height); gl.bindFramebuffer(gl.FRAMEBUFFER, renderTexture.textureBuffer.frameBuffer); gl.readPixels(0, 0, width, height, gl.RGBA, gl.UNSIGNED_BYTE, webGLPixels); gl.bindFramebuffer(gl.FRAMEBUFFER, null); var canvasData = context.getImageData(0, 0, width, height); canvasData.data.set(webGLPixels); context.putImageData(canvasData, 0, 0); } else { context.drawImage(renderTexture.textureBuffer.canvas, 0, 0); } bitmap._setDirty(); return bitmap;};And still don't understand ><
Well, the error message stopped when I changed "bitmap.load" for "Bitmap.load", but no picture appears :/
And it seems that Bitmap.load works with urls.
Are we trying to get a url or to redraw the image pixel per pixel?
Because I think that if we store the image code, pixel per pixel, and find a way to load it from the save file, we would come with a solution. I was researching for some information that could help, and just find some treads about "context" things....
this http://stackoverflow.com/questions/10855189/get-pixels-of-a-bitmap-with-javascript
and http://mrcoles.com/blog/making-images-byte-by-byte-javascript/
I tryied, but I can't understand what to do. :/
In the Bitmap.snap, on game core, I found:
Bitmap.snap = function(stage) { var width = Graphics.width; var height = Graphics.height; var bitmap = new Bitmap(width, height); var context = bitmap._context; var renderTexture = new PIXI.RenderTexture(width, height); if (stage) { renderTexture.render(stage); stage.worldTransform.identity(); } if (Graphics.isWebGL()) { var gl = renderTexture.renderer.gl; var webGLPixels = new Uint8Array(4 * width * height); gl.bindFramebuffer(gl.FRAMEBUFFER, renderTexture.textureBuffer.frameBuffer); gl.readPixels(0, 0, width, height, gl.RGBA, gl.UNSIGNED_BYTE, webGLPixels); gl.bindFramebuffer(gl.FRAMEBUFFER, null); var canvasData = context.getImageData(0, 0, width, height); canvasData.data.set(webGLPixels); context.putImageData(canvasData, 0, 0); } else { context.drawImage(renderTexture.textureBuffer.canvas, 0, 0); } bitmap._setDirty(); return bitmap;};And still don't understand ><
UPDATE
I completed this plugin.... Now I don't know if a moderator will close it or move it to the Release forum.
@Hudell
Well, thank very much Hudell! I finally managed to complete the plugin and make it read the image information from the save file. I was forgeting to blt it, and Iavra helpped me to notice that haha.
@Roguedeus
I think you will want to download the last version of the script. Now it do not uses the game folders to save the map shots anymore, so you will not have the same problem again. And now you can personalize it to fit better to your game.
I completed this plugin.... Now I don't know if a moderator will close it or move it to the Release forum.
@Hudell
Well, thank very much Hudell! I finally managed to complete the plugin and make it read the image information from the save file. I was forgeting to blt it, and Iavra helpped me to notice that haha.
@Roguedeus
I think you will want to download the last version of the script. Now it do not uses the game folders to save the map shots anymore, so you will not have the same problem again. And now you can personalize it to fit better to your game.
You might want to change this line:
to this:
The reason being, that the WindowLayer can only display one thing at a given position, which leads to the cut out edges around the action window you can see in the screenshot. Adding the window directly as a child to the scene will allow it to be positioned above the other windows, without cutting out from them.
Code:
this.addWindow(this._actionWindow);
Code:
this.addChild(this._actionWindow);
Woa! Thanks, I didn't know this!
I changed the line and updated the plugin! ^^
I changed the line and updated the plugin! ^^
Outstanding work.
Is it possible to display the level of the character with the highest level ?
However, I noticed an incompatibility with Mog Weather EX 1.2
When I try to load a save game, after selecting the location, it tells me that message :
Here script :
pastebin
Is it possible to display the level of the character with the highest level ?
However, I noticed an incompatibility with Mog Weather EX 1.2
When I try to load a save game, after selecting the location, it tells me that message :
Here script :
pastebin
Great work!
Can I request a confirmation when deleting a save? 😉
edit:
Also. Is the several second lag between access the scene, and save/load actions, normal?
Can I request a confirmation when deleting a save? 😉
edit:
Also. Is the several second lag between access the scene, and save/load actions, normal?
UPDATE - New version avaliable
@Rito
You will have to delete your old saved games. 🙁
This will stop the errors from happening. New save game files will not cause the same issue.
Ah, and I forgot about the level thing. I'll do it, just wait haha.
@Roguedeus
I'll still do the confirmation thing for you, but the lag issues were corrected.
But it will still lag the more save files your game have. Cause everytime the game loads the info file to check what informations to show on the save screen, it will load everything inside of it, everytime you access the Scene_File, including its pictures (the reason why it lags)
Maybe the better way to avoid this prolbem, for now, is limiting the number of save files to a short quantity, so the info file don't get too heavy. :/
At least until I find a better solution. :/
@Rito
You will have to delete your old saved games. 🙁
This will stop the errors from happening. New save game files will not cause the same issue.
Ah, and I forgot about the level thing. I'll do it, just wait haha.
@Roguedeus
I'll still do the confirmation thing for you, but the lag issues were corrected.
But it will still lag the more save files your game have. Cause everytime the game loads the info file to check what informations to show on the save screen, it will load everything inside of it, everytime you access the Scene_File, including its pictures (the reason why it lags)
Maybe the better way to avoid this prolbem, for now, is limiting the number of save files to a short quantity, so the info file don't get too heavy. :/
At least until I find a better solution. :/
Nickel, impeccable works
Can you create a variable in your imported script please ?
I am trying to create an add-on to change the opacity of windows.
I would do a small screen what I'm traind e do.
I will add this feature to show myself.
Edit :
So much better without windows 🙂
Can you create a variable in your imported script please ?
I am trying to create an add-on to change the opacity of windows.
Code:
var Imported = Imported || {};
Imported.xxxxxxx = true;
I would do a small screen what I'm traind e do.
I will add this feature to show myself.
Edit :
So much better without windows 🙂
@Rito
I don't know how to do it, neither how it works. Would you help me explaining what do I have to do and what it does? >< (about this imported thing)
Cause I'm trying to do a snippet my self to add the confirmation windows that @roguedeus asked, but I'm failling in doing it. Seems like I will have to implement his windows in the core script. ):
Anyway... please, download this:
In this version you can show the party's higher level.
I'll release a new oficial version when I have done what @roguedeus asked me.
I don't know how to do it, neither how it works. Would you help me explaining what do I have to do and what it does? >< (about this imported thing)
Cause I'm trying to do a snippet my self to add the confirmation windows that @roguedeus asked, but I'm failling in doing it. Seems like I will have to implement his windows in the core script. ):
In this version you can show the party's higher level.
Just add this into your plugin (better at the beginning to find their best but not matter):
var Imported = Imported || {};Imported.ArkDG_SaveScreen = true;This allows other plugins to do such and such actions if "Imported.ArkDG_SaveScreen = true" (plugin = ON)
Screen ArkDG_Save being an example, you can name it whatever you want.
These two small lines allow me to do this in my plugin :
// ===========ArkDG=============// Opacity Save Engineif (Imported.ArkDG_SaveScreen){ var _alias_SceneFile_create = Scene_File.prototype.create; Scene_File.prototype.create = function() { _alias_SceneFile_create.call(this); this._statusWindow.opacity = 0; this._listWindow.opacity = 0; };}
This will make some fix if there are incompatibility with plugins for exemple.
var Imported = Imported || {};Imported.ArkDG_SaveScreen = true;This allows other plugins to do such and such actions if "Imported.ArkDG_SaveScreen = true" (plugin = ON)
Screen ArkDG_Save being an example, you can name it whatever you want.
These two small lines allow me to do this in my plugin :
// ===========ArkDG=============// Opacity Save Engineif (Imported.ArkDG_SaveScreen){ var _alias_SceneFile_create = Scene_File.prototype.create; Scene_File.prototype.create = function() { _alias_SceneFile_create.call(this); this._statusWindow.opacity = 0; this._listWindow.opacity = 0; };}
This will make some fix if there are incompatibility with plugins for exemple.
UPDATE - New version and a new addon avaliable!
Thanks again, Rito. You helpped me a lot. And your addon is really beautiful!
@Roguedeus
Hey man, download the last version of the original plugin and the addon I made for you from the first post. ^^
Good luck with your game!
Thanks again, Rito. You helpped me a lot. And your addon is really beautiful!
@Roguedeus
Hey man, download the last version of the original plugin and the addon I made for you from the first post. ^^
Good luck with your game!
Thanks ArkDG!
However, I must report a small issue. Right after adding the confirmation plugin, I tried to save a new game and got this error:
(Removing the new plugin, prevents the error)
However, I must report a small issue. Right after adding the confirmation plugin, I tried to save a new game and got this error:
(Removing the new plugin, prevents the error)
Code:
TypeError: Cannot read property 'refresh' of undefined at Scene_Save.Scene_File.commandSave (file:///X:/SkyDrive/_RMMV%20Projects/Projects/Prequel%20Project/js/plugins/Ark_SaveEngine_Confirmation.js:213:37) at Window_FileAction.Window_Selectable.callHandler (file:///X:/SkyDrive/_RMMV%20Projects/Projects/Prequel%20Project/js/rpg_windows.js:896:31) at Window_FileAction.Window_Command.callOkHandler (file:///X:/SkyDrive/_RMMV%20Projects/Projects/Prequel%20Project/js/rpg_windows.js:1420:14) at Window_FileAction.Window_Selectable.processOk (file:///X:/SkyDrive/_RMMV%20Projects/Projects/Prequel%20Project/js/rpg_windows.js:1150:14) at Window_FileAction.Window_Selectable.processHandling (file:///X:/SkyDrive/_RMMV%20Projects/Projects/Prequel%20Project/js/rpg_windows.js:1021:18) at Window_FileAction.Window_Selectable.update (file:///X:/SkyDrive/_RMMV%20Projects/Projects/Prequel%20Project/js/rpg_windows.js:978:10) at file:///X:/SkyDrive/_RMMV%20Projects/Projects/Prequel%20Project/js/rpg_scenes.js:112:19 at Array.forEach (native) at Scene_Save.Scene_Base.updateChildren (file:///X:/SkyDrive/_RMMV%20Projects/Projects/Prequel%20Project/js/rpg_scenes.js:110:19) at Scene_Save.Scene_Base.update (file:///X:/SkyDrive/_RMMV%20Projects/Projects/Prequel%20Project/js/rpg_scenes.js:42:10)
@roguedeus
Strange.... I'm a little asleep now, but I will look foward to it tomorow.
Had you updated the original plugin to the lastest version? (1.2)
Because if you haven't, there will be incompatibilitty problems. ><
PS.: I can't seem to reproduce this error.... very strange.
Please, update the Ark_SaveScreen.js plugin to the lastest version. (get it on the first post)
I reproduced the error here, and it only happens with old versions of the script.
Had you updated the original plugin to the lastest version? (1.2)
Because if you haven't, there will be incompatibilitty problems. ><
PS.: I can't seem to reproduce this error.... very strange.
Please, update the Ark_SaveScreen.js plugin to the lastest version. (get it on the first post)
I reproduced the error here, and it only happens with old versions of the script.
I had updated it earlier to 1.02 and saw your latest update 1.2 and didn't immediately notice the difference. Sorry!
Having said that though... I am still having some issues.
Now, the confirmation pops up and I confirm. However, it buzzes at me and does not save.
Also, you can try to delete an empty save and it will crash. 🙂
Code:
TypeError: Cannot read property 'level' of undefined/X:/SkyDrive/_RMMV%20Projects/Projects/Prequel%20Project/js/plugins/ArkDG_SaveScreen.js:402 Save data too big!rpg_managers.js:1620 TypeError: Cannot read property 'level' of undefined at Function.Scene_File.HigherLvl (/X:/SkyDrive/_RMMV%20Projects/Projects/Prequel%20Project/js/plugins/ArkDG_SaveScreen.js:418) at Function.DataManager.makeSavefileInfo (/X:/SkyDrive/_RMMV%20Projects/Projects/Prequel%20Project/js/plugins/ArkDG_SaveScreen.js:437) at Function.DataManager.eraseSaveData (/X:/SkyDrive/_RMMV%20Projects/Projects/Prequel%20Project/js/plugins/ArkDG_SaveScreen.js:405) at Scene_Save.Scene_File.commandConfirmation (/X:/SkyDrive/_RMMV%20Projects/Projects/Prequel%20Project/js/plugins/Ark_SaveEngine_Confirmation.js:186) at Window_ActionConfirm.Window_Selectable.callHandler (rpg_windows.js:896) at Window_ActionConfirm.Window_Command.callOkHandler (rpg_windows.js:1420) at Window_ActionConfirm.Window_Selectable.processOk (rpg_windows.js:1150) at Window_ActionConfirm.Window_Selectable.processHandling (rpg_windows.js:1021) at Window_ActionConfirm.Window_Selectable.update (rpg_windows.js:978) at rpg_scenes.js:112
Original thread: https://forums.rpgmakerweb.com/threads/arks-save-engine-complete.51475/