Exemplo n.º 1
0
        public SwordProperties(string name, uint endurance, uint strength, uint dexterity)
        {
            Add("name", name, "string");

            ItemProperties attributes = new ItemProperties();

            attributes.Add("endurance", endurance, "uint32");
            attributes.Add("strength", endurance, "uint32");
            attributes.Add("dexterity", endurance, "uint32");
            Add("attributes", attributes, "dict");
        }
    public void AddProperty()     //this is called from an ICommand
    {
        Property p = _PropertyService.GetProperty(CurrentItem);

        CurrentItem.Properties.Add(p);
        ItemProperties.Add(p);
    }
Exemplo n.º 3
0
        //------------------------------------------------------------------------------------
        /// <summary>
        /// Ensure that the given property is present in the in-memory cache - if not, the
        /// property is populated with its initial value from the backing store (or with a
        /// default empty value if the item is not a persisted type).
        /// </summary>
        //------------------------------------------------------------------------------------
        private ItemProperty EnsureItemProperty(string dsPropName, string publicPropName, PropType type)
        {
            if (publicPropName == null)
            {
                throw new ApplicationException();
            }

            ItemProperty itemProperty = null;

            lock (SyncLockItemProperties)
            {
                if (!ItemProperties.TryGetValue(publicPropName, out itemProperty))
                {
                    itemProperty = new ItemProperty(this, dsPropName, publicPropName, type);
                    if (IsPersisted)
                    {
                        itemProperty.ReadFromStore();
                    }

                    ItemProperties.Add(publicPropName, itemProperty);
                }
            }

            return(itemProperty);
        }
Exemplo n.º 4
0
        public void PopulateProperties()
        {
            ItemClass parentClass = this.ItemClassParent;

            while (parentClass != null)
            {
                foreach (var property in parentClass.ItemProperties)
                {
                    ItemProperties.Add(new ItemProperty()
                    {
                        Name         = parentClass.Name + ":" + property.Name,
                        BaseVariable = property,
                        Value        = property.GetDefaultValue()
                    });
                }

                parentClass = parentClass.ParentClass;
            }
        }
Exemplo n.º 5
0
        protected override void PopulateStatsList()
        {
            ItemProperties.Add(new SelectableItemPropertyVM(new TextObject("{=CEBROTHEL0976}Level").ToString(), _brothel.Level.ToString()));
            ItemProperties.Add(new SelectableItemPropertyVM(new TextObject("{=CEBROTHEL0988}State").ToString(), _brothel.IsRunning
                                                                    ? new TextObject("{=CEBROTHEL0992}Normal").ToString()
                                                                    : new TextObject("{=CEBROTHEL0991}Closed").ToString()));
            ItemProperties.Add(new SelectableItemPropertyVM(new TextObject("{=CEBROTHEL0977}Initial Capital").ToString(), _brothel.InitialCapital.ToString()));
            ItemProperties.Add(new SelectableItemPropertyVM(new TextObject("{=CEBROTHEL0990}Capital").ToString(), _brothel.Capital.ToString()));
            ItemProperties.Add(new SelectableItemPropertyVM(new TextObject("{=CEBROTHEL0989}Daily Wages").ToString(), _brothel.Expense.ToString()));

            if (_brothel.NotRunnedDays > 0)
            {
                TextObject textObject = new TextObject("{=*}{DAYS} days ago");
                textObject.SetTextVariable("DAYS", _brothel.NotRunnedDays);
                ItemProperties.Add(new SelectableItemPropertyVM(new TextObject("{=*}Last Run").ToString(), textObject.ToString()));
            }

            InputProducts = GameTexts.FindText("str_CE_brothel_description", _brothel.IsRunning
                                                   ? null
                                                   : "inactive").ToString();
            OutputProducts = string.Join(",", _brothel.CaptiveProstitutes.Where(c => c.IsHero).Select(c => c.HeroObject.Name.ToString()).ToArray());
        }
Exemplo n.º 6
0
        internal static void SetGoogleID(object item, string googleItemID)
        {
            ItemProperties properties       = null;
            ItemProperty   property         = null;
            ItemProperty   googleIDProperty = null;

            try
            {
                properties = (ItemProperties)GetItemPropertyValue(item, "ItemProperties");
                for (var i = 0; i < properties.Count; i++)
                {
                    property = properties[i];
                    if (property.Name == VSTO.Properties.Settings.Default.ExtendedPropertyName_GoogleIDInOutlookItem)
                    {
                        googleIDProperty = property;
                        //Marshal.ReleaseComObject(property);
                        //property = null;
                        break;
                    }
                    Marshal.ReleaseComObject(property);
                    property = null;
                }
                /// if the Outlook item is new it has no extended property for Google item ID. So we create it
                if (googleIDProperty == null)
                {
                    googleIDProperty = properties.Add(VSTO.Properties.Settings.Default.ExtendedPropertyName_GoogleIDInOutlookItem, OlUserPropertyType.olText);
                }
                googleIDProperty.Value = googleItemID;
            }
            catch (System.Exception exc)
            {
                ErrorHandler.Handle(exc);
            }
            finally
            {
                Marshal.ReleaseComObject(properties);
                Marshal.ReleaseComObject(googleIDProperty);
            }
        }
