Skip to content

Commit

Permalink
simple colour overlay work
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderHarrison committed Oct 17, 2024
1 parent 7a74ae7 commit 7421a7e
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 2 deletions.
36 changes: 34 additions & 2 deletions src/lab.c
Original file line number Diff line number Diff line change
Expand Up @@ -2603,6 +2603,7 @@ void Update_Camera()

return;
}

void Lab_SelectCustomTDI(GOBJ *menu_gobj)
{
MenuData *menu_data = menu_gobj->userdata;
Expand Down Expand Up @@ -5146,6 +5147,36 @@ int Export_Compress(u8 *dest, u8 *source, u32 size)
return compress_size;
}

// Think Function that runs after the character's think functions.
// Needed to prevent color overlays from being overwritten
void Event_PostThink(GOBJ *gobj)
{
GOBJ *hmn = Fighter_GetGObj(0);
FighterData *hmn_data = hmn->userdata;

int set_overlay = false;
GXColor overlay_colour;

for (int i = 0; i < OVERLAY_COUNT; ++i)
{
int mode_idx = LabOptions_Overlays[i].option_val;
if (mode_idx == 0) continue;

int asid_group = LabValues_OverlayASIDGroups[i];
if (CPUAction_CheckASID(hmn, asid_group))
{
set_overlay = true;
overlay_colour = LabValues_OverlayColours[mode_idx];
break;
}
}

if (set_overlay) {
hmn_data->color[1].hex = overlay_colour;
hmn_data->color[1].color_enable = 1;
}
}

// Init Function
void Event_Init(GOBJ *gobj)
{
Expand All @@ -5155,6 +5186,7 @@ void Event_Init(GOBJ *gobj)
FighterData *hmn_data = hmn->userdata;
GOBJ *cpu = Fighter_GetGObj(1);
FighterData *cpu_data = cpu->userdata;
GObj_AddProc(gobj, Event_PostThink, 20);

// theres got to be a better way to do this...
event_vars = *event_vars_ptr;
Expand All @@ -5166,7 +5198,7 @@ void Event_Init(GOBJ *gobj)
InfoDisplay_Init();

// Init DIDraw
DIDraw_Init();
//DIDraw_Init();

// Init Recording
Record_Init();
Expand Down Expand Up @@ -5204,7 +5236,7 @@ void Event_Init(GOBJ *gobj)
void Event_Update()
{
// update DI draw
DIDraw_Update();
//DIDraw_Update();

// update info display
InfoDisplay_Think(infodisp_gobj);
Expand Down
52 changes: 52 additions & 0 deletions src/lab.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ static EventOption LabOptions_InfoDisplay[];
static EventOption LabOptions_Tech[];

static EventMenu LabMenu_General;
static EventMenu LabMenu_Overlays;
static EventMenu LabMenu_InfoDisplay;
static EventMenu LabMenu_CPU;
static EventMenu LabMenu_Record;
Expand Down Expand Up @@ -1560,6 +1561,12 @@ static EventOption LabOptions_General[] = {
.option_values = LabOptions_CamMode, // pointer to an array of strings
.onOptionChange = Lab_ChangeCamMode,
},
{
.option_kind = OPTKIND_MENU, // the type of option this is; menu, string list, integer list, etc
.menu = &LabMenu_Overlays, // pointer to the menu that pressing A opens
.option_name = {"Color Overlays"}, // pointer to a string
.desc = "Set up color indicators for\n. action states.", // string describing what this option does
},
// hud
{
.option_kind = OPTKIND_STRING, // the type of option this is; menu, string list, integer list, etc
Expand Down Expand Up @@ -1614,6 +1621,8 @@ static EventMenu LabMenu_General = {
.options = &LabOptions_General, // pointer to all of this menu's options
.prev = 0, // pointer to previous menu, used at runtime
};


// Info Display
static char **LabValues_InfoDisplay[] = {"None", "Position", "State Name", "State Frame", "Velocity - Self", "Velocity - KB", "Velocity - Total", "Engine LStick", "System LStick", "Engine CStick", "System CStick", "Engine Trigger", "System Trigger", "Ledgegrab Timer", "Intangibility Timer", "Hitlag", "Hitstun", "Shield Health", "Shield Stun", "Grip Strength", "ECB Lock", "ECB Bottom", "Jumps", "Walljumps", "Jab Counter", "Line Info", "Blastzone Left/Right", "Blastzone Up/Down"};
static char **LabValues_InfoPresets[] = {"None", "Custom", "Ledge", "Damage"};
Expand Down Expand Up @@ -2248,6 +2257,49 @@ static EventMenu LabMenu_Record = {
.prev = 0, // pointer to previous menu, used at runtime
};

enum overlay_type
{
OVERLAY_ACTIONABLE_GROUND,
OVERLAY_ACTIONABLE_AIR,

OVERLAY_COUNT,
};

static char *LabValues_OverlayASIDGroups[OVERLAY_COUNT] = {
ASID_ACTIONABLEGROUND,
ASID_ACTIONABLEAIR,
};

#define OVERLAY_COLOUR_COUNT 4
static char *LabValues_OverlayNames[OVERLAY_COLOUR_COUNT] = { "None", "Red", "Green", "Blue" };
static GXColor LabValues_OverlayColours[OVERLAY_COLOUR_COUNT] = {
{ 0, 0, 0, 0 },
{ 255, 0, 0, 255 },
{ 0, 255, 0, 255 },
{ 0, 0, 255, 255 }
};

static EventOption LabOptions_Overlays[OVERLAY_COUNT] = {
{
.option_kind = OPTKIND_STRING, // the type of option this is; menu, string list, integer list, etc
.value_num = OVERLAY_COLOUR_COUNT, // number of values for this option
.option_name = "Actionable on Ground", // pointer to a string
.desc = "", // string describing what this option does
.option_values = LabValues_OverlayNames, // pointer to an array of strings
},
{
.option_kind = OPTKIND_STRING, // the type of option this is; menu, string list, integer list, etc
.value_num = OVERLAY_COLOUR_COUNT, // number of values for this option
.option_name = "Actionable in Air", // pointer to a string
.desc = "", // string describing what this option does
.option_values = LabValues_OverlayNames, // pointer to an array of strings
},
};
static EventMenu LabMenu_Overlays = {
.name = "Overlays", // the name of this menu
.option_num = sizeof(LabOptions_Overlays) / sizeof(EventOption), // number of options this menu contains
.options = &LabOptions_Overlays, // pointer to all of this menu's options
};

u32 lz77_compress(u8 *uncompressed_text, u32 uncompressed_size, u8 *compressed_text, u8 pointer_length_width);
u32 lz77_decompress(u8 *compressed_text, u8 *uncompressed_text);
Expand Down

0 comments on commit 7421a7e

Please sign in to comment.