Пример #1
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Loads the widget
        /// </summary>
        ///
        /// <param name="configFileFilename">Filename of the config file.
        /// The config file must contain a Slider2d section with the needed information.</param>
        ///
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public Slider2d(string configFileFilename)
        {
            m_DraggableWidget  = true;
            m_LoadedConfigFile = Global.ResourcePath + configFileFilename;

            // Parse the config file
            ConfigFile configFile = new ConfigFile(m_LoadedConfigFile, "Slider2d");

            // Find the folder that contains the config file
            string configFileFolder = m_LoadedConfigFile.Substring(0, m_LoadedConfigFile.LastIndexOfAny(new char[] { '/', '\\' }) + 1);

            // Loop over all properties
            for (int i = 0; i < configFile.Properties.Count; ++i)
            {
                if (configFile.Properties[i] == "separatehoverimage")
                {
                    m_SeparateHoverImage = configFile.ReadBool(i);
                }
                else if (configFile.Properties[i] == "tracknormalimage")
                {
                    configFile.ReadTexture(i, configFileFolder, m_TextureTrackNormal);
                }
                else if (configFile.Properties[i] == "trackhoverimage")
                {
                    configFile.ReadTexture(i, configFileFolder, m_TextureTrackHover);
                }
                else if (configFile.Properties[i] == "thumbnormalimage")
                {
                    configFile.ReadTexture(i, configFileFolder, m_TextureThumbNormal);
                }
                else if (configFile.Properties[i] == "thumbhoverimage")
                {
                    configFile.ReadTexture(i, configFileFolder, m_TextureThumbHover);
                }
                else
                {
                    Internal.Output("TGUI warning: Unrecognized property '" + configFile.Properties[i]
                                    + "' in section Slider2d in " + m_LoadedConfigFile + ".");
                }
            }

            // Make sure the required textures were loaded
            if ((m_TextureTrackNormal.texture != null) && (m_TextureThumbNormal.texture != null))
            {
                // Set the size of the slider
                m_Size = new Vector2f(m_TextureTrackNormal.Size.X, m_TextureTrackNormal.Size.Y);
            }
            else
            {
                throw new Exception("Not all needed images were loaded for the slider. Is the Slider2d section in " + m_LoadedConfigFile + " complete?");
            }

            // Check if optional textures were loaded
            if ((m_TextureTrackHover.texture != null) && (m_TextureThumbHover.texture != null))
            {
                m_WidgetPhase |= (byte)WidgetPhase.Hover;
            }
        }
Пример #2
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Loads the widget
        /// </summary>
        ///
        /// <param name="configFileFilename">Filename of the config file.
        /// The config file must contain a SpinButton section with the needed information.</param>
        ///
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public SpinButton(string configFileFilename)
        {
            m_LoadedConfigFile = Global.ResourcePath + configFileFilename;

            // Parse the config file
            ConfigFile configFile = new ConfigFile(m_LoadedConfigFile, "SpinButton");

            // Find the folder that contains the config file
            string configFileFolder = m_LoadedConfigFile.Substring(0, m_LoadedConfigFile.LastIndexOfAny(new char[] { '/', '\\' }) + 1);

            // Loop over all properties
            for (int i = 0; i < configFile.Properties.Count; ++i)
            {
                if (configFile.Properties[i] == "separatehoverimage")
                {
                    m_SeparateHoverImage = configFile.ReadBool(i);
                }
                else if (configFile.Properties[i] == "arrowupnormalimage")
                {
                    configFile.ReadTexture(i, configFileFolder, m_TextureArrowUpNormal);
                }
                else if (configFile.Properties[i] == "arrowuphoverimage")
                {
                    configFile.ReadTexture(i, configFileFolder, m_TextureArrowUpHover);
                }
                else if (configFile.Properties[i] == "arrowdownnormalimage")
                {
                    configFile.ReadTexture(i, configFileFolder, m_TextureArrowDownNormal);
                }
                else if (configFile.Properties[i] == "arrowdownhoverimage")
                {
                    configFile.ReadTexture(i, configFileFolder, m_TextureArrowDownHover);
                }
                else
                {
                    Internal.Output("TGUI warning: Unrecognized property '" + configFile.Properties[i]
                                    + "' in section SpinButton in " + m_LoadedConfigFile + ".");
                }
            }

            // Make sure the required textures were loaded
            if ((m_TextureArrowUpNormal.texture != null) && (m_TextureArrowDownNormal.texture != null))
            {
                m_Size = new Vector2f(m_TextureArrowUpNormal.Size.X, m_TextureArrowUpNormal.Size.Y + m_TextureArrowDownNormal.Size.Y);
            }
            else
            {
                throw new Exception("Not all needed images were loaded for the spin button. Is the SpinButton section in " + m_LoadedConfigFile + " complete?");
            }

            // Check if optional textures were loaded
            if ((m_TextureArrowUpHover.texture != null) && (m_TextureArrowDownHover.texture != null))
            {
                m_WidgetPhase |= (byte)WidgetPhase.Hover;
            }
        }
Пример #3
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Loads the widget
        /// </summary>
        ///
        /// <param name="configFileFilename">Filename of the config file.
        /// The config file must contain a Knob section with the needed information.</param>
        ///
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public Knob(string configFileFilename)
        {
            m_DraggableWidget = true;

            m_loadedConfigFile = Global.ResourcePath + configFileFilename;

            // Parse the config file
            ConfigFile configFile = new ConfigFile(m_loadedConfigFile, "Knob");

            // Find the folder that contains the config file
            string configFileFolder = m_loadedConfigFile.Substring(0, m_loadedConfigFile.LastIndexOfAny(new char[] { '/', '\\' }) + 1);

            // Loop over all properties
            for (int i = 0; i < configFile.Properties.Count; ++i)
            {
                if (configFile.Properties[i] == "backgroundimage")
                {
                    configFile.ReadTexture(i, configFileFolder, m_backgroundTexture);
                }
                else if (configFile.Properties[i] == "foregroundimage")
                {
                    configFile.ReadTexture(i, configFileFolder, m_foregroundTexture);
                }
                else if (configFile.Properties[i] == "imagerotation")
                {
                    m_imageRotation = (float)Convert.ToDouble(configFile.Values[i]);
                }
                else
                {
                    Internal.Output("TGUI warning: Unrecognized property '" + configFile.Properties[i]
                                    + "' in section Knob in " + m_loadedConfigFile + ".");
                }
            }

            // Make sure the required textures were loaded
            if ((m_backgroundTexture.texture != null) && (m_foregroundTexture.texture != null))
            {
                // Rotate the image
                m_foregroundTexture.sprite.Origin   = new Vector2f(m_foregroundTexture.Size.X / 2.0f, m_foregroundTexture.Size.Y / 2.0f);
                m_foregroundTexture.sprite.Rotation = m_startRotation - m_imageRotation;

                m_foregroundTexture.sprite.Position = new Vector2f(m_backgroundTexture.Size.X / 2.0f, m_backgroundTexture.Size.Y / 2.0f);

                Size = new Vector2f(m_backgroundTexture.Size.X, m_backgroundTexture.Size.Y);
            }
            else
            {
                throw new Exception("Not all needed images were loaded for the knob. Is the Knob section in " + m_loadedConfigFile + " complete?");
            }
        }
Пример #4
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Loads the widget
        /// </summary>
        ///
        /// <param name="configFileFilename">Filename of the config file.
        /// The config file must contain a Checkbox section with the needed information.</param>
        ///
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public Checkbox(string configFileFilename)
        {
            m_DraggableWidget = true;

            m_LoadedConfigFile = Global.ResourcePath + configFileFilename;

            // Parse the config file
            ConfigFile configFile = new ConfigFile (m_LoadedConfigFile, "Checkbox");

            // Find the folder that contains the config file
            string configFileFolder = m_LoadedConfigFile.Substring(0, m_LoadedConfigFile.LastIndexOfAny(new char[] {'/', '\\'}) + 1);

            // Loop over all properties
            for (int i = 0; i < configFile.Properties.Count; ++i)
            {
                if (configFile.Properties[i] == "textcolor")
                    m_Text.Color = configFile.ReadColor(i);
                else if (configFile.Properties[i] == "checkedimage")
                    configFile.ReadTexture (i, configFileFolder, m_TextureChecked);
                else if (configFile.Properties[i] == "uncheckedimage")
                    configFile.ReadTexture (i, configFileFolder, m_TextureUnchecked);
                else if (configFile.Properties[i] == "hoverimage")
                    configFile.ReadTexture (i, configFileFolder, m_TextureHover);
                else if (configFile.Properties[i] == "focusedimage")
                    configFile.ReadTexture (i, configFileFolder, m_TextureFocused);
                else
                    Internal.Output("TGUI warning: Unrecognized property '" + configFile.Properties[i]
                                    + "' in section Checkbox in " + m_LoadedConfigFile + ".");
            }

            // Make sure the required textures were loaded
            if ((m_TextureChecked.texture != null) && (m_TextureUnchecked.texture != null))
            {
                Size = new Vector2f(m_TextureUnchecked.Size.X, m_TextureChecked.Size.Y);
            }
            else
                throw new Exception("Not all needed images were loaded for the checkbox. Is the Checkbox section in " + m_LoadedConfigFile + " complete?");

            // Check if optional textures were loaded
            if (m_TextureFocused.texture != null)
            {
                m_AllowFocus = true;
                m_WidgetPhase |= (byte)WidgetPhase.Focused;
            }
            if (m_TextureHover.texture != null)
            {
                m_WidgetPhase |= (byte)WidgetPhase.Hover;
            }
        }
