Skip to content

Commit

Permalink
Add custom chunks to EventExecState to store event state.
Browse files Browse the repository at this point in the history
Contrary to RPG_RT this does not require adding new fields everytime a new event is added that waits.
  • Loading branch information
Ghabry committed Jul 31, 2024
1 parent 41048d4 commit 861adca
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 2 deletions.
1 change: 1 addition & 0 deletions generator/csv/enums_easyrpg.csv
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ EventCommand,Code,EasyRpg_TriggerEventAt,2002
EventCommand,Code,EasyRpg_CallMovementAction,2050
EventCommand,Code,EasyRpg_WaitForSingleMovement,2051
EventCommand,Code,EasyRpg_AnimateVariable,2052
EventCommand,Code,EasyRpg_SpawnMapEvent,2056
EventCommand,Code,Maniac_GetSaveInfo,3001
EventCommand,Code,Maniac_Save,3002
EventCommand,Code,Maniac_Load,3003
Expand Down
3 changes: 3 additions & 0 deletions generator/csv/fields_easyrpg.csv
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ SaveEventExecFrame,maniac_event_id,f,Int32,0x0F,0,0,0,Event ID
SaveEventExecFrame,maniac_event_page_id,f,Int32,0x10,0,0,0,Page ID when it is a map event
SaveEventExecFrame,maniac_loop_info_size,f,Int32,0x11,0,0,0,Amount of loop info groups
SaveEventExecFrame,maniac_loop_info,f,Vector<Int32>,0x12,,0,0,"One group of (Current loop count, end loop value) for each identation"
SaveEventExecState,easyrpg_active,f,Boolean,0xC9,False,0,0,When true state of an event is preserved in easyrpg_string and easyrpg_parameters
SaveEventExecState,easyrpg_string,f,DBString,0xCA,,0,0,Preserved string data of an event
SaveEventExecState,easyrpg_parameters,f,Vector<Int32>,0xCB,,0,0,Preserved int parameter of an event
SavePicture,easyrpg_flip,f,Enum<EasyRpgFlip>,0xC8,0,0,1,How to flip the picture
SavePicture,easyrpg_blend_mode,f,Int32,0xC9,0,0,1,Blend mode to use for blit. See Bitmap::BlendMode
SavePicture,easyrpg_type,f,Enum<EasyRpgPictureType>,0xCA,0,0,1,Type of this picture
Expand Down
8 changes: 7 additions & 1 deletion src/generated/lcf/lsd/chunks.h
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,13 @@ namespace LSD_Reader {
/** */
keyinput_timed = 0x29,
/** Used for a wait command WaitForKeyInput rm2k3 feature to wait for decision key press. */
wait_key_enter = 0x2A
wait_key_enter = 0x2A,
/** When true state of an event is preserved in easyrpg_string and easyrpg_parameters */
easyrpg_active = 0xC9,
/** Preserved string data of an event */
easyrpg_string = 0xCA,
/** Preserved int parameter of an event */
easyrpg_parameters = 0xCB
};
};
struct ChunkSaveMapEventBase {
Expand Down
2 changes: 2 additions & 0 deletions src/generated/lcf/rpg/eventcommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ namespace rpg {
EasyRpg_CallMovementAction = 2050,
EasyRpg_WaitForSingleMovement = 2051,
EasyRpg_AnimateVariable = 2052,
EasyRpg_SpawnMapEvent = 2056,
Maniac_GetSaveInfo = 3001,
Maniac_Save = 3002,
Maniac_Load = 3003,
Expand Down Expand Up @@ -321,6 +322,7 @@ namespace rpg {
Code::EasyRpg_CallMovementAction, "EasyRpg_CallMovementAction",
Code::EasyRpg_WaitForSingleMovement, "EasyRpg_WaitForSingleMovement",
Code::EasyRpg_AnimateVariable, "EasyRpg_AnimateVariable",
Code::EasyRpg_SpawnMapEvent, "EasyRpg_SpawnMapEvent",
Code::Maniac_GetSaveInfo, "Maniac_GetSaveInfo",
Code::Maniac_Save, "Maniac_Save",
Code::Maniac_Load, "Maniac_Load",
Expand Down
11 changes: 10 additions & 1 deletion src/generated/lcf/rpg/saveeventexecstate.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// Headers
#include <stdint.h>
#include <vector>
#include "lcf/dbstring.h"
#include "lcf/rpg/saveeventexecframe.h"
#include "lcf/context.h"
#include <ostream>
Expand Down Expand Up @@ -49,6 +50,9 @@ namespace rpg {
int32_t keyinput_2k3up = 0;
bool keyinput_timed = false;
bool wait_key_enter = false;
bool easyrpg_active = false;
DBString easyrpg_string;
std::vector<int32_t> easyrpg_parameters;
};

inline bool operator==(const SaveEventExecState& l, const SaveEventExecState& r) {
Expand All @@ -73,7 +77,10 @@ namespace rpg {
&& l.keyinput_2k3right == r.keyinput_2k3right
&& l.keyinput_2k3up == r.keyinput_2k3up
&& l.keyinput_timed == r.keyinput_timed
&& l.wait_key_enter == r.wait_key_enter;
&& l.wait_key_enter == r.wait_key_enter
&& l.easyrpg_active == r.easyrpg_active
&& l.easyrpg_string == r.easyrpg_string
&& l.easyrpg_parameters == r.easyrpg_parameters;
}

inline bool operator!=(const SaveEventExecState& l, const SaveEventExecState& r) {
Expand All @@ -88,6 +95,8 @@ namespace rpg {
const auto ctx1 = Context<SaveEventExecState, ParentCtx>{ "stack", i, &obj, parent_ctx };
ForEachString(obj.stack[i], f, &ctx1);
}
const auto ctx24 = Context<SaveEventExecState, ParentCtx>{ "easyrpg_string", -1, &obj, parent_ctx };
f(obj.easyrpg_string, ctx24);
(void)obj;
(void)f;
(void)parent_ctx;
Expand Down
24 changes: 24 additions & 0 deletions src/generated/lsd_saveeventexecstate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,27 @@ static TypedField<rpg::SaveEventExecState, bool> static_wait_key_enter(
0,
0
);
static TypedField<rpg::SaveEventExecState, bool> static_easyrpg_active(
&rpg::SaveEventExecState::easyrpg_active,
LSD_Reader::ChunkSaveEventExecState::easyrpg_active,
"easyrpg_active",
0,
0
);
static TypedField<rpg::SaveEventExecState, DBString> static_easyrpg_string(
&rpg::SaveEventExecState::easyrpg_string,
LSD_Reader::ChunkSaveEventExecState::easyrpg_string,
"easyrpg_string",
0,
0
);
static TypedField<rpg::SaveEventExecState, std::vector<int32_t>> static_easyrpg_parameters(
&rpg::SaveEventExecState::easyrpg_parameters,
LSD_Reader::ChunkSaveEventExecState::easyrpg_parameters,
"easyrpg_parameters",
0,
0
);


template <>
Expand All @@ -200,6 +221,9 @@ Field<rpg::SaveEventExecState> const* Struct<rpg::SaveEventExecState>::fields[]
&static_keyinput_2k3up,
&static_keyinput_timed,
&static_wait_key_enter,
&static_easyrpg_active,
&static_easyrpg_string,
&static_easyrpg_parameters,
NULL
};

Expand Down
7 changes: 7 additions & 0 deletions src/generated/rpg_saveeventexecstate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ std::ostream& operator<<(std::ostream& os, const SaveEventExecState& obj) {
os << ", keyinput_2k3up="<< obj.keyinput_2k3up;
os << ", keyinput_timed="<< obj.keyinput_timed;
os << ", wait_key_enter="<< obj.wait_key_enter;
os << ", easyrpg_active="<< obj.easyrpg_active;
os << ", easyrpg_string="<< obj.easyrpg_string;
os << ", easyrpg_parameters=";
for (size_t i = 0; i < obj.easyrpg_parameters.size(); ++i) {
os << (i == 0 ? "[" : ", ") << obj.easyrpg_parameters[i];
}
os << "]";
os << "}";
return os;
}
Expand Down

0 comments on commit 861adca

Please sign in to comment.