Ejemplo n.º 1
0
        private void initInventoryDisplay()
        {
            if (currentInventory == null)
            {
                return;
            }

            InventorySpace inventory    = currentInventory.inventory;
            int            storageIndex = 0;

            resetInventory();

            foreach (Button slot in inventory_grid.Children.Cast <UIElement>())
            {
                Item current = inventory.items[storageIndex];
                storageIndex++;

                if (current.isItemEmpty() || slot.Visibility == Visibility.Hidden)
                {
                    changeSlotBackground(null, slot);
                    continue;
                }

                DBItems storedItem = DBItems.findItem(current.category, current.index);

                if (storedItem != null)
                {
                    storage_items.Add(slot, current);
                    displayItemInInventory(storedItem, slot);
                }
            }
        }
Ejemplo n.º 2
0
 public static void UpdateItemImages(Boolean reset)
 {
     using (DBConnection conn = new DBConnection())
     {
         var items = from e in conn.items
                     select e;
         foreach (var item in items)
         {
             if (item.image_path == null || item.image_path.Equals("default.gif") || reset)
             {
                 DBItems item_temp = item;
                 string  path      = calcItemImage((int)item.ID, (int)item.category_ID, 0, 0);
                 if (path == null)
                 {
                     Debug.WriteLine("Null path: " + item.ID + " cat: " + item.category_ID);
                     continue;
                 }
                 else
                 {
                     Debug.WriteLine("Update DB");
                     item_temp.image_path = path;
                     conn.SubmitChanges();
                 }
             }
         }
     }
 }
Ejemplo n.º 3
0
        private void displayItemInInventory(DBItems item, Button slot)
        {
            int col    = Grid.GetColumn((Button)slot);
            int row    = Grid.GetRow((Button)slot);
            int width  = (int)item.width - 1;
            int height = (int)item.height - 1;

            int cellDim = 35;

            if (width > 0 || height > 0)
            {
                foreach (Button current in inventory_grid.Children.Cast <UIElement>()
                         .Where(c => (Grid.GetColumn(c) >= col && Grid.GetColumn(c) <= col + width) &&
                                (Grid.GetRow(c) >= row && Grid.GetRow(c) <= row + height)))
                {
                    current.Visibility = Visibility.Hidden;
                }

                ((Button)slot).Visibility = Visibility.Visible;
            }

            ((Button)slot).Width  = (width + 1) * cellDim;
            ((Button)slot).Height = (height + 1) * cellDim;
            Grid.SetColumnSpan((Button)slot, width + 1);
            Grid.SetRowSpan((Button)slot, height + 1);

            changeSlotBackground(new Uri(@"images/items/" + item.image_path, UriKind.Relative), (Button)slot);
        }
Ejemplo n.º 4
0
        private void ItemListOnSelect(object sender, SelectionChangedEventArgs e)
        {
            if (items_list.SelectedItem != null)
            {
                if (current_category == null)
                {
                    current_category       = (DBItemCategories)items_list.SelectedItems[0];
                    category_label.Content = current_category.name;
                    getItemList(current_category.ID);
                    updateTabOptions();

                    categoryBackButton.Visibility = Visibility.Visible;
                }

                else
                {
                    current_item = (DBItems)items_list.SelectedItem;
                    item_image_name_label.Content = current_item.name;
                    current_item_image.Source     = new BitmapImage(new Uri(@"/images/items/" + current_item.image_path, UriKind.Relative));
                }
            }

            if (current_category == null)
            {
                items_list.UnselectAll();
            }
        }
Ejemplo n.º 5
0
        private void OnItemEnter(object sender, MouseEventArgs e)
        {
            Button src = (Button)sender;

            if (storage_items.ContainsKey(src))
            {
                double       x    = Grid.GetColumn(src) * src.Width;
                double       y    = Grid.GetRow(src) * src.Height;
                const double padX = 20;
                const double padY = 10;

                Point pos = e.GetPosition(inventory_canvas);
                Canvas.SetLeft(item_hover_ctrl, x + src.Width + padX);
                Canvas.SetTop(item_hover_ctrl, y + padY);

                Item             item    = storage_items[src];
                ItemHoverControl control = (ItemHoverControl)item_hover_ctrl;
                control.setItemLevel(item.level);
                control.setItemAddLevel(item.addLevel);
                control.setItemLuck(item.luck);
                control.setItemSkill(item.skill);
                control.setItemExc(item);

                DBItems dbItem = DBItems.findItem(item.category, item.index);
                if (dbItem != null)
                {
                    control.setItemName(dbItem.name);
                }

                item_hover_ctrl.Visibility = Visibility.Visible;
            }
        }
