TombEngine/TR5Main/Game/inventory.cpp

3156 lines
78 KiB
C++
Raw Normal View History

2018-08-19 09:46:58 +02:00
#include "inventory.h"
#include "draw.h"
#include "control.h"
#include "larafire.h"
#include "sound.h"
#include "gameflow.h"
#include "sound.h"
#include "savegame.h"
#include "lara.h"
2018-08-19 09:46:58 +02:00
#include "..\Global\global.h"
#include "..\Specific\input.h"
#include "..\Specific\config.h"
#include "lara1gun.h"
#include "lara2gun.h"
2018-08-19 09:46:58 +02:00
Inventory* g_Inventory;
extern GameFlow* g_GameFlow;
extern LaraExtraInfo g_LaraExtra;
2018-08-19 09:46:58 +02:00
void CombinePuzzle1(__int32 action)
2018-08-19 09:46:58 +02:00
{
if (action == INV_COMBINE_COMBINE)
{
Lara.puzzleItems[0] = true;
Lara.puzzleItemsCombo &= (~(3 << 0));
}
else
{
Lara.puzzleItems[0] = false;
Lara.puzzleItemsCombo |= (3 << 0);
}
}
2018-08-19 09:46:58 +02:00
void CombinePuzzle2(__int32 action)
{
if (action == INV_COMBINE_COMBINE)
{
Lara.puzzleItems[1] = true;
Lara.puzzleItemsCombo &= (~(3 << 2));
}
else
{
Lara.puzzleItems[1] = false;
Lara.puzzleItemsCombo |= (3 << 2);
}
2018-08-19 09:46:58 +02:00
}
void CombinePuzzle3(__int32 action)
2018-08-19 09:46:58 +02:00
{
if (action == INV_COMBINE_COMBINE)
{
Lara.puzzleItems[2] = true;
Lara.puzzleItemsCombo &= (~(3 << 4));
}
else
{
Lara.puzzleItems[2] = false;
Lara.puzzleItemsCombo |= (3 << 4);
}
}
void CombinePuzzle4(__int32 action)
{
if (action == INV_COMBINE_COMBINE)
{
Lara.puzzleItems[3] = true;
Lara.puzzleItemsCombo &= (~(3 << 6));
}
else
{
Lara.puzzleItems[3] = false;
Lara.puzzleItemsCombo |= (3 << 6);
}
}
void CombinePuzzle5(__int32 action)
{
if (action == INV_COMBINE_COMBINE)
{
Lara.puzzleItems[4] = true;
Lara.puzzleItemsCombo &= (~(3 << 8));
}
else
{
Lara.puzzleItems[4] = false;
Lara.puzzleItemsCombo |= (3 << 8);
}
}
void CombinePuzzle6(__int32 action)
{
if (action == INV_COMBINE_COMBINE)
{
Lara.puzzleItems[5] = true;
Lara.puzzleItemsCombo &= (~(3 << 10));
}
else
{
Lara.puzzleItems[5] = false;
Lara.puzzleItemsCombo |= (3 << 10);
}
}
void CombinePuzzle7(__int32 action)
{
if (action == INV_COMBINE_COMBINE)
{
Lara.puzzleItems[6] = true;
Lara.puzzleItemsCombo &= (~(3 << 12));
}
else
{
Lara.puzzleItems[6] = false;
Lara.puzzleItemsCombo |= (3 << 12);
}
}
void CombinePuzzle8(__int32 action)
{
if (action == INV_COMBINE_COMBINE)
{
Lara.puzzleItems[7] = true;
Lara.puzzleItemsCombo &= (~(3 << 14));
}
else
{
Lara.puzzleItems[7] = false;
Lara.puzzleItemsCombo |= (3 << 14);
}
}
void CombineKey1(__int32 action)
{
if (action == INV_COMBINE_COMBINE)
{
Lara.keyItems |= (1<<0);
Lara.puzzleItemsCombo &= (~(3 << 0));
}
else
{
Lara.keyItems &= ~(1 << 0);
Lara.puzzleItemsCombo |= (3 << 0);
}
}
void CombineKey2(__int32 action)
{
if (action == INV_COMBINE_COMBINE)
{
Lara.keyItems |= (1 << 1);
Lara.puzzleItemsCombo &= (~(3 << 2));
}
else
{
Lara.keyItems &= ~(1 << 1);
Lara.puzzleItemsCombo |= (3 << 2);
}
}
void CombineKey3(__int32 action)
{
if (action == INV_COMBINE_COMBINE)
{
Lara.keyItems |= (1 << 2);
Lara.puzzleItemsCombo &= (~(3 << 4));
}
else
{
Lara.keyItems &= ~(1 << 2);
Lara.puzzleItemsCombo |= (3 << 4);
}
}
2018-08-19 09:46:58 +02:00
void CombineKey4(__int32 action)
{
if (action == INV_COMBINE_COMBINE)
{
Lara.keyItems |= (1 << 3);
Lara.puzzleItemsCombo &= (~(3 << 6));
}
else
2018-08-19 09:46:58 +02:00
{
Lara.keyItems &= ~(1 << 3);
Lara.puzzleItemsCombo |= (3 << 6);
2018-08-19 09:46:58 +02:00
}
}
2018-08-19 09:46:58 +02:00
void CombineKey5(__int32 action)
{
if (action == INV_COMBINE_COMBINE)
{
Lara.keyItems |= (1 << 4);
Lara.puzzleItemsCombo &= (~(3 << 8));
}
else
{
Lara.keyItems &= ~(1 << 4);
Lara.puzzleItemsCombo |= (3 << 8);
}
}
void CombineKey6(__int32 action)
{
if (action == INV_COMBINE_COMBINE)
{
Lara.keyItems |= (1 << 5);
Lara.puzzleItemsCombo &= (~(3 << 10));
}
else
{
Lara.keyItems &= ~(1 << 5);
Lara.puzzleItemsCombo |= (3 << 10);
}
}
void CombineKey7(__int32 action)
{
if (action == INV_COMBINE_COMBINE)
{
Lara.keyItems |= (1 << 6);
Lara.puzzleItemsCombo &= (~(3 << 12));
}
else
{
Lara.keyItems &= ~(1 << 6);
Lara.puzzleItemsCombo |= (3 << 12);
}
}
void CombineKey8(__int32 action)
{
if (action == INV_COMBINE_COMBINE)
{
Lara.keyItems |= (1 << 7);
Lara.puzzleItemsCombo &= (~(3 << 14));
}
else
{
Lara.keyItems &= ~(1 << 7);
Lara.puzzleItemsCombo |= (3 << 14);
}
}
void CombinePickup1(__int32 action)
{
if (action == INV_COMBINE_COMBINE)
{
Lara.pickupItems |= (1 << 0);
Lara.pickupItemsCombo &= (~(3 << 0));
}
else
{
Lara.pickupItems &= ~(1 << 0);
Lara.pickupItemsCombo |= (3 << 0);
}
}
void CombinePickup2(__int32 action)
{
if (action == INV_COMBINE_COMBINE)
{
Lara.pickupItems |= (1 << 1);
Lara.pickupItemsCombo &= (~(3 << 2));
}
else
{
Lara.pickupItems &= ~(1 << 1);
Lara.pickupItemsCombo |= (3 << 2);
}
}
void CombinePickup3(__int32 action)
{
if (action == INV_COMBINE_COMBINE)
{
Lara.pickupItems |= (1 << 2);
Lara.pickupItemsCombo &= (~(3 << 4));
}
else
{
Lara.pickupItems &= ~(1 << 2);
Lara.pickupItemsCombo |= (3 << 4);
}
}
void CombinePickup4(__int32 action)
{
if (action == INV_COMBINE_COMBINE)
{
Lara.pickupItems |= (1 << 3);
Lara.pickupItemsCombo &= (~(3 << 6));
}
else
{
Lara.pickupItems &= ~(1 << 3);
Lara.pickupItemsCombo |= (3 << 6);
}
}
void CombineRevolverLasersight(__int32 action)
{
if (action == INV_COMBINE_COMBINE)
{
2019-04-26 21:09:58 +02:00
Lara.laserSight = false;
g_LaraExtra.Weapons[WEAPON_REVOLVER].HasLasersight = true;
}
else
{
2019-04-26 21:09:58 +02:00
Lara.laserSight = true;
g_LaraExtra.Weapons[WEAPON_REVOLVER].HasLasersight = false;
}
if (Lara.gunStatus && Lara.gunType == WEAPON_REVOLVER)
{
UndrawPistolMeshRight(WEAPON_REVOLVER);
DrawPistolMeshes(WEAPON_REVOLVER);
}
}
void CombineCrossbowLasersight(__int32 action)
{
if (action == INV_COMBINE_COMBINE)
{
2019-04-26 21:09:58 +02:00
Lara.laserSight = false;
g_LaraExtra.Weapons[WEAPON_CROSSBOW].HasLasersight = true;
}
else
{
2019-04-26 21:09:58 +02:00
Lara.laserSight = true;
g_LaraExtra.Weapons[WEAPON_CROSSBOW].HasLasersight = false;
}
if (Lara.gunStatus && Lara.gunType == WEAPON_CROSSBOW)
{
UndrawShotgunMeshes(WEAPON_CROSSBOW);
DrawShotgunMeshes(WEAPON_CROSSBOW);
}
}
void Inject_Inventory()
{
}
Inventory::Inventory()
{
ZeroMemory(&m_objectsTable[0], sizeof(InventoryObjectDefinition) * INVENTORY_TABLE_SIZE);
// Create objects table
m_objectsTable[INV_OBJECT_UZIS] = InventoryObjectDefinition(ID_UZI_ITEM, STRING_INV_UZI, -1, 0);
m_objectsTable[INV_OBJECT_PISTOLS] = InventoryObjectDefinition(ID_PISTOLS_ITEM, STRING_INV_PISTOLS, -1, 0);
m_objectsTable[INV_OBJECT_SHOTGUN] = InventoryObjectDefinition(ID_SHOTGUN_ITEM, STRING_INV_SHOTGUN, -1, 0);
m_objectsTable[INV_OBJECT_REVOLVER] = InventoryObjectDefinition(ID_REVOLVER_ITEM, STRING_INV_REVOLVER, -1, 0);
m_objectsTable[INV_OBJECT_REVOLVER_LASER] = InventoryObjectDefinition(ID_REVOLVER_ITEM, STRING_INV_REVOLVER_LASER, -1, 0);
m_objectsTable[INV_OBJECT_HK] = InventoryObjectDefinition(ID_HK_ITEM, STRING_INV_HK, -1, 0);
m_objectsTable[INV_OBJECT_SHOTGUN_AMMO1] = InventoryObjectDefinition(ID_SHOTGUN_AMMO1_ITEM, STRING_INV_SHOTGUN_AMMO1, -1, 0);
m_objectsTable[INV_OBJECT_SHOTGUN_AMMO2] = InventoryObjectDefinition(ID_SHOTGUN_AMMO2_ITEM, STRING_INV_SHOTGUN_AMMO2, -1, 0);
m_objectsTable[INV_OBJECT_HK_AMMO1] = InventoryObjectDefinition(ID_HK_AMMO_ITEM, STRING_INV_HK_AMMO, -1, 0);
m_objectsTable[INV_OBJECT_REVOLVER_AMMO] = InventoryObjectDefinition(ID_REVOLVER_AMMO_ITEM, STRING_INV_REVOLVER_AMMO, -1, 0);
m_objectsTable[INV_OBJECT_UZI_AMMO] = InventoryObjectDefinition(ID_UZI_AMMO_ITEM, STRING_INV_UZI_AMMO, -1, 0);
m_objectsTable[INV_OBJECT_PISTOLS_AMMO] = InventoryObjectDefinition(ID_PISTOLS_AMMO_ITEM, STRING_INV_PISTOLS_AMMO, -1, 0);
m_objectsTable[INV_OBJECT_LASERSIGHT] = InventoryObjectDefinition(ID_LASERSIGHT_ITEM, STRING_INV_LASERSIGHT, -1, 0);
m_objectsTable[INV_OBJECT_SILENCER] = InventoryObjectDefinition(ID_SILENCER_ITEM, STRING_INV_SILENCER, -1, 0);
m_objectsTable[INV_OBJECT_LARGE_MEDIPACK] = InventoryObjectDefinition(ID_BIGMEDI_ITEM, STRING_INV_LARGE_MEDIPACK, -1, 0);
m_objectsTable[INV_OBJECT_SMALL_MEDIPACK] = InventoryObjectDefinition(ID_SMALLMEDI_ITEM, STRING_INV_SMALL_MEDIPACK, -1, 0);
m_objectsTable[INV_OBJECT_BINOCULARS] = InventoryObjectDefinition(ID_BINOCULARS_ITEM, STRING_INV_BINOCULARS, -1, 0);
m_objectsTable[INV_OBJECT_FLARES] = InventoryObjectDefinition(ID_FLARE_INV_ITEM, STRING_INV_FLARES, -1, 0);
m_objectsTable[INV_OBJECT_TIMEX] = InventoryObjectDefinition(ID_COMPASS_ITEM, STRING_INV_TIMEX, -1, 0);
m_objectsTable[INV_OBJECT_CROWBAR] = InventoryObjectDefinition(ID_CROWBAR_ITEM, STRING_INV_CROWBAR, -1, 0);
m_objectsTable[INV_OBJECT_GRENADE_LAUNCHER] = InventoryObjectDefinition(ID_GRENADE_ITEM, STRING_INV_GRENADE_LAUNCHER, -1, 0);
2018-11-21 09:34:01 +01:00
m_objectsTable[INV_OBJECT_GRENADE_AMMO1] = InventoryObjectDefinition(ID_GRENADE_AMMO1_ITEM, STRING_INV_GRENADE_AMMO1, -1, 0);
m_objectsTable[INV_OBJECT_GRENADE_AMMO2] = InventoryObjectDefinition(ID_GRENADE_AMMO2_ITEM, STRING_INV_GRENADE_AMMO2, -1, 0);
m_objectsTable[INV_OBJECT_GRENADE_AMMO3] = InventoryObjectDefinition(ID_GRENADE_AMMO3_ITEM, STRING_INV_GRENADE_AMMO3, -1, 0);
m_objectsTable[INV_OBJECT_HARPOON_GUN] = InventoryObjectDefinition(ID_HARPOON_ITEM, STRING_INV_HARPOON_GUN, -1, 0);
m_objectsTable[INV_OBJECT_HARPOON_AMMO] = InventoryObjectDefinition(ID_HARPOON_AMMO_ITEM, STRING_INV_HARPOON_AMMO, -1, 0);
m_objectsTable[INV_OBJECT_ROCKET_LAUNCHER] = InventoryObjectDefinition(ID_ROCKET_LAUNCHER_ITEM, STRING_INV_ROCKET_LAUNCHER, -1, 0);
m_objectsTable[INV_OBJECT_ROCKET_AMMO] = InventoryObjectDefinition(ID_ROCKET_LAUNCHER_AMMO_ITEM, STRING_INV_ROCKET_AMMO, -1, 0);
m_objectsTable[INV_OBJECT_CROSSBOW] = InventoryObjectDefinition(ID_CROSSBOW_ITEM, STRING_INV_CROSSBOW, -1, 0);
m_objectsTable[INV_OBJECT_CROSSBOW_LASER] = InventoryObjectDefinition(ID_CROSSBOW_ITEM, STRING_INV_CROSSBOW_LASER, -1, 0);
m_objectsTable[INV_OBJECT_CROSSBOW_AMMO1] = InventoryObjectDefinition(ID_CROSSBOW_AMMO1_ITEM, STRING_INV_CROSSBOW_AMMO1, -1, 0);
m_objectsTable[INV_OBJECT_CROSSBOW_AMMO2] = InventoryObjectDefinition(ID_CROSSBOW_AMMO2_ITEM, STRING_INV_CROSSBOW_AMMO2, -1, 0);
2018-11-21 09:34:01 +01:00
m_objectsTable[INV_OBJECT_CROSSBOW_AMMO3] = InventoryObjectDefinition(ID_CROSSBOW_AMMO3_ITEM, STRING_INV_CROSSBOW_AMMO3, -1, 0);
m_objectsTable[INV_OBJECT_PASSAPORT] = InventoryObjectDefinition(ID_INVENTORY_PASSPORT, STRING_INV_PASSPORT, -1, 0);
m_objectsTable[INV_OBJECT_KEYS] = InventoryObjectDefinition(ID_INVENTORY_KEYS, STRING_INV_CONTROLS, -1, 0);
m_objectsTable[INV_OBJECT_SUNGLASSES] = InventoryObjectDefinition(ID_INVENTORY_SUNGLASSES, STRING_INV_DISPLAY, -1, 0);
m_objectsTable[INV_OBJECT_POLAROID] = InventoryObjectDefinition(ID_INVENTORY_POLAROID, STRING_INV_LARA_HOME, -1, 0);
m_objectsTable[INV_OBJECT_HEADPHONES] = InventoryObjectDefinition(ID_INVENTORY_HEADPHONES, STRING_INV_SOUND, -1, 0);
2018-11-21 09:34:01 +01:00
m_objectsTable[INV_OBJECT_DIARY] = InventoryObjectDefinition(ID_DIARY, STRING_INV_DIARY, -1, 0);
2018-11-28 13:19:01 +01:00
m_objectsTable[INV_OBJECT_WATERSKIN1] = InventoryObjectDefinition(ID_WATERSKIN1_EMPTY, STRING_INV_WATERSKIN1_EMPTY, -1, 0);
m_objectsTable[INV_OBJECT_WATERSKIN2] = InventoryObjectDefinition(ID_WATERSKIN2_EMPTY, STRING_INV_WATERSKIN2_EMPTY, -1, 0);
// Add combinations
AddCombination(INV_OBJECT_PUZZLE1_COMBO1, INV_OBJECT_PUZZLE1_COMBO2, INV_OBJECT_PUZZLE1, CombinePuzzle1);
AddCombination(INV_OBJECT_PUZZLE2_COMBO1, INV_OBJECT_PUZZLE2_COMBO2, INV_OBJECT_PUZZLE2, CombinePuzzle2);
AddCombination(INV_OBJECT_PUZZLE3_COMBO1, INV_OBJECT_PUZZLE3_COMBO2, INV_OBJECT_PUZZLE3, CombinePuzzle3);
AddCombination(INV_OBJECT_PUZZLE4_COMBO1, INV_OBJECT_PUZZLE4_COMBO2, INV_OBJECT_PUZZLE4, CombinePuzzle4);
AddCombination(INV_OBJECT_PUZZLE5_COMBO1, INV_OBJECT_PUZZLE5_COMBO2, INV_OBJECT_PUZZLE5, CombinePuzzle5);
AddCombination(INV_OBJECT_PUZZLE6_COMBO1, INV_OBJECT_PUZZLE6_COMBO2, INV_OBJECT_PUZZLE6, CombinePuzzle6);
AddCombination(INV_OBJECT_PUZZLE7_COMBO1, INV_OBJECT_PUZZLE7_COMBO2, INV_OBJECT_PUZZLE7, CombinePuzzle7);
AddCombination(INV_OBJECT_PUZZLE8_COMBO1, INV_OBJECT_PUZZLE8_COMBO2, INV_OBJECT_PUZZLE8, CombinePuzzle8);
AddCombination(INV_OBJECT_KEY1_COMBO1, INV_OBJECT_KEY1_COMBO2, INV_OBJECT_KEY1, CombineKey1);
AddCombination(INV_OBJECT_KEY2_COMBO1, INV_OBJECT_KEY2_COMBO2, INV_OBJECT_KEY2, CombineKey2);
AddCombination(INV_OBJECT_KEY3_COMBO1, INV_OBJECT_KEY3_COMBO2, INV_OBJECT_KEY3, CombineKey3);
AddCombination(INV_OBJECT_KEY4_COMBO1, INV_OBJECT_KEY4_COMBO2, INV_OBJECT_KEY4, CombineKey4);
AddCombination(INV_OBJECT_KEY5_COMBO1, INV_OBJECT_KEY5_COMBO2, INV_OBJECT_KEY5, CombineKey5);
AddCombination(INV_OBJECT_KEY6_COMBO1, INV_OBJECT_KEY6_COMBO2, INV_OBJECT_KEY6, CombineKey6);
AddCombination(INV_OBJECT_KEY7_COMBO1, INV_OBJECT_KEY7_COMBO2, INV_OBJECT_KEY7, CombineKey7);
AddCombination(INV_OBJECT_KEY8_COMBO1, INV_OBJECT_KEY8_COMBO2, INV_OBJECT_KEY8, CombineKey8);
AddCombination(INV_OBJECT_PICKUP1_COMBO1, INV_OBJECT_PICKUP1_COMBO2, INV_OBJECT_PICKUP1, CombinePickup1);
AddCombination(INV_OBJECT_PICKUP2_COMBO1, INV_OBJECT_PICKUP2_COMBO2, INV_OBJECT_PICKUP2, CombinePickup2);
AddCombination(INV_OBJECT_PICKUP3_COMBO1, INV_OBJECT_PICKUP3_COMBO2, INV_OBJECT_PICKUP3, CombinePickup3);
AddCombination(INV_OBJECT_PICKUP4_COMBO1, INV_OBJECT_PICKUP4_COMBO2, INV_OBJECT_PICKUP4, CombinePickup4);
AddCombination(INV_OBJECT_REVOLVER, INV_OBJECT_LASERSIGHT, INV_OBJECT_REVOLVER_LASER, CombineRevolverLasersight);
AddCombination(INV_OBJECT_CROSSBOW, INV_OBJECT_LASERSIGHT, INV_OBJECT_CROSSBOW_LASER, CombineCrossbowLasersight);
m_rings[INV_RING_PUZZLES].y = -INV_RINGS_OFFSET;
m_rings[INV_RING_WEAPONS].y = 0;
m_rings[INV_RING_OPTIONS].y = INV_RINGS_OFFSET;
m_rings[INV_RING_CHOOSE_AMMO].y = 0;
m_rings[INV_RING_COMBINE].y = 0;
m_rings[INV_RING_PUZZLES].titleStringIndex = STRING_INV_TITLE_PUZZLES;
m_rings[INV_RING_WEAPONS].titleStringIndex = STRING_INV_TITLE_ITEMS;
m_rings[INV_RING_OPTIONS].titleStringIndex = STRING_INV_TITLE_SETTINGS;
m_rings[INV_RING_CHOOSE_AMMO].titleStringIndex = STRING_INV_TITLE_CHOOSE_AMMO;
m_rings[INV_RING_COMBINE].titleStringIndex = STRING_INV_TITLE_COMBINE;
2018-08-19 09:46:58 +02:00
}
Inventory::~Inventory()
{
}
InventoryRing* Inventory::GetRing(__int32 index)
{
return &m_rings[index];
}
__int32 Inventory::GetActiveRing()
{
return m_activeRing;
}
void Inventory::SetActiveRing(__int32 index)
{
m_activeRing = index;
}
void Inventory::InsertObject(__int32 ring, __int32 objectNumber)
{
m_rings[ring].objects[m_rings[ring].numObjects].inventoryObject = objectNumber;
m_rings[ring].numObjects++;
}
2019-04-26 21:09:58 +02:00
void Inventory::LoadObjects(bool isReload)
2018-08-19 09:46:58 +02:00
{
// Reset the objects in inventory
for (__int32 i = 0; i < NUM_INVENTORY_RINGS; i++)
{
m_rings[i].numObjects = 0;
m_rings[i].rotation = 0;
2018-08-19 09:46:58 +02:00
m_rings[i].currentObject = 0;
2019-04-26 21:09:58 +02:00
if (!isReload)
{
m_rings[i].focusState = INV_FOCUS_STATE_NONE;
}
2018-08-19 09:46:58 +02:00
for (__int32 j = 0; j < NUM_INVENTORY_OBJECTS_PER_RING; j++)
{
m_rings[i].objects[j].inventoryObject = -1;
m_rings[i].objects[j].rotation = 0;
m_rings[i].objects[j].scale = INV_OBJECTS_SCALE;
2018-08-19 09:46:58 +02:00
}
}
// DEBUG
{
g_LaraExtra.Weapons[WEAPON_SHOTGUN].Present = true;
g_LaraExtra.Weapons[WEAPON_SHOTGUN].Ammo[0] = 1000;
g_LaraExtra.Weapons[WEAPON_SHOTGUN].Ammo[1] = 1000;
g_LaraExtra.Weapons[WEAPON_SHOTGUN].SelectedAmmo = WEAPON_AMMO1;
g_LaraExtra.Weapons[WEAPON_REVOLVER].Present = true;
g_LaraExtra.Weapons[WEAPON_REVOLVER].Ammo[0] = 1000;
g_LaraExtra.Weapons[WEAPON_REVOLVER].SelectedAmmo = WEAPON_AMMO1;
Lara.laserSight = true;
2018-12-29 14:27:39 +01:00
/*g_LaraExtra.Weapons[WEAPON_CROSSBOW].Present = true;
2018-11-21 09:34:01 +01:00
g_LaraExtra.Weapons[WEAPON_CROSSBOW].Ammo[0] = 1000;
g_LaraExtra.Weapons[WEAPON_CROSSBOW].SelectedAmmo = WEAPON_AMMO1;
2018-11-21 09:34:01 +01:00
g_LaraExtra.Weapons[WEAPON_GRENADE_LAUNCHER].Present = true;
g_LaraExtra.Weapons[WEAPON_GRENADE_LAUNCHER].Ammo[0] = 1000;
g_LaraExtra.Weapons[WEAPON_GRENADE_LAUNCHER].SelectedAmmo = WEAPON_AMMO1;
g_LaraExtra.Weapons[WEAPON_HARPOON_GUN].Present = true;
2018-12-29 14:27:39 +01:00
g_LaraExtra.Weapons[WEAPON_HARPOON_GUN].Ammo[0] = 1000;*/
2018-08-19 09:46:58 +02:00
}
2018-08-19 09:46:58 +02:00
// Now fill the rings
2018-12-29 14:27:39 +01:00
if (g_GameFlow->GetLevel(CurrentLevel)->LaraType != LARA_DRAW_TYPE::LARA_YOUNG)
2018-08-19 09:46:58 +02:00
{
// Pistols
2018-11-21 09:34:01 +01:00
if (g_LaraExtra.Weapons[WEAPON_PISTOLS].Present)
2018-08-19 09:46:58 +02:00
InsertObject(INV_RING_WEAPONS, INV_OBJECT_PISTOLS);
// Uzi
2018-11-21 09:34:01 +01:00
if (g_LaraExtra.Weapons[WEAPON_UZI].Present)
2018-08-19 09:46:58 +02:00
InsertObject(INV_RING_WEAPONS, INV_OBJECT_UZIS);
2018-11-21 09:34:01 +01:00
else if (g_LaraExtra.Weapons[WEAPON_UZI].Ammo[0])
InsertObject(INV_RING_WEAPONS, INV_OBJECT_UZI_AMMO);
// Revolver
2018-11-21 09:34:01 +01:00
if (g_LaraExtra.Weapons[WEAPON_REVOLVER].Present)
2018-08-19 09:46:58 +02:00
{
2018-11-21 09:34:01 +01:00
if (g_LaraExtra.Weapons[WEAPON_REVOLVER].HasLasersight)
InsertObject(INV_RING_WEAPONS, INV_OBJECT_REVOLVER_LASER);
2018-08-19 09:46:58 +02:00
else
InsertObject(INV_RING_WEAPONS, INV_OBJECT_REVOLVER);
2018-08-19 09:46:58 +02:00
}
else
{
2018-11-21 09:34:01 +01:00
if (g_LaraExtra.Weapons[WEAPON_REVOLVER].Ammo[0])
InsertObject(INV_RING_WEAPONS, INV_OBJECT_REVOLVER_AMMO);
}
// Shotgun
2018-11-21 09:34:01 +01:00
if (g_LaraExtra.Weapons[WEAPON_SHOTGUN].Present)
2018-08-19 09:46:58 +02:00
{
InsertObject(INV_RING_WEAPONS, INV_OBJECT_SHOTGUN);
2018-08-19 09:46:58 +02:00
//if (Lara.shotgunTypeCarried & 0x10)
// CurrentShotGunAmmoType = 1;
}
else
{
2018-11-21 09:34:01 +01:00
if (g_LaraExtra.Weapons[WEAPON_SHOTGUN].Ammo[0])
InsertObject(INV_RING_WEAPONS, INV_OBJECT_SHOTGUN_AMMO1);
2018-11-21 09:34:01 +01:00
if (g_LaraExtra.Weapons[WEAPON_SHOTGUN].Ammo[1])
InsertObject(INV_RING_WEAPONS, INV_OBJECT_SHOTGUN_AMMO2);
2018-08-19 09:46:58 +02:00
}
// HK
2018-11-21 09:34:01 +01:00
if (g_LaraExtra.Weapons[WEAPON_HK].Present)
2018-08-19 09:46:58 +02:00
{
2018-11-21 09:34:01 +01:00
if (g_LaraExtra.Weapons[WEAPON_HK].HasSilencer)
InsertObject(INV_RING_WEAPONS, INV_OBJECT_HK_LASER);
2018-08-19 09:46:58 +02:00
else
InsertObject(INV_RING_WEAPONS, INV_OBJECT_HK);
}
2018-11-21 09:34:01 +01:00
else if (g_LaraExtra.Weapons[WEAPON_HK].Ammo[0])
InsertObject(INV_RING_WEAPONS, INV_OBJECT_HK_AMMO1);
// Crossbow
2018-11-21 09:34:01 +01:00
if (g_LaraExtra.Weapons[WEAPON_CROSSBOW].Present)
2018-08-19 09:46:58 +02:00
{
2018-11-21 09:34:01 +01:00
if (g_LaraExtra.Weapons[WEAPON_CROSSBOW].HasLasersight)
InsertObject(INV_RING_WEAPONS, INV_OBJECT_CROSSBOW_LASER);
else
InsertObject(INV_RING_WEAPONS, INV_OBJECT_CROSSBOW);
2018-08-19 09:46:58 +02:00
}
else
2018-08-19 09:46:58 +02:00
{
2018-11-21 09:34:01 +01:00
if (g_LaraExtra.Weapons[WEAPON_CROSSBOW].Ammo[0])
InsertObject(INV_RING_WEAPONS, INV_OBJECT_CROSSBOW_AMMO1);
2018-11-21 09:34:01 +01:00
if (g_LaraExtra.Weapons[WEAPON_CROSSBOW].Ammo[1])
InsertObject(INV_RING_WEAPONS, INV_OBJECT_CROSSBOW_AMMO2);
2018-11-21 09:34:01 +01:00
if (g_LaraExtra.Weapons[WEAPON_CROSSBOW].Ammo[2])
InsertObject(INV_RING_WEAPONS, INV_OBJECT_CROSSBOW_AMMO3);
2018-08-19 09:46:58 +02:00
}
// Grenade launcher
2018-11-21 09:34:01 +01:00
if (g_LaraExtra.Weapons[WEAPON_GRENADE_LAUNCHER].Present)
InsertObject(INV_RING_WEAPONS, INV_OBJECT_GRENADE_LAUNCHER);
2018-11-21 09:34:01 +01:00
else
{
if (g_LaraExtra.Weapons[WEAPON_GRENADE_LAUNCHER].Ammo[0])
InsertObject(INV_RING_WEAPONS, INV_OBJECT_GRENADE_AMMO1);
if (g_LaraExtra.Weapons[WEAPON_GRENADE_LAUNCHER].Ammo[1])
InsertObject(INV_RING_WEAPONS, INV_OBJECT_GRENADE_AMMO2);
if (g_LaraExtra.Weapons[WEAPON_GRENADE_LAUNCHER].Ammo[2])
InsertObject(INV_RING_WEAPONS, INV_OBJECT_GRENADE_AMMO3);
}
// Harpoon
if (g_LaraExtra.Weapons[WEAPON_HARPOON_GUN].Present)
InsertObject(INV_RING_WEAPONS, INV_OBJECT_HARPOON_GUN);
else if (g_LaraExtra.Weapons[WEAPON_HARPOON_GUN].Ammo[0])
InsertObject(INV_RING_WEAPONS, INV_OBJECT_HARPOON_AMMO);
// Rocket launcher
if (g_LaraExtra.Weapons[WEAPON_ROCKET_LAUNCHER].Present)
InsertObject(INV_RING_WEAPONS, INV_OBJECT_ROCKET_LAUNCHER);
else if (g_LaraExtra.Weapons[WEAPON_ROCKET_LAUNCHER].Ammo[0])
InsertObject(INV_RING_WEAPONS, INV_OBJECT_ROCKET_AMMO);
// Lasersight
2018-08-19 09:46:58 +02:00
if (Lara.laserSight)
InsertObject(INV_RING_WEAPONS, INV_OBJECT_LASERSIGHT);
2018-08-19 09:46:58 +02:00
// Silencer
2018-08-19 09:46:58 +02:00
if (Lara.silencer)
InsertObject(INV_RING_WEAPONS, INV_OBJECT_SILENCER);
2018-08-19 09:46:58 +02:00
// Binoculars
2018-08-19 09:46:58 +02:00
if (Lara.binoculars)
InsertObject(INV_RING_WEAPONS, INV_OBJECT_BINOCULARS);
2018-08-19 09:46:58 +02:00
// Flares
2018-08-19 09:46:58 +02:00
if (Lara.numFlares)
InsertObject(INV_RING_WEAPONS, INV_OBJECT_FLARES);
2018-08-19 09:46:58 +02:00
}
if (Lara.numSmallMedipack)
InsertObject(INV_RING_WEAPONS, INV_OBJECT_SMALL_MEDIPACK);
2018-08-19 09:46:58 +02:00
if (Lara.numLargeMedipack)
InsertObject(INV_RING_WEAPONS, INV_OBJECT_LARGE_MEDIPACK);
2018-08-19 09:46:58 +02:00
if (Lara.crowbar)
InsertObject(INV_RING_WEAPONS, INV_OBJECT_CROWBAR);
2018-08-19 09:46:58 +02:00
__int32 i = 0;
do
{
if (Lara.puzzleItems[i])
InsertObject(INV_RING_PUZZLES, i + INV_OBJECT_PUZZLE1);
2018-08-19 09:46:58 +02:00
i++;
} while (i < 8);
i = 0;
do
{
if ((1 << i) & Lara.puzzleItemsCombo)
InsertObject(INV_RING_PUZZLES, i + INV_OBJECT_PUZZLE1_COMBO1);
2018-08-19 09:46:58 +02:00
i++;
} while (i < 16);
i = 0;
do
{
if ((1 << i) & Lara.keyItems)
InsertObject(INV_RING_PUZZLES, i + INV_OBJECT_KEY1);
2018-08-19 09:46:58 +02:00
i++;
} while (i < 8);
i = 0;
do
{
if ((1 << i) & Lara.keyItemsCombo)
InsertObject(INV_RING_PUZZLES, i + INV_OBJECT_KEY1_COMBO1);
2018-08-19 09:46:58 +02:00
i++;
} while (i < 16);
i = 0;
do
{
if ((1 << i) & Lara.pickupItems)
InsertObject(INV_RING_PUZZLES, i + INV_OBJECT_PICKUP1);
2018-08-19 09:46:58 +02:00
i++;
} while (i < 4);
i = 0;
do
{
if ((1 << i) & Lara.pickupItemsCombo)
InsertObject(INV_RING_PUZZLES, i + INV_OBJECT_PICKUP1_COMBO1);
2018-08-19 09:46:58 +02:00
i++;
} while (i < 8);
if (Lara.examine1)
InsertObject(INV_RING_PUZZLES, INV_OBJECT_EXAMINE1);
2018-08-19 09:46:58 +02:00
if (Lara.examine2)
InsertObject(INV_RING_PUZZLES, INV_OBJECT_EXAMINE2);
2018-08-19 09:46:58 +02:00
if (Lara.examine3)
InsertObject(INV_RING_PUZZLES, INV_OBJECT_EXAMINE3);
if (Lara.wetcloth == 2)
InsertObject(INV_RING_PUZZLES, INV_OBJECT_WETCLOTH1);
if (Lara.wetcloth == 1)
InsertObject(INV_RING_PUZZLES, INV_OBJECT_WETCLOTH2);
if (Lara.bottle)
InsertObject(INV_RING_PUZZLES, INV_OBJECT_BOTTLE);
if (g_LaraExtra.Waterskin1.Present)
InsertObject(INV_RING_PUZZLES, INV_OBJECT_WATERSKIN1);
if (g_LaraExtra.Waterskin2.Present)
InsertObject(INV_RING_PUZZLES, INV_OBJECT_WATERSKIN2);
InventoryRing * ring = &m_rings[INV_RING_OPTIONS];
// Reset the objects in inventory
ring->numObjects = 0;
ring->rotation = 0;
ring->currentObject = 0;
ring->focusState = INV_FOCUS_STATE_NONE;
for (__int32 j = 0; j < NUM_INVENTORY_OBJECTS_PER_RING; j++)
{
ring->objects[j].inventoryObject = -1;
ring->objects[j].rotation = 0;
ring->objects[j].scale = 2.0f;
}
InsertObject(INV_RING_OPTIONS, INV_OBJECT_PASSAPORT);
InsertObject(INV_RING_OPTIONS, INV_OBJECT_SUNGLASSES);
InsertObject(INV_RING_OPTIONS, INV_OBJECT_HEADPHONES);
InsertObject(INV_RING_OPTIONS, INV_OBJECT_KEYS);
}
2019-04-26 21:09:58 +02:00
void Inventory::SelectObject(__int32 r, __int32 object, float scale)
{
if (object != -1)
{
InventoryRing* ring = &m_rings[r];
for (__int32 i = 0; i < ring->numObjects; i++)
{
if (ring->objects[i].inventoryObject == object)
{
ring->currentObject = i;
ring->objects[i].scale = scale;
break;
}
}
}
}
void Inventory::Initialise()
{
2019-04-26 21:09:58 +02:00
LoadObjects(false);
m_activeRing = INV_RING_WEAPONS;
m_type = INV_TYPE_GAME;
m_deltaMovement = 0;
m_movement = INV_MOVE_STOPPED;
m_type = INV_TYPE_GAME;
InventoryItemChosen = -1;
}
__int32 Inventory::DoInventory()
{
Initialise();
// If Lara is dead, then we can use only the passport
if (LaraItem->hitPoints <= 0 && CurrentLevel > 0)
{
m_rings[INV_RING_PUZZLES].draw = false;
m_rings[INV_RING_WEAPONS].draw = false;
m_rings[INV_RING_OPTIONS].draw = true;
m_rings[INV_RING_COMBINE].draw = false;
m_rings[INV_RING_CHOOSE_AMMO].draw = false;
m_activeRing = INV_RING_OPTIONS;
m_rings[m_activeRing].currentObject = 0;
__int32 passportResult = DoPassport();
// Fade out
g_Renderer->FadeOut();
for (__int32 i = 0; i < FADE_FRAMES_COUNT; i++)
{
g_Renderer->DrawInventory();
}
return passportResult;
}
m_rings[INV_RING_PUZZLES].draw = false;
m_rings[INV_RING_WEAPONS].draw = true;
m_rings[INV_RING_OPTIONS].draw = false;
m_rings[INV_RING_COMBINE].draw = false;
m_rings[INV_RING_CHOOSE_AMMO].draw = false;
m_activeRing = INV_RING_WEAPONS;
__int32 result = INV_RESULT_NONE;
g_Renderer->DumpGameScene();
OpenRing(m_activeRing, true);
while (!ResetFlag)
{
SetDebounce = true;
S_UpdateInput();
SetDebounce = false;
GameTimer++;
// Handle input
if (DbInput & IN_DESELECT)
{
SoundEffect(SFX_MENU_SELECT, NULL, 0);
// Exit from inventory
GlobalEnterInventory = -1;
result = INV_RESULT_NONE;
break;
}
else if (DbInput & IN_FORWARD &&
(m_activeRing == INV_RING_WEAPONS && m_rings[INV_RING_PUZZLES].numObjects != 0 ||
m_activeRing == INV_RING_OPTIONS))
{
SoundEffect(SFX_MENU_ROTATE, NULL, 0);
__int32 newRing = INV_RING_WEAPONS;
if (m_activeRing == INV_RING_WEAPONS)
newRing = INV_RING_PUZZLES;
else
newRing = INV_RING_WEAPONS;
SwitchRing(m_activeRing, newRing, -1);
m_activeRing = newRing;
m_movement = 0;
continue;
}
else if (DbInput & IN_BACK && (m_activeRing == INV_RING_PUZZLES || m_activeRing == INV_RING_WEAPONS))
{
SoundEffect(SFX_MENU_ROTATE, NULL, 0);
__int32 newRing = INV_RING_WEAPONS;
if (m_activeRing == INV_RING_WEAPONS)
newRing = INV_RING_OPTIONS;
else
newRing = INV_RING_WEAPONS;
SwitchRing(m_activeRing, newRing, 1);
m_activeRing = newRing;
m_movement = 0;
continue;
}
else if (DbInput & IN_LEFT)
{
SoundEffect(SFX_MENU_ROTATE, NULL, 0);
// Change object left
float deltaAngle = 360.0f / m_rings[m_activeRing].numObjects / INV_NUM_FRAMES_ROTATE;
m_rings[m_activeRing].rotation = 0;
for (__int32 i = 0; i < INV_NUM_FRAMES_ROTATE; i++)
{
m_rings[m_activeRing].rotation += deltaAngle;
g_Renderer->DrawInventory();
g_Renderer->SyncRenderer();
}
if (m_rings[m_activeRing].currentObject == m_rings[m_activeRing].numObjects - 1)
m_rings[m_activeRing].currentObject = 0;
else
m_rings[m_activeRing].currentObject++;
m_rings[m_activeRing].selectedIndex = INV_ACTION_USE;
m_rings[m_activeRing].rotation = 0;
}
else if (DbInput & IN_RIGHT)
{
SoundEffect(SFX_MENU_ROTATE, NULL, 0);
// Change object right
float deltaAngle = 360.0f / m_rings[m_activeRing].numObjects / INV_NUM_FRAMES_ROTATE;
m_rings[m_activeRing].rotation = 0;
for (__int32 i = 0; i < INV_NUM_FRAMES_ROTATE; i++)
{
m_rings[m_activeRing].rotation -= deltaAngle;
g_Renderer->DrawInventory();
g_Renderer->SyncRenderer();
}
if (m_rings[m_activeRing].currentObject == 0)
m_rings[m_activeRing].currentObject = m_rings[m_activeRing].numObjects - 1;
else
m_rings[m_activeRing].currentObject--;
m_rings[m_activeRing].selectedIndex = INV_ACTION_USE;
m_rings[m_activeRing].rotation = 0;
}
else if (DbInput & IN_SELECT)
{
// Handle action
if (m_activeRing == INV_RING_OPTIONS)
{
if (m_rings[INV_RING_OPTIONS].objects[m_rings[INV_RING_OPTIONS].currentObject].inventoryObject == INV_OBJECT_PASSAPORT)
{
__int32 passportResult = DoPassport();
if (passportResult == INV_RESULT_NEW_GAME ||
passportResult == INV_RESULT_EXIT_TO_TILE ||
passportResult == INV_RESULT_LOAD_GAME)
{
// Fade out
g_Renderer->FadeOut();
for (__int32 i = 0; i < FADE_FRAMES_COUNT; i++)
g_Renderer->DrawInventory();
return passportResult;
}
}
__int16 currentObject = m_rings[INV_RING_OPTIONS].objects[m_rings[INV_RING_OPTIONS].currentObject].inventoryObject;
if (currentObject == INV_OBJECT_KEYS)
DoControlsSettings();
if (currentObject == INV_OBJECT_SUNGLASSES)
DoGraphicsSettings();
if (currentObject == INV_OBJECT_HEADPHONES)
DoSoundSettings();
}
else if (m_activeRing == INV_RING_WEAPONS || m_activeRing == INV_RING_PUZZLES)
{
__int16 currentObject = m_rings[m_activeRing].objects[m_rings[m_activeRing].currentObject].inventoryObject;
__int32 result = INV_RESULT_NONE;
if (IsCurrentObjectPuzzle())
// Puzzles have Use, Combine, Separe
result = DoPuzzle();
else if (IsCurrentObjectWeapon())
// Weapons have Use, Select Ammo
result = DoWeapon();
else if (IsCurrentObjectExamine())
// Examines have just Examine
DoExamine();
else if (currentObject == INV_OBJECT_TIMEX)
// Do statistics
DoStatistics();
else
// All other objects have just Use
result = DoGenericObject();
// If an item is set to be used, then use it and close inventory
if (result == INV_RESULT_USE_ITEM)
{
UseCurrentItem();
// Exit from inventory
GlobalEnterInventory = -1;
result = INV_RESULT_USE_ITEM;
break;
}
}
}
g_Renderer->DrawInventory();
g_Renderer->SyncRenderer();
}
CloseRing(m_activeRing, true);
return result;
}
bool Inventory::IsCurrentObjectWeapon()
{
__int16 currentObject = m_rings[m_activeRing].objects[m_rings[m_activeRing].currentObject].inventoryObject;
return (currentObject == INV_OBJECT_PISTOLS || currentObject == INV_OBJECT_UZIS ||
currentObject == INV_OBJECT_REVOLVER_LASER || currentObject == INV_OBJECT_CROSSBOW_LASER ||
currentObject == INV_OBJECT_REVOLVER || currentObject == INV_OBJECT_SHOTGUN ||
currentObject == INV_OBJECT_HK || currentObject == INV_OBJECT_CROSSBOW ||
currentObject == INV_OBJECT_ROCKET_LAUNCHER || currentObject == INV_OBJECT_GRENADE_LAUNCHER ||
currentObject == INV_OBJECT_HARPOON_GUN);
}
bool Inventory::IsCurrentObjectPuzzle()
{
__int16 currentObject = m_rings[m_activeRing].objects[m_rings[m_activeRing].currentObject].inventoryObject;
return (currentObject >= INV_OBJECT_PUZZLE1 && currentObject <= INV_OBJECT_PICKUP4_COMBO2);
}
bool Inventory::IsCurrentObjectGeneric()
{
__int16 currentObject = m_rings[m_activeRing].objects[m_rings[m_activeRing].currentObject].inventoryObject;
return (!IsCurrentObjectPuzzle() && !IsCurrentObjectExamine() && !IsCurrentObjectWeapon() &&
currentObject != INV_OBJECT_TIMEX);
}
bool Inventory::IsCurrentObjectExamine()
{
__int16 currentObject = m_rings[m_activeRing].objects[m_rings[m_activeRing].currentObject].inventoryObject;
return (currentObject >= INV_OBJECT_EXAMINE1 && currentObject <= INV_OBJECT_EXAMINE1);
}
__int32 Inventory::DoPuzzle()
{
InventoryRing* ring = &m_rings[m_activeRing];
ring->frameIndex = 0;
return INV_RESULT_NONE;
}
__int32 Inventory::DoWeapon()
{
InventoryRing* ring = &m_rings[m_activeRing];
ring->frameIndex = 0;
ring->selectedIndex = 0;
ring->numActions = 0;
__int32 result = INV_RESULT_NONE;
bool closeObject = false;
__int16 currentObject = ring->objects[ring->currentObject].inventoryObject;
ring->actions[ring->numActions++] = INV_ACTION_USE;
if (IsObjectCombinable(currentObject)) ring->actions[ring->numActions++] = INV_ACTION_COMBINE;
if (IsObjectSeparable(currentObject)) ring->actions[ring->numActions++] = INV_ACTION_SEPARE;
if (HasWeaponMultipleAmmos(currentObject)) ring->actions[ring->numActions++] = INV_ACTION_SELECT_AMMO;
// If only use action then select the weapon directly
if (ring->numActions == 1)
return INV_RESULT_USE_ITEM;
PopupObject();
// Do the menu
while (true)
{
// Handle input
SetDebounce = true;
S_UpdateInput();
SetDebounce = false;
GameTimer++;
// Handle input
if (DbInput & IN_DESELECT || closeObject)
{
closeObject = true;
break;
}
else if (DbInput & IN_FORWARD)
{
closeObject = false;
SoundEffect(SFX_MENU_CHOOSE, NULL, 0);
if (ring->selectedIndex > 0)
ring->selectedIndex--;
}
else if (DbInput & IN_BACK)
{
closeObject = false;
SoundEffect(SFX_MENU_CHOOSE, NULL, 0);
if (ring->selectedIndex < ring->numActions)
ring->selectedIndex++;
}
else if (DbInput & IN_SELECT)
{
SoundEffect(SFX_MENU_SELECT, NULL, 0);
if (ring->actions[ring->selectedIndex] == INV_ACTION_USE)
{
result = INV_RESULT_USE_ITEM;
closeObject = true;
break;
}
else if (ring->actions[ring->selectedIndex] == INV_ACTION_COMBINE)
{
2019-04-26 21:09:58 +02:00
if (DoCombine())
{
ring->actions[1] = INV_ACTION_SEPARE;
}
}
else if (ring->actions[ring->selectedIndex] == INV_ACTION_SEPARE)
{
2019-04-26 21:09:58 +02:00
if (DoSepare())
{
ring->actions[1] = INV_ACTION_COMBINE;
}
}
else if (ring->actions[ring->selectedIndex] == INV_ACTION_SELECT_AMMO)
{
DoSelectAmmo();
}
}
g_Renderer->DrawInventory();
g_Renderer->SyncRenderer();
}
2018-08-19 09:46:58 +02:00
PopoverObject();
2018-08-19 09:46:58 +02:00
return result;
}
2018-08-19 09:46:58 +02:00
bool Inventory::IsObjectPresentInInventory(__int16 object)
{
for (__int32 r = 0; r < 3; r++)
for (__int32 o = 0; o < m_rings[r].numObjects; o++)
if (m_rings[r].objects[o].inventoryObject == object)
return true;
return false;
}
2018-08-19 09:46:58 +02:00
bool Inventory::IsObjectCombinable(__int16 object)
{
for (__int32 i = 0; i < m_combinations.size(); i++)
if (m_combinations[i].piece1 == object || m_combinations[i].piece2 == object)
return true;
return false;
}
2018-11-28 13:19:01 +01:00
void Inventory::AddCombination(__int16 piece1, __int16 piece2, __int16 combinedObject, void (*f) (__int32))
{
InventoryObjectCombination combination;
combination.piece1 = piece1;
combination.piece2 = piece2;
combination.combinedObject = combinedObject;
combination.combineRoutine = f;
m_combinations.push_back(combination);
}
2018-11-28 13:19:01 +01:00
__int32 Inventory::DoGenericObject()
{
InventoryRing* ring = &m_rings[m_activeRing];
ring->frameIndex = 0;
2018-08-19 09:46:58 +02:00
return INV_RESULT_USE_ITEM;
}
2018-08-19 09:46:58 +02:00
void Inventory::DoStatistics()
{
InventoryRing* ring = &m_rings[m_activeRing];
ring->frameIndex = 0;
2018-08-19 09:46:58 +02:00
}
void Inventory::DoExamine()
2018-08-19 09:46:58 +02:00
{
InventoryRing* ring = &m_rings[m_activeRing];
ring->frameIndex = 0;
}
2019-04-26 21:09:58 +02:00
bool Inventory::DoCombine()
{
InventoryRing* ring = &m_rings[m_activeRing];
2019-04-26 21:09:58 +02:00
__int32 oldRing = m_activeRing;
// Fill the objects ring
InventoryRing* combineRing = &m_rings[INV_RING_COMBINE];
combineRing->numObjects = 0;
__int16 currentObject = ring->objects[ring->currentObject].inventoryObject;
for (__int32 i = 0; i < m_combinations.size(); i++)
{
InventoryObjectCombination* combination = &m_combinations[i];
// Add piece 1
if (currentObject != combination->piece1 && IsObjectPresentInInventory(combination->piece1))
{
bool found = false;
for (__int32 j = 0; j < combineRing->numObjects; j++)
{
if (combineRing->objects[j].inventoryObject == combination->piece1)
{
found = true;
break;
}
}
if (!found)
combineRing->objects[combineRing->numObjects++].inventoryObject = combination->piece1;
}
2018-08-19 09:46:58 +02:00
// Add piece 2
if (currentObject != combination->piece2 && IsObjectPresentInInventory(combination->piece2))
{
bool found = false;
for (__int32 j = 0; j < combineRing->numObjects; j++)
{
if (combineRing->objects[j].inventoryObject == combination->piece2)
{
found = true;
break;
}
}
if (!found)
combineRing->objects[combineRing->numObjects++].inventoryObject = combination->piece2;
}
}
2018-08-19 09:46:58 +02:00
// If no objects then exit
if (combineRing->numObjects == 0)
{
2019-04-26 21:09:58 +02:00
return false;
}
ring->draw = false;
combineRing->draw = true;
combineRing->selectedIndex = 0;
2019-04-27 13:19:44 +02:00
OpenRing(INV_RING_COMBINE, false);
bool closeObject = false;
2019-04-26 21:09:58 +02:00
bool combined = false;
2018-08-19 09:46:58 +02:00
// Do the menu
while (true)
2018-08-19 09:46:58 +02:00
{
// Handle input
2018-08-19 09:46:58 +02:00
SetDebounce = true;
S_UpdateInput();
SetDebounce = false;
GameTimer++;
// Handle input
if (DbInput & IN_DESELECT || closeObject)
2018-08-19 09:46:58 +02:00
{
closeObject = true;
break;
2018-08-19 09:46:58 +02:00
}
else if (DbInput & IN_LEFT && combineRing->numObjects > 1)
2018-08-19 09:46:58 +02:00
{
closeObject = false;
SoundEffect(SFX_MENU_ROTATE, NULL, 0);
// Change object left
float deltaAngle = 360.0f / combineRing->numObjects / INV_NUM_FRAMES_ROTATE;
combineRing->rotation = 0;
for (__int32 i = 0; i < INV_NUM_FRAMES_ROTATE; i++)
2018-08-19 09:46:58 +02:00
{
combineRing->rotation += deltaAngle;
2018-08-19 09:46:58 +02:00
g_Renderer->DrawInventory();
g_Renderer->SyncRenderer();
}
if (combineRing->currentObject > 0)
combineRing->currentObject--;
2018-08-19 09:46:58 +02:00
else
combineRing->currentObject = combineRing->numObjects - 1;
2018-08-19 09:46:58 +02:00
combineRing->rotation = 0;
2018-08-19 09:46:58 +02:00
}
else if (DbInput & IN_RIGHT && combineRing->numObjects > 1)
2018-08-19 09:46:58 +02:00
{
closeObject = false;
// Change object right
float deltaAngle = 360.0f / combineRing->numObjects / INV_NUM_FRAMES_ROTATE;
combineRing->rotation = 0;
for (__int32 i = 0; i < INV_NUM_FRAMES_ROTATE; i++)
2018-08-19 09:46:58 +02:00
{
combineRing->rotation -= deltaAngle;
2018-08-19 09:46:58 +02:00
g_Renderer->DrawInventory();
g_Renderer->SyncRenderer();
}
SoundEffect(SFX_MENU_ROTATE, NULL, 0);
if (combineRing->currentObject < combineRing->numObjects - 1)
combineRing->currentObject++;
2018-08-19 09:46:58 +02:00
else
combineRing->currentObject = 0;
2018-08-19 09:46:58 +02:00
combineRing->rotation = 0;
}
else if (DbInput & IN_SELECT)
{
SoundEffect(SFX_MENU_SELECT, NULL, 0);
2018-08-19 09:46:58 +02:00
// Check if can be combined
__int16 currentObject = combineRing->objects[combineRing->currentObject].inventoryObject;
for (__int32 i = 0; i < m_combinations.size(); i++)
{
InventoryObjectCombination* combination = &m_combinations[i];
if (combination->piece1 == currentObject && combination->piece2 == ring->objects[ring->currentObject].inventoryObject ||
combination->piece2 == currentObject && combination->piece1 == ring->objects[ring->currentObject].inventoryObject)
{
// I can do the combination
SoundEffect(SFX_MENU_COMBINE, NULL, 0);
combination->combineRoutine(INV_COMBINE_COMBINE);
2019-04-26 21:09:58 +02:00
LoadObjects(true);
SelectObject(oldRing, combination->combinedObject, 2 * INV_OBJECTS_SCALE);
closeObject = true;
2019-04-26 21:09:58 +02:00
combined = true;
break;
}
}
if (!closeObject)
SayNo();
}
g_Renderer->DrawInventory();
g_Renderer->SyncRenderer();
}
2019-04-27 13:19:44 +02:00
CloseRing(INV_RING_COMBINE, false);
2019-04-26 21:09:58 +02:00
m_activeRing = oldRing;
combineRing->draw = false;
2019-04-27 13:19:44 +02:00
ring->draw = true;
2019-04-26 21:09:58 +02:00
return combined;
}
2019-04-26 21:09:58 +02:00
bool Inventory::DoSepare()
{
2019-04-26 21:09:58 +02:00
__int16 currentObject = m_rings[m_activeRing].objects[m_rings[m_activeRing].currentObject].inventoryObject;
for (__int32 i = 0; i < m_combinations.size(); i++)
{
InventoryObjectCombination* combination = &m_combinations[i];
if (combination->combinedObject == currentObject)
{
// Separation can be done
SoundEffect(SFX_MENU_COMBINE, NULL, 0);
combination->combineRoutine(INV_COMBINE_SEPARE);
2019-04-26 21:09:58 +02:00
LoadObjects(true);
SelectObject(m_activeRing, combination->piece1, 2 * INV_OBJECTS_SCALE);
2019-04-26 21:09:58 +02:00
return true;
}
}
2019-04-26 21:09:58 +02:00
return false;
}
void Inventory::DoSelectAmmo()
{
InventoryRing* ring = &m_rings[m_activeRing];
// Enable the secondary GUI
m_activeRing = INV_RING_CHOOSE_AMMO;
// Fill the secondary ring
InventoryRing* ammoRing = &m_rings[INV_RING_CHOOSE_AMMO];
2019-04-27 13:19:44 +02:00
ring->draw = false;
ammoRing->draw = true;
ammoRing->numObjects = 0;
switch (ring->objects[ring->currentObject].inventoryObject)
{
case INV_OBJECT_SHOTGUN:
if (g_LaraExtra.Weapons[WEAPON_SHOTGUN].Ammo[0] != 0)
ammoRing->objects[ammoRing->numObjects++].inventoryObject = INV_OBJECT_SHOTGUN_AMMO1;
if (g_LaraExtra.Weapons[WEAPON_SHOTGUN].Ammo[1] != 0)
ammoRing->objects[ammoRing->numObjects++].inventoryObject = INV_OBJECT_SHOTGUN_AMMO2;
ammoRing->selectedIndex = g_LaraExtra.Weapons[WEAPON_SHOTGUN].SelectedAmmo;
break;
case INV_OBJECT_GRENADE_LAUNCHER:
if (g_LaraExtra.Weapons[WEAPON_GRENADE_LAUNCHER].Ammo[0] != 0)
ammoRing->objects[ammoRing->numObjects++].inventoryObject = INV_OBJECT_GRENADE_AMMO1;
if (g_LaraExtra.Weapons[WEAPON_GRENADE_LAUNCHER].Ammo[1] != 0)
ammoRing->objects[ammoRing->numObjects++].inventoryObject = INV_OBJECT_GRENADE_AMMO2;
if (g_LaraExtra.Weapons[WEAPON_GRENADE_LAUNCHER].Ammo[2] != 0)
ammoRing->objects[ammoRing->numObjects++].inventoryObject = INV_OBJECT_GRENADE_AMMO3;
ammoRing->selectedIndex = g_LaraExtra.Weapons[WEAPON_GRENADE_LAUNCHER].SelectedAmmo;
break;
case INV_OBJECT_CROSSBOW:
case INV_OBJECT_CROSSBOW_LASER:
if (g_LaraExtra.Weapons[WEAPON_CROSSBOW].Ammo[0] != 0)
ammoRing->objects[ammoRing->numObjects++].inventoryObject = INV_OBJECT_CROSSBOW_AMMO1;
if (g_LaraExtra.Weapons[WEAPON_CROSSBOW].Ammo[1] != 0)
ammoRing->objects[ammoRing->numObjects++].inventoryObject = INV_OBJECT_CROSSBOW_AMMO2;
if (g_LaraExtra.Weapons[WEAPON_CROSSBOW].Ammo[2] != 0)
ammoRing->objects[ammoRing->numObjects++].inventoryObject = INV_OBJECT_CROSSBOW_AMMO3;
ammoRing->selectedIndex = g_LaraExtra.Weapons[WEAPON_CROSSBOW].SelectedAmmo;
break;
}
// If no objects then exit
if (ammoRing->numObjects == 0)
return;
2019-04-27 13:19:44 +02:00
OpenRing(INV_RING_CHOOSE_AMMO, false);
bool closeObject = false;
// Do the menu
while (true)
{
// Handle input
SetDebounce = true;
S_UpdateInput();
SetDebounce = false;
GameTimer++;
// Handle input
if (DbInput & IN_DESELECT || closeObject)
{
closeObject = true;
break;
2018-08-19 09:46:58 +02:00
}
else if (DbInput & IN_LEFT && ammoRing->numObjects > 1)
2018-08-19 09:46:58 +02:00
{
closeObject = false;
SoundEffect(SFX_MENU_ROTATE, NULL, 0);
// Change object left
float deltaAngle = 360.0f / ammoRing->numObjects / INV_NUM_FRAMES_ROTATE;
ammoRing->rotation = 0;
2018-08-19 09:46:58 +02:00
for (__int32 i = 0; i < INV_NUM_FRAMES_ROTATE; i++)
2018-08-19 09:46:58 +02:00
{
ammoRing->rotation += deltaAngle;
2018-08-19 09:46:58 +02:00
g_Renderer->DrawInventory();
g_Renderer->SyncRenderer();
}
if (ammoRing->currentObject > 0)
ammoRing->currentObject--;
2018-08-19 09:46:58 +02:00
else
ammoRing->currentObject = ammoRing->numObjects - 1;
2018-08-19 09:46:58 +02:00
ammoRing->rotation = 0;
2018-08-19 09:46:58 +02:00
}
else if (DbInput & IN_RIGHT && ammoRing->numObjects > 1)
2018-08-19 09:46:58 +02:00
{
closeObject = false;
// Change object right
float deltaAngle = 360.0f / ammoRing->numObjects / INV_NUM_FRAMES_ROTATE;
ammoRing->rotation = 0;
2018-08-19 09:46:58 +02:00
for (__int32 i = 0; i < INV_NUM_FRAMES_ROTATE; i++)
2018-08-19 09:46:58 +02:00
{
ammoRing->rotation -= deltaAngle;
2018-08-19 09:46:58 +02:00
g_Renderer->DrawInventory();
g_Renderer->SyncRenderer();
}
SoundEffect(SFX_MENU_ROTATE, NULL, 0);
if (ammoRing->currentObject < ammoRing->numObjects - 1)
ammoRing->currentObject++;
2018-08-19 09:46:58 +02:00
else
ammoRing->currentObject = 0;
2018-08-19 09:46:58 +02:00
ammoRing->rotation = 0;
2018-08-19 09:46:58 +02:00
}
else if (DbInput & IN_SELECT)
2018-08-19 09:46:58 +02:00
{
SoundEffect(SFX_MENU_SELECT, NULL, 0);
2018-09-07 18:34:18 +02:00
// Choose ammo
switch (ring->objects[ring->currentObject].inventoryObject)
{
case INV_OBJECT_SHOTGUN:
g_LaraExtra.Weapons[WEAPON_SHOTGUN].SelectedAmmo = ring->selectedIndex;
break;
2018-08-19 09:46:58 +02:00
case INV_OBJECT_GRENADE_LAUNCHER:
g_LaraExtra.Weapons[WEAPON_GRENADE_LAUNCHER].SelectedAmmo = ring->selectedIndex;
break;
2018-08-19 09:46:58 +02:00
case INV_OBJECT_CROSSBOW:
case INV_OBJECT_CROSSBOW_LASER:
g_LaraExtra.Weapons[WEAPON_CROSSBOW].SelectedAmmo = ring->selectedIndex;
break;
2018-08-19 09:46:58 +02:00
}
closeObject = true;
break;
2018-08-19 09:46:58 +02:00
}
g_Renderer->DrawInventory();
g_Renderer->SyncRenderer();
}
2019-04-27 13:19:44 +02:00
CloseRing(INV_RING_CHOOSE_AMMO, false);
// Reset secondary GUI
m_activeRing = INV_RING_WEAPONS;
ammoRing->draw = false;
2019-04-27 13:19:44 +02:00
ring->draw = true;
2018-08-19 09:46:58 +02:00
}
void Inventory::UseCurrentItem()
{
InventoryRing* ring = &m_rings[m_activeRing];
InventoryObject* inventoryObject = &ring->objects[ring->currentObject];
__int16 objectNumber = m_objectsTable[inventoryObject->inventoryObject].objectNumber;
LaraItem->meshBits = -1;
__int32 binocularRange = BinocularRange;
BinocularRange = 0;
OldLaraBusy = false;
2018-08-19 09:46:58 +02:00
// Small medipack
if (objectNumber == ID_SMALLMEDI_ITEM)
{
if ((LaraItem->hitPoints <= 0 || LaraItem->hitPoints >= 1000) && !Lara.poisoned)
{
SayNo();
return;
}
if (Lara.numSmallMedipack != -1)
Lara.numSmallMedipack--;
Lara.dpoisoned = 0;
LaraItem->hitPoints += 500;
if (LaraItem->hitPoints > 1000)
LaraItem->hitPoints = 1000;
SoundEffect(116, 0, 2);
Savegame.Game.HealthUsed++;
SoundEffect(SFX_MENU_MEDI, NULL, 0);
2018-08-19 09:46:58 +02:00
return;
}
// Big medipack
if (objectNumber == ID_BIGMEDI_ITEM)
{
if ((LaraItem->hitPoints <= 0 || LaraItem->hitPoints >= 1000) && !Lara.poisoned)
{
SayNo();
return;
}
if (Lara.numLargeMedipack != -1)
Lara.numLargeMedipack--;
Lara.dpoisoned = 0;
LaraItem->hitPoints += 1000;
if (LaraItem->hitPoints > 1000)
LaraItem->hitPoints = 1000;
SoundEffect(116, 0, 2);
Savegame.Game.HealthUsed++;
SoundEffect(SFX_MENU_MEDI, NULL, 0);
2018-08-19 09:46:58 +02:00
return;
}
// Binoculars
if (objectNumber == ID_BINOCULARS_ITEM)
{
if (LaraItem->currentAnimState == 2 && LaraItem->animNumber == 103 || Lara.isDucked && !(TrInput & 0x20000000))
{
if (!SniperCameraActive && !UseSpotCam && !TrackCameraInit)
{
OldLaraBusy = true;
BinocularRange = 128;
if (Lara.gunStatus)
Lara.gunStatus = LG_UNDRAW_GUNS;
}
}
if (binocularRange)
BinocularRange = binocularRange;
else
BinocularOldCamera = Camera.oldType;
return;
2018-08-19 09:46:58 +02:00
}
// Crowbar and puzzles
if (objectNumber == ID_CROWBAR_ITEM ||
objectNumber >= ID_PUZZLE_ITEM1 && objectNumber <= ID_PUZZLE_ITEM8 ||
objectNumber >= ID_PUZZLE_ITEM1_COMBO1 && objectNumber <= ID_PUZZLE_ITEM8_COMBO2 ||
objectNumber >= ID_KEY_ITEM1 && objectNumber <= ID_KEY_ITEM8 ||
objectNumber >= ID_KEY_ITEM1_COMBO1 && objectNumber <= ID_KEY_ITEM8_COMBO2 ||
objectNumber >= ID_PICKUP_ITEM1 && objectNumber <= ID_PICKUP_ITEM3 ||
objectNumber >= ID_PICKUP_ITEM1_COMBO1 && objectNumber <= ID_PICKUP_ITEM3_COMBO2)
{
// Only if above water
if (Lara.waterStatus == LW_ABOVE_WATER)
{
InventoryItemChosen = objectNumber;
SoundEffect(SFX_MENU_CHOOSE, NULL, 0);
2018-08-19 09:46:58 +02:00
return;
}
else
{
SayNo();
return;
}
}
// Flares
if (objectNumber == ID_FLARE_INV_ITEM)
{
if (Lara.waterStatus == LW_ABOVE_WATER)
{
InventoryItemChosen = objectNumber;
SoundEffect(SFX_MENU_CHOOSE, NULL, 0);
2018-08-19 09:46:58 +02:00
return;
}
else
{
SayNo();
return;
}
}
bool canUseWeapons = !(LaraItem->currentAnimState == STATE_LARA_CRAWL_IDLE ||
LaraItem->currentAnimState == STATE_LARA_CRAWL_FORWARD ||
LaraItem->currentAnimState == STATE_LARA_CRAWL_TURN_LEFT ||
LaraItem->currentAnimState == STATE_LARA_CRAWL_TURN_RIGHT ||
LaraItem->currentAnimState == STATE_LARA_CRAWL_BACK ||
LaraItem->currentAnimState == STATE_LARA_CRAWL_TO_CLIMB ||
LaraItem->currentAnimState == STATE_LARA_CROUCH_IDLE ||
LaraItem->currentAnimState == STATE_LARA_CROUCH_TURN_LEFT ||
LaraItem->currentAnimState == STATE_LARA_CROUCH_TURN_RIGHT ||
Lara.waterStatus != LW_ABOVE_WATER);
2018-08-19 09:46:58 +02:00
// Pistols
if (objectNumber == ID_PISTOLS_ITEM)
{
if (canUseWeapons)
{
Lara.requestGunType = WEAPON_PISTOLS;
if (!Lara.gunStatus && Lara.gunType == WEAPON_PISTOLS)
Lara.gunStatus = LG_DRAW_GUNS;
SoundEffect(SFX_MENU_CHOOSE, NULL, 0);
2018-08-19 09:46:58 +02:00
}
else
{
SayNo();
}
return;
2018-08-19 09:46:58 +02:00
}
// Uzis
if (objectNumber == ID_UZI_ITEM)
{
if (canUseWeapons)
{
Lara.requestGunType = WEAPON_UZI;
if (!Lara.gunStatus && Lara.gunType == WEAPON_UZI)
Lara.gunStatus = LG_DRAW_GUNS;
SoundEffect(SFX_MENU_CHOOSE, NULL, 0);
2018-08-19 09:46:58 +02:00
}
else
{
SayNo();
}
return;
2018-08-19 09:46:58 +02:00
}
// Revolver
if (objectNumber == ID_REVOLVER_ITEM)
{
if (canUseWeapons)
{
Lara.requestGunType = WEAPON_REVOLVER;
if (!Lara.gunStatus && Lara.gunType == WEAPON_REVOLVER)
Lara.gunStatus = LG_DRAW_GUNS;
SoundEffect(SFX_MENU_CHOOSE, NULL, 0);
2018-08-19 09:46:58 +02:00
}
else
{
SayNo();
}
return;
2018-08-19 09:46:58 +02:00
}
// Shotgun
if (objectNumber == ID_SHOTGUN_ITEM)
{
if (canUseWeapons)
{
Lara.requestGunType = WEAPON_SHOTGUN;
if (!Lara.gunStatus && Lara.gunType == WEAPON_SHOTGUN)
Lara.gunStatus = LG_DRAW_GUNS;
SoundEffect(SFX_MENU_CHOOSE, NULL, 0);
2018-08-19 09:46:58 +02:00
}
else
{
SayNo();
}
return;
2018-08-19 09:46:58 +02:00
}
// Grenade launcher
if (objectNumber == ID_GRENADE_ITEM)
{
if (canUseWeapons)
{
2018-11-21 09:34:01 +01:00
Lara.requestGunType = WEAPON_GRENADE_LAUNCHER;
if (!Lara.gunStatus && Lara.gunType == WEAPON_GRENADE_LAUNCHER)
Lara.gunStatus = LG_DRAW_GUNS;
SoundEffect(SFX_MENU_CHOOSE, NULL, 0);
}
else
{
SayNo();
}
return;
}
// Harpoon gun
if (objectNumber == ID_HARPOON_ITEM)
{
if (canUseWeapons)
{
Lara.requestGunType = WEAPON_HARPOON_GUN;
if (!Lara.gunStatus && Lara.gunType == WEAPON_HARPOON_GUN)
Lara.gunStatus = LG_DRAW_GUNS;
SoundEffect(SFX_MENU_CHOOSE, NULL, 0);
}
else
{
SayNo();
}
return;
}
2018-08-19 09:46:58 +02:00
// Crossbow/grappling gun
if (objectNumber == ID_CROSSBOW_ITEM)
{
if (canUseWeapons)
{
Lara.requestGunType = WEAPON_CROSSBOW;
if (!Lara.gunStatus && Lara.gunType == WEAPON_CROSSBOW)
Lara.gunStatus = LG_DRAW_GUNS;
SoundEffect(SFX_MENU_CHOOSE, NULL, 0);
2018-08-19 09:46:58 +02:00
}
else
{
SayNo();
}
return;
2018-08-19 09:46:58 +02:00
}
// HK
if (objectNumber == ID_HK_ITEM)
{
if (canUseWeapons)
{
Lara.requestGunType = WEAPON_HK;
if (!Lara.gunStatus && Lara.gunType == WEAPON_HK)
Lara.gunStatus = LG_DRAW_GUNS;
SoundEffect(SFX_MENU_CHOOSE, NULL, 0);
2018-08-19 09:46:58 +02:00
}
else
{
SayNo();
}
return;
2018-08-19 09:46:58 +02:00
}
// Flares
if (objectNumber == ID_FLARE_INV_ITEM)
{
if (!Lara.gunStatus)
{
if (LaraItem->currentAnimState != STATE_LARA_CRAWL_IDLE &&
LaraItem->currentAnimState != STATE_LARA_CRAWL_FORWARD &&
LaraItem->currentAnimState != STATE_LARA_CRAWL_TURN_LEFT &&
LaraItem->currentAnimState != STATE_LARA_CRAWL_TURN_RIGHT &&
LaraItem->currentAnimState != STATE_LARA_CRAWL_BACK &&
LaraItem->currentAnimState != STATE_LARA_CRAWL_TO_CLIMB &&
Lara.waterStatus == LW_ABOVE_WATER)
2018-08-19 09:46:58 +02:00
{
if (Lara.gunType != WEAPON_FLARE)
{
TrInput = 0x80000;
LaraGun();
TrInput = 0;
SoundEffect(SFX_MENU_CHOOSE, NULL, 0);
2018-08-19 09:46:58 +02:00
}
}
}
else
{
SayNo();
}
return;
2018-08-19 09:46:58 +02:00
}
SayNo();
return;
}
float Inventory::GetVerticalOffset()
{
return m_movement;
}
void Inventory::InitialiseTitle()
{
InventoryRing* ring = &m_rings[INV_RING_OPTIONS];
// Reset the objects in inventory
ring->numObjects = 0;
ring->rotation = 0;
2018-08-19 09:46:58 +02:00
ring->currentObject = 0;
ring->focusState = INV_FOCUS_STATE_NONE;
for (__int32 j = 0; j < NUM_INVENTORY_OBJECTS_PER_RING; j++)
{
ring->objects[j].inventoryObject = -1;
ring->objects[j].rotation = 0;
ring->objects[j].scale = INV_OBJECTS_SCALE;
2018-08-19 09:46:58 +02:00
}
InsertObject(INV_RING_OPTIONS, INV_OBJECT_PASSAPORT);
InsertObject(INV_RING_OPTIONS, INV_OBJECT_POLAROID);
InsertObject(INV_RING_OPTIONS, INV_OBJECT_SUNGLASSES);
InsertObject(INV_RING_OPTIONS, INV_OBJECT_HEADPHONES);
InsertObject(INV_RING_OPTIONS, INV_OBJECT_KEYS);
m_activeRing = INV_RING_OPTIONS;
m_deltaMovement = 0;
m_movement = INV_MOVE_STOPPED;
m_type = INV_TYPE_TITLE;
InventoryItemChosen = -1;
}
__int32 Inventory::DoTitleInventory()
2018-08-19 09:46:58 +02:00
{
InitialiseTitle();
m_rings[INV_RING_PUZZLES].draw = false;
m_rings[INV_RING_WEAPONS].draw = false;
m_rings[INV_RING_OPTIONS].draw = true;
InventoryRing* ring = &m_rings[INV_RING_OPTIONS];
m_activeRing = INV_RING_OPTIONS;
2018-09-07 18:34:18 +02:00
// Fade in
g_Renderer->FadeIn();
for (__int32 i = 0; i < FADE_FRAMES_COUNT; i++)
g_Renderer->DrawInventory();
2018-08-19 09:46:58 +02:00
OpenRing(INV_RING_OPTIONS, true);
__int32 result = INV_RESULT_NONE;
2018-08-19 09:46:58 +02:00
while (!ResetFlag)
{
SetDebounce = true;
S_UpdateInput();
SetDebounce = false;
GameTimer++;
// Handle input
if (DbInput & IN_LEFT)
2018-08-19 09:46:58 +02:00
{
SoundEffect(SFX_MENU_ROTATE, NULL, 0);
2018-08-19 09:46:58 +02:00
// Change object right
float deltaAngle = 360.0f / ring->numObjects / INV_NUM_FRAMES_ROTATE;
ring->rotation = 0;
2018-08-19 09:46:58 +02:00
for (__int32 i = 0; i < INV_NUM_FRAMES_ROTATE; i++)
2018-08-19 09:46:58 +02:00
{
ring->rotation += deltaAngle;
2018-08-19 09:46:58 +02:00
g_Renderer->DrawInventory();
g_Renderer->SyncRenderer();
}
if (ring->currentObject == ring->numObjects - 1)
ring->currentObject = 0;
else
ring->currentObject++;
ring->rotation = 0;
2018-08-19 09:46:58 +02:00
}
else if (DbInput & IN_RIGHT)
2018-08-19 09:46:58 +02:00
{
SoundEffect(SFX_MENU_ROTATE, NULL, 0);
2018-08-19 09:46:58 +02:00
// Change object left
float deltaAngle = 360.0f / ring->numObjects / INV_NUM_FRAMES_ROTATE;
ring->rotation = 0;
2018-08-19 09:46:58 +02:00
for (__int32 i = 0; i < INV_NUM_FRAMES_ROTATE; i++)
2018-08-19 09:46:58 +02:00
{
ring->rotation -= deltaAngle;
2018-08-19 09:46:58 +02:00
g_Renderer->DrawInventory();
g_Renderer->SyncRenderer();
}
if (ring->currentObject == 0)
ring->currentObject = ring->numObjects - 1;
else
ring->currentObject--;
ring->rotation = 0;
2018-08-19 09:46:58 +02:00
}
else if (DbInput & IN_SELECT)
2018-08-19 09:46:58 +02:00
{
SoundEffect(SFX_MENU_SELECT, NULL, 0);
2018-08-19 09:46:58 +02:00
if (ring->objects[ring->currentObject].inventoryObject == INV_OBJECT_PASSAPORT)
{
__int32 passportResult = DoPassport();
if (passportResult == INV_RESULT_NEW_GAME ||
passportResult == INV_RESULT_EXIT_GAME ||
passportResult == INV_RESULT_LOAD_GAME)
{
2019-04-27 13:19:44 +02:00
result = passportResult;
break;
}
}
2018-08-19 09:46:58 +02:00
2018-09-07 18:34:18 +02:00
if (ring->objects[ring->currentObject].inventoryObject == INV_OBJECT_KEYS)
DoControlsSettings();
2018-08-19 09:46:58 +02:00
2018-09-07 18:34:18 +02:00
if (ring->objects[ring->currentObject].inventoryObject == INV_OBJECT_SUNGLASSES)
DoGraphicsSettings();
2018-08-19 09:46:58 +02:00
2018-09-07 18:34:18 +02:00
if (ring->objects[ring->currentObject].inventoryObject == INV_OBJECT_HEADPHONES)
DoSoundSettings();
2018-08-19 09:46:58 +02:00
}
g_Renderer->DrawInventory();
g_Renderer->SyncRenderer();
}
CloseRing(INV_RING_OPTIONS, true);
2018-09-07 18:34:18 +02:00
// Fade out
g_Renderer->FadeOut();
for (__int32 i = 0; i < FADE_FRAMES_COUNT; i++)
g_Renderer->DrawInventory();
return result;
2018-08-19 09:46:58 +02:00
}
InventoryObjectDefinition* Inventory::GetInventoryObject(__int32 index)
{
return &m_objectsTable[index];
}
__int32 Inventory::DoPassport()
2018-08-19 09:46:58 +02:00
{
InventoryRing* ring = &m_rings[m_activeRing];
ring->frameIndex = 0;
__int16 choice = 0;
vector<__int32> choices;
if (m_type == INV_TYPE_TITLE)
{
choices.push_back(INV_WHAT_PASSPORT_NEW_GAME);
choices.push_back(INV_WHAT_PASSPORT_SELECT_LEVEL);
2018-08-19 09:46:58 +02:00
choices.push_back(INV_WHAT_PASSPORT_LOAD_GAME);
choices.push_back(INV_WHAT_PASSPORT_EXIT_GAME);
}
else
{
choices.push_back(INV_WHAT_PASSPORT_NEW_GAME);
choices.push_back(INV_WHAT_PASSPORT_LOAD_GAME);
if (LaraItem->hitPoints > 0 || CurrentLevel == 0)
choices.push_back(INV_WHAT_PASSPORT_SAVE_GAME);
2018-08-19 09:46:58 +02:00
choices.push_back(INV_WHAT_PASSPORT_EXIT_TO_TITLE);
}
ring->passportAction = choices[0];
PopupObject();
// Open the passport
for (__int32 i = 0; i < 14; i++)
{
g_Renderer->DrawInventory();
g_Renderer->SyncRenderer();
ring->frameIndex++;
}
bool moveLeft = false;
bool moveRight = false;
bool closePassport = false;
__int32 result = INV_RESULT_NONE;
2018-08-19 09:46:58 +02:00
// Do the passport
while (true)
{
// Handle input
SetDebounce = true;
S_UpdateInput();
SetDebounce = false;
GameTimer++;
// Handle input
if (DbInput & IN_DESELECT || closePassport)
2018-08-19 09:46:58 +02:00
{
moveLeft = false;
moveRight = false;
closePassport = false;
break;
}
else if (DbInput & IN_LEFT || moveLeft)
2018-08-19 09:46:58 +02:00
{
moveLeft = false;
moveRight = false;
closePassport = false;
if (choice > 0)
{
ring->frameIndex = 19;
for (__int32 i = 0; i < 5; i++)
{
g_Renderer->DrawInventory();
g_Renderer->SyncRenderer();
ring->frameIndex--;
}
choice--;
}
}
else if (DbInput & IN_RIGHT || moveRight)
2018-08-19 09:46:58 +02:00
{
moveLeft = false;
moveRight = false;
closePassport = false;
2018-08-19 09:46:58 +02:00
if (choice < choices.size() - 1)
{
ring->frameIndex = 14;
for (__int32 i = 0; i < 5; i++)
{
g_Renderer->DrawInventory();
g_Renderer->SyncRenderer();
ring->frameIndex++;
}
choice++;
}
}
if (choices[choice] == INV_WHAT_PASSPORT_LOAD_GAME)
{
// Load game
__int32 selectedSavegame = 0;
while (true)
{
SetDebounce = 1;
S_UpdateInput();
SetDebounce = 0;
// Process input
if (DbInput & IN_DESELECT)
2018-08-19 09:46:58 +02:00
{
if (CurrentLevel == 0 || LaraItem->hitPoints > 0)
{
moveLeft = false;
moveRight = false;
closePassport = true;
}
2018-08-19 09:46:58 +02:00
break;
}
else if (DbInput & IN_FORWARD && selectedSavegame > 0)
2018-08-19 09:46:58 +02:00
{
SoundEffect(SFX_MENU_CHOOSE, NULL, 0);
2018-08-19 09:46:58 +02:00
selectedSavegame--;
continue;
}
else if (DbInput & IN_BACK && selectedSavegame < MAX_SAVEGAMES - 1)
2018-08-19 09:46:58 +02:00
{
SoundEffect(SFX_MENU_CHOOSE, NULL, 0);
2018-08-19 09:46:58 +02:00
selectedSavegame++;
continue;
}
else if (DbInput & IN_LEFT)
2018-08-19 09:46:58 +02:00
{
moveLeft = true;
moveRight = false;
closePassport = false;
break;
}
else if (DbInput & IN_RIGHT)
2018-08-19 09:46:58 +02:00
{
moveLeft = false;
moveRight = true;
closePassport = false;
break;
}
else if (DbInput & IN_SELECT)
2018-08-19 09:46:58 +02:00
{
SoundEffect(SFX_MENU_SELECT, NULL, 0);
2018-10-24 23:32:22 +02:00
//ReadSavegame(selectedSavegame);
g_GameFlow->SelectedSaveGame = selectedSavegame;
result = INV_RESULT_LOAD_GAME;
moveLeft = false;
moveRight = false;
closePassport = true;
break;
2018-08-19 09:46:58 +02:00
}
ring->selectedIndex = selectedSavegame;
ring->passportAction = INV_WHAT_PASSPORT_LOAD_GAME;
LoadSavegameInfos();
g_Renderer->DrawInventory();
g_Renderer->SyncRenderer();
}
}
else if (choices[choice] == INV_WHAT_PASSPORT_SAVE_GAME)
{
// Save game
__int32 selectedSavegame = 0;
while (true)
{
SetDebounce = 1;
S_UpdateInput();
SetDebounce = 0;
// Process input
if (DbInput & IN_DESELECT)
2018-08-19 09:46:58 +02:00
{
if (CurrentLevel == 0 || LaraItem->hitPoints > 0)
{
moveLeft = false;
moveRight = false;
closePassport = true;
}
2018-08-19 09:46:58 +02:00
break;
}
else if (DbInput & IN_FORWARD && selectedSavegame > 0)
2018-08-19 09:46:58 +02:00
{
SoundEffect(SFX_MENU_CHOOSE, NULL, 0);
2018-08-19 09:46:58 +02:00
selectedSavegame--;
continue;
}
else if (DbInput & IN_BACK && selectedSavegame < MAX_SAVEGAMES - 1)
2018-08-19 09:46:58 +02:00
{
SoundEffect(SFX_MENU_CHOOSE, NULL, 0);
2018-08-19 09:46:58 +02:00
selectedSavegame++;
continue;
}
else if (DbInput & IN_LEFT)
2018-08-19 09:46:58 +02:00
{
moveLeft = true;
moveRight = false;
closePassport = false;
break;
}
else if (DbInput & IN_RIGHT)
2018-08-19 09:46:58 +02:00
{
moveLeft = false;
moveRight = true;
closePassport = false;
break;
}
else if (DbInput & IN_SELECT)
2018-08-19 09:46:58 +02:00
{
SoundEffect(SFX_MENU_SELECT, NULL, 0);
2018-10-09 00:02:14 +02:00
// Use the new savegame system
char fileName[255];
ZeroMemory(fileName, 255);
sprintf(fileName, "savegame.%d", selectedSavegame);
SaveGame::Save(fileName);
moveLeft = false;
moveRight = false;
closePassport = true;
break;
2018-08-19 09:46:58 +02:00
}
ring->selectedIndex = selectedSavegame;
ring->passportAction = INV_WHAT_PASSPORT_SAVE_GAME;
LoadSavegameInfos();
g_Renderer->DrawInventory();
g_Renderer->SyncRenderer();
}
}
else if (choices[choice] == INV_WHAT_PASSPORT_SELECT_LEVEL)
{
// Save game
__int32 selectedLevel = 0;
while (true)
{
SetDebounce = 1;
S_UpdateInput();
SetDebounce = 0;
// Process input
if (DbInput & IN_DESELECT)
{
if (CurrentLevel == 0 || LaraItem->hitPoints > 0)
{
moveLeft = false;
moveRight = false;
closePassport = true;
}
break;
}
else if (DbInput & IN_FORWARD && selectedLevel > 0)
{
SoundEffect(SFX_MENU_CHOOSE, NULL, 0);
selectedLevel--;
continue;
}
else if (DbInput & IN_BACK && selectedLevel < g_GameFlow->GetNumLevels() - 1)
{
SoundEffect(SFX_MENU_CHOOSE, NULL, 0);
selectedLevel++;
continue;
}
else if (DbInput & IN_LEFT)
{
moveLeft = true;
moveRight = false;
closePassport = false;
break;
}
else if (DbInput & IN_RIGHT)
{
moveLeft = false;
moveRight = true;
closePassport = false;
break;
}
else if (DbInput & IN_SELECT)
{
SoundEffect(SFX_MENU_SELECT, NULL, 0);
result = INV_RESULT_NEW_GAME;
g_GameFlow->SelectedLevelForNewGame = selectedLevel + 1;
moveLeft = false;
moveRight = false;
closePassport = true;
break;
}
ring->selectedIndex = selectedLevel;
ring->passportAction = INV_WHAT_PASSPORT_SELECT_LEVEL;
g_Renderer->DrawInventory();
g_Renderer->SyncRenderer();
}
}
2018-08-19 09:46:58 +02:00
else if (choices[choice] == INV_WHAT_PASSPORT_NEW_GAME)
{
// New game
while (true)
{
SetDebounce = 1;
S_UpdateInput();
SetDebounce = 0;
// Process input
if (DbInput & IN_DESELECT)
2018-08-19 09:46:58 +02:00
{
if (CurrentLevel == 0 || LaraItem->hitPoints > 0)
{
moveLeft = false;
moveRight = false;
closePassport = true;
}
2018-08-19 09:46:58 +02:00
break;
}
else if (DbInput & IN_LEFT)
2018-08-19 09:46:58 +02:00
{
moveLeft = true;
moveRight = false;
closePassport = false;
break;
}
else if (DbInput & IN_RIGHT)
2018-08-19 09:46:58 +02:00
{
moveLeft = false;
moveRight = true;
closePassport = false;
break;
}
else if (DbInput & IN_SELECT)
2018-08-19 09:46:58 +02:00
{
SoundEffect(SFX_MENU_SELECT, NULL, 0);
result = INV_RESULT_NEW_GAME;
moveLeft = false;
moveRight = false;
closePassport = true;
break;
2018-08-19 09:46:58 +02:00
}
ring->passportAction = INV_WHAT_PASSPORT_NEW_GAME;
g_Renderer->DrawInventory();
g_Renderer->SyncRenderer();
}
}
else if (choices[choice] == INV_WHAT_PASSPORT_EXIT_GAME)
{
// Exit game
while (true)
{
SetDebounce = 1;
S_UpdateInput();
SetDebounce = 0;
// Process input
if (DbInput & IN_DESELECT)
2018-08-19 09:46:58 +02:00
{
if (CurrentLevel == 0 || LaraItem->hitPoints > 0)
{
moveLeft = false;
moveRight = false;
closePassport = true;
}
2018-08-19 09:46:58 +02:00
break;
}
else if (DbInput & IN_LEFT)
2018-08-19 09:46:58 +02:00
{
moveLeft = true;
moveRight = false;
closePassport = false;
break;
}
else if (DbInput & IN_RIGHT)
2018-08-19 09:46:58 +02:00
{
moveLeft = false;
moveRight = true;
closePassport = false;
break;
}
else if (DbInput & IN_SELECT)
2018-08-19 09:46:58 +02:00
{
SoundEffect(SFX_MENU_SELECT, NULL, 0);
result = INV_RESULT_EXIT_GAME;
moveLeft = false;
moveRight = false;
closePassport = true;
break;
2018-08-19 09:46:58 +02:00
}
ring->passportAction = INV_WHAT_PASSPORT_EXIT_GAME;
g_Renderer->DrawInventory();
g_Renderer->SyncRenderer();
}
}
else if (choices[choice] == INV_WHAT_PASSPORT_EXIT_TO_TITLE)
{
// Exit game
while (true)
{
SetDebounce = 1;
S_UpdateInput();
SetDebounce = 0;
// Process input
if (DbInput & IN_DESELECT)
2018-08-19 09:46:58 +02:00
{
if (CurrentLevel == 0 || LaraItem->hitPoints > 0)
{
moveLeft = false;
moveRight = false;
closePassport = true;
}
2018-08-19 09:46:58 +02:00
break;
}
else if (DbInput & IN_LEFT)
2018-08-19 09:46:58 +02:00
{
moveLeft = true;
moveRight = false;
closePassport = false;
break;
}
else if (DbInput & IN_RIGHT)
2018-08-19 09:46:58 +02:00
{
moveLeft = false;
moveRight = true;
closePassport = false;
break;
}
else if (DbInput & IN_SELECT)
2018-08-19 09:46:58 +02:00
{
SoundEffect(SFX_MENU_SELECT, NULL, 0);
result = INV_RESULT_EXIT_TO_TILE;
moveLeft = false;
moveRight = false;
closePassport = true;
break;
2018-08-19 09:46:58 +02:00
}
ring->passportAction = INV_WHAT_PASSPORT_EXIT_TO_TITLE;
g_Renderer->DrawInventory();
g_Renderer->SyncRenderer();
}
}
else
{
g_Renderer->DrawInventory();
g_Renderer->SyncRenderer();
}
}
// Close the passport
ring->frameIndex = 24;
for (__int32 i = 24; i < 30; i++)
{
g_Renderer->DrawInventory();
g_Renderer->SyncRenderer();
ring->frameIndex++;
}
ring->frameIndex = 0;
PopoverObject();
return result;
2018-08-19 09:46:58 +02:00
}
__int32 Inventory::PopupObject()
{
InventoryRing* ring = &m_rings[m_activeRing];
__int32 steps = INV_NUM_FRAMES_POPUP;
2018-08-19 09:46:58 +02:00
__int32 deltaAngle = (0 - ring->objects[ring->currentObject].rotation) / steps;
float deltaScale = INV_OBJECTS_SCALE / (float)steps;
2018-08-19 09:46:58 +02:00
ring->focusState = INV_FOCUS_STATE_POPUP;
for (__int32 i = 0; i < steps; i++)
{
g_Renderer->DrawInventory();
g_Renderer->SyncRenderer();
ring->objects[ring->currentObject].rotation += deltaAngle;
ring->objects[ring->currentObject].scale += deltaScale;
}
ring->focusState = INV_FOCUS_STATE_FOCUSED;
return 0;
}
__int32 Inventory::PopoverObject()
{
InventoryRing* ring = &m_rings[m_activeRing];
__int32 steps = INV_NUM_FRAMES_POPUP;
2018-08-19 09:46:58 +02:00
__int32 deltaAngle = (0 - ring->objects[ring->currentObject].rotation) / steps;
float deltaScale = INV_OBJECTS_SCALE / (float)steps;
2018-08-19 09:46:58 +02:00
ring->focusState = INV_FOCUS_STATE_POPOVER;
for (__int32 i = 0; i < steps; i++)
{
g_Renderer->DrawInventory();
g_Renderer->SyncRenderer();
ring->objects[ring->currentObject].rotation -= deltaAngle;
ring->objects[ring->currentObject].scale -= deltaScale;
}
ring->focusState = INV_FOCUS_STATE_NONE;
return 0;
}
__int32 Inventory::GetType()
{
return m_type;
2018-09-07 18:34:18 +02:00
}
void Inventory::DoControlsSettings()
{
InventoryRing* ring = &m_rings[m_activeRing];
ring->frameIndex = 0;
ring->selectedIndex = 0;
ring->waitingForKey = false;
2019-04-29 13:10:58 +02:00
PopupObject();
bool closeObject = false;
2019-04-29 13:10:58 +02:00
// Copy configuration to a temporary object
memcpy(&ring->Configuration.KeyboardLayout, &KeyboardLayout1, NUM_CONTROLS);
// Do the passport
while (true)
{
// Handle input
SetDebounce = true;
S_UpdateInput();
SetDebounce = false;
2018-09-07 18:34:18 +02:00
GameTimer++;
// Handle input
if (DbInput & IN_DESELECT || closeObject)
{
if (!ring->waitingForKey)
closeObject = true;
else
ring->waitingForKey = false;
break;
}
else if (DbInput & IN_FORWARD)
{
closeObject = false;
SoundEffect(SFX_MENU_CHOOSE, NULL, 0);
if (ring->selectedIndex > 0)
ring->selectedIndex--;
}
else if (DbInput & IN_BACK)
{
closeObject = false;
SoundEffect(SFX_MENU_CHOOSE, NULL, 0);
if (ring->selectedIndex < NUM_CONTROLS + 2 - 1)
ring->selectedIndex++;
}
else if (DbInput & IN_SELECT)
{
SoundEffect(SFX_MENU_CHOOSE, NULL, 0);
if (ring->selectedIndex == NUM_CONTROLS)
{
2019-04-29 13:10:58 +02:00
memcpy(KeyboardLayout1, ring->Configuration.KeyboardLayout, NUM_CONTROLS);
SaveConfiguration();
2019-04-29 13:10:58 +02:00
closeObject = true;
break;
}
else if (ring->selectedIndex == NUM_CONTROLS + 1)
{
closeObject = true;
break;
}
else
{
g_Renderer->DrawInventory();
g_Renderer->SyncRenderer();
continue;
}
}
// If RETURN is pressed, then wait for a new key
if (KeyMap[TR_KEY_RETURN] & 0x80)
{
SoundEffect(SFX_MENU_SELECT, NULL, 0);
if (!ring->waitingForKey)
{
ring->waitingForKey = true;
TrInput = 0;
DbInput = 0;
ZeroMemory(KeyMap, 256);
while (true)
{
if (DbInput & IN_DESELECT)
{
ring->waitingForKey = false;
break;
}
__int32 selectedKey = 0;
for (selectedKey = 0; selectedKey < 256; selectedKey++)
{
if (KeyMap[selectedKey] & 0x80)
break;
}
if (selectedKey == 256)
selectedKey = 0;
if (selectedKey && g_KeyNames[selectedKey])
{
// Can't rededefine special keys or the inventory will be not usable
if (!(selectedKey == TR_KEY_RETURN || selectedKey == TR_KEY_LEFT || selectedKey == TR_KEY_RIGHT ||
selectedKey == TR_KEY_UP || selectedKey == TR_KEY_DOWN))
{
if (selectedKey != TR_KEY_ESCAPE)
{
KeyboardLayout1[ring->selectedIndex] = selectedKey;
CheckKeyConflicts();
ring->waitingForKey = false;
break;
}
}
}
g_Renderer->DrawInventory();
g_Renderer->SyncRenderer();
2019-04-28 20:19:27 +02:00
SetDebounce = true;
S_UpdateInput();
SetDebounce = false;
}
}
}
g_Renderer->DrawInventory();
g_Renderer->SyncRenderer();
}
PopoverObject();
2018-09-07 18:34:18 +02:00
}
void Inventory::DoGraphicsSettings()
{
InventoryRing* ring = &m_rings[m_activeRing];
ring->frameIndex = 0;
ring->selectedIndex = 0;
PopupObject();
// Copy configuration to a temporary object
memcpy(&ring->Configuration, &g_Configuration, sizeof(GameConfiguration));
// Get current display mode
vector<RendererVideoAdapter>* adapters = g_Renderer->GetAdapters();
RendererVideoAdapter* adapter = &(*adapters)[ring->Configuration.Adapter];
ring->SelectedVideoMode = 0;
for (__int32 i = 0; i < adapter->DisplayModes.size(); i++)
{
RendererDisplayMode* mode = &adapter->DisplayModes[i];
if (mode->Width == ring->Configuration.Width && mode->Height == ring->Configuration.Height &&
mode->RefreshRate == ring->Configuration.RefreshRate)
{
ring->SelectedVideoMode = i;
break;
}
}
bool closeObject = false;
2018-09-07 18:34:18 +02:00
// Do the menu
while (true)
{
// Handle input
SetDebounce = true;
S_UpdateInput();
SetDebounce = false;
GameTimer++;
// Handle input
if (DbInput & IN_DESELECT || closeObject)
{
closeObject = true;
break;
}
else if (DbInput & IN_LEFT)
{
closeObject = false;
switch (ring->selectedIndex)
{
case INV_DISPLAY_RESOLUTION:
SoundEffect(SFX_MENU_CHOOSE, NULL, 0);
if (ring->SelectedVideoMode > 0)
ring->SelectedVideoMode--;
break;
case INV_DISPLAY_SHADOWS:
SoundEffect(SFX_MENU_CHOOSE, NULL, 0);
ring->Configuration.EnableShadows = !ring->Configuration.EnableShadows;
break;
case INV_DISPLAY_CAUSTICS:
SoundEffect(SFX_MENU_CHOOSE, NULL, 0);
ring->Configuration.EnableCaustics = !ring->Configuration.EnableCaustics;
break;
case INV_DISPLAY_VOLUMETRIC_FOG:
SoundEffect(SFX_MENU_CHOOSE, NULL, 0);
ring->Configuration.EnableVolumetricFog = !ring->Configuration.EnableVolumetricFog;
break;
}
}
else if (DbInput & IN_RIGHT)
{
closeObject = false;
switch (ring->selectedIndex)
{
case INV_DISPLAY_RESOLUTION:
SoundEffect(SFX_MENU_CHOOSE, NULL, 0);
2019-04-29 13:10:58 +02:00
if (ring->SelectedVideoMode < adapter->DisplayModes.size() - 1)
ring->SelectedVideoMode++;
break;
case INV_DISPLAY_SHADOWS:
SoundEffect(SFX_MENU_CHOOSE, NULL, 0);
ring->Configuration.EnableShadows = !ring->Configuration.EnableShadows;
break;
case INV_DISPLAY_CAUSTICS:
SoundEffect(SFX_MENU_CHOOSE, NULL, 0);
ring->Configuration.EnableCaustics = !ring->Configuration.EnableCaustics;
break;
case INV_DISPLAY_VOLUMETRIC_FOG:
SoundEffect(SFX_MENU_CHOOSE, NULL, 0);
ring->Configuration.EnableVolumetricFog = !ring->Configuration.EnableVolumetricFog;
break;
}
}
else if (DbInput & IN_FORWARD)
{
closeObject = false;
SoundEffect(SFX_MENU_CHOOSE, NULL, 0);
if (ring->selectedIndex > 0)
ring->selectedIndex--;
}
else if (DbInput & IN_BACK)
{
closeObject = false;
SoundEffect(SFX_MENU_CHOOSE, NULL, 0);
if (ring->selectedIndex < INV_DISPLAY_COUNT)
ring->selectedIndex++;
}
else if (DbInput & IN_SELECT)
{
SoundEffect(SFX_MENU_SELECT, NULL, 0);
if (ring->selectedIndex == INV_DISPLAY_APPLY)
{
// Save the configuration
RendererDisplayMode* mode = &adapter->DisplayModes[ring->SelectedVideoMode];
ring->Configuration.Width = mode->Width;
ring->Configuration.Height = mode->Height;
ring->Configuration.RefreshRate = mode->RefreshRate;
memcpy(&g_Configuration, &ring->Configuration, sizeof(GameConfiguration));
SaveConfiguration();
// Reset screen and go back
g_Renderer->ChangeScreenResolution(ring->Configuration.Width, ring->Configuration.Height,
ring->Configuration.RefreshRate, ring->Configuration.Windowed);
closeObject = true;
break;
}
else if (ring->selectedIndex == INV_DISPLAY_CANCEL)
{
SoundEffect(SFX_MENU_SELECT, NULL, 0);
closeObject = true;
break;
}
else
{
}
}
g_Renderer->DrawInventory();
g_Renderer->SyncRenderer();
}
PopoverObject();
2018-09-07 18:34:18 +02:00
}
void Inventory::DoSoundSettings()
{
InventoryRing* ring = &m_rings[m_activeRing];
ring->frameIndex = 0;
ring->selectedIndex = 0;
2018-09-07 18:34:18 +02:00
PopupObject();
// Copy configuration to a temporary object
memcpy(&ring->Configuration, &g_Configuration, sizeof(GameConfiguration));
// Open the passport
for (__int32 i = 0; i < 14; i++)
{
g_Renderer->DrawInventory();
g_Renderer->SyncRenderer();
}
bool closeObject = false;
__int32 oldVolume = ring->Configuration.MusicVolume;
__int32 oldSfxVolume = ring->Configuration.SfxVolume;
bool wasSoundEnabled = ring->Configuration.EnableSound;
// Do the passport
while (true)
{
// Handle input
SetDebounce = true;
S_UpdateInput();
SetDebounce = false;
GameTimer++;
// Handle input
if (DbInput & IN_DESELECT || closeObject)
{
closeObject = true;
GlobalMusicVolume = oldVolume;
GlobalFXVolume = oldSfxVolume;
break;
}
else if (DbInput & IN_LEFT)
{
closeObject = false;
switch (ring->selectedIndex)
{
case INV_SOUND_ENABLED:
SoundEffect(SFX_MENU_CHOOSE, NULL, 0);
ring->Configuration.EnableSound = !ring->Configuration.EnableSound;
break;
case INV_SOUND_SPECIAL_EFFECTS:
SoundEffect(SFX_MENU_CHOOSE, NULL, 0);
ring->Configuration.EnableAudioSpecialEffects = !ring->Configuration.EnableAudioSpecialEffects;
break;
case INV_SOUND_MUSIC_VOLUME:
if (ring->Configuration.MusicVolume > 0)
{
ring->Configuration.MusicVolume--;
GlobalMusicVolume = ring->Configuration.MusicVolume;
}
break;
case INV_SOUND_SFX_VOLUME:
if (ring->Configuration.SfxVolume > 0)
{
ring->Configuration.SfxVolume--;
GlobalFXVolume = ring->Configuration.SfxVolume;
SoundEffect(SFX_MENU_CHOOSE, NULL, 0);
}
break;
}
}
else if (DbInput & IN_RIGHT)
{
closeObject = false;
switch (ring->selectedIndex)
{
case INV_SOUND_ENABLED:
SoundEffect(SFX_MENU_CHOOSE, NULL, 0);
ring->Configuration.EnableSound = !ring->Configuration.EnableSound;
break;
case INV_SOUND_SPECIAL_EFFECTS:
SoundEffect(SFX_MENU_CHOOSE, NULL, 0);
ring->Configuration.EnableAudioSpecialEffects = !ring->Configuration.EnableAudioSpecialEffects;
break;
case INV_SOUND_MUSIC_VOLUME:
if (ring->Configuration.MusicVolume < 100)
{
ring->Configuration.MusicVolume++;
GlobalMusicVolume = ring->Configuration.MusicVolume;
}
break;
case INV_SOUND_SFX_VOLUME:
if (ring->Configuration.SfxVolume < 100)
{
ring->Configuration.SfxVolume++;
GlobalFXVolume = ring->Configuration.SfxVolume;
SoundEffect(SFX_MENU_CHOOSE, NULL, 0);
}
break;
}
}
else if (DbInput & IN_FORWARD)
{
closeObject = false;
SoundEffect(SFX_MENU_CHOOSE, NULL, 0);
if (ring->selectedIndex > 0)
ring->selectedIndex--;
}
else if (DbInput & IN_BACK)
{
closeObject = false;
SoundEffect(SFX_MENU_CHOOSE, NULL, 0);
if (ring->selectedIndex < INV_DISPLAY_COUNT)
ring->selectedIndex++;
}
else if (DbInput & IN_SELECT)
{
SoundEffect(SFX_MENU_SELECT, NULL, 0);
if (ring->selectedIndex == INV_DISPLAY_APPLY)
{
// Save the configuration
GlobalMusicVolume = ring->Configuration.MusicVolume;
GlobalFXVolume = ring->Configuration.SfxVolume;
memcpy(&g_Configuration, &ring->Configuration, sizeof(GameConfiguration));
SaveConfiguration();
// Init or deinit the sound system
if (wasSoundEnabled && !g_Configuration.EnableSound)
Sound_DeInit();
else if (!wasSoundEnabled && g_Configuration.EnableSound)
Sound_Init();
closeObject = true;
break;
}
else if (ring->selectedIndex == INV_DISPLAY_CANCEL)
{
SoundEffect(SFX_MENU_SELECT, NULL, 0);
closeObject = true;
GlobalMusicVolume = oldVolume;
GlobalFXVolume = oldSfxVolume;
break;
}
else
{
}
}
g_Renderer->DrawInventory();
g_Renderer->SyncRenderer();
}
PopoverObject();
}
__int32 Inventory::GetActiveGui()
{
return m_activeGui;
}
bool Inventory::IsObjectSeparable(__int16 object)
{
2019-04-26 21:09:58 +02:00
for (__int32 i = 0; i < m_combinations.size(); i++)
if (m_combinations[i].combinedObject == object)
return true;
return false;
}
void Inventory::OpenRing(__int32 r, bool animateCamera)
{
InventoryRing* ring = &m_rings[r];
m_activeRing = r;
m_cameraY = ring->y;
__int32 numFrames = INV_NUM_FRAMES_OPEN_CLOSE;
ring->rotation = 90;
ring->distance = 0;
float deltaAngle = ring->rotation / numFrames;
float deltaShift = INV_OBJECTS_DISTANCE / numFrames;
float deltaTilt = 0;
2019-04-27 13:19:44 +02:00
m_cameraTilt = INV_CAMERA_TILT;
if (animateCamera)
{
deltaTilt = (INV_CAMERA_ANIMATION_TILT - INV_CAMERA_TILT) / numFrames;
m_cameraTilt = INV_CAMERA_ANIMATION_TILT;
}
for (__int32 i = 0; i < numFrames; i++)
{
ring->distance += deltaShift;
ring->rotation -= deltaAngle;
m_cameraTilt -= deltaTilt;
g_Renderer->DrawInventory();
g_Renderer->SyncRenderer();
}
m_cameraTilt = INV_CAMERA_TILT;
m_cameraY = m_rings[r].y;
ring->distance = INV_OBJECTS_DISTANCE;
ring->rotation = 0;
}
void Inventory::CloseRing(__int32 r, bool animateCamera)
{
InventoryRing* ring = &m_rings[r];
__int32 numFrames = INV_NUM_FRAMES_OPEN_CLOSE;
ring->rotation = 0;
ring->distance = INV_OBJECTS_DISTANCE;
float deltaAngle = 90.0f / numFrames;
float deltaShift = INV_OBJECTS_DISTANCE / numFrames;
float deltaTilt = 0;
2019-04-27 13:19:44 +02:00
m_cameraTilt = INV_CAMERA_TILT;
if (animateCamera)
{
deltaTilt = (INV_CAMERA_ANIMATION_TILT - INV_CAMERA_TILT) / numFrames;
m_cameraTilt = INV_CAMERA_TILT;
}
for (__int32 i = 0; i < numFrames; i++)
{
ring->distance -= deltaShift;
ring->rotation += deltaAngle;
m_cameraTilt += deltaTilt;
g_Renderer->DrawInventory();
g_Renderer->SyncRenderer();
}
2019-04-27 13:19:44 +02:00
m_cameraTilt = (animateCamera ? INV_CAMERA_ANIMATION_TILT : INV_CAMERA_TILT);
ring->distance = 0;
ring->rotation = 90;
}
void Inventory::SwitchRing(__int32 from, __int32 to, float verticalShift)
{
InventoryRing* ring1 = &m_rings[from];
InventoryRing* ring2 = &m_rings[to];
__int32 numFrames = INV_NUM_FRAMES_OPEN_CLOSE;
ring1->rotation = 0;
ring1->distance = INV_OBJECTS_DISTANCE;
ring2->rotation = 90;
ring2->distance = 0;
float deltaAngle = 90.0f / numFrames;
float deltaShift = INV_OBJECTS_DISTANCE / numFrames;
float deltaY = INV_RINGS_OFFSET * verticalShift / numFrames;
m_cameraTilt = INV_CAMERA_TILT;
ring1->draw = true;
ring2->draw = false;
for (__int32 i = 0; i < numFrames; i++)
{
ring1->distance -= deltaShift;
ring1->rotation += deltaAngle;
ring2->distance += deltaShift;
ring2->rotation -= deltaAngle;
m_cameraY += deltaY;
if (i >= 2)
{
ring1->draw = false;
ring2->draw = true;
}
g_Renderer->DrawInventory();
g_Renderer->SyncRenderer();
}
ring1->distance = 0;
ring1->rotation = 90;
ring2->distance = INV_OBJECTS_DISTANCE;
ring2->rotation = 0;
m_cameraY = ring2->y;
}
float Inventory::GetCameraY()
{
return m_cameraY;
}
float Inventory::GetCameraTilt()
{
return m_cameraTilt;
}
bool Inventory::HasWeaponMultipleAmmos(__int16 object)
{
return (object == INV_OBJECT_SHOTGUN || object == INV_OBJECT_CROSSBOW || object == INV_OBJECT_GRENADE_LAUNCHER);
2018-08-19 09:46:58 +02:00
}