Ejemplo n.º 1
0
 public Criterion(
     string header,
     string key,
     string description,
     string type,
     object obj,
     string reportStringKey,
     string reportStringVal,
     string databaseID,
     bool empty,
     bool locked,
     object dataSource,
     string dataType,
     UIType uiType,
     bool removable)
 {
     Key = key;
     Description = description;
     Type = type;
     Object = obj;
     ReportStringKey = reportStringKey;
     ReportStringVal = reportStringVal;
     DatabaseID = databaseID;
     Empty = empty;
     Header = header;
     Locked = locked;
     DataSource = dataSource;
     DataType = dataType;
     UIType = uiType;
     Removable = removable;
     Visible = true;
 }
Ejemplo n.º 2
0
        public UIView(ICore core, UIType menuType, int width, int height, UIFlags flags, bool transparent)
            : base(core)
        {
            webCore = core.GetService<IUIManagerService>().GetWebCore();
            this.menuType = menuType;
            this.width = width;
            this.height = height;
            this.flags = flags;
            this.isTransparent = transparent;
            isLoading = false;
            pageLoaded = false;
            webTextureID = TextureFactory.CreateTexture(width, height, isTransparent);
            hudPosX = 0;
            hudPosY = 0;
            hud = new TVScreen2DImmediate();
            Keyboard = core.GetService<IKeyboardService>();
            Mouse = core.GetService<IMouseService>();
            JoyStick = core.GetService<IJoyStickService>();
            Gamepad = core.GetService<IGamepadsService>();

            CanculateHudPosition(flags);

            View = webCore.CreateWebView(width, height, isTransparent, true);
            View.OnFinishLoading += OnFinishLoading;
            View.OnCallback += OnCallback;
            View.Focus();

            buttonClickSound = Core.GetService<ISoundManagerService>().Load2DSound(Path.Combine(Application.StartupPath, @"Data\Sounds\menu\button_click.mp3"));
            buttonFocusSound = Core.GetService<ISoundManagerService>().Load2DSound(Path.Combine(Application.StartupPath, @"Data\Sounds\menu\button_focus.mp3"));
            Core.GetService<ISoundManagerService>().SetVolume(buttonClickSound, 0.5f);
            Core.GetService<ISoundManagerService>().SetVolume(buttonFocusSound, 0.5f);
        }
