///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Loads the widget /// </summary> /// /// <param name="configFileFilename">Filename of the config file. /// The config file must contain a ChatBox section with the needed information.</param> /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public ChatBox(string configFileFilename) { m_DraggableWidget = true; m_LoadedConfigFile = Global.ResourcePath + configFileFilename; // Parse the config file ConfigFile configFile = new ConfigFile(m_LoadedConfigFile, "ChatBox"); // 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] == "backgroundcolor") { BackgroundColor = configFile.ReadColor(i); } else if (configFile.Properties[i] == "bordercolor") { BorderColor = configFile.ReadColor(i); } 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_Scroll = new Scrollbar(configFileFolder + (configFile.Values[i]).Substring(1, configFile.Values[i].Length - 2)); m_Scroll.VerticalScroll = true; m_Scroll.Size = new Vector2f(m_Scroll.Size.X, m_Panel.Size.Y); m_Scroll.LowValue = (int)(m_Panel.Size.Y); m_Scroll.Maximum = (int)m_FullTextHeight; } else { Internal.Output("TGUI warning: Unrecognized property '" + configFile.Properties[i] + "' in section ChatBox in " + m_LoadedConfigFile + "."); } } }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Loads the widget /// </summary> /// /// <param name="configFileFilename">Filename of the config file. /// The config file must contain a MessageBox section with the needed information.</param> /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public MessageBox(string configFileFilename) { Add(m_Label, "MessageBoxText"); m_Label.TextSize = m_TextSize; m_LoadedConfigFile = Global.ResourcePath + configFileFilename; // Parse the config file ConfigFile configFile = new ConfigFile(m_LoadedConfigFile, "MessageBox"); // Find the folder that contains the config file string configFileFolder = configFileFilename.Substring(0, configFileFilename.LastIndexOfAny(new char[] { '/', '\\' }) + 1); bool childWindowPropertyFound = false; bool buttonPropertyFound = false; // Loop over all properties for (int i = 0; i < configFile.Properties.Count; ++i) { if (configFile.Properties[i] == "textcolor") { m_Label.TextColor = configFile.ReadColor(i); } else if (configFile.Properties[i] == "childwindow") { 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 ChildWindow in section MessageBox in " + m_LoadedConfigFile + "."); } InternalLoad(configFileFolder + configFile.Values [i].Substring(1, configFile.Values [i].Length - 2)); childWindowPropertyFound = true; } else if (configFile.Properties[i] == "button") { 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 Button in section MessageBox in " + m_LoadedConfigFile + "."); } m_ButtonConfigFileFilename = configFileFolder + configFile.Values [i].Substring(1, configFile.Values [i].Length - 2); buttonPropertyFound = true; } else { Internal.Output("TGUI warning: Unrecognized property '" + configFile.Properties[i] + "' in section MessageBox in " + m_LoadedConfigFile + "."); } } if (!childWindowPropertyFound) { throw new Exception("TGUI error: Missing a ChildWindow property in section MessageBox in " + m_LoadedConfigFile + "."); } if (!buttonPropertyFound) { throw new Exception("TGUI error: Missing a Button property in section MessageBox in " + m_LoadedConfigFile + "."); } }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Loads the widget /// </summary> /// /// <param name="configFileFilename">Filename of the config file. /// The config file must contain a MenuBar section with the needed information.</param> /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public MenuBar(string configFileFilename) { m_LoadedConfigFile = Global.ResourcePath + configFileFilename; // Parse the config file ConfigFile configFile = new ConfigFile(m_LoadedConfigFile, "MenuBar"); // Loop over all properties for (int i = 0; i < configFile.Properties.Count; ++i) { 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] == "distancetoside") { DistanceToSide = Convert.ToUInt32(configFile.Values [i]); } else { Internal.Output("TGUI warning: Unrecognized property '" + configFile.Properties[i] + "' in section MenuBar in " + m_LoadedConfigFile + "."); } } }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// <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; } }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Loads the widget /// </summary> /// /// <param name="configFileFilename">Filename of the config file. /// The config file must contain a Label section with the needed information.</param> /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public Label(string configFileFilename) { m_Background.FillColor = new Color(0, 0, 0, 0); m_LoadedConfigFile = Global.ResourcePath + configFileFilename; // Parse the config file ConfigFile configFile = new ConfigFile(m_LoadedConfigFile, "Label"); // 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 { Internal.Output("TGUI warning: Unrecognized property '" + configFile.Properties[i] + "' in section Label in " + m_LoadedConfigFile + "."); } } }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Loads the widget /// </summary> /// /// <param name="configFileFilename">Filename of the config file. /// The config file must contain a ListBox section with the needed information.</param> /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public ListBox(string configFileFilename) { m_DraggableWidget = true; m_LoadedConfigFile = Global.ResourcePath + configFileFilename; // Parse the config file ConfigFile configFile = new ConfigFile (m_LoadedConfigFile, "ListBox"); // 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] == "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] == "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_Scroll = new Scrollbar(configFileFolder + (configFile.Values[i]).Substring(1, configFile.Values[i].Length - 2)); m_Scroll.VerticalScroll = true; m_Scroll.Size = new Vector2f(m_Scroll.Size.X, m_Size.Y); m_Scroll.LowValue = (int)(m_Size.Y); m_Scroll.Maximum = (int)(m_Items.Count * m_ItemHeight); } else Internal.Output("TGUI warning: Unrecognized property '" + configFile.Properties[i] + "' in section ListBox in " + m_LoadedConfigFile + "."); } }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// <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; } }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// <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; } }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// <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; }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// <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; }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// <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; } }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// <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; } } }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// <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; } } }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// <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(); }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// <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(); }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Loads the widget /// </summary> /// /// <param name="configFileFilename">Filename of the config file. /// The config file must contain a MessageBox section with the needed information.</param> /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public MessageBox(string configFileFilename) { Add(m_Label, "MessageBoxText"); m_Label.TextSize = m_TextSize; m_LoadedConfigFile = Global.ResourcePath + configFileFilename; // Parse the config file ConfigFile configFile = new ConfigFile (m_LoadedConfigFile, "MessageBox"); // Find the folder that contains the config file string configFileFolder = configFileFilename.Substring(0, configFileFilename.LastIndexOfAny(new char[] {'/', '\\'}) + 1); bool childWindowPropertyFound = false; bool buttonPropertyFound = false; // Loop over all properties for (int i = 0; i < configFile.Properties.Count; ++i) { if (configFile.Properties[i] == "textcolor") m_Label.TextColor = configFile.ReadColor(i); else if (configFile.Properties[i] == "childwindow") { 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 ChildWindow in section MessageBox in " + m_LoadedConfigFile + "."); InternalLoad (configFileFolder + configFile.Values [i].Substring (1, configFile.Values [i].Length - 2)); childWindowPropertyFound = true; } else if (configFile.Properties[i] == "button") { 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 Button in section MessageBox in " + m_LoadedConfigFile + "."); m_ButtonConfigFileFilename = configFileFolder + configFile.Values [i].Substring (1, configFile.Values [i].Length - 2); buttonPropertyFound = true; } else Internal.Output("TGUI warning: Unrecognized property '" + configFile.Properties[i] + "' in section MessageBox in " + m_LoadedConfigFile + "."); } if (!childWindowPropertyFound) throw new Exception("TGUI error: Missing a ChildWindow property in section MessageBox in " + m_LoadedConfigFile + "."); if (!buttonPropertyFound) throw new Exception("TGUI error: Missing a Button property in section MessageBox in " + m_LoadedConfigFile + "."); }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// <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); } }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Loads the widget /// </summary> /// /// <param name="configFileFilename">Filename of the config file. /// The config file must contain a MenuBar section with the needed information.</param> /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public MenuBar(string configFileFilename) { m_LoadedConfigFile = Global.ResourcePath + configFileFilename; // Parse the config file ConfigFile configFile = new ConfigFile (m_LoadedConfigFile, "MenuBar"); // Loop over all properties for (int i = 0; i < configFile.Properties.Count; ++i) { 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] == "distancetoside") DistanceToSide = Convert.ToUInt32(configFile.Values [i]); else Internal.Output("TGUI warning: Unrecognized property '" + configFile.Properties[i] + "' in section MenuBar in " + m_LoadedConfigFile + "."); } }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// <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; } }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Loads the widget /// </summary> /// /// <param name="configFileFilename">Filename of the config file. /// The config file must contain a Label section with the needed information.</param> /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public Label(string configFileFilename) { m_Background.FillColor = new Color (0, 0, 0, 0); m_LoadedConfigFile = Global.ResourcePath + configFileFilename; // Parse the config file ConfigFile configFile = new ConfigFile (m_LoadedConfigFile, "Label"); // 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 Internal.Output("TGUI warning: Unrecognized property '" + configFile.Properties[i] + "' in section Label in " + m_LoadedConfigFile + "."); } }