| 3040 | } |
| 3041 | |
| 3042 | const char* SaveEditorStateToIniString( |
| 3043 | const ImNodesEditorContext* const editor_ptr, |
| 3044 | size_t* const data_size) |
| 3045 | { |
| 3046 | assert(editor_ptr != NULL); |
| 3047 | const ImNodesEditorContext& editor = *editor_ptr; |
| 3048 | |
| 3049 | GImNodes->TextBuffer.clear(); |
| 3050 | // TODO: check to make sure that the estimate is the upper bound of element |
| 3051 | GImNodes->TextBuffer.reserve(64 * editor.Nodes.Pool.size()); |
| 3052 | |
| 3053 | GImNodes->TextBuffer.appendf( |
| 3054 | "[editor]\npanning=%i,%i\n", (int)editor.Panning.x, (int)editor.Panning.y); |
| 3055 | |
| 3056 | for (int i = 0; i < editor.Nodes.Pool.size(); i++) |
| 3057 | { |
| 3058 | if (editor.Nodes.InUse[i]) |
| 3059 | { |
| 3060 | const ImNodeData& node = editor.Nodes.Pool[i]; |
| 3061 | GImNodes->TextBuffer.appendf("\n[node.%d]\n", node.Id); |
| 3062 | GImNodes->TextBuffer.appendf("origin=%i,%i\n", (int)node.Origin.x, (int)node.Origin.y); |
| 3063 | } |
| 3064 | } |
| 3065 | |
| 3066 | if (data_size != NULL) |
| 3067 | { |
| 3068 | *data_size = GImNodes->TextBuffer.size(); |
| 3069 | } |
| 3070 | |
| 3071 | return GImNodes->TextBuffer.c_str(); |
| 3072 | } |
| 3073 | |
| 3074 | void LoadCurrentEditorStateFromIniString(const char* const data, const size_t data_size) |
| 3075 | { |