Skip to content

Commit

Permalink
Fix bug & exporter, Added SlideBar (not finished)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ibrahim778 committed Aug 16, 2021
1 parent 194bd36 commit dbd9c9f
Show file tree
Hide file tree
Showing 11 changed files with 210 additions and 70 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"config_mgr.h": "cpp",
"scetypes.h": "c",
"taihen.h": "c",
"fios2_types.h": "c"
"fios2_types.h": "c",
"display.h": "c"
}
}
3 changes: 3 additions & 0 deletions QuickMenuReborn.emd
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ Library: QuickMenuReborn function: QuickMenuRebornUpdateText nidvalue: 0x68680E2
Library: QuickMenuReborn function: QuickMenuRebornUpdatePlane nidvalue: 0xFC8EA5DB
Library: QuickMenuReborn function: QuickMenuRebornRemoveSeparator nidvalue: 0x7550C9BF
Library: QuickMenuReborn function: QuickMenuRebornGetCheckBoxState nidvalue: 0x65214907
Library: QuickMenuReborn function: QuickMenuRebornAddAdvancedWidget nidvalue: 0xC698BC91
Library: QuickMenuReborn function: QuickMenuRebornAddAdvancedWidgetWithStyleHash nidvalue: 0x5E63C077
Library: QuickMenuReborn function: QuickMenuRebornSlider nidvalue: 0xB962832B
3 changes: 3 additions & 0 deletions QuickMenuReborn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@ modules:
QuickMenuRebornUpdatePlane: 0xFC8EA5DB
QuickMenuRebornRemoveSeparator: 0x7550C9BF
QuickMenuRebornGetCheckBoxState: 0x65214907
QuickMenuRebornAddAdvancedWidget: 0xC698BC91
QuickMenuRebornAddAdvancedWidgetWithStyleHash: 0x5E63C077
QuickMenuRebornSlider: 0xB962832B
7 changes: 5 additions & 2 deletions exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
EMD_PATH="QuickMenuReborn.emd"
YML_PATH="QuickMenuReborn.yml"

EMD_START="Module: QuickMenuReborn major_version: 3 minor_version: 0\nsceModuleInfo_type: 6\nmodule_function: module_start localname: module_start\nmodule_function: module_stop localname: module_stop\n\nLibrary: QuickMenuReborn version: 1\nLibrary: QuickMenuReborn nidsuffix: \"\"\nLibrary: QuickMenuReborn attr: auto_export\n"
LIB_NAME="QuickMenuReborn"
EMD_START="Module: " + LIB_NAME + " major_version: 3 minor_version: 0\nsceModuleInfo_type: 6\nmodule_function: module_start localname: module_start\nmodule_function: module_stop localname: module_stop\n\nLibrary: " + LIB_NAME + " version: 1\nLibrary: "+ LIB_NAME +" nidsuffix: \"\"\nLibrary: " + LIB_NAME + " attr: auto_export\n"
functionNames=[
"QuickMenuRebornAddWidget",
"QuickMenuRebornRemoveWidget",
Expand All @@ -21,7 +21,10 @@
"QuickMenuRebornUpdateText",
"QuickMenuRebornUpdatePlane",
"QuickMenuRebornRemoveSeparator",
"QuickMenuRebornGetCheckBoxState"
"QuickMenuRebornGetCheckBoxState",
"QuickMenuRebornAddAdvancedWidget",
"QuickMenuRebornAddAdvancedWidgetWithStyleHash",
"QuickMenuRebornSlider"
]

def getHash(string):
Expand Down
13 changes: 11 additions & 2 deletions src/quickmenureborn/c_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ typedef enum
button = 0,
check_box,
text,
plane
plane,
slidebar,
} widget_type;

typedef enum check_box_state
Expand Down Expand Up @@ -54,6 +55,11 @@ typedef struct
CheckBoxState state;
} toggleData;

typedef struct
{
void (*OnChange)();
} slidebarData;

