Skip to content

Commit

Permalink
[Guerilla] Add option to show ***all*** fields (unnamed fields, etc)
Browse files Browse the repository at this point in the history
  • Loading branch information
num0005 committed Oct 20, 2019
1 parent 29d6569 commit 09f268a
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 3 deletions.
2 changes: 1 addition & 1 deletion H2Codez/Common/BlamBaseTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ struct editor_string
if (!LOG_CHECK(LoadStringA(get_h2alang(), id, data, ARRAYSIZE(data))))
{
getLogger().WriteLog("Failed to get string %d", id);
return "";
return "BORK BORK BORK";
}
return data;
}
Expand Down
40 changes: 40 additions & 0 deletions H2Codez/H2Guerilla/H2Guerilla.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ inline static void EnableItem(UINT item, bool enable)
void update_ui()
{
CheckItem(ID_EDIT_ADVANCEDSHADERVIEW, conf.getBoolean("disable_templete_view"));
CheckItem(SHOW_ALL_HIDDEN_FIELDS, conf.getBoolean("show_all_fields"));
}

/* Capture menu input */
Expand Down Expand Up @@ -87,6 +88,10 @@ int __fastcall CCmdTarget__OnCmdMsg_hook(void *thisptr, BYTE _, unsigned int nID
TagDefinitions::dump_as_xml();
AssemblyLayoutGenerator::DumpAllTags();
return true;
case SHOW_ALL_HIDDEN_FIELDS:
toggle_boolean("show_all_fields", false);
update_ui();
return true;
}
}
return CCmdTarget__OnCmdMsg_Orginal(thisptr, 0, nID, nCode, pExtra, AFX_CMDHANDLERINFO);
Expand All @@ -101,6 +106,7 @@ void __fastcall CCmdUI__Enable_Hook(void *thisptr, BYTE _, int a2)
EnableItem(SCRIPT_DOC, true);
EnableItem(SHOW_HIDDEN_FIELDS, true);
EnableItem(DUMP_XML_DEFINITION, true);
EnableItem(SHOW_ALL_HIDDEN_FIELDS, show_hidden_fields);
}

/* Override menu loaded by guerilla */
Expand Down Expand Up @@ -207,6 +213,36 @@ void H2GuerrilaPatches::update_field_display()
}
}

static inline bool is_tag_field_group_blacklisted(tag_field* tag_field)
{
auto group = tag_field->group_tag;
return group == 'fnom' || group == 'fnop' || group == 'fnin' || group == 'fnir';
}

static bool __fastcall field_information__should_hide(field_information *thisptr)
{
ASSERT_CHECK(thisptr);
ASSERT_CHECK(thisptr->field);
if (show_hidden_fields && conf.getBoolean("show_all_fields", false))
return false;

/* Hide black listed groups */
if (is_tag_field_group_blacklisted(thisptr->field))
return true;

std::string name = thisptr->field->name.get_string();
/*
Hide unnamed fields needs to check if the string is not null due to a quirk of orginal code
*/
if (thisptr->field->name.id && name.length() == 0)
return true;

/* Finally hide based on name */
bool should_hide = name.find('~') != std::string::npos;

return should_hide && !show_hidden_fields;
}

void H2GuerrilaPatches::Init()
{
for (auto &menu : menu_map)
Expand Down Expand Up @@ -235,6 +271,7 @@ void H2GuerrilaPatches::Init()
NopFill(0x44CDD0, 0x5);

// A messy fix for script text getting cut off
/* Works by patching the string conversion function */
WriteValue(0x402FCE + 1, 0x40000);
WriteValue(0x402F0D + 1, 0x40000);

Expand Down Expand Up @@ -290,6 +327,9 @@ void H2GuerrilaPatches::Init()
// Someone at bungie messed up this def, technically wrong in all the tools but it only matters in guerilla
WriteArray(0x94FDD8, &inverse_matrix4x3_fieldset);

// Replace guerilla logic for deciding if we should show a tag field
WriteJmp(0x477230, field_information__should_hide);

#pragma endregion

#pragma region Hooks
Expand Down
16 changes: 15 additions & 1 deletion H2Codez/H2Guerilla/H2Guerilla.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
#pragma once
#include "Common\TagDefinitions.h"

struct field_information
{
void *vtble;
int field_4;
tag_field *field;
void *field_C;
int parent_tag_info;
field_information *next;
int field_18;
};


class H2GuerrilaPatches {
public:
static void Init();
static void update_field_display();
};
};
Binary file modified H2Codez/Resources/H2Guerilla.rc
Binary file not shown.
3 changes: 2 additions & 1 deletion H2Codez/Resources/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@
#define SAPIEN_TILE_VERTICAL 40019
#define DUMP_XML_DEFINITION 40020
#define DUMP_LOADED_TAGS_TO 40021
#define SHOW_ALL_HIDDEN_FIELDS 40022

// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 105
#define _APS_NEXT_COMMAND_VALUE 40022
#define _APS_NEXT_COMMAND_VALUE 40023
#define _APS_NEXT_CONTROL_VALUE 1003
#define _APS_NEXT_SYMED_VALUE 101
#endif
Expand Down

0 comments on commit 09f268a

Please sign in to comment.