private void LoadDefaultStylesFromFactory(XmlGuiFactory factory) { IEnumerable <IGuiStyle> styles = factory.ConstructAllStyles(); // Find the root style foreach (IGuiStyle style in styles) { if (style != null) { foreach (System.Type t in style.DefaultFor()) { if (t == typeof(GuiElement)) { mDefaultStylesRoot = new StyleTypeNode(t, style); break; } } if (mDefaultStylesRoot != null) { break; } } } if (mDefaultStylesRoot == null) { throw new Exception("Cannot load default styles, no default for GuiElement was defined."); } // Insert each style into the tree foreach (IGuiStyle style in styles) { if (style != null) { foreach (System.Type t in style.DefaultFor()) { if (t != typeof(GuiElement)) { // GuiElement should have already been inserted InsertStyleDefault(mDefaultStylesRoot, t, style); } } } } /* * // Debug.Log the loaded heiarchy of style defaults * StringBuilder sb = new StringBuilder("\n"); * foreach( string line in ListDefaults(mDefaultStylesRoot, 0) ) * { * sb.AppendLine(line); * } * Debug.Log(sb); */ }
public GuiController(IGuiManager manager, string guiPath) { if (manager == null) { throw new ArgumentNullException("manager"); } mManager = manager; if (guiPath == null) { throw new ArgumentNullException("guiPath"); } mPath = guiPath; XmlGuiFactory factory = new XmlGuiFactory(mPath, mManager); factory.RegisterOnBuildWidgetProcessor(delegate(IWidget newWidget) { if (newWidget is Button) { ((Button)newWidget).AddOnPressedAction(delegate() { GameFacade.Instance.SendNotification(GameFacade.PLAY_SOUND_BUTTON_PRESS); }); } }); mTopLevelElements = factory.ConstructAllElements(); foreach (IGuiStyle style in factory.ConstructAllStyles()) { if (style == null) { continue; } mStyles.Add(style.Name, style); } }
private void LoadDefaultStylesFromResources() { XmlGuiFactory factory = new XmlGuiFactory(mDefaultStylePath, this); LoadDefaultStylesFromFactory(factory); }
public void LoadDefaultStylesFromXml(XmlDocument styleData) { XmlGuiFactory factory = new XmlGuiFactory(styleData, this); LoadDefaultStylesFromFactory(factory); }