Exemplo n.º 7
0
        private static void LoadObjectDbXml(string file)
        {
            var xmlSettings = XElement.Load(file);

            // Load Colors
            foreach (var xElement in xmlSettings.Elements("GlobalColors").Elements("GlobalColor"))
            {
                string    name  = (string)xElement.Attribute("Name");
                XNA.Color color = XnaColorFromString((string)xElement.Attribute("Color"));
                GlobalColors.Add(name, color);
            }

            foreach (var xElement in xmlSettings.Elements("Tiles").Elements("Tile"))
            {
                var curTile = new TileProperty();

                // Read XML attributes
                curTile.Color       = ColorFromString((string)xElement.Attribute("Color"));
                curTile.Name        = (string)xElement.Attribute("Name");
                curTile.Id          = (int?)xElement.Attribute("Id") ?? 0;
                curTile.IsFramed    = (bool?)xElement.Attribute("Framed") ?? false;
                curTile.IsSolid     = (bool?)xElement.Attribute("Solid") ?? false;
                curTile.IsSolidTop  = (bool?)xElement.Attribute("SolidTop") ?? false;
                curTile.IsLight     = (bool?)xElement.Attribute("Light") ?? false;
                curTile.FrameSize   = StringToVector2Short((string)xElement.Attribute("Size"), 1, 1);
                curTile.Placement   = InLineEnumTryParse <FramePlacement>((string)xElement.Attribute("Placement"));
                curTile.TextureGrid = StringToVector2Short((string)xElement.Attribute("TextureGrid"), 16, 16);
                curTile.IsGrass     = "Grass".Equals((string)xElement.Attribute("Special"));    /* Heathtech */
                curTile.IsPlatform  = "Platform".Equals((string)xElement.Attribute("Special")); /* Heathtech */
                curTile.IsCactus    = "Cactus".Equals((string)xElement.Attribute("Special"));   /* Heathtech */
                curTile.IsStone     = (bool?)xElement.Attribute("Stone") ?? false;              /* Heathtech */
                curTile.CanBlend    = (bool?)xElement.Attribute("Blends") ?? false;             /* Heathtech */
                curTile.MergeWith   = (int?)xElement.Attribute("MergeWith") ?? null;            /* Heathtech */
                foreach (var elementFrame in xElement.Elements("Frames").Elements("Frame"))
                {
                    var curFrame = new FrameProperty();
                    // Read XML attributes
                    curFrame.Name    = (string)elementFrame.Attribute("Name");
                    curFrame.Variety = (string)elementFrame.Attribute("Variety");
                    curFrame.UV      = StringToVector2Short((string)elementFrame.Attribute("UV"), 0, 0);
                    curFrame.Anchor  = InLineEnumTryParse <FrameAnchor>((string)elementFrame.Attribute("Anchor"));

                    // Assign a default name if none existed
                    if (string.IsNullOrWhiteSpace(curFrame.Name))
                    {
                        curFrame.Name = curTile.Name;
                    }

                    curTile.Frames.Add(curFrame);
                    Sprites.Add(new Sprite
                    {
                        Anchor           = curFrame.Anchor,
                        IsPreviewTexture = false,
                        Name             = curFrame.Name + ", " + curFrame.Variety,
                        Origin           = curFrame.UV,
                        Size             = curTile.FrameSize,
                        Tile             = (byte)curTile.Id,
                        TileName         = curTile.Name
                    });
                    if (curTile.FrameSize.X == 0 && curTile.FrameSize.Y == 0)
                    {
                        int z = 0;
                    }
                }
                if (curTile.Frames.Count == 0 && curTile.IsFramed)
                {
                    var curFrame = new FrameProperty();
                    // Read XML attributes
                    curFrame.Name    = curTile.Name;
                    curFrame.Variety = string.Empty;
                    curFrame.UV      = new Vector2Short(0, 0);
                    //curFrame.Anchor = InLineEnumTryParse<FrameAnchor>((string)xElement.Attribute("Anchor"));

                    // Assign a default name if none existed
                    if (string.IsNullOrWhiteSpace(curFrame.Name))
                    {
                        curFrame.Name = curTile.Name;
                    }

                    curTile.Frames.Add(curFrame);
                    Sprites.Add(new Sprite
                    {
                        Anchor           = curFrame.Anchor,
                        IsPreviewTexture = false,
                        Name             = curFrame.Name + ", " + curFrame.Variety,
                        Origin           = curFrame.UV,
                        Size             = curTile.FrameSize,
                        Tile             = (byte)curTile.Id,
                        TileName         = curTile.Name
                    });
                }
                TileProperties.Add(curTile);
                if (!curTile.IsFramed)
                {
                    TileBricks.Add(curTile);
                }
            }
            for (int i = TileProperties.Count; i < 255; i++)
            {
                TileProperties.Add(new TileProperty(i, "UNKNOWN", Color.FromArgb(255, 255, 0, 255), true));
            }

            foreach (var xElement in xmlSettings.Elements("Walls").Elements("Wall"))
            {
                var curWall = new WallProperty();
                curWall.Color   = ColorFromString((string)xElement.Attribute("Color"));
                curWall.Name    = (string)xElement.Attribute("Name");
                curWall.Id      = (int?)xElement.Attribute("Id") ?? -1;
                curWall.IsHouse = (bool?)xElement.Attribute("IsHouse") ?? false;
                WallProperties.Add(curWall);
            }

            foreach (var xElement in xmlSettings.Elements("Items").Elements("Item"))
            {
                var curItem = new ItemProperty();
                curItem.Id   = (int?)xElement.Attribute("Id") ?? -1;
                curItem.Name = (string)xElement.Attribute("Name");
                ItemProperties.Add(curItem);
                _itemLookup.Add(curItem.Id, curItem);
            }

            foreach (var xElement in xmlSettings.Elements("Npcs").Elements("Npc"))
            {
                int    id   = (int?)xElement.Attribute("Id") ?? -1;
                string name = (string)xElement.Attribute("Name");
                NpcIds.Add(name, id);
                int frames = (int?)xElement.Attribute("Frames") ?? 16;
                NpcFrames.Add(id, frames);
            }

            foreach (var xElement in xmlSettings.Elements("ItemPrefix").Elements("Prefix"))
            {
                int    id   = (int?)xElement.Attribute("Id") ?? -1;
                string name = (string)xElement.Attribute("Name");
                ItemPrefix.Add((byte)id, name);
            }

            foreach (var xElement in xmlSettings.Elements("ShortCutKeys").Elements("Shortcut"))
            {
                var key  = InLineEnumTryParse <Key>((string)xElement.Attribute("Key"));
                var tool = (string)xElement.Attribute("Tool");
                ShortcutKeys.Add(key, tool);
            }

            XElement appSettings = xmlSettings.Element("App");
            int      appWidth    = (int?)appSettings.Attribute("Width") ?? 800;
            int      appHeight   = (int?)appSettings.Attribute("Height") ?? 600;

            _appSize = new Vector2(appWidth, appHeight);

            ToolDefaultData.LoadSettings(xmlSettings.Elements("Tools"));

            AltC = (string)xmlSettings.Element("AltC");
        }
        private static void LoadObjectDbXml(string file)
        {
            var xmlSettings = XElement.Load(file);

            // Load Colors
            foreach (var xElement in xmlSettings.Elements("GlobalColors").Elements("GlobalColor"))
            {
                string    name  = (string)xElement.Attribute("Name");
                XNA.Color color = XnaColorFromString((string)xElement.Attribute("Color"));
                GlobalColors.Add(name, color);
            }

            foreach (var xElement in xmlSettings.Elements("Tiles").Elements("Tile"))
            {
                var curTile = new TileProperty();

                // Read XML attributes
                curTile.Color        = ColorFromString((string)xElement.Attribute("Color"));
                curTile.Name         = (string)xElement.Attribute("Name");
                curTile.Id           = (int?)xElement.Attribute("Id") ?? 0;
                curTile.IsFramed     = (bool?)xElement.Attribute("Framed") ?? false;
                curTile.IsSolid      = (bool?)xElement.Attribute("Solid") ?? false;
                curTile.IsSolidTop   = (bool?)xElement.Attribute("SolidTop") ?? false;
                curTile.IsLight      = (bool?)xElement.Attribute("Light") ?? false;
                curTile.FrameSize    = StringToVector2Short((string)xElement.Attribute("Size"), 1, 1);
                curTile.Placement    = InLineEnumTryParse <FramePlacement>((string)xElement.Attribute("Placement"));
                curTile.TextureGrid  = StringToVector2Short((string)xElement.Attribute("TextureGrid"), 16, 16);
                curTile.IsGrass      = "Grass".Equals((string)xElement.Attribute("Special"));    /* Heathtech */
                curTile.IsPlatform   = "Platform".Equals((string)xElement.Attribute("Special")); /* Heathtech */
                curTile.IsCactus     = "Cactus".Equals((string)xElement.Attribute("Special"));   /* Heathtech */
                curTile.IsStone      = (bool?)xElement.Attribute("Stone") ?? false;              /* Heathtech */
                curTile.CanBlend     = (bool?)xElement.Attribute("Blends") ?? false;             /* Heathtech */
                curTile.MergeWith    = (int?)xElement.Attribute("MergeWith") ?? null;            /* Heathtech */
                curTile.HasFrameName = curTile.IsFramed && ((bool?)xElement.Attribute("UseFrameName") ?? false);
                string frameNamePostfix = (string)xElement.Attribute("FrameNamePostfix") ?? null;

                foreach (var elementFrame in xElement.Elements("Frames").Elements("Frame"))
                {
                    var curFrame = new FrameProperty();
                    // Read XML attributes
                    curFrame.Name    = (string)elementFrame.Attribute("Name");
                    curFrame.Variety = (string)elementFrame.Attribute("Variety");
                    curFrame.UV      = StringToVector2Short((string)elementFrame.Attribute("UV"), 0, 0);
                    curFrame.Anchor  = InLineEnumTryParse <FrameAnchor>((string)elementFrame.Attribute("Anchor"));
                    var frameSize = StringToVector2Short((string)elementFrame.Attribute("FrameSize"), curTile.FrameSize.X, curTile.FrameSize.Y);

                    // Assign a default name if none existed
                    if (string.IsNullOrWhiteSpace(curFrame.Name))
                    {
                        curFrame.Name = curTile.Name;
                    }

                    curTile.Frames.Add(curFrame);
                    string spriteName = null;
                    if (curFrame.Name == curTile.Name)
                    {
                        if (!string.IsNullOrWhiteSpace(curFrame.Variety))
                        {
                            spriteName += curFrame.Variety;
                        }
                    }
                    else
                    {
                        spriteName += curFrame.Name;
                        if (!string.IsNullOrWhiteSpace(curFrame.Variety))
                        {
                            spriteName += " - " + curFrame.Variety;
                        }
                    }
                    Sprites.Add(new Sprite
                    {
                        Anchor           = curFrame.Anchor,
                        IsPreviewTexture = false,
                        Name             = spriteName,
                        Origin           = curFrame.UV,
                        Size             = frameSize,
                        Tile             = (ushort)curTile.Id,     /* SBlogic */
                        TileName         = curTile.Name
                    });
                    if (curTile.HasFrameName)
                    {
                        string frameName = curFrame.Name;
                        if (frameNamePostfix != null)
                        {
                            frameName += " (" + frameNamePostfix + ")";
                        }
                        if (curFrame.Variety != null)
                        {
                            frameName += ", " + curFrame.Variety;
                        }

                        //  TODO:  There must be a more efficient way than to store each frame...
                        for (int x = 0, mx = curTile.FrameSize.X; x < mx; x++)
                        {
                            for (int y = 0, my = curTile.FrameSize.Y; y < my; y++)
                            {
                                string frameNameKey = GetFrameNameKey(curTile.Id, (short)(curFrame.UV.X + (x * 18)), (short)(curFrame.UV.Y + (y * 18)));
                                if (!FrameNames.ContainsKey(frameNameKey))
                                {
                                    FrameNames.Add(frameNameKey, frameName);
                                }
                                else
                                {
                                    System.Diagnostics.Debug.WriteLine(curFrame.Name + " collided with " + frameNameKey);
                                }
                            }
                        }
                    }
                }
                if (curTile.Frames.Count == 0 && curTile.IsFramed)
                {
                    var curFrame = new FrameProperty();
                    // Read XML attributes
                    curFrame.Name    = curTile.Name;
                    curFrame.Variety = string.Empty;
                    curFrame.UV      = new Vector2Short(0, 0);
                    //curFrame.Anchor = InLineEnumTryParse<FrameAnchor>((string)xElement.Attribute("Anchor"));

                    curTile.Frames.Add(curFrame);
                    Sprites.Add(new Sprite
                    {
                        Anchor           = curFrame.Anchor,
                        IsPreviewTexture = false,
                        Name             = null,
                        Origin           = curFrame.UV,
                        Size             = curTile.FrameSize,
                        Tile             = (ushort)curTile.Id,
                        TileName         = curTile.Name
                    });
                }
                TileProperties.Add(curTile);
                if (!curTile.IsFramed)
                {
                    TileBricks.Add(curTile);
                }
            }
            for (int i = TileProperties.Count; i < 255; i++)
            {
                TileProperties.Add(new TileProperty(i, "UNKNOWN", Color.FromArgb(255, 255, 0, 255), true));
            }

            foreach (var xElement in xmlSettings.Elements("Walls").Elements("Wall"))
            {
                var curWall = new WallProperty();
                curWall.Color = ColorFromString((string)xElement.Attribute("Color"));
                curWall.Name  = (string)xElement.Attribute("Name");
                curWall.Id    = (int?)xElement.Attribute("Id") ?? -1;
                WallProperties.Add(curWall);
            }

            foreach (var xElement in xmlSettings.Elements("Items").Elements("Item"))
            {
                var curItem = new ItemProperty();
                curItem.Id    = (int?)xElement.Attribute("Id") ?? -1;
                curItem.Name  = (string)xElement.Attribute("Name");
                curItem.Scale = (float?)xElement.Attribute("Scale") ?? 1f;
                ItemProperties.Add(curItem);
                _itemLookup.Add(curItem.Id, curItem);
                int tally = (int?)xElement.Attribute("Tally") ?? 0;
                if (tally > 0)
                {
                    _tallynames.Add(tally, curItem.Name);
                }
                int head = (int?)xElement.Attribute("Head") ?? -1;
                if (head >= 0)
                {
                    _armorHeadNames.Add(head, curItem.Name);
                }
                int body = (int?)xElement.Attribute("Body") ?? -1;
                if (body >= 0)
                {
                    _armorBodyNames.Add(body, curItem.Name);
                }
                int legs = (int?)xElement.Attribute("Legs") ?? -1;
                if (legs >= 0)
                {
                    _armorLegsNames.Add(legs, curItem.Name);
                }
                bool rack = (bool?)xElement.Attribute("Rack") ?? false;
                if (rack)
                {
                    _rackable.Add(curItem.Id, curItem.Name);
                }
            }

            foreach (var xElement in xmlSettings.Elements("Paints").Elements("Paint"))
            {
                var curPaint = new PaintProperty();
                curPaint.Id    = (int?)xElement.Attribute("Id") ?? -1;
                curPaint.Name  = (string)xElement.Attribute("Name");
                curPaint.Color = ColorFromString((string)xElement.Attribute("Color"));
                PaintProperties.Add(curPaint);
            }

            int chestId = 0;

            foreach (var tileElement in xmlSettings.Elements("Tiles").Elements("Tile"))
            {
                string tileName = (string)tileElement.Attribute("Name");
                if (tileName == "Chest" || tileName == "Dresser")
                {
                    ushort type = (ushort)((int?)tileElement.Attribute("Id") ?? 21);
                    foreach (var xElement in tileElement.Elements("Frames").Elements("Frame"))
                    {
                        var curItem = new ChestProperty();
                        curItem.Name = (string)xElement.Attribute("Name");
                        string variety = (string)xElement.Attribute("Variety");
                        if (variety != null)
                        {
                            if (tileName == "Dresser")
                            {
                                curItem.Name = variety + " " + "Dresser";
                            }
                            else
                            {
                                curItem.Name = curItem.Name + " " + variety;
                            }
                        }
                        curItem.ChestId  = chestId++;
                        curItem.UV       = StringToVector2Short((string)xElement.Attribute("UV"), 0, 0);
                        curItem.TileType = type;
                        ChestProperties.Add(curItem);
                    }
                }
            }

            int signId = 0;

            foreach (var tileElement in xmlSettings.Elements("Tiles").Elements("Tile"))
            {
                string tileName = (string)tileElement.Attribute("Name");
                if (tileName == "Sign" || tileName == "Grave Marker" || tileName == "Announcement Box")
                {
                    ushort type = (ushort)((int?)tileElement.Attribute("Id") ?? 55);
                    foreach (var xElement in tileElement.Elements("Frames").Elements("Frame"))
                    {
                        var    curItem = new SignProperty();
                        string variety = (string)xElement.Attribute("Variety");
                        if (variety != null)
                        {
                            if (tileName == "Sign")
                            {
                                curItem.Name = "Sign " + variety;
                            }
                            else
                            {
                                curItem.Name = variety;
                            }
                        }
                        curItem.SignId   = signId++;
                        curItem.UV       = StringToVector2Short((string)xElement.Attribute("UV"), 0, 0);
                        curItem.TileType = type;
                        SignProperties.Add(curItem);
                    }
                }
            }

            foreach (var xElement in xmlSettings.Elements("Npcs").Elements("Npc"))
            {
                int    id   = (int?)xElement.Attribute("Id") ?? -1;
                string name = (string)xElement.Attribute("Name");
                NpcIds.Add(name, id);
                NpcNames.Add(id, name);
                int frames = (int?)xElement.Attribute("Frames") ?? 16;
                NpcFrames.Add(id, frames);
            }

            foreach (var xElement in xmlSettings.Elements("ItemPrefix").Elements("Prefix"))
            {
                int    id   = (int?)xElement.Attribute("Id") ?? -1;
                string name = (string)xElement.Attribute("Name");
                ItemPrefix.Add((byte)id, name);
            }

            foreach (var xElement in xmlSettings.Elements("ShortCutKeys").Elements("Shortcut"))
            {
                var key  = InLineEnumTryParse <Key>((string)xElement.Attribute("Key"));
                var tool = (string)xElement.Attribute("Tool");
                ShortcutKeys.Add(key, tool);
            }

            XElement appSettings   = xmlSettings.Element("App");
            int      appWidth      = (int?)appSettings.Attribute("Width") ?? 800;
            int      appHeight     = (int?)appSettings.Attribute("Height") ?? 600;
            int      clipboardSize = (int)XNA.MathHelper.Clamp((int?)appSettings.Attribute("ClipboardRenderSize") ?? 512, 64, 4096);

            _appSize = new Vector2(appWidth, appHeight);
            ClipboardBuffer.ClipboardRenderSize = clipboardSize;

            ToolDefaultData.LoadSettings(xmlSettings.Elements("Tools"));

            AltC        = (string)xmlSettings.Element("AltC");
            SteamUserId = (int?)xmlSettings.Element("SteamUserId") ?? null;
        }
