InventoryWearable Class, details on a clothing item or body part
Inheritance: InventoryItem
        void treeview_inv_ButtonPressEvent(object o, ButtonPressEventArgs args)
        {
            lock (inventory)
            {
                if (args.Event.Button == 3)//F**k this should be a define
                {
                    // Do the context sensitive stuff here
                    // Detect type of asset selected and show an approprate menu
                    // maybe
                    Gtk.TreeModel mod;
                    Gtk.TreeIter iter;
                    InventoryBase item = null;

                    Logger.Log("ROOT IS " + MainClass.client.Inventory.Store.RootFolder.UUID.ToString(),Helpers.LogLevel.Debug);

                    TreePath[] paths = treeview_inv.Selection.GetSelectedRows(out mod);

                    if (paths.Length == 1)
                    {
                        //all good and simple
                        TreeIter itera;
                        mod.GetIter(out itera, paths[0]);
                        UUID ida = (UUID)mod.GetValue(itera, 2);
                        item = (InventoryBase)MainClass.client.Inventory.Store.GetNodeFor(ida).Data;

                    }

                    if (paths.Length > 1)
                    {
                        bool allsame = true;
                        bool wearables = true;
                        bool folders = true;
                        TreeIter itera, iterb;

                        foreach (TreePath path in paths)
                        {
                            mod.GetIter(out itera, path);
                            UUID ida = (UUID)mod.GetValue(itera, 2);
                            InventoryBase itema = (InventoryBase)MainClass.client.Inventory.Store.GetNodeFor(ida).Data;
                            if (!(itema is InventoryWearable))
                                wearables = false;
                            if (!(itema is InventoryFolder))
                                folders = false;

                            foreach (TreePath innerpath in paths)
                            {
                                mod.GetIter(out iterb, innerpath);
                                UUID idb = (UUID)mod.GetValue(iterb, 2);
                                InventoryBase itemb = (InventoryBase)MainClass.client.Inventory.Store.GetNodeFor(idb).Data;

                                if (itema.GetType() != itemb.GetType())
                                {
                                    allsame = false;
                                }
                            }

                        }

                        //ok if allsame==true we can allow specific extra menu options
                        //or if all wearables then we can allow wearable options
                        if (allsame)
                        {
                            mod.GetIter(out iter, paths[0]);
                            UUID ida = (UUID)mod.GetValue(iter, 2);
                            item = (InventoryBase)MainClass.client.Inventory.Store.GetNodeFor(ida).Data;
                        }
                        else if (wearables)
                        {
                            item = new InventoryWearable(UUID.Zero); //fake an item
                        }

                    }

                    if (item == null)
                        return;

                    Gtk.Menu menu = new Gtk.Menu();

                    Logger.Log("Item is " + item.ToString() + " ID is " + item.UUID.ToString(),Helpers.LogLevel.Debug);

                    Logger.Log("Item parent is " + item.ToString() + " ID is " + item.ParentUUID.ToString(),Helpers.LogLevel.Debug);

                    if (item is InventoryLandmark)
                    {
                        Gtk.ImageMenuItem menu_tp_lm = new ImageMenuItem("Teleport to Landmark");
                        menu_tp_lm.Image = new Gtk.Image(MainClass.GetResource("icon_place.png"));
                        menu_tp_lm.ButtonPressEvent += new ButtonPressEventHandler(Teleporttolandmark);
                        menu.Append(menu_tp_lm);
                    }

                    if (item is InventoryFolder)
                    {
                        if (item.UUID == trash_folder)
                        {
                            Gtk.ImageMenuItem menu_delete_folder = new ImageMenuItem("Empty Trash");
                            menu_delete_folder.Image = new Gtk.Image(MainClass.GetResource("inv_folder_trash.png"));
                            menu_delete_folder.ButtonPressEvent += new ButtonPressEventHandler(onemptytrash);
                            menu.Append(menu_delete_folder);
                        }
                        else
                        {

                          if (item.UUID == MainClass.client.Inventory.Store.LibraryFolder.UUID)
                                return;

                            Gtk.MenuItem menu_wear_folder = new MenuItem("Wear folder contents");
                            Gtk.ImageMenuItem menu_give_folder = new ImageMenuItem("Give folder to user");
                            menu_give_folder.Image = new Gtk.Image(MainClass.GetResource("ff_edit_theirs.png"));

                            Gtk.ImageMenuItem new_note = new ImageMenuItem("Create new notecard");
                            new_note.Image = new Gtk.Image(MainClass.GetResource("inv_item_notecard.png"));

                            Gtk.ImageMenuItem new_script = new ImageMenuItem("Create new script");
                            new_script.Image = new Gtk.Image(MainClass.GetResource("inv_item_script.png"));

                            Gtk.ImageMenuItem new_folder = new ImageMenuItem("Create new folder");
                            new_folder.Image = new Gtk.Image(MainClass.GetResource("inv_folder_plain_open.png"));

                            Gtk.ImageMenuItem menu_cut_folder = new ImageMenuItem("Cut Folder");
                            menu_cut_folder.Image = new Gtk.Image(Gtk.Stock.Cut, IconSize.Menu);

                            Gtk.ImageMenuItem menu_copy_folder = new ImageMenuItem("Copy Folder");
                            menu_copy_folder.Image = new Gtk.Image(Gtk.Stock.Copy, IconSize.Menu);

                            Gtk.ImageMenuItem menu_paste_folder = new ImageMenuItem("Paste here..");
                            menu_paste_folder.Image = new Gtk.Image(Gtk.Stock.Paste, IconSize.Menu);

                            Gtk.ImageMenuItem menu_delete_folder = new ImageMenuItem("Delete Folder");
                            menu_delete_folder.Image = new Gtk.Image(MainClass.GetResource("inv_folder_trash.png"));

                            menu_delete_folder.ButtonPressEvent += new ButtonPressEventHandler(ondeleteasset);
                            menu_give_folder.ButtonPressEvent += new ButtonPressEventHandler(ongiveasset);
                            menu_wear_folder.ButtonPressEvent += new ButtonPressEventHandler(menu_ware_ButtonPressEvent);
                            //menu_debork.ButtonPressEvent += new ButtonPressEventHandler(FixBorkedFolder);
                            new_note.ButtonPressEvent += new ButtonPressEventHandler(menu_on_new_note);
                            new_script.ButtonPressEvent += new ButtonPressEventHandler(menu_on_new_script);
                            new_folder.ButtonPressEvent += new ButtonPressEventHandler(menu_on_new_folder);
                            menu_cut_folder.ButtonPressEvent += new ButtonPressEventHandler(menu_on_cut_folder);
                            menu_copy_folder.ButtonPressEvent += new ButtonPressEventHandler(menu_on_copy_folder);
                            menu_paste_folder.ButtonPressEvent += new ButtonPressEventHandler(menu_on_paste_folder);

                            Gtk.Label x = new Gtk.Label("Folder Item");

                            if (item.UUID != MainClass.client.Inventory.Store.RootFolder.UUID)
                            {
                                //menu.Append(menu_debork);
                                menu.Append(menu_wear_folder);
                            }

                            if (paths.Length == 1)
                            {
                                menu.Append(new Gtk.SeparatorMenuItem());
                                menu.Append(new_note);
                                menu.Append(new_script);
                                menu.Append(new_folder);
                            }

                            if (item.UUID != MainClass.client.Inventory.Store.RootFolder.UUID)
                            {
                                menu.Append(new Gtk.SeparatorMenuItem());
                                menu.Append(menu_give_folder);
                            }

                            menu.Append(new Gtk.SeparatorMenuItem());

                            if (item.UUID != MainClass.client.Inventory.Store.RootFolder.UUID)
                            {
                                menu.Append(menu_cut_folder);
                            }
                                //menu.Append(menu_copy_folder);
                            if (cutcopylist.Count > 0)
                                menu.Append(menu_paste_folder);

                            if (item.UUID != MainClass.client.Inventory.Store.RootFolder.UUID)
                            {
                                menu.Append(new Gtk.SeparatorMenuItem());
                                menu.Append(menu_delete_folder);
                            }
                        }
                    }
                    if (item is InventoryNotecard)
                    {
                        Gtk.MenuItem menu_read_note = new MenuItem("Open notecard");
                        menu_read_note.ButtonPressEvent += new ButtonPressEventHandler(onOpenNotecard);
                        menu.Append(menu_read_note);

                    }

                    if (item is InventoryLSL)
                    {
                        Gtk.MenuItem menu_read_note = new MenuItem("Open script");
                        menu_read_note.ButtonPressEvent += new ButtonPressEventHandler(onOpenScript);
                        menu.Append(menu_read_note);

                    }

                    if (item is InventoryTexture || item is InventorySnapshot)
                    {
                        Gtk.MenuItem menu_view_texture = new MenuItem("View texture");
                        menu_view_texture.ButtonPressEvent += new ButtonPressEventHandler(onViewTexture);
                        menu.Append(menu_view_texture);
                    }

                    if (item is InventoryAttachment || item is InventoryObject)
                    {
                        Gtk.MenuItem menu_attach_item = new MenuItem("Attach (default pos)");
                        menu_attach_item.ButtonPressEvent += new ButtonPressEventHandler(menu_attach_item_ButtonPressEvent);
                        menu.Append(menu_attach_item);
                    }

                    if (item is InventoryWearable)
                    {
                        Gtk.MenuItem menu_attach_item = new MenuItem("Wear");
                        menu_attach_item.ButtonPressEvent += new ButtonPressEventHandler(menu_wear_item_ButtonPressEvent);
                        menu.Append(menu_attach_item);
                    }

                    if (item is InventoryItem)
                    {

                        Gtk.ImageMenuItem menu_give_item = new ImageMenuItem("Give item to user");
                        menu_give_item.Image = new Gtk.Image(MainClass.GetResource("ff_edit_theirs.png"));

                        Gtk.ImageMenuItem menu_delete_item = new ImageMenuItem("Delete item");
                        menu_delete_item.Image = new Gtk.Image(MainClass.GetResource("inv_folder_trash.png"));

                        menu_give_item.ButtonPressEvent += new ButtonPressEventHandler(ongiveasset);
                        menu_delete_item.ButtonPressEvent += new ButtonPressEventHandler(ondeleteasset);
                        menu.Append(new Gtk.SeparatorMenuItem());
                        menu.Append(menu_give_item);
                        menu.Append(new Gtk.SeparatorMenuItem());

                        Gtk.ImageMenuItem menu_cut_folder = new ImageMenuItem("Cut Item(s)");
                        menu_cut_folder.Image = new Gtk.Image(Gtk.Stock.Cut, IconSize.Menu);
                        Gtk.ImageMenuItem menu_copy_folder = new ImageMenuItem("Copy Item(s)");
                        menu_copy_folder.Image = new Gtk.Image(Gtk.Stock.Copy, IconSize.Menu);
                        menu_cut_folder.ButtonPressEvent += new ButtonPressEventHandler(menu_on_cut_folder);
                        menu_copy_folder.ButtonPressEvent += new ButtonPressEventHandler(menu_on_copy_folder);
                        menu.Append(menu_cut_folder);
                        // menu.Append(menu_copy_folder);

                        menu.Append(new Gtk.SeparatorMenuItem());
                        menu.Append(menu_delete_item);
                    }

                    menu.Popup();
                    menu.ShowAll();

                }
            }
        }
Beispiel #2
0
 /// <summary>
 /// Get a pronouncable form of each wearable type.
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 string WearableType(InventoryWearable item)
 {
     switch (item.WearableType)
     {
         case OpenMetaverse.WearableType.Shirt: return "shirt";
         case OpenMetaverse.WearableType.Pants: return "pants";
         case OpenMetaverse.WearableType.Skirt: return "skirt";
         case OpenMetaverse.WearableType.Shoes: return "shoes";
         case OpenMetaverse.WearableType.Jacket: return "jacket";
         case OpenMetaverse.WearableType.Socks: return "socks";
         case OpenMetaverse.WearableType.Undershirt: return "undershirt";
         case OpenMetaverse.WearableType.Underpants: return "underpants";
         case OpenMetaverse.WearableType.Skin: return "skin";
         case OpenMetaverse.WearableType.Eyes: return "eyes";
         case OpenMetaverse.WearableType.Gloves: return "gloves";
         case OpenMetaverse.WearableType.Hair: return "hair";
         case OpenMetaverse.WearableType.Shape: return "body shape";
         default: return "clothes";
     }
 }