Foundation / checks (deploy) (push) Successful in 6s
Foundation / checks (ecs) (push) Successful in 2m23s
Foundation / checks (tsan) (push) Successful in 10m11s
Foundation / checks (client) (push) Failing after 14m26s
Foundation / checks (network) (push) Successful in 18m54s
Foundation / checks (checks) (push) Successful in 42m9s
Foundation / checks (postgres) (push) Successful in 43m51s
Foundation / postgres-tools (push) Skipped
Foundation / server-image (push) Skipped
Foundation / image (push) Skipped
988 lines
49 KiB
C++
988 lines
49 KiB
C++
#include "panels.hpp"
|
|
#include "evo/client/labels.hpp"
|
|
#include <algorithm>
|
|
#include <cstdio>
|
|
#include <cstring>
|
|
#include <imgui.h>
|
|
#include <string>
|
|
|
|
namespace evo::client_app {
|
|
namespace {
|
|
using client::LaunchPhase;
|
|
// Logical sizes at the current UI scale (window height and Ctrl+= / Ctrl+-).
|
|
float px(float v) {
|
|
return v * ImGui::GetStyle().FontScaleMain;
|
|
}
|
|
// A panel placed once (the user may move or resize it), and again at each new UI scale.
|
|
ImGuiCond placed(float& seen) {
|
|
const float scale = ImGui::GetStyle().FontScaleMain;
|
|
if (scale == seen)
|
|
return ImGuiCond_FirstUseEver;
|
|
seen = scale;
|
|
return ImGuiCond_Always;
|
|
}
|
|
ImVec4 color(render::Color c) {
|
|
return {static_cast<float>(c.red) / 255.0F, static_cast<float>(c.green) / 255.0F,
|
|
static_cast<float>(c.blue) / 255.0F, static_cast<float>(c.alpha) / 255.0F};
|
|
}
|
|
void copy(std::array<char, client::max_field_bytes>& out, const std::string& in) {
|
|
out.fill('\0');
|
|
std::memcpy(out.data(), in.data(), std::min(in.size(), out.size() - 1));
|
|
}
|
|
std::string text(const std::array<char, client::max_field_bytes>& in) {
|
|
return {in.begin(), std::find(in.begin(), in.end(), '\0')};
|
|
}
|
|
void row(const char* label, const std::string& value, const std::string& unit = {}) {
|
|
ImGui::TableNextRow();
|
|
ImGui::TableNextColumn();
|
|
ImGui::TextUnformatted(label);
|
|
ImGui::TableNextColumn();
|
|
ImGui::TextUnformatted(value.c_str());
|
|
ImGui::TableNextColumn();
|
|
ImGui::TextUnformatted(unit.c_str());
|
|
}
|
|
void swatch(const char* id, render::Color c, const char* label) {
|
|
ImGui::ColorButton(id, color(c), ImGuiColorEditFlags_NoTooltip | ImGuiColorEditFlags_NoAlpha,
|
|
{px(14), px(14)});
|
|
ImGui::SameLine();
|
|
ImGui::TextUnformatted(label);
|
|
}
|
|
constexpr ImVec4 amber{0.94F, 0.67F, 0.16F, 1.0F}, red{0.95F, 0.35F, 0.35F, 1.0F},
|
|
green{0.35F, 0.80F, 0.60F, 1.0F};
|
|
ImVec4 freshness_color(client::Freshness f) {
|
|
return f == client::Freshness::current ? green : f == client::Freshness::stale ? amber : red;
|
|
}
|
|
const char* outcome_name(client::OutcomeState s) {
|
|
switch (s) {
|
|
case client::OutcomeState::sent:
|
|
return "sent (no reply yet)";
|
|
case client::OutcomeState::admitted:
|
|
return "admitted (not yet durable)";
|
|
case client::OutcomeState::rejected:
|
|
return "rejected";
|
|
case client::OutcomeState::durable:
|
|
return "durable, no effect";
|
|
case client::OutcomeState::not_committed:
|
|
return "not committed";
|
|
case client::OutcomeState::unknown:
|
|
return "UNKNOWN (connection lost)";
|
|
case client::OutcomeState::simulated:
|
|
return "simulated (not durable)";
|
|
}
|
|
return "?";
|
|
}
|
|
void disabled_wrapped(const char* text) {
|
|
ImGui::PushStyleColor(ImGuiCol_Text, ImGui::GetStyleColorVec4(ImGuiCol_TextDisabled));
|
|
ImGui::TextWrapped("%s", text);
|
|
ImGui::PopStyleColor();
|
|
}
|
|
std::string key_label(client::KeyCode key) {
|
|
return key == client::no_key ? std::string{"-"} : std::string{client::key_name(key)};
|
|
}
|
|
std::string controls_hint(const client::Bindings& b) {
|
|
using client::Action;
|
|
const auto k = [&](Action action) { return key_label(b.slot(action).primary); };
|
|
return "Click selects, wheel zooms. Move " + k(Action::move_up) + " " + k(Action::move_left) +
|
|
" " + k(Action::move_down) + " " + k(Action::move_right) + "; pan " + k(Action::pan_up) +
|
|
" " + k(Action::pan_left) + " " + k(Action::pan_down) + " " + k(Action::pan_right) +
|
|
"; UI capture " + k(Action::toggle_capture) + ".";
|
|
}
|
|
// Fixed wording only (never echoes paths or file bytes); wraps inside the launcher.
|
|
void error_text(client::LaunchError error) {
|
|
ImGui::PushStyleColor(ImGuiCol_Text, red);
|
|
ImGui::TextWrapped("%s", std::string{client::launch_error_text(error)}.c_str());
|
|
ImGui::PopStyleColor();
|
|
}
|
|
|
|
constexpr std::array<const char*, world::field_count + 1> layer_names{
|
|
"Water", "Dissolved nitrogen", "Dissolved phosphorus",
|
|
"Organic carbon", "Organic nitrogen", "Organic phosphorus",
|
|
"Organic other", "Organic energy", "Incident energy",
|
|
"Heat", "Moisture (saturation)"};
|
|
|
|
void launcher(const PanelView& v, FormBuffers& form, PanelActions& a) {
|
|
const auto phase = v.launcher->phase();
|
|
const auto& io = ImGui::GetIO();
|
|
ImGui::SetNextWindowPos({io.DisplaySize.x * 0.5F, io.DisplaySize.y * 0.5F}, ImGuiCond_Always,
|
|
{0.5F, 0.5F});
|
|
ImGui::SetNextWindowSize({std::min(px(520), io.DisplaySize.x - px(16)), 0}, ImGuiCond_Always);
|
|
ImGui::Begin("Aeternalis Evolution - engineering client", nullptr,
|
|
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse);
|
|
ImGui::TextColored(green, "AETERNALIS / EVOLUTION");
|
|
ImGui::TextWrapped("Begin a cellular life in the shared dev ecosystem, or explore the local "
|
|
"engineering fixture.");
|
|
if (ImGui::SmallButton("Controls..."))
|
|
a.open_controls = true;
|
|
ImGui::Separator();
|
|
if (ImGui::Button("Local fixture", {px(160), 0}))
|
|
a.fixture = true;
|
|
ImGui::SameLine();
|
|
ImGui::TextWrapped("In-memory stand-in: environment changes and static organisms. Not a "
|
|
"server, not an ecosystem, not authoritative.");
|
|
ImGui::Separator();
|
|
ImGui::TextUnformatted("Connect to a dev region");
|
|
ImGui::BeginDisabled(!v.remote_available || phase == LaunchPhase::connecting);
|
|
ImGui::InputText("Endpoint (host:port)", form.endpoint.data(), form.endpoint.size());
|
|
ImGui::InputText("Server name", form.server_name.data(), form.server_name.size());
|
|
ImGui::InputText("Dev CA file", form.authority.data(), form.authority.size());
|
|
ImGui::InputText("Grant bundle file", form.grants.data(), form.grants.size());
|
|
bool cellular_trial = v.cellular_trial;
|
|
if (ImGui::Checkbox("Cellular play (v10)", &cellular_trial))
|
|
a.cellular_trial = cellular_trial;
|
|
const bool start = phase == LaunchPhase::choosing && ImGui::Button("Connect", {px(160), 0});
|
|
ImGui::EndDisabled();
|
|
if (start)
|
|
a.connect = true;
|
|
if (!v.remote_available)
|
|
ImGui::TextColored(amber, "Remote mode needs a build with EVO_BUILD_NETWORK.");
|
|
if (v.form_error)
|
|
error_text(*v.form_error);
|
|
if (phase == LaunchPhase::connecting) {
|
|
ImGui::TextColored(amber, "Connecting (TLS handshake and grant check)...");
|
|
if (ImGui::Button("Cancel", {px(120), 0}))
|
|
a.cancel = true;
|
|
}
|
|
if (phase == LaunchPhase::failed) {
|
|
error_text(v.launcher->error());
|
|
if (ImGui::Button("Retry", {px(120), 0}))
|
|
a.retry = true;
|
|
ImGui::SameLine();
|
|
if (ImGui::Button("Cancel", {px(120), 0}))
|
|
a.cancel = true;
|
|
}
|
|
ImGui::TextDisabled("Files are read when you connect; nothing is saved.");
|
|
ImGui::End();
|
|
}
|
|
|
|
void banner(const PanelView& v, PanelActions& a) {
|
|
const auto& io = ImGui::GetIO();
|
|
ImGui::SetNextWindowPos({io.DisplaySize.x * 0.5F, px(4)}, ImGuiCond_Always, {0.5F, 0});
|
|
ImGui::Begin("##mode", nullptr,
|
|
ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_AlwaysAutoResize |
|
|
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoSavedSettings);
|
|
if (v.mode == Mode::fixture) {
|
|
ImGui::TextColored(amber, "LOCAL FIXTURE - in-memory stand-in, not authoritative");
|
|
ImGui::SameLine();
|
|
if (ImGui::SmallButton("Launcher"))
|
|
a.back = true;
|
|
ImGui::SameLine();
|
|
if (ImGui::SmallButton("Controls"))
|
|
a.open_controls = true;
|
|
} else {
|
|
ImGui::TextColored(v.remote && v.remote->phase == "connected" ? green : amber,
|
|
"DEV REGION - %s%s", v.remote ? v.remote->phase.c_str() : "?",
|
|
v.remote && v.remote->stale_view ? " - STALE (last view, frozen)" : "");
|
|
ImGui::SameLine();
|
|
if (ImGui::SmallButton("Disconnect"))
|
|
a.ask_disconnect = true;
|
|
ImGui::SameLine();
|
|
if (ImGui::SmallButton("Controls"))
|
|
a.open_controls = true;
|
|
}
|
|
ImGui::End();
|
|
}
|
|
|
|
void legend(const PanelView& v, render::EnvironmentDisplay& display) {
|
|
static float seen = 0;
|
|
const auto when = placed(seen);
|
|
ImGui::SetNextWindowPos({px(8), px(40)}, when);
|
|
ImGui::SetNextWindowSize({px(300), 0}, when);
|
|
ImGui::Begin("Legend");
|
|
int current = display.mode == render::EnvironmentDisplay::Mode::moisture
|
|
? static_cast<int>(world::field_count)
|
|
: static_cast<int>(display.field);
|
|
if (ImGui::Combo("Layer", ¤t, layer_names.data(), static_cast<int>(layer_names.size()))) {
|
|
display = current == static_cast<int>(world::field_count)
|
|
? render::EnvironmentDisplay{render::EnvironmentDisplay::Mode::moisture}
|
|
: render::EnvironmentDisplay{render::EnvironmentDisplay::Mode::field,
|
|
static_cast<world::Field>(current)};
|
|
}
|
|
if (display.mode == render::EnvironmentDisplay::Mode::moisture)
|
|
ImGui::TextWrapped("Water saturation, linear from 0 %% (low) to 100 %% (high).");
|
|
else
|
|
ImGui::TextWrapped("%s", client::density_scale(display.field).c_str());
|
|
swatch("##low", render::ramp(0), "Present: low");
|
|
ImGui::SameLine();
|
|
swatch("##mid", render::ramp(0.5), "mid");
|
|
ImGui::SameLine();
|
|
swatch("##high", render::ramp(1), "high");
|
|
swatch("##zero", render::palette::present_zero, "Present zero (black)");
|
|
swatch("##missing", render::palette::missing_a, "Missing: checkerboard");
|
|
swatch("##notreq", render::palette::not_requested, "Not requested: hollow outline");
|
|
swatch("##undef", render::palette::undefined, "Undefined moisture (no capacity)");
|
|
swatch("##stale", render::palette::stale_outline, "Stale: dimmed, amber outlines");
|
|
ImGui::Separator();
|
|
const auto env = v.environment ? v.environment->freshness() : client::Freshness::none;
|
|
const auto org = v.organisms ? v.organisms->freshness() : client::Freshness::none;
|
|
ImGui::TextColored(freshness_color(env), "Environment: %s",
|
|
std::string{client::freshness_name(env)}.c_str());
|
|
ImGui::TextColored(freshness_color(org), "Organisms: %s",
|
|
std::string{client::freshness_name(org)}.c_str());
|
|
if (v.mode == Mode::remote && v.organisms && v.organisms->current() &&
|
|
v.organisms->current()->cells().empty())
|
|
ImGui::TextWrapped("No individual organisms: this region reports pooled inventories only.");
|
|
if (v.mode == Mode::fixture)
|
|
ImGui::TextWrapped("Fixture organisms are static presentation data built from genomes.");
|
|
if (v.visible_organisms >= 0)
|
|
ImGui::Text("Organisms drawn: %d", v.visible_organisms);
|
|
if (v.bindings != nullptr)
|
|
disabled_wrapped(controls_hint(*v.bindings).c_str());
|
|
ImGui::End();
|
|
}
|
|
|
|
void inspector(const PanelView& v) {
|
|
const auto& io = ImGui::GetIO();
|
|
static float seen = 0;
|
|
const auto when = placed(seen);
|
|
ImGui::SetNextWindowPos({io.DisplaySize.x - px(8), px(40)}, when, {1, 0});
|
|
ImGui::SetNextWindowSize({px(420), 0}, when);
|
|
ImGui::Begin("Inspector");
|
|
const auto* env = v.environment ? v.environment->current() : nullptr;
|
|
const auto* orgs = v.organisms ? v.organisms->current() : nullptr;
|
|
const auto* organism = v.selection->organism(orgs);
|
|
const auto* cell = v.selection->cell(env);
|
|
if (organism == nullptr && cell == nullptr) {
|
|
ImGui::TextWrapped("Click an organism or habitat cell to inspect it.");
|
|
ImGui::End();
|
|
return;
|
|
}
|
|
const auto freshness = organism ? v.organisms->freshness() : v.environment->freshness();
|
|
if (freshness == client::Freshness::stale)
|
|
ImGui::TextColored(amber, "STALE: values are from an older revision.");
|
|
if (ImGui::BeginTable("rows", 3, ImGuiTableFlags_RowBg | ImGuiTableFlags_SizingFixedFit)) {
|
|
for (const auto& r : organism ? client::organism_rows(*organism) : client::cell_rows(*cell))
|
|
row(r.label.c_str(), r.value, r.unit);
|
|
ImGui::EndTable();
|
|
}
|
|
if (cell != nullptr && ImGui::BeginTable("fields", 2, ImGuiTableFlags_RowBg)) {
|
|
// Values wrap inside the column so missing/not-requested explanations stay readable.
|
|
ImGui::TableSetupColumn("field", ImGuiTableColumnFlags_WidthFixed, px(150));
|
|
ImGui::TableSetupColumn("value", ImGuiTableColumnFlags_WidthStretch);
|
|
for (std::size_t k = 0; k < world::field_count; ++k) {
|
|
const auto field = static_cast<world::Field>(k);
|
|
const auto value = client::describe_field(*cell, field);
|
|
ImGui::TableNextRow();
|
|
ImGui::TableNextColumn();
|
|
ImGui::TextUnformatted(std::string{client::field_name(field)}.c_str());
|
|
ImGui::TableNextColumn();
|
|
const bool tinted = value.kind == client::ValueKind::missing ||
|
|
value.kind == client::ValueKind::not_requested;
|
|
if (tinted)
|
|
ImGui::PushStyleColor(ImGuiCol_Text,
|
|
value.kind == client::ValueKind::missing
|
|
? red
|
|
: ImGui::GetStyleColorVec4(ImGuiCol_TextDisabled));
|
|
ImGui::TextWrapped("%s", value.text.c_str());
|
|
if (tinted)
|
|
ImGui::PopStyleColor();
|
|
}
|
|
const auto moisture = client::describe_moisture(*cell);
|
|
ImGui::TableNextRow();
|
|
ImGui::TableNextColumn();
|
|
ImGui::TextUnformatted("Moisture");
|
|
ImGui::TableNextColumn();
|
|
ImGui::TextWrapped("%s", moisture.text.c_str());
|
|
ImGui::EndTable();
|
|
}
|
|
ImGui::End();
|
|
}
|
|
|
|
// Rebinding: each slot button arms key capture for that slot; the panel holds UI
|
|
// capture, so no key or click reaches the world while it is open (ADR-0085).
|
|
void controls(const PanelView& v, PanelActions& a) {
|
|
if (v.controls == nullptr)
|
|
return;
|
|
const auto& io = ImGui::GetIO();
|
|
ImGui::SetNextWindowPos({io.DisplaySize.x * 0.5F, io.DisplaySize.y * 0.5F}, ImGuiCond_Always,
|
|
{0.5F, 0.5F});
|
|
ImGui::SetNextWindowSize({std::min(px(460), io.DisplaySize.x - px(16)), 0}, ImGuiCond_Always);
|
|
ImGui::Begin("Controls", nullptr,
|
|
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse |
|
|
ImGuiWindowFlags_NoSavedSettings);
|
|
disabled_wrapped("Keys are named by their US-layout position. Mouse click (select) and "
|
|
"wheel (zoom) are fixed. Escape cancels a key capture.");
|
|
if (ImGui::BeginTable("bindings", 3, ImGuiTableFlags_RowBg)) {
|
|
ImGui::TableSetupColumn("Action", ImGuiTableColumnFlags_WidthStretch);
|
|
ImGui::TableSetupColumn("Primary", ImGuiTableColumnFlags_WidthFixed, px(120));
|
|
ImGui::TableSetupColumn("Secondary", ImGuiTableColumnFlags_WidthFixed, px(150));
|
|
ImGui::TableHeadersRow();
|
|
for (std::size_t k = 0; k < client::action_count; ++k) {
|
|
const auto action = static_cast<client::Action>(k);
|
|
const auto& slot = v.controls->draft()[k];
|
|
ImGui::TableNextRow();
|
|
ImGui::TableNextColumn();
|
|
ImGui::TextUnformatted(std::string{client::action_name(action)}.c_str());
|
|
for (const bool secondary : {false, true}) {
|
|
ImGui::TableNextColumn();
|
|
const ControlSlot here{action, secondary};
|
|
const auto key = secondary ? slot.secondary : slot.primary;
|
|
const std::string label =
|
|
(v.capturing == here ? std::string{"Press a key"} : key_label(key)) + "##" +
|
|
std::to_string(k) + (secondary ? "s" : "p");
|
|
ImGui::BeginDisabled(v.capturing.has_value());
|
|
if (ImGui::Button(label.c_str(), {px(100), 0}))
|
|
a.capture_key = here;
|
|
if (secondary && key != client::no_key) {
|
|
ImGui::SameLine();
|
|
if (ImGui::SmallButton(("x##clear" + std::to_string(k)).c_str()))
|
|
a.clear_secondary = action;
|
|
}
|
|
ImGui::EndDisabled();
|
|
}
|
|
}
|
|
ImGui::EndTable();
|
|
}
|
|
if (v.capturing) {
|
|
ImGui::TextColored(amber, "Press a key for %s (Escape cancels).",
|
|
std::string{client::action_name(v.capturing->action)}.c_str());
|
|
if (ImGui::Button("Cancel capture", {px(140), 0}))
|
|
a.cancel_capture = true;
|
|
}
|
|
if (v.controls_problem) {
|
|
ImGui::PushStyleColor(ImGuiCol_Text, red);
|
|
ImGui::TextWrapped("%s", client::describe(*v.controls_problem).c_str());
|
|
ImGui::PopStyleColor();
|
|
}
|
|
ImGui::BeginDisabled(v.capturing.has_value());
|
|
if (ImGui::Button("Apply", {px(100), 0}))
|
|
a.apply_controls = true;
|
|
ImGui::SameLine();
|
|
if (ImGui::Button("Reset defaults", {px(130), 0}))
|
|
a.reset_controls = true;
|
|
ImGui::SameLine();
|
|
if (ImGui::Button("Cancel", {px(100), 0}))
|
|
a.close_controls = true;
|
|
ImGui::EndDisabled();
|
|
ImGui::End();
|
|
}
|
|
|
|
void session(const PanelView& v, PanelActions& a) {
|
|
if (!v.remote)
|
|
return;
|
|
const auto& io = ImGui::GetIO();
|
|
static float seen = 0;
|
|
const auto when = placed(seen);
|
|
ImGui::SetNextWindowPos({px(8), io.DisplaySize.y - px(8)}, when, {0, 1});
|
|
ImGui::SetNextWindowSize({px(360), 0}, when);
|
|
ImGui::Begin("Session");
|
|
const auto& s = *v.remote;
|
|
if (s.cellular_trial)
|
|
ImGui::TextColored(amber, "CELLULAR TRIAL - exploratory server-authoritative play");
|
|
if (ImGui::BeginTable("status", 3, ImGuiTableFlags_SizingFixedFit)) {
|
|
row("Connection", s.phase);
|
|
row("Session / epoch", std::to_string(s.session) + " / " + std::to_string(s.epoch));
|
|
row("Region", std::to_string(s.region) + " (" + std::to_string(s.handoffs) + " crossings)");
|
|
row("Server tick", std::to_string(s.server_tick));
|
|
row("Simulated through", std::to_string(s.simulated_tick));
|
|
row("Grants left", std::to_string(s.grants_left));
|
|
row("Snapshot", s.snapshot_tick == 0 ? std::string{"none yet"}
|
|
: "tick " + std::to_string(s.snapshot_tick) + ", " +
|
|
std::to_string(s.cells) + " cells, " +
|
|
std::to_string(s.organisms) + " organisms");
|
|
if (s.focused)
|
|
row("Interest", std::to_string(s.focus_x) + ", " + std::to_string(s.focus_y) + ", z " +
|
|
std::to_string(s.focus_z) + " (radius 7)");
|
|
row("Snapshot bytes", std::to_string(s.snapshot_bytes));
|
|
if (s.marker) { // Probe marker (ADR-0094, EXPERIMENT): predicted and smoothed.
|
|
char position[64];
|
|
std::snprintf(position, sizeof position, "%.2f, %.2f m", s.marker_x_mm / 1000,
|
|
s.marker_y_mm / 1000);
|
|
row("Probe marker", position);
|
|
row("Prediction", std::to_string(s.inputs_pending) + " pending, lead " +
|
|
std::to_string(s.lead) + " ticks");
|
|
row("Corrections", std::to_string(s.corrections) + ", max error " +
|
|
std::to_string(s.max_error_um / 1000) + " mm, " +
|
|
std::to_string(s.snaps) + " snaps");
|
|
char delay[48];
|
|
std::snprintf(delay, sizeof delay, "%zu, %.1f ticks behind, %zu stale", s.other_markers,
|
|
s.interpolation_delay, s.stale_markers);
|
|
row("Other markers", delay);
|
|
}
|
|
ImGui::EndTable();
|
|
}
|
|
if (s.cellular_trial) {
|
|
ImGui::Separator();
|
|
ImGui::TextUnformatted("Nearby food patches (server sensor view)");
|
|
if (!s.cellular_action.empty())
|
|
ImGui::TextWrapped("%s", s.cellular_action.c_str());
|
|
if (!v.cellular_perception) {
|
|
ImGui::TextDisabled("Waiting for the first cell view...");
|
|
} else if (v.cellular_perception->life_identity == 0) {
|
|
ImGui::TextColored(amber, "No living cell is currently bound to this account.");
|
|
} else {
|
|
ImGui::Text("Life %llu, tick %llu",
|
|
static_cast<unsigned long long>(v.cellular_perception->life_identity),
|
|
static_cast<unsigned long long>(v.cellular_perception->tick));
|
|
if (const auto& diagnostics = v.cellular_perception->diagnostics) {
|
|
const auto& matter = diagnostics->reserve_matter_fg;
|
|
ImGui::TextWrapped("Reserve %llu pJ | C %llu N %llu P %llu O %llu fg",
|
|
static_cast<unsigned long long>(diagnostics->reserve_energy_pj),
|
|
static_cast<unsigned long long>(matter[0]),
|
|
static_cast<unsigned long long>(matter[1]),
|
|
static_cast<unsigned long long>(matter[2]),
|
|
static_cast<unsigned long long>(matter[3]));
|
|
const auto movement_name = [&] {
|
|
switch (diagnostics->movement) {
|
|
case network::CellularMovementResult::not_reported:
|
|
return "unavailable";
|
|
case network::CellularMovementResult::no_movement:
|
|
return "no movement";
|
|
case network::CellularMovementResult::moved:
|
|
return "moved";
|
|
case network::CellularMovementResult::blocked:
|
|
return "blocked";
|
|
case network::CellularMovementResult::insufficient_energy:
|
|
return "insufficient reserve";
|
|
}
|
|
return "unknown";
|
|
};
|
|
const auto intake_name = [&] {
|
|
switch (diagnostics->intake) {
|
|
case network::CellularIntakeResult::not_reported:
|
|
return "unavailable";
|
|
case network::CellularIntakeResult::not_requested:
|
|
return "not feeding";
|
|
case network::CellularIntakeResult::acquired:
|
|
return "acquired";
|
|
case network::CellularIntakeResult::missing_patch:
|
|
return "patch missing";
|
|
case network::CellularIntakeResult::out_of_contact:
|
|
return "out of contact";
|
|
}
|
|
return "unknown";
|
|
};
|
|
ImGui::TextWrapped(
|
|
"Last tick: maintenance %llu pJ, movement %llu pJ; %s; feeding %s",
|
|
static_cast<unsigned long long>(diagnostics->maintenance_cost_pj),
|
|
static_cast<unsigned long long>(diagnostics->movement_cost_pj), movement_name(),
|
|
intake_name());
|
|
if (!diagnostics->has_tick_effects)
|
|
ImGui::TextDisabled("Tick effects unavailable after recovery.");
|
|
}
|
|
ImGui::TextDisabled("Steer with movement keys. Feeding continues until stopped.");
|
|
if (v.cellular_feed_target && ImGui::SmallButton("Stop feeding"))
|
|
a.stop_feeding = true;
|
|
if (ImGui::BeginChild("cellular-patches", {0, px(142)}, true)) {
|
|
const auto& patches = v.cellular_perception->patches;
|
|
if (patches.empty())
|
|
ImGui::TextDisabled("No provisioned food within sensor range.");
|
|
for (std::size_t i = 0; i < patches.size(); ++i) {
|
|
const auto& patch = patches[i];
|
|
ImGui::PushID(static_cast<int>(i));
|
|
ImGui::Text("Patch (%u, %u) um", patch.x_um, patch.y_um);
|
|
ImGui::TextWrapped("Energy %llu pJ | C %llu N %llu P %llu O %llu fg",
|
|
static_cast<unsigned long long>(patch.energy_pj),
|
|
static_cast<unsigned long long>(patch.matter_fg[0]),
|
|
static_cast<unsigned long long>(patch.matter_fg[1]),
|
|
static_cast<unsigned long long>(patch.matter_fg[2]),
|
|
static_cast<unsigned long long>(patch.matter_fg[3]));
|
|
const bool active = v.cellular_feed_target &&
|
|
v.cellular_feed_target->first == patch.x_um &&
|
|
v.cellular_feed_target->second == patch.y_um;
|
|
if (active)
|
|
ImGui::TextColored(green, "Feeding target");
|
|
else if (ImGui::SmallButton("Feed this patch"))
|
|
a.feed_patch = {patch.x_um, patch.y_um};
|
|
ImGui::Separator();
|
|
ImGui::PopID();
|
|
}
|
|
}
|
|
ImGui::EndChild();
|
|
}
|
|
}
|
|
disabled_wrapped("Intentions (newest first; this is the record, toasts expire):");
|
|
if (v.outcomes &&
|
|
ImGui::BeginTable("outcomes", 3, ImGuiTableFlags_RowBg | ImGuiTableFlags_SizingFixedFit)) {
|
|
const auto& entries = v.outcomes->entries();
|
|
int shown = 0;
|
|
for (auto it = entries.rbegin(); it != entries.rend() && shown < 10; ++it, ++shown) {
|
|
ImGui::TableNextRow();
|
|
ImGui::TableNextColumn();
|
|
ImGui::Text("#%llu", static_cast<unsigned long long>(it->sequence));
|
|
ImGui::TableNextColumn();
|
|
ImGui::TextUnformatted(outcome_name(it->state));
|
|
ImGui::TableNextColumn();
|
|
if (it->state == client::OutcomeState::durable)
|
|
ImGui::Text("tick %llu, commit %llu", static_cast<unsigned long long>(it->tick),
|
|
static_cast<unsigned long long>(it->commit_sequence));
|
|
else if (it->state == client::OutcomeState::rejected)
|
|
ImGui::Text("status %u", static_cast<unsigned>(it->detail));
|
|
else if (it->tick != 0)
|
|
ImGui::Text("tick %llu", static_cast<unsigned long long>(it->tick));
|
|
}
|
|
ImGui::EndTable();
|
|
}
|
|
ImGui::End();
|
|
}
|
|
|
|
const char* cell_action_name(CellAction kind) {
|
|
switch (kind) {
|
|
case CellAction::engulf:
|
|
return "Engulf";
|
|
case CellAction::bud:
|
|
return "Bud";
|
|
case CellAction::mutation:
|
|
return "Mutation";
|
|
}
|
|
return "Action";
|
|
}
|
|
const char* cell_action_state(CellActionState state) {
|
|
switch (state) {
|
|
case CellActionState::queued:
|
|
return "Queued";
|
|
case CellActionState::sent:
|
|
return "Sent / awaiting admission";
|
|
case CellActionState::admitted:
|
|
return "Accepted / awaiting commit";
|
|
case CellActionState::unresolved:
|
|
return "Unresolved / outcome unknown";
|
|
case CellActionState::committed:
|
|
return "Committed";
|
|
case CellActionState::no_effect:
|
|
return "Committed / no effect";
|
|
case CellActionState::refused:
|
|
return "Refused / no new action";
|
|
}
|
|
return "Unknown";
|
|
}
|
|
void cell_record(const CellActionRecord& record) {
|
|
ImGui::TextColored(record.state == CellActionState::committed ? green : amber, "%s",
|
|
cell_action_name(record.kind));
|
|
ImGui::TextWrapped("%s", cell_action_state(record.state));
|
|
if (record.state == CellActionState::refused &&
|
|
record.refusal != network::AdmitStatus::admitted)
|
|
disabled_wrapped(std::string{cellular_admission_message(record.refusal)}.c_str());
|
|
}
|
|
void cell_vitals(const PanelView& v) {
|
|
const auto* p = v.cellular_perception;
|
|
const auto* play = v.cellular_play;
|
|
ImGui::TextColored(green, "VITAL SIGNS");
|
|
if (!play || !play->fresh())
|
|
ImGui::TextColored(amber, "Waiting for a fresh server view");
|
|
if (!p || !p->diagnostics || !play || play->life() == 0) {
|
|
disabled_wrapped("Your cell's reserves will appear here when a living cell is visible.");
|
|
return;
|
|
}
|
|
const auto& d = *p->diagnostics;
|
|
ImGui::TextDisabled("ENERGY RESERVE");
|
|
ImGui::PushFont(nullptr, 24);
|
|
ImGui::TextWrapped("%llu pJ", static_cast<unsigned long long>(d.reserve_energy_pj));
|
|
ImGui::PopFont();
|
|
if (const auto& change = play->energy_change(); change) {
|
|
ImGui::TextColored(change->falling ? amber : green, "%s%llu pJ net",
|
|
change->falling ? "-" : "+",
|
|
static_cast<unsigned long long>(change->amount));
|
|
ImGui::TextDisabled("Across %llu observed ticks",
|
|
static_cast<unsigned long long>(change->to_tick - change->from_tick));
|
|
if (change->falling)
|
|
disabled_wrapped(
|
|
"Energy is falling. Feeding may not cover upkeep, movement or actions.");
|
|
}
|
|
if (v.cellular_feed_target) {
|
|
const auto patch = std::ranges::find_if(p->patches, [&](const auto& candidate) {
|
|
return v.cellular_feed_target == std::pair{candidate.x_um, candidate.y_um};
|
|
});
|
|
if (patch != p->patches.end() && patch->energy_pj == 0)
|
|
ImGui::TextWrapped("FEED TARGET HAS NO ENERGY. Check Food for another patch.");
|
|
}
|
|
ImGui::Separator();
|
|
if (ImGui::BeginTable("matter", 2, ImGuiTableFlags_SizingStretchSame)) {
|
|
constexpr std::array names{"Carbon", "Nitrogen", "Phosphorus", "Other matter"};
|
|
for (std::size_t i = 0; i < names.size(); ++i) {
|
|
ImGui::TableNextColumn();
|
|
ImGui::TextDisabled("%s", names[i]);
|
|
ImGui::Text("%llu fg", static_cast<unsigned long long>(d.reserve_matter_fg[i]));
|
|
}
|
|
ImGui::EndTable();
|
|
}
|
|
ImGui::Separator();
|
|
if (!d.has_tick_effects) {
|
|
disabled_wrapped("Tick effects are unavailable until the next committed tick.");
|
|
return;
|
|
}
|
|
ImGui::TextWrapped("Last tick: upkeep %llu pJ / movement %llu pJ",
|
|
static_cast<unsigned long long>(d.maintenance_cost_pj),
|
|
static_cast<unsigned long long>(d.movement_cost_pj));
|
|
constexpr std::array movement{"Unavailable", "Resting", "Moving", "Movement blocked",
|
|
"Not enough energy to move"};
|
|
constexpr std::array intake{"Unavailable", "Not feeding", "Feeding attempt processed",
|
|
"Food patch missing", "Move into contact to feed"};
|
|
constexpr std::array engulf{"Unavailable",
|
|
"Not requested",
|
|
"Prey engulfed",
|
|
"No eligible prey in contact",
|
|
"Engulf unsupported here",
|
|
"Engulf failed: no cell touching yours",
|
|
"Engulf failed: prey is too large",
|
|
"Engulf failed: prey's membrane is too thick"};
|
|
constexpr std::array bud{"Unavailable",
|
|
"Not requested",
|
|
"Wildlife bud created",
|
|
"Cell cannot bud yet",
|
|
"Not enough resources to bud",
|
|
"No space for a bud"};
|
|
ImGui::TextWrapped("%s", movement.at(static_cast<std::size_t>(d.movement)));
|
|
ImGui::TextWrapped("%s", intake.at(static_cast<std::size_t>(d.intake)));
|
|
if (d.intake == network::CellularIntakeResult::acquired)
|
|
disabled_wrapped("A feeding attempt can yield zero energy. Watch the reserve change.");
|
|
if (const auto& feedback = play->engulf_feedback(); feedback)
|
|
ImGui::TextWrapped("%s (tick %llu)", engulf.at(static_cast<std::size_t>(feedback->second)),
|
|
static_cast<unsigned long long>(feedback->first));
|
|
if (const auto& feedback = play->bud_feedback(); feedback)
|
|
ImGui::TextWrapped("%s (tick %llu)", bud.at(static_cast<std::size_t>(feedback->second)),
|
|
static_cast<unsigned long long>(feedback->first));
|
|
}
|
|
void cell_food(const PanelView& v, PanelActions& a, FormBuffers& form) {
|
|
ImGui::TextColored(green, "FEED & SURVIVE");
|
|
ImGui::Checkbox("Feed automatically", &form.cellular_controls.auto_feed);
|
|
ImGui::Checkbox("Slow near food", &form.cellular_controls.slow_near_food);
|
|
ImGui::Checkbox("Precision steering (20%)", &form.cellular_controls.precision);
|
|
ImGui::SetNextItemWidth(-1);
|
|
ImGui::SliderInt("##speed", &form.cellular_controls.speed_percent, 1, 100, "Speed: %d%%");
|
|
disabled_wrapped(
|
|
"Map key: gold E = energy, teal M = matter; no letters = empty (zoom in to "
|
|
"see letters). Auto feed prefers energy in contact. Choose a patch for manual feeding.");
|
|
disabled_wrapped("Patch stock is finite and shared. Matter does not replenish energy. Uptake "
|
|
"is limited by your cell; stock is not a promise of gain each tick. Upkeep is "
|
|
"paid before feeding.");
|
|
const bool active = v.cellular_play && v.cellular_play->fresh() && v.cellular_play->life() != 0;
|
|
ImGui::BeginDisabled(!active);
|
|
if (v.cellular_feed_target && ImGui::Button("Stop feeding", {-1, 0}))
|
|
a.stop_feeding = true;
|
|
if (const auto* p = v.cellular_perception) {
|
|
if (p->patches.empty())
|
|
disabled_wrapped("No food is visible within sensor range.");
|
|
for (const auto& patch : p->patches) {
|
|
ImGui::PushID(static_cast<int>(patch.x_um));
|
|
ImGui::PushID(static_cast<int>(patch.y_um));
|
|
ImGui::Separator();
|
|
ImGui::Text("Patch %u / %u um", patch.x_um, patch.y_um);
|
|
const bool has_matter =
|
|
std::ranges::any_of(patch.matter_fg, [](auto amount) { return amount != 0; });
|
|
ImGui::TextColored(patch.energy_pj != 0 ? amber : green, "%s",
|
|
patch.energy_pj != 0 ? "E ENERGY AVAILABLE"
|
|
: has_matter ? "M MATTER ONLY / NO ENERGY"
|
|
: "EMPTY / DEPLETED");
|
|
ImGui::Text("Energy stock: %llu pJ", static_cast<unsigned long long>(patch.energy_pj));
|
|
ImGui::TextWrapped("C %llu / N %llu / P %llu / other %llu fg",
|
|
static_cast<unsigned long long>(patch.matter_fg[0]),
|
|
static_cast<unsigned long long>(patch.matter_fg[1]),
|
|
static_cast<unsigned long long>(patch.matter_fg[2]),
|
|
static_cast<unsigned long long>(patch.matter_fg[3]));
|
|
const bool selected = v.cellular_feed_target == std::pair{patch.x_um, patch.y_um};
|
|
if (selected)
|
|
ImGui::TextColored(green, "FEEDING TARGET");
|
|
else if (ImGui::Button("Feed here", {-1, 0}))
|
|
a.feed_patch = {patch.x_um, patch.y_um};
|
|
ImGui::PopID();
|
|
ImGui::PopID();
|
|
}
|
|
}
|
|
ImGui::EndDisabled();
|
|
}
|
|
void cell_actions(const PanelView& v, PanelActions& a) {
|
|
const auto* play = v.cellular_play;
|
|
ImGui::Separator();
|
|
ImGui::TextColored(green, "ACT ONCE");
|
|
ImGui::BeginDisabled(!play || !play->can_act());
|
|
const float width = (ImGui::GetContentRegionAvail().x - ImGui::GetStyle().ItemSpacing.x) / 2;
|
|
if (ImGui::Button("Engulf", {width, px(32)}))
|
|
a.cell_action = CellAction::engulf;
|
|
ImGui::SameLine();
|
|
if (ImGui::Button("Bud", {width, px(32)}))
|
|
a.cell_action = CellAction::bud;
|
|
ImGui::EndDisabled();
|
|
disabled_wrapped("Engulf attempts nearby prey. Bud funds an independent descendant; you keep "
|
|
"your cell. Automatic feeding resumes after the action tick.");
|
|
if (!play)
|
|
return;
|
|
if (const auto& pending = play->pending(); pending) {
|
|
ImGui::Separator();
|
|
cell_record(*pending);
|
|
if (pending->state == CellActionState::unresolved) {
|
|
disabled_wrapped("The reply was lost or is unavailable. Checking the original request; "
|
|
"no second action is created.");
|
|
if (ImGui::Button("Keep result as unknown", {-1, 0}))
|
|
a.keep_unknown = true;
|
|
}
|
|
}
|
|
}
|
|
void cell_evolution(const PanelView& v, PanelActions& a) {
|
|
const auto* play = v.cellular_play;
|
|
ImGui::TextColored(green, "LIFE & EVOLUTION");
|
|
if (!play)
|
|
return;
|
|
if (play->life() == 0) {
|
|
ImGui::Separator();
|
|
if (const auto& ended = play->ended(); ended) {
|
|
ImGui::TextColored(amber, "THIS LIFE HAS ENDED");
|
|
const auto cause = ended->cause;
|
|
ImGui::TextWrapped("%s", cause == network::CellularDeathReason::starved
|
|
? "Your cell starved."
|
|
: cause == network::CellularDeathReason::engulfed
|
|
? "Your cell was engulfed."
|
|
: "The cause was not recorded.");
|
|
if (cause == network::CellularDeathReason::starved)
|
|
disabled_wrapped("Your reserve could not pay upkeep before feeding. A patch can "
|
|
"still hold matter after its energy runs out; intake can also be "
|
|
"slower than your energy spending.");
|
|
ImGui::TextWrapped("Its history and descendants remain. Your next life begins as a new "
|
|
"primitive cell.");
|
|
} else {
|
|
ImGui::TextWrapped("%s", play->birth_pending() ? "Establishing your cell..."
|
|
: "No active cell is visible.");
|
|
disabled_wrapped("A missing view alone does not reveal a death cause. A suspended cell "
|
|
"may still be waiting for space to resume.");
|
|
}
|
|
ImGui::BeginDisabled(!play->can_restart());
|
|
if (ImGui::Button("Start new life", {-1, px(38)}))
|
|
a.restart_life = true;
|
|
ImGui::EndDisabled();
|
|
if (play->birth_pending())
|
|
disabled_wrapped(
|
|
"Waiting for the server. Rechecking this same birth request every "
|
|
"2 seconds. Reconnecting or creating an account cannot refill a nursery.");
|
|
if (v.remote && !v.remote->cellular_action.empty())
|
|
ImGui::TextWrapped("%s", v.remote->cellular_action.c_str());
|
|
return;
|
|
}
|
|
const auto& offer = play->offer();
|
|
if (!offer) {
|
|
ImGui::Separator();
|
|
ImGui::TextWrapped("Feed. Adapt. Leave descendants.");
|
|
disabled_wrapped("Useful feeding earns mutation opportunities. When an offer arrives, "
|
|
"choose a tradeoff for this life.");
|
|
ImGui::Spacing();
|
|
disabled_wrapped("No offer is available yet. Wildlife descendants inherit your genome and "
|
|
"live independently.");
|
|
return;
|
|
}
|
|
ImGui::TextColored(amber, "MUTATION AVAILABLE");
|
|
disabled_wrapped("Useful feeding earned this choice. Each change trades a capability against "
|
|
"upkeep and body mass. The server checks your reserve when it commits.");
|
|
constexpr std::array capabilities{"Energy conversion", "Membrane", "Movement",
|
|
"Ingestion", "Reproduction", "Target size",
|
|
"Thermal tolerance"};
|
|
constexpr std::array effects{"Increase", "Decrease", "Acquire", "Shed"};
|
|
for (const auto& c : offer->candidates) {
|
|
ImGui::PushID(static_cast<int>(c.operator_id));
|
|
ImGui::Separator();
|
|
ImGui::TextWrapped("%s %s", effects.at(c.effect), capabilities.at(c.capability));
|
|
constexpr std::array increase{"Convert more intake into usable energy.",
|
|
"Build a thicker protective membrane.",
|
|
"Raise your maximum movement speed.",
|
|
"Raise how much food you can ingest per second.",
|
|
"Increase your reproduction capability.",
|
|
"Grow toward a larger target body mass.",
|
|
"Widen your temperature tolerance."};
|
|
constexpr std::array decrease{"Reduce energy conversion capability.",
|
|
"Build a thinner membrane.",
|
|
"Lower your maximum movement speed.",
|
|
"Lower how much food you can ingest per second.",
|
|
"Reduce your reproduction capability.",
|
|
"Grow toward a smaller target body mass.",
|
|
"Narrow your temperature tolerance."};
|
|
disabled_wrapped(c.effect == 3 ? "Remove this capability from your genome."
|
|
: c.effect == 2 ? "Add this capability to your genome."
|
|
: c.effect == 0 ? increase.at(c.capability)
|
|
: decrease.at(c.capability));
|
|
constexpr std::array units{"per 1000", "um", "um/s", "fg/s", "per 1000", "fg", "mK"};
|
|
ImGui::TextWrapped("Successor value %u %s", c.parameter, units.at(c.capability));
|
|
ImGui::TextWrapped("Maintenance %llu pJ / s\nTotal mass %llu fg",
|
|
static_cast<unsigned long long>(c.maintenance),
|
|
static_cast<unsigned long long>(c.total_mass));
|
|
const auto* perception = v.cellular_perception;
|
|
const bool affordable =
|
|
perception && perception->diagnostics && can_fund(c, *perception->diagnostics);
|
|
ImGui::TextWrapped("Cost: %llu pJ\nC %llu / N %llu / P %llu / other %llu fg",
|
|
static_cast<unsigned long long>(c.cost_energy_pj),
|
|
static_cast<unsigned long long>(c.cost_matter_fg[0]),
|
|
static_cast<unsigned long long>(c.cost_matter_fg[1]),
|
|
static_cast<unsigned long long>(c.cost_matter_fg[2]),
|
|
static_cast<unsigned long long>(c.cost_matter_fg[3]));
|
|
if (!affordable)
|
|
ImGui::TextColored(amber, "Need more reserves");
|
|
ImGui::BeginDisabled(!affordable || !play->can_act() || !v.remote ||
|
|
v.remote->server_tick <= offer->offer_tick);
|
|
if (ImGui::Button("Choose mutation", {-1, px(30)}))
|
|
a.mutation = MutationChoice{offer->life_identity, offer->event_index, offer->offer_tick,
|
|
c.operator_id};
|
|
ImGui::EndDisabled();
|
|
ImGui::PopID();
|
|
}
|
|
}
|
|
void cell_log(const PanelView& v, FormBuffers& form) {
|
|
ImGui::TextColored(green, "ACTION RECORD");
|
|
if (v.cellular_play) {
|
|
const auto& records = v.cellular_play->history();
|
|
if (records.empty())
|
|
disabled_wrapped("Your discrete action results will appear here.");
|
|
for (auto it = records.rbegin(); it != records.rend(); ++it) {
|
|
cell_record(*it);
|
|
ImGui::Separator();
|
|
}
|
|
}
|
|
if (v.remote) {
|
|
ImGui::TextWrapped("Region %llu / tick %llu / grants %zu",
|
|
static_cast<unsigned long long>(v.remote->region),
|
|
static_cast<unsigned long long>(v.remote->server_tick),
|
|
v.remote->grants_left);
|
|
}
|
|
ImGui::Checkbox("Engineering panels", &form.engineering);
|
|
disabled_wrapped("On disconnect your biology freezes immediately, but the cell remains "
|
|
"vulnerable for the 10-second linger before suspension.");
|
|
}
|
|
void cellular(const PanelView& v, FormBuffers& form, PanelActions& a) {
|
|
const auto& io = ImGui::GetIO();
|
|
const float margin = px(12), top = px(58);
|
|
const bool compact = io.DisplaySize.x < px(880);
|
|
const float height = std::max(px(80), io.DisplaySize.y - top - margin);
|
|
const float left_width = compact ? std::min(px(330), io.DisplaySize.x - 2 * margin) : px(280);
|
|
const auto flags = ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize |
|
|
ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoSavedSettings;
|
|
ImGui::SetNextWindowPos({margin, top}, ImGuiCond_Always);
|
|
ImGui::SetNextWindowSize({left_width, height}, ImGuiCond_Always);
|
|
ImGui::Begin("Cellular field journal", nullptr, flags);
|
|
if (ImGui::BeginTabBar("cell-tabs")) {
|
|
if (ImGui::BeginTabItem("Cell")) {
|
|
disabled_wrapped(form.cellular_controls.auto_feed ? "AUTO FEED ON / steering in Food"
|
|
: "MANUAL FEED / steering in Food");
|
|
cell_vitals(v);
|
|
cell_actions(v, a);
|
|
if (v.bindings) {
|
|
ImGui::Separator();
|
|
disabled_wrapped(controls_hint(*v.bindings).c_str());
|
|
}
|
|
ImGui::EndTabItem();
|
|
}
|
|
if (ImGui::BeginTabItem("Food")) {
|
|
cell_food(v, a, form);
|
|
ImGui::EndTabItem();
|
|
}
|
|
if (compact && ImGui::BeginTabItem("Life")) {
|
|
cell_evolution(v, a);
|
|
ImGui::EndTabItem();
|
|
}
|
|
if (ImGui::BeginTabItem("Log")) {
|
|
cell_log(v, form);
|
|
ImGui::EndTabItem();
|
|
}
|
|
ImGui::EndTabBar();
|
|
}
|
|
ImGui::End();
|
|
if (!compact) {
|
|
ImGui::SetNextWindowPos({io.DisplaySize.x - margin, top}, ImGuiCond_Always, {1, 0});
|
|
ImGui::SetNextWindowSize({px(300), height}, ImGuiCond_Always);
|
|
ImGui::Begin("Evolution", nullptr, flags);
|
|
cell_evolution(v, a);
|
|
ImGui::End();
|
|
}
|
|
}
|
|
|
|
// Newest at the bottom right. Each notice wraps its text beside a reserved close
|
|
// column, so the button is always visible; the stack stops at 60 % of the viewport
|
|
// height and counts what it could not show (those still expire or can be dismissed
|
|
// once space frees). Notices are not the outcome record (Session panel is).
|
|
void notices(const PanelView& v, PanelActions& a) {
|
|
const auto& io = ImGui::GetIO();
|
|
const float width = std::min(px(notice_width), io.DisplaySize.x - px(16));
|
|
const float top = io.DisplaySize.y * 0.4F;
|
|
float y = io.DisplaySize.y - px(8);
|
|
const auto list = v.ui->notices();
|
|
std::size_t hidden = 0;
|
|
for (auto it = list.rbegin(); it != list.rend(); ++it) {
|
|
const auto& n = *it;
|
|
if (y < top || width < 120) {
|
|
++hidden;
|
|
continue;
|
|
}
|
|
ImGui::SetNextWindowPos({io.DisplaySize.x - px(8), y}, ImGuiCond_Always, {1, 1});
|
|
ImGui::SetNextWindowSize({width, 0}, ImGuiCond_Always);
|
|
const std::string id = notice_window_prefix + std::to_string(n.id);
|
|
ImGui::Begin(id.c_str(), nullptr,
|
|
ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoMove |
|
|
ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing);
|
|
if (ImGui::BeginTable("notice", 2)) {
|
|
ImGui::TableSetupColumn("text", ImGuiTableColumnFlags_WidthStretch);
|
|
ImGui::TableSetupColumn("close", ImGuiTableColumnFlags_WidthFixed,
|
|
px(notice_close_width));
|
|
ImGui::TableNextRow();
|
|
ImGui::TableNextColumn();
|
|
ImGui::PushStyleColor(ImGuiCol_Text, n.level == client::NoticeLevel::error ? red
|
|
: n.level == client::NoticeLevel::warning ? amber
|
|
: green);
|
|
ImGui::TextWrapped("%s", n.text.c_str());
|
|
ImGui::PopStyleColor();
|
|
ImGui::TableNextColumn();
|
|
if (ImGui::Button(("x" + id).c_str(), {px(notice_close_width), 0}))
|
|
a.dismiss_notice = n.id;
|
|
ImGui::EndTable();
|
|
}
|
|
y -= ImGui::GetWindowHeight() + px(4);
|
|
ImGui::End();
|
|
}
|
|
if (v.ui->evicted_notices() > 0 || hidden > 0) {
|
|
ImGui::SetNextWindowPos({io.DisplaySize.x - px(8), y}, ImGuiCond_Always, {1, 1});
|
|
ImGui::Begin("##evicted", nullptr,
|
|
ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_AlwaysAutoResize |
|
|
ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing);
|
|
if (hidden > 0)
|
|
ImGui::TextDisabled("%zu more notices (dismiss to show)", hidden);
|
|
if (v.ui->evicted_notices() > 0)
|
|
ImGui::TextDisabled("%llu older notices discarded",
|
|
static_cast<unsigned long long>(v.ui->evicted_notices()));
|
|
ImGui::End();
|
|
}
|
|
}
|
|
|
|
void dialog(const PanelView& v, PanelActions& a) {
|
|
const auto& d = v.ui->dialog();
|
|
if (!d)
|
|
return;
|
|
const std::string id = d->title + "##dialog" + std::to_string(d->id);
|
|
ImGui::OpenPopup(id.c_str());
|
|
if (ImGui::BeginPopupModal(id.c_str(), nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
|
|
ImGui::TextWrapped("%s", d->body.c_str());
|
|
if (ImGui::Button("Confirm", {px(120), 0}))
|
|
a.confirm_dialog = d->id;
|
|
ImGui::SameLine();
|
|
if (ImGui::Button("Cancel", {px(120), 0}))
|
|
a.cancel_dialog = d->id;
|
|
ImGui::EndPopup();
|
|
}
|
|
}
|
|
} // namespace
|
|
|
|
void FormBuffers::load(const client::ConnectForm& f) {
|
|
copy(endpoint, f.endpoint);
|
|
copy(server_name, f.server_name);
|
|
copy(authority, f.authority_path);
|
|
copy(grants, f.grants_path);
|
|
}
|
|
|
|
client::ConnectForm FormBuffers::form() const {
|
|
return {text(endpoint), text(server_name), text(authority), text(grants)};
|
|
}
|
|
|
|
PanelActions draw_panels(const PanelView& view, FormBuffers& form,
|
|
render::EnvironmentDisplay& display) {
|
|
PanelActions actions;
|
|
if (view.mode == Mode::launcher) {
|
|
launcher(view, form, actions);
|
|
} else {
|
|
banner(view, actions);
|
|
if (view.remote && view.remote->cellular_trial)
|
|
cellular(view, form, actions);
|
|
if (!view.remote || !view.remote->cellular_trial || form.engineering) {
|
|
legend(view, display);
|
|
inspector(view);
|
|
session(view, actions);
|
|
}
|
|
}
|
|
controls(view, actions);
|
|
notices(view, actions);
|
|
dialog(view, actions);
|
|
return actions;
|
|
}
|
|
} // namespace evo::client_app
|