private static void LoadFromRoot(string name, JsonArray root) { foreach (var vl in root) { ImNode.Create(name, vl); } }
private static void ParseNode(ImNode node) { if (node is DialogNode n) { Add(n.Convert()); } }
public static void RenderNodes() { ImGui.Checkbox("Show grid", ref grid); filter.Draw("Filter"); ImGui.Checkbox("Hide filtred", ref hideFiltred); ImGui.Separator(); RenderMenu(); ImNode first = null; var sawFocused = false; foreach (var p in ImNodes.Nodes) { var node = p.Value; var name = node.GetName(); if (!filter.PassFilter(name)) { continue; } if (first == null) { first = node; } if (ImNode.Focused == node) { node.ForceFocus = true; sawFocused = true; } if (ImGui.Selectable($"#{node.Id} {name}", ImNode.Focused == node)) { ImNode.Focused = node; node.ForceFocus = true; sawFocused = true; target = -node.RealPosition + new Vector2((Engine.Instance.GetScreenWidth() - node.Size.X) / 2, (Engine.Instance.GetScreenHeight() - node.Size.Y) / 2); } if (ImGui.OpenPopupOnItemClick("node_menu", 1)) { CurrentMenu = node; } } if (!sawFocused) { ImNode.Focused = first; } ImGui.End(); }
public ImNode NodeForPlacement(NodePlacement placement) { foreach (ImEntity entity in entities) { ImNode node = entity as ImNode; if (node.nodePlacement == placement) { return(node); } } return(null); }
public static void RenderUi() { if (ImNode.Focused != null) { if (last != ImNode.Focused) { last = ImNode.Focused; str.Label = Locale.Get(ImNode.Focused.LocaleId); } } str.Render(); }
public ImNodeLayer() { for (int i = 0; i < (int)(NodePlacement.MAX - 1); i++) { ImNode node = new ImNode((NodePlacement)(i + 1)); Vector2 pos = ImConfig.PositionForNodePlacement(node.nodePlacement); node.x = pos.x; node.y = pos.y; node.HealthComponent().SignalHealthChanged += NodeHealthChanged; entities.Add(node); AddChild(node); } }
public void HandlePopoverNeedsInventoryRefresh(WTPopoverDialogue popover) { ImNode node = (ImNode)popover.correspondingEntity; bool hasTitle = false; bool hasDone = false; foreach (ImTableCell cell in popover.tableCells) { if (cell.tableCellType == TableCellType.Done) { hasDone = true; } if (cell.tableCellType == TableCellType.Title) { hasTitle = true; } } if (!hasTitle) { popover.AddTableCell(ImConfig.NameForNodePlacement(node.nodePlacement), TableCellType.Title); } foreach (ImAbstractItem item in inventory) { ImTableCell cellWithItem = null; foreach (ImTableCell itemCell in popover.tableCells) { if (itemCell.item == item) { cellWithItem = itemCell; } } if (cellWithItem == null && item.CanBeUsedOnEntity(popover.correspondingEntity)) { popover.AddTableCell(item.Description(), "Futile_White", item, TableCellType.Item); } if (cellWithItem != null && !item.CanBeUsedOnEntity(popover.correspondingEntity)) { popover.RemoveTableCell(cellWithItem); } } if (!hasDone) { popover.AddTableCell("Done", TableCellType.Done); } }
public List <ImNode> CorrespondingNodesInNodeLayer(ImNodeLayer nodeLayer) { List <ImNode> nodes = new List <ImNode>(); ImNode fromNode = nodeLayer.NodeForPlacement(veinEndpoints.fromNodePlacement); ImNode toNode = nodeLayer.NodeForPlacement(veinEndpoints.toNodePlacement); if (fromNode != null) { nodes.Add(fromNode); } if (toNode != null) { nodes.Add(toNode); } return(nodes); }
public static void Load() { var dir = FileHandle.FromRoot("Dialogs"); foreach (var f in dir.ListFileHandles()) { if (f.Extension == ".json") { try { var name = f.NameWithoutExtension; var root = JsonValue.Parse(f.ReadAll()); // Create nodes foreach (var vl in root.AsJsonArray) { try { ImNode.Create(name, vl); } catch (Exception e) { } } // Connect em foreach (var node in ImNodes.Nodes) { node.Value.ReadOutputs(); } // Parse foreach (var node in ImNodes.Nodes) { ParseNode(node.Value); } ImNodes.Nodes.Clear(); ImNode.LastId = 0; } catch (Exception e) { Log.Error(e); } } } }
public bool HandleSingleTouchBegan(FTouch touch) { ImNode touchedNode = null; foreach (ImEntity entity in nodeLayer.entities) { ImNode node = entity as ImNode; if (node.ContainsGlobalPoint(touch.position)) { touchedNode = node; } } foreach (ImEntity entity in nodeLayer.entities) { ImNode node = entity as ImNode; if (node.ContainsGlobalPoint(touch.position)) { touchedNode = node; } } if (touchedNode != null && !pop.isShowing) { pop.Show(inventory, touchedNode); } if (pop != null) { if (pop.HandleTouchBegan(touch)) { currentEntityWithFocus = pop; } } return(true); }
public void NodeHealthChanged(ImAbstractComponent ac) { ImNode node = (ImNode)ac.owner; node.RadialWipeSpriteComponents()[0].sprite.percentage = node.HealthComponent().currentHealth / node.HealthComponent().maxHealth; }
public static bool BeforeRender() { if (grid) { var list = ImGui.GetBackgroundDrawList(); var width = Engine.Instance.GetScreenWidth(); var height = Engine.Instance.GetScreenHeight(); var off = ImNode.Offset; for (float x = off.X % gridSize; x <= width - off.X % gridSize; x += gridSize) { list.AddLine(new Vector2(x, 0), new Vector2(x, height), ((int)(off.X - x) == 0 ? gridMainColor : gridColor).PackedValue); } for (float y = off.Y % gridSize; y <= height - off.Y % gridSize; y += gridSize) { list.AddLine(new Vector2(0, y), new Vector2(width, y), ((int)(off.Y - y) == 0 ? gridMainColor : gridColor).PackedValue); } } RenderVoidMenu(); if (target.HasValue) { ImNode.Offset += (target.Value - ImNode.Offset) * Engine.Delta * 10f; if ((target.Value - ImNode.Offset).Length() <= 3f) { target = null; } } else if (ImGui.IsMouseDragging(2) || Input.Keyboard.IsDown(Keys.Space, true)) { ImNode.Offset += ImGui.GetIO().MouseDelta; } foreach (var n in ImNodes.Nodes) { var node = n.Value; if (!hideFiltred || filter.PassFilter(node.GetName())) { node.Render(); } if (node.Done) { toRemove.Add(n.Key); } } CurrentActive?.RemoveEmptyConnection(); if (toRemove.Count > 0) { var c = ImNodes.Nodes.Count - 1; foreach (var k in toRemove) { if (ImNodes.Nodes[k].Id == c) { ImNode.LastId--; } ImNodes.Nodes.Remove(k); } toRemove.Clear(); } if (pasted != null) { try { var root = JsonValue.Parse(pasted); if (root.IsJsonObject) { var val = root["imnode"]; var node = ImNode.Create(val, true); if (node != null) { node.New = true; node.Position = ImGui.GetIO().MousePos; ImNode.Focused = node; } } } catch (Exception e) { Log.Error(e); } pasted = null; } if (toAdd != null) { var node = ImNodeRegistry.Create(toAdd); if (node != null) { node.New = true; node.Position = ImGui.GetIO().MousePos; node.File = DialogEditor.Current; ImNode.Focused = node; } Node(node); toAdd = null; } ImGui.SetNextWindowSize(size, ImGuiCond.Once); if (!ImGui.Begin("Nodes")) { ImGui.End(); return(false); } return(true); }
public static void Node(ImNode node) { ImNodes.Nodes[node.Id] = node; }
public WTImmunity() : base("") { instance = this; Futile.AddStage(this); gameLayer = new FContainer(); gameLayer.x = Futile.screen.halfWidth; gameLayer.y = Futile.screen.halfHeight; gameLayer.scale = 0.23f; zoomLevel_ = gameLayer.scale; AddChild(gameLayer); inventory = new List <ImAbstractItem>(); inventory.Add(new ImHealthPill("Health Pill", 15)); inventory.Add(new ImPoisonPill("Poison Pill", 6)); inventory.Add(new ImPoisonPill("Poison Pill", 17)); inventory.Add(new ImHealthPill("Health Pill", 5)); inventory.Add(new ImPoisonPill("Poison Pill", 30)); inventory.Add(new ImHealthPill("Health Pill", 7)); inventory.Add(new ImHealthPill("Health Pill", 42)); float sliceWidth = 460f / 4f; float sliceHeight = 436f / 4f; int sliceHorizontalCount = 6; int sliceVerticalCount = 16; float bodyWidth = sliceWidth * sliceHorizontalCount; float bodyHeight = sliceHeight * sliceVerticalCount; FContainer bodyContainer = new FContainer(); bodyContainer.x -= bodyWidth / 2f; bodyContainer.y -= bodyHeight / 2f; gameLayer.AddChild(bodyContainer); for (int i = 0; i < sliceVerticalCount; i++) { for (int j = 0; j < sliceHorizontalCount; j++) { int imageNum = i * sliceHorizontalCount + j + 1; string imageName = string.Format("bodySlices/body_{0}.png", imageNum.ToString("D2")); FSprite slice = new FSprite(imageName); slice.anchorX = slice.anchorY = 0; slice.x = j * sliceWidth; slice.y = bodyHeight - (i + 1) * sliceHeight; bodyContainer.AddChild(slice); } } organLayer = new ImOrganLayer(); organLayer.owner = this; gameLayer.AddChild(organLayer); veinLayer = new ImVeinLayer(); veinLayer.owner = this; gameLayer.AddChild(veinLayer); nodeLayer = new ImNodeLayer(); nodeLayer.owner = this; gameLayer.AddChild(nodeLayer); /*pop = new ImPopoverDialogue(100f, 100f, 4f, PopoverTriangleDirectionType.PointingRight); * AddChild(pop);*/ pop = new WTPopoverDialogue(false, "popover!"); pop.SignalNeedsInventoryRefresh += HandlePopoverNeedsInventoryRefresh; pop.SignalItemUsed += HandleItemUsed; pop.x = Futile.screen.halfWidth; pop.y = Futile.screen.halfHeight; pop.width = 200f; pop.isVisible = false; AddChild(pop); uiLayer = new ImUILayer(); SignalPauseStateChanged += uiLayer.SetTransportBar; AddChild(uiLayer); ImNode node = nodeLayer.NodeForPlacement(NodePlacement.ElbowRight); node.Infect(testVirus); node.InfectionComponent().StartInfecting(); }