Skip to content

Commit 04f4d62

Browse files
committed
HistoryHUD(Item) classes, MC_PRE/POST_HISTORYHUD_RENDER, couple other lil things
1 parent 94c84f6 commit 04f4d62

24 files changed

+727
-4
lines changed

changelog.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,35 @@ Added:
3737
* EntityPlayer:
3838
- [Get/Set]ImExcitedSpeedupCountdown
3939
- [Get/Set]DonateLuck
40+
- GetErrorTrinketEffect
41+
* RoomDescriptor
42+
- GetErrorTrinketEffect
4043
* RoomConfig:
4144
- LoadStb(StbType, int Mode, string StbFileName)
4245
* RoomConfigSet:
4346
- LoadStb(string StbFileName)
4447
* CharacterMenu
4548
- GetCompletionMarksSprite
49+
* History
50+
- SearchCollectibles(int or table)
51+
- SearchTrinkets(int or table)
52+
* HUD
53+
- GetHistoryHUD
54+
* Added HistoryHUD and HistoryHUDItem classes
4655
* Backported new enums for GameStateFlag
56+
* The "Error" and "Modeling Clay" trinkets now use the sprite of the item they are mimicking when smelted, like how they do in later versions of Repentance+.
4757
/newline/
4858
Modified:
4959
* EntityPlayer:
5060
- SetControllerIndex(integer ControllerIndex, boolean IncludePlayerOwned = false)
5161
If IncludePlayerOwned set to true, then sets ControllerIndex for player's subplayer/twinplayer
62+
/newline/
5263
Fixes:
5364
* ModCallbacks:
5465
- Fixed MC_GET_STATUS_EFFECT_TARGET not running for the "shrink" status effect.
66+
* CharacterMenu:
67+
- Fixed GetCharacterMenuIDFromPlayerType not returning the correct value for Tainted Isaac
68+
* Fixed modded characters' locked/door sprites rendering on the "continue" widget if they are locked behind an achievement.
5569
/newline/
5670
/versionseparator/
5771
v1.1.1a -

libzhl/IsaacRepentance_static.cpp

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,59 @@ bool ItemConfig::IsValidTrinket(unsigned int TrinketType) {
554554
return false;
555555
}
556556

557+
int RoomDescriptor::GetErrorTrinketEffect() {
558+
if (this->SpawnSeed != 0) {
559+
unsigned int seed = this->SpawnSeed;
560+
seed = seed >> 2 ^ seed;
561+
seed = seed << 7 ^ seed;
562+
seed = seed >> 25 ^ seed;
563+
return seed % (NUM_TRINKETS-1) + 1;
564+
}
565+
return TRINKET_ERROR;
566+
}
567+
568+
Vector HistoryHUD::GetPosition() const {
569+
Vector minimapDisplaySize;
570+
g_Game->GetMinimap()->GetDisplayedSize(minimapDisplaySize);
571+
const float hudOffset = 1 - g_Manager->GetOptions()->_hudOffset;
572+
return Vector(g_WIDTH - 87 + hudOffset * 24, hudOffset * -14 + minimapDisplaySize.y + 32);
573+
}
574+
575+
bool HistoryHUD::HasTwin() const {
576+
return _playerHistoryHuds[1]._player != nullptr;
577+
}
578+
579+
bool HistoryHUD::IsMini() const {
580+
return g_Manager->GetOptions()->_historyHudMode == 2;
581+
}
582+
583+
float HistoryHUD::GetScale() const {
584+
return IsMini() ? 0.5f : 1.0f;
585+
}
586+
587+
float HistoryHUD::GetIconSize() const {
588+
return GetScale() * 32.f;
589+
}
590+
591+
int HistoryHUD::GetNumRows() const {
592+
const float hudOffset = 1 - g_Manager->GetOptions()->_hudOffset;
593+
return (int)std::ceil(((hudOffset * 14 + (g_HEIGHT - 64)) - GetPosition().y) / GetIconSize());
594+
}
595+
596+
// This is per-player, if there are twins.
597+
int HistoryHUD::GetNumColumns() const {
598+
int col = HasTwin() ? 1 : 2;
599+
if (IsMini()) {
600+
col *= 2;
601+
}
602+
return col;
603+
}
604+
605+
// This is per-player, if there are twins.
606+
int HistoryHUD::GetNumVisibleItems() const {
607+
return GetNumRows() * GetNumColumns();
608+
}
609+
557610
bool Isaac::IsInGame() {
558611
return g_Manager->GetState() == 2 && g_Game;
559612
}