Пример #5
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Loads the widget
        /// </summary>
        ///
        /// <param name="configFileFilename">Filename of the config file.
        /// The config file must contain a ComboBox section with the needed information.</param>
        ///
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public ComboBox(string configFileFilename)
        {
            m_DraggableWidget = true;

            m_ListBox.Visible               = false;
            m_ListBox.Size                  = new Vector2f(50, 24);
            m_ListBox.ItemHeight            = 24;
            m_ListBox.ItemSelectedCallback += NewItemSelectedCallbackFunction;
            m_ListBox.UnfocusedCallback    += ListBoxUnfocusedCallbackFunction;

            m_LoadedConfigFile = Global.ResourcePath + configFileFilename;

            // Parse the config file
            ConfigFile configFile = new ConfigFile(m_LoadedConfigFile, "ComboBox");

            // Find the folder that contains the config file
            string configFileFolder = configFileFilename.Substring(0, configFileFilename.LastIndexOfAny(new char[] { '/', '\\' }) + 1);

            // Loop over all properties
            for (int i = 0; i < configFile.Properties.Count; ++i)
            {
                if (configFile.Properties[i] == "separatehoverimage")
                {
                    m_SeparateHoverImage = configFile.ReadBool(i);
                }
                else if (configFile.Properties[i] == "backgroundcolor")
                {
                    BackgroundColor = configFile.ReadColor(i);
                }
                else if (configFile.Properties[i] == "textcolor")
                {
                    TextColor = configFile.ReadColor(i);
                }
                else if (configFile.Properties[i] == "selectedbackgroundcolor")
                {
                    SelectedBackgroundColor = configFile.ReadColor(i);
                }
                else if (configFile.Properties[i] == "selectedtextcolor")
                {
                    SelectedTextColor = configFile.ReadColor(i);
                }
                else if (configFile.Properties[i] == "bordercolor")
                {
                    BorderColor = configFile.ReadColor(i);
                }
                else if (configFile.Properties[i] == "arrowupnormalimage")
                {
                    configFile.ReadTexture(i, configFileFolder, m_TextureArrowUpNormal);
                }
                else if (configFile.Properties[i] == "arrowuphoverimage")
                {
                    configFile.ReadTexture(i, configFileFolder, m_TextureArrowUpHover);
                }
                else if (configFile.Properties[i] == "arrowdownnormalimage")
                {
                    configFile.ReadTexture(i, configFileFolder, m_TextureArrowDownNormal);
                }
                else if (configFile.Properties[i] == "arrowdownhoverimage")
                {
                    configFile.ReadTexture(i, configFileFolder, m_TextureArrowDownHover);
                }
                else if (configFile.Properties[i] == "borders")
                {
                    Borders borders;
                    if (Internal.ExtractBorders(configFile.Values [i], out borders))
                    {
                        Borders = borders;
                    }
                }
                else if (configFile.Properties[i] == "scrollbar")
                {
                    if ((configFile.Values[i].Length < 3) || (configFile.Values[i][0] != '"') || (configFile.Values[i][configFile.Values[i].Length - 1] != '"'))
                    {
                        throw new Exception("Failed to parse value for Scrollbar in section ChatBox in " + m_LoadedConfigFile + ".");
                    }

                    // load the scrollbar
                    m_ListBox.SetScrollbar(configFileFolder + (configFile.Values[i]).Substring(1, configFile.Values[i].Length - 2));
                }
                else
                {
                    Internal.Output("TGUI warning: Unrecognized property '" + configFile.Properties[i]
                                    + "' in section ComboBox in " + m_LoadedConfigFile + ".");
                }
            }

            // Make sure the required textures were loaded
            if ((m_TextureArrowUpNormal.texture == null) || (m_TextureArrowDownNormal.texture == null))
            {
                throw new Exception("Not all needed images were loaded for the combo box. Is the ComboBox section in " + m_LoadedConfigFile + " complete?");
            }

            // Check if optional textures were loaded
            if ((m_TextureArrowUpHover.texture != null) && (m_TextureArrowDownHover.texture != null))
            {
                m_WidgetPhase |= (byte)WidgetPhase.Hover;
            }
        }
Пример #6
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Loads the widget
        /// </summary>
        ///
        /// <param name="configFileFilename">Filename of the config file.
        /// The config file must contain a LoadingBar section with the needed information.</param>
        ///
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public LoadingBar(string configFileFilename)
        {
            m_LoadedConfigFile = Global.ResourcePath + configFileFilename;

            // Parse the config file
            ConfigFile configFile = new ConfigFile(m_LoadedConfigFile, "LoadingBar");

            // Find the folder that contains the config file
            string configFileFolder = m_LoadedConfigFile.Substring(0, m_LoadedConfigFile.LastIndexOfAny(new char[] { '/', '\\' }) + 1);

            // Loop over all properties
            for (int i = 0; i < configFile.Properties.Count; ++i)
            {
                if (configFile.Properties[i] == "backimage")
                {
                    configFile.ReadTexture(i, configFileFolder, m_TextureBack_M);
                    m_SplitImage = false;
                }
                else if (configFile.Properties[i] == "frontimage")
                {
                    configFile.ReadTexture(i, configFileFolder, m_TextureFront_M);
                }
                else if (configFile.Properties[i] == "backimage_l")
                {
                    configFile.ReadTexture(i, configFileFolder, m_TextureBack_L);
                }
                else if (configFile.Properties[i] == "backimage_m")
                {
                    configFile.ReadTexture(i, configFileFolder, m_TextureBack_M);
                    m_SplitImage = true;
                }
                else if (configFile.Properties[i] == "backimage_r")
                {
                    configFile.ReadTexture(i, configFileFolder, m_TextureBack_R);
                }
                else if (configFile.Properties[i] == "frontimage_l")
                {
                    configFile.ReadTexture(i, configFileFolder, m_TextureFront_L);
                }
                else if (configFile.Properties[i] == "frontimage_m")
                {
                    configFile.ReadTexture(i, configFileFolder, m_TextureFront_M);
                }
                else if (configFile.Properties[i] == "frontimage_r")
                {
                    configFile.ReadTexture(i, configFileFolder, m_TextureFront_R);
                }
                else if (configFile.Properties [i] == "textcolor")
                {
                    TextColor = configFile.ReadColor(i);
                }
                else if (configFile.Properties [i] == "textsize")
                {
                    TextSize = Convert.ToUInt32(configFile.Values [i]);
                }
                else
                {
                    Internal.Output("TGUI warning: Unrecognized property '" + configFile.Properties[i]
                                    + "' in section LoadingBar in " + m_LoadedConfigFile + ".");
                }
            }

            // Check if the image is split
            if (m_SplitImage)
            {
                // Make sure the required textures were loaded
                if ((m_TextureBack_L.texture != null) && (m_TextureBack_M.texture != null) && (m_TextureBack_R.texture != null) &&
                    (m_TextureFront_L.texture != null) && (m_TextureFront_M.texture != null) && (m_TextureFront_R.texture != null))
                {
                    m_Size.X = (float)(m_TextureBack_L.Size.X + m_TextureBack_M.Size.X + m_TextureBack_R.Size.X);
                    m_Size.Y = (float)(m_TextureBack_M.Size.Y);

                    m_TextureBack_M.texture.texture.Repeated  = true;
                    m_TextureFront_M.texture.texture.Repeated = true;
                }
                else
                {
                    throw new Exception("Not all needed images were loaded for the loading bar. Is the LoadingBar section in " + m_LoadedConfigFile + " complete?");
                }
            }
            else // The image isn't split
            {
                // Make sure the required textures were loaded
                if ((m_TextureBack_M.texture != null) && (m_TextureFront_M.texture != null))
                {
                    m_Size = new Vector2f(m_TextureBack_M.Size.X, m_TextureBack_M.Size.Y);
                }
                else
                {
                    throw new Exception("TGUI error: Not all needed images were loaded for the loading bar. Is the LoadingBar section in " + m_LoadedConfigFile + " complete?");
                }
            }

            // Calculate the size of the front image (the size of the part that will be drawn)
            RecalculateSize();
        }
Пример #7
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Loads the widget
        /// </summary>
        ///
        /// <param name="configFileFilename">Filename of the config file.
        /// The config file must contain a EditBox section with the needed information.</param>
        ///
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public EditBox(string configFileFilename)
        {
            m_AnimatedWidget = true;
            m_DraggableWidget = true;
            m_AllowFocus = true;

            m_LoadedConfigFile = Global.ResourcePath + configFileFilename;

            // Parse the config file
            ConfigFile configFile = new ConfigFile (m_LoadedConfigFile, "EditBox");

            // Find the folder that contains the config file
            string configFileFolder = m_LoadedConfigFile.Substring(0, m_LoadedConfigFile.LastIndexOfAny(new char[] {'/', '\\'}) + 1);

            // Loop over all properties
            for (int i = 0; i < configFile.Properties.Count; ++i)
            {
                if (configFile.Properties[i] == "separatehoverimage")
                    m_SeparateHoverImage = configFile.ReadBool(i);
                else if (configFile.Properties[i] == "textcolor")
                {
                    Color color = configFile.ReadColor(i);
                    m_TextBeforeSelection.Color = color;
                    m_TextAfterSelection.Color = color;
                }
                else if (configFile.Properties[i] == "selectedtextcolor")
                    m_TextSelection.Color = configFile.ReadColor(i);
                else if (configFile.Properties[i] == "selectedtextbackgroundcolor")
                    m_SelectedTextBackground.FillColor = configFile.ReadColor(i);
                else if (configFile.Properties[i] == "selectionpointcolor")
                    m_SelectionPoint.FillColor = configFile.ReadColor(i);
                else if (configFile.Properties[i] == "selectionpointwidth")
                    SelectionPointWidth = Convert.ToUInt32(configFile.Values [i]);
                else if (configFile.Properties[i] == "borders")
                {
                    Borders borders;
                    if (Internal.ExtractBorders(configFile.Values [i], out borders))
                        Borders = borders;
                }
                else if (configFile.Properties[i] == "normalimage")
                {
                    configFile.ReadTexture (i, configFileFolder, m_TextureNormal_M);
                    m_SplitImage = false;
                }
                else if (configFile.Properties[i] == "hoverimage")
                    configFile.ReadTexture(i, configFileFolder, m_TextureHover_M);
                else if (configFile.Properties[i] == "focusedimage")
                    configFile.ReadTexture (i, configFileFolder, m_TextureFocused_M);
                else if (configFile.Properties[i] == "normalimage_l")
                    configFile.ReadTexture (i, configFileFolder, m_TextureNormal_L);
                else if (configFile.Properties[i] == "normalimage_m")
                {
                    configFile.ReadTexture(i, configFileFolder, m_TextureNormal_M);
                    m_SplitImage = true;
                }
                else if (configFile.Properties[i] == "normalimage_r")
                    configFile.ReadTexture(i, configFileFolder, m_TextureNormal_R);
                else if (configFile.Properties[i] == "hoverimage_l")
                    configFile.ReadTexture(i, configFileFolder, m_TextureHover_L);
                else if (configFile.Properties[i] == "hoverimage_m")
                    configFile.ReadTexture (i, configFileFolder, m_TextureHover_M);
                else if (configFile.Properties[i] == "hoverimage_r")
                    configFile.ReadTexture (i, configFileFolder, m_TextureHover_R);
                else if (configFile.Properties[i] == "focusedimage_l")
                    configFile.ReadTexture (i, configFileFolder, m_TextureFocused_L);
                else if (configFile.Properties[i] == "focusedimage_m")
                    configFile.ReadTexture(i, configFileFolder, m_TextureFocused_M);
                else if (configFile.Properties[i] == "focusedimage_r")
                    configFile.ReadTexture(i, configFileFolder, m_TextureFocused_R);
                else
                    Internal.Output("TGUI warning: Unrecognized property '" + configFile.Properties[i]
                                    + "' in section EditBox in " + m_LoadedConfigFile + ".");
            }

            // Check if the image is split
            if (m_SplitImage)
            {
                // Make sure the required textures were loaded
                if ((m_TextureNormal_L.texture != null) && (m_TextureNormal_M.texture != null) && (m_TextureNormal_R.texture != null))
                {
                    Size = new Vector2f(m_TextureNormal_L.Size.X + m_TextureNormal_M.Size.X + m_TextureNormal_R.Size.X,
                                        m_TextureNormal_M.Size.Y);

                    m_TextureNormal_M.texture.texture.Repeated = true;
                }
                else
                {
                    throw new Exception("Not all needed images were loaded for the edit box. Is the EditBox section in "
                                        + m_LoadedConfigFile + " complete?");
                }

                // Check if optional textures were loaded
                if ((m_TextureFocused_L.texture != null) && (m_TextureFocused_M.texture != null) && (m_TextureFocused_R.texture != null))
                {
                    m_WidgetPhase |= (byte)WidgetPhase.Focused;

                    m_TextureFocused_M.texture.texture.Repeated = true;
                }
                if ((m_TextureHover_L.texture != null) && (m_TextureHover_M.texture != null) && (m_TextureHover_R.texture != null))
                {
                    m_WidgetPhase |= (byte)WidgetPhase.Hover;

                    m_TextureHover_M.texture.texture.Repeated = true;
                }
            }
            else // The image isn't split
            {
                // Make sure the required texture was loaded
                if (m_TextureNormal_M.texture != null)
                {
                    Size = new Vector2f(m_TextureNormal_M.Size.X, m_TextureNormal_M.Size.Y);
                }
                else
                    throw new Exception("NormalImage property wasn't loaded. Is the EditBox section in " + m_LoadedConfigFile + " complete?");

                // Check if optional textures were loaded
                if (m_TextureFocused_M.texture != null)
                {
                    m_WidgetPhase |= (byte)WidgetPhase.Focused;
                }
                if (m_TextureHover_M.texture != null)
                {
                    m_WidgetPhase |= (byte)WidgetPhase.Hover;
                }
            }

            // Auto-size the text
            TextSize = 0;
        }
Пример #8
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Loads the child window
        /// </summary>
        ///
        /// <param name="configFileFilename">Filename of the config file.
        /// The config file must contain a ChildWindow section with the needed information.</param>
        ///
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        protected void InternalLoad(string configFileFilename)
        {
            m_LoadedConfigFile = Global.ResourcePath + configFileFilename;

            // Parse the config file
            ConfigFile configFile = new ConfigFile (m_LoadedConfigFile, "ChildWindow");

            // Find the folder that contains the config file
            string configFileFolder = m_LoadedConfigFile.Substring(0, m_LoadedConfigFile.LastIndexOfAny(new char[] {'/', '\\'}) + 1);

            // Loop over all properties
            for (int i = 0; i < configFile.Properties.Count; ++i)
            {
                if (configFile.Properties[i] == "backgroundcolor")
                    m_BackgroundColor = configFile.ReadColor(i);
                else if (configFile.Properties[i] == "titlecolor")
                    m_TitleText.Color = configFile.ReadColor(i);
                else if (configFile.Properties[i] == "bordercolor")
                    m_BorderColor = configFile.ReadColor(i);
                else if (configFile.Properties[i] == "titlebarimage")
                {
                    configFile.ReadTexture (i, configFileFolder, m_TextureTitleBar_M);
                    m_SplitImage = false;
                }
                else if (configFile.Properties[i] == "titlebarimage_l")
                    configFile.ReadTexture (i, configFileFolder, m_TextureTitleBar_L);
                else if (configFile.Properties[i] == "titlebarimage_m")
                {
                    configFile.ReadTexture (i, configFileFolder, m_TextureTitleBar_M);
                    m_SplitImage = true;
                }
                else if (configFile.Properties[i] == "titlebarimage_r")
                    configFile.ReadTexture (i, configFileFolder, m_TextureTitleBar_R);
                else if (configFile.Properties[i] == "closebuttonseparatehoverimage")
                    m_CloseButton.m_SeparateHoverImage = configFile.ReadBool(i);
                else if (configFile.Properties[i] == "closebuttonnormalimage")
                    configFile.ReadTexture(i, configFileFolder, m_CloseButton.m_TextureNormal_M);
                else if (configFile.Properties[i] == "closebuttonhoverimage")
                    configFile.ReadTexture(i, configFileFolder, m_CloseButton.m_TextureHover_M);
                else if (configFile.Properties[i] == "closebuttondownimage")
                    configFile.ReadTexture (i, configFileFolder, m_CloseButton.m_TextureDown_M);
                else if (configFile.Properties[i] == "borders")
                {
                    Borders borders;
                    if (Internal.ExtractBorders (configFile.Values [i], out borders))
                        Borders = borders;
                }
                else if (configFile.Properties[i] == "distancetoside")
                    DistanceToSide = Convert.ToUInt32(configFile.Values [i]);
                else
                    Internal.Output("TGUI warning: Unrecognized property '" + configFile.Properties[i]
                                    + "' in section ChildWindow in " + m_LoadedConfigFile + ".");
            }

            // Initialize the close button if it was loaded
            if (m_CloseButton.m_TextureNormal_M.texture != null)
            {
                // Check if optional textures were loaded
                if (m_CloseButton.m_TextureHover_M.texture != null)
                {
                    m_CloseButton.m_WidgetPhase |= (byte)WidgetPhase.Hover;
                }
                if (m_CloseButton.m_TextureDown_M.texture != null)
                {
                    m_CloseButton.m_WidgetPhase |= (byte)WidgetPhase.MouseDown;
                }

                m_CloseButton.m_Size = new Vector2f(m_CloseButton.m_TextureNormal_M.Size.X,
                                                    m_CloseButton.m_TextureNormal_M.Size.Y);
            }
            else // Close button wan't loaded
                throw new Exception("Missing a CloseButtonNormalImage property in section ChildWindow in " + m_LoadedConfigFile + ".");

            // Check if the image is split
            if (m_SplitImage)
            {
                // Make sure the required textures was loaded
                if ((m_TextureTitleBar_L.texture != null) && (m_TextureTitleBar_M.texture != null) && (m_TextureTitleBar_R.texture != null))
                {
                    m_TitleBarHeight = m_TextureTitleBar_M.Size.Y;

                    float width = m_TextureTitleBar_L.Size.X + m_TextureTitleBar_M.Size.X + m_TextureTitleBar_R.Size.X;
                    Size = new Vector2f(width, width * 3.0f / 4.0f);

                    m_TextureTitleBar_M.texture.texture.Repeated = true;
                }
                else
                    throw new Exception("TGUI error: Not all needed images were loaded for the child window. Is the ChildWindow section in " + m_LoadedConfigFile + " complete?");
            }
            else // The image isn't split
            {
                // Make sure the required texture was loaded
                if ((m_TextureTitleBar_M.texture != null))
                {
                    m_TitleBarHeight = m_TextureTitleBar_M.Size.Y;

                    Size = new Vector2f(m_TextureTitleBar_M.Size.X, m_TextureTitleBar_M.Size.X * 3.0f / 4.0f);
                }
                else
                    throw new Exception("Not all needed images were loaded for the child window. Is the ChildWindow section in " + m_LoadedConfigFile + " complete?");

                // Set the size of the title text
                m_TitleText.CharacterSize = (uint)(m_TitleBarHeight * 8.0 / 10.0);
            }
        }
