IEnumerator DisablePanelDeleyed(PanelInstance page) { //bool closedStateReached = false; bool wantToClose = true; page.isClosed = false; Animator anim = page.GetComponent <Animator> (); if (anim && anim.enabled) { while (!page.isClosed && wantToClose) { yield return(new WaitForEndOfFrame()); } if (wantToClose) { page.gameObject.SetActive(false); } } else { page.gameObject.SetActive(false); } }
// use this function when you need to open and close in the same way. public bool TogglePanelByName(string name) { PanelInstance page = null; for (int i = 0; i < Pages.Length; i++) { if (Pages [i].name == name) { page = Pages [i]; break; } } if (page == null) { return(false); } if (page.gameObject.activeSelf) { ClosePanel(page); return(false); } else { page.PanelBefore = currentPanel; currentPanel = page; CloseAllPanels(); page.OpenPanel(true); return(true); } }
//禁用面板 public IEnumerator DisablePanelDeleyed(PanelInstance page) { bool closedStateReached = false; bool wantToClose = true; Animator anim = page.gameObject.GetComponent <Animator>(); if (anim && anim.enabled) { while (!closedStateReached && wantToClose) { if (anim.isActiveAndEnabled && !anim.IsInTransition(0)) { closedStateReached = anim.GetCurrentAnimatorStateInfo(0).IsName("Closing"); } yield return(new WaitForEndOfFrame()); } if (wantToClose) { anim.gameObject.SetActive(false); } } else { page.gameObject.SetActive(false); } }
//通过名字打开面板 public void OpenPanelByName(string name) { PanelInstance page = null; for (int i = 0; i < Pages.Length; i++) { if (Pages[i].name == name) { page = Pages[i]; break; } } if (page == null) { return; } page.PanelBefore = currentPanel; currentPanel = page; CloseAllPanels(); Animator anim = page.GetComponent <Animator>(); if (anim && anim.isActiveAndEnabled) { anim.SetBool("Open", true); } page.gameObject.SetActive(true); }
public static T GetInstance <T>(PanelName name) where T : PanelInstance { PanelInstance i = prefabs[name]; if (!i.instanciated) { i.OnCreate(); } return((T)i); }
// close panel by object PanelInstance public void ClosePanel(PanelInstance page) { if (page == null) { return; } currentPanel = null; page.OpenPanel(false); StartCoroutine(DisablePanelDeleyed(page)); }
public void ClosePanel(PanelInstance page) { if (page == null) return; currentPanel = null; Animator anim = page.GetComponent<Animator> (); if (anim && anim.isActiveAndEnabled) { anim.SetBool ("Open", false); } StartCoroutine (DisablePanelDeleyed (page)); }
// open panel by object PanelInstance public void OpenPanel(PanelInstance page) { if (page == null) { return; } page.PanelBefore = currentPanel; currentPanel = page; CloseAllPanels(); page.OpenPanel(true); }
public void OpenPanel(PanelInstance page) { if (page == null) return; page.PanelBefore = currentPanel; currentPanel = page; CloseAllPanels (); Animator anim = page.GetComponent<Animator> (); if (anim && anim.isActiveAndEnabled) { anim.SetBool ("Open", true); } page.gameObject.SetActive (true); }
public void Show(string title, string msg, Action <bool> clb) { this.clb = clb; component = PanelInstance.GetInstance <PanelInstanceOk>(PanelName.PANEL_OK).GetComponent(); component.closer.SetUIVisible(true); Debug.Log("here"); component.title.SetText(title); component.text.SetText(msg); component.okController.RegisterOnClickEvent(() => { Debug.Log("Button click"); component.closer.SetUIVisible(false); clb(true); }); component.cancelController.RegisterOnClickEvent(Cancel); component.closeController.RegisterOnClickEvent(Cancel); }
//打开面板 public void OpenPanel(PanelInstance page) { if (page == null) { return; } page.PanelBefore = currentPanel; currentPanel = page; CloseAllPanels(); Animator anim = page.GetComponent <Animator>(); if (anim && anim.isActiveAndEnabled) { anim.SetBool("Open", true); } page.gameObject.SetActive(true); Debug.Log("面板" + page.gameObject.name + "已经打开"); }
// use this function when you need to open previous panel public void OpenPreviousPanel() { if (setPreviousPanel != null) { CloseAllPanels(); setPreviousPanel.OpenPanel(true); currentPanel = setPreviousPanel; setPreviousPanel = null; } else { //Debug.Log ("open previous "+currentPanel.PanelBefore); if (currentPanel && currentPanel.PanelBefore) { CloseAllPanels(); currentPanel.PanelBefore.OpenPanel(true); currentPanel = currentPanel.PanelBefore; } } }
// close panel by name. public void ClosePanelByName(string name) { PanelInstance page = null; for (int i = 0; i < Pages.Length; i++) { if (Pages [i].name == name) { page = Pages [i]; break; } } if (page == null) { return; } currentPanel = null; page.OpenPanel(false); StartCoroutine(DisablePanelDeleyed(page)); }
// use this function when you need to open panel without saving a previous. // so you can't use OpenPreviousPanel to open a previous panel again. public void OpenPanelByNameNoPreviousSave(string name) { PanelInstance page = null; for (int i = 0; i < Pages.Length; i++) { if (Pages [i].name == name) { page = Pages [i]; break; } } if (page == null) { return; } currentPanel = page; CloseAllPanels(); page.OpenPanel(true); }
public void Show(PlanetEntity entity) { if (inst == null) { inst = PanelInstance.CreateInstance <PanelInstanceObject>(PanelName.PANEL_OBJECT_INFO).GetComponent(); } inst.title.SetText(entity.entityData.name); inst.description.SetText(entity.entityData.description); if (entity.entityData.canSell) { this.inst.sellAmount.gameObject.SetActive(true); this.inst.sellButton.gameObject.SetActive(true); inst.sellAmount.SetText("$ " + (entity.entityData.cost * ConstMultiplier.MONEY).ToString()); inst.sellButton.ClearEvents(); inst.sellButton.RegisterOnClickEvent(() => { if (entity.gameObject == null) { return; } Player.Instance.money += entity.entityData.cost * ConstMultiplier.MONEY; Object.Destroy(entity.gameObject); this.inst.gameObject.SetActive(false); }); } else { this.inst.sellAmount.gameObject.SetActive(false); this.inst.sellButton.gameObject.SetActive(false); } ShowEntityInfo(entity); inst.closer.SetUIVisible(true); }
//通过名字打开面板 public void OpenPanelByName(string name) { PanelInstance page = null; for (int i = 0; i < Pages.Length; i++) { if (Pages[i].name == name) { page = Pages[i]; break; } } if (page == null) { Debug.Log("未找到该界面"); return; } page.PanelBefore = currentPanel; currentPanel = page; CloseAllPanels(); Debug.Log("面板" + page.gameObject.name + "已经打开"); page.gameObject.SetActive(true); }
void CreatePageWidget(SectionPage page) { List <PanelInstance> boxPanels = new List <PanelInstance> (); List <PanelInstance> tabPanels = new List <PanelInstance> (); foreach (PanelInstance pi in page.Panels) { if (pi.Widget == null) { pi.Widget = pi.Panel.CreatePanelWidget(); if (pi.Widget == null) { continue; } //HACK: work around bug 469427 - broken themes match on widget names if (pi.Widget.Name.IndexOf("Panel") > 0) { pi.Widget.Name = pi.Widget.Name.Replace("Panel", "_"); } } else if (pi.Widget.Parent != null) { ((Gtk.Container)pi.Widget.Parent).Remove(pi.Widget); } if (pi.Node.Grouping == PanelGrouping.Tab) { tabPanels.Add(pi); } else { boxPanels.Add(pi); } } // Try to fit panels with grouping=box or auto in the main page. // If they don't fit. Move auto panels to its own tab page. int mainPageSize; bool fits; do { PanelInstance lastAuto = null; mainPageSize = 0; foreach (PanelInstance pi in boxPanels) { if (pi.Node.Grouping == PanelGrouping.Auto) { lastAuto = pi; } // HACK: This we are parenting/unparenting the widget here as a workaround // for a layout issue. To properly calculate the size of the widget, the widget // needs to have the style that it will have when added to the window. pi.Widget.Parent = this; mainPageSize += pi.Widget.SizeRequest().Height + 6; pi.Widget.Unparent(); } fits = mainPageSize <= pageFrame.Allocation.Height; if (!fits) { if (lastAuto != null && boxPanels.Count > 1) { boxPanels.Remove(lastAuto); tabPanels.Insert(0, lastAuto); } else { fits = true; } } } while (!fits); Gtk.VBox box = new VBox(false, 12); box.Show(); for (int n = 0; n < boxPanels.Count; n++) { if (n != 0) { HSeparator sep = new HSeparator(); sep.Show(); box.PackStart(sep, false, false, 0); } PanelInstance pi = boxPanels [n]; box.PackStart(pi.Widget, pi.Node.Fill, pi.Node.Fill, 0); pi.Widget.Show(); } box.BorderWidth = 12; if (tabPanels.Count > 0) { /* SquaredNotebook nb = new SquaredNotebook (); * nb.Show (); * nb.AddTab (box, GettextCatalog.GetString ("General")); * foreach (PanelInstance pi in tabPanels) { * Gtk.Alignment a = new Alignment (0, 0, 1, 1); * a.BorderWidth = 9; * a.Show (); * a.Add (pi.Widget); * nb.AddTab (a, GettextCatalog.GetString (pi.Node.Label)); * pi.Widget.Show (); * }*/ Gtk.Notebook nb = new Notebook(); nb.Show(); if (box.Children.Length > 0) { Gtk.Label blab = new Gtk.Label(GettextCatalog.GetString("General")); blab.Show(); box.BorderWidth = 9; nb.InsertPage(box, blab, -1); } foreach (PanelInstance pi in tabPanels) { Gtk.Label lab = new Gtk.Label(GettextCatalog.GetString(pi.Node.Label)); lab.Show(); Gtk.Alignment a = new Alignment(0, 0, 1, 1); a.BorderWidth = 9; a.Show(); a.Add(pi.Widget); nb.InsertPage(a, lab, -1); pi.Widget.Show(); } page.Widget = nb; nb.BorderWidth = 12; } else { page.Widget = box; } }
SectionPage CreatePage(TreeIter it, OptionsDialogSection section, object dataObject) { SectionPage page; if (pages.TryGetValue(section, out page)) { return(page); } page = new SectionPage(); page.Iter = it; page.Panels = new List <PanelInstance> (); pages [section] = page; List <OptionsPanelNode> nodes = new List <OptionsPanelNode> (); if (!string.IsNullOrEmpty(section.TypeName) || section.CustomNode) { nodes.Add(section); } if (!section.CustomNode) { foreach (ExtensionNode nod in section.ChildNodes) { OptionsPanelNode node = nod as OptionsPanelNode; if (node != null && !(node is OptionsDialogSection)) { nodes.Add(node); } } } foreach (OptionsPanelNode node in nodes.ToArray()) { if (!string.IsNullOrEmpty(node.Replaces)) { var replaced = nodes.FindIndex(n => n.Id == node.Replaces); if (replaced != -1) { nodes.Remove(node); nodes [replaced] = node; } } } foreach (OptionsPanelNode node in nodes) { PanelInstance pi = null; if (panels.TryGetValue(node, out pi)) { if (pi.DataObject == dataObject) { // The panel can be reused if (!pi.Panel.IsVisible()) { continue; } } else { // If the data object has changed, this panel instance can't be // reused anymore. Destroy it. panels.Remove(node); if (pi.Widget != null) { pi.Widget.Destroy(); } IDisposable d = pi.Panel as IDisposable; if (d != null) { d.Dispose(); } pi = null; } } if (pi == null) { IOptionsPanel panel = node.CreatePanel(); pi = new PanelInstance(); pi.Panel = panel; pi.Node = node; pi.DataObject = dataObject; page.Panels.Add(pi); panel.Initialize(this, dataObject); if (!panel.IsVisible()) { page.Panels.Remove(pi); continue; } panels [node] = pi; } else { page.Panels.Add(pi); } } return(page); }
SectionPage CreatePage (TreeIter it, OptionsDialogSection section, object dataObject) { SectionPage page; if (pages.TryGetValue (section, out page)) return page; page = new SectionPage (); page.Iter = it; page.Panels = new List<PanelInstance> (); pages [section] = page; List<OptionsPanelNode> nodes = new List<OptionsPanelNode> (); if (!string.IsNullOrEmpty (section.TypeName) || section.CustomNode) nodes.Add (section); if (!section.CustomNode) { foreach (ExtensionNode nod in section.ChildNodes) { OptionsPanelNode node = nod as OptionsPanelNode; if (node != null && !(node is OptionsDialogSection)) nodes.Add (node); } } foreach (OptionsPanelNode node in nodes) { PanelInstance pi = null; if (panels.TryGetValue (node, out pi)) { if (pi.DataObject == dataObject) { // The panel can be reused if (!pi.Panel.IsVisible ()) continue; } else { // If the data object has changed, this panel instance can't be // reused anymore. Destroy it. panels.Remove (node); if (pi.Widget != null) pi.Widget.Destroy (); IDisposable d = pi.Panel as IDisposable; if (d != null) d.Dispose (); pi = null; } } if (pi == null) { IOptionsPanel panel = node.CreatePanel (); pi = new PanelInstance (); pi.Panel = panel; pi.Node = node; pi.DataObject = dataObject; page.Panels.Add (pi); panel.Initialize (this, dataObject); if (!panel.IsVisible ()) { page.Panels.Remove (pi); continue; } panels [node] = pi; } else page.Panels.Add (pi); } return page; }
void CreatePageWidget(SectionPage page) { List <PanelInstance> boxPanels = new List <PanelInstance> (); List <PanelInstance> tabPanels = new List <PanelInstance> (); foreach (PanelInstance pi in page.Panels) { if (pi.Widget == null) { pi.Widget = pi.Panel.CreatePanelWidget(); //HACK: work around bug 469427 - broken themes match on widget names if (pi.Widget.Name.IndexOf("Panel") > 0) { pi.Widget.Name = pi.Widget.Name.Replace("Panel", "_"); } } else if (pi.Widget.Parent != null) { ((Gtk.Container)pi.Widget.Parent).Remove(pi.Widget); } if (pi.Node.Grouping == PanelGrouping.Tab) { tabPanels.Add(pi); } else { boxPanels.Add(pi); } } // Try to fit panels with grouping=box or auto in the main page. // If they don't fit. Move auto panels to its own tab page. int mainPageSize; bool fits; do { PanelInstance lastAuto = null; mainPageSize = 0; foreach (PanelInstance pi in boxPanels) { if (pi.Node.Grouping == PanelGrouping.Auto) { lastAuto = pi; } mainPageSize += pi.Widget.SizeRequest().Height + 6; } fits = mainPageSize <= pageFrame.Allocation.Height; if (!fits) { if (lastAuto != null && boxPanels.Count > 1) { boxPanels.Remove(lastAuto); tabPanels.Insert(0, lastAuto); } else { fits = true; } } }while (!fits); Gtk.VBox box = new VBox(false, 12); box.Show(); for (int n = 0; n < boxPanels.Count; n++) { if (n != 0) { HSeparator sep = new HSeparator(); sep.Show(); box.PackStart(sep, false, false, 0); } PanelInstance pi = boxPanels [n]; box.PackStart(pi.Widget, pi.Node.Fill, pi.Node.Fill, 0); pi.Widget.Show(); } if (tabPanels.Count > 0) { Gtk.Notebook nb = new Notebook(); nb.Show(); Gtk.Label blab = new Gtk.Label(GettextCatalog.GetString("General")); blab.Show(); box.BorderWidth = 9; nb.InsertPage(box, blab, -1); foreach (PanelInstance pi in tabPanels) { Gtk.Label lab = new Gtk.Label(GettextCatalog.GetString(pi.Node.Label)); lab.Show(); Gtk.Alignment a = new Alignment(0, 0, 1, 1); a.BorderWidth = 9; a.Show(); a.Add(pi.Widget); nb.InsertPage(a, lab, -1); pi.Widget.Show(); } page.Widget = nb; } else { page.Widget = box; } }
public void OpenPreviousPanel() { if (currentPanel && currentPanel.PanelBefore) { CloseAllPanels (); Animator anim = currentPanel.PanelBefore.GetComponent<Animator> (); if (anim && anim.isActiveAndEnabled) { anim.SetBool ("Open", true); } currentPanel.PanelBefore.gameObject.SetActive (true); currentPanel = currentPanel.PanelBefore; } }
IEnumerator DisablePanelDeleyed(PanelInstance page) { bool closedStateReached = false; bool wantToClose = true; Animator anim = page.GetComponent<Animator> (); if (anim && anim.enabled) { while (!closedStateReached && wantToClose) { if (!anim.IsInTransition (0)) { closedStateReached = anim.GetCurrentAnimatorStateInfo (0).IsName ("Closing"); } yield return new WaitForEndOfFrame(); } if (wantToClose) { anim.gameObject.SetActive (false); } } else { page.gameObject.SetActive (false); } }
public void OpenPanelByName(string name) { PanelInstance page = null; for (int i=0; i<Pages.Length; i++) { if (Pages [i].name == name) { page = Pages [i]; break; } } if (page == null) return; page.PanelBefore = currentPanel; currentPanel = page; CloseAllPanels (); Animator anim = page.GetComponent<Animator> (); if (anim && anim.isActiveAndEnabled) { anim.SetBool ("Open", true); } page.gameObject.SetActive (true); }
private static void OnCloseIPanel(Guid panelTypeGuid, uint documentSerailNumber, PanelInstance instance, IPanel panel, bool onCloseDocument) { Panels.OnClosePanel(panelTypeGuid, documentSerailNumber); panel?.PanelClosing(documentSerailNumber, onCloseDocument); }
public void SetPreviousPanel(PanelInstance panel) { setPreviousPanel = panel; }
private static void DestoryInstnce(Guid panelTypeGuid, Guid containerId, uint documentSerailNumber, PanelInstance instance) { // Get the definition associated with the type Id var definition = Definition(panelTypeGuid); // Create should never get called for a unregistered type but just to make sure... var containers = definition?.Containers(documentSerailNumber); containers?.Destroy(instance); }
//禁用面板 /* * public IEnumerator DisablePanelDeleyed(PanelInstance page) * { * * bool closeStateReached = false; * bool wantToClose = true; * Animator anim = page.gameObject.GetComponent<Animator>(); * if (anim && anim.enabled) * { * while(!closeStateReached&&wantToClose) * { * if(anim.isActiveAndEnabled&&!anim.IsInTransition(0)) * { * closeStateReached = anim.GetCurrentAnimatorStateInfo(0).IsName("Closing"); * } * yield return new WaitForEndOfFrame(); * } * if(wantToClose) * { * anim.gameObject.SetActive(false); * } * } * * page.gameObject.SetActive(false); * } */ public void DisablePanelDeleyed(PanelInstance page) { page.gameObject.SetActive(false); }