mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2025-10-30 08:01:01 +00:00
Fix djui interactable crash when they get destroyed
This commit is contained in:
parent
5b07d3b78c
commit
afe7e28fb3
5 changed files with 18 additions and 8 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "djui.h"
|
#include "djui.h"
|
||||||
|
#include "djui_interactable.h"
|
||||||
|
|
||||||
////////////////
|
////////////////
|
||||||
// properties //
|
// properties //
|
||||||
|
|
@ -389,6 +390,13 @@ void djui_base_destroy(struct DjuiBase* base) {
|
||||||
base->interactable = NULL;
|
base->interactable = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// remove from interactable variable
|
||||||
|
if (base == gDjuiHovered) { gDjuiHovered = NULL; }
|
||||||
|
if (base == gDjuiCursorDownOn) { gDjuiCursorDownOn = NULL; }
|
||||||
|
if (base == gInteractableFocus) { gInteractableFocus = NULL; }
|
||||||
|
if (base == gInteractableBinding) { gInteractableBinding = NULL; }
|
||||||
|
if (base == gInteractableMouseDown) { gInteractableMouseDown = NULL; }
|
||||||
|
|
||||||
// destroy this
|
// destroy this
|
||||||
base->destroy(base);
|
base->destroy(base);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
static void djui_checkbox_update_style(struct DjuiBase* base) {
|
static void djui_checkbox_update_style(struct DjuiBase* base) {
|
||||||
struct DjuiCheckbox* checkbox = (struct DjuiCheckbox*)base;
|
struct DjuiCheckbox* checkbox = (struct DjuiCheckbox*)base;
|
||||||
|
if (!checkbox) { return; }
|
||||||
if (!checkbox->base.enabled) {
|
if (!checkbox->base.enabled) {
|
||||||
djui_base_set_border_color(&checkbox->rect->base, 93, 93, 93, 255);
|
djui_base_set_border_color(&checkbox->rect->base, 93, 93, 93, 255);
|
||||||
djui_base_set_color(&checkbox->rect->base, 0, 0, 0, 0);
|
djui_base_set_color(&checkbox->rect->base, 0, 0, 0, 0);
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ struct DjuiBase* gDjuiHovered = NULL;
|
||||||
struct DjuiBase* gDjuiCursorDownOn = NULL;
|
struct DjuiBase* gDjuiCursorDownOn = NULL;
|
||||||
struct DjuiBase* gInteractableFocus = NULL;
|
struct DjuiBase* gInteractableFocus = NULL;
|
||||||
struct DjuiBase* gInteractableBinding = NULL;
|
struct DjuiBase* gInteractableBinding = NULL;
|
||||||
static struct DjuiBase* sMouseDown = NULL;
|
struct DjuiBase* gInteractableMouseDown = NULL;
|
||||||
bool gInteractableOverridePad = false;
|
bool gInteractableOverridePad = false;
|
||||||
OSContPad gInteractablePad = { 0 };
|
OSContPad gInteractablePad = { 0 };
|
||||||
static OSContPad sLastInteractablePad = { 0 };
|
static OSContPad sLastInteractablePad = { 0 };
|
||||||
|
|
@ -399,17 +399,17 @@ void djui_interactable_update(void) {
|
||||||
} else if ((padButtons & PAD_BUTTON_A) || (mouseButtons & MOUSE_BUTTON_1)) {
|
} else if ((padButtons & PAD_BUTTON_A) || (mouseButtons & MOUSE_BUTTON_1)) {
|
||||||
// cursor down events
|
// cursor down events
|
||||||
if (gDjuiHovered != NULL) {
|
if (gDjuiHovered != NULL) {
|
||||||
sMouseDown = gDjuiHovered;
|
gInteractableMouseDown = gDjuiHovered;
|
||||||
gDjuiHovered = NULL;
|
gDjuiHovered = NULL;
|
||||||
djui_interactable_on_cursor_down_begin(sMouseDown, !mouseButtons);
|
djui_interactable_on_cursor_down_begin(gInteractableMouseDown, !mouseButtons);
|
||||||
} else {
|
} else {
|
||||||
djui_interactable_on_cursor_down(sMouseDown);
|
djui_interactable_on_cursor_down(gInteractableMouseDown);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// cursor up event
|
// cursor up event
|
||||||
if (sMouseDown != NULL) {
|
if (gInteractableMouseDown != NULL) {
|
||||||
djui_interactable_on_cursor_down_end(sMouseDown);
|
djui_interactable_on_cursor_down_end(gInteractableMouseDown);
|
||||||
sMouseDown = NULL;
|
gInteractableMouseDown = NULL;
|
||||||
}
|
}
|
||||||
struct DjuiBase* lastHovered = gDjuiHovered;
|
struct DjuiBase* lastHovered = gDjuiHovered;
|
||||||
gDjuiHovered = NULL;
|
gDjuiHovered = NULL;
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,7 @@ extern struct DjuiBase* gDjuiHovered;
|
||||||
extern struct DjuiBase* gDjuiCursorDownOn;
|
extern struct DjuiBase* gDjuiCursorDownOn;
|
||||||
extern struct DjuiBase* gInteractableFocus;
|
extern struct DjuiBase* gInteractableFocus;
|
||||||
extern struct DjuiBase* gInteractableBinding;
|
extern struct DjuiBase* gInteractableBinding;
|
||||||
|
extern struct DjuiBase* gInteractableMouseDown;
|
||||||
|
|
||||||
bool djui_interactable_is_binding(void);
|
bool djui_interactable_is_binding(void);
|
||||||
void djui_interactable_set_binding(struct DjuiBase* base);
|
void djui_interactable_set_binding(struct DjuiBase* base);
|
||||||
|
|
|
||||||
|
|
@ -314,7 +314,7 @@ static bool gfx_texture_cache_lookup(int tile, struct TextureHashmapNode **n, co
|
||||||
hash = (hash >> HASH_SHIFT) & HASH_MASK;
|
hash = (hash >> HASH_SHIFT) & HASH_MASK;
|
||||||
|
|
||||||
struct TextureHashmapNode **node = &gfx_texture_cache.hashmap[hash];
|
struct TextureHashmapNode **node = &gfx_texture_cache.hashmap[hash];
|
||||||
while (*node != NULL && *node - gfx_texture_cache.pool < (int)gfx_texture_cache.pool_pos) {
|
while (node != NULL && *node != NULL && *node - gfx_texture_cache.pool < (int)gfx_texture_cache.pool_pos) {
|
||||||
if (CMPADDR((*node)->texture_addr, orig_addr) && (*node)->fmt == fmt && (*node)->siz == siz) {
|
if (CMPADDR((*node)->texture_addr, orig_addr) && (*node)->fmt == fmt && (*node)->siz == siz) {
|
||||||
gfx_rapi->select_texture(tile, (*node)->texture_id);
|
gfx_rapi->select_texture(tile, (*node)->texture_id);
|
||||||
*n = *node;
|
*n = *node;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue