public Image(string name, IGuiStyle style, IGuiSize size) : base(name, size, style) { mTexture = null; }
public Button BuildTabButton(XmlNode buttonNode) { string name = BuildName(buttonNode); IGuiSize size = BuildSize(buttonNode); IGuiStyle activatedStyle = GetNamedStyle(buttonNode, "activatedStyle", typeof(TabButton)); IGuiStyle deactivatedStyle = GetNamedStyle(buttonNode, "deactivatedStyle", typeof(TabButton)); Texture image = null; if (buttonNode.Attributes["image"] != null) { image = BuildTexture(buttonNode, "image"); } IGuiFrame frame = null; XmlNode frameNode = buttonNode.SelectSingleNode("Frame"); XmlNode scrollFrameNode = buttonNode.SelectSingleNode("ScrollFrame"); if (frameNode != null) { frame = BuildFrame(frameNode); } if (scrollFrameNode != null) { frame = BuildScrollFrame(scrollFrameNode); } if (frame == null) { throw new GuiConstructionException("Cannot create TabButton (" + name + "), cannot find frame child node."); } return(new TabButton(name, size, activatedStyle, deactivatedStyle, image, frame)); }
public Image(string name, IGuiStyle style, Texture texture) : base(name, new FixedSize(texture.width, texture.height), style) { mTexture = texture; }
public TopLevel(string name, IGuiSize size, IGuiPosition position, IGuiManager manager, KeyValuePair <IGuiFrame, IGuiPosition> mainFrame, IGuiStyle style) : base(name, size, style) { if (manager == null) { throw new ArgumentNullException("manager"); } if (position == null) { throw new ArgumentNullException("position"); } mPosition = position; mWindowId = UnityWindowIdManager.RequestNewWindowId(); mManager = manager; mManager.RegisterTopLevel(this, position); mMainFrame = mainFrame; if (mMainFrame.Value == null) { mMainFrame = new KeyValuePair <IGuiFrame, IGuiPosition>(mainFrame.Key, new MainFrameSizePosition()); } if (mMainFrame.Key != null) { mMainFrame.Key.Parent = this; } }
public IGuiStyle GetNamedStyle(XmlNode widgetWithStyle, string styleName, System.Type defaultWidgetType) { IGuiStyle result = null; if (mStyles == null) { ConstructAllStyles(); } XmlAttribute styleAttribute = widgetWithStyle.Attributes[styleName]; if (styleAttribute != null) { if (mStyles.ContainsKey(styleAttribute.InnerText)) { result = mStyles[styleAttribute.InnerText]; } } else { result = mManager.GetDefaultStyle(defaultWidgetType); } return(result); }
public Window(string name, IGuiSize size, IGuiManager manager, IGuiStyle style) : this(name, size, manager, new KeyValuePair <IGuiFrame, IGuiPosition>(null, null), new KeyValuePair <IGuiFrame, IGuiPosition>(null, null), style) { }
protected override Window BuildWindow(XmlNode windowNode) { string name = BuildName(windowNode); IGuiSize size = BuildSize(windowNode); IGuiFrame mainFrame = null; IGuiPosition mainFramePosition = null; XmlNode mainFrameNode = windowNode.SelectSingleNode("MainFrame"); if (mainFrameNode != null) { mainFramePosition = BuildPosition(mainFrameNode); mainFrame = BuildFrame(mainFrameNode); if (mainFrame == null) { throw new GuiConstructionException("Found MainFrame node in Window (" + name + "), but was unable to construct it."); } } IGuiStyle style = GetStyle(windowNode, typeof(Window)); return(new DockableEditorTab ( name, size, mManager, new KeyValuePair <IGuiFrame, IGuiPosition> ( mainFrame, mainFramePosition ), style )); }
public StyleTypeNode(StyleTypeNode copy) { mRegisteredType = copy.RegisteredType; mDefaultStyle = copy.DefaultStyle; mChildren = new List <StyleTypeNode>(copy.Children); mParent = copy.Parent; }
private IGuiStyle FindDefaultStyle(StyleTypeNode root, System.Type elementType) { IGuiStyle result = null; if (root != null) { if (root.RegisteredType == elementType) { result = root.DefaultStyle; } else { foreach (StyleTypeNode child in root.Children) { if (elementType.IsSubclassOf(child.RegisteredType)) { result = FindDefaultStyle(child, elementType); } else if (elementType == child.RegisteredType) { result = child.DefaultStyle; } } if (result == null) { result = root.DefaultStyle; } } } return(result); }
public ProgressView(string name, IGuiSize size, IGuiFrame progressFrame, IGuiPosition progressFramePosition, IGuiStyle progressLabelsStyle, IGuiFrame contextFrame, IGuiPosition contextFramePosition) : base(name, size, null) { if (progressFrame == null) { throw new ArgumentNullException("progressFrame"); } if (progressFramePosition == null) { throw new ArgumentNullException("progressFramePosition"); } if (contextFrame == null) { throw new ArgumentNullException("contextFrame"); } if (contextFramePosition == null) { throw new ArgumentNullException("contextFramePosition"); } mProgressFrame = new Pair <IGuiFrame, IGuiPosition>(progressFrame, progressFramePosition); mContextFrame = new Pair <IGuiFrame, IGuiPosition>(contextFrame, contextFramePosition); mProgressLabelStyle = progressLabelsStyle; mProgressFrame.First.Parent = this; mContextFrame.First.Parent = this; }
private static void InsertStyleDefault(StyleTypeNode root, System.Type type, IGuiStyle style) { if (type.IsSubclassOf(root.RegisteredType)) { // Construct the branch to this type StyleTypeNode newBranchRoot = root.Find(type); if (newBranchRoot == null) { newBranchRoot = new StyleTypeNode(type, style); // Create empty elements up a known point in the tree StyleTypeNode ancestor = FindClosestAncestor(root, type); while (newBranchRoot.RegisteredType.BaseType != ancestor.RegisteredType) { StyleTypeNode oldBranchRoot = new StyleTypeNode(newBranchRoot); newBranchRoot = new StyleTypeNode(oldBranchRoot.RegisteredType.BaseType, null); oldBranchRoot.Parent = newBranchRoot; newBranchRoot.Children.Add(oldBranchRoot); } newBranchRoot.Parent = ancestor; ancestor.Children.Add(newBranchRoot); } } else { throw new ArgumentException("Argument type(" + type.Name + ") must be a subclass of root.RegisteredType(" + root.RegisteredType.Name + ")"); } }
public Button(string name, IGuiSize size, IGuiStyle style, Texture image) : this(name, size, style, image, null) { }
public Button(string name, IGuiSize size, IGuiStyle style, string text) : this(name, size, style, null, text) { }
public Window(string name, IGuiSize size, IGuiPosition position, IGuiManager manager, KeyValuePair <IGuiFrame, IGuiPosition> mainFrame, KeyValuePair <IGuiFrame, IGuiPosition> headerFrame, DragBehavior isDraggable, IGuiStyle style) : base(name, size, position, manager, mainFrame, style) { mLogger = manager.Logger; mDraggable = isDraggable; mHeaderFrame = headerFrame; if (mHeaderFrame.Key != null) { mHeaderFrame.Key.Parent = this; } if (mHeaderFrame.Value == null) { mHeaderFrame = new KeyValuePair <IGuiFrame, IGuiPosition> ( mHeaderFrame.Key, new HeaderFrameSizePosition() ); } }
public override void Draw(IGuiContainer container, Vector2 position) { if (Event.current.type == EventType.mouseDrag) { foreach (Action <Vector2> callback in mMouseDragCallbacks) { callback(Event.current.mousePosition); } } GUIContent buttonContent = BuildButtonContent(); Vector2 size = this.Size; Rect coords = new Rect(position.x, position.y, size.x, size.y); bool buttonClicked = false; IGuiStyle style = this.GetButtonStyle(); if (style != null) { GUIStyle style2 = style.GenerateUnityGuiStyle(this.Enabled); buttonClicked = GUI.RepeatButton(coords, buttonContent, style2); } else { buttonClicked = GUI.RepeatButton(coords, buttonContent); } if (buttonClicked && this.Enabled) { OnPressed(); } }
public GuiRange(string name, IGuiStyle style, IGuiSize size) : base(name, size, style) { mBounds = new Rangef(0.0f, 1.0f); Percent = 0.0f; }
public PushButton(string name, IGuiSize size, IGuiStyle style, Texture image, string text) : base(name, size, style, image, text) { }
public DockableEditorTab(string name, IGuiSize size, IGuiManager manager, KeyValuePair <IGuiFrame, IGuiPosition> mainFrame, IGuiStyle style) : base(name, size, manager, mainFrame, new KeyValuePair <IGuiFrame, IGuiPosition>(null, null), style) { }
public Label(string name, IGuiSize size, IGuiStyle style, string text) : base(name, size, style) { mText = text; }
public Window(string name, IGuiSize size, IGuiManager manager, KeyValuePair <IGuiFrame, IGuiPosition> mainFrame, KeyValuePair <IGuiFrame, IGuiPosition> headerFrame, IGuiStyle style) : this(name, size, manager, mainFrame, headerFrame, Window.DefaultDragBehavior, style) { }
public Image(string name, IGuiStyle style, IGuiSize size, Texture2D texture) : base(name, size, style) { // TODO: Nobody destroys this texture that we just created. This essentially creates a leak here. mTexture = TextureUtility.ResizeTexture(texture, (int)size.GetSize(this).x, (int)size.GetSize(this).y); }
public SelectableFrame(string name, IGuiSize size, IEnumerable <KeyValuePair <IWidget, IGuiPosition> > widgets, IGuiStyle unselectedStyle, IGuiStyle selectedStyle) : base(name, size, widgets, unselectedStyle) { mSelectedStyle = selectedStyle; mUnselectedStyle = unselectedStyle; }
public TabButton(string name, IGuiSize size, IGuiStyle activatedStyle, IGuiStyle deactivatedStyle, Texture image, IGuiFrame frame) : base(name, size, activatedStyle, deactivatedStyle, image) { mFrame = frame; }
public Label BuildLabel(XmlNode labelNode) { string name = BuildName(labelNode); IGuiSize size = BuildSize(labelNode); IGuiStyle style = GetStyle(labelNode, typeof(Label)); string text = BuildText(labelNode); return(new Label(name, size, style, text)); }
public Button(string name, IGuiSize size, IGuiStyle style, Texture image, string text) : base(name, size, style) { mImage = image; mText = text; }
public Window(string name, IGuiSize size, IGuiManager manager, KeyValuePair <IGuiFrame, IGuiPosition> mainFrame, KeyValuePair <IGuiFrame, IGuiPosition> headerFrame, DragBehavior isDraggable, IGuiStyle style) : this(name, size, new FixedPosition(new Vector2(Screen.width * 0.5f, Screen.height * 0.5f)), manager, mainFrame, headerFrame, isDraggable, style) { }
public ScrollFrame(string name, IGuiSize size, IEnumerable <KeyValuePair <IWidget, IGuiPosition> > widgets, IGuiStyle frameStyle) : base(name, size, widgets, frameStyle) { AddModifyPositionCallback(delegate(Vector2 widgetPosition) { return(widgetPosition + mScrollOffset); }); }
public FashionGameGui() : base(GameFacade.Instance.RetrieveMediator <RuntimeGuiManager>(), FASHION_GUI_PATH) { mInput = GameFacade.Instance.RetrieveMediator <FashionGameInput>(); mScheduler = GameFacade.Instance.RetrieveMediator <SchedulerMediator>().Scheduler; this.MainGui.Showing = true; foreach (ITopLevel topLevel in AllGuis) { switch (topLevel.Name) { case "FashionGameGui": mMainWindow = (Window)topLevel; mMainWindow.Showing = true; break; case "FashionScoreGui": mScoreWindow = (Window)topLevel; mScoreWindow.Showing = true; break; } } mMainFrame = mMainWindow.SelectSingleElement <IGuiFrame>("MainFrame"); mClothingButtonPrototype = mMainFrame.SelectSingleElement <PushButton>("ButtonPrototype"); // Initialize the clothing stack slots uint clothingStacks = (uint)(mMainFrame.InternalSize.x / mClothingButtonPrototype.ExternalSize.x); for (uint i = 0; i < clothingStacks; ++i) { mActiveClothes.Add(new List <Pair <ClothingItem, PushButton> >()); } mMainFrame.RemoveChildWidget(mClothingButtonPrototype); mWaveLabel = mScoreWindow.SelectSingleElement <Label>("**/WaveLabel"); mWaveString = mWaveLabel.Text; mNextWaveButton = mScoreWindow.SelectSingleElement <Button>("**/NextWaveButton"); mNextWaveButton.Enabled = false; mLevelLabel = mScoreWindow.SelectSingleElement <Label>("**/LevelLabel"); mExperienceMeter = mScoreWindow.SelectSingleElement <ProgressIndicator>("**/ExperienceMeter"); mExperienceLabel = mScoreWindow.SelectSingleElement <Label>("**/ExperienceLabel"); mProgressStyle = GetNamedStyle("Progress"); mProgressCompleteStyle = GetNamedStyle("ProgressComplete"); mEnergyLabel = mScoreWindow.SelectSingleElement <Label>("**/EnergyLabel"); mEnergyTimerLabel = mScoreWindow.SelectSingleElement <Label>("**/EnergyTimerLabel"); mEnergyMeter = mScoreWindow.SelectSingleElement <ProgressIndicator>("**/EnergyMeter"); mTasks.Add(mScheduler.StartCoroutine(UpdateEnergyDisplay())); }
/** * /param[frameStyle] Can be null for an invisible GuiFrame * /param[widgets] All the widgets for this frame. The list of widgets can be a Dictionary if the ordering doesn't matter. If ordering is required (ex. if the widgets use IAutoLayouts), then pass an ordered IEnumerator (List or Array). */ public GuiFrame(string name, IGuiSize size, IEnumerable <KeyValuePair <IWidget, IGuiPosition> > widgets, IGuiStyle frameStyle) : base(name, size, frameStyle) { if (widgets == null) { throw new ArgumentNullException("widgets"); } mWidgets = new List <KeyValuePair <IWidget, IGuiPosition> >(widgets); RegisterChildrenWidgets(); }