コード例 #1
0
        private Texture LoadTexture(string file, out TextureHelper.TextureType texType)
        {
            texType = TextureHelper.TextureType.UNKNOWN;
            var strm = Resolve(file);

            if (strm == null)
            {
                return(null);
            }

            var data = Util.Read_Stream(strm);

            strm.Close();

            texType = TextureHelper.Identify_Texture_Type(data);
            var tex = TextureHelper.Load(data);

            tex.name = file;
            return(tex);
        }
コード例 #2
0
        /// <summary>
        /// Loads all of the predefined common texture resources.
        /// </summary>
        internal static void Load_Common()
        {
            const string myNamespace = "SR_PluginLoader";
            var          FLAGS       = (TextureOpFlags.NO_MIPMAPPING & TextureOpFlags.NO_WRAPPING);

            TextureHelper.icon_logo       = (Texture2D)TextureHelper.Load_From_Resource("logo.png", myNamespace, FLAGS);
            TextureHelper.icon_logo_sad   = (Texture2D)TextureHelper.Load_From_Resource("logo_sad.png", myNamespace, FLAGS);
            TextureHelper.icon_unknown    = (Texture2D)TextureHelper.Load_From_Resource("mystery.png", myNamespace, FLAGS);
            TextureHelper.icon_alert      = (Texture2D)TextureHelper.Load_From_Resource("alert.png", myNamespace, FLAGS);
            TextureHelper.icon_close      = (Texture2D)TextureHelper.Load_From_Resource("close.png", myNamespace, FLAGS);
            TextureHelper.icon_close_dark = (Texture2D)TextureHelper.Load_From_Resource("close.png", myNamespace, FLAGS);
            TextureHelper.icon_checkbox   = (Texture2D)TextureHelper.Load_From_Resource("checkbox.png", myNamespace, FLAGS);
            TextureHelper.icon_checkmark  = (Texture2D)TextureHelper.Load_From_Resource("checkmark.png", myNamespace, FLAGS);

            TextureHelper.icon_arrow_left  = (Texture2D)TextureHelper.Load_From_Resource("arrow_left.png", myNamespace, FLAGS);
            TextureHelper.icon_arrow_right = (Texture2D)TextureHelper.Load_From_Resource("arrow_right.png", myNamespace, FLAGS);

            TextureHelper.icon_node_arrow_right = (Texture2D)TextureHelper.Load_From_Resource("node_arrow.png", myNamespace, FLAGS);
            TextureHelper.icon_node_arrow_down  = Rotate_90(icon_node_arrow_right, FLAGS);

            Util.Tint_Texture(TextureHelper.icon_close_dark, new Color(1f, 1f, 1f, 0.5f));
        }
コード例 #3
0
        private void Load_Assets()
        {
            if (this.dll == null)
            {
                return;
            }
            string icon_file  = this.data.ICON;
            string thumb_file = this.data.PREVIEW;


            if (icon_file != null)
            {
                byte[] buf = this.Load_Resource(icon_file);
                if (buf != null)
                {
                    this.icon = (Texture2D)TextureHelper.Load(buf, icon_file);
                }
                else
                {
                    this.icon = null;
                }
            }

            if (thumb_file != null)
            {
                byte[] buf = this.Load_Resource(thumb_file);
                if (buf != null)
                {
                    this.thumbnail = (Texture2D)TextureHelper.Load(buf, thumb_file);
                }
                else
                {
                    this.thumbnail = null;
                }
            }
        }
コード例 #4
0
        public static void init(string hash)
        {
            lock (locker)
            {
                if (Loader.Config != null)
                {
                    return;
                }
                //Application.stackTraceLogType = StackTraceLogType.Full;
                Logging.Logger.Begin(Path.Combine(Application.dataPath, "plugins.log"));

                Stopwatch timer = new Stopwatch();
                timer.Start();

                if (!Loader.Load_Config_Stream())
                {
                    return;
                }

                try
                {
                    DebugHud.Init();
                    TextureHelper.Setup();
                    MaterialHelper.Setup();
                    SiscosHooks.Setup();
                    PluginLoader_Watermark.Setup();
                    MainMenu.Setup();
                    DebugUI.Setup();

                    Setup_Update_Helper();
                    bool ok = Verify_PluginLoader_Hash(hash);
                    if (!ok)
                    {
                        return;
                    }

                    IN_LOADING_PHASE = true;
                    Setup_Plugin_Dir();

                    Check_For_Updates();

                    Setup_Assembly_Resolver();
                    Upgrades.Setup();
                    Assemble_Plugin_List();
                    Load_Config();
                    IN_LOADING_PHASE = false;
                    ResourceExt.map_SR_Icons();

                    plugin_updater = uiControl.Create <Plugin_Update_Viewer>();// This control manages itself and is only able to become visible under certain conditions which it will control. Therefore it needs no var to track it.
                    plugin_updater.Show();

                    dev_tools = uiControl.Create <DevMenu>();
                    //dev_tools.Show();
                    //dev_tools.onShown += (uiWindow w) => { GameTime.Pause(); };
                    //dev_tools.onHidden += (uiWindow w) => { GameTime.Unpause(); };

                    //Misc_Experiments.Find_Common_Classes_For_Idents(new HashSet<Identifiable.Id> { Identifiable.Id.PINK_RAD_LARGO });
                }
                catch (Exception ex)
                {
                    SLog.Error("Exception during PluginLoader initialization!");
                    SLog.Error(ex);
                }
                finally
                {
                    timer.Stop();
                    SLog.Debug("Plugin Loader initialized! Took: {0}ms", timer.ElapsedMilliseconds);
                }
            }
        }