Пример #9
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Loads the widget
        /// </summary>
        ///
        /// <param name="configFileFilename">Filename of the config file.
        /// The config file must contain a Slider2d section with the needed information.</param>
        ///
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public Slider2d(string configFileFilename)
        {
            m_DraggableWidget = true;
            m_LoadedConfigFile = Global.ResourcePath + configFileFilename;

            // Parse the config file
            ConfigFile configFile = new ConfigFile (m_LoadedConfigFile, "Slider2d");

            // Find the folder that contains the config file
            string configFileFolder = m_LoadedConfigFile.Substring(0, m_LoadedConfigFile.LastIndexOfAny(new char[] {'/', '\\'}) + 1);

            // Loop over all properties
            for (int i = 0; i < configFile.Properties.Count; ++i)
            {
                if (configFile.Properties[i] == "separatehoverimage")
                    m_SeparateHoverImage = configFile.ReadBool(i);
                else if (configFile.Properties[i] == "tracknormalimage")
                    configFile.ReadTexture (i, configFileFolder, m_TextureTrackNormal);
                else if (configFile.Properties[i] == "trackhoverimage")
                    configFile.ReadTexture(i, configFileFolder, m_TextureTrackHover);
                else if (configFile.Properties[i] == "thumbnormalimage")
                    configFile.ReadTexture(i, configFileFolder, m_TextureThumbNormal);
                else if (configFile.Properties[i] == "thumbhoverimage")
                    configFile.ReadTexture(i, configFileFolder, m_TextureThumbHover);
                else
                    Internal.Output("TGUI warning: Unrecognized property '" + configFile.Properties[i]
                                    + "' in section Slider2d in " + m_LoadedConfigFile + ".");
            }

            // Make sure the required textures were loaded
            if ((m_TextureTrackNormal.texture != null) && (m_TextureThumbNormal.texture != null))
            {
                // Set the size of the slider
                m_Size = new Vector2f(m_TextureTrackNormal.Size.X, m_TextureTrackNormal.Size.Y);
            }
            else
            {
                throw new Exception("Not all needed images were loaded for the slider. Is the Slider2d section in " + m_LoadedConfigFile + " complete?");
            }

            // Check if optional textures were loaded
            if ((m_TextureTrackHover.texture != null) && (m_TextureThumbHover.texture != null))
            {
                m_WidgetPhase |= (byte)WidgetPhase.Hover;
            }
        }
Пример #10
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Loads the widget
        /// </summary>
        ///
        /// <param name="configFileFilename">Filename of the config file.
        /// The config file must contain a Checkbox section with the needed information.</param>
        ///
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public Checkbox(string configFileFilename)
        {
            m_DraggableWidget = true;

            m_LoadedConfigFile = Global.ResourcePath + configFileFilename;

            // Parse the config file
            ConfigFile configFile = new ConfigFile(m_LoadedConfigFile, "Checkbox");

            // Find the folder that contains the config file
            string configFileFolder = m_LoadedConfigFile.Substring(0, m_LoadedConfigFile.LastIndexOfAny(new char[] { '/', '\\' }) + 1);

            // Loop over all properties
            for (int i = 0; i < configFile.Properties.Count; ++i)
            {
                if (configFile.Properties[i] == "textcolor")
                {
                    m_Text.Color = configFile.ReadColor(i);
                }
                else if (configFile.Properties[i] == "checkedimage")
                {
                    configFile.ReadTexture(i, configFileFolder, m_TextureChecked);
                }
                else if (configFile.Properties[i] == "uncheckedimage")
                {
                    configFile.ReadTexture(i, configFileFolder, m_TextureUnchecked);
                }
                else if (configFile.Properties[i] == "hoverimage")
                {
                    configFile.ReadTexture(i, configFileFolder, m_TextureHover);
                }
                else if (configFile.Properties[i] == "focusedimage")
                {
                    configFile.ReadTexture(i, configFileFolder, m_TextureFocused);
                }
                else
                {
                    Internal.Output("TGUI warning: Unrecognized property '" + configFile.Properties[i]
                                    + "' in section Checkbox in " + m_LoadedConfigFile + ".");
                }
            }

            // Make sure the required textures were loaded
            if ((m_TextureChecked.texture != null) && (m_TextureUnchecked.texture != null))
            {
                Size = new Vector2f(m_TextureUnchecked.Size.X, m_TextureChecked.Size.Y);
            }
            else
            {
                throw new Exception("Not all needed images were loaded for the checkbox. Is the Checkbox section in " + m_LoadedConfigFile + " complete?");
            }

            // Check if optional textures were loaded
            if (m_TextureFocused.texture != null)
            {
                m_AllowFocus   = true;
                m_WidgetPhase |= (byte)WidgetPhase.Focused;
            }
            if (m_TextureHover.texture != null)
            {
                m_WidgetPhase |= (byte)WidgetPhase.Hover;
            }
        }
Пример #11
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Loads the widget
        /// </summary>
        ///
        /// <param name="configFileFilename">Filename of the config file.
        /// The config file must contain a ComboBox section with the needed information.</param>
        ///
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public ComboBox(string configFileFilename)
        {
            m_DraggableWidget = true;

            m_ListBox.Visible = false;
            m_ListBox.Size = new Vector2f(50, 24);
            m_ListBox.ItemHeight = 24;
            m_ListBox.ItemSelectedCallback += NewItemSelectedCallbackFunction;
            m_ListBox.UnfocusedCallback += ListBoxUnfocusedCallbackFunction;

            m_LoadedConfigFile = Global.ResourcePath + configFileFilename;

            // Parse the config file
            ConfigFile configFile = new ConfigFile (m_LoadedConfigFile, "ComboBox");

            // Find the folder that contains the config file
            string configFileFolder = configFileFilename.Substring(0, configFileFilename.LastIndexOfAny(new char[] {'/', '\\'}) + 1);

            // Loop over all properties
            for (int i = 0; i < configFile.Properties.Count; ++i)
            {
                if (configFile.Properties[i] == "separatehoverimage")
                    m_SeparateHoverImage = configFile.ReadBool(i);
                else if (configFile.Properties[i] == "backgroundcolor")
                    BackgroundColor = configFile.ReadColor(i);
                else if (configFile.Properties[i] == "textcolor")
                    TextColor = configFile.ReadColor(i);
                else if (configFile.Properties[i] == "selectedbackgroundcolor")
                    SelectedBackgroundColor = configFile.ReadColor(i);
                else if (configFile.Properties[i] == "selectedtextcolor")
                    SelectedTextColor = configFile.ReadColor(i);
                else if (configFile.Properties[i] == "bordercolor")
                    BorderColor = configFile.ReadColor(i);
                else if (configFile.Properties[i] == "arrowupnormalimage")
                    configFile.ReadTexture(i, configFileFolder, m_TextureArrowUpNormal);
                else if (configFile.Properties[i] == "arrowuphoverimage")
                    configFile.ReadTexture(i, configFileFolder, m_TextureArrowUpHover);
                else if (configFile.Properties[i] == "arrowdownnormalimage")
                    configFile.ReadTexture(i, configFileFolder, m_TextureArrowDownNormal);
                else if (configFile.Properties[i] == "arrowdownhoverimage")
                    configFile.ReadTexture(i, configFileFolder, m_TextureArrowDownHover);
                else if (configFile.Properties[i] == "borders")
                {
                    Borders borders;
                    if (Internal.ExtractBorders(configFile.Values [i], out borders))
                        Borders = borders;
                }
                else if (configFile.Properties[i] == "scrollbar")
                {
                    if ((configFile.Values[i].Length < 3) || (configFile.Values[i][0] != '"') || (configFile.Values[i][configFile.Values[i].Length-1] != '"'))
                        throw new Exception("Failed to parse value for Scrollbar in section ChatBox in " + m_LoadedConfigFile + ".");

                    // load the scrollbar
                    m_ListBox.SetScrollbar (configFileFolder + (configFile.Values[i]).Substring(1, configFile.Values[i].Length - 2));
                }
                else
                    Internal.Output("TGUI warning: Unrecognized property '" + configFile.Properties[i]
                                    + "' in section ComboBox in " + m_LoadedConfigFile + ".");
            }

            // Make sure the required textures were loaded
            if ((m_TextureArrowUpNormal.texture == null) || (m_TextureArrowDownNormal.texture == null))
                throw new Exception("Not all needed images were loaded for the combo box. Is the ComboBox section in " + m_LoadedConfigFile + " complete?");

            // Check if optional textures were loaded
            if ((m_TextureArrowUpHover.texture != null) && (m_TextureArrowDownHover.texture != null))
            {
                m_WidgetPhase |= (byte)WidgetPhase.Hover;
            }
        }
