summaryrefslogtreecommitdiffstats
path: root/src/extras/frontendoption.h
diff options
context:
space:
mode:
authoreray orçunus <erayorcunus@gmail.com>2020-08-24 21:42:26 +0200
committereray orçunus <erayorcunus@gmail.com>2020-08-24 23:55:57 +0200
commit082c4caecfb542e93f5a9a942e51b555e0035279 (patch)
tree1b10202b6f99dd002b00df1973a0b4c6965a0150 /src/extras/frontendoption.h
parentMerge branch 'master' of https://github.com/GTAmodding/re3 into erorcun (diff)
downloadre3-082c4caecfb542e93f5a9a942e51b555e0035279.tar
re3-082c4caecfb542e93f5a9a942e51b555e0035279.tar.gz
re3-082c4caecfb542e93f5a9a942e51b555e0035279.tar.bz2
re3-082c4caecfb542e93f5a9a942e51b555e0035279.tar.lz
re3-082c4caecfb542e93f5a9a942e51b555e0035279.tar.xz
re3-082c4caecfb542e93f5a9a942e51b555e0035279.tar.zst
re3-082c4caecfb542e93f5a9a942e51b555e0035279.zip
Diffstat (limited to 'src/extras/frontendoption.h')
-rw-r--r--src/extras/frontendoption.h121
1 files changed, 98 insertions, 23 deletions
diff --git a/src/extras/frontendoption.h b/src/extras/frontendoption.h
index 7cfc09a7..9608870b 100644
--- a/src/extras/frontendoption.h
+++ b/src/extras/frontendoption.h
@@ -4,48 +4,102 @@
#ifdef CUSTOM_FRONTEND_OPTIONS
#include "Frontend.h"
-// Warning: All of the code relies on that you won't use more then NUM_MENUROWS(18) options on one page. Also congrats if you can make 18 options visible at once.
+// Warning:
+// All of the code relies on that you won't use more then NUM_MENUROWS(18) options on one page.
+// Also congrats if you can make 18 options visible at once.
+// About texts:
+// All text parameters accept wchar(including hardcoded wchar* and TheText.Get)
+// except FrontendScreenAdd(it's char[8] by the design of Frontend).
+// All texts reload if custom options reloaded too, which includes language changes and via live reload feature in debug menu!
-// Static/select: User allocates variable, passes it to function and it's set automatically from input among the strings given to function,
-// then you can handle ChangeFunc and ReturnPrevPageFunc if needed.
+// Execute direction:
+// All of the calls below eventually manipulate the aScreens array, so keep in mind to add/replace options in order,
+// i.e. don't set cursor to 8 first and then 3.
+
+// Live reload:
+// You can add/change/undo the new options in-game if you use VS. Change what you want, build the changed bits via "Edit and Continue",
+// and hit the "Reload custom frontend options" from debug menu. Or call CustomFrontendOptionsPopulate() from somewhere else.
+
+
+// -- Option types
+//
+// Static/select: You allocate the variable, pass it to function and game sets it from user input among the strings given to function,
+// then you can handle ChangeFunc(only called on enter if onlyApplyOnEnter set, or set immediately)
+// and ReturnPrevPageFunc optionally. You can store the option in gta3.set if you pass true to corresponding parameter.
+//
+// Dynamic: Passing variable to function is only needed if you want to store it, otherwise you should do
+// all the operations with ButtonPressFunc, this includes allocating the variable.
+// Left-side text is passed while creating and static, but ofc right-side text is dynamic -
+// you should return it in DrawFunc, which is called on every draw. ReturnPrevPageFunc is also here if needed.
//
-// Dynamic: Function doesn't accept value pointer, user should do operations with handling ButtonPressFunc.
-// Right-side text can be set via DrawFunc, which is called on every draw. ReturnPrevPageFunc is also here if needed.
+// Redirect: Redirection to another screen. selectedOption parameter is the highlighted option user will see after the redirection.
+//
+// Built-in action: As the name suggests, any action that game has built-in. But as an extra you can set the option text,
+// and can be informed on button press/focus loss via buttonPressFunc. ReturnPrevPageFunc is also here.
#define FEOPTION_SELECT 0
#define FEOPTION_DYNAMIC 1
#define FEOPTION_REDIRECT 2
#define FEOPTION_GOBACK 3
+#define FEOPTION_BUILTIN_ACTION 4
+// -- Returned via ButtonPressFunc() action param.
#define FEOPTION_ACTION_LEFT 0
#define FEOPTION_ACTION_RIGHT 1
#define FEOPTION_ACTION_SELECT 2
#define FEOPTION_ACTION_FOCUSLOSS 3
-void RemoveCustomFrontendOptions();
-void CustomFrontendOptionsPopulate();
+// -- Passed via FrontendScreenAdd()
+#define FESCREEN_CENTER 0
+#define FESCREEN_LEFT_ALIGN 1
+#define FESCREEN_RIGHT_ALIGN 2
-// for static and dynamic options
+// -- Callbacks
+
+// pretty much in everything I guess, and optional in all of them
typedef void (*ReturnPrevPageFunc)();
// for static options
-typedef void (*ChangeFunc)(int8 displayedValue); // called before updating the value
+typedef void (*ChangeFunc)(int8 displayedValue); // called before updating the value.
+ // only called on enter if onlyApplyOnEnter set, otherwise called on every value change
// for dynamic options
-typedef wchar* (*DrawFunc)(bool* disabled); // should return pointer to right text. *disabled = true will make it dark yellow
+typedef wchar* (*DrawFunc)(bool* disabled, bool userHovering); // you must return a pointer for right text.
+ // you can also set *disabled if you want to gray it out.
typedef void (*ButtonPressFunc)(int8 action); // see FEOPTION_ACTIONs above
+struct FrontendScreen
+{
+ int id;
+ char name[8];
+ eMenuSprites sprite;
+ int prevPage;
+ int columnWidth;
+ int headerHeight;
+ int lineHeight;
+ int8 font;
+ float fontScaleX;
+ float fontScaleY;
+ int8 alignment;
+ bool showLeftRightHelper;
+ ReturnPrevPageFunc returnPrevPageFunc;
+};
+
struct FrontendOption
{
int8 type;
int8 screenOptionOrder;
- eMenuScreen screen;
- const wchar* leftText;
+ int32 screen;
+ wchar leftText[64];
ReturnPrevPageFunc returnPrevPageFunc;
+ int8* value;
+ int8 displayedValue; // only if onlyApplyOnEnter enabled for now
+ bool save;
+ int32 ogOptionId; // for replacements, see overwrite parameter of SetCursor
union {
- // Only for dynamic
+ // Only for dynamic / built-in action
struct {
DrawFunc drawFunc;
ButtonPressFunc buttonPressFunc;
@@ -55,33 +109,54 @@ struct FrontendOption
struct {
const wchar** rightTexts;
int8 numRightTexts;
- int8 *value;
- int8 displayedValue; // if onlyApplyOnEnter enabled
bool onlyApplyOnEnter;
ChangeFunc changeFunc;
+ int8 lastSavedValue; // only if onlyApplyOnEnter enabled
};
// Only for redirect
struct {
- eMenuScreen to;
+ int to;
int8 option;
bool fadeIn;
};
};
};
+// -- Internal things
+void RemoveCustomFrontendOptions();
+void CustomFrontendOptionsPopulate();
+
+extern int lastOgScreen; // for reloading
+
extern int numCustomFrontendOptions;
extern FrontendOption* customFrontendOptions;
-// To be used in ButtonPressFunc / ChangeFunc(but that would be weird):
-void ChangeScreen(eMenuScreen screen, int option = 0, bool fadeIn = true);
+extern int numCustomFrontendScreens;
+extern FrontendScreen* customFrontendScreens;
+
+// -- To be used in ButtonPressFunc / ChangeFunc(this one would be weird):
+void ChangeScreen(int screen, int option = 0, bool fadeIn = true);
void GoBack(bool fadeIn = true);
-// If option is positive number, all calls will increase it before using it (you can think it as cursor). -1 means before the back button, -2 is end of page
-void FrontendOptionSetPosition(eMenuScreen screen, int8 option = -1);
+uint8 GetNumberOfMenuOptions(int screen);
-void FrontendOptionAddSelect(const wchar* leftText, const wchar** rightTexts, int8 numRightTexts, int8 *var, bool onlyApplyOnEnter, ChangeFunc changeFunc, ReturnPrevPageFunc returnPrevPageFunc);
-void FrontendOptionAddDynamic(const wchar* leftText, DrawFunc rightTextDrawFunc, ButtonPressFunc buttonPressFunc, ReturnPrevPageFunc returnPrevPageFunc);
-void FrontendOptionAddRedirect(const wchar* text, eMenuScreen to, int8 selectedOption = 0, bool fadeIn = true);
+// -- Placing the cursor to append/overwrite option
+//
+// Done via FrontendOptionSetCursor(screen, position, overwrite = false), parameters explained below:
+// Screen: as the name suggests. Also accepts the screen IDs returned from FrontendScreenAdd.
+// Option: if positive, next AddOption call will put the option to there and progress the cursor.
+// if negative, cursor will be placed on bottom-(pos+1), so -1 means the very bottom, -2 means before the back button etc.
+// Overwrite: Use to overwrite the options, not appending a new one. AddOption calls will still progress the cursor.
+
+void FrontendOptionSetCursor(int screen, int8 option, bool overwrite = false);
+
+// var is optional in AddDynamic, you can enable save parameter if you pass one, otherwise pass nil/0
+void FrontendOptionAddBuiltinAction(const wchar* leftText, int action, ButtonPressFunc buttonPressFunc, ReturnPrevPageFunc returnPrevPageFunc);
+void FrontendOptionAddSelect(const wchar* leftText, const wchar** rightTexts, int8 numRightTexts, int8 *var, bool onlyApplyOnEnter, ChangeFunc changeFunc, ReturnPrevPageFunc returnPrevPageFunc, bool save = false);
+void FrontendOptionAddDynamic(const wchar* leftText, DrawFunc rightTextDrawFunc, int8 *var, ButtonPressFunc buttonPressFunc, ReturnPrevPageFunc returnPrevPageFunc, bool save = false);
+void FrontendOptionAddRedirect(const wchar* text, int to, int8 selectedOption = 0, bool fadeIn = true);
void FrontendOptionAddBackButton(const wchar* text, bool fadeIn = true);
+
+uint8 FrontendScreenAdd(char* gxtKey, eMenuSprites sprite, int prevPage, int columnWidth, int headerHeight, int lineHeight, int8 font, float fontScaleX, float fontScaleY, int8 alignment, bool showLeftRightHelper, ReturnPrevPageFunc returnPrevPageFunc = nil);
#endif \ No newline at end of file