Skip to content

Commit

Permalink
Merge branch 'ActorList' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Luzagar authored Aug 14, 2024
2 parents 5de8aa4 + 02e4360 commit e0957e2
Show file tree
Hide file tree
Showing 19 changed files with 510 additions and 7 deletions.
3 changes: 3 additions & 0 deletions RomHack.toml.in
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,8 @@ iso = "@TWWGZ_CFG_BLD_ISO@"
# menu
"twwgz/mn/Menu1.dat" = "../res/menu/EN_Menu1.dat"

# actor info
"twwgz/procs.bin" = "../res/proc_info/procs.bin"

# REL modules
"twwgz/rels" = "modules/rels"
8 changes: 8 additions & 0 deletions external/libtww/include/f_op/f_op_actor_mng.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,15 @@ inline void fopAcM_OffStatus(fopAc_ac_c* pActor, u32 flag) {
inline csXyz* fopAcM_GetAngle_p(fopAc_ac_c* i_actor) {
return &i_actor->current.angle;
}
LIBTWW_DEFINE_FUNC(fopAcM_delete__FP10fopAc_ac_c,
void, fopAcM_delete, (fopAc_ac_c*))


LIBTWW_DEFINE_FUNC(fopAcM_SearchByName__FsPP10fopAc_ac_c, s32, fopAcM_SearchByName, (u32, fopAc_ac_c**))


extern "C" {
extern node_list_class g_fopAcTg_Queue;
}

#endif
6 changes: 5 additions & 1 deletion modules/boot/include/global_data.h
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
#pragma once
#pragma once
#include "libtww/include/f_op/f_op_actor_mng.h"

extern fopAc_ac_c* g_currentActor;
extern bool g_actorViewEnabled;
1 change: 1 addition & 0 deletions modules/boot/include/menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ enum MenuIndex {

// Scene menu's sub menus
MN_COLLISION_VIEW_INDEX,
MN_ACTOR_LIST_INDEX,

// Settings sub menus
MN_EQUIP_PRIORITY_INDEX,
Expand Down
1 change: 1 addition & 0 deletions modules/boot/include/scene.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ enum SceneIndex {
TIME_MINUTES_INDEX,
MODIFY_DATE_INDEX,
COLLISION_VIEW_INDEX,
ACTOR_LIST_INDEX,

SCENE_MENU_MAX
};
Expand Down
3 changes: 3 additions & 0 deletions modules/boot/src/global_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
KEEP_VAR u8 g_geometryOpacity = 0x80;
KEEP_VAR u8 g_collisionRaise = 1;

KEEP_VAR fopAc_ac_c* g_currentActor;
KEEP_VAR bool g_actorViewEnabled;

KEEP_VAR CollisionItem g_collisionFlags[VIEW_COLLISION_MAX] = {
{VIEW_POLYGON_GROUND, false}, {VIEW_POLYGON_WALL, false}, {VIEW_POLYGON_ROOF, false}, {VIEW_POLYGON_EDGES, false},
{VIEW_AT_CC, false}, {VIEW_TG_CC, false}, {VIEW_CO_CC, false},
Expand Down
12 changes: 6 additions & 6 deletions modules/boot/src/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

// This array must correspond to the order of the MenuIndex enum.
const char* g_menuPaths[MN_COUNT] = {
"main", "cheats", "flags", "inventory", "memory", "practice",
"scene", "settings", "tools", "general_flags", "dungeon_flags", "savewarp_flags",
"tuner_flags", "amounts", "item_inventory", "quest_status", "delivery_bag", "spoils_bag",
"bait_bag", "charts", "treasure_chart", "special_chart", "triforce_chart", "watches",
"memory_editor", "any_saves", "nomss_saves", "ad_saves", "collision_view", "equip_priority",
"pos_settings",
"main", "cheats", "flags", "inventory", "memory", "practice",
"scene", "settings", "tools", "general_flags", "dungeon_flags", "savewarp_flags",
"tuner_flags", "amounts", "item_inventory", "quest_status", "delivery_bag", "spoils_bag",
"bait_bag", "charts", "treasure_chart", "special_chart", "triforce_chart", "watches",
"memory_editor", "any_saves", "nomss_saves", "ad_saves", "collision_view", "actor_list",
"equip_priority", "pos_settings",
};

KEEP_FUNC Menu::Menu(Cursor& cursor) : cursor(cursor) {}
5 changes: 5 additions & 0 deletions modules/features/actor_view/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
file(GLOB_RECURSE srcs CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp")
file(GLOB_RECURSE asms CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/*.s")
list(APPEND srcs ${asms})
get_filename_component(rel_name ${CMAKE_CURRENT_SOURCE_DIR} NAME)
twwgz_add_module(${rel_name} "${srcs}" "${CMAKE_CURRENT_SOURCE_DIR}/include")
5 changes: 5 additions & 0 deletions modules/features/actor_view/include/actor_view.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#pragma once

namespace ActorViewer {
void execute();
} // namespace ActorViewer
6 changes: 6 additions & 0 deletions modules/features/actor_view/include/main.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#pragma once

namespace twwgz::modules {
void main();
void exit();
} // namespace twwgz::modules
52 changes: 52 additions & 0 deletions modules/features/actor_view/src/actor_view.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#include "features/actor_view/include/actor_view.h"
#include "menus/utils/menu_mgr.h"
#include "libtww/include/f_op/f_op_actor_mng.h"
//#include "libtww/include/f_op/f_op_draw_tag.h"
#include "menus/menu_actor_list/include/actor_list_menu.h"
#include "geometry_draw.h"
#include "global_data.h"
#include "libtww/include/m_Do/m_Do_printf.h"

namespace ActorViewer {
void drawGizmo(fopAc_ac_c* actor) {
// Gizmo cube size and angle
cXyz cube_size = {10.0f, 10.0f, 10.0f};
csXyz cube_angle = {0, 0, 0};

// Colors for the gizmo's axis lines and cube
GXColor red = {255, 0, 0, 255};
GXColor green = {0, 255, 0, 255};
GXColor blue = {0, 0, 255, 255};
GXColor white = {255, 255, 255, 255};

// length of the gizmo's axis grid lines to draw
f32 grid_line_length = 200.0f;

// width of the gizmo's axis grid lines to draw
u8 line_width = 20;

// Draw a cube at the position of the actor
dDbVw_drawCubeXlu(actor->current.pos, cube_size, cube_angle, white);

// Gizmo axis line points
cXyz point_x_a = {actor->current.pos.x + grid_line_length, actor->current.pos.y, actor->current.pos.z};
cXyz point_x_b = {actor->current.pos.x - grid_line_length, actor->current.pos.y, actor->current.pos.z};
cXyz point_y_a = {actor->current.pos.x, actor->current.pos.y + grid_line_length, actor->current.pos.z};
cXyz point_y_b = {actor->current.pos.x, actor->current.pos.y - grid_line_length, actor->current.pos.z};
cXyz point_z_a = {actor->current.pos.x, actor->current.pos.y, actor->current.pos.z + grid_line_length};
cXyz point_z_b = {actor->current.pos.x, actor->current.pos.y, actor->current.pos.z - grid_line_length};


// Gizmo axis lines
dDbVw_drawLineXlu(point_x_a, point_x_b, red, 0, line_width);
dDbVw_drawLineXlu(point_y_a, point_y_b, green, 0, line_width);
dDbVw_drawLineXlu(point_z_a, point_z_b, blue, 0, line_width);
}

KEEP_FUNC void execute() {
if (g_actorViewEnabled) {
if (g_currentActor != NULL)
drawGizmo(g_currentActor);
}
}
} // namespace ActorViewer
14 changes: 14 additions & 0 deletions modules/features/actor_view/src/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include <main.h>
#include "features/actor_view/include/actor_view.h"
#include "rels/include/cxx.h"
#include "events/pre_loop_listener.h"

namespace twwgz::modules {
void main() {
g_PreLoopListener->addListener(ActorViewer::execute);
}
void exit() {
g_PreLoopListener->removeListener(ActorViewer::execute);
}

} // namespace twwgz::modules
5 changes: 5 additions & 0 deletions modules/menus/menu_actor_list/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
file(GLOB_RECURSE srcs CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp")
file(GLOB_RECURSE asms CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/*.s")
list(APPEND srcs ${asms})
get_filename_component(rel_name ${CMAKE_CURRENT_SOURCE_DIR} NAME)
twwgz_add_module(${rel_name} "${srcs}" "${CMAKE_CURRENT_SOURCE_DIR}/include")
54 changes: 54 additions & 0 deletions modules/menus/menu_actor_list/include/actor_list_menu.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#include "menu.h"
#include "libtww/include/f_op/f_op_actor_mng.h"

struct ActorListData {
uint16_t l_index;
};

/**
* @struct procBinData
* @brief Structure for entries in res/proc_info/procs.bin
*/
struct procBinData {
s16 procId;
char procName[30];
} __attribute__((aligned(32)));

enum {
ACTOR_NAME_INDEX,
ACTOR_PARAMS_INDEX,
ACTOR_ADDRESS_INDEX,
ACTOR_POSITION_X_INDEX,
ACTOR_POSITION_Y_INDEX,
ACTOR_POSITION_Z_INDEX,
ACTOR_ANGLE_X_INDEX,
ACTOR_ANGLE_Y_INDEX,
ACTOR_ANGLE_Z_INDEX,

ACTOR_LIST_LINE_COUNT,
};

class ActorListMenu : public Menu {
public:
ActorListMenu(Cursor&, ActorListData&);
virtual ~ActorListMenu();
virtual void draw();

private:
void updateActorData();
template <typename T>
void updateValue(T*, bool);
void loadActorName();
void checkAndCloseMenu();
void checkAndRestoreMenu();

u16& l_index;

Line lines[ACTOR_LIST_LINE_COUNT];
s32 l_cameraPlay;
bool l_halt;
u8 l_menuStatus;
u8 l_windowStatus;
cXyz l_cameraPos;
cXyz l_cameraTarget;
};
6 changes: 6 additions & 0 deletions modules/menus/menu_actor_list/include/main.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#pragma once

namespace twwgz::modules {
void main();
void exit();
} // namespace twwgz::modules
Loading

0 comments on commit e0957e2

Please sign in to comment.