Skip to content

Commit

Permalink
Implimented BusyIndicator, bugfixes & improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Ibrahim778 committed May 16, 2022
1 parent 3431885 commit 785f6d4
Show file tree
Hide file tree
Showing 12 changed files with 69 additions and 16 deletions.
1 change: 1 addition & 0 deletions QuickMenuReborn.emd
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ Library: QuickMenuReborn function: QuickMenuRebornSetWidgetTextureBase nidvalue:
Library: QuickMenuReborn function: QuickMenuRebornCloseMenu nidvalue: 0xCD66AED8
Library: QuickMenuReborn function: QuickMenuRebornRegisterWidgetFromStyle nidvalue: 0xC236CE22
Library: QuickMenuReborn function: QuickMenuRebornRegisterWidgetFromStyleHash nidvalue: 0x7538EB34
Library: QuickMenuReborn function: QuickMenuRebornAssignOnDeleteHandler nidvalue: 0x3F667364
1 change: 1 addition & 0 deletions QuickMenuReborn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ modules:
QuickMenuRebornCloseMenu: 0xCD66AED8
QuickMenuRebornRegisterWidgetFromStyle: 0xC236CE22
QuickMenuRebornRegisterWidgetFromStyleHash: 0x7538EB34
QuickMenuRebornAssignOnDeleteHandler: 0x3F667364
5 changes: 4 additions & 1 deletion exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@
"QuickMenuRebornSetWidgetTextureBase",
"QuickMenuRebornCloseMenu",
"QuickMenuRebornRegisterWidgetFromStyle",
"QuickMenuRebornRegisterWidgetFromStyleHash"
"QuickMenuRebornRegisterWidgetFromStyleHash",
"QuickMenuRebornAssignOnDeleteHandler",
"QuickMenuRebornStartBusyIndicator",
"QuickMenuRebornStopBusyIndicator"
]

def getHash(string):
Expand Down
2 changes: 1 addition & 1 deletion resource/src/qmr_plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<progressbar_touch style="slidebar_style" id="qmr_slidebar" />
</template>

<template fast_open="1" id="busyindicator_template">
<template fast_open="1" id="qmr_busyindicator_template">
<busyindicator id="qmr_busyindicator" style="base_style_busyindicator" texture="_common_texture_busy" />
</template>

Expand Down
2 changes: 1 addition & 1 deletion sample_plugin/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ int module_start()

//Get our checkboxes saved state
int ret = QuickMenuRebornGetCheckboxValue(CHECKBOX_REF_ID);
resetOnExit = ret == CONFIG_MGR_ERROR_NOT_EXIST ? false : ret;
resetOnExit = ret == QMR_CONFIG_MGR_ERROR_NOT_EXIST ? false : ret;

QuickMenuRebornRegisterWidget(TEXT_ID, NULL, text);
QuickMenuRebornSetWidgetSize(TEXT_ID, SCE_PLANE_WIDTH, 50, 0, 0);
Expand Down
1 change: 1 addition & 0 deletions src/quickmenureborn/c_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ typedef enum
plane,
slidebar,
progressbar_touch,
busyindicator,
} QMRWidgetType;

typedef enum
Expand Down
10 changes: 7 additions & 3 deletions src/quickmenureborn/qm_reborn.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
//Height of SCE separator planes
#define SCE_SEPARATOR_HEIGHT 20.0f

#define CONFIG_MGR_ERROR_NOT_EXIST -1
#define CONFIG_MGR_ERROR_COULD_NOT_WRITE_FULL -2
#define CONFIG_MGR_OK 0
#define QMR_CONFIG_MGR_ERROR_NOT_EXIST -1
#define QMR_CONFIG_MGR_ERROR_COULD_NOT_WRITE_FULL -2
#define QMR_CONFIG_MGR_OK 0

