+++ DYNRPG - THE RM2K3 PLUGIN SDK +++
Posts
Figured it out. This is the code I used:
Then in RPG Maker, I made a common event set to Auto Start, triggers when 4026 is turned on, erases picture 333, and turns off switch 4026. This basically displays that picture in the exact second between when the menu closes, and when the evented System & Save menus opens.
To explain this visually ...
Imagine you open the menu, and select "System" which, with a separate plugin I made, turns on a switch that loads the system menu via common events. Normally, you'd see this:



The middle image is what I'm talking about. You see the map for a split second inbetween menus. Since "ej-menus_bgcolor.png" is a solid dark gray, with the plugin code above, you get:



...Which looks way more natural. You wouldn't even give it a second thought if you saw it.
Edit: Also, for the record, RPG::switches line had to be put in the onPictureDrawn function, otherwise it wouldn't work.
#define AUTO_DLLMAIN
#include <DynRPG/DynRPG.h>
using namespace RPG;
bool onSystemBackgroundDrawn(RECT *rect) {
std::string filepath = "Picture\\ej-menus_bgcolor.png";
RPG::pictures[333]->show(filepath,160,120,false,100,0,0,true,100,100,100,100,RPG::PFX_NONE,0);
return true;
}
bool onPictureDrawn (RPG::Picture *picture) {
if (picture->id == 333) {
RPG::switches[4026] = true; // Turns on Switch 4026 when picture 333 is drawn
}
return true;
}
Then in RPG Maker, I made a common event set to Auto Start, triggers when 4026 is turned on, erases picture 333, and turns off switch 4026. This basically displays that picture in the exact second between when the menu closes, and when the evented System & Save menus opens.
To explain this visually ...
Imagine you open the menu, and select "System" which, with a separate plugin I made, turns on a switch that loads the system menu via common events. Normally, you'd see this:



The middle image is what I'm talking about. You see the map for a split second inbetween menus. Since "ej-menus_bgcolor.png" is a solid dark gray, with the plugin code above, you get:



