Skip to content

Commit

Permalink
View Life sector, view Squad markers, Empty node DFF import crash fix
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrienTD committed Apr 5, 2022
1 parent bc8ee00 commit f2e90ec
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 9 deletions.
10 changes: 6 additions & 4 deletions CKGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,9 @@ void CKGrpSquad::deserialize(KEnvironment * kenv, File * file, size_t length)
for (auto &ref : refs)
ref = kenv->readObjRef<CKObject>(file);
for (auto arr : { &sqUnk3, &sqUnk4 })
for (float &f : *arr)
f = file->readFloat();
for (Vector3& v : *arr)
for (float& f : v)
f = file->readFloat();
sqUnk5 = file->readUint32();
uint32_t numChoreographies = file->readUint32();
choreographies.resize(numChoreographies);
Expand Down Expand Up @@ -198,8 +199,9 @@ void CKGrpSquad::serialize(KEnvironment * kenv, File * file)
for (auto &ref : refs)
kenv->writeObjRef<CKObject>(file, ref);
for (auto arr : { &sqUnk3, &sqUnk4 })
for (float &f : *arr)
file->writeFloat(f);
for (Vector3& v : *arr)
for (float& f : v)
file->writeFloat(f);
file->writeUint32(sqUnk5);
file->writeUint32(choreographies.size());
for (auto &ref : choreographies)
Expand Down
4 changes: 2 additions & 2 deletions CKGroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ struct CKGrpSquad : CKSubclass<CKGrpBaseSquad, 24> {
float sqUnk1;
Vector3 sqUnk2;
std::array<kobjref<CKObject>, 4> refs;
std::array<float, 6> sqUnk3, sqUnk4;
std::array<Vector3, 2> sqUnk3, sqUnk4;
uint32_t sqUnk5;
//uint32_t numChoreographies;
std::vector<kobjref<CKChoreography>> choreographies;
//uint32_t numChoreoKeys;
std::vector<kobjref<CKChoreoKey>> choreoKeys;
struct Bing {
uint32_t markerIndex; uint8_t b;
uint32_t markerIndex = 0; uint8_t b = 0;
};
std::vector<Bing> guardMarkers, spawnMarkers;
std::vector<uint32_t> fings; // seems to be always empty
Expand Down
47 changes: 44 additions & 3 deletions EditorInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1229,8 +1229,8 @@ void EditorInterface::render()
CKGrpSquadEnemy* squad = osquad->cast<CKGrpSquadEnemy>();
if (showSquadBoxes) {
for (const auto& bb : { squad->sqUnk3, squad->sqUnk4 }) {
Vector3 v1(bb[0], bb[1], bb[2]);
Vector3 v2(bb[3], bb[4], bb[5]);
const Vector3& v1 = bb[0];
const Vector3& v2 = bb[1];
drawBox(v1 - v2 * 0.5f, v1 + v2 * 0.5f);
}
}
Expand Down Expand Up @@ -2600,7 +2600,7 @@ void EditorInterface::IGSceneNodeProperties()
// Remove current geometry
// TODO: Proper handling of duplicate geometries
CKAnyGeometry *kgeo = geonode->geometry.get();
CKObject* lightSetBackup = kgeo->lightSet.get();
CKObject* lightSetBackup = kgeo ? kgeo->lightSet.get() : nullptr;
geonode->geometry.reset();
while (kgeo) {
if (CMaterial* mat = kgeo->material.get()) {
Expand Down Expand Up @@ -3252,9 +3252,35 @@ void EditorInterface::IGSquadEditor()
}
ImGui::EndTabItem();
}
if (ImGui::BeginTabItem("Markers")) {
for (auto [name, list] : { std::make_pair("Spawning points", &squad->spawnMarkers), std::make_pair("Guard points",&squad->guardMarkers) }) {
ImGui::PushID(name);
if (ImGui::CollapsingHeader(name, ImGuiTreeNodeFlags_DefaultOpen)) {
if (ImGui::Button("Add")) {
list->emplace_back();
}
ImGui::SameLine();
if (ImGui::Button("Clear")) {
list->clear();
}
for (auto& pnt : *list) {
ImGui::Separator();
ImGui::PushID(&pnt);
ImGui::InputScalar("Marker Index", ImGuiDataType_U32, &pnt.markerIndex);
ImGui::InputScalar("Byte", ImGuiDataType_U8, &pnt.b);
// TODO: Modify marker properties directly here
ImGui::PopID();
}
}
ImGui::PopID();
}
ImGui::EndTabItem();
}
if (ImGui::BeginTabItem("MsgAction")) {
ImGui::BeginChild("MsgActionWnd");
CKMsgAction *msgAction = squad->msgAction->cast<CKMsgAction>();
if (ImGui::Button("Clear"))
msgAction->mas1.clear();
for (auto &a : msgAction->mas1) {
if (ImGui::TreeNodeEx(&a, ImGuiTreeNodeFlags_DefaultOpen, "%i", a.mas2.size())) {
for (auto &b : a.mas2) {
Expand Down Expand Up @@ -3709,6 +3735,21 @@ void EditorInterface::IGHookEditor()
ImGui::EndDragDropSource();
}
ImGui::Separator();
if (selectedHook->life) {
// NOTE: Currently modifying life sector is dangerous
// (e.g. makes PostRef decoding fail since it relies on the
// life sectors)
ImGui::LabelText("Life value", "%08X", selectedHook->life->unk1);
int lifeSector = selectedHook->life->unk1 >> 2;
int lifeFlags = selectedHook->life->unk1 & 3;
bool lifeChanged = false;
lifeChanged |= ImGui::InputInt("Life sector", &lifeSector);
lifeChanged |= ImGui::InputInt("Life flags", &lifeFlags);
if (lifeChanged) {
selectedHook->life->unk1 = (lifeFlags & 3) | (lifeSector << 2);
}
ImGui::Separator();
}
ImGuiMemberListener ml(kenv, *this);
selectedHook->virtualReflectMembers(ml, &kenv);
}
Expand Down

0 comments on commit f2e90ec

Please sign in to comment.