MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / RenderEntryValue

Function RenderEntryValue

apps/tools/Studio/StudioApp.cpp:2626–2682  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2624
2625 ImGui::EndChild();
2626}
2627
2628static void RenderEntryValue(const ParamEntry& e)
2629{
2630 if (e.IsArray())
2631 {
2632 std::string val = e.GetName().Data();
2633 val += "[] = {";
2634 int show = std::min(e.GetSize(), 5);
2635 for (int j = 0; j < show; j++)
2636 {
2637 if (j > 0)
2638 val += ", ";
2639 const IParamArrayValue& av = e[j];
2640 if (av.IsFloatValue())
2641 {
2642 char buf[32];
2643 snprintf(buf, sizeof(buf), "%g", av.GetFloat());
2644 val += buf;
2645 }
2646 else if (av.IsIntValue())
2647 val += std::to_string(av.GetInt());
2648 else
2649 {
2650 val += '"';
2651 val += av.GetValue().Data();
2652 val += '"';
2653 }
2654 }
2655 if (e.GetSize() > 5)
2656 val += ", ...";
2657 val += "}";
2658 ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.7f, 0.9f, 0.7f, 1.0f));
2659 ImGui::TextUnformatted(val.c_str());
2660 ImGui::PopStyleColor();
2661 }
2662 else
2663 {
2664 std::string line = e.GetName().Data();
2665 line += " = ";
2666 if (e.IsFloatValue())
2667 {
2668 char buf[32];
2669 snprintf(buf, sizeof(buf), "%g", (float)e);
2670 line += buf;
2671 }
2672 else if (e.IsIntValue())
2673 line += std::to_string((int)e);
2674 else
2675 {
2676 line += '"';
2677 line += e.GetValue().Data();
2678 line += '"';
2679 }
2680 ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.8f, 0.8f, 1.0f, 1.0f));
2681 ImGui::TextUnformatted(line.c_str());
2682 ImGui::PopStyleColor();
2683 }

Callers 1

renderConfigClassTreeMethod · 0.85

Calls 10

minFunction · 0.85
IsArrayMethod · 0.45
DataMethod · 0.45
GetNameMethod · 0.45
GetSizeMethod · 0.45
IsFloatValueMethod · 0.45
GetFloatMethod · 0.45
IsIntValueMethod · 0.45
GetIntMethod · 0.45
GetValueMethod · 0.45

Tested by

no test coverage detected