Skip to content

Commit

Permalink
Add draw group visualization
Browse files Browse the repository at this point in the history
  • Loading branch information
TheIndra55 committed Jan 21, 2024
1 parent 13cbff5 commit 7947602
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/modules/InstanceViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,13 @@ void InstanceViewer::DrawInstance()
// Draw groups
if (ImGui::CollapsingHeader("Draw groups"))
{
#ifndef TR8
// Draw the bit representation
auto binary = GetBinary(~instance->noDrawGroups);

ImGui::Text("%s", binary.c_str());
#endif

static int drawGroup = 0;
static bool enabled = false;

Expand Down Expand Up @@ -180,4 +187,17 @@ void InstanceViewer::SkewTo(Instance* instance)
auto player = Game::GetPlayerInstance();

player->position = instance->position;
}

std::string InstanceViewer::GetBinary(int value)
{
std::string binary;

// Not actually binary, reversed binary
for (int i = 0; i <= 31; i++)
{
binary += (value & (1 << i)) ? "1" : "0";
}

return binary;
}
4 changes: 4 additions & 0 deletions src/modules/InstanceViewer.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#include <string>

#include "Module.h"

#include "instance/Instance.h"
Expand All @@ -14,6 +16,8 @@ class InstanceViewer : public Module
void DrawInstance();
void SkewTo(Instance* instance);

std::string GetBinary(int value);

public:
void OnMenu();
void OnDraw();
Expand Down

0 comments on commit 7947602

Please sign in to comment.