Skip to content

Commit

Permalink
Fix Bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Ibrahim778 committed Sep 22, 2021
1 parent dbd9c9f commit b88757e
Show file tree
Hide file tree
Showing 8 changed files with 159 additions and 146 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
/release
/package.bat
/build.bat
/functionNamer.py
268 changes: 142 additions & 126 deletions src/user/linkedList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,166 +5,182 @@
#ifndef QM_REBORN_LL_CPP
#define QM_REBORN_LL_CPP

linked_list::linked_list()
widgetData *linked_list::get_node(const char *refID)
{
node *n = head;
while(n != NULL)
{
head = NULL;
tail = NULL;
if(sce_paf_strncmp(n->widget.refId, refID, sizeof(n->widget.refId)) == 0)
return &n->widget;
n = n->next;
}

void linked_list::printall()
return NULL;
}

linked_list::linked_list()
{
head = NULL;
tail = NULL;
}

void linked_list::printall()
{
#ifdef DEBUG
node *current = head;
while (current != NULL)
{
#ifdef DEBUG
node *current = head;
while (current != NULL)
{
print("%s, ", current->widget.refId);
current = current->next;
}

#endif
print("%s, ", current->widget.refId);
current = current->next;
}

void linked_list::update_checkbox_status(const char *refID, CheckBoxState state)
#endif
}

void linked_list::update_checkbox_status(const char *refID, CheckBoxState state)
{
node *tmp = head;
while (tmp != NULL)
{
node *tmp = head;
while(tmp != NULL)
{
if(sce_paf_strcmp(tmp->widget.refId, refID) == 0)
break;
tmp = tmp->next;
}
if (sce_paf_strcmp(tmp->widget.refId, refID) == 0)
break;
tmp = tmp->next;
}

if(tmp == NULL)
return;
if (tmp == NULL)
return;

tmp->widget.data.CheckBoxData.state = state;
tmp->widget.data.CheckBoxData.state = state;
}

