Example #1
0
        public void DrawLines(SpriteBatch spriteBatch)
        {
            RasterizerState state = new RasterizerState {
                ScissorTestEnable = true
            };

            spriteBatch.End();

            spriteBatch.Begin(SpriteSortMode.Texture, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, state, null, Main.UIScaleMatrix);

            foreach (UIResearch element in view.items.Select(x => (UIResearch)x))
            {
                if (element.research.Parents.Any())
                {
                    foreach (string parent in element.research.Parents)
                    {
                        UIResearch research = view.items.Select(x => (UIResearch)x).FirstOrDefault(x => x.research.Name == parent);

                        if (research != null)
                        {
                            foreach (Line line in CreateBolt(element.GetDimensions().Center(), research.GetDimensions().Center(), 2f))
                            {
                                line.Draw(spriteBatch, Color.LightBlue);
                            }
                        }
                    }
                }
            }

            spriteBatch.End();
            spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, state, null, Main.UIScaleMatrix);
        }
Example #2
0
        public void PopulateView()
        {
            view.Clear();

            if (currentCategory != null)
            {
                foreach (KeyValuePair <string, ModResearch> item in currentCategory.research)
                {
                    UIResearch research = new UIResearch(item.Value);
                    research.Width.Pixels  = 40;
                    research.Height.Pixels = 40;
                    research.BasePosition  = item.Value.position;
                    research.HoverText     = item.Value.DisplayName.GetTranslation(Language.ActiveCulture) + "\n" + item.Value.Tooltip.GetTranslation(Language.ActiveCulture);
                    view.Add(research);
                }
            }

            view.RecalculateChildren();
        }