Browse Source

add arena memory gooey widget

main
cinnaboot 4 years ago
parent
commit
7a530b6e88
  1. 28
      src/gooey.cpp

28
src/gooey.cpp

@ -8,6 +8,7 @@ using namespace ImGui;
#include "gooey.h"
#include "orbits.h"
#include "util.h"
const static int G_WIDTH = 400;
@ -17,6 +18,7 @@ const int H_FLAGS = ImGuiTreeNodeFlags_DefaultOpen;
// forward declarations
void drawSimulationWindow(bool& running, u64 sim_time_ms, float& sim_speed);
void drawMemoryWindow(MemoryArena* arena);
void drawOrbitWindow(GameState* gs);
void drawEllipseParameters(EllipseParameters& ep);
void drawGravitationalBody(GravBody& body);
@ -74,12 +76,13 @@ gooDraw(SDL_Window* window, GameState* gs)
Begin("Gooey");
drawSimulationWindow(gs->running, gs->sim_time_ms, gs->sim_speed);
drawMemoryWindow(gs->arena);
Separator();
// FIXME: slit up orbit window into function calls here
// FIXME: split up orbit window into function calls here
drawOrbitWindow(gs);
BeginChild("impulsive maneuver", ImVec2(G_WIDTH - 20, 150), true);
BeginChild("impulsive maneuver", ImVec2(G_WIDTH - 20, 125), true);
drawManeuverWindow(gs);
EndChild();
#if 0
@ -113,11 +116,26 @@ void drawSimulationWindow(bool& running, u64 sim_time_ms, float& sim_speed)
InputFloat("sim speed", &sim_speed, 0.1, 4.0, "%.1f");
}
void drawMemoryWindow(MemoryArena* arena)
{
BeginChild("memory", ImVec2(G_WIDTH - 20, 50), true);
Text("GameState Memory Arena");
float freeMB = (float) arena->free_size / (float) (1024 * 1024);
float maxMB = (float) arena->max_size / (float) (1024 * 1024);
float usedMB = maxMB - freeMB;
Text("%.2f MB", usedMB);
SameLine();
ProgressBar(usedMB / maxMB, ImVec2(100, 15));
SameLine();
Text("%.2f MB", maxMB);
EndChild();
}
void drawOrbitWindow(GameState* gs)
{
Text("Orbit Selection");
BeginChild("orbit selection", ImVec2(G_WIDTH - 20, 100), true);
BeginChild("orbit selection", ImVec2(G_WIDTH - 20, 70), true);
static u32 selected = UINT_MAX;
for (u32 i = 0; i < gs->num_orbits; i++) {
@ -146,8 +164,8 @@ void drawOrbitWindow(GameState* gs)
//Text("Orbital Period: %.2fs", sys.orbital_period);
drawSystemWindow(sys);
Separator();
drawGravitationalBody(sys.body);
Separator();
//drawGravitationalBody(sys.body);
//Separator();
drawSatelliteWindow(sys.sat);
Separator();
drawOrbitalElements(sys.elements);

Loading…
Cancel
Save