예제 #1
0
        private FrameworkElement GetItemImageFromStructure(STreasureTableElement item, bool big_gui)
        {
            BitmapSource source = big_gui ? item.ImageBig : item.ImageSmall;

            if (source != null)
            {
                //Let's create a new stack panel to aggregate the item image and description
                StackPanel stackPanel = new StackPanel();
                stackPanel.Margin = new Thickness(2);

                Image itemImage = new Image();
                itemImage.Source = source;
                itemImage.Width  = source.Width;
                itemImage.Height = source.Height;

                TextBlock itemInfo = new TextBlock();
                itemInfo.Text = item.DisplayInfo;
                itemInfo.HorizontalAlignment = HorizontalAlignment.Center;

                stackPanel.Children.Add(itemImage);
                stackPanel.Children.Add(itemInfo);
                stackPanel.HorizontalAlignment = HorizontalAlignment.Center;
                stackPanel.VerticalAlignment   = VerticalAlignment.Center;

                return(stackPanel);
            }
            else
            {
                return(null);
            }
        }
예제 #2
0
        public static void Parse(STreasureTable treasures_table)
        {
            string strColumnSearchName    = DBTableAttributtesFetcher.GetPrimaryKeyName(EDBTable.eTreasureTable);
            string strColumnRetriveName   = DBTableAttributtesFetcher.GetColumnsNames(EDBTable.eTreasureTable)[(int)EDBTreasureTableColumns.eATreasures];
            string strItemTypesTableSufix = DBTableAttributtesFetcher.GetNameSufix(EDBTable.eItemTypes);

            //Split the and entries first
            string strATreasures = App.DB.GetColumnValueFromMemoryTable(strColumnSearchName, treasures_table.ID, treasures_table.TableName, strColumnRetriveName);

            string [] strTableAndEntriesSplitted = strATreasures.Split(',');
            foreach (string strTableOrEntries in strTableAndEntriesSplitted)
            {
                List <object> treasureItems = new List <object>();

                //Split the or entries second
                string[] strTableOrEntriesSplitted = strTableOrEntries.Split('|');
                foreach (string strEntry in strTableOrEntriesSplitted)
                {
                    string[] strEntrySplitted = strEntry.Split('x');
                    //Translate the entry to the respective table
                    string strEntryID    = strEntrySplitted[(int)STreasureTableElement.EDataIndex.eID];
                    string strEntryTable = treasures_table.TableName;
                    ItemTypes.ItemTypes.GetFinalItemAndTableFromEncapsulatedItemAndTableWithSufix(ref strEntryID, ref strEntryTable, strItemTypesTableSufix);
                    //Now we need to check if it is a table or an item
                    string[] strEntryIDSplitted = strEntryID.Split('.');
                    //is an item in the format GroupID.SubgroupID
                    if (strEntryIDSplitted.Length == 2)
                    {
                        STreasureTableElement item = new STreasureTableElement(strEntryIDSplitted, strEntrySplitted, strEntryTable);
                        treasureItems.Add(item);
                    }
                    else if (string.IsNullOrEmpty(strEntryIDSplitted[0]) == false)
                    {
                        STreasureTable innerTresureTable = new STreasureTable(strEntryIDSplitted[0], strEntryTable, strEntrySplitted[(int)STreasureTableElement.EDataIndex.eProbability], strEntrySplitted[(int)STreasureTableElement.EDataIndex.eOccurrence]);
                        // Recursive parse tables, hopefully modders didn't create loop references in the treasure tables because I am not protecting them for now
                        Parse(innerTresureTable);
                        treasureItems.Add(innerTresureTable);
                    }
                }
                if (treasureItems.Count > 0)
                {
                    treasures_table.Elements.Add(treasureItems);
                }
            }
        }