...Which looks way more natural. You wouldn't even give it a second thought if you saw it.
Edit: Also, for the record, RPG::switches line had to be put in the onPictureDrawn function, otherwise it wouldn't work.
Oh, THAT'S what you want (I thought you want to replace the black menu background with an image)...
Sorry.
Still, what you are doing might be not the optimal way. There is a better way, but currently it needs a hack because the FieldScene class isn't implemented in the SDK yet.
This gives you the fieldScene object (not with all members yet, but we only need "initialized" here).
Then you use:
...where 1234 is the switch which is used for the "end" menu item. fieldScene->initialized = true will in this case prevent the map from doing a "fade in" effect. So what's going to happen is: The menu fades out, but the map doesn't fade in. You can then show the menu from a common event and call "<> Show Screen: Fade In" afterwards.
In case this doesn't work, you would have to remove the "scene == RPG::SCENE_MENU &&" part, but then please turn off the switch (1234 in this example) as soon as possible.
(No pictures involved now.)
Sorry.
Still, what you are doing might be not the optimal way. There is a better way, but currently it needs a hack because the FieldScene class isn't implemented in the SDK yet.
class FieldScene {
public:
void **vTable;
int _unknown_4;
bool initialized;
bool teleport;
int mapId;
int x;
int y;
// There are more members but I haven't analyzed them yet
}
static FieldScene *&fieldScene = (**reinterpret_cast<FieldScene ***>(0x4CDC1C));This gives you the fieldScene object (not with all members yet, but we only need "initialized" here).
Then you use:
void onFrame(RPG::Scene scene) {
if(scene == RPG::SCENE_MENU && RPG::switches[1234] == true) {
fieldScene->initialized = true;
}
}
...where 1234 is the switch which is used for the "end" menu item. fieldScene->initialized = true will in this case prevent the map from doing a "fade in" effect. So what's going to happen is: The menu fades out, but the map doesn't fade in. You can then show the menu from a common event and call "<> Show Screen: Fade In" afterwards.
In case this doesn't work, you would have to remove the "scene == RPG::SCENE_MENU &&" part, but then please turn off the switch (1234 in this example) as soon as possible.
(No pictures involved now.)
Yeah, I wasn't sure at the time what would get the right effect to be honest.
I tried the FieldScene code, but I'm getting some errors:
FieldScene.h (also defined in DynRPG.h)
menu_tweaks.cpp
Not sure what "fieldScene" needs to be declared as, but I'm getting "base operand of '->' is not a pointer" and "error: 'fieldScene' was not declared in this scope" obviously if it's not declared as anything.
I tried the FieldScene code, but I'm getting some errors:
FieldScene.h (also defined in DynRPG.h)
menu_tweaks.cpp
Not sure what "fieldScene" needs to be declared as, but I'm getting "base operand of '->' is not a pointer" and "error: 'fieldScene' was not declared in this scope" obviously if it's not declared as anything.
Well, you were not supposed to put FieldScene into namespace "RPG", and "int fieldScene" is wrong because it's already declared as a "static FieldScene *&" (not an "int"). "using namespace RPG" is also not recommended, because the "RPG" namespace should seperate DynRPG functions from your own (and thus, the incomplete "FieldScene" class shouldn't be put into the "RPG" namespace because later it might be implemented in DynRPG too, and then it would be in conflict).
Just put both codes together into your CPP file, or use a FieldScene.h but without "namespace RPG". And remove the second declaration as "int".
Just put both codes together into your CPP file, or use a FieldScene.h but without "namespace RPG". And remove the second declaration as "int".
Just did that and am still getting two errors:
error: expected initializer before '*' token
In function 'void onFrame(RPG::Scene)':
error: 'fieldScene' was not declared in this scope
error: expected initializer before '*' token
In function 'void onFrame(RPG::Scene)':
error: 'fieldScene' was not declared in this scope
It compiled this time, but it doesn't work. :( I tried removing "scene = RPG::SCENE_MENU &&" as well, but still nothing.
So basically what I should be seeing is that when I hit "End Game" (or "System" as the string is defined), it should just fade out completely until I run a fade in command?
So basically what I should be seeing is that when I hit "End Game" (or "System" as the string is defined), it should just fade out completely until I run a fade in command?
@All: The code I gave PepsiOtaku (to turn a switch on when "End game" was selected) was:
====
I modified the code so it directly does the "fieldScene->initalized = true" from inside the patch:
This should give the desired result.
static int patch[] = {
0x4CDC7CA1, 0xBA008B00,
1234, // Switch ID
0x04C701B1, 0x4A274024, 0xB33C6800, 0x90C30048
};
memcpy(reinterpret_cast<void *>(0x4A2328), patch, sizeof(patch));====
I modified the code so it directly does the "fieldScene->initalized = true" from inside the patch:
static int patch[] = {
0x4CDC1CA1, 0xC6008B00, 0x90010C40, 0x4CDC7CA1, 0xBA008B00,
1234, // Switch ID
0x04C701B1, 0x4A274024, 0xB33C6800, 0x90C30048
};
memcpy(reinterpret_cast<void *>(0x4A2328), patch, sizeof(patch));This should give the desired result.
Very cool! Works perfectly. Here's an all-in-one plugin variation:
Just compile as "quit_switch.dll" and add this to DynRPG.ini:
You're going to hate me for asking this question though:
How can I use that same effect for the Save menu, which uses your CustomSaveLoad patch along with switch 4008?
Also, I have a custom party menu built that would be cool to use with the "Party" menu option too. Could I get the patch code for that as well? That should be all I have left to customize outside of adding a "time played" counter.
#define AUTO_DLLMAIN
#include <DynRPG/DynRPG.h>
int quitSwitchValue;
bool onStartup(char *pluginName) {
// Load configuration on startup
std::map<std::string, std::string> configuration = RPG::loadConfiguration(pluginName);
quitSwitchValue = atoi(configuration["QuitSwitch"].c_str()); // atoi is the easiest way here to get an integer
static int patch[] = {
0x4CDC1CA1, 0xC6008B00, 0x90010C40, 0x4CDC7CA1, 0xBA008B00,
quitSwitchValue, // Switch ID
0x04C701B1, 0x4A274024, 0xB33C6800, 0x90C30048
};
memcpy(reinterpret_cast<void *>(0x4A2328), patch, sizeof(patch));
return true;
}
Just compile as "quit_switch.dll" and add this to DynRPG.ini:
[quit_switch]
QuitSwitch=4025
You're going to hate me for asking this question though:
How can I use that same effect for the Save menu, which uses your CustomSaveLoad patch along with switch 4008?
Also, I have a custom party menu built that would be cool to use with the "Party" menu option too. Could I get the patch code for that as well? That should be all I have left to customize outside of adding a "time played" counter.
Well, you don't need the whole fieldScene thing here, because it's already part of the path.
Also:
...why do you use a stringstream at all? Better:
Save menu: We can apply another patch there:
Party menu:
(It's the same patch as for the end menu, just the address in the memcpy line changed and you can put another switch ID).
Also:
std::map<std::string, std::string> configuration = RPG::loadConfiguration(pluginName);
std::stringstream keyName;
keyName << "QuitSwitch";
quitSwitchValue = atoi(configuration[keyName.str()].c_str()); // atoi is the easiest way here to get an integer
std::map<std::string, std::string> configuration = RPG::loadConfiguration(pluginName);
quitSwitchValue = atoi(configuration["QuitSwitch"].c_str());
Save menu: We can apply another patch there:
*reinterpret_cast<unsigned int *>(0x4A2621) = 0x4CDC1C;
*reinterpret_cast<unsigned char *>(0x4A2629) = 0xC;
Party menu:
static int patch2[] = {
0x4CDC1CA1, 0xC6008B00, 0x90010C40, 0x4CDC7CA1, 0xBA008B00,
1234, // Switch ID
0x04C701B1, 0x4A274024, 0xB33C6800, 0x90C30048
};
memcpy(reinterpret_cast<void *>(0x4A23BC), patch2, sizeof(patch2));Fixed. I'm getting a crash ingame when I try to run the Save menu patch/plugin though. Should this not be onStartup?
It's saying "Access violation in module 'RPG_RT.exe' in with address 004A2624 and offset 0CDE1F62 of type Write occurred" when I select Save.
#define AUTO_DLLMAIN
#include <DynRPG/DynRPG.h>
bool onStartup(char *pluginName) {
*reinterpret_cast<unsigned int *>(0x4A2621) = 0x4CDC1C;
*reinterpret_cast<unsigned char *>(0x4A2629) = 0xC;
return true;
}
It's saying "Access violation in module 'RPG_RT.exe' in with address 004A2624 and offset 0CDE1F62 of type Write occurred" when I select Save.
Yes, sorry, I made a mistake there. A more complicated patch is needed:
(instead of the one you used in your last message)
static unsigned char patchSave1[] = {0x50, 0x8B, 0x35, 0x1C, 0xDC, 0x4C};
static unsigned char patchSave2[] = {0x58, 0x8B, 0x36, 0xC6, 0x46, 0x0C, 0x01};
memcpy(reinterpret_cast<void *>(0x4A25E9), patchSave1, sizeof(patchSave1));
memcpy(reinterpret_cast<void *>(0x4A25F7), patchSave2, sizeof(patchSave2));
(instead of the one you used in your last message)
author=PepsiOtaku
Imagine you open the menu, and select "System" which, with a separate plugin I made, turns on a switch that loads the system menu via common events. Normally, you'd see this.
What was the separate plugin for system options? And, does the original keep the current System Graphic, or is it set up for the green background and blue text?
(I have four custom system graphics, since there's a menu for it)
Does this change with the color scheme, or does it assume the one you've got?
@bulma: It's just this:
http://rpgmaker.net/forums/topics/10254/?post=444597#post444597
Compile that & add the config in DynRPG.ini & set your switch ID. Mine was "4025"
Go to the database, String tab, Page 5, and under "Commands," change "Quit" to "System".
Now go to Common Events, click on a blank common event, set the trigger to Auto Start, Trigger Switch to the one you defined in DynRPG.ini, and add the following:
Boot up the game, open the menu, and select "System" and you'll see the Hello World message. It's up to you to event the menu from there.
@Cherry: Still getting an access violation error for address 004A2624 and offset 0CDE1F62
http://rpgmaker.net/forums/topics/10254/?post=444597#post444597
Compile that & add the config in DynRPG.ini & set your switch ID. Mine was "4025"
Go to the database, String tab, Page 5, and under "Commands," change "Quit" to "System".
Now go to Common Events, click on a blank common event, set the trigger to Auto Start, Trigger Switch to the one you defined in DynRPG.ini, and add the following:
Show Screen: Instant
Message: Hello world!
Hide Screen: Instantaneous
Switch Operation: [Your Switch ID] OFF
Open Main Menu
@Cherry: Still getting an access violation error for address 004A2624 and offset 0CDE1F62
@PepsiOtaku:
...so don't forget to remove this:
author=Cherry
(instead of the one you used in your last message)
...so don't forget to remove this:
*reinterpret_cast<unsigned int *>(0x4A2621) = 0x4CDC1C;
*reinterpret_cast<unsigned char *>(0x4A2629) = 0xC;
I did. Not sure what I did differently this time, but I recompiled it and it worked. Hmm...
Thanks for all of your help!
Thanks for all of your help!
I'm gonna call this system_menu instead of quit_switch. Just for personally remembering it. I'm gonna try a few things. Doesn't look at all like yours, but I assume this is the work of yet another plugin. The point being that it does work and display in my current color and text type...
The hide screen turned out to be unnecessary, and I converted it to simple choice options (which I did System Graphics Change (choose one of the colors and fonts available), Debug Mode (Lets you alter variables and switches. It's system-protected that you have to add Admin to KazString's dynstore.txt, since Debug Mode has the potential to screw up the game in a major way if you don't know what you're doing), and Quit (Return to Title Screen). Cancel has an event handler, and I moved Open Menu there). It's sort of noob looking, but it does a few interesting things.
The hide screen turned out to be unnecessary, and I converted it to simple choice options (which I did System Graphics Change (choose one of the colors and fonts available), Debug Mode (Lets you alter variables and switches. It's system-protected that you have to add Admin to KazString's dynstore.txt, since Debug Mode has the potential to screw up the game in a major way if you don't know what you're doing), and Quit (Return to Title Screen). Cancel has an event handler, and I moved Open Menu there). It's sort of noob looking, but it does a few interesting things.
@bulma, it is actually necessary when you have a ton of pictures loaded, that you have to erase and then transition cleanly back to the main menu. Otherwise, you'll get that same scenario I posted at the top of the page, except in reverse.
Well, I wasn't using a picture in this case. It just brought up basic text, and I made it into a choice menu. In my case, since I wanted to transfer to alot of places, it instead caused a blackout. The show screen did seem to be necessary, however, since it wouldn't show the screen without it. Well, without pushing the action button and going to the next thing.
So it's transitions and not teleports that have been doing my picture erase? ...Doesn't seem that way. I guess what you've saying is that it's needed to keep the pictures from showing graphically, while all this transition is going on.
I'm having this same problem with PicsInBattle carrying over pictures, so I ended up employing a picture flush common event. I wonder if there's a way in DynRPG to build in those transitions so you don't have to do that?
So it's transitions and not teleports that have been doing my picture erase? ...Doesn't seem that way. I guess what you've saying is that it's needed to keep the pictures from showing graphically, while all this transition is going on.
I'm having this same problem with PicsInBattle carrying over pictures, so I ended up employing a picture flush common event. I wonder if there's a way in DynRPG to build in those transitions so you don't have to do that?
Yeah, there's some tweaks you would have to do to work around that. You only want to use "Hide Screen" right before "Open Main Menu." Otherwise, you're just hiding the screen, and need to "show" it again. With that plugin, the main menu has "Show Screen" built into it, so the extra step isn't needed.
Here's the culmination of those plugins/patches!
http://rpgmaker.net/games/20/media/857/
The menus are pretty finalized at this point. I forgot to add a loading bar for the "Delete" save function though. It'll be the same as the others, but with a red bar.
Here's the culmination of those plugins/patches!
http://rpgmaker.net/games/20/media/857/
The menus are pretty finalized at this point. I forgot to add a loading bar for the "Delete" save function though. It'll be the same as the others, but with a red bar.




