Пример #12
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Loads the widget
        /// </summary>
        ///
        /// <param name="configFileFilename">Filename of the config file.
        /// The config file must contain a SpinButton section with the needed information.</param>
        ///
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public SpinButton(string configFileFilename)
        {
            m_LoadedConfigFile = Global.ResourcePath + configFileFilename;

            // Parse the config file
            ConfigFile configFile = new ConfigFile (m_LoadedConfigFile, "SpinButton");

            // Find the folder that contains the config file
            string configFileFolder = m_LoadedConfigFile.Substring(0, m_LoadedConfigFile.LastIndexOfAny(new char[] {'/', '\\'}) + 1);

            // Loop over all properties
            for (int i = 0; i < configFile.Properties.Count; ++i)
            {
                if (configFile.Properties[i] == "separatehoverimage")
                    m_SeparateHoverImage = configFile.ReadBool(i);
                else if (configFile.Properties[i] == "arrowupnormalimage")
                    configFile.ReadTexture(i, configFileFolder, m_TextureArrowUpNormal);
                else if (configFile.Properties[i] == "arrowuphoverimage")
                    configFile.ReadTexture(i, configFileFolder, m_TextureArrowUpHover);
                else if (configFile.Properties[i] == "arrowdownnormalimage")
                    configFile.ReadTexture(i, configFileFolder, m_TextureArrowDownNormal);
                else if (configFile.Properties[i] == "arrowdownhoverimage")
                    configFile.ReadTexture(i, configFileFolder, m_TextureArrowDownHover);
                else
                    Internal.Output("TGUI warning: Unrecognized property '" + configFile.Properties[i]
                                    + "' in section SpinButton in " + m_LoadedConfigFile + ".");
            }

            // Make sure the required textures were loaded
            if ((m_TextureArrowUpNormal.texture != null) && (m_TextureArrowDownNormal.texture != null))
            {
                m_Size = new Vector2f(m_TextureArrowUpNormal.Size.X, m_TextureArrowUpNormal.Size.Y + m_TextureArrowDownNormal.Size.Y);
            }
            else
            {
                throw new Exception("Not all needed images were loaded for the spin button. Is the SpinButton section in " + m_LoadedConfigFile + " complete?");
            }

            // Check if optional textures were loaded
            if ((m_TextureArrowUpHover.texture != null) && (m_TextureArrowDownHover.texture != null))
            {
                m_WidgetPhase |= (byte)WidgetPhase.Hover;
            }
        }
Пример #13
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Loads the widget
        /// </summary>
        ///
        /// <param name="configFileFilename">Filename of the config file.
        /// The config file must contain a Tab section with the needed information.</param>
        ///
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public Tab(string configFileFilename)
        {
            m_LoadedConfigFile = Global.ResourcePath + configFileFilename;

            // Parse the config file
            ConfigFile configFile = new ConfigFile (m_LoadedConfigFile, "Tab");

            // Find the folder that contains the config file
            string configFileFolder = m_LoadedConfigFile.Substring(0, m_LoadedConfigFile.LastIndexOfAny(new char[] {'/', '\\'}) + 1);

            // Loop over all properties
            for (int i = 0; i < configFile.Properties.Count; ++i)
            {
                if (configFile.Properties[i] == "separateselectedimage")
                    m_SeparateSelectedImage = configFile.ReadBool(i);
                else if (configFile.Properties[i] == "textcolor")
                    m_TextColor = configFile.ReadColor(i);
                else if (configFile.Properties[i] == "selectedtextcolor")
                    m_SelectedTextColor = configFile.ReadColor(i);
                else if (configFile.Properties[i] == "distancetoside")
                    DistanceToSide = Convert.ToUInt32(configFile.Values [i]);
                else if (configFile.Properties[i] == "normalimage")
                {
                    configFile.ReadTexture (i, configFileFolder, m_TextureNormal_M);
                    m_SplitImage = false;
                }
                else if (configFile.Properties[i] == "selectedimage")
                    configFile.ReadTexture (i, configFileFolder, m_TextureSelected_M);
                else if (configFile.Properties[i] == "normalimage_l")
                    configFile.ReadTexture (i, configFileFolder, m_TextureNormal_L);
                else if (configFile.Properties[i] == "normalimage_m")
                {
                    configFile.ReadTexture(i, configFileFolder, m_TextureNormal_M);
                    m_SplitImage = true;
                }
                else if (configFile.Properties[i] == "normalimage_r")
                    configFile.ReadTexture(i, configFileFolder, m_TextureNormal_R);
                else if (configFile.Properties[i] == "selectedimage_l")
                    configFile.ReadTexture (i, configFileFolder, m_TextureSelected_L);
                else if (configFile.Properties[i] == "selectedimage_m")
                    configFile.ReadTexture(i, configFileFolder, m_TextureSelected_M);
                else if (configFile.Properties[i] == "selectedimage_r")
                    configFile.ReadTexture(i, configFileFolder, m_TextureSelected_R);
                else
                    Internal.Output("TGUI warning: Unrecognized property '" + configFile.Properties[i]
                                    + "' in section Tab in " + m_LoadedConfigFile + ".");
            }

            // Check if the image is split
            if (m_SplitImage)
            {
                // Make sure the required textures were loaded
                if ((m_TextureNormal_L.texture != null) && (m_TextureNormal_M.texture != null) && (m_TextureNormal_R.texture != null))
                {
                    m_TabHeight = (uint)m_TextureNormal_M.Size.Y;

                    m_TextureNormal_M.texture.texture.Repeated = true;
                }
                else
                    throw new Exception("Not all needed images were loaded for the tab. Is the Tab section in " + m_LoadedConfigFile + " complete?");

                // Check if optional textures were loaded
                if ((m_TextureSelected_L.texture != null) && (m_TextureSelected_M.texture != null) && (m_TextureSelected_R.texture != null))
                {
                    m_WidgetPhase |= (byte)WidgetPhase.Selected;

                    m_TextureSelected_M.texture.texture.Repeated = true;
                }
            }
            else // The image isn't split
            {
                // Make sure the required texture was loaded
                if (m_TextureNormal_M.texture != null)
                {
                    m_TabHeight = (uint)m_TextureNormal_M.Size.Y;
                }
                else
                    throw new Exception("NormalImage wasn't loaded. Is the Tab section in " + m_LoadedConfigFile + " complete?");

                // Check if optional textures were loaded
                if (m_TextureSelected_M.texture != null)
                {
                    m_WidgetPhase |= (byte)WidgetPhase.Selected;
                }
            }

            // Recalculate the text size when auto sizing
            if (m_TextSize == 0)
                TextSize = 0;
        }
