Пин со странными символами
Мой класс такой:
Код: Выделить всё
struct Pin
{
int ID;
char Name[32];
Pin(int id, const char *name)
{
ID = id;
strcpy(Name, name);
}
};
struct Node
{
int ID;
char Name[32];
ImVec2 Pos, Size;
float Value;
ImVector
Inputs, Outputs;
Node(int id, const char *name, const ImVec2 &pos, const ImVector inputs, const ImVector outputs)
{
ID = id;
strcpy(Name, name);
Pos = pos;
Inputs = inputs;
Outputs = outputs;
}
ImRect GetInputFlowSlotPos(ImVec2 offset) const
{
return ImRect(offset + ImVec2(Pos.x + 24.0f, Pos.y + 44.0f), offset + ImVec2(Pos.x + 4.0f, Pos.y + 24.0f));
}
ImRect GetOutputFlowSlotPos(ImVec2 offset) const
{
return ImRect(offset + ImVec2(Pos.x + Size.x - 24.0f, Pos.y + 24.0f), offset + ImVec2(Pos.x + Size.x - 4.0f, Pos.y + 44.0f));
}
ImVec2 GetInputSlotPos(int slot_no) const { return ImVec2(Pos.x, Pos.y + Size.y * ((float)slot_no + 1) / ((float)Inputs.Size + 1)); }
ImVec2 GetOutputSlotPos(int slot_no) const { return ImVec2(Pos.x + Size.x, Pos.y + Size.y * ((float)slot_no + 1) / ((float)Outputs.Size + 1)); }
};
Код: Выделить всё
inputsPin.push_back(Pin(0, "X"));
inputsPin.push_back(Pin(1, "Y"));
inputsPin.push_back(Pin(2, "Z"));
nodes.push_back(Node(0, "Di", ImVec2(40, 50), inputsPin, outputsPin));
nodes.push_back(Node(1, "Di", ImVec2(40, 150), inputsPin, outputsPin));
nodes.push_back(Node(2, "Di", ImVec2(270, 80), inputsPin, outputsPin));
Код: Выделить всё
for (int slot_idx = 0; slot_idx < node->Inputs.Size; slot_idx++)
{
Pin *pin = &node->Inputs[slot_idx];
ImGui::SetCursorScreenPos(offset + node->GetInputSlotPos(slot_idx));
ImGui::Text("%s", pin->Name);
}
Подробнее здесь: https://stackoverflow.com/questions/786 ... mvectorpin