Example #1
0
        public void Update_Plugins_List()
        {
            set_layout_dirty();
            list.Clear_Children();

            float dY = 3f;

            foreach (KeyValuePair <string, Plugin> kv in Loader.plugins)
            {
                try
                {
                    var sel = Create <Plugin_Manager_List_Item>();
                    sel.Set_Plugin(kv.Value);
                    sel.onClicked += Sel_onClicked;
                    list.Add(kv.Value.Hash, sel);
                }
                catch (Exception ex)
                {
                    SLog.Error(ex);
                }
            }

            if (list.isEmpty)
            {
                tab_need_plugins.Select();              // tabPanel.Set_Tab(NEED_PLUGINS_TAB_NAME);
            }
            else
            {
                tab_ins.Select(); // tabPanel.Set_Tab(INSTRUCTION_TAB_NAME);
            }
            // Set the very first plugin in our list as the active one
            //if (Loader.plugins.Count > 0) { this.Select_Plugin(Loader.plugins.First().Value); }
        }
Example #2
0
        public DevMenu()
        {
            onLayout += DevMenu_onLayout;
            Title     = "DevMenu";
            Set_Size(800, 600);
            Center();

            list = uiControl.Create <uiListView>(this);
            list.alignTop();
            list.alignLeftSide();
            list.Set_Margin(0, 4, 0, 0);

            tabPanel = uiControl.Create <uiTabPanel>(this);
            tabPanel.Autosize_Method = AutosizeMethod.FILL;
            //tabPanel.local_style.normal.background = null;

            foreach (var kvp in Menus)
            {
                string eStr = Enum.GetName(typeof(Dev_Menu_Type), kvp.Key);
                var    tab  = tabPanel.Add_Tab();
                tab.Scrollable      = false;
                Menus[kvp.Key].Tab  = tab;
                Menus[kvp.Key].Type = kvp.Key;

                switch (kvp.Key)
                {
                case Dev_Menu_Type.HIERARCHY:
                    Create <Dev_Hierarchy_Browser>(tab);
                    break;

                case Dev_Menu_Type.SPAWN:
                    Create <Dev_SpawnMenu>(tab);
                    break;

                default:
                    SLog.Warn("Unhandled Dev_Menu type: {0}", eStr);
                    break;
                }

                var itm = uiControl.Create <uiListItem>();
                itm.Title       = kvp.Value.Title;
                itm.Description = kvp.Value.Description;
                itm.onSelected += (uiControl c) => { Set_Active_Menu(kvp.Value.Type); };
                list.Add(itm);
            }
        }
 public override uiControl Add(uiControl c)
 {
     list.Add(c); update_icon(); return(c);
 }
        private void Rebuild_Plugins_UI()
        {
            pending_rebuild = false;
            list.Clear_Children();
            string search_str = search.text.ToLower();

            // add all the plugins to the sidebar
            foreach (KeyValuePair <string, Plugin_Download_Data> kv in this.plugins)
            {
                Plugin_Download_Data plugin = kv.Value;

                Plugin_Data dat = new Plugin_Data()
                {
                    AUTHOR      = plugin.Author,
                    NAME        = plugin.Name,
                    DESCRIPTION = plugin.Description
                };

                if (search_str.Length > 0)
                {
                    bool match = false;
                    if (plugin.Name.ToLower().IndexOf(search_str) > -1)
                    {
                        match = true;
                    }
                    if (plugin.Author.ToLower().IndexOf(search_str) > -1)
                    {
                        match = true;
                    }

                    if (!match)
                    {
                        continue;
                    }
                }


                Plugin_StoreItem itm = uiControl.Create <Plugin_StoreItem>();
                itm.onClicked += this.Select_Plugin;
                itm.Set_Plugin_Data(dat);
                list.Add(itm.plugin_hash, itm);
            }

            // select one of the plugins
            if (list.Get_Children().Count() > 0)
            {
                if (this.selected_plugin == null)
                {
                    //Select nothing, show instructions instead
                    //Select_Plugin(list.Get_Children()[0]);
                    tabPanel.Select_Tab(INSTRUCTION_TAB_NAME);
                }
                else
                {
                    uiControl found = null;
                    foreach (uiControl c in this.list.Get_Children())
                    {
                        Plugin_StoreItem itm = (Plugin_StoreItem)c;
                        if (itm.plugin_hash == selected_plugin.plugin_hash)
                        {
                            found = c;
                            break;
                        }
                    }

                    if (found != null)
                    {
                        Select_Plugin(found);
                    }
                    else
                    {
                        Select_Plugin(list.Get_Children().First());
                    }
                }
            }
            else
            {
                Select_Plugin(null);
            }
        }