#define QMR_BUTTON_RELEASE_ID 0x10000008
#define QMR_BUTTON_PRESS_ID 0x10000003
Expand Down Expand Up @@ -69,6 +69,7 @@ int QuickMenuRebornGetCheckboxValue(const char *refID);
int QuickMenuRebornAssignRecallHandler(VoidCallback callback, const char *refID);
int QuickMenuRebornAssignSaveHandler(VoidCallback callback, const char *refID);
int QuickMenuRebornAssignOnLoadHandler(VoidCallback callback, const char *refID);
int QuickMenuRebornAssignOnDeleteHandler(VoidCallback callback, const char *refID);

int QuickMenuRebornAssignDefaultCheckBoxSave(const char *refID);
int QuickMenuRebornAssignDefaultCheckBoxRecall(const char *refID);
Expand All @@ -90,6 +91,9 @@ int QuickMenuRebornSetWidgetTextureBase(const char *refID, const char *textureID

int QuickMenuRebornCloseMenu();

int QuickMenuRebornStartBusyIndicator(const char *refID);
int QuickMenuRebornStopBusyIndicator(const char *refID);

#ifdef __cplusplus
}
#endif
Expand Down
1 change: 1 addition & 0 deletions src/user/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ extern bool displayed;
#define PLANE_TEMPLATE_ID "qmr_plane_template"
#define SLIDEBAR_TEMPLATE_ID "qmr_slidebar_template"
#define PROGRESSBAR_TOUCH_TEMPLATE_ID "qmr_progressbar_touch_template"
#define BUSYINDICATOR_TEMPLATE_ID "qmr_busyindicator_template"

#endif
12 changes: 6 additions & 6 deletions src/user/config_mgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ int writeIntToFile(const char *path, int val)
SceUID file = sceIoOpen(path, SCE_O_WRONLY | SCE_O_CREAT | SCE_O_TRUNC, 0777);
int ret = sceIoWrite(file, &val, sizeof(val));
sceIoClose(file);
return ret == sizeof(int) ? CONFIG_MGR_OK : CONFIG_MGR_ERROR_COULD_NOT_WRITE_FULL;
return ret == sizeof(int) ? QMR_CONFIG_MGR_OK : QMR_CONFIG_MGR_ERROR_COULD_NOT_WRITE_FULL;
}

int writeFloatToFile(const char *path, float val)
{
SceUID file = sceIoOpen(path, SCE_O_WRONLY | SCE_O_CREAT | SCE_O_TRUNC, 0777);
int ret = sceIoWrite(file, &val, sizeof(val));
sceIoClose(file);
return ret == sizeof(float) ? CONFIG_MGR_OK : CONFIG_MGR_ERROR_COULD_NOT_WRITE_FULL;
return ret == sizeof(float) ? QMR_CONFIG_MGR_OK : QMR_CONFIG_MGR_ERROR_COULD_NOT_WRITE_FULL;
}

int preSetup()
Expand Down Expand Up @@ -61,7 +61,7 @@ int readCheckBoxState(const char *refID)

sce_paf_snprintf(key, 0x400, CHECKBOX_SAVE_DIR "%s", refID);

if(!checkFileExist(key)) return CONFIG_MGR_ERROR_NOT_EXIST;
if(!checkFileExist(key)) return QMR_CONFIG_MGR_ERROR_NOT_EXIST;

ret = readIntFromFile(key);

Expand All @@ -70,7 +70,7 @@ int readCheckBoxState(const char *refID)