typedef struct
{
float r;
Expand All @@ -73,7 +79,9 @@ typedef struct
typedef struct
{
char type[256];
char idType[256];
char styleInfo[256];
int useHash;
int hash;
} advancedData;

typedef struct
Expand All @@ -96,6 +104,7 @@ typedef struct
toggleData CheckBoxData;
buttonData ButtonData;
textData TextData;
slidebarData SlidebarData;
} data;

//BOOL: Set weather the advanced data is used
Expand Down
24 changes: 22 additions & 2 deletions src/quickmenureborn/qm_reborn.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,26 @@ EXPORT int QuickMenuRebornUpdatePlane(const char *refID, vector4 *Size, vector4
*/
EXPORT int QuickMenuRebornGetCheckBoxState(const char *refID);

/**
*
* @brief Add an advanced widget with stylehash directly
*
* @param refID Refrence ID of the widget
* @param parentRefID Refrence ID of the parent widget (pass NULL if none)
* @param Size Pointer to size of widget
* @param Position Pointer to position of widget
* @param Color Pointer to color of widget
* @param Type Type of widget
* @param styleHash Hash of the style of widget
* @param OnLoad Function to be called whenever widget is loaded in quick menu
* @todo
* @retval Bool: 0 or 1 on succes < 0 on error
*
*/
EXPORT int QuickMenuRebornAddAdvancedWidgetWithStyleHash(const char *refID, const char *parentRefID, vector4 *Size, vector4 *Position, widgetColor *Color, const char *Type, int styleHash, void (*OnLoad)());

EXPORT int QuickMenuRebornSlider(const char *refID, const char *parentRefID, vector4 *Size, vector4 *Position, widgetColor *Color, void(*OnChange)(), void (*OnLoad)());

#define COLOR_WHITE makeWidgetColor(1.0f, 1.0f, 1.0f, 1.0f)
#define COLOR_RED makeWidgetColor(1.0f, 0.0f, 0.0f, 1.0f)
#define COLOR_GREEN makeWidgetColor(0.0f, 1.0f, 0.0f, 1.0f)
Expand All @@ -291,8 +311,8 @@ EXPORT int QuickMenuRebornGetCheckBoxState(const char *refID);
#define makeCommonWidgetVector4Int(common) makeWidgetVector4(common##.0f, common##.0f, common##.0f, common##.0f)
#define makeCommonWidgetColorInt(common) makeWidgetColor(common##.0f, common##.0f, common##.0f, common##.0f)

//Size of all the other planes in the quick menu (as close as I could get)
#define SCE_PLANE_WIDTH 825.0f
//Size of all the other planes in the quick menu
#define SCE_PLANE_WIDTH 835.0f

#define CONFIG_MGR_ERROR_NOT_EXIST -1
#define CONFIG_MGR_ERROR_COULD_NOT_WRITE_FULL -2
Expand Down
54 changes: 29 additions & 25 deletions src/user/event_handler.cpp
Original file line number Diff line number Diff line change
@@ -1,36 +1,40 @@
#include "event_handler.hpp"
#include "config_mgr.h"

extern linked_list currentWidgets;
extern linked_list currentWidgets;

QMEventHandler::QMEventHandler()
{
eventHandler = onGet;
}
QMEventHandler::QMEventHandler()
{
eventHandler = onGet;
}

void QMEventHandler::onGet(SceInt32 , Widget *self, SceInt32, ScePVoid puserData)
void QMEventHandler::onGet(SceInt32 , Widget *self, SceInt32, ScePVoid puserData)
{
widgetData *widget = (widgetData *)puserData;
switch (widget->type)
{
widgetData *widget = (widgetData *)puserData;
switch (widget->type)
case button:
{
case button:
{
if(widget->data.ButtonData.onPress != NULL) widget->data.ButtonData.onPress();
break;
}
if(widget->data.ButtonData.onPress != NULL) widget->data.ButtonData.onPress();
break;
}

case check_box:
{
print("Setting checkbox state to %d\n", ((CheckBox *)self)->checked);
currentWidgets.update_checkbox_status(widget->refId, ((CheckBox *)self)->checked ? CHECKBOX_ON : CHECKBOX_OFF);
print("Got save ret = 0x%X\n", saveCheckBoxState(widget->refId, ((CheckBox *)self)->checked ? CHECKBOX_ON : CHECKBOX_OFF));
if(widget->data.CheckBoxData.OnToggle != NULL) widget->data.CheckBoxData.OnToggle(((CheckBox *)self)->checked);
break;
}
case check_box:
{
currentWidgets.update_checkbox_status(widget->refId, ((CheckBox *)self)->checked ? CHECKBOX_ON : CHECKBOX_OFF);
if(widget->data.CheckBoxData.OnToggle != NULL) widget->data.CheckBoxData.OnToggle(((CheckBox *)self)->checked);
break;
}

default:
{
break;
}
case slidebar:
{
if(widget->data.SlidebarData.OnChange != NULL) widget->data.SlidebarData.OnChange();
break;
}

default:
{
break;
}
}
}
83 changes: 65 additions & 18 deletions src/user/export_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,20 +161,13 @@ int QuickMenuRebornPlane(const char *refID, const char *parentRefID, vector4 *Si
int QuickMenuRebornSeparator(const char *refID)
{
char sepID[256] = {0};
sce_paf_snprintf(sepID, sizeof(sepID), "qm_reborn_%s_separator_0", refID);
sce_paf_snprintf(sepID, sizeof(sepID), "qm_reborn_%s_separator", refID);

//Invisible Spacer
vector4 size = makeWidgetVector4Int(825, 20, 0, 0), pos = makeCommonWidgetVector4Int(0);
widgetColor col = COLOR_TRANSPARENT;
vector4 size = makeWidgetVector4Int(835, 20, 0, 0), pos = makeCommonWidgetVector4Int(0);
widgetColor col = COLOR_WHITE;

QuickMenuRebornPlane(sepID, NULL, &size, &pos, &col, NULL);

//Line
sce_paf_snprintf(sepID, sizeof(sepID), "qm_reborn_%s_separator_1", refID);
size = makeWidgetVector4(825.0f,2.0f,0.0f,0.0f);
pos = makeWidgetVector4(0,0,0,0);
col = makeWidgetColor(.75f,.75f,.75f,.75f);
QuickMenuRebornPlane(sepID, NULL, &size, &pos, &col, NULL);
QuickMenuRebornAddAdvancedWidgetWithStyleHash(sepID, NULL, &size, &pos, &col, "plane", 0x26C7781E, NULL);

return 0;
}
Expand Down Expand Up @@ -231,7 +224,7 @@ int QuickMenuRebornUpdateCheckBox(const char *refID, vector4 *Size, vector4 *Pos
widget.isAdvanced = 0;


return QuickMenuRebornUpdateWidget(&widget, flags);
return QuickMenuRebornUpdateWidget(&widget, flags);
}

int QuickMenuRebornUpdateText(const char *refID, vector4 *Size, vector4 *Position, widgetColor *Color, const char *Text, void (*OnLoad)(), int flags)
Expand All @@ -253,11 +246,9 @@ int QuickMenuRebornUpdateText(const char *refID, vector4 *Size, vector4 *Positio
}

widget.OnLoad = OnLoad;

widget.isAdvanced = 0;

return QuickMenuRebornUpdateWidget(&widget, flags);

return QuickMenuRebornUpdateWidget(&widget, flags);
}

int QuickMenuRebornUpdatePlane(const char *refID, vector4 *Size, vector4 *Position, widgetColor *Color, void (*OnLoad)(), int flags)
Expand All @@ -276,11 +267,11 @@ int QuickMenuRebornUpdatePlane(const char *refID, vector4 *Size, vector4 *Positi

widget.isAdvanced = 0;

return QuickMenuRebornUpdateWidget(&widget, flags);
return QuickMenuRebornUpdateWidget(&widget, flags);

}

int QuickMenuRebornAddAdvancedWidget(const char *refID, const char *parentRefID, vector4 *Size, vector4 *Position, widgetColor *Color, const char *Type, const char *idType, void (*OnLoad)())
int QuickMenuRebornAddAdvancedWidget(const char *refID, const char *parentRefID, vector4 *Size, vector4 *Position, widgetColor *Color, const char *Type, const char *styleInfo, void (*OnLoad)())
{
widgetData widget;

Expand All @@ -300,14 +291,70 @@ int QuickMenuRebornAddAdvancedWidget(const char *refID, const char *parentRefID,

sceClibMemset(&widget.adata, 0, sizeof(widget.adata));

sce_paf_strncpy(widget.adata.idType, idType, sizeof(widget.adata.idType));
sce_paf_strncpy(widget.adata.styleInfo, styleInfo, sizeof(widget.adata.styleInfo));
sce_paf_strncpy(widget.adata.type, Type, sizeof(widget.adata.type));

widget.OnLoad = OnLoad;

return registerWidget(&widget);
}

int QuickMenuRebornAddAdvancedWidgetWithStyleHash(const char *refID, const char *parentRefID, vector4 *Size, vector4 *Position, widgetColor *Color, const char *Type, int styleHash, void (*OnLoad)())
{
widgetData widget;

sceClibMemset(widget.refId, 0, sizeof(widget.refId));
sce_paf_strncpy(widget.refId, refID, sizeof(widget.refId));

sceClibMemset(widget.parentRefId, 0, sizeof(widget.parentRefId));
if(parentRefID != NULL) sce_paf_strncpy(widget.parentRefId, parentRefID, sizeof(widget.parentRefId));

if(Size != NULL) widget.size = *Size;
if(Position != NULL) widget.pos = *Position;
if(Color != NULL) widget.col = *Color;

widget.isAdvanced = true;

widget.hasParent = parentRefID != NULL;

sceClibMemset(&widget.adata, 0, sizeof(widget.adata));

widget.adata.useHash = 1;
widget.adata.hash = styleHash;
sce_paf_strncpy(widget.adata.type, Type, sizeof(widget.adata.type));

widget.OnLoad = OnLoad;

return registerWidget(&widget);
}

int QuickMenuRebornSlider(const char *refID, const char *parentRefID, vector4 *Size, vector4 *Position, widgetColor *Color, void (*OnChange)(), void (*OnLoad)())
{
widgetData dat;
sceClibMemset(&dat, 0, sizeof(dat));

sceClibMemset(dat.refId, 0, sizeof(dat.refId));
sce_paf_strncpy(dat.refId, refID, sizeof(dat.refId));

sceClibMemset(dat.parentRefId, 0, sizeof(dat.parentRefId));
if(parentRefID != NULL) sce_paf_strncpy(dat.parentRefId, parentRefID, sizeof(dat.parentRefId));

dat.type = slidebar;
dat.hasParent = parentRefID != NULL;

dat.pos = *Position;
dat.size = *Size;
dat.col = *Color;

dat.OnLoad = OnLoad;

dat.isAdvanced = 0;

dat.data.SlidebarData.OnChange = OnChange;

return registerWidget(&dat);
}

int QuickMenuRebornGetCheckBoxState(const char *refID)
{
return readCheckBoxState(refID);
Expand Down
2 changes: 1 addition & 1 deletion src/user/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ int sceClibPrintf(const char * fmt, ...);
#else
#define print dummyprint
#define TRY(method) method;
#define TRY_RET(method, toSet, type) do { void *ret = (void *)method; toSet = (type)ret; } while(0)
#define TRY_RET(method, toSet, type) do { type ret = (type)method; toSet = (type)ret; } while(0)
#define DO(method)
#define FAIL_IF(con) if (con) { return 0; }
#define FAILTHREAD_IF(con) if (con) { return sceKernelExitDeleteThread(0); }
Expand Down
Loading

0 comments on commit dbd9c9f

Please sign in to comment.