Simplify GUI ring access code

This commit is contained in:
Sezz 2023-07-31 17:53:22 +10:00
parent 38afa940d4
commit 0fd527c46c
6 changed files with 235 additions and 168 deletions

View file

@ -41,7 +41,7 @@ namespace TEN::Gui
GuiController g_Gui;
std::vector<const char*> OptionStrings = std::vector<const char*>
std::vector<std::string> OptionStrings =
{
STRING_USE,
STRING_CHOOSE_AMMO,
@ -58,7 +58,7 @@ namespace TEN::Gui
// STRING_READ_DIARY
};
std::vector<const char*> GeneralActionStrings =
std::vector<std::string> GeneralActionStrings =
{
STRING_ACTIONS_FORWARD,
STRING_ACTIONS_BACKWARD,
@ -76,7 +76,7 @@ namespace TEN::Gui
STRING_ACTIONS_LOOK
};
std::vector<const char*> VehicleActionStrings =
std::vector<std::string> VehicleActionStrings =
{
STRING_ACTIONS_ACCELERATE,
STRING_ACTIONS_REVERSE,
@ -86,7 +86,7 @@ namespace TEN::Gui
STRING_ACTIONS_FIRE
};
std::vector<const char*> QuickActionStrings =
std::vector<std::string> QuickActionStrings =
{
STRING_ACTIONS_FLARE,
STRING_ACTIONS_SMALL_MEDIPACK,
@ -105,7 +105,7 @@ namespace TEN::Gui
STRING_ACTIONS_WEAPON_10
};
std::vector<const char*> MenuActionStrings =
std::vector<std::string> MenuActionStrings =
{
STRING_ACTIONS_SELECT,
STRING_ACTIONS_DESELECT,
@ -196,9 +196,9 @@ namespace TEN::Gui
return CurrentSettings;
}
InventoryRing* GuiController::GetRings(int ringIndex)
const InventoryRing& GuiController::GetRing(RingTypes ringType)
{
return &Rings[ringIndex];
return Rings[(int)ringType];
}
short GuiController::GetSelectedOption()
@ -1219,9 +1219,11 @@ namespace TEN::Gui
bool GuiController::IsItemInInventory(int objectNumber)
{
const auto& ring = Rings[(int)RingTypes::Inventory];
for (int i = 0; i < INVENTORY_TABLE_SIZE; i++)
{
if (Rings[(int)RingTypes::Inventory].CurrentObjectList[i].InventoryItem == objectNumber)
const auto& listObject = ring.CurrentObjectList[i];
if (listObject.InventoryItem == objectNumber)
return true;
}
@ -1264,10 +1266,12 @@ namespace TEN::Gui
void GuiController::SetupObjectListStartPosition(int newObjectNumber)
{
auto& ring = Rings[(int)RingTypes::Inventory];
for (int i = 0; i < INVENTORY_TABLE_SIZE; i++)
{
if (Rings[(int)RingTypes::Inventory].CurrentObjectList[i].InventoryItem == newObjectNumber)
Rings[(int)RingTypes::Inventory].CurrentObjectInList = i;
const auto& listObject = ring.CurrentObjectList[i];
if (listObject.InventoryItem == newObjectNumber)
ring.CurrentObjectInList = i;
}
}
@ -1280,8 +1284,11 @@ namespace TEN::Gui
void GuiController::SetupAmmoSelector()
{
const auto& ring = Rings[(int)RingTypes::Inventory];
const auto& invObject = InventoryObjectTable[ring.CurrentObjectList[ring.CurrentObjectInList].InventoryItem];
int number = 0;
unsigned __int64 options = InventoryObjectTable[Rings[(int)RingTypes::Inventory].CurrentObjectList[Rings[(int)RingTypes::Inventory].CurrentObjectInList].InventoryItem].Options;
unsigned __int64 options = invObject.Options;
AmmoSelectorFlag = 0;
NumAmmoSlots = 0;
@ -1292,7 +1299,7 @@ namespace TEN::Gui
AmmoObjectList[1].Orientation = EulerAngles::Zero;
AmmoObjectList[2].Orientation = EulerAngles::Zero;
if (options &
if (options &
(OPT_CHOOSE_AMMO_UZI | OPT_CHOOSE_AMMO_PISTOLS | OPT_CHOOSE_AMMO_REVOLVER | OPT_CHOOSE_AMMO_CROSSBOW |
OPT_CHOOSE_AMMO_HK | OPT_CHOOSE_AMMO_SHOTGUN | OPT_CHOOSE_AMMO_GRENADEGUN | OPT_CHOOSE_AMMO_HARPOON | OPT_CHOOSE_AMMO_ROCKET))
{
@ -1889,7 +1896,9 @@ namespace TEN::Gui
void GuiController::FadeAmmoSelector()
{
if (Rings[(int)RingTypes::Inventory].RingActive)
{
AmmoSelectorFadeVal = 0;
}
else if (AmmoSelectorFadeDir == 1)
{
if (AmmoSelectorFadeVal < 128)
@ -2196,22 +2205,24 @@ namespace TEN::Gui
void GuiController::DoInventory(ItemInfo* item)
{
auto* lara = GetLaraInfo(item);
auto& invRing = Rings[(int)RingTypes::Inventory];
auto& ammoRing = Rings[(int)RingTypes::Ammo];
if (Rings[(int)RingTypes::Ammo].RingActive)
if (ammoRing.RingActive)
{
auto optionString = g_GameFlow->GetString(OptionStrings[5]);
auto optionString = g_GameFlow->GetString(OptionStrings[5].c_str());
g_Renderer.AddString(PHD_CENTER_X, PHD_CENTER_Y, optionString, PRINTSTRING_COLOR_WHITE, PRINTSTRING_BLINK | PRINTSTRING_CENTER | PRINTSTRING_OUTLINE);
if (Rings[(int)RingTypes::Inventory].ObjectListMovement)
if (invRing.ObjectListMovement)
return;
if (Rings[(int)RingTypes::Ammo].ObjectListMovement)
if (ammoRing.ObjectListMovement)
return;
if (GuiIsSelected(false))
{
short invItem = Rings[(int)RingTypes::Inventory].CurrentObjectList[Rings[(int)RingTypes::Inventory].CurrentObjectInList].InventoryItem;
short ammoItem = Rings[(int)RingTypes::Ammo].CurrentObjectList[Rings[(int)RingTypes::Ammo].CurrentObjectInList].InventoryItem;
short invItem = invRing.CurrentObjectList[invRing.CurrentObjectInList].InventoryItem;
short ammoItem = ammoRing.CurrentObjectList[ammoRing.CurrentObjectInList].InventoryItem;
if (DoObjectsCombine(invItem, ammoItem))
{
@ -2270,66 +2281,66 @@ namespace TEN::Gui
}
else
{
int num = Rings[(int)RingTypes::Inventory].CurrentObjectList[Rings[(int)RingTypes::Inventory].CurrentObjectInList].InventoryItem;
int num = invRing.CurrentObjectList[invRing.CurrentObjectInList].InventoryItem;
for (int i = 0; i < 3; i++)
{
CurrentOptions[i].Type = MenuType::None;
CurrentOptions[i].Text = 0;
CurrentOptions[i].Text = {};
}
int n = 0;
unsigned long options;
if (!AmmoActive)
{
options = InventoryObjectTable[Rings[(int)RingTypes::Inventory].CurrentObjectList[Rings[(int)RingTypes::Inventory].CurrentObjectInList].InventoryItem].Options;
options = InventoryObjectTable[invRing.CurrentObjectList[invRing.CurrentObjectInList].InventoryItem].Options;
if (options & OPT_LOAD)
{
CurrentOptions[0].Type = MenuType::Load;
CurrentOptions[0].Text = g_GameFlow->GetString(OptionStrings[6]);
CurrentOptions[0].Text = g_GameFlow->GetString(OptionStrings[6].c_str());
n = 1;
}
if (options & OPT_SAVE)
{
CurrentOptions[n].Type = MenuType::Save;
CurrentOptions[n].Text = g_GameFlow->GetString(OptionStrings[7]);
CurrentOptions[n].Text = g_GameFlow->GetString(OptionStrings[7].c_str());
n++;
}
if (options & OPT_EXAMINABLE)
{
CurrentOptions[n].Type = MenuType::Examine;
CurrentOptions[n].Text = g_GameFlow->GetString(OptionStrings[8]);
CurrentOptions[n].Text = g_GameFlow->GetString(OptionStrings[8].c_str());
n++;
}
if (options & OPT_STATS)
{
CurrentOptions[n].Type = MenuType::Statistics;
CurrentOptions[n].Text = g_GameFlow->GetString(OptionStrings[9]);
CurrentOptions[n].Text = g_GameFlow->GetString(OptionStrings[9].c_str());
n++;
}
if (options & OPT_USE)
{
CurrentOptions[n].Type = MenuType::Use;
CurrentOptions[n].Text = g_GameFlow->GetString(OptionStrings[0]);
CurrentOptions[n].Text = g_GameFlow->GetString(OptionStrings[0].c_str());
n++;
}
if (options & OPT_EQUIP)
{
CurrentOptions[n].Type = MenuType::Equip;
CurrentOptions[n].Text = g_GameFlow->GetString(OptionStrings[4]);
CurrentOptions[n].Text = g_GameFlow->GetString(OptionStrings[4].c_str());
n++;
}
if (options & (OPT_CHOOSE_AMMO_SHOTGUN | OPT_CHOOSE_AMMO_CROSSBOW | OPT_CHOOSE_AMMO_GRENADEGUN | OPT_CHOOSE_AMMO_HK))
{
CurrentOptions[n].Type = MenuType::ChooseAmmo;
CurrentOptions[n].Text = g_GameFlow->GetString(OptionStrings[1]);
CurrentOptions[n].Text = g_GameFlow->GetString(OptionStrings[1].c_str());
n++;
}
@ -2338,7 +2349,7 @@ namespace TEN::Gui
if (IsItemCurrentlyCombinable(num))
{
CurrentOptions[n].Type = MenuType::Combine;
CurrentOptions[n].Text = g_GameFlow->GetString(OptionStrings[2]);
CurrentOptions[n].Text = g_GameFlow->GetString(OptionStrings[2].c_str());
n++;
}
}
@ -2346,21 +2357,21 @@ namespace TEN::Gui
if (options & OPT_ALWAYS_COMBINE)
{
CurrentOptions[n].Type = MenuType::Combine;
CurrentOptions[n].Text = g_GameFlow->GetString(OptionStrings[2]);
CurrentOptions[n].Text = g_GameFlow->GetString(OptionStrings[2].c_str());
n++;
}
if (options & OPT_SEPERABLE)
{
CurrentOptions[n].Type = MenuType::Seperate;
CurrentOptions[n].Text = g_GameFlow->GetString(OptionStrings[3]);
CurrentOptions[n].Text = g_GameFlow->GetString(OptionStrings[3].c_str());
n++;
}
if (options & OPT_DIARY)
{
CurrentOptions[n].Type = MenuType::Diary;
CurrentOptions[n].Text = g_GameFlow->GetString(OptionStrings[11]);
CurrentOptions[n].Text = g_GameFlow->GetString(OptionStrings[11].c_str());
n++;
}
}
@ -2372,7 +2383,7 @@ namespace TEN::Gui
CurrentOptions[1].Text = g_GameFlow->GetString(InventoryObjectTable[AmmoObjectList[1].InventoryItem].ObjectName);
n = 2;
options = InventoryObjectTable[Rings[(int)RingTypes::Inventory].CurrentObjectList[Rings[(int)RingTypes::Inventory].CurrentObjectInList].InventoryItem].Options;
options = InventoryObjectTable[invRing.CurrentObjectList[invRing.CurrentObjectInList].InventoryItem].Options;
if (options & (OPT_CHOOSE_AMMO_CROSSBOW | OPT_CHOOSE_AMMO_GRENADEGUN | OPT_CHOOSE_AMMO_HK))
{
@ -2387,15 +2398,19 @@ namespace TEN::Gui
int yPos = 310 - LINE_HEIGHT;
if (n == 1)
{
yPos += LINE_HEIGHT;
}
else if (n == 2)
{
yPos += LINE_HEIGHT / 2;
}
if (n > 0)
{
for (int i = 0; i < n; i++)
{
auto optionString = std::string(CurrentOptions[i].Text);
auto optionString = CurrentOptions[i].Text;
if (i == CurrentSelectedOption)
{
@ -2411,8 +2426,8 @@ namespace TEN::Gui
}
if (MenuActive &&
!Rings[(int)RingTypes::Inventory].ObjectListMovement &&
!Rings[(int)RingTypes::Ammo].ObjectListMovement)
!invRing.ObjectListMovement &&
!ammoRing.ObjectListMovement)
{
if (AmmoActive)
{
@ -2462,13 +2477,16 @@ namespace TEN::Gui
if (GuiIsSelected(false))
{
if (CurrentOptions[CurrentSelectedOption].Type != MenuType::Equip && CurrentOptions[CurrentSelectedOption].Type != MenuType::Use)
if (CurrentOptions[CurrentSelectedOption].Type != MenuType::Equip &&
CurrentOptions[CurrentSelectedOption].Type != MenuType::Use)
{
SoundEffect(SFX_TR4_MENU_CHOOSE, nullptr, SoundEnvironment::Always);
}
switch (CurrentOptions[CurrentSelectedOption].Type)
{
case MenuType::ChooseAmmo:
Rings[(int)RingTypes::Inventory].RingActive = false;
invRing.RingActive = false;
AmmoActive = 1;
Ammo.StashedCurrentSelectedOption = CurrentSelectedOption;
Ammo.StashedCurrentPistolsAmmoType = Ammo.CurrentPistolsAmmoType;
@ -2504,14 +2522,14 @@ namespace TEN::Gui
case MenuType::Ammo2:
case MenuType::Ammo3:
AmmoActive = 0;
Rings[(int)RingTypes::Inventory].RingActive = true;
invRing.RingActive = true;
CurrentSelectedOption = 0;
break;
case MenuType::Combine:
ConstructCombineObjectList(item);
Rings[(int)RingTypes::Inventory].RingActive = false;
Rings[(int)RingTypes::Ammo].RingActive = true;
invRing.RingActive = false;
ammoRing.RingActive = true;
AmmoSelectorFlag = 0;
MenuActive = false;
CombineRingFadeDir = 1;
@ -2539,7 +2557,7 @@ namespace TEN::Gui
{
SoundEffect(SFX_TR4_MENU_SELECT, nullptr, SoundEnvironment::Always);
AmmoActive = 0;
Rings[(int)RingTypes::Inventory].RingActive = true;
invRing.RingActive = true;
Ammo.CurrentPistolsAmmoType = Ammo.StashedCurrentPistolsAmmoType;
Ammo.CurrentUziAmmoType = Ammo.StashedCurrentUziAmmoType;
Ammo.CurrentRevolverAmmoType = Ammo.StashedCurrentRevolverAmmoType;
@ -2652,9 +2670,13 @@ namespace TEN::Gui
char invTextBuffer[256];
if (AmmoObjectList[n].Amount == -1)
{
sprintf(&invTextBuffer[0], "Unlimited %s", g_GameFlow->GetString(InventoryObjectTable[AmmoObjectList[n].InventoryItem].ObjectName));
}
else
{
sprintf(&invTextBuffer[0], "%d x %s", AmmoObjectList[n].Amount, g_GameFlow->GetString(InventoryObjectTable[AmmoObjectList[n].InventoryItem].ObjectName));
}
// CHECK: AmmoSelectorFadeVal is never true and therefore the string is never printed.
//if (AmmoSelectorFadeVal)
@ -2675,14 +2697,15 @@ namespace TEN::Gui
}
}
void GuiController::DrawCurrentObjectList(ItemInfo* item, int ringIndex)
void GuiController::DrawCurrentObjectList(ItemInfo* item, RingTypes ringType)
{
auto* lara = GetLaraInfo(item);
const auto& player = GetLaraInfo(*item);
auto& ring = Rings[(int)ringType];
if (Rings[ringIndex].CurrentObjectList <= 0)
if (ring.CurrentObjectList <= 0)
return;
if (ringIndex == (int)RingTypes::Ammo)
if (ringType == RingTypes::Ammo)
{
AmmoSelectorFadeVal = 0;
AmmoSelectorFadeDir = 0;
@ -2708,7 +2731,9 @@ namespace TEN::Gui
CombineRingFadeDir = 0;
if (CombineTypeFlag)
{
NormalRingFadeDir = 2;
}
else
{
Rings[(int)RingTypes::Inventory].RingActive = true;
@ -2756,7 +2781,9 @@ namespace TEN::Gui
SetupObjectListStartPosition(CombineObject1);
}
else if (SeperateTypeFlag)
{
SeparateObject(item, Rings[(int)RingTypes::Inventory].CurrentObjectList[Rings[(int)RingTypes::Inventory].CurrentObjectInList].InventoryItem);
}
HandleObjectChangeover((int)RingTypes::Inventory);
}
@ -2767,34 +2794,34 @@ namespace TEN::Gui
int xOffset = 0;
int n = 0;
if (Rings[ringIndex].NumObjectsInList != 1)
xOffset = (OBJLIST_SPACING * Rings[ringIndex].ObjectListMovement) >> 16;
if (ring.NumObjectsInList != 1)
xOffset = (OBJLIST_SPACING * ring.ObjectListMovement) >> 16;
if (Rings[ringIndex].NumObjectsInList == 2)
if (ring.NumObjectsInList == 2)
{
minObj = -1;
maxObj = 0;
n = Rings[ringIndex].CurrentObjectInList - 1;
n = ring.CurrentObjectInList - 1;
}
if (Rings[ringIndex].NumObjectsInList == 3 || Rings[ringIndex].NumObjectsInList == 4)
if (ring.NumObjectsInList == 3 || ring.NumObjectsInList == 4)
{
minObj = -2;
maxObj = 1;
n = Rings[ringIndex].CurrentObjectInList - 2;
n = ring.CurrentObjectInList - 2;
}
if (Rings[ringIndex].NumObjectsInList >= 5)
if (ring.NumObjectsInList >= 5)
{
minObj = -3;
maxObj = 2;
n = Rings[ringIndex].CurrentObjectInList - 3;
n = ring.CurrentObjectInList - 3;
}
if (n < 0)
n += Rings[ringIndex].NumObjectsInList;
n += ring.NumObjectsInList;
if (Rings[ringIndex].ObjectListMovement < 0)
if (ring.ObjectListMovement < 0)
maxObj++;
if (minObj <= maxObj)
@ -2805,230 +2832,270 @@ namespace TEN::Gui
if (minObj == i)
{
if (Rings[ringIndex].ObjectListMovement < 0)
if (ring.ObjectListMovement < 0)
{
shade = 0;
}
else
shade = Rings[ringIndex].ObjectListMovement >> 9;
{
shade = ring.ObjectListMovement >> 9;
}
}
else if (i != minObj + 1 || maxObj == minObj + 1)
{
if (i != maxObj)
{
shade = 128;
}
else
{
if (Rings[ringIndex].ObjectListMovement < 0)
shade = (-128 * Rings[ringIndex].ObjectListMovement) >> 16;
if (ring.ObjectListMovement < 0)
{
shade = (-128 * ring.ObjectListMovement) >> 16;
}
else
shade = 128 - short(Rings[ringIndex].ObjectListMovement >> 9);
{
shade = 128 - short(ring.ObjectListMovement >> 9);
}
}
}
else
{
if (Rings[ringIndex].ObjectListMovement < 0)
shade = 128 - ((-128 * Rings[ringIndex].ObjectListMovement) >> 16);
if (ring.ObjectListMovement < 0)
{
shade = 128 - ((-128 * ring.ObjectListMovement) >> 16);
}
else
{
shade = 128;
}
}
if (!minObj && !maxObj)
shade = 128;
if (ringIndex == (int)RingTypes::Ammo && CombineRingFadeVal < 128 && shade)
if (ringType == RingTypes::Ammo && CombineRingFadeVal < 128 && shade)
{
shade = CombineRingFadeVal;
else if (ringIndex == (int)RingTypes::Inventory && NormalRingFadeVal < 128 && shade)
}
else if (ringType == RingTypes::Inventory && NormalRingFadeVal < 128 && shade)
{
shade = NormalRingFadeVal;
}
auto& listObject = ring.CurrentObjectList[n];
const auto& invObject = InventoryObjectTable[listObject.InventoryItem];
if (!i)
{
int numItems = 0;
int count = 0;
char textBufferMe[128];
char textBuffer[128];
switch (InventoryObjectTable[Rings[ringIndex].CurrentObjectList[n].InventoryItem].ObjectNumber)
switch (invObject.ObjectNumber)
{
case ID_BIGMEDI_ITEM:
numItems = lara->Inventory.TotalLargeMedipacks;
numItems = player.Inventory.TotalLargeMedipacks;
break;
case ID_SMALLMEDI_ITEM:
numItems = lara->Inventory.TotalSmallMedipacks;
numItems = player.Inventory.TotalSmallMedipacks;
break;
case ID_FLARE_INV_ITEM:
numItems = lara->Inventory.TotalFlares;
numItems = player.Inventory.TotalFlares;
break;
default:
if (InventoryObjectTable[Rings[ringIndex].CurrentObjectList[n].InventoryItem].ObjectNumber < ID_PUZZLE_ITEM1 ||
InventoryObjectTable[Rings[ringIndex].CurrentObjectList[n].InventoryItem].ObjectNumber > ID_PUZZLE_ITEM16)
if (invObject.ObjectNumber < ID_PUZZLE_ITEM1 ||
invObject.ObjectNumber > ID_PUZZLE_ITEM16)
{
switch (InventoryObjectTable[Rings[ringIndex].CurrentObjectList[n].InventoryItem].ObjectNumber)
switch (invObject.ObjectNumber)
{
case ID_SHOTGUN_AMMO1_ITEM:
numItems = lara->Weapons[(int)LaraWeaponType::Shotgun].Ammo[(int)WeaponAmmoType::Ammo1].GetCount();
numItems = player.Weapons[(int)LaraWeaponType::Shotgun].Ammo[(int)WeaponAmmoType::Ammo1].GetCount();
break;
case ID_SHOTGUN_AMMO2_ITEM:
numItems = lara->Weapons[(int)LaraWeaponType::Shotgun].Ammo[(int)WeaponAmmoType::Ammo2].GetCount();
numItems = player.Weapons[(int)LaraWeaponType::Shotgun].Ammo[(int)WeaponAmmoType::Ammo2].GetCount();
break;
case ID_HK_AMMO_ITEM:
numItems = lara->Weapons[(int)LaraWeaponType::HK].Ammo[(int)WeaponAmmoType::Ammo1].GetCount();
numItems = player.Weapons[(int)LaraWeaponType::HK].Ammo[(int)WeaponAmmoType::Ammo1].GetCount();
break;
case ID_CROSSBOW_AMMO1_ITEM:
count = lara->Weapons[(int)LaraWeaponType::Crossbow].Ammo[(int)WeaponAmmoType::Ammo1].GetCount();
count = player.Weapons[(int)LaraWeaponType::Crossbow].Ammo[(int)WeaponAmmoType::Ammo1].GetCount();
numItems = count;
break;
case ID_CROSSBOW_AMMO2_ITEM:
count = lara->Weapons[(int)LaraWeaponType::Crossbow].Ammo[(int)WeaponAmmoType::Ammo2].GetCount();
count = player.Weapons[(int)LaraWeaponType::Crossbow].Ammo[(int)WeaponAmmoType::Ammo2].GetCount();
numItems = count;
break;
case ID_CROSSBOW_AMMO3_ITEM:
count = lara->Weapons[(int)LaraWeaponType::Crossbow].Ammo[(int)WeaponAmmoType::Ammo3].GetCount();
count = player.Weapons[(int)LaraWeaponType::Crossbow].Ammo[(int)WeaponAmmoType::Ammo3].GetCount();
numItems = count;
break;
case ID_GRENADE_AMMO1_ITEM:
count = lara->Weapons[(int)LaraWeaponType::GrenadeLauncher].Ammo[(int)WeaponAmmoType::Ammo1].GetCount();
count = player.Weapons[(int)LaraWeaponType::GrenadeLauncher].Ammo[(int)WeaponAmmoType::Ammo1].GetCount();
numItems = count;
break;
case ID_GRENADE_AMMO2_ITEM:
count = lara->Weapons[(int)LaraWeaponType::GrenadeLauncher].Ammo[(int)WeaponAmmoType::Ammo2].GetCount();
count = player.Weapons[(int)LaraWeaponType::GrenadeLauncher].Ammo[(int)WeaponAmmoType::Ammo2].GetCount();
numItems = count;
break;
case ID_GRENADE_AMMO3_ITEM:
count = lara->Weapons[(int)LaraWeaponType::GrenadeLauncher].Ammo[(int)WeaponAmmoType::Ammo3].GetCount();
count = player.Weapons[(int)LaraWeaponType::GrenadeLauncher].Ammo[(int)WeaponAmmoType::Ammo3].GetCount();
numItems = count;
break;
case ID_ROCKET_LAUNCHER_AMMO_ITEM:
numItems = lara->Weapons[(int)LaraWeaponType::RocketLauncher].Ammo[(int)WeaponAmmoType::Ammo1].GetCount();
numItems = player.Weapons[(int)LaraWeaponType::RocketLauncher].Ammo[(int)WeaponAmmoType::Ammo1].GetCount();
break;
case ID_HARPOON_AMMO_ITEM:
numItems = lara->Weapons[(int)LaraWeaponType::HarpoonGun].Ammo[(int)WeaponAmmoType::Ammo1].GetCount();
numItems = player.Weapons[(int)LaraWeaponType::HarpoonGun].Ammo[(int)WeaponAmmoType::Ammo1].GetCount();
break;
case ID_REVOLVER_AMMO_ITEM:
numItems = lara->Weapons[(int)LaraWeaponType::Revolver].Ammo[(int)WeaponAmmoType::Ammo1].GetCount();
numItems = player.Weapons[(int)LaraWeaponType::Revolver].Ammo[(int)WeaponAmmoType::Ammo1].GetCount();
break;
case ID_UZI_AMMO_ITEM:
numItems = lara->Weapons[(int)LaraWeaponType::Uzi].Ammo[(int)WeaponAmmoType::Ammo1].GetCount();
numItems = player.Weapons[(int)LaraWeaponType::Uzi].Ammo[(int)WeaponAmmoType::Ammo1].GetCount();
break;
}
}
else
{
numItems = lara->Inventory.Puzzles[InventoryObjectTable[Rings[ringIndex].CurrentObjectList[n].InventoryItem].ObjectNumber - ID_PUZZLE_ITEM1];
numItems = player.Inventory.Puzzles[invObject.ObjectNumber - ID_PUZZLE_ITEM1];
if (numItems <= 1)
sprintf(textBufferMe, g_GameFlow->GetString(InventoryObjectTable[Rings[ringIndex].CurrentObjectList[n].InventoryItem].ObjectName));
{
sprintf(textBuffer, g_GameFlow->GetString(invObject.ObjectName));
}
else
sprintf(textBufferMe, "%d x %s", numItems, g_GameFlow->GetString(InventoryObjectTable[Rings[ringIndex].CurrentObjectList[n].InventoryItem].ObjectName));
{
sprintf(textBuffer, "%d x %s", numItems, g_GameFlow->GetString(invObject.ObjectName));
}
}
break;
}
if (InventoryObjectTable[Rings[ringIndex].CurrentObjectList[n].InventoryItem].ObjectNumber < ID_PUZZLE_ITEM1 ||
InventoryObjectTable[Rings[ringIndex].CurrentObjectList[n].InventoryItem].ObjectNumber > ID_PUZZLE_ITEM16)
if (invObject.ObjectNumber < ID_PUZZLE_ITEM1 ||
invObject.ObjectNumber > ID_PUZZLE_ITEM16)
{
if (numItems)
{
if (numItems == -1)
sprintf(textBufferMe, "Unlimited %s", g_GameFlow->GetString(InventoryObjectTable[Rings[ringIndex].CurrentObjectList[n].InventoryItem].ObjectName));
{
sprintf(textBuffer, "Unlimited %s", g_GameFlow->GetString(invObject.ObjectName));
}
else
sprintf(textBufferMe, "%d x %s", numItems, g_GameFlow->GetString(InventoryObjectTable[Rings[ringIndex].CurrentObjectList[n].InventoryItem].ObjectName));
{
sprintf(textBuffer, "%d x %s", numItems, g_GameFlow->GetString(invObject.ObjectName));
}
}
else
sprintf(textBufferMe, g_GameFlow->GetString(InventoryObjectTable[Rings[ringIndex].CurrentObjectList[n].InventoryItem].ObjectName));
{
sprintf(textBuffer, g_GameFlow->GetString(invObject.ObjectName));
}
}
int objectNumber;
if (ringIndex == (int)RingTypes::Inventory)
if (ringType == RingTypes::Inventory)
{
objectNumber = int(PHD_CENTER_Y - (SCREEN_SPACE_RES.y + 1) * 0.0625 * 2.5);
}
else
{
objectNumber = int(PHD_CENTER_Y + (SCREEN_SPACE_RES.y + 1) * 0.0625 * 2.0);
}
g_Renderer.AddString(PHD_CENTER_X, objectNumber, textBufferMe, PRINTSTRING_COLOR_YELLOW, PRINTSTRING_CENTER | PRINTSTRING_OUTLINE);
g_Renderer.AddString(PHD_CENTER_X, objectNumber, textBuffer, PRINTSTRING_COLOR_YELLOW, PRINTSTRING_CENTER | PRINTSTRING_OUTLINE);
}
if (!i && !Rings[ringIndex].ObjectListMovement)
if (!i && !ring.ObjectListMovement)
{
if (InventoryObjectTable[Rings[ringIndex].CurrentObjectList[n].InventoryItem].RotFlags & INV_ROT_X)
Rings[ringIndex].CurrentObjectList[n].Orientation.x += ANGLE(5.0f);
if (invObject.RotFlags & INV_ROT_X)
listObject.Orientation.x += ANGLE(5.0f);
if (InventoryObjectTable[Rings[ringIndex].CurrentObjectList[n].InventoryItem].RotFlags & INV_ROT_Y)
Rings[ringIndex].CurrentObjectList[n].Orientation.y += ANGLE(5.0f);
if (invObject.RotFlags & INV_ROT_Y)
listObject.Orientation.y += ANGLE(5.0f);
if (InventoryObjectTable[Rings[ringIndex].CurrentObjectList[n].InventoryItem].RotFlags & INV_ROT_Z)
Rings[ringIndex].CurrentObjectList[n].Orientation.z += ANGLE(5.0f);
if (invObject.RotFlags & INV_ROT_Z)
listObject.Orientation.z += ANGLE(5.0f);
}
else
SpinBack(Rings[ringIndex].CurrentObjectList[n].Orientation);
{
SpinBack(listObject.Orientation);
}
int activeNum = 0;
if (Rings[ringIndex].ObjectListMovement)
if (ring.ObjectListMovement)
{
if (Rings[ringIndex].ObjectListMovement > 0)
if (ring.ObjectListMovement > 0)
{
activeNum = -1;
}
else
{
activeNum = 1;
}
}
if (i == activeNum)
{
if (Rings[ringIndex].CurrentObjectList[n].Bright < 160)
Rings[ringIndex].CurrentObjectList[n].Bright += 16;
if (listObject.Bright < 160)
listObject.Bright += 16;
if (Rings[ringIndex].CurrentObjectList[n].Bright > 160)
Rings[ringIndex].CurrentObjectList[n].Bright = 160;
if (listObject.Bright > 160)
listObject.Bright = 160;
}
else
{
if (Rings[ringIndex].CurrentObjectList[n].Bright > 32)
Rings[ringIndex].CurrentObjectList[n].Bright -= 16;
if (listObject.Bright > 32)
listObject.Bright -= 16;
if (Rings[ringIndex].CurrentObjectList[n].Bright < 32)
Rings[ringIndex].CurrentObjectList[n].Bright = 32;
if (listObject.Bright < 32)
listObject.Bright = 32;
}
int x = 400 + xOffset + i * OBJLIST_SPACING;
int y = 150;
int y2 = 480; // Combine.
short objectNumber = ConvertInventoryItemToObject(Rings[ringIndex].CurrentObjectList[n].InventoryItem);
float scaler = InventoryObjectTable[Rings[ringIndex].CurrentObjectList[n].InventoryItem].Scale1;
auto& orientation = Rings[ringIndex].CurrentObjectList[n].Orientation;
int bits = InventoryObjectTable[Rings[ringIndex].CurrentObjectList[n].InventoryItem].MeshBits;
short objectNumber = ConvertInventoryItemToObject(listObject.InventoryItem);
float scaler = invObject.Scale1;
auto& orient = listObject.Orientation;
int bits = invObject.MeshBits;
g_Renderer.DrawObjectIn2DSpace(objectNumber, Vector2(x, (ringIndex == (int)RingTypes::Inventory) ? y : y2), orientation, scaler, 1.0f, bits);
g_Renderer.DrawObjectIn2DSpace(objectNumber, Vector2(x, (ringType == RingTypes::Inventory) ? y : y2), orient, scaler, 1.0f, bits);
if (++n >= Rings[ringIndex].NumObjectsInList)
if (++n >= ring.NumObjectsInList)
n = 0;
}
if (Rings[ringIndex].RingActive)
if (ring.RingActive)
{
if (Rings[ringIndex].NumObjectsInList != 1 && (ringIndex != 1 || CombineRingFadeVal == 128))
if (ring.NumObjectsInList != 1 && (ringType != RingTypes::Ammo || CombineRingFadeVal == 128))
{
if (Rings[ringIndex].ObjectListMovement > 0)
Rings[ringIndex].ObjectListMovement += ANGLE(45.0f);
if (ring.ObjectListMovement > 0)
ring.ObjectListMovement += ANGLE(45.0f);
if (Rings[ringIndex].ObjectListMovement < 0)
Rings[ringIndex].ObjectListMovement -= ANGLE(45.0f);
if (ring.ObjectListMovement < 0)
ring.ObjectListMovement -= ANGLE(45.0f);
if (IsHeld(In::Left))
{
if (!Rings[ringIndex].ObjectListMovement)
if (!ring.ObjectListMovement)
{
SoundEffect(SFX_TR4_MENU_ROTATE, nullptr, SoundEnvironment::Always);
Rings[ringIndex].ObjectListMovement += ANGLE(45.0f);
ring.ObjectListMovement += ANGLE(45.0f);
if (AmmoSelectorFlag)
AmmoSelectorFadeDir = 2;
@ -3037,41 +3104,41 @@ namespace TEN::Gui
if (IsHeld(In::Right))
{
if (!Rings[ringIndex].ObjectListMovement)
if (!ring.ObjectListMovement)
{
SoundEffect(SFX_TR4_MENU_ROTATE, nullptr, SoundEnvironment::Always);
Rings[ringIndex].ObjectListMovement -= ANGLE(45.0f);
ring.ObjectListMovement -= ANGLE(45.0f);
if (AmmoSelectorFlag)
AmmoSelectorFadeDir = 2;
}
}
if (Rings[ringIndex].ObjectListMovement < 65536)
if (ring.ObjectListMovement < 65536)
{
if (Rings[ringIndex].ObjectListMovement < -65535)
if (ring.ObjectListMovement < -65535)
{
Rings[ringIndex].CurrentObjectInList++;
ring.CurrentObjectInList++;
if (Rings[ringIndex].CurrentObjectInList >= Rings[ringIndex].NumObjectsInList)
Rings[ringIndex].CurrentObjectInList = 0;
if (ring.CurrentObjectInList >= ring.NumObjectsInList)
ring.CurrentObjectInList = 0;
Rings[ringIndex].ObjectListMovement = 0;
ring.ObjectListMovement = 0;
if (ringIndex == (int)RingTypes::Inventory)
if (ringType == RingTypes::Inventory)
HandleObjectChangeover(0);
}
}
else
{
Rings[ringIndex].CurrentObjectInList--;
ring.CurrentObjectInList--;
if (Rings[ringIndex].CurrentObjectInList < 0)
Rings[ringIndex].CurrentObjectInList = Rings[ringIndex].NumObjectsInList - 1;
if (ring.CurrentObjectInList < 0)
ring.CurrentObjectInList = ring.NumObjectsInList - 1;
Rings[ringIndex].ObjectListMovement = 0;
ring.ObjectListMovement = 0;
if (ringIndex == (int)RingTypes::Inventory)
if (ringType == RingTypes::Inventory)
HandleObjectChangeover(0);
}
}

View file

@ -5,11 +5,11 @@
#include "Specific/configuration.h"
#include "Specific/Input/InputAction.h"
struct ItemInfo;
using namespace TEN::Input;
using namespace TEN::Math;
struct ItemInfo;
namespace TEN::Gui
{
enum class InventoryMode
@ -85,14 +85,14 @@ namespace TEN::Gui
struct MenuOption
{
MenuType Type;
char const* Text;
MenuType Type = MenuType::None;
std::string Text = {};
};
struct ObjectList
{
short InventoryItem;
EulerAngles Orientation = EulerAngles::Zero;
int InventoryItem = 0;
EulerAngles Orientation = EulerAngles::Zero;
unsigned short Bright;
};
@ -168,7 +168,7 @@ namespace TEN::Gui
InventoryResult TitleOptions(ItemInfo* item);
InventoryResult DoPauseMenu(ItemInfo* item);
void DrawInventory();
void DrawCurrentObjectList(ItemInfo* item, int ringIndex);
void DrawCurrentObjectList(ItemInfo* item, RingTypes ringType);
int IsObjectInInventory(int objectNumber);
int ConvertObjectToInventoryItem(int objectNumber);
int ConvertInventoryItemToObject(int objectNumber);
@ -178,7 +178,7 @@ namespace TEN::Gui
void DrawCompass(ItemInfo* item);
// Getters
InventoryRing* GetRings(int ringIndex);
const InventoryRing& GetRing(RingTypes ringType);
short GetSelectedOption();
Menu GetMenuToDisplay();
InventoryMode GetInventoryMode();
@ -229,9 +229,9 @@ namespace TEN::Gui
};
extern GuiController g_Gui;
extern std::vector<const char*> OptionStrings;
extern std::vector<const char*> GeneralActionStrings;
extern std::vector<const char*> VehicleActionStrings;
extern std::vector<const char*> QuickActionStrings;
extern std::vector<const char*> MenuActionStrings;
extern std::vector<std::string> OptionStrings;
extern std::vector<std::string> GeneralActionStrings;
extern std::vector<std::string> VehicleActionStrings;
extern std::vector<std::string> QuickActionStrings;
extern std::vector<std::string> MenuActionStrings;
}

View file

@ -709,7 +709,7 @@ namespace TEN::Renderer
void SwitchDebugPage(bool goBack);
void DrawDisplayPickup(const DisplayPickup& pickup);
int Synchronize();
void AddString(int x, int y, const char* string, D3DCOLOR color, int flags);
void AddString(int x, int y, const std::string& string, D3DCOLOR color, int flags);
void AddString(const std::string& string, const Vector2& pos, const Color& color, float scale, int flags);
void AddDebugString(const std::string& string, const Vector2& pos, const Color& color, float scale, int flags, RendererDebugPage page);
void FreeRendererData();

View file

@ -265,7 +265,7 @@ namespace TEN::Renderer
// General action listing
for (int k = 0; k < GeneralActionStrings.size(); k++)
{
AddString(MenuLeftSideEntry, y, g_GameFlow->GetString(GeneralActionStrings[k]), PRINTSTRING_COLOR_WHITE, SF(titleOption == k));
AddString(MenuLeftSideEntry, y, g_GameFlow->GetString(GeneralActionStrings[k].c_str()), PRINTSTRING_COLOR_WHITE, SF(titleOption == k));
if (g_Gui.GetCurrentSettings().WaitingForKey && titleOption == k)
{
@ -315,7 +315,7 @@ namespace TEN::Renderer
// Vehicle action listing
for (int k = 0; k < VehicleActionStrings.size(); k++)
{
AddString(MenuLeftSideEntry, y, g_GameFlow->GetString(VehicleActionStrings[k]), PRINTSTRING_COLOR_WHITE, SF(titleOption == k));
AddString(MenuLeftSideEntry, y, g_GameFlow->GetString(VehicleActionStrings[k].c_str()), PRINTSTRING_COLOR_WHITE, SF(titleOption == k));
if (g_Gui.GetCurrentSettings().WaitingForKey && titleOption == k)
{
@ -371,7 +371,7 @@ namespace TEN::Renderer
// Quick action listing
for (int k = 0; k < QuickActionStrings.size(); k++)
{
AddString(MenuLeftSideEntry, y, g_GameFlow->GetString(QuickActionStrings[k]), PRINTSTRING_COLOR_WHITE, SF(titleOption == k));
AddString(MenuLeftSideEntry, y, g_GameFlow->GetString(QuickActionStrings[k].c_str()), PRINTSTRING_COLOR_WHITE, SF(titleOption == k));
if (g_Gui.GetCurrentSettings().WaitingForKey && titleOption == k)
{
@ -420,7 +420,7 @@ namespace TEN::Renderer
// Menu action listing.
for (int k = 0; k < MenuActionStrings.size(); k++)
{
AddString(MenuLeftSideEntry, y, g_GameFlow->GetString(MenuActionStrings[k]), PRINTSTRING_COLOR_WHITE, SF(titleOption == k));
AddString(MenuLeftSideEntry, y, g_GameFlow->GetString(MenuActionStrings[k].c_str()), PRINTSTRING_COLOR_WHITE, SF(titleOption == k));
if (g_Gui.GetCurrentSettings().WaitingForKey && titleOption == k)
{
@ -674,10 +674,10 @@ namespace TEN::Renderer
void Renderer11::RenderNewInventory()
{
g_Gui.DrawCurrentObjectList(LaraItem, (int)RingTypes::Inventory);
g_Gui.DrawCurrentObjectList(LaraItem, RingTypes::Inventory);
if (g_Gui.GetRings((int)RingTypes::Ammo)->RingActive)
g_Gui.DrawCurrentObjectList(LaraItem, (int)RingTypes::Ammo);
if (g_Gui.GetRing(RingTypes::Ammo).RingActive)
g_Gui.DrawCurrentObjectList(LaraItem, RingTypes::Ammo);
g_Gui.DrawAmmoSelector();
g_Gui.FadeAmmoSelector();
@ -864,7 +864,7 @@ namespace TEN::Renderer
static EulerAngles orient = EulerAngles::Zero;
static float scaler = 1.2f;
short invItem = g_Gui.GetRings((int)RingTypes::Inventory)->CurrentObjectList[g_Gui.GetRings((int)RingTypes::Inventory)->CurrentObjectInList].InventoryItem;
short invItem = g_Gui.GetRing(RingTypes::Inventory).CurrentObjectList[g_Gui.GetRing(RingTypes::Inventory).CurrentObjectInList].InventoryItem;
auto& object = InventoryObjectTable[invItem];

View file

@ -15,9 +15,9 @@ namespace TEN::Renderer
AddString(string, pos, color, scale, FLAGS);
}
void Renderer11::AddString(int x, int y, const char* string, D3DCOLOR color, int flags)
void Renderer11::AddString(int x, int y, const std::string& string, D3DCOLOR color, int flags)
{
AddString(std::string(string), Vector2(x, y), Color(color), 1.0f, flags);
AddString(string, Vector2(x, y), Color(color), 1.0f, flags);
}
void Renderer11::AddString(const std::string& string, const Vector2& pos, const Color& color, float scale, int flags)

View file

@ -113,7 +113,7 @@ void StringsHandler::ProcessDisplayStrings(float deltaTime)
{
if (!endOfLife || str.m_isInfinite)
{
char const* cstr = str.m_isTranslated ? g_GameFlow->GetString(str.m_key.c_str()) : str.m_key.c_str();
auto cstr = str.m_isTranslated ? g_GameFlow->GetString(str.m_key.c_str()) : str.m_key.c_str();
int flags = 0;
if (str.m_flags[static_cast<size_t>(DisplayStringOptions::CENTER)])