Ejemplo n.º 3
0
 public void Close(UIType type)
 {
     BaseUI closeUI = null;
     if(UIInstsanceGroup.TryGetValue(type,out closeUI))
     {
         closeUI.Close();
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// 窗口信息
 /// </summary>
 /// <param name="key">标识</param>
 /// <param name="t">宿主脚本</param>
 /// <param name="resName">资源名称,如果resName为null取key.tostring()</param>
 /// <param name="wType">窗口类型</param>
 /// <param name="wEffect">窗口效果</param>
 public UIWindowInfo(UIType key, System.Type t, string resName = "", UIWindowType wType = UIWindowType.ModelType, UIWindowEffect wEffect = UIWindowEffect.Default)
 {
     Key = key;
     Owner = t;
     WinType = wType;
     WinEffect = wEffect;
     mResourceName = resName;
 }
Ejemplo n.º 5
0
		public UI(Scene scene, UIType uiType, UI parent, GameObject gameObject) : base(EntityType.UI)
		{
			this.Scene = scene;
			this.UIType = uiType;

			gameObject.transform.SetParent(parent?.GameObject.transform);
			this.GameObject = gameObject;
			this.AddComponent<ChildrenComponent<UI>>();
		}
Ejemplo n.º 6
0
 public void SendMsg(UIType type,MsgType msgType,object arg)
 {
     BaseUI UI = null;
     if(UIInstsanceGroup.TryGetValue(type,out UI))
     {
         if(UI.gameObject.activeSelf)
             UI.OnMsg(msgType,arg);
     }
 }
Ejemplo n.º 7
0
        public UI Create(Scene scene, UIType type, UI parent)
        {
            GameObject mainPrefab = Resources.Load<GameObject>("UI/LoginPanel");
            mainPrefab = Object.Instantiate(mainPrefab);
			mainPrefab.layer = LayerMask.NameToLayer(LayerNames.UI);

			UI ui = new UI(scene, type, parent, mainPrefab);
			parent.AddChild(ui);
            
            return ui;
        }
Ejemplo n.º 8
0
 public void Show(UIType type)
 {
     BaseUI showUI = null;
     if(!UIInstsanceGroup.TryGetValue(type,out showUI))
     {
         showUI = NGUITools.AddChild(gameObject,mPrefabDataGroup.First(C=>C.mType == type).mPrefab).GetComponent<BaseUI>();
         UIInstsanceGroup[type] = showUI;
     }
     showUI.gameObject.SetActive(true);
     showUI.Show();
 }
Ejemplo n.º 9
0
		public UI Create(UIType type)
		{
			try
			{
				UI ui = this.UiTypes[type].Create(this.GetOwner<Scene>(), type, this.Root);
				this.uis.Add(type, ui);
				return ui;
			}
			catch (Exception e)
			{
				throw new Exception($"{type} UI 错误: {e}");
			}
		}
Ejemplo n.º 10
0
        public TypeProperty(string canonicalName, PropertyType identityPropertyType, string expectedType, UIType expectedUIType, bool mandatory, bool nullable)
        {
            CanonicalName = canonicalName;
            ExpectedType = expectedType;
            ExpectedUIType = expectedUIType;
            Mandatory = mandatory;
            IdentityPropertyType = identityPropertyType;
            Nullable = nullable;

            //string name = CanonicalName;
            //if ((name.StartsWith("<")) && (name.EndsWith(">")))
            //{
            //    name = name.Substring(1, name.Length - 2);
            //}
            //IdentityPropertyType = ConvertUtilities.ChangeType(name, PropertyType.None);
        }
Ejemplo n.º 11
0
    //页面入栈,位于栈顶,显示
    public void PushPanel(UIType uiType)
    {
        if (_panelStack == null)
        {
            _panelStack = new Stack <BasePanel>();
        }

        if (_panelStack.Count > 0)
        {
            _panelStack.Peek().OnPaused();
        }

        BasePanel panel = GetPanel(uiType);

        panel.OnEnter();
        _panelStack.Push(panel);
    }
Ejemplo n.º 12
0
        protected virtual void OnUITypeChanged()
        {
            UIType uiType = ((IXafDocumentsHostWindow)this).UIType;

            if (uiType == UIType.TabbedMDI)
            {
                SetupTabbedMdi();
            }
            else if (uiType == UIType.StandardMDI)
            {
                SetupStandardMdi();
            }
            else
            {
                SetupSdi();
            }
        }
Ejemplo n.º 13
0
    private void UISwitcher_ChangeActiveUI(UIType arg1, UIChange arg2)
    {
        switch (arg2)
        {
        case UIChange.SWITCH:
            SwitchUI(arg1);
            break;

        case UIChange.DEACTIVATE:
            DecativateUI();
            break;

        case UIChange.PREVIOUS:
            GoToPreviousUI();
            break;
        }
    }
Ejemplo n.º 14
0
    //해당 타입에 맞는 녀석들 중 최상단에 있는 것을 넘겨준다.
    public UIBasePanel GetFirstUI(UIType type)
    {
        if (ShowingPanels.Count <= 0)
        {
            return(null);
        }

        for (int i = 0; i < ShowingPanels.Count; i++)
        {
            if (ShowingPanels[i].UIType == type)
            {
                return(ShowingPanels[i]);
            }
        }

        return(null);
    }
Ejemplo n.º 15
0
    static int get_m_UIType(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UIWindowBase obj = (UIWindowBase)o;
            UIType       ret = obj.m_UIType;
            ToLua.Push(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index m_UIType on a nil value" : e.Message));
        }
    }
Ejemplo n.º 16
0
        private GameObject GetViewPrefab(UIType uiType)
        {
            if (m_ViewPrefabs == null)
            {
                m_ViewPrefabs = new Dictionary <UIType, GameObject> {
                    { UIType.mainMenu, m_MainMenuPrefab },
                    { UIType.gameHud, m_GameHudPrefab },
                    { UIType.roundCompleteView, m_RoundCompletePrefab }
                };
            }

            if (m_ViewPrefabs.ContainsKey(uiType))
            {
                return(m_ViewPrefabs[uiType]);
            }
            return(null);
        }
Ejemplo n.º 17
0
    static int set_m_UIType(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UIWindowBase obj  = (UIWindowBase)o;
            UIType       arg0 = (UIType)ToLua.CheckObject(L, 2, typeof(UIType));
            obj.m_UIType = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index m_UIType on a nil value" : e.Message));
        }
    }
Ejemplo n.º 18
0
        public void Connect(string ip, int port, UnityAction callback = null)
        {
            if (socket != null && socket.Connected)
            {
                callback?.Invoke();
                Debug.Log("Connect fail, already connected");
                return;
            }

            if (isConnecting)
            {
                if (callback != null)
                {
                    lock (connectCallbackList)
                    {
                        connectCallbackList.Enqueue(callback);
                    }
                }
                Debug.Log("Connect fail, isConnecting");
                return;
            }
            InitState();

            socket.NoDelay = true;
            isConnecting   = true;

            MonoMgr.Instance.StartDelayEvent(2000, () =>
            {
                if (socket == null || !socket.Connected)
                {
                    UIType <string> warnText = new UIType <string>(UICacheKeys.MESSAGE_STRING, "网络连接失败");
                    UIMgr.Instance.ShowPanel <WarnBox>(UIPanelPath.WARN_MESSAGE_BOX);
                }
            });

            if (callback != null)
            {
                lock (connectCallbackList)
                {
                    connectCallbackList.Enqueue(callback);
                }
            }

            socket.BeginConnect(ip, port, ConnectCallback, socket);
        }
Ejemplo n.º 19
0
        private void ResumeView(UIType uiType, ViewBase ui, OnGetViewBaseHandler onResumUI)
        {
            if (ui != null)
            {
                ChangeUIViewDepthBySetParent(ui.transform, ui.uiMenuDepth);
                ui.transform.localPosition = Vector3.zero;
                ui.transform.localScale    = Vector3.one;

                _inactiveUIDic.Remove(ui.uiType);
                _activeUIDic.Add(ui.uiType, ui);

                onResumUI(ui, ui.uiType);
            }
            else
            {
                DebugUtils.LogError(DebugUtils.Type.UI, string.Format(" Can't find inactive ui, uiType = {0}", uiType));
            }
        }
Ejemplo n.º 20
0
 /// <summary>
 /// 加载有过渡loading的界面切换
 /// </summary>
 /// <param name="_sceneType"></param>
 /// <param name="_uiType"></param>
 /// <param name="_params"></param>
 public void ChangeScene(ScnType _sceneType, UIType _uiType, params object[] _params)
 {
     sceneOpenUIType   = _uiType;
     sceneOpenUIParams = _params;
     if (LastSceneType == _sceneType)
     {
         if (sceneOpenUIType == UIType.None)
         {
             return;
         }
         UIManager.Instance.OpenUI(sceneOpenUIType, false, sceneOpenUIParams);
         sceneOpenUIType = UIType.None;
     }
     else
     {
         ChangeScene(_sceneType);
     }
 }
Ejemplo n.º 21
0
        /// <summary>
        /// 显示UI
        /// </summary>
        /// <param name="_type"></param>
        void ShowUI(UIType _type)
        {
            UIPlane _uiPlane = _PlaneDictionary.TryGet(_type);

            if (_uiPlane != null)
            {
                _uiPlane.Begin();
                return;
            }
            else
            {
                _uiPlane = CreateUI(_type);
                if (_uiPlane == null)
                {
                    return;
                }
            }
        }
Ejemplo n.º 22
0
    public void ActiveteObject(UIType type, string name, bool isActive)
    {
        UIController desiredUI = UIControllers.Find(x => x.canvasType == type);

        if (desiredUI == null)
        {
            Debug.LogWarning("The desired UI was not found!");
            return;
        }
        Transform objectTransform = desiredUI.gameObject.transform.Find(name);

        if (objectTransform == null)
        {
            Debug.LogWarning("The desired object was not found!");
            return;
        }
        objectTransform.gameObject.SetActive(isActive);
    }
Ejemplo n.º 23
0
        /// <summary>
        /// 关闭界面。
        /// </summary>
        /// <param name="uiType">User interface type.</param>
        public void CloseUI(UIType _uiType)
        {
            if (dicOpenUIsCache.ContainsKey(_uiType))
            {
                dicOpenUIs.Remove(_uiType);
                dicOpenUIsCache[_uiType].SetActive(false);
                return;
            }
            GameObject _uiObj = null;

            if (!dicOpenUIs.TryGetValue(_uiType, out _uiObj))
            {
                Debug.Log("dicOpenUIs TryGetValue Failure! _uiType :" + _uiType.ToString());
                return;
            }

            CloseUI(_uiType, _uiObj);
        }
Ejemplo n.º 24
0
 private void SetEditMode(object obj)
 {
     if (obj is AClient)
     {
         if (obj is Client)
         {
             currentType = UIType.EditClient;
         }
         else if (obj is Entity)
         {
             currentType = UIType.EditEntity;
         }
     }
     else if (obj is Employee)
     {
         currentType = UIType.EditEmployee;
     }
 }
Ejemplo n.º 25
0
    void Awake()
    {
        UIType.InitUIType(
            false,
            false,
            false,
            UIFormTypes.Normal,
            UIFormShowModes.Normal,
            UIFormLucencyTypes.Penetrable);

        RegretButton.onClick.AddListener(LevelManager.Instance.RetractStep);
        GiveUpButton.onClick.AddListener(() =>
        {
            LevelManager.Instance.Failed();
            ResultPanel rp = UIManager.Instance.GetBaseUIForm <ResultPanel>();
            rp.SetGiveUp();
        });
    }
Ejemplo n.º 26
0
    private void Awake()
    {
        UIType.InitUIType(
            isClearStack: false,
            isESCClose: true,
            isClickElsewhereClose: true,
            uiForms_Type: UIFormTypes.Normal,
            uiForms_ShowMode: UIFormShowModes.Normal,
            uiForm_LucencyType: UIFormLucencyTypes.ImPenetrable);

        UpgradeCardButton.onClick.AddListener(OnUpgradeButtonClick);
        DegradeCardButton.onClick.AddListener(OnDegradeButtonClick);
        LanguageManager.Instance.RegisterTextKeys(new List <(Text, string)>
        {
            (UpgradeText, "SelectBuildManagerPreviewUpgrade_UpgradeText"),
            (DegradeText, "SelectBuildManagerPreviewUpgrade_DegradeText"),
        });
    }
Ejemplo n.º 27
0
    /// <summary>
    /// AddShow the UI_Panel from the type.
    /// </summary>
    public void AddShow(GameObject parent, UIType type)
    {
        GameObject obj = PoolManager.Instance.GetUIFromPool(type);

        if (obj == null)
        {
            Debug.Log(type.ToString());
            GameObject o = UILoader.Instance.LoadUIPanel(parent, type.ToString());
            o.SetActive(true);
            showList.Add(o);
            PoolManager.instance.AddUIPool(o);
        }
        else
        {
            obj.SetActive(true);
            showList.Add(obj);
        }
    }
Ejemplo n.º 28
0
    // 加载每一个场景的PanelManger,如果两个场景使用相同UI布局,则不释放资源
    public void Init(UIType t)
    {
        mUIType = t;

        //主UI不卸载
        if (t == UIType.Main && null != panelManger && null != UIRootObj)
        {
            return;
        }

        if (panelManger != null)
        {
            panelManger.Release();
            panelManger = null;
        }

        switch (t)
        {
        case UIType.Launch:
            panelManger = new LaunchPanelMng();
            break;

        case UIType.Login:
            panelManger = new LoginPanelMng();
            break;

        case UIType.Loading:
            panelManger = new LoadingPanelMng();
            break;

        case UIType.Main:
            panelManger = new MainPanelMng();
            break;

        default:
            //panelManger = new MainPanelMng();
            break;
        }

        if (null != panelManger)
        {
            panelManger.Init(SecendLevelUIType.None);
        }
    }
Ejemplo n.º 29
0
        public void SetBtnAtrribute(UIType func, Vector3 insertPos, bool Showing, bool defaultEnable, string AudioName)//初始化按钮属性,包括图片样式点击后返回操作等
        {
            gameObject.SetActive(false);
            this.m_buttonFunc = func;
            this.m_insertPos  = insertPos;
            m_DefaultEnable   = defaultEnable;
            m_AudioName       = AudioName;
            this.Showing      = Showing;

            if (Showing)
            {
                ShowInsertBtn();
            }

            if (defaultEnable)
            {
                ShowInsertBtn();
            }
        }
Ejemplo n.º 30
0
        //初始讀專門的配置表獲取 IsGlobal  、supportBack、WindowType
        protected void LoadDB()
        {
            var ui_info = DBUIManager.Instance.GetData(mWndName);

            if (ui_info != null)
            {
                mInfo = ui_info;

                IsGlobal   = ui_info.is_global;
                WindowType = (UIType)ui_info.ui_type;

                SubWindow.Clear();
                if (string.IsNullOrEmpty(mInfo.sub_panels) == false)
                {
                    var      raw     = mInfo.sub_panels.Replace("[", "").Replace("]", "");
                    string[] results = raw.Split(',');
                    for (int i = 0; i < results.Length; i++)
                    {
                        if (results[i].CompareTo(string.Empty) != 0)
                        {
                            SubWindow.Add(results[i]);
                        }
                    }
                }

                InitOpenWindows.Clear();
                if (string.IsNullOrEmpty(mInfo.init_open_panels) == false)
                {
                    var      raw     = mInfo.init_open_panels.Replace("[", "").Replace("]", "");
                    string[] results = raw.Split(',');
                    for (int i = 0; i < results.Length; i++)
                    {
                        if (results[i].CompareTo(string.Empty) != 0)
                        {
                            InitOpenWindows.Add(results[i]);
                        }
                    }
                }

                int static_index = mInfo.static_layer_index;
                this.staticLayerIndex = UIManager.Instance.GetLayerInfo(WindowType).GetStaticLayerIndex(static_index);
            }
        }
Ejemplo n.º 31
0
    void CreateUIGUI()
    {
        EditorGUI.indentLevel = 0;
        isFoldCreateUI        = EditorGUILayout.Foldout(isFoldCreateUI, "创建UI:");

        if (isFoldCreateUI)
        {
            EditorGUI.indentLevel = 1;
            EditorGUILayout.LabelField("提示: 脚本和 UI 名称会自动添加Window后缀");
            m_uiName = EditorGUILayout.TextField("UI Name:", m_uiName);
            m_UIType = (UIType)EditorGUILayout.EnumPopup("UI Type:", m_UIType);

            isAutoCreatePrefab = EditorGUILayout.Toggle("自动生成 Prefab", isAutoCreatePrefab);

            var l_nameTmp = m_uiName + "Window";
            if (!string.IsNullOrEmpty(m_uiName))
            {
                var l_typeTmp = EditorTool.GetType(l_nameTmp);
                if (l_typeTmp != null)
                {
                    if (l_typeTmp.BaseType.Equals(typeof(UIWindowBase)))
                    {
                        if (GUILayout.Button("创建UI"))
                        {
                            UICreateService.CreatUI(l_nameTmp, m_UIType, m_UILayerManager, isAutoCreatePrefab);
                            m_uiName = "";
                        }
                    }
                    else
                    {
                        EditorGUILayout.LabelField("该类没有继承UIWindowBase");
                    }
                }
                else
                {
                    if (GUILayout.Button("创建UI脚本"))
                    {
                        UICreateService.CreatUIScript(l_nameTmp);
                    }
                }
            }
        }
    }
Ejemplo n.º 32
0
        public void changeScene(string sceneName, UIType type, string flow)
        {
            if (!isFirstTrain)
            {
                //记录LOADING场景中需要读取的场景名称
                GlobalConfig.loadName = sceneName;
                //先进入LoadingScene场景
                SceneManager.LoadScene("LoadingScene");
                loading.SetActive(true);

                ((TrainUI)setActiveUI(type)).initTrainUI(null, flow, TrainUI.TrainMode.Training);
            }
            else
            {
                SceneManager.LoadScene("Guide");
                ((GuideHelperUI)setActiveUI(UIType.GuideUI)).setNextScene(sceneName, type, flow);
            }
            isFirstTrain = false;
        }
Ejemplo n.º 33
0
    public static T Load <T>(UIType uiType, bool active = true) where T : Component
    {
        string     path = "UI/" + uiType.ToString();
        GameObject obj  = Resources.Load <GameObject>(path);

        if (obj != null)
        {
            obj      = GameObject.Instantiate(obj);
            obj.name = uiType.ToString();
            obj.transform.SetParent(GameObject.Find("UIManager").transform);
            obj.SetActive(active);

            m_uiDic.Add(uiType, obj);

            return(obj.GetComponent <T>());
        }

        return(null);
    }
Ejemplo n.º 34
0
        UIPlane CreateUI(UIType _type)
        {
            string path = _PathDictionary.TryGet(_type);

            if (path.Equals(""))
            {
                return(null);
            }

            UIPlane _temp = (GameObject.Instantiate(Resources.Load(path)) as GameObject).GetComponent <UIPlane>();

            _temp.transform.SetParent(_CanvasTransform, false);
            _PlaneDictionary.Add(_type, _temp);

            //清除路径
            _PathDictionary.Remove(_type);

            return(_temp);
        }
Ejemplo n.º 35
0
    public int CalcuteBtn(UIType uiType, SubType subUIType, bool autoSequence)
    {
        int mainID = GetHeadID(uiType);
        int subID  = GetSubID(subUIType);
        int btnID  = mainID + subID;

        if (autoSequence)
        {
            while (m_guideBtnParam.ContainsKey(btnID))
            {
                btnID++;
            }
            //while (m_btnIDList.Exists(P => P == btnID))
            //{
            //    btnID++;
            //}
        }
        return(btnID);
    }
Ejemplo n.º 36
0
    /// <summary>
    /// 根据UIType获取UIPath(用于Resources加载)
    /// </summary>
    /// <param name="uIType"></param>
    /// <returns></returns>
    private string GetUIPathByUIType(UIType uIType)
    {
        string path = string.Empty;

        switch (uIType)
        {
        case UIType.InitUI:
            path = "UIPrefab/InitUI";
            break;

        case UIType.GameUI:
            path = "UIPrefab/GameUI";
            break;

        default:
            break;
        }
        return(path);
    }
Ejemplo n.º 37
0
        protected bool SetStyle(string tag, UIType type, SizeType row0SizeType, int row0Hight, SizeType column0SizeType, int column0Width, TableLayoutPanelCellBorderStyle tlpcs)
        {
            bool b = default(bool);

            try
            {
                this.pTag                = tag;
                this.pType               = type;
                this.tlp.RowStyles[0]    = new RowStyle(row0SizeType, row0Hight);
                this.tlp.ColumnStyles[0] = new ColumnStyle(column0SizeType, column0Width);
                this.tlp.CellBorderStyle = tlpcs;
                b = true;
            }
            catch (Exception)
            {
                b = false;
            }
            return(b);
        }
Ejemplo n.º 38
0
        public void DestoryWnd(UIType t)
        {
            UICache cache = null;

            if (mWindowInstanceList.TryGetValue(t, out cache))
            {
                mStackInstance.Pop(t);
                mWindowInstanceList.Remove(t);

                //  TODO
                cache.mOwner = null;
                GameObject.Destroy(cache.mInstance);
                Utility.LogColor("8080ff", string.Format("DestoryWnd {0}", t.ToString()));
            }
            else
            {
                Debug.Log(string.Format("mWindowInstanceList Can't find type [{0}]", t.ToString()));
            }
        }
Ejemplo n.º 39
0
    public static void OpenUI(int uiId)
    {
        UINameTable uINameTable = DataReader <UINameTable> .Get(uiId);

        if (uINameTable == null)
        {
            return;
        }
        Transform root           = WidgetSystem.GetRoot(uINameTable.parent);
        bool      hideTheVisible = false;

        if (uINameTable.hideTheVisible == 1)
        {
            hideTheVisible = true;
        }
        UIType type = (UIType)uINameTable.type;

        UIManagerControl.Instance.OpenUI(uINameTable.name, root, hideTheVisible, type);
    }
Ejemplo n.º 40
0
 //public Panel Panel
 //{
 //    get 
 //    {
 //        return panel;
 //    }
 //    set
 //    { 
 //    }
 //}
 public void UpdatePnl(UIType uis)
 {
     if (uiStatus != uis)
     {
         if (pnlIsShow)
         {
             panel.Visible = false;
             pnlIsShow = false;
         }
     }
     else
     {
         if (!pnlIsShow)
         {
             panel.Visible = true;
             pnlIsShow = true;
         }
     }
 }
Ejemplo n.º 41
0
    public int RegGuideButton(GameObject btnGO, UIType uiType, BtnMapId_Sub subUIType, Action <bool> customerActHandler)
    {
        int btnID = CalcBtnId(uiType, subUIType);

        if (btnID != 0)
        {
            if (!m_guideBtnParam.ContainsKey(btnID))
            {
                m_guideBtnParam.Add(btnID, new GuideBtnParam(btnID, btnGO, btnGO.collider.enabled, uiType, subUIType));

                if (!this.m_isEndGuide)
                {
                    SetGuideBtnStatus(m_guideBtnParam[btnID], false, false);
                }
            }
        }

        return(btnID);
    }
Ejemplo n.º 42
0
        void DrawCache()
        {
            if (CSCommonEditor.DrawHeader("Cache", "CSUI-Cache"))
            {
                var info = CSCommonEditor.GetField<Dictionary<UIType, UICache>>(UIManager.Instance, "mWindowInstanceList");
                if (info != null)
                {
                    int index = 0;
                    bool isUnload = false;

                    cacheScrollPos = GUILayout.BeginScrollView(cacheScrollPos);

                    foreach (var item in info)
                    {
                        ++index;

                        bool highlight = cacheSelectType == item.Key;
                        GUI.backgroundColor = highlight ? Color.white : new Color(0.8f, 0.8f, 0.8f);
                        GUILayout.BeginHorizontal("AS TextArea", GUILayout.MinHeight(20f));
                        GUI.backgroundColor = Color.white;
                        GUILayout.Label(index.ToString(), GUILayout.Width(24f));

                        if (GUILayout.Button(item.Key.ToString(), "OL TextField", GUILayout.Height(20f)))
                            cacheSelectType = item.Key;

                        if (cacheUnloadType.Contains(item.Key))
                        {
                            GUI.backgroundColor = Color.red;

                            if (GUILayout.Button("Delete", GUILayout.Width(60f)))
                            {
                                isUnload = true;
                            }
                            GUI.backgroundColor = Color.green;
                            if (GUILayout.Button("X", GUILayout.Width(22f)))
                            {
                                cacheUnloadType.Remove(item.Key);
                                isUnload = false;
                            }
                            GUI.backgroundColor = Color.white;
                        }
                        else
                        {
                            if (GUILayout.Button("X", GUILayout.Width(22f))) cacheUnloadType.Add(item.Key);
                        }

                        GUILayout.EndHorizontal();
                    }

                    GUILayout.EndScrollView();

                    if (isUnload)
                    {
                        string dBug = "unload item : ";
                        for (int i = 0; i < cacheUnloadType.Count; i++)
                        {
                            dBug += cacheUnloadType[i].ToString() + " ";
                        }
                        //Utility.Log(dBug);
                    }
                }
            }
        }
Ejemplo n.º 43
0
        void DrawController()
        {
            CSCommonEditor.DrawHeader("Controller");

            CSCommonEditor.BeginContents();
            GUILayout.BeginHorizontal();
            ctlSelectShowType = (UIType)EditorGUILayout.EnumPopup("Show UI Type", ctlSelectShowType);
            if (GUILayout.Button("Show"))
            {
                UIManager.Instance.ShowWnd(ctlSelectShowType);
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            ctlSelectHideType = (UIType)EditorGUILayout.EnumPopup("Hide UI Type", ctlSelectHideType);
            if (GUILayout.Button("Hide"))
            {
                UIManager.Instance.HideWnd(ctlSelectHideType);
            }
            GUILayout.EndHorizontal();
            CSCommonEditor.EndContents();

            DrawCtlTopInfo();
            DrawControllerListWnd();
        }
Ejemplo n.º 44
0
        public UIView GetByType(UIType type)
        {
            foreach (var gm in gameMenu)
            {
                if (gm.Key.MenuType.Equals(type))
                    return gm.Key;
            }

            return null;
        }
Ejemplo n.º 45
0
 public TypeProperty(string canonicalName, PropertyType identityPropertyType, string expectedType, UIType expectedUIType, bool nullable)
     : this(canonicalName, identityPropertyType, expectedType, expectedUIType, false, nullable)
 {
 }
Ejemplo n.º 46
0
    void CreateUIGUI()
    {
        EditorGUI.indentLevel = 0;
        isFoldCreateUI = EditorGUILayout.Foldout(isFoldCreateUI, "创建UI:");

        if (isFoldCreateUI)
        {
            EditorGUI.indentLevel = 1;
            EditorGUILayout.LabelField("提示: 脚本和 UI 名称会自动添加Window后缀");
            m_UIname = EditorGUILayout.TextField("UI Name:", m_UIname);
            m_UIType = (UIType)EditorGUILayout.EnumPopup("UI Type:", m_UIType);

            isUseLua = EditorGUILayout.Toggle("使用 Lua", isUseLua);
            if (isUseLua)
            {
                EditorGUI.indentLevel ++;
                isAutoCreateLuaFile = EditorGUILayout.Toggle("自动创建Lua脚本", isAutoCreateLuaFile);
                EditorGUI.indentLevel --;
            }

            isAutoCreatePrefab = EditorGUILayout.Toggle("自动生成 Prefab", isAutoCreatePrefab);

            if (m_UIname != "")
            {
                string l_nameTmp = m_UIname + "Window";

                if (!isUseLua)
                {
                    Type l_typeTmp = EditorTool.GetType(l_nameTmp);
                    if (l_typeTmp != null)
                    {
                        if (l_typeTmp.BaseType.Equals(typeof(UIWindowBase)))
                        {
                            if (GUILayout.Button("创建UI"))
                            {
                                UICreateService.CreatUI(l_nameTmp, m_UIType, m_UILayerManager, isAutoCreatePrefab);
                                m_UIname = "";
                            }
                        }
                        else
                        {
                            EditorGUILayout.LabelField("该类没有继承UIWindowBase");
                        }
                    }
                    else
                    {
                        if (GUILayout.Button("创建UI脚本"))
                        {
                            UICreateService.CreatUIScript(l_nameTmp);
                        }
                    }
                }
                else
                {
                    if (GUILayout.Button("创建UI"))
                    {
                        UICreateService.CreatUIbyLua(l_nameTmp, m_UIType, m_UILayerManager, isAutoCreatePrefab);
                        if (isAutoCreateLuaFile)
                        {
                            UICreateService.CreatUILuaScript(l_nameTmp);
                        }

                        m_UIname = "";
                    }
                }

            }
        }
    }
Ejemplo n.º 47
0
 /// <summary>
 /// Copies the contents from one param to another
 /// </summary>
 /// <param name="aParams">The parameters to copy</param>
 public void Copy(UIToggleParams aParams)
 {
     m_Name = aParams.name;
     m_ID = aParams.id;
     m_RecieveActions = aParams.recieveActions;
     m_IsSelectable = aParams.isSelectable;
     m_UISpace = aParams.uiSpace;
     m_UIType = aParams.uiType;
 }
Ejemplo n.º 48
0
        private void ToggleCreateGUI()
        {
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField(TOGGLE_EDITOR, EditorStyles.boldLabel);
            GameObject gameObject = EditorUtilities.ObjectField<GameObject>(m_InitRootGameObject, m_UIRoot);
            if (gameObject != m_UIRoot)
            {
                m_NewRoot = gameObject;
                m_NextState = State.UPDATE_ROOT;
            }
            EditorGUILayout.EndHorizontal();
            if (GUILayout.Button(BACK))
            {
                if (m_NextState == State.TOGGLE_CREATE)
                {
                    m_NextState = State.TOGGLE_SELECT;
                }
            }
            m_CreateScrollPosition = EditorGUILayout.BeginScrollView(m_CreateScrollPosition);

            if(m_ToggleParams != null)
            {
                m_ToggleParams.name = EditorGUILayout.TextField(NAME, m_ToggleParams.name);
                m_ToggleParams.id = EditorGUILayout.IntField(ID, m_ToggleParams.id);
                m_ToggleParams.isSelectable = EditorGUILayout.Toggle(SELECTABLE, m_ToggleParams.isSelectable);
                m_ToggleParams.recieveActions = EditorGUILayout.Toggle(RECIEVE_ACTIONS, m_ToggleParams.recieveActions);
                m_ToggleParams.uiSpace = (UISpace)EditorGUILayout.EnumPopup(UI_SPACE, m_ToggleParams.uiSpace);
                m_NextUIType = (UIType)EditorGUILayout.EnumPopup(UI_TYPE, m_ToggleParams.uiType);
                switch(m_ToggleParams.uiType)
                {
                    case UIType.IMAGE:
                        DrawUIImage();
                        break;
                    case UIType.LABEL:
                        DrawUILabel();
                        break;
                    case UIType.BUTTON:
                        DrawUIButton();
                        break;
                    case UIType.TEXTFIELD:
                        DrawUITextfield();
                        break;
                }
            }
            EditorGUILayout.EndScrollView();
            if(GUILayout.Button(CREATE) && m_ToggleParams.name != string.Empty)
            {
                if (GetToggle(m_ToggleParams.name) == null)
                {
                    CreateUIToggle();
                }
                else
                {
                    DebugUtils.LogError(TOGGLE_WITH_NAME_EXISTS);
                }
            }
        }
Ejemplo n.º 49
0
        private void ToggleEditGUI()
        {
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField(TOGGLE_EDITOR, EditorStyles.boldLabel);
            GameObject gameObject = EditorUtilities.ObjectField<GameObject>(m_InitRootGameObject, m_UIRoot);
            if (gameObject != m_UIRoot)
            {
                m_NewRoot = gameObject;
                m_NextState = State.UPDATE_ROOT;
            }
            EditorGUILayout.EndHorizontal();
            if (GUILayout.Button(BACK))
            {
                if (m_NextState == State.TOGGLE_EDIT)
                {
                    m_NextState = State.TOGGLE_SELECT;
                }
            }
            m_EditScrollPosition = EditorGUILayout.BeginScrollView(m_EditScrollPosition);

            if (m_ToggleParams != null && m_ToggleToEdit != null)
            {
                m_ToggleParams.name = EditorGUILayout.TextField(NAME, m_ToggleParams.name);
                m_ToggleParams.id = EditorGUILayout.IntField(ID, m_ToggleParams.id);
                m_ToggleParams.isSelectable = EditorGUILayout.Toggle(SELECTABLE, m_ToggleParams.isSelectable);
                m_ToggleParams.recieveActions = EditorGUILayout.Toggle(RECIEVE_ACTIONS, m_ToggleParams.recieveActions);
                m_ToggleParams.uiSpace = (UISpace)EditorGUILayout.EnumPopup(UI_SPACE, m_ToggleParams.uiSpace);
                m_NextUIType = (UIType)EditorGUILayout.EnumPopup(UI_TYPE, m_ToggleParams.uiType);
                switch(m_ToggleParams.uiType)
                {
                    case UIType.IMAGE:
                        DrawUIImage();
                        break;
                    case UIType.LABEL:
                        DrawUILabel();
                        break;
                    case UIType.BUTTON:
                        DrawUIButton();
                        break;
                    case UIType.TEXTFIELD:
                        DrawUITextfield();
                        break;
                }
            }
            EditorGUILayout.EndScrollView();
            if(GUILayout.Button(SAVE))
            {
                if(m_ToggleToEdit != null)
                {
                    UIToggle toggleWithName = GetToggle(m_ToggleParams.name);
                    if(toggleWithName != null && toggleWithName != m_ToggleToEdit)
                    {
                        DebugUtils.LogError(TOGGLE_WITH_NAME_EXISTS);
                    }
                    else
                    {
                        UIType previousType = m_ToggleToEdit.uiType;
                        m_ToggleToEdit.gameObject.name = m_ToggleParams.name;
                        m_ToggleToEdit.id = m_ToggleParams.id;
                        m_ToggleToEdit.selectable = m_ToggleParams.isSelectable;
                        m_ToggleToEdit.receivesActionEvents = m_ToggleParams.recieveActions;
                        m_ToggleToEdit.uiSpace = m_ToggleParams.uiSpace;
                        m_ToggleToEdit.uiType = m_ToggleParams.uiType;
                        switch(m_ToggleToEdit.uiSpace)
                        {
                            case UISpace.TWO_DIMENSIONAL:
                                if(m_2DUI != null)
                                {
                                    m_ToggleToEdit.transform.parent = m_2DUI.transform;
                                }
                                break;
                            case UISpace.THREE_DIMENSIONAL:
                                if (m_3DUI != null)
                                {
                                    m_ToggleToEdit.transform.parent = m_3DUI.transform;
                                }
                                break;
                            case UISpace.WORLD:
                                if (m_WorldUI != null)
                                {
                                    m_ToggleToEdit.transform.parent = m_WorldUI.transform;
                                }
                                break;
                        }
                        UpdateToggleByType(previousType);
                        EditorUtility.SetDirty(m_ToggleToEdit);
                    }
                }
            }
        }
Ejemplo n.º 50
0
 private void CreateParamsForType(UIType aType)
 {
     UIToggleParams tempParams = m_ToggleParams;
     DebugUtils.Log("Create params " + aType);
     switch(aType)
     {
         case UIType.IMAGE:
             m_ToggleParams = new UIImageParams();
             m_ToggleParams.uiType = UIType.IMAGE;
             m_ToggleParams.Copy(tempParams);
             break;
         case UIType.LABEL:
             m_ToggleParams = new UILabelParams();
             m_ToggleParams.uiType = UIType.LABEL;
             m_ToggleParams.Copy(tempParams);
             break;
         case UIType.BUTTON:
             m_ToggleParams = new UIButtonParams();
             m_ToggleParams.uiType = UIType.BUTTON;
             m_ToggleParams.Copy(tempParams);
             break;
         case UIType.TEXTFIELD:
             m_ToggleParams = new UITextfieldParams();
             m_ToggleParams.uiType = UIType.TEXTFIELD;
             m_ToggleParams.Copy(tempParams);
             break;
     }
 }
Ejemplo n.º 51
0
        /// <summary>
        /// Updates the toggle based on the previous type
        /// </summary>
        /// <param name="aPreviousType"></param>
        private void UpdateToggleByType(UIType aPreviousType)
        {
            if (aPreviousType != m_ToggleToEdit.uiType)
            {
                //Step 1. Remove the previous gameobjects.
                switch (aPreviousType)
                {
                    case UIType.IMAGE:
                        {
                            UIImage image = m_ToggleToEdit.GetComponentInChildren<UIImage>();
                            if (image != null)
                            {
                                DestroyImmediate(image.gameObject);
                            }
                        }
                        break;
                    case UIType.LABEL:
                        {
                            UILabel label = m_ToggleToEdit.GetComponentInChildren<UILabel>();
                            if(label != null)
                            {
                                DestroyImmediate(label.gameObject);
                            }
                        }
                        break;
                    case UIType.BUTTON:
                        {
                            UIButton button = m_ToggleToEdit.GetComponentInChildren<UIButton>();
                            if(button != null)
                            {
                                DestroyImmediate(button.gameObject);
                            }
                        }
                        break;
                    case UIType.TEXTFIELD:
                        {
                            UITextfield textfield = m_ToggleToEdit.GetComponentInChildren<UITextfield>();
                            if(BUTTON != null)
                            {
                                DestroyImmediate(textfield.gameObject);
                            }
                        }
                        break;
                }
                //Step 2. Add the new game objects
                switch (m_ToggleToEdit.uiType)
                {
                    case UIType.IMAGE:
                        {
                            UIImageParams imageParams = m_ToggleParams as UIImageParams;
                            if (imageParams != null)
                            {
                                UIUtilities.CreateUIImage(imageParams, m_ToggleToEdit);
                            }
                        }
                        break;
                    case UIType.LABEL:
                        {
                            UILabelParams labelParams = m_ToggleParams as UILabelParams;
                            if(labelParams != null)
                            {
                                UIUtilities.CreateUILabel(labelParams, m_ToggleToEdit);
                            }
                        }
                        break;
                    case UIType.BUTTON:
                        {
                            UIButtonParams buttonParams = m_ToggleParams as UIButtonParams;
                            if(buttonParams != null)
                            {
                                UIUtilities.CreateUIButton(buttonParams, m_ToggleToEdit);
                            }
                        }
                        break;
                    case UIType.TEXTFIELD:
                        {
                            UITextfieldParams textfieldParams = m_ToggleParams as UITextfieldParams;
                            if (textfieldParams != null)
                            {
                                UIUtilities.CreateUITextfield(textfieldParams, m_ToggleToEdit);
                            }
                        }
                        break;
                }
            }
            else
            {
                switch(m_ToggleToEdit.uiType)
                {
                    case UIType.IMAGE:
                        {
                            UIImage image = m_ToggleToEdit.GetComponentInChildren<UIImage>();
                            UIImageParams imageParams = m_ToggleParams as UIImageParams;
                            if(image == null || imageParams == null)
                            {
                                DebugUtils.LogError(MISSING_LABEL);
                                break;
                            }
                            image.width = imageParams.width;
                            image.height = imageParams.height;
                            image.meshBoarder = imageParams.meshBoarder;
                            image.outerUVBoarder = imageParams.outerUVBoarder;
                            image.innerUVBoarder = imageParams.innerUVBoarder;
                            image.texture = imageParams.texture;
                            image.shader = imageParams.shader;
                            image.color = imageParams.color;
                            image.material.shader = image.shader;
                            image.material.SetTexture(UIUtilities.SHADER_TEXTURE, image.texture);

                            image.GenerateMesh();
                            image.SetTexture();
                            image.SetColor();

                        }
                        break;
                    case UIType.LABEL:
                        {
                            UILabel label = m_ToggleToEdit.GetComponentInChildren<UILabel>();
                            UILabelParams labelParams = m_ToggleParams as UILabelParams;
                            if(label == null || labelParams == null)
                            {
                                DebugUtils.LogError(MISSING_LABEL);
                                break;
                            }
                            label.text = labelParams.text;
                            label.fontSize = labelParams.fontSize;
                            label.font = labelParams.font;
                            label.color = labelParams.color;
                            label.fontTexture = labelParams.fontTexture;
                            label.UpdateComponents();
                        }
                        break;
                    case UIType.BUTTON:
                        {
                            UIButton button = m_ToggleToEdit.GetComponentInChildren<UIButton>();
                            UIButtonParams buttonParams = m_ToggleParams as UIButtonParams;
                            if(button == null || buttonParams == null)
                            {
                                DebugUtils.LogError(MISSING_BUTTON);
                                break;
                            }
                            buttonParams.disabled = button.buttonState == UIButtonState.DISABLED;
                            buttonParams.disabledTexture = button.disabledTexture;
                            buttonParams.normalTexture = button.normalTexture;
                            buttonParams.hoverTexture = button.hoverTexture;
                            buttonParams.downTexture = button.downTexture;
                            buttonParams.enabledTextColor = button.enabledTextColor;
                            buttonParams.disabledTextColor = button.disabledTextColor;
                            buttonParams.eventListener = button.eventListener;

                            UILabel label = button.GetComponentInChildren<UILabel>();
                            if (label == null)
                            {
                                DebugUtils.LogError(MISSING_LABEL);
                            }
                            else
                            {
                                label.color = buttonParams.labelColor;
                                label.font = buttonParams.labelFont;
                                label.fontSize = buttonParams.labelFontSize;
                                label.fontTexture = buttonParams.labelFontTexture;
                                label.text = buttonParams.labelText;
                            }
                            UIImage image = button.GetComponentInChildren<UIImage>();
                            if (image == null)
                            {
                                DebugUtils.LogError(MISSING_IMAGE);
                            }
                            else
                            {
                                image.color = buttonParams.imageColor;
                                image.height = buttonParams.imageHeight;
                                image.width = buttonParams.imageWidth;
                                image.meshBoarder = buttonParams.imageMeshBoarder;
                                image.innerUVBoarder = buttonParams.imageInnerUVBoarder;
                                image.outerUVBoarder = buttonParams.imageInnerUVBoarder;
                                image.shader = buttonParams.imageShader;
                                image.texture = buttonParams.imageTexture;
                            }
                        }
                        break;

                    case UIType.TEXTFIELD:
                        {
                            UITextfield textfield = m_ToggleToEdit.GetComponentInChildren<UITextfield>();
                            UITextfieldParams textfieldParams = m_ToggleParams as UITextfieldParams;
                            if (textfield == null || textfieldParams == null)
                            {
                                DebugUtils.LogError(MISSING_TEXTFIELD);
                                break;
                            }
                            textfieldParams.disabled = textfield.buttonState == UIButtonState.DISABLED;
                            textfieldParams.disabledTexture = textfield.disabledTexture;
                            textfieldParams.normalTexture = textfield.normalTexture;
                            textfieldParams.hoverTexture = textfield.hoverTexture;
                            textfieldParams.downTexture = textfield.downTexture;
                            textfieldParams.enabledTextColor = textfield.enabledTextColor;
                            textfieldParams.disabledTextColor = textfield.disabledTextColor;
                            textfieldParams.eventListener = textfield.eventListener;
                            textfieldParams.maxCharacter = textfield.maxCharacter;

                            UILabel label = textfield.GetComponentInChildren<UILabel>();
                            if (label == null)
                            {
                                DebugUtils.LogError(MISSING_LABEL);
                            }
                            else
                            {
                                label.color = textfieldParams.labelColor;
                                label.font = textfieldParams.labelFont;
                                label.fontSize = textfieldParams.labelFontSize;
                                label.fontTexture = textfieldParams.labelFontTexture;
                                label.text = textfieldParams.labelText;
                            }
                            UIImage image = textfield.GetComponentInChildren<UIImage>();
                            if (image == null)
                            {
                                DebugUtils.LogError(MISSING_IMAGE);
                            }
                            else
                            {
                                image.color = textfieldParams.imageColor;
                                image.height = textfieldParams.imageHeight;
                                image.width = textfieldParams.imageWidth;
                                image.meshBoarder = textfieldParams.imageMeshBoarder;
                                image.innerUVBoarder = textfieldParams.imageInnerUVBoarder;
                                image.outerUVBoarder = textfieldParams.imageInnerUVBoarder;
                                image.shader = textfieldParams.imageShader;
                                image.texture = textfieldParams.imageTexture;
                            }
                        }
                        break;
                }
            }
        }
Ejemplo n.º 52
0
 public MainPnl(UIType uis)
     : base(uis)
 {
 }
        /// <summary>
        /// Initialize the button and register to ui
        /// </summary>
        public void Init()
        {
            Log.Debug(gameObject.name+ " Init");

            UIManager uiManager = UIManager.Instance;

            //only add collider if not yet exist
            Collider2D c = gameObject.GetComponent<Collider2D>();
            if(c == null)
            {
                //gameObject.AddComponent<PolygonCollider2D>();
                gameObject.AddComponent<BoxCollider2D>();
            }

            //Log.Debug(gameObject.name+" ============== uiType:"+uiType);
            if(uiType == UIType.Button && toggle)
                uiType = UIType.ToggleButton;

            //TODO FIXME this should NOT be here
            // if((gameObject.name.EndsWith("btn_SoundEffects")) ||
            //    (gameObject.name.EndsWith("btn_Sound")))
            // 	uiType = UIType.SoundButton;

            // if((gameObject.name.EndsWith("btn_CityHall")) ||
            //    (gameObject.name.EndsWith("btn_Engineer")) ||
            //    (gameObject.name.EndsWith("btn_Settings")) ||
            //    (gameObject.name.EndsWith("btn_LeaveScreen")) ||
            //    (gameObject.name.EndsWith("btn_MessageHead")) ||
            //    (gameObject.name.EndsWith("btn_Emails")) ||
            //    (gameObject.name.EndsWith("btn_Play")))
            // 	uiType = UIType.SettingsButton;

            // if(gameObject.name.EndsWith("btn_Earth") ||
            //    gameObject.name.EndsWith("btn_Future") ||
            //    gameObject.name.EndsWith("btn_Sun") ||
            //    gameObject.name.EndsWith("btn_Water") ||
            //    gameObject.name.EndsWith("btn_WhatIsEnergy") ||
            //    gameObject.name.EndsWith("btn_Wind"))
            // 	uiType = UIType.TouchButton;

            // TODO fix this for more cases, localization and
            //use resourcePath only if given
            if(resourcePath.Length > 0)
            {
                // Log.Info("add res:"+resourcePath);
                uiButton = (UIButton)uiManager.Add(uiType, gameObject, resourcePath);
            }
            else
            {
                ////check if we have sprite to use instead
                SpriteRenderer sr = gameObject.GetComponent<SpriteRenderer>();
                if(sr != null && sr.sprite != null)
                {
                    //TODO fix localization and find a way to load the rest of the sprites..
                    Log.Info("We have a sprite:"+gameObject.name);
                    uiButton = (UIButton)uiManager.Add(uiType, gameObject, "", sr.sprite);
                }
                else
                {
                    Log.Debug("No resource nor sprite set in button: "+gameObject.name);
                    uiButton = (UIButton)uiManager.Add(uiType, gameObject, "");

                }
            }

            uiButton.SetSpriteOrder(spriteOrder);
            Register(uiButton);

            if(text != null)
            {
                uiButton.SetTextColors(
                    upColor, downColor, overColor, disabledColor, activeColor);
                uiButton.SetText(text);
            }
        }
		}//LoadSprite()
		
		/// <summary>
		/// Adds a UI button.		
		/// </summary>
		/// <param name="obj">Parent game object.</param>
		/// <param name="fileName">Resource file name with path, relative to Rersources folder.</param>
		public UIObject Add(UIType type, GameObject obj, string fileName, Sprite spr = null)
		{
			Log.Info("Add: <color=yellow>"+obj.name+" - id:"+obj.GetComponent<GUIText>()+"</color> type:"+type);

			//// Log.GameTimes("_______________-_-_-_-_-_ <color=yellow>"+fileName+" _____ obj: "+obj+"</color>, type: "+type);


			if(images.ContainsKey(obj.GetInstanceID()))
			{
			 	//give warning, then return existing one (ignore new registration)
			 	Log.Debug("This button already registered, ignoring new registration. <color=cyan>" + obj.name+"</color> ");
			 	return images[obj.GetInstanceID()];
			}

			Sprite[] sprList = new Sprite[1];
			if(fileName.Length == 0)
			{

				if(spr == null)
				{
					Log.Debug("This button <color=yellow>"+obj.name+"</color> has no image.");
				}
				else
				{
					Log.Debug("Sprite >>>>>>>>>>>>>>>>> "+spr.name);
					sprList[0] = spr;
				}
			}
			else
			{
				sprList = LoadSprite(fileName);
			}



			UIObject image = null;
			switch(type)
			{
				case UIType.Image:
					Log.Debug("Add UIImage");
					image = new UIImage(obj, sprList);
					break;

				case UIType.Button:
					Log.Debug("Add UIButton");
					image = new UIButton(obj, sprList);
					break;

				case UIType.ToggleButton:
					Log.Debug("Add UIToggleButton");
					image = new UIToggleButton(obj, sprList);
					break;
					
				case UIType.Slider:
					Log.Debug("Add UISlider");
					image = new UISlider(obj, sprList);
					break;

				case UIType.Character:
					Log.Debug("Add UICharacter");
					image = new UICharacter(obj, sprList);
					break;

				case UIType.ChartPie:
					Log.Debug("Add UIChartPie");
					image = new UIChartPie(obj);
					break;

				case UIType.ChartLine:
					Log.Debug("Add UIChartLine");
					image = new UIChartLine(obj);
					break;

				case UIType.Checkbox:
					Log.Debug("Add Checkbox");
					image = new UICheckbox(obj, sprList);
					break;

				default:
					Log.Exception("Invalid UIType to add:" + type);
					break;
			}

			//TODO remove this
			images.Add(obj.GetInstanceID(), image);
			
			//
			//images.Add(""+lastId++, image);
			//Log.Info("Button added:"+obj.name+" image:"+image.Name);

			return image;

		}//Add()
Ejemplo n.º 55
0
 public GamePnl(Panel pnl, UIType uis, bool isShow)
 {
     panel = pnl;
     uiStatus = uis;
     PnlIsShow = isShow;
 }
Ejemplo n.º 56
0
 public void ChangeUIStatus(UIType uis)
 {
     PnlStatus = uis;
     Update();
 }
Ejemplo n.º 57
0
    void ShowBar(UIType uiType, int current)
    {
        if (isTutorial)
            return;

        if (current < 0)
            return;

        Transform[] targetT;
        switch (uiType)
        {
            case UIType.Bomb: targetT = uiBombBar; break;
            case UIType.HP: targetT = uiHpBar; break;
            case UIType.Life: targetT = uiLifeBar; break;
            default: targetT = null; break;
        }

        // targerT should not be null -> Exception.
        if (targetT == null)
            return;

        for (int ix = 0; ix < current; ++ix)
        {
            targetT[ix].gameObject.SetActive(true);
        }

        for (int ix = current; ix < targetT.Length; ++ix)
        {
            targetT[ix].gameObject.SetActive(false);
        }
    }
Ejemplo n.º 58
0
 public Pnl(UIType uis)
 {
     uiStatus = uis;
 }
		/// <summary>
		/// Remove all registered UIImages, where type is match
		/// </summary>
		public void ClearUI(UIType type)
		{
			List<int> dropList = new List<int>();

			foreach(KeyValuePair<int, UIObject> entry in images)
			{
				if(type == UIType.ALL
					|| type == entry.Value.GetType())
				{
					dropList.Add(entry.Key);
				}
			}
			foreach(int id in dropList)
			{
				images.Remove(id);
			}

			dropList.Clear();
			dropList = null;
			
		}//ClearUI()
Ejemplo n.º 60
0
		public UIFactoryAttribute(UIType type)
		{
			this.Type = type;
		}