Пример #14
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Loads the widget
        /// </summary>
        ///
        /// <param name="configFileFilename">Filename of the config file.
        /// The config file must contain a Tab section with the needed information.</param>
        ///
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public Tab(string configFileFilename)
        {
            m_LoadedConfigFile = Global.ResourcePath + configFileFilename;

            // Parse the config file
            ConfigFile configFile = new ConfigFile(m_LoadedConfigFile, "Tab");

            // Find the folder that contains the config file
            string configFileFolder = m_LoadedConfigFile.Substring(0, m_LoadedConfigFile.LastIndexOfAny(new char[] { '/', '\\' }) + 1);

            // Loop over all properties
            for (int i = 0; i < configFile.Properties.Count; ++i)
            {
                if (configFile.Properties[i] == "separateselectedimage")
                {
                    m_SeparateSelectedImage = configFile.ReadBool(i);
                }
                else if (configFile.Properties[i] == "textcolor")
                {
                    m_TextColor = configFile.ReadColor(i);
                }
                else if (configFile.Properties[i] == "selectedtextcolor")
                {
                    m_SelectedTextColor = configFile.ReadColor(i);
                }
                else if (configFile.Properties[i] == "distancetoside")
                {
                    DistanceToSide = Convert.ToUInt32(configFile.Values [i]);
                }
                else if (configFile.Properties[i] == "normalimage")
                {
                    configFile.ReadTexture(i, configFileFolder, m_TextureNormal_M);
                    m_SplitImage = false;
                }
                else if (configFile.Properties[i] == "selectedimage")
                {
                    configFile.ReadTexture(i, configFileFolder, m_TextureSelected_M);
                }
                else if (configFile.Properties[i] == "normalimage_l")
                {
                    configFile.ReadTexture(i, configFileFolder, m_TextureNormal_L);
                }
                else if (configFile.Properties[i] == "normalimage_m")
                {
                    configFile.ReadTexture(i, configFileFolder, m_TextureNormal_M);
                    m_SplitImage = true;
                }
                else if (configFile.Properties[i] == "normalimage_r")
                {
                    configFile.ReadTexture(i, configFileFolder, m_TextureNormal_R);
                }
                else if (configFile.Properties[i] == "selectedimage_l")
                {
                    configFile.ReadTexture(i, configFileFolder, m_TextureSelected_L);
                }
                else if (configFile.Properties[i] == "selectedimage_m")
                {
                    configFile.ReadTexture(i, configFileFolder, m_TextureSelected_M);
                }
                else if (configFile.Properties[i] == "selectedimage_r")
                {
                    configFile.ReadTexture(i, configFileFolder, m_TextureSelected_R);
                }
                else
                {
                    Internal.Output("TGUI warning: Unrecognized property '" + configFile.Properties[i]
                                    + "' in section Tab in " + m_LoadedConfigFile + ".");
                }
            }

            // Check if the image is split
            if (m_SplitImage)
            {
                // Make sure the required textures were loaded
                if ((m_TextureNormal_L.texture != null) && (m_TextureNormal_M.texture != null) && (m_TextureNormal_R.texture != null))
                {
                    m_TabHeight = (uint)m_TextureNormal_M.Size.Y;

                    m_TextureNormal_M.texture.texture.Repeated = true;
                }
                else
                {
                    throw new Exception("Not all needed images were loaded for the tab. Is the Tab section in " + m_LoadedConfigFile + " complete?");
                }

                // Check if optional textures were loaded
                if ((m_TextureSelected_L.texture != null) && (m_TextureSelected_M.texture != null) && (m_TextureSelected_R.texture != null))
                {
                    m_WidgetPhase |= (byte)WidgetPhase.Selected;

                    m_TextureSelected_M.texture.texture.Repeated = true;
                }
            }
            else // The image isn't split
            {
                // Make sure the required texture was loaded
                if (m_TextureNormal_M.texture != null)
                {
                    m_TabHeight = (uint)m_TextureNormal_M.Size.Y;
                }
                else
                {
                    throw new Exception("NormalImage wasn't loaded. Is the Tab section in " + m_LoadedConfigFile + " complete?");
                }

                // Check if optional textures were loaded
                if (m_TextureSelected_M.texture != null)
                {
                    m_WidgetPhase |= (byte)WidgetPhase.Selected;
                }
            }

            // Recalculate the text size when auto sizing
            if (m_TextSize == 0)
            {
                TextSize = 0;
            }
        }
Пример #15
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Loads the widget
        /// </summary>
        ///
        /// <param name="configFileFilename">Filename of the config file.
        /// The config file must contain a Button section with the needed information.</param>
        ///
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public Button(string configFileFilename)
        {
            m_LoadedConfigFile = Global.ResourcePath + configFileFilename;

            // Parse the config file
            ConfigFile configFile = new ConfigFile(m_LoadedConfigFile, "Button");

            // Find the folder that contains the config file
            string configFileFolder = m_LoadedConfigFile.Substring(0, m_LoadedConfigFile.LastIndexOfAny(new char[] { '/', '\\' }) + 1);

            // Loop over all properties
            for (int i = 0; i < configFile.Properties.Count; ++i)
            {
                if (configFile.Properties[i] == "separatehoverimage")
                {
                    m_SeparateHoverImage = configFile.ReadBool(i);
                }
                else if (configFile.Properties[i] == "textcolor")
                {
                    m_Text.Color = configFile.ReadColor(i);
                }
                else if (configFile.Properties[i] == "normalimage")
                {
                    configFile.ReadTexture(i, configFileFolder, m_TextureNormal_M);
                    m_SplitImage = false;
                }
                else if (configFile.Properties[i] == "hoverimage")
                {
                    configFile.ReadTexture(i, configFileFolder, m_TextureHover_M);
                }
                else if (configFile.Properties[i] == "downimage")
                {
                    configFile.ReadTexture(i, configFileFolder, m_TextureDown_M);
                }
                else if (configFile.Properties[i] == "focusedimage")
                {
                    configFile.ReadTexture(i, configFileFolder, m_TextureFocused_M);
                }
                else if (configFile.Properties[i] == "normalimage_l")
                {
                    configFile.ReadTexture(i, configFileFolder, m_TextureNormal_L);
                }
                else if (configFile.Properties[i] == "normalimage_m")
                {
                    configFile.ReadTexture(i, configFileFolder, m_TextureNormal_M);
                    m_SplitImage = true;
                }
                else if (configFile.Properties[i] == "normalimage_r")
                {
                    configFile.ReadTexture(i, configFileFolder, m_TextureNormal_R);
                }
                else if (configFile.Properties[i] == "hoverimage_l")
                {
                    configFile.ReadTexture(i, configFileFolder, m_TextureHover_L);
                }
                else if (configFile.Properties[i] == "hoverimage_m")
                {
                    configFile.ReadTexture(i, configFileFolder, m_TextureHover_M);
                }
                else if (configFile.Properties[i] == "hoverimage_r")
                {
                    configFile.ReadTexture(i, configFileFolder, m_TextureHover_R);
                }
                else if (configFile.Properties[i] == "downimage_l")
                {
                    configFile.ReadTexture(i, configFileFolder, m_TextureDown_L);
                }
                else if (configFile.Properties[i] == "downimage_m")
                {
                    configFile.ReadTexture(i, configFileFolder, m_TextureDown_M);
                }
                else if (configFile.Properties[i] == "downimage_r")
                {
                    configFile.ReadTexture(i, configFileFolder, m_TextureDown_R);
                }
                else if (configFile.Properties[i] == "focusedimage_l")
                {
                    configFile.ReadTexture(i, configFileFolder, m_TextureFocused_L);
                }
                else if (configFile.Properties[i] == "focusedimage_m")
                {
                    configFile.ReadTexture(i, configFileFolder, m_TextureFocused_M);
                }
                else if (configFile.Properties[i] == "focusedimage_r")
                {
                    configFile.ReadTexture(i, configFileFolder, m_TextureFocused_R);
                }
                else
                {
                    Internal.Output("TGUI warning: Unrecognized property '" + configFile.Properties[i]
                                    + "' in section Button in " + m_LoadedConfigFile + ".");
                }
            }

            // Check if the image is split
            if (m_SplitImage)
            {
                // Make sure the required textures were loaded
                if ((m_TextureNormal_L.texture != null) && (m_TextureNormal_M.texture != null) && (m_TextureNormal_R.texture != null))
                {
                    Size = new Vector2f(m_TextureNormal_L.Size.X + m_TextureNormal_M.Size.X + m_TextureNormal_R.Size.X,
                                        m_TextureNormal_M.Size.Y);

                    m_TextureNormal_M.texture.texture.Repeated = true;
                }
                else
                {
                    throw new Exception("Not all needed images were loaded for the button. Is the Button section in "
                                        + m_LoadedConfigFile + " complete?");
                }

                // Check if optional textures were loaded
                if ((m_TextureFocused_L.texture != null) && (m_TextureFocused_M.texture != null) && (m_TextureFocused_R.texture != null))
                {
                    m_AllowFocus   = true;
                    m_WidgetPhase |= (byte)WidgetPhase.Focused;

                    m_TextureFocused_M.texture.texture.Repeated = true;
                }
                if ((m_TextureHover_L.texture != null) && (m_TextureHover_M.texture != null) && (m_TextureHover_R.texture != null))
                {
                    m_WidgetPhase |= (byte)WidgetPhase.Hover;

                    m_TextureHover_M.texture.texture.Repeated = true;
                }
                if ((m_TextureDown_L.texture != null) && (m_TextureDown_M.texture != null) && (m_TextureDown_R.texture != null))
                {
                    m_WidgetPhase |= (byte)WidgetPhase.MouseDown;

                    m_TextureDown_M.texture.texture.Repeated = true;
                }
            }
            else // The image isn't split
            {
                // Make sure the required texture was loaded
                if (m_TextureNormal_M.texture != null)
                {
                    Size = new Vector2f(m_TextureNormal_M.Size.X, m_TextureNormal_M.Size.Y);
                }
                else
                {
                    throw new Exception("NormalImage property wasn't loaded. Is the Button section in " + m_LoadedConfigFile + " complete?");
                }

                // Check if optional textures were loaded
                if (m_TextureFocused_M.texture != null)
                {
                    m_AllowFocus   = true;
                    m_WidgetPhase |= (byte)WidgetPhase.Focused;
                }
                if (m_TextureHover_M.texture != null)
                {
                    m_WidgetPhase |= (byte)WidgetPhase.Hover;
                }
                if (m_TextureDown_M.texture != null)
                {
                    m_WidgetPhase |= (byte)WidgetPhase.MouseDown;
                }
            }
        }
