internal bool HasToolbar; //small caption, maybe no splitter etc /// <summary> /// This ctor is used at startup, when adding from XML. /// </summary> internal _Panel(AuDockPanel manager, _Split parentSplit, XElement x, _Tab parentTab = null) : base(manager, parentSplit) { var name = x.Attr("name"); var c = manager._initControls[name]; _manager._aPanel.Add(this); this.Content = c; Debug.Assert(c.Name == name); this.Name = name; this.ParentTab = parentTab; if (c is ToolStrip ts) { _InitToolstrip(ts); } else if (x.HasAttr("doc")) { this.HasDocument = true; // c.AccessibleRole = AccessibleRole.Document; //no, its child is DOCUMENT //} else { // c.AccessibleRole = AccessibleRole.Pane; } c.AccessibleRole = AccessibleRole.Pane; this.InitDockStateFromXML(x); }
void OnGUI() { if (UI.buttonStyle == null) { UI.InitButtonStyle(); } if (GUI.Button(new Rect(Screen.width - 35, 5, 30, 30), "R", UI.buttonStyle)) { GlobalStatsTB.ResetAll(); Application.LoadLevel(Application.loadedLevelName); } GUIStyle style = new GUIStyle(); style.fontSize = 20; style.fontStyle = FontStyle.Bold; style.normal.textColor = Color.black; style.alignment = TextAnchor.UpperRight; GUI.Label(new Rect(0 + 2, 5 + 2, Screen.width - 45, 50), "Point: " + playerPoint, style); style.normal.textColor = UI.colorH; GUI.Label(new Rect(0, 5, Screen.width - 45, 50), "Point: " + playerPoint, style); if (GUI.Button(new Rect(Screen.width - 65, Screen.height - 65, 60, 60), "Start\nBattle", UI.buttonStyle)) { LoadNextScene(); } if (GUI.Button(new Rect(5, Screen.height - 65, 60, 60), "Main\nMenu", UI.buttonStyle)) { if (mainMenu != "") { Application.LoadLevel(mainMenu); } else { Debug.Log("Menu scene name not specified"); } } if (tab == _Tab.Unit) { if (GUI.Button(new Rect(Screen.width / 2 - 45 - 3, Screen.height - 35 - 3, 86, 36), "Unit", UI.buttonStyle)) { tab = _Tab.Unit; } if (GUI.Button(new Rect(Screen.width / 2 + 45, Screen.height - 35, 80, 30), "Perk", UI.buttonStyle)) { tab = _Tab.Perk; } uiUnit.DrawUnitMenu(); } else { if (GUI.Button(new Rect(Screen.width / 2 - 45, Screen.height - 35, 80, 30), "Unit", UI.buttonStyle)) { tab = _Tab.Unit; } if (GUI.Button(new Rect(Screen.width / 2 + 45 - 3, Screen.height - 35 - 3, 86, 36), "Perk", UI.buttonStyle)) { tab = _Tab.Perk; } uiPerk.DrawPerkMenu(true); } }
void OnGUI() { if (window == null) { Init(); } int startX = 0; int startY = 0; if (GUI.Button(new Rect(10, 10, 100, 30), "New Armor")) { EditorDBManager.AddNewArmorType(); } if (GUI.Button(new Rect(120, 10, 100, 30), "New Damage")) { EditorDBManager.AddNewDamageType(); } List <DamageType> damageTypeList = EditorDBManager.GetDamageTypeList(); List <ArmorType> armorTypeList = EditorDBManager.GetArmorTypeList(); Rect visibleRect = new Rect(10, 50, window.position.width - 20, 185); Rect contentRect = new Rect(10, 50, 118 + damageTypeList.Count * 105, 5 + (armorTypeList.Count + 1) * 25); GUI.Box(visibleRect, ""); scrollPos = GUI.BeginScrollView(visibleRect, scrollPos, contentRect); startY = 60; startX = 20; for (int i = 0; i < damageTypeList.Count; i++) { DamageType dmgType = damageTypeList[i]; if (selectedID == i && tab == _Tab.Damage) { GUI.color = new Color(0, 1, 1, 1); } if (GUI.Button(new Rect(startX += 105, startY, 100, 20), dmgType.name)) { selectedID = i; tab = _Tab.Damage; delete = false; GUI.FocusControl(""); } GUI.color = Color.white; } startY = 60; for (int i = 0; i < armorTypeList.Count; i++) { startX = 20; ArmorType armorType = armorTypeList[i]; if (selectedID == i && tab == _Tab.Armor) { GUI.color = new Color(0, 1, 1, 1); } if (GUI.Button(new Rect(startX, startY += 25, 100, 20), armorType.name)) { selectedID = i; tab = _Tab.Armor; delete = false; GUI.FocusControl(""); } GUI.color = Color.white; if (armorType.modifiers.Count != damageTypeList.Count) { while (armorType.modifiers.Count < damageTypeList.Count) { armorType.modifiers.Add(1); } while (armorType.modifiers.Count > damageTypeList.Count) { armorType.modifiers.RemoveAt(armorType.modifiers.Count - 1); } EditorDBManager.SetDirtyDamageArmor(); } startX += 110; for (int j = 0; j < damageTypeList.Count; j++) { armorType.modifiers[j] = EditorGUI.FloatField(new Rect(startX, startY, 90, 20), armorType.modifiers[j]); startX += 105; } } GUI.EndScrollView(); startX = 10; startY = 250; if (selectedID >= 0) { DAType daInstance = null; if (tab == _Tab.Damage) { selectedID = Mathf.Min(selectedID, damageTypeList.Count - 1); daInstance = damageTypeList[selectedID]; } if (tab == _Tab.Armor) { selectedID = Mathf.Min(selectedID, armorTypeList.Count - 1); daInstance = armorTypeList[selectedID]; } GUI.Label(new Rect(startX, startY, 200, 17), "Name:"); daInstance.name = EditorGUI.TextField(new Rect(startX + 80, startY, 150, 17), daInstance.name); GUIStyle styleL = new GUIStyle(GUI.skin.textArea); styleL.wordWrap = true; styleL.clipping = TextClipping.Clip; styleL.alignment = TextAnchor.UpperLeft; EditorGUI.LabelField(new Rect(startX, startY += 25, 150, 17), "Description: "); daInstance.desp = EditorGUI.TextArea(new Rect(startX, startY += 17, window.position.width - 20, 50), daInstance.desp, styleL); string label = ""; if (tab == _Tab.Damage) { for (int i = 0; i < armorTypeList.Count; i++) { label += " - cause " + (armorTypeList[i].modifiers[selectedID] * 100).ToString("f0") + "% damage to " + armorTypeList[i].name + "\n"; } } if (tab == _Tab.Armor) { for (int i = 0; i < damageTypeList.Count; i++) { label += " - take " + (armorTypeList[selectedID].modifiers[i] * 100).ToString("f0") + "% damage from " + damageTypeList[i].name + "\n"; } } GUI.Label(new Rect(startX, startY += 60, window.position.width - 20, 100), label); startX = 300; startY = 250; if (!delete) { if (GUI.Button(new Rect(startX, startY, 80, 20), "delete")) { delete = true; } } else if (delete) { if (GUI.Button(new Rect(startX, startY, 80, 20), "cancel")) { delete = false; } GUI.color = Color.red; if (GUI.Button(new Rect(startX += 90, startY, 80, 20), "confirm")) { if (tab == _Tab.Damage) { EditorDBManager.RemoveDamageType(selectedID); } if (tab == _Tab.Armor) { EditorDBManager.RemoveArmorType(selectedID); } selectedID = -1; } GUI.color = Color.white; } } if (GUI.changed) { EditorDBManager.SetDirtyDamageArmor(); } }
/// <summary> /// Docks this _Panel or _Tab in an existing or new _Tab or _Split. /// If need, creates new _Tab or _Split in gcTarget place and adds gcTarget and this to it. Else reorders if need. /// This can be a new _Panel, with null ParentSplit and ParentTab, dock state not Docked. /// </summary> /// <param name="gcTarget">New sibling _Panel (side can be any) or sibling _Tab (when side is SplitX) or parent _Tab (when side is TabX).</param> /// <param name="side">Specifies whether to add on a _Tab or _Split, and at which side of gcTarget.</param> internal void DockBy(_ContentNode gcTarget, _DockHow side) { var gpThis = this as _Panel; var gtThisParent = gpThis?.ParentTab; var gsThisParent = this.ParentSplit; var gsTargetParent = gcTarget.ParentSplit; if (side == _DockHow.TabBefore || side == _DockHow.TabAfter) { var gpTarget = gcTarget as _Panel; _Tab gtTargetParent = (gpTarget != null) ? gpTarget.ParentTab : gcTarget as _Tab; bool after = side == _DockHow.TabAfter; bool sameTargetTab = false; if (gtTargetParent != null) { gtTargetParent.AddOrReorderItem(gpThis, gpTarget, after); if (gtThisParent == gtTargetParent) { sameTargetTab = true; } } else { var gtNew = new _Tab(_manager, gsTargetParent, after ? gpTarget : gpThis, after ? gpThis : gpTarget); gsTargetParent.ReplaceChild(gpTarget, gtNew); gtNew.Bounds = gpTarget.Bounds; gtNew.CaptionAt = gpTarget.CaptionAt; } if (!sameTargetTab) { this.ParentSplit = gsTargetParent; if (gtThisParent != null) { gtThisParent.OnItemRemoved(gpThis); } else { gsThisParent?.OnChildRemoved(this); } } } else { if (gcTarget.IsTabbedPanel) { gcTarget = (gcTarget as _Panel).ParentTab; } bool after = side == _DockHow.SplitRight || side == _DockHow.SplitBelow; bool verticalSplit = side == _DockHow.SplitLeft || side == _DockHow.SplitRight; if (gsTargetParent == gsThisParent && gtThisParent == null) { //just change vertical/horizontal or/and swap with sibling gsThisParent.RepositionChild(this, verticalSplit, after); } else { var gsNew = new _Split(_manager, gsTargetParent, after ? gcTarget : this, after ? this : gcTarget, verticalSplit); gsTargetParent.ReplaceChild(gcTarget, gsNew); gsNew.Bounds = gcTarget.Bounds; if (gtThisParent != null) { gpThis.ParentTab = null; gtThisParent.OnItemRemoved(gpThis); } else { gsThisParent?.OnChildRemoved(this); } } } SetDockState(_DockState.Docked, false); }
internal void SetDockState(_DockState state, bool onStartDrag = false) { //AOutput.Write(this, Name); var gp = this as _Panel; if (state == _DockState.LastVisible) { if (!this.IsHidden) { if (this.IsTabbedPanel) { gp.ParentTab.SetDockState(_DockState.LastVisible); if (this.IsDocked) { gp.ParentTab.SetActiveItem(gp); } } if (this.ParentControl is _Float gf) { ((AWnd)gf).EnsureInScreen(); } return; } state = this.SavedVisibleDockState; } var prevState = this.DockState; if (state == prevState) { return; } if (this.ParentSplit == null && state == _DockState.Docked) //new panel { ADialog.ShowInfo("How to dock floating panels", "Alt+drag and drop.", owner: _manager); return; } bool isTab = gp == null; _Tab gt = null, gtParent = null; if (isTab) { gt = this as _Tab; } else { gtParent = gp.ParentTab; } this.DockState = state; //get RECT for floating now, because later this.ParentControl will change and even may be destroyed RECT rect = default; if (state == _DockState.Floating) { if (!onStartDrag && !SavedFloatingBounds.IsEmptyRect()) { if (SavedFloatingBounds.X == int.MinValue) //specified only width and height { var mp = AMouse.XY; rect = new RECT(mp.x - 15, mp.y - 15, SavedFloatingBounds.Width, SavedFloatingBounds.Height); } else { rect = SavedFloatingBounds; } rect.EnsureInScreen(); } else if (this.ParentSplit != null) { rect = this.RectangleInScreen; AWnd.More.WindowRectFromClientRect(ref rect, WS.POPUP | WS.THICKFRAME, WS2.TOOLWINDOW); } else //new panel, empty bounds { var mp = AMouse.XY; rect = new RECT(mp.x - 15, mp.y - 15, 300, 150); rect.EnsureInScreen(); } } var panels = isTab ? gt.Items.FindAll(v => v.IsDocked) : new List <_Panel>(1) { gp }; //(isTab ? gt.ActiveItem : gp)?.Content.Hide(); var gtp = isTab ? gt.ActiveItem : gp; if (gtp != null) { if (state != _DockState.Docked && _manager.ZFocusControlOnUndockEtc != null && gtp.Content.ContainsFocus) { _manager.ZFocusControlOnUndockEtc.Focus(); } gtp.Content.Hide(); } Action postAction = null; switch (prevState) { case _DockState.Docked: if (gtParent != null) { gtParent.OnItemUndocked(gp, out postAction); } else { this.ParentSplit.OnChildUndocked(this); } _manager.Invalidate(this.Bounds, true); //some controls don't redraw properly, eg ToolStripTextBox break; case _DockState.Floating: //case _DockState.AutoHide: var f = this.ParentControl as _Float; var parent = (gtParent != null) ? gtParent.ParentControl : _manager; _parentControl = parent; foreach (var v in panels) { _ChangeParent(v, parent); } if (prevState == _DockState.Floating) { this.SavedFloatingBounds = f.Bounds; } f.Close(); break; } switch (state) { case _DockState.Docked: if (gtParent != null) { gtParent.OnItemDocked(gp); } else { this.ParentSplit.OnChildDocked(this); } break; case _DockState.Floating: var f = new _Float(_manager, this); this._parentControl = f; foreach (var v in panels) { _ChangeParent(v, f); } f.Bounds = rect; f.Show(_manager.TopLevelControl); break; //case _DockState.AutoHide: // break; case _DockState.Hidden: this.SavedVisibleDockState = prevState; break; } if (state != _DockState.Hidden) { (isTab ? gt.ActiveItem : gp)?.Content.Show(); } postAction?.Invoke(); //_manager.Invalidate(true); if (prevState != _DockState.Hidden) { _manager._OnMouseLeave_Common(this.ParentControl); //calls _UnhiliteTabButton and _HideTooltip } }
public void DrawUnitMenu() { GUIStyle style = new GUIStyle(); style.fontSize = 20; style.fontStyle = FontStyle.Bold; style.normal.textColor = UI.colorH; style.alignment = TextAnchor.UpperCenter; int winWidth = 385; int winHeight = 550; int startX = Screen.width / 2 - 30; int startY = Screen.height / 2 - winHeight / 2; int rowLimit = 5; int row = 0; int column = 0; for (int i = 0; i < 3; i++) { GUI.Box(new Rect(startX, startY, winWidth, winHeight), ""); } GUI.Label(new Rect(startX, startY + 10, winWidth, winHeight), "Unit Selection", style); style.fontSize = 16; style.alignment = TextAnchor.UpperLeft; GUI.Label(new Rect(startX + 10, startY + 45, winWidth, winHeight), "Available Units:", style); startX += 10; startY += 65; int scrollLength = (int)(Mathf.Ceil(availableUnits.Count / rowLimit + 1) * 70); if (availableUnits.Count % rowLimit == 0) { scrollLength -= 70; } Rect viewRect = new Rect(startX, startY, winWidth - 20, 280); Rect scrollRect = new Rect(startX, startY, winWidth - 50, scrollLength); GUI.Box(viewRect, ""); scrollPosition1 = GUI.BeginScrollView(viewRect, scrollPosition1, scrollRect); startX += 5; startY += 5; for (int i = 0; i < availableUnits.Count; i++) { if (tab == _Tab.Available && selectedID == i) { if (GUI.Button(new Rect(startX + column * 70 - 3, startY + row * 70 - 3, 66, 66), availableUnits[i].icon)) { } } else { if (GUI.Button(new Rect(startX + column * 70, startY + row * 70, 60, 60), availableUnits[i].icon)) { tab = _Tab.Available; selectedID = i; } } column += 1; if (column == 5) { row += 1; column = 0; } } GUI.EndScrollView(); startY += 280; if (tab == _Tab.Available) { if (GUI.Button(new Rect(startX + 280, startY, 80, 30), "Select", UI.buttonStyle)) { UnitTB unit = availableUnits[selectedID]; if (UISetup.playerPoint >= unit.pointCost) { UISetup.UpdatePoints(-unit.pointCost); selectedUnits.Add(unit); } } } else if (tab == _Tab.Selected) { if (GUI.Button(new Rect(startX + 280, startY, 80, 30), "Remove", UI.buttonStyle)) { UISetup.UpdatePoints(selectedUnits[selectedID].pointCost); selectedUnits.RemoveAt(selectedID); if (selectedUnits.Count > 0) { selectedID = Mathf.Max(selectedID - 1, 0); } else { selectedID = 0; tab = _Tab.Available; } } } style.fontSize = 16; GUI.Label(new Rect(startX, startY + 15, winWidth, winHeight), "Selected Units:", style); startX -= 5; startY += 35; scrollLength = (int)(Mathf.Ceil(selectedUnits.Count / rowLimit + 1) * 70); if (selectedUnits.Count % rowLimit == 0) { scrollLength -= 70; } viewRect = new Rect(startX, startY, winWidth - 20, 140); scrollRect = new Rect(startX, startY, winWidth - 50, scrollLength); GUI.Box(viewRect, ""); scrollPosition2 = GUI.BeginScrollView(viewRect, scrollPosition2, scrollRect); row = 0; column = 0; startX += 5; startY += 5; for (int i = 0; i < selectedUnits.Count; i++) { if (tab == _Tab.Selected && selectedID == i) { if (GUI.Button(new Rect(startX + column * 70 - 3, startY + row * 70 - 3, 66, 66), selectedUnits[i].icon)) { } } else { if (GUI.Button(new Rect(startX + column * 70, startY + row * 70, 60, 60), selectedUnits[i].icon)) { tab = _Tab.Selected; selectedID = i; } } column += 1; if (column == 5) { row += 1; column = 0; } } GUI.EndScrollView(); UnitTB selectedUnit = null; if (tab == _Tab.Available) { selectedUnit = availableUnits[selectedID]; } else if (tab == _Tab.Selected) { selectedUnit = selectedUnits[selectedID]; } DrawSelectedUnit(selectedUnit); }
void OnGUI(){ if(window==null) Init(); int startX=0; int startY=0; if(GUI.Button(new Rect(10, 10, 100, 30), "New Armor")) EditorDBManager.AddNewArmorType(); if(GUI.Button(new Rect(120, 10, 100, 30), "New Damage")) EditorDBManager.AddNewDamageType(); List<DamageType> damageTypeList=EditorDBManager.GetDamageTypeList(); List<ArmorType> armorTypeList=EditorDBManager.GetArmorTypeList(); Rect visibleRect=new Rect(10, 50, window.position.width-20, 185); Rect contentRect=new Rect(10, 50, 118+damageTypeList.Count*105, 5+(armorTypeList.Count+1)*25); GUI.Box(visibleRect, ""); scrollPos = GUI.BeginScrollView(visibleRect, scrollPos, contentRect); startY=60; startX=20; for(int i=0; i<damageTypeList.Count; i++){ DamageType dmgType=damageTypeList[i]; if(selectedID==i && tab==_Tab.Damage) GUI.color=new Color(0, 1, 1, 1); if(GUI.Button(new Rect(startX+=105, startY, 100, 20), dmgType.name)){ selectedID=i; tab=_Tab.Damage; delete=false; GUI.FocusControl (""); } GUI.color=Color.white; } startY=60; for(int i=0; i<armorTypeList.Count; i++){ startX=20; ArmorType armorType=armorTypeList[i]; if(selectedID==i && tab==_Tab.Armor) GUI.color=new Color(0, 1, 1, 1); if(GUI.Button(new Rect(startX, startY+=25, 100, 20), armorType.name)){ selectedID=i; tab=_Tab.Armor; delete=false; GUI.FocusControl (""); } GUI.color=Color.white; if(armorType.modifiers.Count!=damageTypeList.Count){ while(armorType.modifiers.Count<damageTypeList.Count) armorType.modifiers.Add(1); while(armorType.modifiers.Count>damageTypeList.Count) armorType.modifiers.RemoveAt(armorType.modifiers.Count-1); EditorDBManager.SetDirtyDamageArmor(); } startX+=110; for(int j=0; j<damageTypeList.Count; j++){ armorType.modifiers[j]=EditorGUI.FloatField(new Rect(startX, startY, 90, 20), armorType.modifiers[j]); startX+=105; } } GUI.EndScrollView(); startX=10; startY=250; if(selectedID>=0){ DAType daInstance=null; if(tab==_Tab.Damage){ selectedID=Mathf.Min(selectedID, damageTypeList.Count-1); daInstance=damageTypeList[selectedID]; } if(tab==_Tab.Armor){ selectedID=Mathf.Min(selectedID, armorTypeList.Count-1); daInstance=armorTypeList[selectedID]; } GUI.Label(new Rect(startX, startY, 200, 17), "Name:"); daInstance.name=EditorGUI.TextField(new Rect(startX+80, startY, 150, 17), daInstance.name); GUIStyle styleL=new GUIStyle(GUI.skin.textArea); styleL.wordWrap=true; styleL.clipping=TextClipping.Clip; styleL.alignment=TextAnchor.UpperLeft; EditorGUI.LabelField(new Rect(startX, startY+=25, 150, 17), "Description: "); daInstance.desp=EditorGUI.TextArea(new Rect(startX, startY+=17, window.position.width-20, 50), daInstance.desp, styleL); string label=""; if(tab==_Tab.Damage) { for(int i=0; i<armorTypeList.Count; i++){ label+=" - cause "+(armorTypeList[i].modifiers[selectedID]*100).ToString("f0")+"% damage to "+armorTypeList[i].name+"\n"; } } if(tab==_Tab.Armor){ for(int i=0; i<damageTypeList.Count; i++){ label+=" - take "+(armorTypeList[selectedID].modifiers[i]*100).ToString("f0")+"% damage from "+damageTypeList[i].name+"\n"; } } GUI.Label(new Rect(startX, startY+=60, window.position.width-20, 100), label); startX=300; startY=250; if(!delete){ if(GUI.Button(new Rect(startX, startY, 80, 20), "delete")) delete=true; } else if(delete){ if(GUI.Button(new Rect(startX, startY, 80, 20), "cancel")) delete=false; GUI.color=Color.red; if(GUI.Button(new Rect(startX+=90, startY, 80, 20), "confirm")){ if(tab==_Tab.Damage) EditorDBManager.RemoveDamageType(selectedID); if(tab==_Tab.Armor) EditorDBManager.RemoveArmorType(selectedID); selectedID=-1; } GUI.color=Color.white; } } if(GUI.changed) EditorDBManager.SetDirtyDamageArmor(); }
public void DrawUnitMenu() { GUIStyle style=new GUIStyle(); style.fontSize=20; style.fontStyle=FontStyle.Bold; style.normal.textColor=UI.colorH; style.alignment=TextAnchor.UpperCenter; int winWidth=385; int winHeight=550; int startX=Screen.width/2-30; int startY=Screen.height/2-winHeight/2; int rowLimit=5; int row=0; int column=0; for(int i=0; i<3; i++) GUI.Box(new Rect(startX, startY, winWidth, winHeight), ""); GUI.Label(new Rect(startX, startY+10, winWidth, winHeight), "Unit Selection", style); style.fontSize=16; style.alignment=TextAnchor.UpperLeft; GUI.Label(new Rect(startX+10, startY+45, winWidth, winHeight), "Available Units:", style); startX+=10; startY+=65; int scrollLength=(int)(Mathf.Ceil(availableUnits.Count/rowLimit+1)*70); if(availableUnits.Count%rowLimit==0) scrollLength-=70; Rect viewRect=new Rect(startX, startY, winWidth-20, 280); Rect scrollRect=new Rect(startX, startY, winWidth-50, scrollLength); GUI.Box(viewRect, ""); scrollPosition1 = GUI.BeginScrollView (viewRect, scrollPosition1, scrollRect); startX+=5; startY+=5; for(int i=0; i<availableUnits.Count; i++){ if(tab==_Tab.Available && selectedID==i){ if(GUI.Button(new Rect(startX+column*70-3, startY+row*70-3, 66, 66), availableUnits[i].icon)){ } } else{ if(GUI.Button(new Rect(startX+column*70, startY+row*70, 60, 60), availableUnits[i].icon)){ tab=_Tab.Available; selectedID=i; } } column+=1; if(column==5){ row+=1; column=0; } } GUI.EndScrollView(); startY+=280; if(tab==_Tab.Available){ if(GUI.Button(new Rect(startX+280, startY, 80, 30), "Select", UI.buttonStyle)){ UnitTB unit=availableUnits[selectedID]; if(UISetup.playerPoint>=unit.pointCost){ UISetup.UpdatePoints(-unit.pointCost); selectedUnits.Add(unit); } } } else if(tab==_Tab.Selected){ if(GUI.Button(new Rect(startX+280, startY, 80, 30), "Remove", UI.buttonStyle)){ UISetup.UpdatePoints(selectedUnits[selectedID].pointCost); selectedUnits.RemoveAt(selectedID); if(selectedUnits.Count>0){ selectedID=Mathf.Max(selectedID-1, 0); } else{ selectedID=0; tab=_Tab.Available; } } } style.fontSize=16; GUI.Label(new Rect(startX, startY+15, winWidth, winHeight), "Selected Units:", style); startX-=5; startY+=35; scrollLength=(int)(Mathf.Ceil(selectedUnits.Count/rowLimit+1)*70); if(selectedUnits.Count%rowLimit==0) scrollLength-=70; viewRect=new Rect(startX, startY, winWidth-20, 140); scrollRect=new Rect(startX, startY, winWidth-50, scrollLength); GUI.Box(viewRect, ""); scrollPosition2 = GUI.BeginScrollView (viewRect, scrollPosition2, scrollRect); row=0; column=0; startX+=5; startY+=5; for(int i=0; i<selectedUnits.Count; i++){ if(tab==_Tab.Selected && selectedID==i){ if(GUI.Button(new Rect(startX+column*70-3, startY+row*70-3, 66, 66), selectedUnits[i].icon)){ } } else{ if(GUI.Button(new Rect(startX+column*70, startY+row*70, 60, 60), selectedUnits[i].icon)){ tab=_Tab.Selected; selectedID=i; } } column+=1; if(column==5){ row+=1; column=0; } } GUI.EndScrollView(); UnitTB selectedUnit=null; if(tab==_Tab.Available) selectedUnit=availableUnits[selectedID]; else if(tab==_Tab.Selected) selectedUnit=selectedUnits[selectedID]; DrawSelectedUnit(selectedUnit); }
int _width; //used if !_isFraction; if _isWidth1, it is Child1 width, else Child2 with /// <summary> /// This ctor is used at startup, when adding from XML. /// </summary> internal _Split(AuDockPanel manager, _Split parentSplit, XElement x) : base(manager, parentSplit) { manager._aSplit.Add(this); if (!x.HasAttr("hor")) { IsVerticalSplit = true; } int k = x.Attr("splitter", -1); if (k < 0 || k > 20) { k = _splitterWidth; } this.SplitterWidth = k; //SHOULDDO: use DPI-dependent units, not pixels. Especially if form size depends on DPI. if (!(_isFraction = x.Attr(out _fraction, "f")) && !(_isWidth1 = x.Attr(out _width, "w1"))) { _width = x.Attr("w2", 1); } foreach (var xe in x.Elements()) { _Node gn = null; switch (xe.Name.LocalName) { case "panel": gn = new _Panel(manager, this, xe); break; case "split": gn = new _Split(manager, this, xe); break; case "tab": gn = new _Tab(manager, this, xe); break; case "dummy": gn = new _DummyNode(_manager, this); break; default: continue; } if (gn.IsDocked) { _dockedChildCount++; } if (Child1 == null) { Child1 = gn; } else { Child2 = gn; break; } } if (Child2 == null) { throw new Exception(); } if (_dockedChildCount == 0) { this.DockState = _DockState.Hidden; } }
void OnGUI() { if(UI.buttonStyle==null){ UI.InitButtonStyle(); } if(GUI.Button(new Rect(Screen.width-35, 5, 30, 30), "R", UI.buttonStyle)){ GlobalStatsTB.ResetAll(); Application.LoadLevel(Application.loadedLevelName); } GUIStyle style=new GUIStyle(); style.fontSize=20; style.fontStyle=FontStyle.Bold; style.normal.textColor=Color.black; style.alignment=TextAnchor.UpperRight; GUI.Label(new Rect(0+2, 5+2, Screen.width-45, 50), "Point: "+playerPoint, style); style.normal.textColor=UI.colorH; GUI.Label(new Rect(0, 5, Screen.width-45, 50), "Point: "+playerPoint, style); if(GUI.Button(new Rect(Screen.width-65, Screen.height-65, 60, 60), "Start\nBattle", UI.buttonStyle)){ LoadNextScene(); } if(GUI.Button(new Rect(5, Screen.height-65, 60, 60), "Main\nMenu", UI.buttonStyle)){ if(mainMenu!="") Application.LoadLevel(mainMenu); else Debug.Log("Menu scene name not specified"); } if(tab==_Tab.Unit){ if(GUI.Button(new Rect(Screen.width/2-45-3, Screen.height-35-3, 86, 36), "Unit", UI.buttonStyle)){ tab=_Tab.Unit; } if(GUI.Button(new Rect(Screen.width/2+45, Screen.height-35, 80, 30), "Perk", UI.buttonStyle)){ tab=_Tab.Perk; } uiUnit.DrawUnitMenu(); } else{ if(GUI.Button(new Rect(Screen.width/2-45, Screen.height-35, 80, 30), "Unit", UI.buttonStyle)){ tab=_Tab.Unit; } if(GUI.Button(new Rect(Screen.width/2+45-3, Screen.height-35-3, 86, 36), "Perk", UI.buttonStyle)){ tab=_Tab.Perk; } uiPerk.DrawPerkMenu(true); } }