Files
tp/src/f_op/f_op_scene_req.cpp
T
TakaRikka 5867eaf68b general cleanup, d_menu_quit / d_a_obj_testcube mostly done, d_msg_scrn_explain debug (#3065)
* typedef for cPhs_Step

* make sdk includes consistent

* d_menu_quit / d_msg_scrn_explain debug

* d_a_obj_testcube mostly done

* d_debug_pad mostly done

* jstudio tool library headers

* some JStudioCameraEditor headers

* d_jcam_editor mostly done

* try fixing some shield regressions

* d_bg_parts mostly done

* fix merge errors

* debug fix
2026-01-24 23:36:23 -08:00

152 lines
4.3 KiB
C++

/**
* f_op_scene_req.cpp
* Scene Process Request
*/
#include "f_op/f_op_scene_req.h"
#include "f_op/f_op_overlap_mng.h"
#include "f_op/f_op_scene.h"
#include "f_op/f_op_scene_pause.h"
#include "f_pc/f_pc_executor.h"
#include "f_pc/f_pc_manager.h"
static cPhs_Step fopScnRq_phase_ClearOverlap(scene_request_class* i_sceneReq) {
return fopOvlpM_ClearOfReq() == 1 ? cPhs_NEXT_e : cPhs_INIT_e;
UNUSED(i_sceneReq);
}
static cPhs_Step fopScnRq_phase_Execute(scene_request_class* i_sceneReq) {
return fpcNdRq_Execute(&i_sceneReq->create_request);
}
static cPhs_Step fopScnRq_phase_IsDoingOverlap(scene_request_class* i_sceneReq) {
return fopOvlpM_IsDoingReq() == 1 ? cPhs_NEXT_e : cPhs_INIT_e;
UNUSED(i_sceneReq);
}
static cPhs_Step fopScnRq_phase_IsDoneOverlap(scene_request_class* i_sceneReq) {
return fopOvlpM_IsDone() == 1 ? cPhs_NEXT_e : cPhs_INIT_e;
UNUSED(i_sceneReq);
}
static BOOL l_fopScnRq_IsUsingOfOverlap;
static cPhs_Step fopScnRq_phase_Done(scene_request_class* i_sceneReq) {
if (i_sceneReq->create_request.parameters != 1) {
scene_class* scene = (scene_class*)fpcM_SearchByID(i_sceneReq->create_request.creating_id);
(void)scene;
fopScnPause_Disable(scene);
}
l_fopScnRq_IsUsingOfOverlap = FALSE;
return cPhs_NEXT_e;
}
static cPhs_Step fopScnRq_Execute(scene_request_class* i_sceneReq) {
cPhs_Step phase_state = cPhs_Do(&i_sceneReq->phase_request, i_sceneReq);
switch (phase_state) {
case cPhs_NEXT_e:
return fopScnRq_Execute(i_sceneReq);
break;
default:
break;
}
return phase_state;
}
static int fopScnRq_PostMethod(void* i_scene, scene_request_class* i_sceneReq) {
if (i_sceneReq->fade_request != NULL) {
fopScnPause_Enable((scene_class*)i_scene);
fopOvlpM_ToldAboutID(((scene_class*)i_scene)->base.base.id);
}
return 1;
}
static int fopScnRq_Cancel(scene_request_class* i_sceneReq) {
if (i_sceneReq->fade_request != NULL && !fopOvlpM_Cancel()) {
return 0;
} else {
return 1;
}
}
static scene_request_class* fopScnRq_FadeRequest(s16 i_procname, u16 i_peektime) {
overlap_request_class* req = NULL;
if (!l_fopScnRq_IsUsingOfOverlap) {
req = fopOvlpM_Request(i_procname, i_peektime);
if (req != NULL) {
l_fopScnRq_IsUsingOfOverlap = TRUE;
}
}
return (scene_request_class*)req;
}
fpc_ProcID fopScnRq_Request(int i_reqType, scene_class* i_scene, s16 i_procName, void* i_data, s16 i_fadename,
u16 i_peektime) {
static node_create_request_method_class submethod = {
(process_method_func)fopScnRq_Execute,
(process_method_func)fopScnRq_Cancel,
NULL,
(process_method_func)fopScnRq_PostMethod,
};
static cPhs__Handler noFadeFase[8] = {
(cPhs__Handler)fopScnRq_phase_Execute,
(cPhs__Handler)fopScnRq_phase_Done,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
};
static cPhs__Handler fadeFase[8] = {
(cPhs__Handler)fopScnRq_phase_IsDoingOverlap,
(cPhs__Handler)fopScnRq_phase_IsDoneOverlap,
(cPhs__Handler)fopScnRq_phase_Execute,
(cPhs__Handler)fopScnRq_phase_ClearOverlap,
(cPhs__Handler)fopScnRq_phase_IsDoneOverlap,
(cPhs__Handler)fopScnRq_phase_Done,
NULL,
NULL,
};
scene_request_class* fade_req = NULL;
cPhs__Handler* phase_handler = noFadeFase;
scene_request_class* req = (scene_request_class*)fpcNdRq_Request(
sizeof(scene_request_class), i_reqType, (process_node_class*)i_scene, i_procName, i_data,
&submethod);
if (req == NULL) {
return fpcM_ERROR_PROCESS_ID_e;
}
if (i_fadename != 0x7FFF) {
phase_handler = fadeFase;
fade_req = fopScnRq_FadeRequest(i_fadename, i_peektime);
if (fade_req == NULL) {
fpcNdRq_Delete(&req->create_request);
return fpcM_ERROR_PROCESS_ID_e;
}
}
req->fade_request = fade_req;
cPhs_Set(&req->phase_request, phase_handler);
return req->create_request.request_id;
}
s32 fopScnRq_ReRequest(fpc_ProcID i_requestId, s16 i_procName, void* i_data) {
return fpcNdRq_ReRequest(i_requestId, i_procName, i_data);
}
int fopScnRq_Handler() {
return fpcNdRq_Handler();
}