Пример #16
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Loads the widget
        /// </summary>
        ///
        /// <param name="configFileFilename">Filename of the config file.
        /// The config file must contain a Button section with the needed information.</param>
        ///
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public Button(string configFileFilename)
        {
            m_LoadedConfigFile = Global.ResourcePath + configFileFilename;

            // Parse the config file
            ConfigFile configFile = new ConfigFile (m_LoadedConfigFile, "Button");

            // Find the folder that contains the config file
            string configFileFolder = m_LoadedConfigFile.Substring(0, m_LoadedConfigFile.LastIndexOfAny(new char[] {'/', '\\'}) + 1);

            // Loop over all properties
            for (int i = 0; i < configFile.Properties.Count; ++i)
            {
                if (configFile.Properties[i] == "separatehoverimage")
                    m_SeparateHoverImage = configFile.ReadBool(i);
                else if (configFile.Properties[i] == "textcolor")
                    m_Text.Color = configFile.ReadColor(i);
                else if (configFile.Properties[i] == "normalimage")
                {
                    configFile.ReadTexture (i, configFileFolder, m_TextureNormal_M);
                    m_SplitImage = false;
                }
                else if (configFile.Properties[i] == "hoverimage")
                    configFile.ReadTexture(i, configFileFolder, m_TextureHover_M);
                else if (configFile.Properties[i] == "downimage")
                    configFile.ReadTexture (i, configFileFolder, m_TextureDown_M);
                else if (configFile.Properties[i] == "focusedimage")
                    configFile.ReadTexture (i, configFileFolder, m_TextureFocused_M);
                else if (configFile.Properties[i] == "normalimage_l")
                    configFile.ReadTexture (i, configFileFolder, m_TextureNormal_L);
                else if (configFile.Properties[i] == "normalimage_m")
                {
                    configFile.ReadTexture(i, configFileFolder, m_TextureNormal_M);
                    m_SplitImage = true;
                }
                else if (configFile.Properties[i] == "normalimage_r")
                    configFile.ReadTexture(i, configFileFolder, m_TextureNormal_R);
                else if (configFile.Properties[i] == "hoverimage_l")
                    configFile.ReadTexture(i, configFileFolder, m_TextureHover_L);
                else if (configFile.Properties[i] == "hoverimage_m")
                    configFile.ReadTexture (i, configFileFolder, m_TextureHover_M);
                else if (configFile.Properties[i] == "hoverimage_r")
                    configFile.ReadTexture (i, configFileFolder, m_TextureHover_R);
                else if (configFile.Properties[i] == "downimage_l")
                    configFile.ReadTexture(i, configFileFolder, m_TextureDown_L);
                else if (configFile.Properties[i] == "downimage_m")
                    configFile.ReadTexture(i, configFileFolder, m_TextureDown_M);
                else if (configFile.Properties[i] == "downimage_r")
                    configFile.ReadTexture(i, configFileFolder, m_TextureDown_R);
                else if (configFile.Properties[i] == "focusedimage_l")
                    configFile.ReadTexture (i, configFileFolder, m_TextureFocused_L);
                else if (configFile.Properties[i] == "focusedimage_m")
                    configFile.ReadTexture(i, configFileFolder, m_TextureFocused_M);
                else if (configFile.Properties[i] == "focusedimage_r")
                    configFile.ReadTexture(i, configFileFolder, m_TextureFocused_R);
                else
                    Internal.Output("TGUI warning: Unrecognized property '" + configFile.Properties[i]
                                    + "' in section Button in " + m_LoadedConfigFile + ".");
            }

            // Check if the image is split
            if (m_SplitImage)
            {
                // Make sure the required textures were loaded
                if ((m_TextureNormal_L.texture != null) && (m_TextureNormal_M.texture != null) && (m_TextureNormal_R.texture != null))
                {
                    Size = new Vector2f(m_TextureNormal_L.Size.X + m_TextureNormal_M.Size.X + m_TextureNormal_R.Size.X,
                                        m_TextureNormal_M.Size.Y);

                    m_TextureNormal_M.texture.texture.Repeated = true;
                }
                else
                {
                    throw new Exception("Not all needed images were loaded for the button. Is the Button section in "
                                        + m_LoadedConfigFile + " complete?");
                }

                // Check if optional textures were loaded
                if ((m_TextureFocused_L.texture != null) && (m_TextureFocused_M.texture != null) && (m_TextureFocused_R.texture != null))
                {
                    m_AllowFocus = true;
                    m_WidgetPhase |= (byte)WidgetPhase.Focused;

                    m_TextureFocused_M.texture.texture.Repeated = true;
                }
                if ((m_TextureHover_L.texture != null) && (m_TextureHover_M.texture != null) && (m_TextureHover_R.texture != null))
                {
                    m_WidgetPhase |= (byte)WidgetPhase.Hover;

                    m_TextureHover_M.texture.texture.Repeated = true;
                }
                if ((m_TextureDown_L.texture != null) && (m_TextureDown_M.texture != null) && (m_TextureDown_R.texture != null))
                {
                    m_WidgetPhase |= (byte)WidgetPhase.MouseDown;

                    m_TextureDown_M.texture.texture.Repeated = true;
                }
            }
            else // The image isn't split
            {
                // Make sure the required texture was loaded
                if (m_TextureNormal_M.texture != null)
                {
                    Size = new Vector2f(m_TextureNormal_M.Size.X, m_TextureNormal_M.Size.Y);
                }
                else
                    throw new Exception("NormalImage property wasn't loaded. Is the Button section in " + m_LoadedConfigFile + " complete?");

                // Check if optional textures were loaded
                if (m_TextureFocused_M.texture != null)
                {
                    m_AllowFocus = true;
                    m_WidgetPhase |= (byte)WidgetPhase.Focused;
                }
                if (m_TextureHover_M.texture != null)
                {
                    m_WidgetPhase |= (byte)WidgetPhase.Hover;
                }
                if (m_TextureDown_M.texture != null)
                {
                    m_WidgetPhase |= (byte)WidgetPhase.MouseDown;
                }
            }
        }
Пример #17
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Loads the widget
        /// </summary>
        ///
        /// <param name="configFileFilename">Filename of the config file.
        /// The config file must contain a LoadingBar section with the needed information.</param>
        ///
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public LoadingBar(string configFileFilename)
        {
            m_LoadedConfigFile = Global.ResourcePath + configFileFilename;

            // Parse the config file
            ConfigFile configFile = new ConfigFile (m_LoadedConfigFile, "LoadingBar");

            // Find the folder that contains the config file
            string configFileFolder = m_LoadedConfigFile.Substring(0, m_LoadedConfigFile.LastIndexOfAny(new char[] {'/', '\\'}) + 1);

            // Loop over all properties
            for (int i = 0; i < configFile.Properties.Count; ++i)
            {
                if (configFile.Properties[i] == "backimage")
                {
                    configFile.ReadTexture (i, configFileFolder, m_TextureBack_M);
                    m_SplitImage = false;
                }
                else if (configFile.Properties[i] == "frontimage")
                    configFile.ReadTexture(i, configFileFolder, m_TextureFront_M);
                else if (configFile.Properties[i] == "backimage_l")
                    configFile.ReadTexture (i, configFileFolder, m_TextureBack_L);
                else if (configFile.Properties[i] == "backimage_m")
                {
                    configFile.ReadTexture(i, configFileFolder, m_TextureBack_M);
                    m_SplitImage = true;
                }
                else if (configFile.Properties[i] == "backimage_r")
                    configFile.ReadTexture(i, configFileFolder, m_TextureBack_R);
                else if (configFile.Properties[i] == "frontimage_l")
                    configFile.ReadTexture(i, configFileFolder, m_TextureFront_L);
                else if (configFile.Properties[i] == "frontimage_m")
                    configFile.ReadTexture (i, configFileFolder, m_TextureFront_M);
                else if (configFile.Properties[i] == "frontimage_r")
                    configFile.ReadTexture (i, configFileFolder, m_TextureFront_R);
                else if (configFile.Properties [i] == "textcolor")
                    TextColor = configFile.ReadColor (i);
                else if (configFile.Properties [i] == "textsize")
                    TextSize = Convert.ToUInt32(configFile.Values [i]);
                else
                    Internal.Output("TGUI warning: Unrecognized property '" + configFile.Properties[i]
                                    + "' in section LoadingBar in " + m_LoadedConfigFile + ".");
            }

            // Check if the image is split
            if (m_SplitImage)
            {
                // Make sure the required textures were loaded
                if ((m_TextureBack_L.texture != null) && (m_TextureBack_M.texture != null) && (m_TextureBack_R.texture != null)
                    && (m_TextureFront_L.texture != null) && (m_TextureFront_M.texture != null) && (m_TextureFront_R.texture != null))
                {
                    m_Size.X = (float)(m_TextureBack_L.Size.X + m_TextureBack_M.Size.X + m_TextureBack_R.Size.X);
                    m_Size.Y = (float)(m_TextureBack_M.Size.Y);

                    m_TextureBack_M.texture.texture.Repeated = true;
                    m_TextureFront_M.texture.texture.Repeated = true;
                }
                else
                    throw new Exception("Not all needed images were loaded for the loading bar. Is the LoadingBar section in " + m_LoadedConfigFile + " complete?");
            }
            else // The image isn't split
            {
                // Make sure the required textures were loaded
                if ((m_TextureBack_M.texture != null) && (m_TextureFront_M.texture != null))
                {
                    m_Size = new Vector2f(m_TextureBack_M.Size.X, m_TextureBack_M.Size.Y);
                }
                else
                    throw new Exception("TGUI error: Not all needed images were loaded for the loading bar. Is the LoadingBar section in " + m_LoadedConfigFile + " complete?");
            }

            // Calculate the size of the front image (the size of the part that will be drawn)
            RecalculateSize();
        }
