rewrite CFO + postfx/pipeline options
This commit is contained in:
@@ -2,47 +2,23 @@
|
||||
#include "common.h"
|
||||
|
||||
#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.
|
||||
|
||||
// About texts:
|
||||
// All text parameters accept wchar(including hardcoded wchar* and TheText.Get)
|
||||
// except FrontendScreenAdd(it's char[8] GXT key 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!
|
||||
|
||||
// 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.
|
||||
|
||||
// ! There are 2 ways to use CFO,
|
||||
// 1st; by adding a new option to the array in MenuScreensCustom.cpp and passing attributes/CBs to it
|
||||
// 2nd; by calling the functions listed at the bottom of this file.
|
||||
|
||||
// -- 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 an INI file if you pass the key(as a char array) to corresponding parameter.
|
||||
// optionally you can add post-change event via ChangeFunc(only called on enter if onlyApplyOnEnter set, or set immediately)
|
||||
// You can store the option in an INI file if you pass the key(as a char array) 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.
|
||||
//
|
||||
// Redirect: Redirection to another screen. selectedOption parameter is the highlighted option user will see after the redirection.
|
||||
// you should return it in DrawFunc, which is called on every draw.
|
||||
//
|
||||
// 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
|
||||
@@ -61,7 +37,7 @@
|
||||
typedef void (*ReturnPrevPageFunc)();
|
||||
|
||||
// for static options
|
||||
typedef void (*ChangeFunc)(int8 displayedValue); // called before updating the value.
|
||||
typedef void (*ChangeFunc)(int8 before, int8 after); // called after updating the value.
|
||||
// only called on enter if onlyApplyOnEnter set, otherwise called on every value change
|
||||
|
||||
// for dynamic options
|
||||
@@ -69,71 +45,11 @@ typedef wchar* (*DrawFunc)(bool* disabled, bool userHovering); // you must retur
|
||||
// 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;
|
||||
int32 screen;
|
||||
wchar leftText[128];
|
||||
ReturnPrevPageFunc returnPrevPageFunc;
|
||||
int8* value;
|
||||
int8 displayedValue; // only if onlyApplyOnEnter enabled for now
|
||||
const char* save;
|
||||
int32 ogOptionId; // for replacements, see overwrite parameter of SetCursor
|
||||
|
||||
union {
|
||||
// Only for dynamic / built-in action
|
||||
struct {
|
||||
DrawFunc drawFunc;
|
||||
ButtonPressFunc buttonPressFunc;
|
||||
};
|
||||
|
||||
// Only for static/select
|
||||
struct {
|
||||
wchar** rightTexts;
|
||||
int8 numRightTexts;
|
||||
bool onlyApplyOnEnter;
|
||||
ChangeFunc changeFunc;
|
||||
int8 lastSavedValue; // only if onlyApplyOnEnter enabled
|
||||
};
|
||||
|
||||
// Only for redirect
|
||||
struct {
|
||||
int to;
|
||||
int8 option;
|
||||
bool fadeIn;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
// -- Internal things
|
||||
void RemoveCustomFrontendOptions();
|
||||
void CustomFrontendOptionsPopulate();
|
||||
|
||||
extern int lastOgScreen; // for reloading
|
||||
|
||||
extern int numCustomFrontendOptions;
|
||||
extern FrontendOption* customFrontendOptions;
|
||||
|
||||
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);
|
||||
@@ -141,6 +57,21 @@ void GoBack(bool fadeIn = true);
|
||||
|
||||
uint8 GetNumberOfMenuOptions(int screen);
|
||||
|
||||
// !!! We're now moved to MenuScreensCustom.cpp, which houses an array that keeps all original+custom options.
|
||||
// But you can still use the APIs below, and manipulate aScreens while in game.
|
||||
|
||||
// Limits:
|
||||
// The code relies on that you won't use more then NUM_MENUROWS(18) options on one page, and won't exceed the MENUPAGES of pages.
|
||||
// Also congrats if you can make 18 options visible at once.
|
||||
|
||||
// Texts:
|
||||
// All text parameters accept char[8] GXT key.
|
||||
|
||||
// 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.
|
||||
|
||||
|
||||
// -- Placing the cursor to append/overwrite option
|
||||
//
|
||||
// Done via FrontendOptionSetCursor(screen, position, overwrite = false), parameters explained below:
|
||||
@@ -152,11 +83,9 @@ uint8 GetNumberOfMenuOptions(int screen);
|
||||
void FrontendOptionSetCursor(int screen, int8 option, bool overwrite = false);
|
||||
|
||||
// var is optional in AddDynamic, enables you to save them in an INI file(also needs passing char array to saveName param. obv), 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, const char* saveName = nil);
|
||||
void FrontendOptionAddDynamic(const wchar* leftText, DrawFunc rightTextDrawFunc, int8 *var, ButtonPressFunc buttonPressFunc, ReturnPrevPageFunc returnPrevPageFunc, const char* saveName = nil);
|
||||
void FrontendOptionAddRedirect(const wchar* text, int to, int8 selectedOption = 0, bool fadeIn = true);
|
||||
void FrontendOptionAddBackButton(const wchar* text, bool fadeIn = true);
|
||||
void FrontendOptionAddBuiltinAction(const char* gxtKey, int action, int targetMenu = MENUPAGE_NONE, int saveSlot = SAVESLOT_NONE);
|
||||
void FrontendOptionAddSelect(const char* gxtKey, const char** rightTexts, int8 numRightTexts, int8 *var, bool onlyApplyOnEnter, ChangeFunc changeFunc, const char* saveName = nil);
|
||||
void FrontendOptionAddDynamic(const char* gxtKey, DrawFunc rightTextDrawFunc, int8 *var, ButtonPressFunc buttonPressFunc, const char* saveName = nil);
|
||||
|
||||
uint8 FrontendScreenAdd(const 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
|
||||
|
||||
Reference in New Issue
Block a user