Exemplo n.º 9
0
        private static void LoadObjectDbXml(string file)
        {
            var xmlSettings = XElement.Load(file);

            // Load Colors
            foreach (var xElement in xmlSettings.Elements("GlobalColors").Elements("GlobalColor"))
            {
                string    name  = (string)xElement.Attribute("Name");
                XNA.Color color = XnaColorFromString((string)xElement.Attribute("Color"));
                GlobalColors.Add(name, color);
            }

            foreach (var xElement in xmlSettings.Elements("Tiles").Elements("Tile"))
            {
                var curTile = new TileProperty();

                // Read XML attributes
                curTile.Color      = ColorFromString((string)xElement.Attribute("Color"));
                curTile.Name       = (string)xElement.Attribute("Name");
                curTile.Id         = (int?)xElement.Attribute("Id") ?? 0;
                curTile.IsFramed   = (bool?)xElement.Attribute("Framed") ?? false;
                curTile.IsSolid    = (bool?)xElement.Attribute("Solid") ?? false;
                curTile.IsSolidTop = (bool?)xElement.Attribute("SolidTop") ?? false;
                curTile.IsLight    = (bool?)xElement.Attribute("Light") ?? false;
                curTile.IsAnimated = (bool?)xElement.Attribute("IsAnimated") ?? false;
                curTile.FrameSize  = StringToVector2ShortArray((string)xElement.Attribute("Size"), 1, 1);
                // curTile.FrameSize = StringToVector2Short((string)xElement.Attribute("Size"), 1, 1);
                curTile.Placement   = InLineEnumTryParse <FramePlacement>((string)xElement.Attribute("Placement"));
                curTile.TextureGrid = StringToVector2Short((string)xElement.Attribute("TextureGrid"), 16, 16);
                curTile.FrameGap    = StringToVector2Short((string)xElement.Attribute("FrameGap"), 0, 0);
                curTile.IsGrass     = "Grass".Equals((string)xElement.Attribute("Special"));    /* Heathtech */
                curTile.IsPlatform  = "Platform".Equals((string)xElement.Attribute("Special")); /* Heathtech */
                curTile.IsCactus    = "Cactus".Equals((string)xElement.Attribute("Special"));   /* Heathtech */
                curTile.IsStone     = (bool?)xElement.Attribute("Stone") ?? false;              /* Heathtech */
                curTile.CanBlend    = (bool?)xElement.Attribute("Blends") ?? false;             /* Heathtech */
                curTile.MergeWith   = (int?)xElement.Attribute("MergeWith") ?? null;            /* Heathtech */
                string frameNamePostfix = (string)xElement.Attribute("FrameNamePostfix") ?? null;

                foreach (var elementFrame in xElement.Elements("Frames").Elements("Frame"))
                {
                    var curFrame = new FrameProperty();
                    // Read XML attributes
                    curFrame.Name    = (string)elementFrame.Attribute("Name");
                    curFrame.Variety = (string)elementFrame.Attribute("Variety");
                    curFrame.UV      = StringToVector2Short((string)elementFrame.Attribute("UV"), 0, 0);
                    curFrame.Anchor  = InLineEnumTryParse <FrameAnchor>((string)elementFrame.Attribute("Anchor"));
                    var frameSize = StringToVector2Short((string)elementFrame.Attribute("FrameSize"), curTile.FrameSize[0].X, curTile.FrameSize[0].Y);

                    // Assign a default name if none existed
                    if (string.IsNullOrWhiteSpace(curFrame.Name))
                    {
                        curFrame.Name = curTile.Name;
                    }

                    curTile.Frames.Add(curFrame);
                    string spriteName = null;
                    if (curFrame.Name == curTile.Name)
                    {
                        if (!string.IsNullOrWhiteSpace(curFrame.Variety))
                        {
                            spriteName += curFrame.Variety;
                        }
                    }
                    else
                    {
                        spriteName += curFrame.Name;
                        if (!string.IsNullOrWhiteSpace(curFrame.Variety))
                        {
                            spriteName += " - " + curFrame.Variety;
                        }
                    }
                    Sprites.Add(new Sprite
                    {
                        Anchor           = curFrame.Anchor,
                        IsPreviewTexture = false,
                        Name             = spriteName,
                        Origin           = curFrame.UV,
                        Size             = frameSize,
                        Tile             = (ushort)curTile.Id, /* SBlogic */
                        TileName         = curTile.Name
                    });
                }
                if (curTile.Frames.Count == 0 && curTile.IsFramed)
                {
                    var curFrame = new FrameProperty();
                    // Read XML attributes
                    curFrame.Name    = curTile.Name;
                    curFrame.Variety = string.Empty;
                    curFrame.UV      = new Vector2Short(0, 0);
                    //curFrame.Anchor = InLineEnumTryParse<FrameAnchor>((string)xElement.Attribute("Anchor"));

                    curTile.Frames.Add(curFrame);
                    Sprites.Add(new Sprite
                    {
                        Anchor           = curFrame.Anchor,
                        IsPreviewTexture = false,
                        Name             = null,
                        Origin           = curFrame.UV,
                        Size             = curTile.FrameSize[0],
                        Tile             = (ushort)curTile.Id,
                        TileName         = curTile.Name
                    });
                }
                TileProperties.Add(curTile);
                if (!curTile.IsFramed)
                {
                    TileBricks.Add(curTile);
                }
            }
            for (int i = TileProperties.Count; i < 255; i++)
            {
                TileProperties.Add(new TileProperty(i, "UNKNOWN", Color.FromArgb(255, 255, 0, 255), true));
            }

            foreach (var xElement in xmlSettings.Elements("Walls").Elements("Wall"))
            {
                var curWall = new WallProperty();
                curWall.Color = ColorFromString((string)xElement.Attribute("Color"));
                curWall.Name  = (string)xElement.Attribute("Name");
                curWall.Id    = (int?)xElement.Attribute("Id") ?? -1;
                WallProperties.Add(curWall);
            }

            foreach (var xElement in xmlSettings.Elements("Items").Elements("Item"))
            {
                var curItem = new ItemProperty();
                curItem.Id    = (int?)xElement.Attribute("Id") ?? -1;
                curItem.Name  = (string)xElement.Attribute("Name");
                curItem.Scale = (float?)xElement.Attribute("Scale") ?? 1f;

                ItemProperties.Add(curItem);
                _itemLookup.Add(curItem.Id, curItem);
                int tally = (int?)xElement.Attribute("Tally") ?? 0;
                if (tally > 0)
                {
                    _tallynames.Add(tally, curItem.Name);
                }
                int head = (int?)xElement.Attribute("Head") ?? -1;
                if (head >= 0)
                {
                    _armorHeadNames.Add(head, curItem.Name);
                }
                int body = (int?)xElement.Attribute("Body") ?? -1;
                if (body >= 0)
                {
                    _armorBodyNames.Add(body, curItem.Name);
                }
                int legs = (int?)xElement.Attribute("Legs") ?? -1;
                if (legs >= 0)
                {
                    _armorLegsNames.Add(legs, curItem.Name);
                }
                bool rack = (bool?)xElement.Attribute("Rack") ?? false;
                if (rack)
                {
                    _rackable.Add(curItem.Id, curItem.Name);
                }

                bool food = (bool?)xElement.Attribute("IsFood") ?? false;
                if (food)
                {
                    _foodNames.Add(curItem.Id, curItem.Name);
                    curItem.IsFood = true;
                }

                bool acc = (bool?)xElement.Attribute("Accessory") ?? false;
                if (acc)
                {
                    _accessoryNames.Add(curItem.Id, curItem.Name);
                }

                if (curItem.Name.Contains("Dye"))
                {
                    _dyeNames.Add(curItem.Id, curItem.Name);
                }
            }

            foreach (var xElement in xmlSettings.Elements("Paints").Elements("Paint"))
            {
                var curPaint = new PaintProperty();
                curPaint.Id    = (int?)xElement.Attribute("Id") ?? -1;
                curPaint.Name  = (string)xElement.Attribute("Name");
                curPaint.Color = ColorFromString((string)xElement.Attribute("Color"));
                PaintProperties.Add(curPaint);
            }

            int chestId = 0;

            foreach (var tileElement in xmlSettings.Elements("Tiles").Elements("Tile"))
            {
                string tileName = (string)tileElement.Attribute("Name");
                int    type     = (int)tileElement.Attribute("Id");
                if (Tile.IsChest(type))
                {
                    foreach (var xElement in tileElement.Elements("Frames").Elements("Frame"))
                    {
                        var curItem = new ChestProperty();
                        curItem.Name = (string)xElement.Attribute("Name");
                        string variety = (string)xElement.Attribute("Variety");
                        if (variety != null)
                        {
                            if (tileName == "Dresser")
                            {
                                curItem.Name = variety + " " + "Dresser";
                            }
                            else
                            {
                                curItem.Name = curItem.Name + " " + variety;
                            }
                        }
                        curItem.ChestId  = chestId++;
                        curItem.UV       = StringToVector2Short((string)xElement.Attribute("UV"), 0, 0);
                        curItem.TileType = (ushort)type;
                        ChestProperties.Add(curItem);
                    }
                }
            }

            int signId = 0;

            foreach (var tileElement in xmlSettings.Elements("Tiles").Elements("Tile"))
            {
                var    tileId   = (int?)tileElement.Attribute("Id") ?? 0;
                string tileName = (string)tileElement.Attribute("Name");
                if (Tile.IsSign(tileId))
                {
                    ushort type = (ushort)((int?)tileElement.Attribute("Id") ?? 55);
                    foreach (var xElement in tileElement.Elements("Frames").Elements("Frame"))
                    {
                        var    curItem = new SignProperty();
                        string variety = (string)xElement.Attribute("Variety");
                        string anchor  = (string)xElement.Attribute("Anchor");
                        curItem.Name     = $"{tileName} {variety} {anchor}";
                        curItem.SignId   = signId++;
                        curItem.UV       = StringToVector2Short((string)xElement.Attribute("UV"), 0, 0);
                        curItem.TileType = type;
                        SignProperties.Add(curItem);
                    }
                }
            }

            foreach (var xElement in xmlSettings.Elements("Npcs").Elements("Npc"))
            {
                int    id   = (int?)xElement.Attribute("Id") ?? -1;
                string name = (string)xElement.Attribute("Name");
                NpcIds[name] = id;
                NpcNames[id] = name;
                var frames = StringToVector2Short((string)xElement.Attribute("Size"), 16, 40);
                NpcFrames[id] = frames;
            }

            foreach (var xElement in xmlSettings.Elements("ItemPrefix").Elements("Prefix"))
            {
                int    id   = (int?)xElement.Attribute("Id") ?? -1;
                string name = (string)xElement.Attribute("Name");
                ItemPrefix.Add((byte)id, name);
            }

            foreach (var xElement in xmlSettings.Elements("ShortCutKeys").Elements("Shortcut"))
            {
                var key      = InLineEnumTryParse <Key>((string)xElement.Attribute("Key"));
                var modifier = InLineEnumTryParse <ModifierKeys>((string)xElement.Attribute("Modifier"));
                var tool     = (string)xElement.Attribute("Action");
                ShortcutKeys.Add(tool, key, modifier);
            }

            XElement appSettings   = xmlSettings.Element("App");
            int      appWidth      = (int?)appSettings.Attribute("Width") ?? 800;
            int      appHeight     = (int?)appSettings.Attribute("Height") ?? 600;
            int      clipboardSize = (int)XNA.MathHelper.Clamp((int?)appSettings.Attribute("ClipboardRenderSize") ?? 512, 64, 4096);

            _appSize = new Vector2(appWidth, appHeight);
            ClipboardBuffer.ClipboardRenderSize = clipboardSize;

            ToolDefaultData.LoadSettings(xmlSettings.Elements("Tools"));

            AltC        = (string)xmlSettings.Element("AltC");
            SteamUserId = (int?)xmlSettings.Element("SteamUserId") ?? null;
        }
