示例#1
0
        /// <summary>
        /// Forces the plugin to download the latest version of itself.
        /// (Coroutine)
        /// </summary>
        /// <param name="prog">uiProgressBar instance which this function will use to display the current update progress.</param>
        /// <returns></returns>
        public IEnumerator force_download(uiProgressBar prog, Updater_File_Download_Completed download_complete_cb)
        {
            if (this.data.UPDATE_METHOD == null)
            {
                throw new ArgumentNullException(String.Format("{0} Plugin has no UPDATE_METHOD specified!", this));
            }

            IEnumerator iter = this.Updater.DownloadAsync(this.data.UPDATE_METHOD.URL, this.FilePath, null,
                                                          (float current, float total) =>
            {   //Download progress
                float f = (float)current / (float)total;

                if (prog != null)
                {
                    float p    = (float)current / (float)total;
                    prog.Value = p;
                }
            },
                                                          (string file) =>
            {
                this.is_update_available = false;
                if (download_complete_cb != null)
                {
                    download_complete_cb(file);
                }
            });

            // Run the download coroutine within this coroutine without starting a seperate instance.
            while (iter.MoveNext())
            {
                yield return(null);
            }

            yield break;// Honestly probably not needed but I like to be safe because I still don't fully know the innerworkings of unity's coroutine system.
        }
示例#2
0
 private void Progress_bar_onProgress(uiProgressBar c, float progress, string text)
 {
     if (progress_text != null)
     {
         progress_text.Text = text;
     }
 }
        private void process_downloads()
        {
            if (download_queue.Count > 0)
            {
                Plugin             plugin = download_queue.First();
                Plugin_Update_Item itm    = list.Get_Children().First(o => ((Plugin_Update_Item)o).plugin_hash == plugin.Hash) as Plugin_Update_Item;
                if (itm == null)
                {
                    SLog.Info("Unable to find plugin_update_item for plugin {0}({1})", plugin.data.NAME, plugin.Hash);
                    return;
                }
                else
                {
                    SLog.Info("Found plugin_update_item for plugin {0}({1})", plugin.data.NAME, plugin.Hash);
                }

                uiProgressBar prog = null;
                if (itm != null)
                {
                    prog = itm.progress_bar;
                }

                StartCoroutine(plugin.force_download(prog, (string file) =>
                {
                    download_queue.RemoveAt(0);
                    process_downloads();
                }));
            }
            else
            {
                this.Hide();
                Loader.Restart_App();
            }
        }
        public Plugin_StoreItem() : base(uiControlType.Panel)
        {
            Set_Padding(4, 2, 2, 2);
            Set_Margin(2, 2, 2, 2);
            //Set_Size(DEFAULT_WIDTH, DEFAULT_HEIGHT);
            Autosize_Method = AutosizeMethod.BLOCK;

            Util.Set_BG_Color(local_style.normal, new Color32(32, 32, 32, 200));
            Util.Set_BG_Color(local_style.hover, new Color32(64, 64, 64, 255));
            const float b = 0.5f;

            Border.normal.color = new Color(b, b, b, 1f);

            const float g = 0.8f;

            TextColor       = new Color(g, g, g, 1f);
            TextColor_Hover = Color.white;
            //Utility.Set_BG_Color(local_style.hover, new Color32(32, 40, 60, 255));

            uiText name = uiControl.Create <uiText>("name", this);

            name.Clone_Text_Style(this);
            name.TextStyle       = FontStyle.Bold;
            name.TextSize        = 14;
            name.Autosize_Method = AutosizeMethod.BLOCK;

            uiText auth = uiControl.Create <uiText>("author", this);

            auth.Clone_Text_Style(this);
            auth.TextStyle       = FontStyle.Normal;
            auth.TextSize        = 12;
            auth.Autosize_Method = AutosizeMethod.BLOCK;

            download_info = Create <uiCollapser>("download_info", this);
            download_info.Size_Height_Collapsed = 0;
            download_info.onLayout += Download_info_onLayout;
            download_info.Set_Margin(0);
            download_info.Set_Padding(0);
            //Util.Set_BG_Color(download_info.local_style.normal, new Color(0.1f, 0.5f, 1.0f));
            download_info.Set_Collapsed(true);

            progress_bar = Create <uiProgressBar>("progress", download_info);
            progress_bar.Set_Height(4f);
            progress_bar.Value = 0;
            progress_bar.show_progress_text = false;
            Util.Set_BG_Color(progress_bar.prog_bar.local_style.normal, new Color(0.1f, 0.5f, 1.0f));
            Util.Set_BG_Color(progress_bar.local_style.normal, new Color(0.1f, 0.1f, 0.1f));


            progress_text = uiControl.Create <uiVarText>("progress_text", download_info);
            progress_text.Clone_Text_Style(this);
            progress_text.TextAlign = TextAnchor.LowerRight;
            progress_text.TextStyle = FontStyle.Normal;
            progress_text.TextSize  = 12;
            progress_text.Text      = "Downloading:";
            //progress_text.Text = "0%";
        }
示例#5
0
        /// <summary>
        /// Starts downloading the latest version of this plugin.
        /// (Coroutine)
        /// </summary>
        /// <param name="prog">uiProgressBar instance which this function will use to display the current update progress.</param>
        /// <returns></returns>
        public IEnumerator download_update(uiProgressBar prog, Updater_File_Download_Completed download_complete_cb)
        {
            if (!this.check_for_updates())
            {
                SLog.Info("{0} Plugin.download_update():  Already up to date!", this);
                yield break;
            }

            yield return(this.force_download(prog, download_complete_cb));
        }
示例#6
0
        public Plugin_Update_Item() : base()
        {
            Autosize_Method = AutosizeMethod.BLOCK;
            onClicked      += Plugin_Update_Item_onClicked;

            Border.normal.color = new Color(1f, 1f, 1f, 0.1f);
            Border.active.color = mySkin.settings.selectionColor;
            Border.normal.size  = new RectOffset(0, 0, 0, 1);

            Util.Set_BG_Color(local_style.normal, new Color32(32, 32, 32, 200));

            progress_bar = Create <uiProgressBar>(this);
            progress_bar.show_progress_text = false;
            Util.Set_BG_Color(progress_bar.prog_bar.local_style.normal, new Color(0.1f, 0.4f, 0.8f, 0.7f));
            progress_bar.onProgress += Progress_bar_onProgress;

            checkbox = Create <uiCheckbox>(this);
            checkbox.label.local_style.fontSize = 16;

            progress_text = Create <uiText>(this);
            progress_text.local_style.fontSize  = 11;
            progress_text.local_style.fontStyle = FontStyle.BoldAndItalic;
            //progress_text.local_style.normal.textColor = new Color(0.3f, 0.7f, 1.0f, 0.9f);
        }