Skip to content

Commit

Permalink
feat: another attempt at full inventory control
Browse files Browse the repository at this point in the history
  • Loading branch information
RobbeBryssinck committed Dec 21, 2021
1 parent 48eec06 commit 4f8fbe0
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 0 deletions.
1 change: 1 addition & 0 deletions Code/client/Games/BSAnimationGraphManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ uint64_t BSAnimationGraphManager::GetDescriptorKey(int aForceIndex)
}
}

// TODO: this sometimes crashes when appending. Adding logging seems to fix it. Ask cosi for repro
for(auto& [id, name] : variables)
{
variableNames += name;
Expand Down
1 change: 1 addition & 0 deletions Code/client/Games/Skyrim/Actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ void Actor::SetInventory(const Inventory& acInventory) noexcept
pEquipManager->Equip(this, pAmmo, nullptr, count, DefaultObjectManager::Get().rightEquipSlot, false, true, false, false);
}

// TODO: check if weapon drawn state is the same
SetWeaponDrawnEx(acInventory.IsWeaponDrawn);
}

Expand Down
8 changes: 8 additions & 0 deletions Code/client/Games/Skyrim/Forms/AlchemyItem.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#pragma once

#include "TESForm.h"

struct AlchemyItem : TESForm
{

};
8 changes: 8 additions & 0 deletions Code/client/Games/Skyrim/Forms/EnchantmentItem.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#pragma once

#include "TESForm.h"

struct EnchantmentItem : TESForm
{

};
71 changes: 71 additions & 0 deletions Code/client/Services/Generic/TestService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,19 @@
#include <Games/Skyrim/DefaultObjectManager.h>
#include <Games/Skyrim/Misc/InventoryEntry.h>
#include <EquipManager.h>

#include <ExtraData/ExtraCharge.h>
#include <ExtraData/ExtraCount.h>
#include <ExtraData/ExtraEnchantment.h>
#include <ExtraData/ExtraHealth.h>
#include <ExtraData/ExtraPoison.h>
#include <ExtraData/ExtraPoison.h>
#include <ExtraData/ExtraSoul.h>
#include <ExtraData/ExtraTextDisplayData.h>
#include <ExtraData/ExtraWorn.h>
#include <ExtraData/ExtraWornLeft.h>
#include <Forms/EnchantmentItem.h>
#include <Forms/AlchemyItem.h>
#endif

#include <imgui.h>
Expand Down Expand Up @@ -996,18 +1009,76 @@ void TestService::OnDraw() noexcept

bool charge = pDataList->Contains(ExtraData::Charge);
ImGui::TextColored(charge ? green : red, "charge");
if (charge)
{
auto pCharge = (ExtraCharge*)pDataList->GetByType(ExtraData::Charge);
ImGui::InputFloat("Charge", &pCharge->fCharge, 0, 0, "%.3f",
ImGuiInputTextFlags_ReadOnly);
}

bool count = pDataList->Contains(ExtraData::Count);
ImGui::TextColored(count ? green : red, "count");
if (count)
{
auto pCount = (ExtraCount*)pDataList->GetByType(ExtraData::Count);
auto iCount = int(pCount->count);
ImGui::InputInt("Item count", &iCount, 0, 0, ImGuiInputTextFlags_ReadOnly);
}

bool enchantment = pDataList->Contains(ExtraData::Enchantment);
ImGui::TextColored(enchantment ? green : red, "enchantment");
if (enchantment)
{
auto pEnchantment = (ExtraEnchantment*)pDataList->GetByType(ExtraData::Enchantment);
int enchantmentID =
pEnchantment->pEnchantment ? int(pEnchantment->pEnchantment->formID) : 0;
ImGui::InputInt("Enchantment id", &enchantmentID, 0, 0, ImGuiInputTextFlags_ReadOnly | ImGuiInputTextFlags_CharsHexadecimal);
int iCharge = int(pEnchantment->usCharge);
ImGui::InputInt("Charge", &iCharge, 0, 0, ImGuiInputTextFlags_ReadOnly);
int iRemoveOnUnequip = int(pEnchantment->bRemoveOnUnequip);
ImGui::InputInt("Remove on unequip?", &iRemoveOnUnequip, 0, 0, ImGuiInputTextFlags_ReadOnly);
}

bool health = pDataList->Contains(ExtraData::Health);
ImGui::TextColored(health ? green : red, "health");
if (health)
{
auto pHealth = (ExtraHealth*)pDataList->GetByType(ExtraData::Health);
ImGui::InputFloat("Health", &pHealth->fHealth, 0, 0, "%.3f",
ImGuiInputTextFlags_ReadOnly);
}

bool poison = pDataList->Contains(ExtraData::Poison);
ImGui::TextColored(poison ? green : red, "poison");
if (poison)
{
auto pPoison = (ExtraPoison*)pDataList->GetByType(ExtraData::Poison);
int poisonID =
pPoison->pPoison ? int(pPoison->pPoison->formID) : 0;
ImGui::InputInt("Poison id", &poisonID, 0, 0, ImGuiInputTextFlags_ReadOnly | ImGuiInputTextFlags_CharsHexadecimal);
int iCount = int(pPoison->uiCount);
ImGui::InputInt("Count", &iCount, 0, 0, ImGuiInputTextFlags_ReadOnly);
}

bool soul = pDataList->Contains(ExtraData::Soul);
ImGui::TextColored(soul ? green : red, "soul");
if (soul)
{
auto pSoul = (ExtraSoul*)pDataList->GetByType(ExtraData::Soul);
auto iSoulLevel = int(pSoul->cSoul);
ImGui::InputInt("Soul level", &iSoulLevel, 0, 0, ImGuiInputTextFlags_ReadOnly);
}

bool textDisplayData = pDataList->Contains(ExtraData::TextDisplayData);
ImGui::TextColored(textDisplayData ? green : red, "textDisplayData");
if (textDisplayData)
{
auto pTextDisplayData = (ExtraTextDisplayData*)pDataList->GetByType(ExtraData::TextDisplayData);
char name[256];
sprintf_s(name, std::size(name), "%s", pTextDisplayData->DisplayName.AsAscii());
ImGui::InputText("Name", name, std::size(name), ImGuiInputTextFlags_ReadOnly);
}

bool worn = pDataList->Contains(ExtraData::Worn);
ImGui::TextColored(worn ? green : red, "worn");
bool wornLeft = pDataList->Contains(ExtraData::WornLeft);
Expand Down

0 comments on commit 4f8fbe0

Please sign in to comment.