Exemplo n.º 10
0
        private void CatalogsControl_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            switch (e.PropertyName)
            {
            case "Type":
            case "Norm":
            {
                var t = _integrationBase.ApiCore.Catalogs.GetAll($"Type={Type}&Norm={Norm}");

                ItemProperties.Clear();
                CatalogItems.Clear();
                _catalogs.Clear();

                if (t != null && t.Count > 0)
                {
                    foreach (var item in t)
                    {
                        Catalogs.Add(new CatalogGroup
                            {
                                Id          = item.Id,
                                Name        = item.Name,
                                Description = item.Description
                            });
                        if (Type == "CrossSection")
                        {
                            var serviceUrl = $"{_integrationBase.ServerName}/v2/content/crosssectiondefinitions/{item.Id}";
                            try
                            {
                                var cd = BimPlus.LightCaseClient.GenericProxies.RestGet <DtoCrossSectionDefinition>(serviceUrl, _integrationBase.ClientConfiguration);
                                if (cd == null || cd.Shapes?.Count == 0)
                                {
                                    continue;
                                }
                                foreach (var shape in cd.Shapes)
                                {
                                    Catalogs.Add(new CatalogGroup
                                        {
                                            Id          = shape.Id,
                                            Description = shape.Name,
                                            Name        = ""
                                        });
                                }
                            }
                            catch (Exception ex)
                            {
                                Trace.WriteLine(string.Format("Get catalogs: {0}", ex.Message));
                            }
                        }
                    }
                }
                break;
            }

            case "SelectedCatalog":
            {
                var catalog = SelectedCatalog as CatalogGroup;
                if (catalog == null)
                {
                    break;
                }
                var items = _integrationBase.ApiCore.Catalogs.GetAllCatalogItems(catalog.Id);
                ItemProperties.Clear();
                CatalogItems.Clear();
                foreach (var item in items)
                {
                    CatalogItems.Add(new CatalogGroup
                        {
                            Id          = item.Id,
                            Name        = item.Name,
                            Description = item.Description
                        });
                }
                break;
            }

            case "SelectedItem":
            {
                var item = SelectedItem as CatalogGroup;
                if (item == null)
                {
                    break;
                }
                var properties = _integrationBase.ApiCore.Catalogs.GetCatalogItem(item.Id);
                ItemProperties.Clear();
                foreach (var property in properties.Properties)
                {
                    ItemProperties.Add(new CatalogProperty
                        {
                            Id             = property.Key,
                            Name           = ContentAttributes.Find(x => x.Id == property.Key)?.Name ?? property.Key.ToString(),
                            AttributeValue = property.Value
                        });
                }
                break;
            }
            }
            //base.PropertyChanged(sender, e);
        }