private void ProcessPlaceCharacter(LogicalPlaceObject placeObject) { if (!placeObject.ModifyingExisting) { ImGui.Button("Initialize"); ImGui.SameLine(); if (placeObject.Character is int character) { if (ImGui.InputInt("##place character", ref character)) { if (_utilities !.IsCharacterPlaceable(character, out var whyNot)) { placeObject.SetCharacter(character); } else { ImGui.TextColored(ColorRgbaF.Red.ToVector4(), whyNot.ToString()); } } } else { ImGui.TextColored(ColorRgbaF.Red.ToVector4(), "Invalid character"); } }
public void AddPlaceObject(int depth, int?character) { if (_placeObjects.ContainsKey(depth)) { throw new AptEditorException(ErrorType.PlaceObjectDepthAlreadyTaken); } var currentIndex = CurrentItems.Count; FrameItem? created; LogicalPlaceObject?logicalPO; if (character is int index) { var po = PlaceObject.Create(depth, index); created = po; logicalPO = new LogicalPlaceObject(EditAndUpdate, po); } else { created = RemoveObject.Create(depth); logicalPO = null; } void Add() { CurrentItems.Add(created); _placeObjects.Add(depth, logicalPO); } void Remove() { CurrentItems.RemoveAt(currentIndex); _placeObjects.Remove(depth); } EditAndUpdate(new EditAction(Add, Remove, "Add PlaceObject")); }