コード例 #5
0
        public PluginManager()
        {
            onLayout += PluginManager_onLayout;
            Title     = "Plugin Manager";
            Set_Size(650, 400);
            Center();
            onShown  += PluginManager_onShown;
            onHidden += PluginManager_onHidden;

            list = Create <uiListView>(this);
            list.Set_Width(200f);
            list.Set_Margin(2, 0, 2, 2);


            top_wrapper = Create <uiWrapperPanel>(this);
            top_wrapper.Autosize_Method = AutosizeMethod.BLOCK;
            top_wrapper.Set_Margin(0, 0, 0, 2);
            top_wrapper.Set_Padding(2);
            top_wrapper.onLayout += Top_wrapper_onLayout;


            btn_store                     = Create <uiIconButton>(top_wrapper);
            btn_store.Text                = "Plugin Store";
            btn_store.Icon                = TextureHelper.icon_arrow_left;
            btn_store.Border.type         = uiBorderType.NONE;
            btn_store.Border.normal.color = Color.white;
            btn_store.Border.normal.size  = new RectOffset(1, 1, 1, 1);
            btn_store.onClicked          += (uiControl c) => { uiWindow.Switch(PluginStore.Instance); };


            btn_donate                 = Create <uiIcon>(top_wrapper);
            btn_donate.Text            = null;
            btn_donate.Image           = (Texture2D)TextureHelper.Load_From_Resource("donate_btn.png", "SR_PluginLoader", (TextureOpFlags.NO_MIPMAPPING & TextureOpFlags.NO_WRAPPING));
            btn_donate.Image_MouseOver = Util.Tint_Texture((Texture2D)TextureHelper.Load_From_Resource("donate_btn.png", "SR_PluginLoader", (TextureOpFlags.NO_MIPMAPPING & TextureOpFlags.NO_WRAPPING)), new Color(0.7f, 0.7f, 0.7f));
            btn_donate.Border.type     = uiBorderType.NONE;
            btn_donate.onClicked      += (uiControl c) => { Process.Start("https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=DYGPA5XA4MWC2"); };


            //CONTROL PANEL
            control_panel = Create <uiCollapser>("control_panel", this);
            control_panel.Autosize_Method = AutosizeMethod.BLOCK;
            control_panel.Set_Margin(2, 2, 2, 0);
            control_panel.Set_Padding(2);
            Util.Set_BG_Color(control_panel.local_style.normal, new Color(0f, 0f, 0f, 0.2f));
            control_panel.onLayout += Control_panel_onLayout;
            control_panel.Collapse();


            pl_toggle           = Create <uiToggle>("pl_toggle", control_panel);
            pl_toggle.onChange += Pl_toggle_onChange;

            btn_copy_json      = Create <uiButton>("copy_json", control_panel);
            btn_copy_json.Text = "Copy Json";
            btn_copy_json.Set_Margin(3, 0);
            btn_copy_json.onClicked += Btn_copy_json_onClicked;


            // TABBED PANEL
            tabPanel = Create <uiTabPanel>(this);
            tabPanel.Autosize_Method = AutosizeMethod.FILL;
            tabPanel.disableBG       = true;
            tabPanel.Set_Margin(2);// This margin gives us that light colored area surrounding the list and tabpanel
            pl_tab = tabPanel.Add_Tab(PLUGIN_TAB_NAME);
            tabPanel.CurrentTab.onLayout += tabPanel_onLayout;
            tabPanel.onChanged           += TabPanel_onChanged;

            pl_tab.Set_Padding(3);// so we can distinguish where the plugin thumbnail's borders are


            // PLUGIN ERRORS PANEL
            pl_errors           = Create <uiCollapser>(pl_tab);
            pl_errors.onLayout += Clps_errors_onLayout;
            pl_errors.Collapse();

            var err_ico = Create <uiIcon>("err_ico", pl_errors);

            err_ico.Image = TextureHelper.icon_alert;
            err_ico.Set_Height(26);

            var err_lbl = Create <uiText>("err_lbl", pl_errors);

            err_lbl.TextColor = Color.red;
            err_lbl.Text      = "Plugin experienced errors while loading!";
            err_lbl.TextAlign = TextAnchor.MiddleLeft;
            err_lbl.Set_Margin(2, 0, 0, 0);


            // PLUGIN INFO

            pl_title = Create <uiText>("pl_title", pl_tab);
            pl_title.local_style.fontSize  = 22;
            pl_title.local_style.fontStyle = FontStyle.Bold;


            pl_auth = Create <uiText>("pl_author", pl_tab);
            pl_vers = Create <uiText>("pl_vers", pl_tab);
            pl_desc = Create <uiTextArea>("pl_desc", pl_tab);

            pl_thumb = Create <uiIcon>("pl_thumb", pl_tab);
            pl_thumb.Border.normal.color = new Color(0f, 0f, 0f, 0.3f);

            pl_desc.Set_Margin(2);
            pl_desc.Set_Background(new Color(0.1f, 0.1f, 0.1f, 0.4f));
            pl_desc.Set_Padding(2);
            pl_desc.Border.normal.color = new Color(0f, 0f, 0f, 0.3f);
            pl_desc.Autosize_Method     = AutosizeMethod.BLOCK;

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

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

            ins_text           = Create <uiTextArea>(tabPanel);
            ins_text.Text      = "Select a plugin from the list on the left to manage it's settings.\nOr, to browse more plugins for download, click the \"Plugin Store\" button at the top left of this window!";
            ins_text.TextStyle = FontStyle.Italic;
            ins_text.Autosize  = true;


            tab_need_plugins              = tabPanel.Add_Tab(NEED_PLUGINS_TAB_NAME);
            tabPanel.CurrentTab.onLayout += NeedPluginsTab_onLayout;

            nop_wrapper           = Create <uiWrapperPanel>(tabPanel);
            nop_wrapper.onLayout += Nop_Wrapper_onLayout;

            ins_no_plugins_text           = Create <uiTextArea>(nop_wrapper);
            ins_no_plugins_text.Text      = "You do not have any plugins installed!\nVisit the plugin store to find and install new plugins.";
            ins_no_plugins_text.TextSize  = 16;
            ins_no_plugins_text.TextColor = new Color(1f, 0.1f, 0.1f, 0.9f);
            ins_no_plugins_text.TextStyle = FontStyle.Bold;
            ins_no_plugins_text.TextAlign = TextAnchor.UpperCenter;
            ins_no_plugins_text.Autosize  = true;
        }
コード例 #6
0
 public static Texture2D Load_Texture_From_Data(byte[] data)
 {
     return((Texture2D)TextureHelper.Load(data));
 }
コード例 #7
0
 public static Texture2D Load_Texture_Resource(string name, string namespace_str)
 {
     return((Texture2D)TextureHelper.Load_From_Resource(name, namespace_str));
 }