From 6cb971715ebd627b21f7a9def5a4e1eb94580382 Mon Sep 17 00:00:00 2001 From: Trxye Date: Tue, 15 Jun 2021 14:09:49 -0500 Subject: [PATCH] diary bs --- TR5Main/Game/Lara/lara_struct.h | 17 +++++ TR5Main/Game/newinv2.cpp | 101 ++++++++++++++++++++-------- TR5Main/Game/newinv2.h | 28 +++++++- TR5Main/Objects/TR5/tr5_objects.cpp | 1 + TR5Main/Objects/objectslist.h | 1 + TR5Main/Renderer/Renderer11.h | 1 + TR5Main/Renderer/Renderer11Draw.cpp | 23 +++++++ 7 files changed, 141 insertions(+), 31 deletions(-) diff --git a/TR5Main/Game/Lara/lara_struct.h b/TR5Main/Game/Lara/lara_struct.h index f4b26564d..996eee17d 100644 --- a/TR5Main/Game/Lara/lara_struct.h +++ b/TR5Main/Game/Lara/lara_struct.h @@ -927,9 +927,26 @@ typedef struct CarriedWeaponInfo bool HasSilencer; }; +#define MaxDiaryPages 64 +#define MaxStringsPerPage 8 + +typedef struct DiaryString +{ + int x, y; + short stringID; +}; + +typedef struct DiaryPage +{ + DiaryString Strings[MaxStringsPerPage]; +}; + typedef struct DiaryInfo { bool Present; + short numPages; + short currentPage; + DiaryPage Pages[MaxDiaryPages]; }; typedef struct LARA_ARM diff --git a/TR5Main/Game/newinv2.cpp b/TR5Main/Game/newinv2.cpp index 83a11a03b..254381437 100644 --- a/TR5Main/Game/newinv2.cpp +++ b/TR5Main/Game/newinv2.cpp @@ -1,4 +1,5 @@ #include "framework.h" +#ifdef NEW_INV #include "newinv2.h" #include "draw.h" #include "control.h" @@ -107,10 +108,11 @@ short optmessages[] = // STRING_COMBINE_WITH, STRING_LOAD_GAME, STRING_SAVE_GAME, - 1,1,1//remove later + 1,1,1,1//remove later // STRING_EXAMINE, // STRING_STATISTICS, // STRING_CHOOSE_WEAPON, +// STRING_READ_DIARY }; #define phd_winxmax g_Configuration.Width @@ -236,7 +238,7 @@ INVOBJ inventry_objects_list[INVENTORY_TABLE_SIZE] = {ID_PC_LOAD_SAVE_ITEM, 52, 0.3f, ANGLE(180), 0, 0, OPT_SAVE, STRING_SAVE_GAME, -1, INV_ROT_Y}, {ID_BURNING_TORCH_ITEM, 14, 0.5f, 0, ANGLE(90), 0, OPT_USE, STRING_LOAD_GAME, -1, INV_ROT_Y}, {ID_CROWBAR_ITEM, 4, 0.5f, 0, ANGLE(90), 0, OPT_USE, STRING_CROWBAR, -1, INV_ROT_Y}, -{ID_DIARY_ITEM, 0, 0.5f, 0, 0, 0, OPT_USE, STRING_DIARY, -1, INV_ROT_Y}, +{ID_DIARY_ITEM, 0, 0.3f, ANGLE(180), 0, 0, OPT_DIARY, STRING_DIARY, -1, INV_ROT_Y}, {ID_COMPASS_ITEM, 0x0FFF2, 0.5f, 0, 0, 0, 0, STRING_LOAD_GAME, -1, INV_ROT_Y}, {ID_CLOCKWORK_BEETLE, 14, 0.5f, 0, 0, 0, OPT_USE, STRING_LOAD_GAME, -1, INV_ROT_Y}, {ID_CLOCKWORK_BEETLE_COMBO1, 18, 0.5f, 0, 0, 0, OPT_COMBINABLE, STRING_LOAD_GAME, -1, INV_ROT_Y}, @@ -251,6 +253,7 @@ INVOBJ inventry_objects_list[INVENTORY_TABLE_SIZE] = {ID_WATERSKIN2_3, 2, 0.5f, 0, ANGLE(285), 0, OPT_USE | OPT_COMBINABLE, STRING_LOAD_GAME, -1, INV_ROT_Y}, {ID_WATERSKIN2_4, 2, 0.5f, 0, ANGLE(285), 0, OPT_USE | OPT_COMBINABLE, STRING_LOAD_GAME, -1, INV_ROT_Y}, {ID_WATERSKIN2_5, 2, 0.5f, 0, ANGLE(285), 0, OPT_USE | OPT_COMBINABLE, STRING_LOAD_GAME, -1, INV_ROT_Y}, +{ID_OPEN_DIARY_ITEM, 0, 0.9f, ANGLE(90), 0, 0, 0, 0, 0, 0}, //puzzles @@ -2802,49 +2805,49 @@ void handle_inventry_menu() if ((opts & OPT_LOAD)) { - current_options[0].type = 9; + current_options[0].type = MENU_TYPE_LOAD; current_options[0].text = g_GameFlow->GetString(optmessages[6]); n = 1; } if ((opts & OPT_SAVE)) { - current_options[n].type = 10; + current_options[n].type = MENU_TYPE_SAVE; current_options[n].text = g_GameFlow->GetString(optmessages[7]); n++; } if ((opts & OPT_EXAMINABLE)) { - current_options[n].type = 11; + current_options[n].type = MENU_TYPE_EXAMINE; current_options[n].text = g_GameFlow->GetString(optmessages[8]); n++; } if ((opts & OPT_STATS)) { - current_options[n].type = 12; + current_options[n].type = MENU_TYPE_STATS; current_options[n].text = g_GameFlow->GetString(optmessages[9]); n++; } if ((opts & OPT_USE)) { - current_options[n].type = 1; + current_options[n].type = MENU_TYPE_USE; current_options[n].text = g_GameFlow->GetString(optmessages[0]); n++; } if ((opts & OPT_EQUIP)) { - current_options[n].type = 5; + current_options[n].type = MENU_TYPE_EQUIP; current_options[n].text = g_GameFlow->GetString(optmessages[4]); n++; } if ((opts & (OPT_CHOOSEAMMO_SHOTGUN | OPT_CHOOSEAMMO_CROSSBOW | OPT_CHOOSEAMMO_GRENADEGUN))) { - current_options[n].type = 2; + current_options[n].type = MENU_TYPE_CHOOSEAMMO; current_options[n].text = g_GameFlow->GetString(optmessages[1]); n++; } @@ -2853,7 +2856,7 @@ void handle_inventry_menu() { if (is_item_currently_combinable(num)) { - current_options[n].type = 3; + current_options[n].type = MENU_TYPE_COMBINE; current_options[n].text = g_GameFlow->GetString(optmessages[2]); n++; } @@ -2861,23 +2864,30 @@ void handle_inventry_menu() if ((opts & OPT_ALWAYSCOMBINE)) { - current_options[n].type = 3; + current_options[n].type = MENU_TYPE_COMBINE; current_options[n].text = g_GameFlow->GetString(optmessages[2]); n++; } if ((opts & OPT_SEPERATABLE)) { - current_options[n].type = 4; + current_options[n].type = MENU_TYPE_SEPERATE; current_options[n].text = g_GameFlow->GetString(optmessages[3]); n++; } + + if (opts & OPT_DIARY) + { + current_options[n].type = MENU_TYPE_DIARY; + current_options[n].text = g_GameFlow->GetString(optmessages[11]); + n++; + } } else { - current_options[0].type = 6; + current_options[0].type = MENU_TYPE_AMMO1; current_options[0].text = g_GameFlow->GetString(inventry_objects_list[ammo_object_list[0].invitem].objname); - current_options[1].type = 7; + current_options[1].type = MENU_TYPE_AMMO2; current_options[1].text = g_GameFlow->GetString(inventry_objects_list[ammo_object_list[1].invitem].objname); n = 2; @@ -2886,7 +2896,7 @@ void handle_inventry_menu() if (opts & (OPT_CHOOSEAMMO_CROSSBOW | OPT_CHOOSEAMMO_GRENADEGUN)) { n = 3; - current_options[2].type = 8; + current_options[2].type = MENU_TYPE_AMMO3; current_options[2].text = g_GameFlow->GetString(inventry_objects_list[ammo_object_list[2].invitem].objname); } @@ -2956,7 +2966,7 @@ void handle_inventry_menu() switch (current_options[current_selected_option].type) { - case 2: + case MENU_TYPE_CHOOSEAMMO: rings[RING_INVENTORY]->ringactive = 0; ammo_active = 1; Stashedcurrent_selected_option = current_selected_option; @@ -2971,31 +2981,31 @@ void handle_inventry_menu() StashedCurrentRocketAmmoType = CurrentRocketAmmoType; break; - case 9: + case MENU_TYPE_LOAD: loading_or_saving = 1; break; - case 10: + case MENU_TYPE_SAVE: loading_or_saving = 2; break; - case 11: + case MENU_TYPE_EXAMINE: GLOBAL_invMode = IM_EXAMINE; break; - case 12: + case MENU_TYPE_STATS: GLOBAL_invMode = IM_STATS; break; - case 6: - case 7: - case 8: + case MENU_TYPE_AMMO1: + case MENU_TYPE_AMMO2: + case MENU_TYPE_AMMO3: ammo_active = 0; rings[RING_INVENTORY]->ringactive = 1; current_selected_option = 0; break; - case 3: + case MENU_TYPE_COMBINE: construct_combine_object_list(); rings[RING_INVENTORY]->ringactive = 0; rings[RING_AMMO]->ringactive = 1; @@ -3004,16 +3014,21 @@ void handle_inventry_menu() combine_ring_fade_dir = 1; break; - case 4: + case MENU_TYPE_SEPERATE: seperate_type_flag = 1; normal_ring_fade_dir = 2; break; - case 5: - case 1: + case MENU_TYPE_EQUIP: + case MENU_TYPE_USE: menu_active = 0; useItem = 1; break; + + case MENU_TYPE_DIARY: + GLOBAL_invMode = IM_DIARY; + Lara.Diary.currentPage = 1; + break; } } @@ -3657,8 +3672,11 @@ int S_CallInventory2() if (GLOBAL_invMode == IM_EXAMINE) do_examine_mode(); - DrawInv(); - draw_compass(); + if (GLOBAL_invMode == IM_DIARY) + do_diary(); + + DrawInv(); + draw_compass(); if (useItem & !TrInput) val = 1; @@ -3747,6 +3765,30 @@ void draw_compass() Matrix::CreateRotationY(compass_angle); } +void do_diary() +{ + GLOBAL_invMode = IM_DIARY; + + if (goRight && Lara.Diary.currentPage < Lara.Diary.numPages) + { + Lara.Diary.currentPage++; + SoundEffect(SFX_TR4_MENU_CHOOSE, 0, SFX_ALWAYS); + } + + if (goLeft && Lara.Diary.currentPage > 1) + { + Lara.Diary.currentPage--; + SoundEffect(SFX_TR4_MENU_CHOOSE, 0, SFX_ALWAYS); + } + + if (goDeselect) + { + SoundEffect(SFX_TR4_MENU_SELECT, 0, SFX_ALWAYS); + goDeselect = 0; + GLOBAL_invMode = IM_NONE; + } +} + void combine_revolver_lasersight(int flag) { if (flag) @@ -4264,3 +4306,4 @@ int do_special_waterskin_combine_bullshit(int flag) return 0; } +#endif \ No newline at end of file diff --git a/TR5Main/Game/newinv2.h b/TR5Main/Game/newinv2.h index 2255b3695..a0c91b1b3 100644 --- a/TR5Main/Game/newinv2.h +++ b/TR5Main/Game/newinv2.h @@ -1,3 +1,4 @@ +#ifdef NEW_INV #pragma once #include "configuration.h" #include @@ -42,6 +43,7 @@ int S_CallInventory2(); void do_stats_mode(); void do_examine_mode(); void draw_compass(); +void do_diary(); void combine_revolver_lasersight(int flag); void combine_crossbow_lasersight(int flag); void combine_HK_SILENCER(int flag); @@ -114,6 +116,24 @@ int do_special_waterskin_combine_bullshit(int flag); #define INV_RESULT_EXIT_TO_TILE 6 #define INV_RESULT_NEW_GAME_SELECTED_LEVEL 7 +enum menu_types +{ + nothing, + MENU_TYPE_USE, + MENU_TYPE_CHOOSEAMMO, + MENU_TYPE_COMBINE, + MENU_TYPE_SEPERATE, + MENU_TYPE_EQUIP, + MENU_TYPE_AMMO1, + MENU_TYPE_AMMO2, + MENU_TYPE_AMMO3, + MENU_TYPE_LOAD, + MENU_TYPE_SAVE, + MENU_TYPE_EXAMINE, + MENU_TYPE_STATS, + MENU_TYPE_DIARY +}; + enum item_options { OPT_ALWAYSCOMBINE = 1 << 0, @@ -133,7 +153,8 @@ enum item_options OPT_CHOOSEAMMO_HK = 1 << 14, OPT_STATS = 1 << 15, OPT_CHOOSEAMMO_HARPOON = 1 << 16, - OPT_CHOOSEAMMO_ROCKET = 1 << 17 + OPT_CHOOSEAMMO_ROCKET = 1 << 17, + OPT_DIARY = 1 << 18 }; enum rotflags @@ -215,6 +236,7 @@ enum inv_objects INV_OBJECT_BIG_WATERSKIN3L, INV_OBJECT_BIG_WATERSKIN4L, INV_OBJECT_BIG_WATERSKIN5L, + INV_OBJECT_OPEN_DIARY, // Puzzle, keys, pickups, examines INV_OBJECT_PUZZLE1, @@ -409,7 +431,8 @@ enum inv_modes IM_INGAME, IM_PAUSE, IM_STATS, - IM_EXAMINE + IM_EXAMINE, + IM_DIARY }; typedef struct titleSettings @@ -492,3 +515,4 @@ extern int GLOBAL_lastinvitem; extern int GLOBAL_enterinventory; extern RINGME* rings[2]; extern INVOBJ inventry_objects_list[]; +#endif \ No newline at end of file diff --git a/TR5Main/Objects/TR5/tr5_objects.cpp b/TR5Main/Objects/TR5/tr5_objects.cpp index 3d7436a54..15c47d2bd 100644 --- a/TR5Main/Objects/TR5/tr5_objects.cpp +++ b/TR5Main/Objects/TR5/tr5_objects.cpp @@ -1278,6 +1278,7 @@ static void StartPickup(OBJECT_INFO *obj) InitPickup(obj, ID_WATERSKIN1_EMPTY); InitPickup(obj, ID_WATERSKIN2_EMPTY); InitPickup(obj, ID_GOLDROSE_ITEM); + InitPickup(obj, ID_DIARY_ITEM); } static OBJECT_INFO *objToInit; diff --git a/TR5Main/Objects/objectslist.h b/TR5Main/Objects/objectslist.h index dbfc13e4d..1fa7498e5 100644 --- a/TR5Main/Objects/objectslist.h +++ b/TR5Main/Objects/objectslist.h @@ -737,6 +737,7 @@ typedef enum GAME_OBJECT_ID ID_MEMCARD_SAVE_INV_ITEM, ID_PC_LOAD_INV_ITEM, ID_PC_LOAD_SAVE_ITEM, + ID_OPEN_DIARY_ITEM, /* Inventory main objects */ ID_INVENTORY_PASSPORT = 1000, diff --git a/TR5Main/Renderer/Renderer11.h b/TR5Main/Renderer/Renderer11.h index 974e4ec04..8f2a21670 100644 --- a/TR5Main/Renderer/Renderer11.h +++ b/TR5Main/Renderer/Renderer11.h @@ -527,6 +527,7 @@ namespace T5M::Renderer void renderNewInventory(); void drawStatistics(); void drawExamines(); + void drawDiary(); void drawDebris(RenderView& view,bool transparent); void drawFullScreenImage(ID3D11ShaderResourceView* texture, float fade, ID3D11RenderTargetView* target, ID3D11DepthStencilView* depthTarget); void createBillboardMatrix(DirectX::SimpleMath::Matrix* out, DirectX::SimpleMath::Vector3* particlePos, DirectX::SimpleMath::Vector3* cameraPos, float rotation); diff --git a/TR5Main/Renderer/Renderer11Draw.cpp b/TR5Main/Renderer/Renderer11Draw.cpp index a760d5a25..8f6d130a6 100644 --- a/TR5Main/Renderer/Renderer11Draw.cpp +++ b/TR5Main/Renderer/Renderer11Draw.cpp @@ -1094,6 +1094,23 @@ namespace T5M::Renderer drawObjectOn2DPosition(400, 300, convert_invobj_to_obj(inv_item), xrot, yrot, zrot, obj->scale1); obj->scale1 = saved_scale; } + + void Renderer11::drawDiary() + { + INVOBJ* obj = &inventry_objects_list[INV_OBJECT_OPEN_DIARY]; + short currentPage = Lara.Diary.currentPage; + drawObjectOn2DPosition(400, 300, convert_invobj_to_obj(INV_OBJECT_OPEN_DIARY), obj->xrot, obj->yrot, obj->zrot, obj->scale1); + + for (int i = 0; i < MaxStringsPerPage; i++) + { + if (!Lara.Diary.Pages[Lara.Diary.currentPage].Strings[i].x && !Lara.Diary.Pages[Lara.Diary.currentPage].Strings[i].y && !Lara.Diary.Pages[Lara.Diary.currentPage].Strings[i].stringID) + break; + + drawString(Lara.Diary.Pages[currentPage].Strings[i].x, Lara.Diary.Pages[currentPage].Strings[i].y, g_GameFlow->GetString(Lara.Diary.Pages[currentPage].Strings[i].stringID), PRINTSTRING_COLOR_WHITE, 0); + } + + drawAllStrings(); + } #endif void Renderer11::renderInventoryScene(ID3D11RenderTargetView* target, ID3D11DepthStencilView* depthTarget, ID3D11ShaderResourceView* background) { @@ -1237,6 +1254,12 @@ namespace T5M::Renderer return; } + if (GLOBAL_invMode == IM_DIARY) + { + drawDiary(); + return; + } + #else for (int k = 0; k < NUM_INVENTORY_RINGS; k++) {