Ejemplo n.º 6
0
        public static void updateSingleItemImage(int item_id, int category_id, string path)
        {
            using (DBConnection conn = new DBConnection())
            {
                var item = from e in conn.items
                           where e.ID == item_id && e.category_ID == category_id
                           select e;

                DBItems item_temp = item.First();
                if (File.Exists("images/items/" + path))
                {
                    item_temp.image_path = path;
                    conn.SubmitChanges();
                }
            }
        }
Ejemplo n.º 7
0
        private bool isInsideBoundaries(DBItems item, Button slot)
        {
            int col    = Grid.GetColumn((Button)slot);
            int row    = Grid.GetRow((Button)slot);
            int width  = (int)item.width - 1;
            int height = (int)item.height - 1;

            if ((col + width) >= inventory_grid.ColumnDefinitions.Count || (row + height) >= inventory_grid.RowDefinitions.Count)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Ejemplo n.º 8
0
        private void initItemOptions(Item item)
        {
            if (item == null)
            {
                return;
            }

            current_category = DBItemCategories.findCategory(item.category);
            current_item     = DBItems.findItem(item.category, item.index);

            getItemList(item.category);
            items_list.SelectedIndex = item.index;
            items_list.ScrollIntoView(items_list.SelectedIndex);

            initBasicOptions(item);
            initExcOptions(item);
        }
Ejemplo n.º 9
0
        private void ItemListOnSelect(object sender, SelectionChangedEventArgs e)
        {
            if (items_list.SelectedItem != null)
            {
                if (current_category == null)
                {
                    current_category =  (DBItemCategories)items_list.SelectedItems[0];
                    category_label.Content = current_category.name;
                    getItemList(current_category.ID);
                    updateTabOptions();

                    categoryBackButton.Visibility = Visibility.Visible;
                }

                else
                {
                    current_item = (DBItems)items_list.SelectedItem;
                    item_image_name_label.Content = current_item.name;
                    current_item_image.Source = new BitmapImage(new Uri(@"/images/items/" + current_item.image_path, UriKind.Relative));
                }
            }

            if(current_category == null) items_list.UnselectAll();
        }
Ejemplo n.º 10
0
        private bool isInsideBoundaries(DBItems item, Button slot)
        {
            int col = Grid.GetColumn((Button)slot);
            int row = Grid.GetRow((Button)slot);
            int width = (int)item.width - 1;
            int height = (int)item.height - 1;

            if ((col + width) >= inventory_grid.ColumnDefinitions.Count || (row + height) >= inventory_grid.RowDefinitions.Count)
                return false;
            else
                return true;
        }
Ejemplo n.º 11
0
        private void initItemOptions(Item item)
        {
            if (item == null) return;

            current_category = DBItemCategories.findCategory(item.category);
            current_item = DBItems.findItem(item.category, item.index);

            getItemList(item.category);
            items_list.SelectedIndex = item.index;
            items_list.ScrollIntoView(items_list.SelectedIndex);

            initBasicOptions(item);
            initExcOptions(item);
        }
Ejemplo n.º 12
0
        private void displayItemInInventory(DBItems item, Button slot)
        {
            int col = Grid.GetColumn((Button)slot);
            int row = Grid.GetRow((Button)slot);
            int width = (int)item.width - 1;
            int height = (int)item.height - 1;

            int cellDim = 35;

            if (width > 0 || height > 0)
            {
                foreach (Button current in inventory_grid.Children.Cast<UIElement>()
                    .Where(c => (Grid.GetColumn(c) >= col && Grid.GetColumn(c) <= col + width)
                    && (Grid.GetRow(c) >= row && Grid.GetRow(c) <= row + height)))
                {
                    current.Visibility = Visibility.Hidden;
                }

                ((Button)slot).Visibility = Visibility.Visible;
            }

            ((Button)slot).Width = (width + 1) * cellDim;
            ((Button)slot).Height = (height + 1) * cellDim;
            Grid.SetColumnSpan((Button) slot, width + 1);
            Grid.SetRowSpan((Button) slot, height + 1);

            changeSlotBackground(new Uri(@"images/items/" + item.image_path, UriKind.Relative), (Button)slot);
        }