mirror of
https://github.com/zeldaret/ss
synced 2026-06-08 04:07:22 -04:00
Fix a bunch of splits and implement LayoutArc/ObjectArcControl
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
|
||||
#include "d/d_heap.h"
|
||||
|
||||
|
||||
LayoutArcManager *LayoutArcManager::sInstance;
|
||||
|
||||
LayoutArcManager::LayoutArcManager() {
|
||||
@@ -57,3 +56,68 @@ bool LayoutArcManager::create(EGG::Heap *heap) {
|
||||
GetInstance()->init(heap);
|
||||
return true;
|
||||
}
|
||||
|
||||
LayoutArcControl::~LayoutArcControl() {
|
||||
if (mLayoutArcs != nullptr) {
|
||||
release();
|
||||
}
|
||||
}
|
||||
|
||||
void LayoutArcControl::set(const char *const *layoutArcs, s32 numArcs) {
|
||||
mLayoutArcs = layoutArcs;
|
||||
mNumArcs = numArcs;
|
||||
}
|
||||
|
||||
bool LayoutArcControl::load(EGG::Heap *heap) const {
|
||||
if (mLayoutArcs == nullptr) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const char *const *ptr = mLayoutArcs;
|
||||
for (int i = 0; i < mNumArcs; i++) {
|
||||
LayoutArcManager::GetInstance()->loadLayoutArcFromDisk(*ptr, heap);
|
||||
ptr++;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool LayoutArcControl::allLoaded() const {
|
||||
if (mLayoutArcs == nullptr) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const char *const *ptr = mLayoutArcs;
|
||||
for (int i = 0; i < mNumArcs; i++) {
|
||||
dArcResult_e res = LayoutArcManager::GetInstance()->ensureLoaded1(*ptr);
|
||||
if (res != D_ARC_RESULT_OK) {
|
||||
return false;
|
||||
}
|
||||
ptr++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool LayoutArcControl::release() {
|
||||
if (mLayoutArcs == nullptr) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const char *const *ptr = mLayoutArcs;
|
||||
for (int i = 0; i < mNumArcs; i++) {
|
||||
dArcResult_e res = LayoutArcManager::GetInstance()->ensureLoaded2(*ptr);
|
||||
if (res != D_ARC_RESULT_ERROR_NOT_FOUND && res != D_ARC_RESULT_OK) {
|
||||
return false;
|
||||
}
|
||||
ptr++;
|
||||
}
|
||||
|
||||
ptr = mLayoutArcs;
|
||||
for (int i = 0; i < mNumArcs; i++) {
|
||||
LayoutArcManager::GetInstance()->decrement(*ptr);
|
||||
ptr++;
|
||||
}
|
||||
mLayoutArcs = nullptr;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -89,3 +89,52 @@ bool OarcManager::create(EGG::Heap *heap) {
|
||||
GetInstance()->init(heap);
|
||||
return true;
|
||||
}
|
||||
|
||||
ObjectArcControl::~ObjectArcControl() {
|
||||
if (mObjectArcs != nullptr) {
|
||||
release();
|
||||
}
|
||||
}
|
||||
|
||||
void ObjectArcControl::set(const char *const *objectArcs, s32 numArcs) {
|
||||
mObjectArcs = objectArcs;
|
||||
mNumArcs = numArcs;
|
||||
}
|
||||
|
||||
bool ObjectArcControl::load(EGG::Heap *heap) const {
|
||||
if (mObjectArcs == nullptr) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const char *const *ptr = mObjectArcs;
|
||||
for (int i = 0; i < mNumArcs; i++) {
|
||||
OarcManager::GetInstance()->loadObjectArcFromDisk(*ptr, heap);
|
||||
ptr++;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ObjectArcControl::release() {
|
||||
if (mObjectArcs == nullptr) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const char *const *ptr = mObjectArcs;
|
||||
for (int i = 0; i < mNumArcs; i++) {
|
||||
dArcResult_e res = OarcManager::GetInstance()->ensureLoaded2(*ptr);
|
||||
if (res != D_ARC_RESULT_ERROR_NOT_FOUND && res != D_ARC_RESULT_OK) {
|
||||
return false;
|
||||
}
|
||||
ptr++;
|
||||
}
|
||||
|
||||
ptr = mObjectArcs;
|
||||
for (int i = 0; i < mNumArcs; i++) {
|
||||
OarcManager::GetInstance()->decrement(*ptr);
|
||||
ptr++;
|
||||
}
|
||||
mObjectArcs = nullptr;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user