void linked_list::update_node(widgetData *widget, int flags)
{
node *tmp = head;
while (tmp != NULL)
{
if (sce_paf_strcmp(tmp->widget.refId, widget->refId) == 0)
break;
tmp = tmp->next;
}
if (tmp == NULL)
{
print("WARNING TMP == NULL CANNOT UPDATE\n");
return;
}

void linked_list::update_node(widgetData *widget, int flags)
if (flags & UPDATE_COLOR)
tmp->widget.col = widget->col;
if (flags & UPDATE_SIZE)
tmp->widget.size = widget->size;
if (flags & UPDATE_POSITION)
tmp->widget.pos = widget->pos;
if (flags & UPDATE_TEXT)
{
node *tmp = head;
while (tmp != NULL)
switch (widget->type)
{
if(sce_paf_strcmp(tmp->widget.refId, widget->refId) == 0)
break;
tmp = tmp->next;
}
if(tmp == NULL)
case button:
{
print("WARNING TMP == NULL CANNOT UPDATE\n");
return;
sce_paf_memcpy(tmp->widget.data.ButtonData.label, widget->data.ButtonData.label, sizeof(tmp->widget.data.ButtonData.label));
print("After copying text %s\n", tmp->widget.data.ButtonData.label);
break;
}

if(flags & UPDATE_COLOR)
tmp->widget.col = widget->col;
if(flags & UPDATE_SIZE)
tmp->widget.size = widget->size;
if(flags & UPDATE_POSITION)
tmp->widget.pos = widget->pos;
if(flags & UPDATE_TEXT)
case text:
{
switch (widget->type)
{
case button:
{
sce_paf_memcpy(tmp->widget.data.ButtonData.label, widget->data.ButtonData.label, sizeof(tmp->widget.data.ButtonData.label));
print("After copying text %s\n", tmp->widget.data.ButtonData.label);
break;
}
case text:
{
sce_paf_strncpy(tmp->widget.data.TextData.label, widget->data.ButtonData.label, sizeof(tmp->widget.data.ButtonData.label));
break;
}
default:
break;
}
sce_paf_strncpy(tmp->widget.data.TextData.label, widget->data.ButtonData.label, sizeof(tmp->widget.data.ButtonData.label));
break;
}

if(flags & UPDATE_CHECKBOX_STATE)
{
if(tmp->widget.type == check_box)
{
tmp->widget.data.CheckBoxData.state = widget->data.CheckBoxData.state;
}
default:
break;
}
}

if(flags & UPDATE_EVENT)
if (flags & UPDATE_CHECKBOX_STATE)
{
if (tmp->widget.type == check_box)
{
switch (widget->type)
{
case button:
{
tmp->widget.data.ButtonData.onPress = widget->data.ButtonData.onPress;
break;
}

case check_box:
{
tmp->widget.data.CheckBoxData.OnToggle = widget->data.CheckBoxData.OnToggle;
break;
}

default:
break;
}
tmp->widget.data.CheckBoxData.state = widget->data.CheckBoxData.state;
}

if(flags & UPDATE_LOAD)
tmp->widget.OnLoad = widget->OnLoad;
}

void linked_list::add_node(widgetData *widget)
if (flags & UPDATE_EVENT)
{
node *tmp = new node;
sce_paf_memcpy(&tmp->widget, widget, sizeof(widgetData));
tmp->next = NULL;

if(head == NULL)
switch (widget->type)
{
case button:
{
head = tmp;
tail = tmp;
tmp->widget.data.ButtonData.onPress = widget->data.ButtonData.onPress;
break;
}
else

case check_box:
{
tail->next = tmp;
tail = tail->next;
tmp->widget.data.CheckBoxData.OnToggle = widget->data.CheckBoxData.OnToggle;
break;
}
}

//Credit to CreepNT for this
void linked_list::remove_node(const char *tag) {
//Check head isn't NULL
if (head == NULL)
return;

//First, handle the case where we free the head
if (sce_paf_strcmp(head->widget.refId, tag) == 0) {
node* nodeToDelete = head;
head = head->next;
sce_paf_free(nodeToDelete);
return;

default:
break;
}
}

//Bail out if the head is the only node
if (head->next == NULL)
return;
if (flags & UPDATE_LOAD)
tmp->widget.OnLoad = widget->OnLoad;
}

//Else, try to locate node we're asked to remove
node** pCurrentNodeNext = &head; //This points to the current node's `next` field (or to pHead)
while (1) {
if (sce_paf_strcmp((*pCurrentNodeNext)->widget.refId, tag) == 0) //pCurrentNodeNext points to the pointer that points to the node we need to delete
break;
void linked_list::add_node(widgetData *widget)
{
node *tmp = new node;
sce_paf_memcpy(&tmp->widget, widget, sizeof(widgetData));
tmp->next = NULL;

//If the next node's next is NULL, we reached the end of the list. Bail out.
if ((*pCurrentNodeNext)->next == NULL)
return;
if (head == NULL)
{
head = tmp;
tail = tmp;
}
else
{
tail->next = tmp;
tail = tail->next;
}
}

//Credit to CreepNT for this
void linked_list::remove_node(const char *tag)
{
//Check head isn't NULL
if (head == NULL)
return;

pCurrentNodeNext = &(*pCurrentNodeNext)->next;
};
node* nodeToDelete = *pCurrentNodeNext;
*pCurrentNodeNext = (*pCurrentNodeNext)->next;
//First, handle the case where we free the head
if (sce_paf_strcmp(head->widget.refId, tag) == 0)
{
node *nodeToDelete = head;
head = head->next;
sce_paf_free(nodeToDelete);
return;
}

//Bail out if the head is the only node
if (head->next == NULL)
return;

//Else, try to locate node we're asked to remove
node **pCurrentNodeNext = &head; //This points to the current node's `next` field (or to pHead)
while (1)
{
if (sce_paf_strcmp((*pCurrentNodeNext)->widget.refId, tag) == 0) //pCurrentNodeNext points to the pointer that points to the node we need to delete
break;

//If the next node's next is NULL, we reached the end of the list. Bail out.
if ((*pCurrentNodeNext)->next == NULL)
return;

pCurrentNodeNext = &(*pCurrentNodeNext)->next;
};
node *nodeToDelete = *pCurrentNodeNext;
*pCurrentNodeNext = (*pCurrentNodeNext)->next;
sce_paf_free(nodeToDelete);
}

#endif
2 changes: 1 addition & 1 deletion src/user/linkedList.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class linked_list
void printall();
void update_node(widgetData *widget, int flags);
void update_checkbox_status(const char *refID, CheckBoxState state);

widgetData *get_node(const char *refID);
void add_node(widgetData *widget);
void remove_node(const char *tag);
};
Expand Down
2 changes: 1 addition & 1 deletion src/user/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ extern "C"
int module_start(SceSize, void *)
{
sceClibPrintf("QuickMenuReborn, by Ibrahim\n");
mainThreadID = sceKernelCreateThread("quickmenureborn", impose_thread, 248, SCE_KERNEL_4KiB, 0, 0, NULL);
mainThreadID = sceKernelCreateThread("quickmenureborn", impose_thread, 248, SCE_KERNEL_64KiB, 0, 0, NULL);
if(sceKernelStartThread(mainThreadID, 0, NULL) < 0) return SCE_KERNEL_START_NO_RESIDENT;

SceUID load_thread_id = sceKernelCreateThread("quickmenureborn_plugins", load_thread, 250, SCE_KERNEL_4KiB, 0, 0, NULL);
Expand Down
2 changes: 1 addition & 1 deletion src/user/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ using namespace widget;

int sceClibPrintf(const char * fmt, ...);
#define QM_REBORN_INTERNAL
#ifdef DEBUG
#ifdef _DEBUG
#define print sceClibPrintf
#define TRY(method) do { sceClibPrintf("Trying " #method "\n"); void *ret = (void *)method; sceClibPrintf("Got ret = 0x%X\n", ret); } while(0);
#define TRY_RET(method, toSet, type) do { sceClibPrintf("Trying " #method "\n"); type ret = (type)method; sceClibPrintf("Got ret = 0x%X\n", ret); toSet = ret; } while(0)
Expand Down
9 changes: 0 additions & 9 deletions src/user/types.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
#include "main.h"
#include "types.h"

WString makeWString(const char *string)
{
String *str = new String((char *)string);
WString wstr;
str->ToWString(&wstr);
delete str;
return wstr;
}

Widget::Color makeSceColor(float r, float g, float b, float a)
{
Widget::Color color;
Expand Down
1 change: 0 additions & 1 deletion src/user/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include "main.h"
#include "../quickmenureborn/qm_reborn.h"

WString makeWString(const char *string);
Widget::Color makeSceColor(float r, float g, float b, float a);
Widget::Color makeSceColor(widgetColor col);
SceFVector4 makeSceVector4(SceFloat x, SceFloat y, SceFloat z, SceFloat w);
Expand Down
Loading

0 comments on commit b88757e

Please sign in to comment.