Пример #18
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Loads the widget
        /// </summary>
        ///
        /// <param name="configFileFilename">Filename of the config file.
        /// The config file must contain a Knob section with the needed information.</param>
        ///
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public Knob(string configFileFilename)
        {
            m_DraggableWidget = true;

            m_loadedConfigFile = Global.ResourcePath + configFileFilename;

            // Parse the config file
            ConfigFile configFile = new ConfigFile (m_loadedConfigFile, "Knob");

            // Find the folder that contains the config file
            string configFileFolder = m_loadedConfigFile.Substring(0, m_loadedConfigFile.LastIndexOfAny(new char[] {'/', '\\'}) + 1);

            // Loop over all properties
            for (int i = 0; i < configFile.Properties.Count; ++i)
            {
                if (configFile.Properties[i] == "backgroundimage")
                    configFile.ReadTexture(i, configFileFolder, m_backgroundTexture);
                else if (configFile.Properties[i] == "foregroundimage")
                    configFile.ReadTexture(i, configFileFolder, m_foregroundTexture);
                else if (configFile.Properties[i] == "imagerotation")
                    m_imageRotation = (float)Convert.ToDouble(configFile.Values[i]);
                else
                    Internal.Output("TGUI warning: Unrecognized property '" + configFile.Properties[i]
                                    + "' in section Knob in " + m_loadedConfigFile + ".");
            }

            // Make sure the required textures were loaded
            if ((m_backgroundTexture.texture != null) && (m_foregroundTexture.texture != null))
            {
                // Rotate the image
                m_foregroundTexture.sprite.Origin = new Vector2f(m_foregroundTexture.Size.X / 2.0f, m_foregroundTexture.Size.Y / 2.0f);
                m_foregroundTexture.sprite.Rotation = m_startRotation - m_imageRotation;

                m_foregroundTexture.sprite.Position = new Vector2f(m_backgroundTexture.Size.X / 2.0f, m_backgroundTexture.Size.Y / 2.0f);

                Size = new Vector2f(m_backgroundTexture.Size.X, m_backgroundTexture.Size.Y);
            }
            else
            {
                throw new Exception("Not all needed images were loaded for the knob. Is the Knob section in " + m_loadedConfigFile + " complete?");
            }
        }
Пример #19
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Loads the widget
        /// </summary>
        ///
        /// <param name="configFileFilename">Filename of the config file.
        /// The config file must contain a Scrollbar section with the needed information.</param>
        ///
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public Scrollbar(string configFileFilename)
        {
            m_DraggableWidget = true;

            m_LoadedConfigFile = Global.ResourcePath + configFileFilename;

            // Parse the config file
            ConfigFile configFile = new ConfigFile (m_LoadedConfigFile, "Scrollbar");

            // Find the folder that contains the config file
            string configFileFolder = m_LoadedConfigFile.Substring(0, m_LoadedConfigFile.LastIndexOfAny(new char[] {'/', '\\'}) + 1);

            // Loop over all properties
            for (int i = 0; i < configFile.Properties.Count; ++i)
            {
                if (configFile.Properties[i] == "separatehoverimage")
                    m_SeparateHoverImage = configFile.ReadBool(i);
                else if (configFile.Properties[i] == "verticalscroll")
                {
                    m_VerticalScroll = configFile.ReadBool(i);
                    m_VerticalImage = m_VerticalScroll;
                }
                else if (configFile.Properties[i] == "tracknormalimage")
                {
                    configFile.ReadTexture (i, configFileFolder, m_TextureTrackNormal_M);
                    m_SplitImage = false;
                }
                else if (configFile.Properties[i] == "trackhoverimage")
                    configFile.ReadTexture(i, configFileFolder, m_TextureTrackHover_M);
                else if (configFile.Properties[i] == "thumbnormalimage")
                    configFile.ReadTexture(i, configFileFolder, m_TextureThumbNormal);
                else if (configFile.Properties[i] == "thumbhoverimage")
                    configFile.ReadTexture(i, configFileFolder, m_TextureThumbHover);
                else if (configFile.Properties[i] == "arrowupnormalimage")
                    configFile.ReadTexture(i, configFileFolder, m_TextureArrowUpNormal);
                else if (configFile.Properties[i] == "arrowuphoverimage")
                    configFile.ReadTexture(i, configFileFolder, m_TextureArrowUpHover);
                else if (configFile.Properties[i] == "arrowdownnormalimage")
                    configFile.ReadTexture(i, configFileFolder, m_TextureArrowDownNormal);
                else if (configFile.Properties[i] == "arrowdownhoverimage")
                    configFile.ReadTexture(i, configFileFolder, m_TextureArrowDownHover);
                else if (configFile.Properties[i] == "tracknormalimage_l")
                    configFile.ReadTexture (i, configFileFolder, m_TextureTrackNormal_L);
                else if (configFile.Properties[i] == "tracknormalimage_m")
                {
                    configFile.ReadTexture(i, configFileFolder, m_TextureTrackNormal_M);
                    m_SplitImage = true;
                }
                else if (configFile.Properties[i] == "tracknormalimage_r")
                    configFile.ReadTexture(i, configFileFolder, m_TextureTrackNormal_R);
                else if (configFile.Properties[i] == "trackhoverimage_l")
                    configFile.ReadTexture(i, configFileFolder, m_TextureTrackHover_L);
                else if (configFile.Properties[i] == "trackhoverimage_m")
                    configFile.ReadTexture (i, configFileFolder, m_TextureTrackHover_M);
                else if (configFile.Properties[i] == "trackhoverimage_r")
                    configFile.ReadTexture (i, configFileFolder, m_TextureTrackHover_R);
                else
                    Internal.Output("TGUI warning: Unrecognized property '" + configFile.Properties[i]
                                    + "' in section Scrollbar in " + m_LoadedConfigFile + ".");
            }

            // Check if the image is split
            if (m_SplitImage)
            {
                 throw new Exception("SplitImage is not yet supported yet in Scrollbar.");
            /*
                // Make sure the required textures were loaded
                if ((m_TextureTrackNormal_L.texture != null) && (m_TextureTrackNormal_M.texture != null) && (m_TextureTrackNormal_R.texture != null)
                    && (m_TextureThumbNormal.texture != null) && (m_TextureArrowUpNormal.texture != null) && (m_TextureArrowDownNormal.texture != null))
                {
                    // Set the size of the scrollbar
                    if (m_VerticalImage)
                        Size = new Vector2f((m_TextureTrackNormal_M.Size.X), (float)(m_TextureTrackNormal_L.Size.Y + m_TextureTrackNormal_M.Size.Y + m_TextureTrackNormal_R.Size.Y));
                    else
                        Size = new Vector2f((m_TextureTrackNormal_L.Size.X + m_TextureTrackNormal_M.Size.X + m_TextureTrackNormal_R.Size.X), (float)(m_TextureTrackNormal_M.Size.Y));

                    // Set the thumb size
                    m_ThumbSize = new Vector2f(m_TextureThumbNormal.Size.X, m_TextureThumbNormal.Size.Y);
                }
                else
                    throw new Exception("Not all needed images were loaded for the scrollbar. Is the Scrollbar section in " + m_LoadedConfigFile + " complete?");

                // Check if optional textures were loaded
                if ((m_TextureTrackHover_L.texture != null) && (m_TextureTrackHover_M.texture != null) && (m_TextureTrackHover_R.texture != null)
                    && (m_TextureThumbHover.texture != null) && (m_TextureArrowUpHover.texture != null) && (m_TextureArrowDownHover.texture != null))
                {
                    m_WidgetPhase |= (byte)WidgetPhase.Hover;
                }
            */
            }
            else // The image isn't split
            {
                // Make sure the required textures were loaded
                if ((m_TextureTrackNormal_M.texture != null) && (m_TextureThumbNormal.texture != null)
                    && (m_TextureArrowUpNormal.texture != null) && (m_TextureArrowDownNormal.texture != null))
                {
                    // Set the size of the scrollbar
                    Size = new Vector2f(m_TextureTrackNormal_M.Size.X, m_TextureTrackNormal_M.Size.Y);
                }
                else
                    throw new Exception("TGUI error: Not all needed images were loaded for the scrollbar. Is the Scrollbar section in " + m_LoadedConfigFile + " complete?");

                // Check if optional textures were loaded
                if ((m_TextureTrackHover_M.texture != null) && (m_TextureThumbHover.texture != null)
                    && (m_TextureArrowUpHover.texture != null) && (m_TextureArrowDownHover.texture != null))
                {
                    m_WidgetPhase |= (byte)WidgetPhase.Hover;
                }
            }
        }