Esempio n. 1
0
        public Dev_SpawnMenu()
        {
            Autosize        = true;
            Autosize_Method = AutosizeMethod.FILL;
            onLayout       += Layout;

            // This list will contain different categories of spawnable items
            cList = uiControl.Create <uiListView>(this);
            cList.Set_Margin(0, 4, 0, 0);
            cList.Set_Width(130f);

            catPanel = uiControl.Create <uiTabPanel>(this);

            foreach (SpawnCategory cty in Enum.GetValues(typeof(SpawnCategory)))
            {
                if (cty == SpawnCategory.NONE)
                {
                    continue;
                }
                string catStr = Enum.GetName(typeof(SpawnCategory), cty);
                var    catBtn = uiControl.Create <uiListItem>(String.Concat("category_", catStr.ToLower()), cList);
                catBtn.Title       = catStr.ToLower().CapitalizeFirst();
                catBtn.Description = null;

                uiTab cTab = null;
                switch (cty)
                {
                case SpawnCategory.SLIMES:
                    cTab = Create_Spawn_Category_Menu(catPanel, cty, Ident.ALL_SLIMES);
                    break;

                case SpawnCategory.PLORTS:
                    cTab = Create_Spawn_Category_Menu(catPanel, cty, Identifiable.PLORT_CLASS);
                    break;

                case SpawnCategory.ANIMALS:
                    cTab = Create_Spawn_Category_Menu(catPanel, cty, Ident.ALL_ANIMALS);
                    break;

                case SpawnCategory.FRUITS:
                    cTab = Create_Spawn_Category_Menu(catPanel, cty, Identifiable.FRUIT_CLASS);
                    break;

                case SpawnCategory.VEGETABLES:
                    cTab = Create_Spawn_Category_Menu(catPanel, cty, Identifiable.VEGGIE_CLASS);
                    break;

                default:
                    SLog.Info("Unhandled Spawn menu category: {0}", catStr);
                    break;
                }

                catBtn.onSelected += (uiControl c) =>
                {
                    Sound.Play(SoundId.BTN_CLICK);
                    cTab.Select();
                };
            }
        }