int saveCheckBoxState(const char *refID, int val)
{
int ret = CONFIG_MGR_OK;
int ret = QMR_CONFIG_MGR_OK;
if(ret = preSetup(), ret < 0) return ret;

char key[0x400] = {0};
Expand All @@ -83,7 +83,7 @@ int saveCheckBoxState(const char *refID, int val)

int saveSlidebarState(const char *refId, SceFloat32 val)
{
int ret = CONFIG_MGR_OK;
int ret = QMR_CONFIG_MGR_OK;
if(ret = preSetup(), ret < 0)
{
print("preSetup() Failed!\n");
Expand All @@ -106,7 +106,7 @@ SceFloat32 getSlidebarValue(const char *refID)

sce_paf_snprintf(key, 0x400, SLIDEBAR_SAVE_DIR "%s", refID);

if(!checkFileExist(key)) return CONFIG_MGR_ERROR_NOT_EXIST;
if(!checkFileExist(key)) return QMR_CONFIG_MGR_ERROR_NOT_EXIST;

return readFloatFromFile(key);
}
4 changes: 2 additions & 2 deletions src/user/default_handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void defaultCheckBoxRecall(const char *refID)
if(data == NULL) return;

int state = readCheckBoxState(refID);
if(state == CONFIG_MGR_ERROR_NOT_EXIST) return;
if(state == QMR_CONFIG_MGR_ERROR_NOT_EXIST) return;

((CheckBox *)data->widget)->SetChecked(0, state, 0);
}
Expand All @@ -38,7 +38,7 @@ void defaultSliderRecall(const char *refID)
if(data == NULL) return;

SceFloat32 state = getSlidebarValue(refID);
if(state == CONFIG_MGR_ERROR_NOT_EXIST) return;
if(state == QMR_CONFIG_MGR_ERROR_NOT_EXIST) return;

((ProgressBarTouch *)data->widget)->SetProgress(state, 0, 0);
}
36 changes: 34 additions & 2 deletions src/user/export_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ int QuickMenuRebornRemoveSeparator(const char *id)

sce_paf_snprintf(rID, sizeof(rID), "qmr_sep_%s_internal", id);

QMR::UnregisterWidget(rID);
return QMR::UnregisterWidget(rID);

}

Expand Down Expand Up @@ -274,7 +274,7 @@ int QuickMenuRebornSetSlidebarValue(const char *refID, float val)

int QuickMenuRebornSaveSlidebarValue(const char *refID, float val)
{
saveSlidebarState(refID, val);
return saveSlidebarState(refID, val);
}

int QuickMenuRebornSetCheckBoxState(const char *refID, int state)
Expand Down Expand Up @@ -356,4 +356,36 @@ widgetData *QuickMenuRebornRegisterWidgetFromStyleHash(const char *id, const cha
dat.advancedData.useHash = true;

return QMR::RegisterWidget(&dat);
}

int QuickMenuRebornAssignOnDeleteHandler(VoidCallback callback, const char *refID)
{
widgetData *data = currentWidgets.GetNode(refID);

if(data == NULL)
return -1;

data->OnDelete = callback;
}

int QuickMenuRebornStartBusyIndicator(const char *refID)
{
widgetData *data = currentWidgets.GetNode(refID);

if(data == NULL)
return -1;

((BusyIndicator *)data->widget)->Start();
return 0;
}

int QuickMenuRebornStopBusyIndicator(const char *refID)
{
widgetData *data = currentWidgets.GetNode(refID);

if(data == NULL)
return -1;

((BusyIndicator *)data->widget)->Stop();
return 0;
}
10 changes: 10 additions & 0 deletions src/user/widgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const char *widgetTemplateID[] = //THESE ARE IN ORDER TO MATCH WITH THE ENUM
PLANE_TEMPLATE_ID,
SLIDEBAR_TEMPLATE_ID,
PROGRESSBAR_TOUCH_TEMPLATE_ID,
BUSYINDICATOR_TEMPLATE_ID
};

static bool addedTask = false;
Expand Down Expand Up @@ -56,6 +57,15 @@ SceVoid OnQuickMenuClose()
n->texture = SCE_NULL;
n = n->next;
}


node *widget = currentWidgets.head;
while(widget != NULL)
{
if(widget->widget.OnDelete != NULL)
widget->widget.OnDelete(widget->widget.refId);
widget = widget->next;
}
}

SceVoid onPluginReady(Plugin *plugin)
Expand Down

0 comments on commit 785f6d4

Please sign in to comment.