public void SetVisibleUI(UITypes uiType) { foreach (KeyValuePair <UITypes, IUIPanel> uiPanel in _uiPanels) { uiPanel.Value.SetVisibility(uiPanel.Key == uiType); } }
//动态增加ui时需传入uipath,在uitype和uiname中均需要配置 public UIOperateBase showUI <T>(UITypes type, string path = "") where T : UIOperateBase { if (!_UIList.ContainsKey(type)) { if (!checkNameConfig(type)) { return(null); } string name = UIName.Type2Name[type]; if (path == "") { _UIList.Add(type, UIOperateBase.New <T>(name)); } else { _UIList.Add(type, UIOperateBase.DynamicNew <T>(name, path)); } } _UIList[type].Open(); if (!checkIsHUDUI(type)) { updateOpenCout(1); } EventManager.SendEvent(EventMacro.SHOW_UI, type); _layerController.updateLayer(type, UILayers.HIGHEST); return(_UIList[type]); }
public void SetIconFor(UITypes type, Item item, Slot slot) { ItemData createdGo = CreateSlotPlaceholder(item, slot); switch (type) { case UITypes.hotbarUI_hotslots: hotbarUI.hotSlots[hotbarUI.hotSlots.IndexOf(slot)].itemData = createdGo; break; case UITypes.inventoryUI_hotSlots: inventoryUI.hotSlots[inventoryUI.hotSlots.IndexOf(slot)].itemData = createdGo; break; case UITypes.inventoryUI_invSlots: inventoryUI.invSlots[inventoryUI.invSlots.IndexOf(slot)].itemData = createdGo; break; case UITypes.mechanismUI_hotSlots: mechanismUI.hotSlots[mechanismUI.hotSlots.IndexOf(slot)].itemData = createdGo; break; case UITypes.mechanismUI_invSlots: mechanismUI.invSlots[mechanismUI.invSlots.IndexOf(slot)].itemData = createdGo; break; default: Debug.Log("None set for " + type.ToString()); break; } }
/*** * @params: * iconsumperpage * iconname * materialdic * iconrespath* * iconprefabpath* * **/ public void initComponents(params object[] paras) { //暂时用同一个size _iconSumPerPage = BackpackItemManager.Instance.GetSize(tabIndexToItemType[0]); string iconName = Convert.ToString(paras[0]); _uiType = (UITypes)paras[1]; _iconResPath = paras[2] == null ? _iconResPath : Convert.ToString(paras[2]); _materials = new int[_iconSumPerPage]; _iconbases = new UIIcon[_iconSumPerPage]; _buttons = new GameObject[_iconSumPerPage]; _bagBtnGrid = this.transform.Find("Grid"); for (int i = 0; i < _iconSumPerPage; i++) { addItemIcon(i); } if (paras[3] != null) { _selectSprite = GameObject.Find(Convert.ToString(paras[3])); _selectSprite.SetActive(false); } GridLayoutGroup glg = _bagBtnGrid.GetComponent <GridLayoutGroup>(); float height = (glg.cellSize.y + glg.spacing.y) * (_iconSumPerPage / 6); RectTransform rtf = _bagBtnGrid.GetComponent <RectTransform>(); rtf.sizeDelta = new Vector2(rtf.sizeDelta.x, height); EventManager.RegisterEvent(UIEventMacro.CLICK_TAB, onClickTab); UIEventManager.RegisterEvent(UIEventManager.ET_UI_CLICK, _uiType.ToString(), onSelect); showIcon(0); }
public UIOperateBase getUI(UITypes type) { if (!_UIList.ContainsKey(type)) { throw new Exception("非法的UI类型!"); } return(_UIList[type]); }
public void initComponents(params object[] paras) { _uiType = (UITypes)paras[0]; GameObject icons = GameObject.Find("BagIcons"); _iconComponent = icons.AddComponent <IconsComponent>(); _iconComponent.initComponents("BagButton", _uiType, _resPath, "Bagselect"); }
/// <summary> /// Overwrites previous implementations for this type. /// </summary> public void Overwrite() { // overwrite type UITypes.Register(WithGetter.GenerateType.ForType.Type, WithGetter.GenerateType.ControlGenerator, WithGetter.ControlGetter, ControlSetter, true); }
public virtual void Init(string id, params object[] paras) { mTrans = transform; mGo = gameObject; this.id = id; UItype = (UITypes)paras[0]; Register(); InitElements(); }
private bool checkNameConfig(UITypes type) { if (!UIName.Type2Name.ContainsKey(type)) { Debug.LogError("没有当前UI的配置!请在UIName中配置UI!"); return(false); } return(true); }
void ProcessColor(string doc, UITypes type) { var dict = ProcessMakeDict(doc); var val = dict.GetKeyValue("key"); switch (type) { case UITypes.Label: if (!string.IsNullOrEmpty(val)) { if (val == "textColor") { var colType = dict.GetKeyValue("cocoaTouchSystemColor"); if (!string.IsNullOrEmpty(colType)) { ProcessSystemColor(colType); } } } break; case UITypes.Button: if (val == "titleColor") { var col = dict.GetKeyValue("red", "0"); if (!string.IsNullOrEmpty(col)) { ui.ColorR = ((int)(Convert.ToDouble(col) * 255)).ToString(); } col = dict.GetKeyValue("green", "0"); if (!string.IsNullOrEmpty(col)) { ui.ColorG = ((int)(Convert.ToDouble(col) * 255)).ToString(); } col = dict.GetKeyValue("blue", "0"); if (!string.IsNullOrEmpty(col)) { ui.ColorB = ((int)(Convert.ToDouble(col) * 255)).ToString(); } col = dict.GetKeyValue("alpha", "1"); if (!string.IsNullOrEmpty(col)) { ui.ColorA = col; } col = dict.GetKeyValue("white", "0"); if (!string.IsNullOrEmpty(col)) { ui.ColorW = col; ui.ColorB = ui.ColorG = ui.ColorR = "255"; } } break; } }
private void EnterMenu(UITypes t) { CurrentUI = t; im.SetMode(InteractMode.gMode.GM_MENU); if (t == UITypes.InventoryGUI) { SelectedSlot = -1; im.EndUseWith(); } }
public void registerUI <T>(UITypes type) where T : UIOperateBase { if (!checkNameConfig(type)) { return; } string name = UIName.Type2Name[type]; _UIList.Add(type, UIOperateBase.New <T>(name)); _layerController.register(_UIList[type]); }
public void closeUI(UITypes type) { if (!_UIList.ContainsKey(type)) { return; } _UIList[type].Close(); if (!checkIsHUDUI(type)) { updateOpenCout(-1); } _layerController.updateLayer(type, UILayers.LOWEST); EventManager.SendEvent(EventMacro.CLOSE_UI, type); }
/// <summary> /// Скрыть все интерфейсы типа /// </summary> /// <param name="uiType"></param> public void Close(UITypes uiType, bool use_animate = true) { foreach (var item in screenList) { if (item == null) { continue; } if (item.UIType == uiType) { item.Close(use_animate); } } }
/// <summary> /// Отобразить все интерфейсы типа /// </summary> /// <param name="uiType"></param> public void Open(UITypes uiType, Action OnClose = null, bool use_animate = true) { foreach (var item in screenList) { if (item == null) { continue; } if (item.UIType == uiType) { item.Open(OnClose, use_animate); } } }
public void updateLayer(UITypes type, int layers) { if (!_UILayerList.ContainsKey(type)) { _UILayerList.Add(type, layers); } else { _UILayerList[type] = layers; } if (_UIList.ContainsKey(type)) { _UIList[type].updateLayer(layers); } }
/// <summary> /// Получить один интерфейсы типа (если их несколько, то первый попавшийся) /// </summary> /// <param name="uiType"></param> public UIScreen GetUIOnce(UITypes uiType) { foreach (var item in screenList) { if (item == null) { continue; } if (item.UIType == uiType) { return(item); } } return(null); }
public void initComponents(params object[] paras) { int padNum = Convert.ToInt32(paras[0]); string padName = Convert.ToString(paras[1]); _type = (UITypes)paras[2]; int index; _padList = new GameObject[padNum]; for (int i = 0; i < padNum; i++) { index = i + 1; _padList[i] = GameObject.Find(padName + index); addPadScript(_padList[i], index); } }
/// <summary> /// Получить все интерфейсы типа /// </summary> /// <param name="uiType"></param> public List <UIScreen> GetUI(UITypes uiType) { List <UIScreen> lst = new List <UIScreen>(); foreach (var item in screenList) { if (item == null) { continue; } if (item.UIType == uiType) { lst.Add(item); } } return(lst); }
public void initComponents(params object[] paras) { int tabNum = Convert.ToInt32(paras[0]); string tabName = Convert.ToString(paras[1]); _selectMcName = Convert.ToString(paras[2]); _type = (UITypes)paras[3]; int index; _tabList = new GameObject[tabNum]; for (int i = 0; i < tabNum; i++) { index = i + 1; _tabList[i] = GameObject.Find(tabName + index); addTabScript(_tabList[i], index); } resetTab(); }
public void SetSlotFor(UISlotType slotType, UITypes type, int slotNumber) { switch (slotType) { case UISlotType.hotbar: switch (type) { case UITypes.hotbarUI_hotslots: hotbarUI.hotSlots.Add(CreateSlot(hotbarUI, slotType, hotbarUI.hotbarGo.transform, slotNumber)); break; case UITypes.inventoryUI_hotSlots: inventoryUI.hotSlots.Add(CreateSlot(inventoryUI, slotType, inventoryUI.hotbarGo.transform, slotNumber)); break; case UITypes.mechanismUI_hotSlots: mechanismUI.hotSlots.Add(CreateSlot(mechanismUI, slotType, mechanismUI.hotbarGo.transform, slotNumber)); break; default: Debug.Log("None set for " + type.ToString()); break; } break; case UISlotType.inventory: switch (type) { case UITypes.inventoryUI_invSlots: inventoryUI.invSlots.Add(CreateSlot(inventoryUI, slotType, inventoryUI.inventoryGo.transform, slotNumber)); break; case UITypes.mechanismUI_invSlots: mechanismUI.invSlots.Add(CreateSlot(mechanismUI, slotType, mechanismUI.inventoryGo.transform, slotNumber)); break; default: Debug.Log("None set for " + type.ToString()); break; } break; } }
public void initComponents(params object[] paras) { _uiType = (UITypes)paras[0]; _iconContainer = GameObject.Find("BagSelectContainer"); UIEventManager.RegisterEvent(UIEventManager.ET_UI_CLICK, _uiType.ToString(), onSelect); _prefab = _prefab == null?Resources.Load(_iconPrefabPath) as GameObject : _prefab; GameObject icon = GameObject.Instantiate(_prefab) as GameObject; RectTransform rectTrans = icon.GetComponent <RectTransform>(); Vector3 localPosition = rectTrans.anchoredPosition3D; rectTrans.SetParent(_iconContainer.transform); rectTrans.anchoredPosition3D = localPosition; rectTrans.localScale = Vector3.one; icon.AddComponent <UIIcon>(); _iconBase = icon.GetComponent <UIIcon>(); _iconBase.Init("0", _uiType, _iconResPath); _iconBase.setEnable(false); }
public void initComponents(params object[] paras) { string containerName = Convert.ToString(paras[0]); _uiType = (UITypes)paras[1]; //_iconResPath = paras[2] == null ? _iconResPath : Convert.ToString(paras[2]); //_iconPrefabPath = paras[3] == null ? _iconPrefabPath : Convert.ToString(paras[3]); _iconContainer = GameObject.Find(containerName); _prefab = _prefab == null?Resources.Load(_iconPrefabPath) as GameObject : _prefab; GameObject icon = GameObject.Instantiate(_prefab) as GameObject; RectTransform rectTrans = icon.GetComponent <RectTransform>(); Vector3 localPosition = rectTrans.anchoredPosition3D; rectTrans.SetParent(_iconContainer.transform); icon.transform.parent = _iconContainer.transform; rectTrans.localScale = Vector3.one; rectTrans.anchoredPosition3D = localPosition; icon.AddComponent <UIIcon>(); _iconBase = icon.GetComponent <UIIcon>(); _iconBase.Init("0", _uiType, _iconResPath); }
public ModelOperate(string operate, string text, string groupText, int order, int imageIndex, UITypes uiType = UITypes.LargerButton) { this.Operate = operate; this.Text = text; this.GroupText = groupText; this.Order = order; this.ImageIndex = imageIndex; this.UIType = uiType; }
public void initComponents(params object[] paras) { _type = (UITypes)paras[0]; _itemList = new List <SelectItem>(); _selectView = new List <GameObject>(); }
void OnGUI() { GUI.depth = 2; if (CurrentUI == UITypes.MainGUI) { if(im.GetMode() == InteractMode.gMode.GM_WORLD) // Hide the GUI when not in world mode { Box.x = 25; Box.y = Screen.height - BoxWidth*1.5f; if (GUI.Button(Box, Inventoryicon)) { EnterMenu(UITypes.InventoryGUI); } Box.y = 10; if (GUI.Button(Box, "Menu")) { //Put code here to switch back to the menu view EnterMenu(UITypes.MenuGUI); } //If any other GUI options need to go on the main game overlay they go here } } else if (CurrentUI == UITypes.InventoryGUI) { GUI.skin.label.fontSize = 14; GUI.skin.label.alignment = TextAnchor.MiddleCenter; GUI.skin.box.fontSize = 28; GUI.Box(InventoryBackground, "Inventory"); Icon45.x = (Screen.width / 10) + 5; Icon45.y = (Screen.height / 10) + 5; if (GUI.Button(Icon45, "Exit")) { if(SelectedSlot != -1) im.SetUseWith(inv.GetObjectInSlot(SelectedSlot)); ExitToMain(); } int j = 0; for (int i = 0; i < Inventory.INVENTORY_SIZE; i++) { if (i % 5 == 0) { j++; } LabelInventoryScalable.x = (Screen.width / 14) * ((i % 5) + 1) * 2; LabelInventoryScalable.y = (Screen.height / 14) * 3 * j -30; if (inv.GetObjectInSlot(i) == -1) { GUI.Label(LabelInventoryScalable, "Empty"); } else { GUI.Label(LabelInventoryScalable, db.GetObject(inv.GetObjectInSlot(i)).name); } IconInventoryScalable.x = (Screen.width / 14) * ((i % 5) + 1) * 2; IconInventoryScalable.y = (Screen.height / 14) * 3 * j; if(i == SelectedSlot) GUI.backgroundColor = Color.yellow; else GUI.backgroundColor = Color.white; if(GUI.Button(IconInventoryScalable, "")) { if(inv.GetObjectInSlot(i) != -1) { if(SelectedSlot != -1) AttemptCombine(i); else SelectedSlot = i; } } GUI.backgroundColor = Color.white; // reset after so it wont effect anything else // since you modify the Rect's x/y after that first loop, well you can sort this out // JUST MAKE SURE SLOT ISNT EMPTY ELSE NULL TEXTURE if(inv.GetObjectInSlot(i) != -1) GUI.DrawTexture(IconInventoryScalable, ((Collectable)db.GetObject(inv.GetObjectInSlot(i))).icon); } } else if (CurrentUI == UITypes.MenuGUI) { Application.LoadLevel("Menu"); /* MenuButton.x = Screen.width / 2 -100; MenuButton.y = (Screen.height / 10) * 5; if (GUI.Button(MenuButton, "Play Game")) { //Put code here to switch to the game view ExitToMain(); } MenuButton.y = (Screen.height / 10) * 6; if (GUI.Button(MenuButton, "Options")) { //Put code here to switch to the menu options view EnterMenu(UITypes.MenuOptionGUI); } //Any additional menu options can be added in here*/ } else if (CurrentUI == UITypes.MenuOptionGUI) { //Test menu options slider MenuButton.x = Screen.width / 10; MenuButton.y = Screen.height / 10; GUI.Box(MenuButton, "Master Volume"); //Removed for now, when menu choices are finalised proper size and position of sliders will be determined. //vSliderValue = GUI.HorizontalSlider(new Rect(Screen.width / 14 * 3, Screen.height / 10+10, 100, 50), vSliderValue, 10.0f, 0.0f); //Fill out the rest of this when we know what options we want to give the players } else if (CurrentUI == UITypes.BookGUI) { GUI.Box(BookBackground, BookTexture, Book); if (GUI.Button(new Rect(Screen.width / 2 - (Screen.width / 15 /2), Screen.height - Screen.height / 10, Screen.width / 15, Screen.height / 20), "Close")) { CurrentUI = UITypes.MainGUI; } } }
public void ChangeUI(UITypes newUI) { CurrentUI = newUI; }
public override void Init(string id, params object[] paras) { _resPath = Convert.ToString(paras[1]); _uiType = (UITypes)paras[0]; base.Init(id, paras); }
public WithSetter WithSetter(Action <ControlSetter> controlSetter) { // register type UITypes.Register(GenerateType.ForType.Type, GenerateType.ControlGenerator, ControlGetter, controlSetter, false); return(new WithSetter(this, controlSetter)); }
/// <summary> /// インスタンスを取得する /// </summary> /// <param name="type">取得するUIオブジェクトのタイプ</param> /// <param name="mode">表示モード</param> /// <param name="name">名前</param> /// <exception cref="InvalidEnumArgumentException"><paramref name="type"/>が無効な値</exception> /// <returns><see cref="UIInfoBase"/>から派生したインスタンス</returns> public static UIInfoBase GetInstance(UITypes type, int mode, string name) => type switch {
void OnGUI() { GUI.depth = 2; if (CurrentUI == UITypes.MainGUI) { Icon50.x = 25; Icon50.y = Screen.height - 75; if (GUI.Button(Icon50, Inventoryicon)) { CurrentUI = UITypes.InventoryGUI; } Icon50.y = 10; if (GUI.Button(Icon50, "Menu")) { //Put code here to switch back to the menu view Application.LoadLevel("menu"); //CurrentUI = UITypes.MenuGUI; } //If any other GUI options need to go on the main game overlay they go here } else if (CurrentUI == UITypes.InventoryGUI) { GUI.Box(InventoryBackground, "Inventory"); Icon45.x = (Screen.width / 10) + 5; Icon45.y = (Screen.height / 10) + 5; if (GUI.Button(Icon45, "Exit")) { CurrentUI = UITypes.MainGUI; } int j = 0; for (int i = 0; i < Inventory.INVENTORY_SIZE; i++) { if (i % 5 == 0) { j++; } LabelInventoryScalable.x = (Screen.width / 14) * ((i % 5) + 1) * 2; LabelInventoryScalable.y = (Screen.height / 14) * 3 * j -30; //GUI.skin.label.alignment = TextAnchor.UpperCenter; if (inv.GetObjectInSlot(i) == -1) { GUI.Label(LabelInventoryScalable, "Empty"); } else { GUI.Label(LabelInventoryScalable, db.GetObject(inv.GetObjectInSlot(i)).name); } IconInventoryScalable.x = (Screen.width / 14) * ((i % 5) + 1) * 2; IconInventoryScalable.y = (Screen.height / 14) * 3 * j; GUI.Box(IconInventoryScalable, ""); //change later to fetch appropriate inventory icon // since you modify the Rect's x/y after that first loop, well you can sort this out // JUST MAKE SURE SLOT ISNT EMPTY ELSE NULL TEXTURE if(inv.GetObjectInSlot(i) != -1) GUI.DrawTexture(IconInventoryScalable, ((Collectable)db.GetObject(inv.GetObjectInSlot(i))).icon); } } else if (CurrentUI == UITypes.MenuGUI) { MenuButton.x = Screen.width / 2 -100; MenuButton.y = (Screen.height / 10) * 5; if (GUI.Button(MenuButton, "Play Game")) { //Put code here to switch to the game view CurrentUI = UITypes.MainGUI; } MenuButton.y = (Screen.height / 10) * 6; if (GUI.Button(MenuButton, "Options")) { //Put code here to switch to the menu options view //CurrentUI = UITypes.MenuOptionGUI; } //Any additional menu options can be added in here } else if (CurrentUI == UITypes.MenuOptionGUI) { //Test menu options slider MenuButton.x = Screen.width / 10; MenuButton.y = Screen.height / 10; GUI.Box(MenuButton, "Master Volume"); //Removed for now, when menu choices are finalised proper size and position of sliders will be determined. //vSliderValue = GUI.HorizontalSlider(new Rect(Screen.width / 14 * 3, Screen.height / 10+10, 100, 50), vSliderValue, 10.0f, 0.0f); //Fill out the rest of this when we know what options we want to give the players } }
private static UIType GetEditableType(Type t) { return(UITypes.Get(t)); }
void ProcessColor(string doc, UITypes type) { var dict = ProcessMakeDict(doc); var val = dict.GetKeyValue("key"); switch (type) { case UITypes.Label: if (!string.IsNullOrEmpty(val)) { if (val == "textColor") { var colType = dict.GetKeyValue("cocoaTouchSystemColor"); if (!string.IsNullOrEmpty(colType)) { ProcessSystemColor(colType); } } } break; case UITypes.Button: if (val == "titleColor") { var col = dict.GetKeyValue("red", "0"); if (!string.IsNullOrEmpty(col)) ui.ColorR = ((int)(Convert.ToDouble(col) * 255)).ToString(); col = dict.GetKeyValue("green", "0"); if (!string.IsNullOrEmpty(col)) ui.ColorG = ((int)(Convert.ToDouble(col) * 255)).ToString(); col = dict.GetKeyValue("blue", "0"); if (!string.IsNullOrEmpty(col)) ui.ColorB = ((int)(Convert.ToDouble(col) * 255)).ToString(); col = dict.GetKeyValue("alpha", "1"); if (!string.IsNullOrEmpty(col)) ui.ColorA = col; col = dict.GetKeyValue("white", "0"); if (!string.IsNullOrEmpty(col)) { ui.ColorW = col; ui.ColorB = ui.ColorG = ui.ColorR = "255"; } } break; } }
private void ExitToMain() { CurrentUI = UITypes.MainGUI; im.SetMode(InteractMode.gMode.GM_WORLD); }
public ModelOperate(OperateTypes operate, string text, string groupText, int order, int imageIndex, UITypes uiType = UITypes.LargerButton) : this(operate.ToString(), text, groupText, order, imageIndex, uiType) { }
private bool checkIsHUDUI(UITypes type) { return(type == UITypes.TASK); }