public IEnumerable <IComponent> GetSetMenu(List <string> sets, string activeSet, IComponent template)
        {
            int h      = 25;
            int margin = 5;

            List <IComponent> menuItems = new List <IComponent>();

            int y = margin * 2;

            foreach (string menu in sets)
            {
                var m = template.Clone(Helper.GetPlatoHelper(), menu);
                if (menu.Equals(activeSet))
                {
                    m.Select();
                }

                if (m.GetComponentsByTag("caption").FirstOrDefault() is TextComponent t)
                {
                    t.ParseAttribute("content", menu);
                    t.Recompose();
                }

                m.ParseAttribute("Y", y.ToString());

                y += (h + margin);

                menuItems.Add(m);
            }

            return(menuItems);
        }
Exemple #2
0
        public IComponent Duplicate(IComponent component)
        {
            var newComponent = component.Clone();

            // Add target to our document

            return(newComponent);
        }
        public IEnumerable <IComponent> GetTiles(Rectangle tBounds, GameLocation tLocation, List <Point> highlights, bool loaded, IComponent template)
        {
            List <IComponent> components = new List <IComponent>();

            if (!loaded)
            {
                Helper.GetPlatoHelper().SetDelayedAction(1, () =>
                {
                    template.Parent.Repopulate();
                    template.Parent.Recompose();
                });
                return(components);
            }

            int   ph          = template.Parent.Bounds.Height;
            int   pw          = template.Parent.Bounds.Width;
            float fitToHeight = (float)ph / (float)tBounds.Height;
            float fitToWidth  = (float)pw / (float)tBounds.Width;
            float scale       = Math.Min(Math.Min(fitToHeight, fitToWidth), 4f);
            float w           = (tBounds.Width * scale);
            float h           = (tBounds.Height * scale);

            int   sx       = (int)((pw - w) / 2);
            int   sy       = (int)((ph - h) / 2);
            float tilesize = (Game1.tileSize / 4f) * scale;
            int   tilesx   = (int)(w / tilesize);
            int   tilesy   = (int)(h / tilesize);

            for (int tx = 0; tx <= tilesx; tx++)
            {
                for (int ty = 0; ty <= tilesy; ty++)
                {
                    bool clear = tLocation?.isTileLocationTotallyClearAndPlaceableIgnoreFloors(new Vector2(tx, ty)) ?? false;
                    bool high  = highlights.Any(p => p.X == tx && p.Y == ty);
                    if (clear || high)
                    {
                        var t = template.Clone(Helper.GetPlatoHelper());
                        t.ParseAttribute("Width", ((int)tilesize).ToString());
                        t.ParseAttribute("Height", ((int)tilesize).ToString());
                        t.ParseAttribute("X", ((int)(sx + tx * tilesize)).ToString());
                        t.ParseAttribute("Y", ((int)(sy + ty * tilesize)).ToString());
                        if (high)
                        {
                            t.AddTag("highlight");
                        }

                        if (clear)
                        {
                            t.Params = new string[] { tx.ToString(), ty.ToString() }
                        }
                        ;
                        components.Add(t);
                    }
                }
            }

            return(components);
        }
        private void TestClone()
        {
            int        hr;
            IComponent it;

            hr = m_comp.Clone(out it);
            DsError.ThrowExceptionForHR(hr);

            Debug.Assert(it != null, "Clone");
        }
