Esempio n. 1
0
        public void Update()
        {
            UpdateTabOrder();

            if (DisplayedNode is SupplyNode)
            {
                if (!Parent.ShowMiners)
                {
                    text = "Input: " + (DisplayedNode as SupplyNode).SuppliedItem.FriendlyName;
                }
                else
                {
                    text = "";
                }
            }
            else if (DisplayedNode is ConsumerNode)
            {
                text = "Output: " + (DisplayedNode as ConsumerNode).ConsumedItem.FriendlyName;
            }
            else if (DisplayedNode is RecipeNode)
            {
                if (!Parent.ShowAssemblers)
                {
                    text = "Recipe: " + (DisplayedNode as RecipeNode).BaseRecipe.FriendlyName;
                }
                else
                {
                    text = "";
                }
            }

            Graphics graphics = Parent.CreateGraphics();
            int      minWidth = (int)graphics.MeasureString(text, size10Font).Width;

            Width = Math.Max(75, getIconWidths());
            Width = Math.Max(Width, minWidth);

            if (assemblerBox != null)
            {
                if ((DisplayedNode is RecipeNode && Parent.ShowAssemblers) ||
                    (DisplayedNode is SupplyNode && Parent.ShowMiners))
                {
                    Height = 120;
                    if (DisplayedNode is RecipeNode)
                    {
                        assemblerBox.AssemblerList = (DisplayedNode as RecipeNode).GetMinimumAssemblers();
                    }
                    else if (DisplayedNode is SupplyNode)
                    {
                        assemblerBox.AssemblerList = (DisplayedNode as SupplyNode).GetMinimumMiners();
                    }
                    assemblerBox.Update();
                    Width          = Math.Max(Width, assemblerBox.Width + 20);
                    Height         = assemblerBox.Height + 80;
                    assemblerBox.X = (Width - assemblerBox.Width) / 2 + 2;
                    assemblerBox.Y = (Height - assemblerBox.Height) / 2 + 2;
                }
                else
                {
                    assemblerBox.AssemblerList.Clear();
                    Width  = Math.Max(100, Width);
                    Height = 90;
                    assemblerBox.Update();
                }
            }

            else
            {
                Height = 90;
            }

            foreach (ItemTab tab in inputTabs.Union(outputTabs))
            {
                tab.FillColour = chooseIconColour(tab.Item, tab.Type);
                tab.Text       = getIconString(tab.Item, tab.Type);
            }

            UpdateTabOrder();
        }
Esempio n. 2
0
        public void Update()
        {
            UpdateTabOrder();

            if (DisplayedNode is SupplyNode)
            {
                SupplyNode node = (SupplyNode)DisplayedNode;
                if (!Parent.ShowMiners)
                {
                    if (node.SuppliedItem.IsMissingItem)
                    {
                        text = String.Format("Item not loaded! ({0})", node.DisplayName);
                    }
                    else
                    {
                        text = "Input: " + node.SuppliedItem.FriendlyName;
                    }
                }
                else
                {
                    text = "";
                }
            }
            else if (DisplayedNode is ConsumerNode)
            {
                ConsumerNode node = (ConsumerNode)DisplayedNode;
                if (node.ConsumedItem.IsMissingItem)
                {
                    text = String.Format("Item not loaded! ({0})", node.DisplayName);
                }
                else
                {
                    text = "Output: " + node.ConsumedItem.FriendlyName;
                }
            }
            else if (DisplayedNode is RecipeNode)
            {
                RecipeNode node = (RecipeNode)DisplayedNode;
                if (!Parent.ShowAssemblers)
                {
                    if (node.BaseRecipe.IsMissingRecipe)
                    {
                        text = String.Format("Recipe not loaded! ({0})", node.DisplayName);
                    }
                    else
                    {
                        text = "Recipe: " + node.BaseRecipe.FriendlyName;
                    }
                }
                else
                {
                    text = "";
                }
            }

            Graphics graphics = Parent.CreateGraphics();
            int      minWidth = (int)graphics.MeasureString(text, size10Font).Width;

            Width = Math.Max(75, getIconWidths());
            Width = Math.Max(Width, minWidth);

            if (assemblerBox != null)
            {
                if ((DisplayedNode is RecipeNode && Parent.ShowAssemblers) ||
                    (DisplayedNode is SupplyNode && Parent.ShowMiners))
                {
                    Height = 120;
                    if (DisplayedNode is RecipeNode)
                    {
                        var assemblers = (DisplayedNode as RecipeNode).GetAssemblers();
                        if (Parent.Graph.SelectedAmountType == AmountType.FixedAmount)
                        {
                            assemblers = assemblers.ToDictionary(p => p.Key, p => 0);
                        }
                        assemblerBox.AssemblerList = assemblers;
                    }
                    else if (DisplayedNode is SupplyNode)
                    {
                        assemblerBox.AssemblerList = (DisplayedNode as SupplyNode).GetMinimumMiners();
                    }
                    assemblerBox.Update();
                    Width          = Math.Max(Width, assemblerBox.Width + 20);
                    Height         = assemblerBox.Height + 80;
                    assemblerBox.X = (Width - assemblerBox.Width) / 2 + 2;
                    assemblerBox.Y = (Height - assemblerBox.Height) / 2 + 2;
                }
                else
                {
                    assemblerBox.AssemblerList.Clear();
                    Width  = Math.Max(100, Width);
                    Height = 90;
                    assemblerBox.Update();
                }
            }

            else
            {
                Height = 90;
            }

            foreach (ItemTab tab in inputTabs.Union(outputTabs))
            {
                tab.FillColour = chooseIconColour(tab.Item, tab.Type);
                tab.Text       = getIconString(tab.Item, tab.Type);
            }

            UpdateTabOrder();
        }