Exemplo n.º 1
0
 public WindowQueue(ScreenId id, GameObject prefab, ControllerData paramsModal, ViewElementData screenElement)
 {
     Id            = id;
     Prafab        = prefab;
     ParamsModal   = paramsModal;
     ScreenElement = screenElement;
 }
Exemplo n.º 2
0
    private void CreateScreen <TController, TView>(ScreenId id, GameObject screenObject, ControllerData paramsScreen) where TController : IControllerUI <TView>
    {
        var controller = default(TController);

        controller = (TController)Activator.CreateInstance(typeof(TController));

        controller.SetData(paramsScreen);
        var createdAction = new Action <object>((obj) => { controller.OnCreatedView((TView)obj); });
        var closedAction  = new Action <object>((obj) => { controller.OnWantToCloseView((TView)obj); });
        var destroyAction = new Action <object>((obj) => { controller.OnDestoyView((TView)obj); });
        var screenElement = new ViewElementData {
            Id = id, OnClosed = closedAction, OnCreated = createdAction, OnDestroy = destroyAction
        };

        OpenScreen(new WindowQueue(id, screenObject, paramsScreen, screenElement));
    }
Exemplo n.º 3
0
    public void CreateWindow <TController, TView>(ScreenId id, ControllerData paramsWindow, bool showOnTop = false) where TController : IControllerUI <TView>
    {
        titlePanelUIView.gameObject.SetActive(true);
        var prefab = GetPrefab(id, "[Window]");

        var target = modalRect;
        var winGo  = Instantiate(prefab, target);
        var window = winGo.GetComponent <AbstractWindow>();

        window.SetTitle(id.Name);
        var controller = (TController)Activator.CreateInstance(typeof(TController));

        controller.SetData(paramsWindow);
        var createdAction = new Action <object>((obj) => { controller.OnCreatedView((TView)obj); });
        var closedAction  = new Action <object>((obj) => { controller.OnWantToCloseView((TView)obj); });
        var destroyAction = new Action <object>((obj) => { controller.OnDestoyView((TView)obj); });

        window.OnWantClose += (z) =>
        {
            if (OpenedWindows.ContainsKey(z))
            {
                closedAction?.Invoke(z);
            }
        };
        window.OnClose += (z) =>
        {
            if (OpenedWindows.ContainsKey(z))
            {
                OpenedWindows[z].OnDestroy?.Invoke(z);
                OnCloseView?.Invoke(z as IViewUI, OpenedWindows[z].Id);
                OnCloseWindowView?.Invoke(z as IViewUI, OpenedWindows[z].Id);
                OpenedWindows.Remove(z);
                if (OpenedWindows.Count > 0)
                {
                    var last   = OpenedWindows.Last();
                    var config = last.Value.Id.Config.TitleConfig;
                }
                else
                {
                    if (IsAnyOpenScreen)
                    {
                        if (OpenedScreens.Count > 0)
                        {
                            var openedScreen = OpenedScreens.Last();
                            var config       = openedScreen.Value.Id.Config.TitleConfig;
                        }
                    }
                    else
                    {
                        if (currentMainScreen != null)
                        {
                            var config = ScreenId.GetMainScreen().Config.TitleConfig;
                            titlePanelUIController.SetScreenConfig("", config);
                        }
                        else
                        {
                            titlePanelUIController.SetScreenConfig("", TitlePanelConfig.GetEmpty());
                        }
                    }
                }
            }
        };
        createdAction.Invoke(window);

        var windowElement = new ViewElementData {
            ViewElement = window, Id = id, OnClosed = closedAction, OnCreated = createdAction, OnDestroy = destroyAction
        };

        OpenedWindows[window] = windowElement;
    }