Exemple #5
0
 /// <summary>
 /// Create a new instance of the component container with the provided component as the "Current".
 /// "Next" will be created automatically.
 /// </summary>
 /// <param name="component"></param>
 public ComponentContainer(IComponent component)
 {
     Current = component;
     Next    = Current.Clone();
 }
        public IEnumerable <IComponent> GetLocationsForSet(string set, string activeLocation, List <string> menuEntries, IComponent template, out int cols)
        {
            int h      = 25;
            int w      = 120;
            int margin = 5;

            List <string> locations = new List <string>();

            Func <GameLocation, bool> inGroup = (l) => l.map.Properties.ContainsKey("Group");

            if (set == i18n.Get("menu.outdoors"))
            {
                locations = Game1.locations.Where(l => !inGroup(l) && l.IsOutdoors && !(l.IsFarm || l.IsGreenhouse)).Select(g => g.NameOrUniqueName).ToList();
            }
            else if (set == i18n.Get("menu.indoors"))
            {
                locations = Game1.locations.Where(l => !inGroup(l) && !l.IsOutdoors && !(l.IsFarm || l.IsGreenhouse)).Select(g => g.NameOrUniqueName).ToList();
            }
            else if (set == i18n.Get("menu.buildings"))
            {
                locations = Game1.locations.Where(l => l is BuildableGameLocation)
                            .SelectMany(bgl => (bgl as BuildableGameLocation).buildings)
                            .Where(b => b.indoors.Value is GameLocation)
                            .Select(b => b.indoors.Value.NameOrUniqueName)
                            .ToList();
            }
            else if (set == i18n.Get("menu.farm"))
            {
                locations = Game1.locations.Where(l => l.IsFarm || l.IsGreenhouse).Select(g => g.NameOrUniqueName).ToList();
            }
            else if (set == i18n.Get("menu.artifacts"))
            {
                locations = Game1.locations.Where(l => l.Objects.Values.FirstOrDefault(o => o.ParentSheetIndex == 590) is StardewValley.Object).Select(g => g.NameOrUniqueName).ToList();
            }
            else if (set == i18n.Get("menu.farm"))
            {
                locations = Game1.locations.Where(l => l.IsFarm || l.IsGreenhouse).Select(g => g.NameOrUniqueName).ToList();
            }
            else if (set == i18n.Get("menu.characters"))
            {
                locations = new List <string>();
                foreach (var loc in Game1.locations)
                {
                    foreach (var character in loc.characters.Where(v => v.isVillager()))
                    {
                        locations.Add(character.Name);
                    }
                }
            }
            else
            {
                locations = Game1.locations.Where(l => inGroup(l) && l.map.Properties["Group"].ToString().Equals(set)).Select(g => g.NameOrUniqueName).ToList();
            }

            List <IComponent> menuItems = new List <IComponent>();

            int y = margin * 2;
            int x = margin * 2;
            int i = 0;

            cols = 1;
            foreach (string menu in locations.OrderBy(l => l))
            {
                var m = template.Clone(Helper.GetPlatoHelper(), menu);
                if (m.GetComponentsByTag("caption").FirstOrDefault() is TextComponent t)
                {
                    t.ParseAttribute("content", menu);
                    t.Recompose();
                }

                if (activeLocation == menu)
                {
                    m.Parent.DeSelectAll(se => true);
                    m.Select();
                    m.SelectAll(se => se.HasTag("caption"));
                }

                m.ParseAttribute("Y", y.ToString());
                m.ParseAttribute("X", x.ToString());
                y += (h + margin);
                //x += (w + margin);

                menuItems.Add(m);
                i++;

                if (i * (h + (margin * 2)) >= Game1.viewport.Height) //(i == 5)
                {
                    i = 0;
                    cols++;
                    x += (w + margin);
                    y  = margin * 2;
                    //y += (h + margin);
                    //x = margin * 2;
                }
            }

            return(menuItems);
        }
Exemple #7
0
 /// <summary>
 /// Create a new instance of the component container with the provided component as the "Current".
 /// "Next" will be created automatically.
 /// </summary>
 /// <param name="component"></param>
 public ComponentContainer(IComponent component)
 {
     Current = component;
     Next = Current.Clone();
 }
        public object Clone()
        {
            var dn = new DecoratorName((IComponent)iComponent.Clone());

            return(dn);
        }
        public object Clone()
        {
            var dr = new DecoratorRevenue((IComponent)iComponent.Clone());

            return(dr);
        }
        public object Clone()
        {
            var dcp = new DecoratorContactPhone((IComponent)iComponent.Clone());

            return(dcp);
        }