libzhl/LuaCore.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -788,6 +788,8 @@ namespace lua {
788788
const char* GridWebMT = "GridEntityWeb";
789789
const char* HistoryMT = "History";
790790
const char* HistoryItemMT = "HistoryItem";
791+
const char* HistoryHUDMT = "HistoryHUD";
792+
const char* HistoryHUDItemMT = "HistoryHUDItem";
791793
const char* HUDMessageMT = "HUDMessage";
792794
const char* ImGuiMT = "ImGui";
793795
const char* ItemOverlayMT = "ItemOverlay";

libzhl/LuaCore.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,8 @@ namespace lua {
207207
extern LIBZHL_API const char* GridWebMT;
208208
extern LIBZHL_API const char* HistoryMT;
209209
extern LIBZHL_API const char* HistoryItemMT;
210+
extern LIBZHL_API const char* HistoryHUDMT;
211+
extern LIBZHL_API const char* HistoryHUDItemMT;
210212
extern LIBZHL_API const char* HUDMessageMT;
211213
extern LIBZHL_API const char* ImGuiMT;
212214
extern LIBZHL_API const char* ItemOverlayMT;

libzhl/functions/ASM.zhl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ asm RenderPocketItemPillIdentifiedCheck "3bc10f42c880bc??????????000f84????????5
2525
asm UsePillIdentifyPill "3bc80f42c1c684??????????01c785????????00000000";
2626
asm ItemPoolGetPillEffect "8bb4??????????85ff";
2727

28+
asm HistoryHudRecomputeGfx "84c074??a1????????8bfa";
29+
asm HistoryHudRecomputeGfx_Jump "897d??85ff0f84????????833f03";
30+
asm HistoryHudRecomputeGfx_RefreshCheck "0f84????????8b45??83c0f8";
31+
asm PreRenderHistoryItem "0f294424??85c9";
32+
asm PreRenderHistoryItemStackOffsets "8d9424????????528d5424??528b40??8d9424";
33+
asm PreRenderHistoryItemColorModOffset "8d8c24????????e8????????f30f107c24";
34+
asm PostRenderHistoryItem "8b4c24??83c628";
35+
2836
asm GreedDonationBreakChanceForModdedCharacters "f30f1005????????59";
2937
asm GreedDonationCoinCountForModdedCharacters "83f8297d??6a01";
3038

libzhl/functions/EntityPlayer.zhl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,7 @@ struct Entity_Player depends (Vector, ANM2, ColorMod, KColor, PlayerCostumeMap,
814814
char _poopSpellQueue[6] : 0x1f30;
815815
int _eveSumptoriumCharge : 0x1f58;
816816
std_map_int_int _itemWispsList : 0x1f5c;
817+
int _modelingClayEffect : 0x1f94;
817818
int _keepersSackBonus : 0x1f98;
818819
ConsumableData _consumablesBackup : 0x2014;
819820
uint8_t _wildCardItemType : 0x2064;

libzhl/functions/ExtraTypes

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,11 @@ TypeInfo std_vector_history_historyitem {
159159
Align 4;
160160
};
161161

162+
TypeInfo std_vector_HistoryHUDItem {
163+
Size 12;
164+
Align 4;
165+
};
166+
162167
TypeInfo vector_ModEntryPointer {
163168
Size 12;
164169
Align 4;

libzhl/functions/GameState.zhl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ struct GameState depends (RoomDescriptor, GameStateRoomConfig, GameStatePlayer,
2323
uint32_t _roomCount : 0x19c;
2424
RoomDescriptor _rooms[527] : 0x1a0;
2525
GameStateRoomConfig _roomConfigs[527] : 0x17c68;
26+
int _roomIdx : 0x19d1c;
27+
int _lastRoomIdx : 0x19d20;
2628
uint32_t _playerCount : 0x19d70;
2729
GameStatePlayer _players[8] : 0x19d74;
2830
GameStatePlayer _esauJrStates[4] : 0x1cb54;

libzhl/functions/Global.zhl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ typedef std::deque<std::string> deque_string;
6868
typedef std::vector<int> std_vector_int;
6969
typedef std::vector<Vector> std_vector_vector2;
7070
typedef std::vector<History_HistoryItem> std_vector_history_historyitem;
71+
typedef std::vector<HistoryHUD_Item> std_vector_HistoryHUDItem;
7172
typedef std::vector<unsigned int> std_vector_uint;
7273
typedef std::set<uint32_t> std_set_uint32t;
7374
typedef std::vector<EntitySaveState> vector_EntitySaveState;

libzhl/functions/HUD.zhl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ __thiscall int HUD::GetPlayerHUDLayout(int playerHudIndex, Entity_Player* player
4444

4545

4646

47-
struct HUD depends (PlayerHUD, ANM2, StatHUD, HUD_Message) { {{
47+
struct HUD depends (PlayerHUD, ANM2, StatHUD, HUD_Message, HistoryHUD) { {{
4848
inline PlayerHUD* GetPlayerHUD(int index) {
4949
if (index < 0 || index > 7) {
5050
return nullptr;
@@ -71,4 +71,5 @@ struct HUD depends (PlayerHUD, ANM2, StatHUD, HUD_Message) { {{
7171
ANM2 _craftingTableSprite : 0x571c;
7272
ANM2 _poopSpellsSprite : 0x5830;
7373
StatHUD _statHUD : 0x59b4;
74+
HistoryHUD _historyHUD : 0x5c64;
7475
} : 0x5c90;

0 commit comments

Comments
 (0)