Esempio n. 2
0
        private void Select_Plugin(Plugin p)
        {
            set_layout_dirty();
            if (!list.isEmpty)
            {
                pl_tab.Select();
                //set ALL selectors to inactive first.
                foreach (var sel in list.Get_Children())
                {
                    ((Plugin_Manager_List_Item)sel).Active = false;
                }
            }
            else
            {
                tab_ins.Select();
            }

            // Unregister our error event hook for the last plugin we had selected
            Plugin last = GetPlugin();

            if (last != null)
            {
                last.onError -= onPluginError;
            }

            selected = null;
            if (p != null)
            {
                selected = p.Hash;
                Plugin_Manager_List_Item sel = list[p.Hash] as Plugin_Manager_List_Item;
                if (sel != null)
                {
                    sel.Active = true;
                }
            }
            p.onError += onPluginError;

            control_panel.Set_Collapsed(selected == null);

            float thumb_aspect = 1f;
            float thumb_sz     = 256f;

            if (p == null || p.data == null)
            {
                this.pl_title.Text = "";
                this.pl_auth.Text  = "";
                this.pl_desc.Text  = "";
                //this.pl_desc.isDisabled = true;

                this.pl_vers.Text        = "";
                this.pl_thumb.Image      = null;
                this.pl_toggle.isVisible = false;
                this.pl_toggle.isChecked = false;
                this.pl_errors.Collapse();
            }
            else
            {
                this.pl_title.Text = p.data.NAME;
                this.pl_auth.Text  = String.Format("<color=#808080ff>Author:</color> {0}", p.data.AUTHOR);
                this.pl_desc.Text  = (string.IsNullOrEmpty(p.data.DESCRIPTION) ? "<b><color=#808080ff>No Description</color></b>" : p.data.DESCRIPTION);
                //this.pl_desc.isDisabled = false;

                this.pl_vers.Text        = p.data.VERSION.ToString();
                this.pl_thumb.Image      = p.thumbnail;
                this.pl_toggle.isVisible = true;
                this.pl_toggle.isChecked = p.Enabled;
                this.pl_errors.Set_Collapsed(!p.HasErrors);
            }

            if (this.pl_thumb.Image == null)
            {
                thumb_sz = 0f;
            }
            else
            {
                thumb_aspect = ((float)this.pl_thumb.Image.height / (float)this.pl_thumb.Image.width);
            }

            float thumb_height = (thumb_sz * thumb_aspect);

            pl_thumb.Set_Size(thumb_sz, thumb_height);
        }
        public PluginStore()
        {
            onLayout += PluginStore_onLayout;
            Title     = "Plugin Store";
            Set_Size(800, 600);
            Center();


            lbl_pl_count       = Create <uiVarText>(this);
            lbl_pl_count.Text  = "Total Plugins:";
            lbl_pl_count.Value = "0";
            lbl_pl_count.text_style.fontStyle = FontStyle.Bold;

            search           = uiControl.Create <uiTextbox>(this);
            search.onChange += Search_onChange;

            lbl_search      = uiControl.Create <uiText>(this);
            lbl_search.Text = "Search ";


            btn_config             = Create <uiIconButton>(this);
            btn_config.Text        = "Settings";
            btn_config.Icon        = TextureHelper.icon_arrow_left;
            btn_config.Border.type = uiBorderType.NONE;
            //btn_config.Skin = uiSkinPreset.FLAT;
            btn_config.Border.normal.color = Color.white;
            btn_config.Border.normal.size  = new RectOffset(1, 1, 1, 1);
            btn_config.onClicked          += Btn_config_onClicked;


            tabPanel = Create <uiTabPanel>(this);
            tabPanel.Add_Tab(MAIN_TAB_NAME);
            tabPanel.CurrentTab.onLayout += InfoTab_onLayout;
            tabPanel.Set_Margin(2);// This margin gives us that light colored area surrounding the list and tabpanel


            pl_title      = uiControl.Create <uiText>(tabPanel);
            pl_title.Text = "";
            var sty = new GUIStyle(pl_title.Style);

            sty.fontStyle = FontStyle.Bold;
            sty.fontSize  = 22;
            pl_title.Set_Style(sty);


            pl_auth      = uiControl.Create <uiText>(tabPanel);
            pl_auth.Text = "";

            pl_desc      = uiControl.Create <uiTextArea>(tabPanel);
            pl_desc.Text = "";
            pl_desc.Set_Padding(2);
            pl_desc.Border.normal.color = new Color(0f, 0f, 0f, 0.3f);


            install_btn = uiControl.Create <uiButton>(tabPanel);
            install_btn.local_style.fontSize  = 18;
            install_btn.local_style.fontStyle = FontStyle.Bold;
            install_btn.Text       = "Download";
            install_btn.onClicked += Install_btn_onClicked;
            Color blue = new Color(0.2f, 0.4f, 1f, 1f);

            Util.Set_BG_Gradient(install_btn.local_style.normal, 64, GRADIENT_DIR.TOP_BOTTOM, blue, new Color(0.5f, 0.5f, 0.5f, 1f) * blue);


            // INSTRUCTIONS TAB
            tabPanel.Add_Tab(INSTRUCTION_TAB_NAME);
            tabPanel.CurrentTab.onLayout += InstructionsTab_onLayout;;

            ins_title           = Create <uiTextArea>(tabPanel);
            ins_title.Text      = "Welcome";
            ins_title.TextSize  = 22;
            ins_title.TextStyle = FontStyle.Bold;

            ins_text           = Create <uiTextArea>(tabPanel);
            ins_text.Text      = "Here you can find and download new plugins.\nTo get started select a plugin from the list on the left to see more information about it.\nWhen you find a plugin you wish to install you can do so by clicking the \"Install\" button!";
            ins_text.TextStyle = FontStyle.Italic;
            ins_text.TextAlign = TextAnchor.UpperCenter;
            ins_text.Autosize  = true;

            statusPanel = Create <uiTabPanel>(this);
            statusPanel.Set_Width(200);
            statusPanel.Set_Margin(2, 0, 2, 2);
            statusPanel.onLayout += StatusPanel_onLayout;

            loading_tab       = statusPanel.Add_Tab("loading_tab");
            ld_text           = Create <uiTextArea>("ld_text", statusPanel);
            ld_text.Text      = "...";
            ld_text.TextSize  = 16;
            ld_text.TextAlign = TextAnchor.MiddleCenter;

            retry_pl_list_btn = Create <uiButton>(statusPanel);
            retry_pl_list_btn.Set_Margin(0, 0, 4, 0);
            retry_pl_list_btn.Text     = "Refresh";
            retry_pl_list_btn.TextSize = 16;
            Util.Set_BG_Gradient(retry_pl_list_btn.local_style.normal, 64, GRADIENT_DIR.TOP_BOTTOM, blue, new Color(0.5f, 0.5f, 0.5f, 1f) * blue);
            retry_pl_list_btn.onClicked += retry_btn_onClicked;
            retry_pl_list_btn.isVisible  = false;

            statusPanel.CurrentTab.onLayout += CurrentTab_onLayout;

            plugins_tab          = statusPanel.Add_Tab("plugins_tab");
            list                 = Create <uiListView>(plugins_tab);
            list.disableBG       = true;
            list.Autosize_Method = AutosizeMethod.FILL;
            list.FloodXY();

            loading_tab.Select();
        }
        private IEnumerator Client_Plugins_List_Update()
        {
            loading_tab.Select();
            ld_text.Text = "Fetching master plugins list";
            retry_pl_list_btn.isVisible = false;
            yield return(new WaitForSeconds(0.4f));

            bool        b = true, fail = false;
            IEnumerator iter = null;

            try
            {
                iter = Git_Updater.instance.Cache_And_Open_File_Async(PLUGINS_LIST_URL);
            }
            catch (Exception ex)
            {
                SLog.Error(ex);
                fail = true;
            }
            //while (iter.MoveNext()) yield return null;
            while (b && !fail)
            {
                try
                {
                    if (iter == null)
                    {
                        fail = true;
                        break;
                    }
                    b = iter.MoveNext();
                }
                catch (Exception ex)
                {
                    SLog.Error(ex);
                    fail = true;
                }

                //if(b) yield return null;// wait
                yield return(null);// wait
            }


            if (fail == false)
            {
                ld_text.Text = "Listing plugins";
                if (iter.Current != null)
                {
                    try
                    {
                        FileStream strm = iter.Current as FileStream;

                        byte[] data = Util.Read_Stream(strm);
                        var    list = JSON.Parse(Encoding.ASCII.GetString(data))["plugins"];
                        plugins.Clear();

                        foreach (JSONNode json in list.Childs)
                        {
                            var dat = new Plugin_Download_Data(json);
                            plugins[dat.Hash] = dat;
                        }

                        lbl_pl_count.Value = plugins.Count.ToString();
                        pending_rebuild    = true;
                        plugins_tab.Select();
                    }
                    catch (Exception ex)
                    {
                        SLog.Info("Error while updating plugins list.");
                        SLog.Error(ex);
                        fail = true;
                    }
                }
                else
                {
                    fail = true;
                }
            }

            if (fail)
            {
                retry_pl_list_btn.isVisible = true; // show the retry button
                ld_text.Text = "unable to load plugin master list";
                yield break;                        // exit
            }
            else
            {
                retry_pl_list_btn.isVisible = false;// show the retry button
                ld_text.Text = "Done!";
                plugins_tab.Select();
            }

            yield break;
        }