/* Работа с экранами несколько отличается от работы модальных окон * Модальное окно может быть в единсвенном колличестве и они в очереди открытия, одно за другим * Экрны же могут открываться сворачивая предыдущий экран, а когда экран закрывается, то разворачивается предыдущий * в этом и вся разница */ public void CreateMainScreen <TController, TView>(ControllerData paramsScreen) where TController : IControllerUI <TView> { titlePanelUIView.gameObject.SetActive(true); var id = ScreenId.GetMainScreen(); if (id == null) { Debug.LogError("ВНИМАНИЕ!!! НЕТ ГЛАВНОГО ЭКРАНА В КОНФИГЕ!!!"); return; } var controller = default(TController); controller = (TController)Activator.CreateInstance(typeof(TController)); controller.SetData(paramsScreen); var createdAction = new Action <object>((obj) => { controller.OnCreatedView(((TView)obj)); }); var prefab = GetPrefab(id, "[Screen]"); var screen = Instantiate(prefab, screenRect).GetComponent <AbstractView>(); closedActionMain = new Action(() => { controller.OnWantToCloseView((TView)(screen as object)); }); destroyActionMain = new Action(() => { controller.OnDestoyView((TView)(screen as object)); }); currentMainScreen = screen; screen.GetComponent <RectTransform>().SetSiblingIndex(-999999); createdAction?.Invoke(screen); titlePanelUIView.SetScreenConfig("Main Screen", id.Config.TitleConfig); }
public OsDecorator(Scene scene, AbstractView itemStoreView, string itemName, Vector3 positionToDisplay) : base(scene) { m_itemStoreView = itemStoreView; m_itemName = itemName; m_positionToDisplay = positionToDisplay; }
public void Init() { if (view == null) { GameObject go = GameObject.Find("GlobalDelegate"); if (go != null) { view = go.GetComponent <AbstractView>(); if (view == null) { view = go.AddComponent <AbstractView>(); } } else { go = new GameObject("GlobalDelegate"); view = go.AddComponent <AbstractView>(); } view.OnUpdate += this.update; view.OnLevelLoaded += () => { if (SceneManager.Instance != null && SceneManager.Instance.CurrentScene != null) { SceneManager.Instance.CurrentScene.UpdateGlobalLight(); } }; GameObject.DontDestroyOnLoad(go); } }
private void OnValidate() { if (closeButton == null) { closeButton = GetComponent <Button>(); } if (abstractWindow == null) { abstractWindow = GetComponent <AbstractView>(); var parrent = transform.parent; while (abstractWindow == null || parrent == null) { abstractWindow = parrent.GetComponent <AbstractView>(); if (abstractWindow == null) { parrent = parrent.parent; } else { break; } } } }
private static void HandlePlayModeStateChanged(PlayModeStateChange state) { if (state == PlayModeStateChange.ExitingEditMode) { // remove views, cache list AbstractView[] views = GameObject.FindObjectsOfType <AbstractView>(); _cachedViewPrefabs = new Object[views.Length]; int i = 0, l = views.Length; for (; i < l; ++i) { AbstractView view = views[i]; UnityEngine.Object prefabParent = PrefabUtility.GetCorrespondingObjectFromSource(view.gameObject); _cachedViewPrefabs[i] = prefabParent; DestroyImmediate(views[i].gameObject); } } else if (state == PlayModeStateChange.EnteredEditMode && _cachedViewPrefabs != null) { // restore views from cached list int i = 0, l = _cachedViewPrefabs.Length; for (; i < l; ++i) { PrefabUtility.InstantiatePrefab(_cachedViewPrefabs[i]); } } }
public static AbstractView GetViewFile(HttpContext context, AbstractView view) { var extension = view.Extension; string url = context.Request.Url.AbsolutePath; if (url.EndsWith("/")) { url = url + "index"; } if (!url.EndsWith("." + extension)) { url = url + "." + extension; } url = "/views" + url; FilePath path = context.Server.MapPath(url); if (File.Exists(path)) { var stream = File.OpenRead(path); view.File = stream; view.Path = path; return(view); } else { return(null); } }
public void initCompositionEvent(string typeArg, bool canBubbleArg, bool cancelableArg, AbstractView viewArg, string dataArg, string localeArg) { base.initUIEvent(typeArg, canBubbleArg, cancelableArg, viewArg, 0); data = dataArg; locale = localeArg; }
public override void OnInspectorGUI() { DrawDefaultInspector(); _target = (AbstractView)target; #if UNITY_4_2 Undo.RegisterUndo(_target, "AbstractViewEditor"); #elif UNITY_4_3 Undo.RecordObject(_target, "AbstractViewEditor"); #endif GUILayout.Label("VIEW", EditorStyles.boldLabel); EditorGUILayout.HelpBox("I WANT THIS VIEW TO", MessageType.None); _target.showingType = (AbstractView.ShowingTypes)EditorGUILayout.EnumPopup(_target.showingType); GUILayout.Label("In Transition"); _target.inTransition = (AnimationClip)EditorGUILayout.ObjectField(_target.inTransition, typeof(AnimationClip), true); GUILayout.Label("Out Transition"); _target.outTransition = (AnimationClip)EditorGUILayout.ObjectField(_target.outTransition, typeof(AnimationClip), true); if (GUILayout.Button("Save View")) { PrefabUtility.ReplacePrefab(_target.gameObject, PrefabUtility.GetPrefabParent(_target.gameObject), ReplacePrefabOptions.ConnectToPrefab); } if (GUILayout.Button("Move to library")) { PrefabUtility.ReplacePrefab(_target.gameObject, PrefabUtility.GetPrefabParent(_target.gameObject), ReplacePrefabOptions.ConnectToPrefab); UnityEditor.Editor.DestroyImmediate(_target.gameObject); } EditorUtility.SetDirty(_target); }
protected void SetupClosableView(AbstractView abstractView) { SetupView(abstractView); var closableView = abstractView.GetComponent <IClosableView>(); var closableViewController = _closableViewControllerFactory.Create(closableView); }
/// <summary> /// Следуюшее окно /// </summary> private void OpenScreen(WindowQueue windowQueue) { var rml = stackScreen.RemoveAll(x => x == null); foreach (var screen in stackScreen) { screen.Hide(); } if (stackScreen != null) { var prefab = windowQueue.Prafab; var param = windowQueue.ParamsModal; var screenElement = windowQueue.ScreenElement; var screen = Instantiate(prefab, screenRect).GetComponent <AbstractView>(); screenElement.ViewElement = screen; OpenedScreens[screen] = screenElement; var config = screenElement.Id.Config.TitleConfig; titlePanelUIController.SetScreenConfig(screenElement.Id.Name, config); currentScreen = screen; screen.OnClose += OnCloseCurrentScreen; screen.OnWantClose += (screenObject) => { if (OpenedScreens.ContainsKey(screenObject)) { screenElement?.OnClosed?.Invoke(screenObject); } }; screen.Init(); screenElement.OnCreated?.Invoke(screen); screen.Show(false); stackScreen.Add(screen); } }
public void UnloadThis() { _core = null; if (_dataFactory != null) { _dataFactory.Dispose(); } if (_serverFactory != null) { _serverFactory.Dispose(); } if (_modelFactory != null) { _modelFactory.Dispose(); } _dataFactory = null; _serverFactory = null; _modelFactory = null; AbstractView.DestoryAllObj(); Destroy(this); }
/// <summary> /// Следующий доступный экран /// </summary> private void NextScreen() { if (stackScreen != null && stackScreen.Count > 0) { currentScreen = stackScreen[stackScreen.Count - 1]; stackScreen[stackScreen.Count - 1].Show(true); } }
public Label(AbstractView view, string text, TextAlign textAlign) : base(view) { // Use a font as "default" label font Font = "Arial"; FontColor = Color.Black; Text = text; Align = textAlign; }
private void DrawElementCallback(Rect rect, int index, bool isActive, bool isFocused) { SerializedProperty propertyViewAsset = serializedProperty.GetArrayElementAtIndex(index); SerializedProperty propertyViewTypeID = propertyViewAsset.FindPropertyRelative("viewTypeID"); SerializedProperty propertyAssetID = propertyViewAsset.FindPropertyRelative("assetID"); string viewName = UViewEditorUtils.GetViewName(propertyViewTypeID); string assetPath = AssetDatabase.GUIDToAssetPath(propertyAssetID.stringValue); if (UViewEditorUtils.ValidateViewAsset(propertyViewAsset)) { System.Type viewType = System.Type.GetType(propertyViewTypeID.stringValue); AbstractView sceneInstance = _loadedViews.ContainsKey(viewType) ? _loadedViews[viewType] : null; bool existsInScene = sceneInstance != null; EditorGUI.LabelField(new Rect(rect.x, rect.y, rect.width, rect.height), existsInScene ? string.Format("{0} (Loaded)", viewName) : viewName, existsInScene ? EditorStyles.boldLabel : EditorStyles.label); if (existsInScene) { if (GUI.Button(new Rect(rect.x + rect.width - 145, rect.y, 90, rect.height - 4), "Apply & Unload", EditorStyles.miniButton)) { UnityEngine.Object prefabParent = PrefabUtility.GetCorrespondingObjectFromSource(sceneInstance.gameObject); GameObject gameObject = PrefabUtility.FindValidUploadPrefabInstanceRoot(sceneInstance.gameObject); PrefabUtility.ReplacePrefab(gameObject, prefabParent, ReplacePrefabOptions.ConnectToPrefab); GameObject.DestroyImmediate(sceneInstance.gameObject); } else if (GUI.Button(new Rect(rect.x + rect.width - 55, rect.y, 55, rect.height - 4), "Unload", EditorStyles.miniButton)) { GameObject.DestroyImmediate(sceneInstance.gameObject); } } else if (!existsInScene && GUI.Button(new Rect(rect.x + rect.width - 55, rect.y, 55, rect.height - 4), "Load", EditorStyles.miniButton)) { AbstractView viewAsset = AssetDatabase.LoadAssetAtPath <AbstractView>(assetPath); if (viewAsset != null) { AbstractView instance = PrefabUtility.InstantiatePrefab(viewAsset) as AbstractView; instance.SetParent(_propertyViewParent.objectReferenceValue as Transform, ViewDisplayMode.Overlay); Selection.activeGameObject = instance.gameObject; } else { Debug.LogErrorFormat("Unable to load {0} ({1}), missing an AbstractView component", viewName, assetPath); } } } else { EditorGUI.LabelField(new Rect(rect.x, rect.y, rect.width, rect.height), string.Format("{0} (Asset Missing)", viewName), EditorStyles.boldLabel); requiresRebuild = true; } }
public static void DrawViewDebugInfo(AbstractView view, ref bool foldout) { if (!EditorApplication.isPlaying) { return; } if (PrefabUtility.IsPartOfPrefabAsset(view)) { return; } foldout = EditorGUILayout.BeginFoldoutHeaderGroup(foldout, "Runtime"); if (foldout) { using (new EditorGUI.IndentLevelScope()) { //EditorGUILayout.LabelField($"Key: {GetObjString(view.InternalObjKey)}"); EditorGUILayout.LabelField("ViewState", EditorStyles.boldLabel); if (view.IsTransiting) { EditorGUILayout.HelpBox($"Transforming({view.RemainingTransitionCount} Remains)", MessageType.Warning); } else { EditorGUILayout.HelpBox(view.State.ToString(), MessageType.Info); } if (view.Actions != null) { EditorGUILayout.LabelField("Action Center", EditorStyles.boldLabel); EditorGUILayout.LabelField(view.Actions.GetType().ToString()); EditorGUILayout.LabelField($"{view.Actions.ExecutingCoroutineCount} Executing Coroutines"); if (view.Actions.ActionCount > 0) { EditorGUILayout.LabelField("Actions", EditorStyles.boldLabel); foreach (KeyValuePair <string, Delegate> pair in view.Actions.ActionMap) { EditorGUILayout.LabelField($"[{pair.Key}] {pair.Value.Method.Name}"); } } } EditorGUILayout.Space(); } } EditorGUILayout.EndFoldoutHeaderGroup(); }
public void CloseAllScreens() { foreach (var screen in new List <AbstractView>(stackScreen)) { screen.Close(); } OpenedScreens.Clear(); OpenedWindows.Clear(); stackScreen.Clear(); currentScreen = null; }
public static void CreateViewAsset(SerializedProperty property, AbstractView view) { string assetPath = AssetDatabase.GetAssetPath(view); SerializedProperty propertyViewTypeID = property.FindPropertyRelative("viewTypeID"); SerializedProperty propertyResourcePath = property.FindPropertyRelative("resourcePath"); SerializedProperty propertyAssetID = property.FindPropertyRelative("assetID"); propertyViewTypeID.stringValue = view.GetType().AssemblyQualifiedName; propertyResourcePath.stringValue = UViewEditorUtils.GetResourcePath(assetPath); propertyAssetID.stringValue = AssetDatabase.AssetPathToGUID(assetPath); }
public TextInput(AbstractView view, string placeholder, int width) : base(view) { Placeholder = placeholder; Width = width; // Use a font as "default" label font Font = "Arial"; FontColor = Color.Black; Selected = false; Content = ""; }
/// <summary> /// Экран закрылся /// </summary> private void OnCloseCurrentScreen(object screenObj) { if (stackScreen != null && stackScreen.Count > 0) { var screen = (screenObj as AbstractView); screen.OnClose -= OnCloseCurrentScreen; if (OpenedScreens.ContainsKey(screenObj)) { OnCloseView?.Invoke(screenObj as IViewUI, OpenedScreens[screenObj].Id); OnCloseScreenView?.Invoke(screenObj as IViewUI, OpenedScreens[screenObj].Id); OpenedScreens[screenObj].OnDestroy?.Invoke(screenObj); OpenedScreens.Remove(screenObj); if (OpenedScreens.Count > 0) { var openedScreen = OpenedScreens.Last(); var config = openedScreen.Value.Id.Config.TitleConfig; titlePanelUIController.SetScreenConfig(openedScreen.Value.Id.Name, config); } else { if (currentMainScreen != null) { var config = ScreenId.GetMainScreen().Config.TitleConfig; titlePanelUIController.SetScreenConfig("", config); } else { titlePanelUIController.SetScreenConfig("", TitlePanelConfig.GetEmpty()); } } } stackScreen.Remove(screen); //.RemoveAt(stackScreen.Count - 1); if (currentScreen == screen) { currentScreen = null; } } NextScreen(); if (!IsAnyOpenScreen) { if (currentMainScreen != null) { var config = ScreenId.GetMainScreen().Config.TitleConfig; titlePanelUIController.SetScreenConfig("", config); } else { titlePanelUIController.SetScreenConfig("", TitlePanelConfig.GetEmpty()); } } }
protected override bool OnSettingChange(string pageId, AbstractView currentView, AbstractView changedView) { //React to the toggles that control the visibility of the last 2 settings pages if (changedView.Id == Constants.Settings.Sp1PageVisToggle1Id) { //Make sure the changed view is a ToggleView if (!(changedView is ToggleView tView)) { return(false); } //Show/Hide the second page based on the new state of the toggle if (tView.IsEnabled) { Settings.ShowPageById(Constants.Settings.SettingsPage2Id); } else { Settings.HidePageById(Constants.Settings.SettingsPage2Id); } } else if (changedView.Id == Constants.Settings.Sp1PageVisToggle2Id) { //Make sure the changed view is a ToggleView if (!(changedView is ToggleView tView)) { return(false); } //Show/Hide the second page based on the new state of the toggle if (tView.IsEnabled) { Settings.ShowPageById(Constants.Settings.SettingsPage3Id); } else { Settings.HidePageById(Constants.Settings.SettingsPage3Id); } } else { if (LogDebug) { Console.WriteLine($"View ID {changedView.Id} does not match any views on the page."); } } return(true); }
private void OpenAbstract() { try { var vm = new AbstractViewModel(currentAbstract); var v = new AbstractView { DataContext = vm }; v.Show(); } catch (Exception ex) { LogManager.Write(ex); } }
public void LoadAllViews() { _views = new List <AbstractView>(); _viewNames = new List <string>(); UnityEngine.Object[] views = Resources.LoadAll("Views"); foreach (UnityEngine.Object o in views) { AbstractView v = (o as GameObject).GetComponent <AbstractView>(); if (v != null) { _views.Add(v); _viewNames.Add(v.name); } } }
private void SaveAndCloseAll() { int i = 0, l = _viewNames.Count; for (; i < l; ++i) { System.Type t = _abstractViews[i].GetType(); AbstractView sceneObject = GameObject.FindObjectOfType(t) as AbstractView; if (sceneObject != null) { //when you close a view, save the prefab! SaveAndClose(sceneObject.gameObject); } } }
public void UpdateLoadedViews() { _loadedViews.Clear(); Object[] gameObjects = Resources.FindObjectsOfTypeAll(typeof(AbstractView)); int i = 0, l = gameObjects.Length; for (; i < l; ++i) { AbstractView view = gameObjects[i] as AbstractView; if (!EditorUtility.IsPersistent(view)) { _loadedViews.Add(view.GetType(), view); } } }
public void initWheelEvent(string typeArg, bool canBubbleArg, bool cancelableArg, AbstractView viewArg, long detailArg, long screenXArg, long screenYArg, long clientXArg, long clientYArg, short buttonArg, EventTarget relatedTargetArg, string modifiersListArg, double deltaXArg, double deltaYArg, double deltaZArg, long deltaModeArg) { modifiersListArg = modifiersListArg.ToLower(); bool ctrlKeyArg = modifiersListArg.Contains("control"); bool altKeyArg = modifiersListArg.Contains("alt"); bool shiftKeyArg = modifiersListArg.Contains("shift"); bool metaKeyArg = modifiersListArg.Contains("meta"); if (modifiersListArg.Contains("altgraph")) ctrlKeyArg = altKeyArg = true; base.initMouseEvent(typeArg, canBubbleArg, cancelableArg, viewArg, detailArg, screenXArg, screenYArg, clientXArg, clientYArg, ctrlKeyArg, altKeyArg, shiftKeyArg, metaKeyArg, buttonArg, relatedTargetArg); deltaX = deltaXArg; deltaY = deltaYArg; deltaZ = deltaZArg; deltaMode = deltaModeArg; }
public static void Rebuild(SerializedProperty propertyViewAssets) { int i = 0, l = propertyViewAssets.arraySize; for (; i < l; ++i) { SerializedProperty propertyViewAsset = propertyViewAssets.GetArrayElementAtIndex(i); SerializedProperty propertyAssetID = propertyViewAsset.FindPropertyRelative("assetID"); string assetPath = AssetDatabase.GUIDToAssetPath(propertyAssetID.stringValue); AbstractView view = AssetDatabase.LoadAssetAtPath <AbstractView>(assetPath); if (view != null) { CreateViewAsset(propertyViewAsset, view); } } }
public static void RemoveViewAssets(SerializedProperty property) { SerializedProperty propertyAssetID = property.FindPropertyRelative("assetID"); string assetPath = AssetDatabase.GUIDToAssetPath(propertyAssetID.stringValue); AbstractView view = AssetDatabase.LoadAssetAtPath <AbstractView>(assetPath); if (view != null) { MonoScript script = MonoScript.FromMonoBehaviour(view); string scriptPath = AssetDatabase.GetAssetPath(script); AssetDatabase.DeleteAsset(scriptPath); } AssetDatabase.DeleteAsset(assetPath); AssetDatabase.Refresh(); }
private void CreateAllViews() { UnityEngine.Object[] views = Resources.LoadAll(_scaffoldingConfig.ViewPrefabPath()); _viewNames = new List <string>(); _abstractViews = new List <AbstractView>(); foreach (UnityEngine.Object o in views) { if (o is GameObject) { AbstractView v = (o as GameObject).GetComponent <AbstractView>(); if (v != null) { _viewNames.Add(v.GetType().Name); _abstractViews.Add(v); } } } views = null; }
/// <summary> /// 初始化模块工厂类 /// </summary> private void initModules() { //Log.info(">> 3.初始化模块工厂类"); //建立之间引用关系 //data 无权访问任何模块,只被调用,做读取、写入 //ctrl 只被view调用,不实现任何业务逻辑,而是选择想要的model,处理数据。 //server 只能调用model,将数据交给model处理 //model 操作data,操作server发送数据给服务器;处理后的消息,通过信号or事件通知视图View _dataFactory = new DataFactory(); _serverFactory = new ServerFactory(); _modelFactory = new ModelFactory(); _dataFactory.Init(); _serverFactory.Init(_modelFactory); _modelFactory.Init(_dataFactory, _serverFactory); AbstractView.Setup(_modelFactory); }
private void OnDialogComplete() { if (currentItem != null && currentItem.dialog != null) { currentItem.dialog.Enqueues = null; } collection.Complete(currentItem); //dialogManager.Play(introDialog); if (lastView) { lastView.Begin(); } lastView = null; End(); }
/// <inheritdoc /> /// <remarks> /// This is where we validate data entry and update the <see cref="AbstractActionType.ConfigPage"/> /// so that it represents the next state it should be in for configuration. /// </remarks> protected override bool OnConfigItemUpdate(AbstractView configViewChange) { if (configViewChange.Id != LogTypeSelectListId) { //When the ID being changed is not the log type select list, always save and continue. // No more configuration is needed return(true); } //Log Type selection change //Make sure the change is to a select list view if (!(configViewChange is SelectListView changedLogTypeSl)) { return(false); } //Make sure the target select list view casts correctly if (!(ConfigPage.GetViewById(LogTypeSelectListId) is SelectListView currentLogTypeSl)) { return(false); } if (currentLogTypeSl.Selection == changedLogTypeSl.Selection) { //If the selection didn't change then return false because the user may still need to supply a message return(false); } //Initialize the new state of the page so it asks for a message var newConfPage = InitConfigPageWithInput(); ConfigPage = newConfPage.Page; //Save the change to the log type select list return(true); }
public WaterWarsDecorator( WaterWarsController controller, Scene scene, AbstractView itemStoreView, string itemName, Vector3 positionToDisplay) : base(scene, itemStoreView, itemName, positionToDisplay) { m_controller = controller; }
public void initUIEvent(string type, bool canBubble, bool cancelable, AbstractView viewArg, long detailArg) { base.initEvent(type, canBubble, cancelable); view = viewArg; detail = detailArg; }
public void initFocusEvent(string typeArg, bool canBubbleArg, bool cancelableArg, AbstractView viewArg, long detailArg, EventTarget relatedTargetArg) { base.initUIEvent(typeArg, canBubbleArg, cancelableArg, viewArg, detailArg); relatedTarget = relatedTargetArg; }
public void initKeyboardEvent(string typeArg, bool canBubbleArg, bool cancelableArg, AbstractView viewArg, string charArg, string keyArg, long locationArg, string modifiersListArg, bool repeatArg, string localeArg) { base.initUIEvent(typeArg, canBubbleArg, cancelableArg, viewArg, 0); DecodeModifiersString(modifiersListArg); @char = charArg; key = keyArg; location = locationArg; repeat = repeatArg; locale = localeArg; charCode = (long)@char[0]; try { keyCode = (int)new KeysConverter().ConvertFromString(keyArg); } catch (Exception) { } which = keyCode; }
public void initMouseEvent(string typeArg, bool canBubbleArg, bool cancelableArg, AbstractView viewArg, long detailArg, long screenXArg, long screenYArg, long clientXArg, long clientYArg, bool ctrlKeyArg, bool altKeyArg, bool shiftKeyArg, bool metaKeyArg, short buttonArg, EventTarget relatedTargetArg) { base.initUIEvent(typeArg, canBubbleArg, cancelableArg, viewArg, detailArg); screenX = screenXArg; screenY = screenYArg; clientX = clientXArg; clientY = clientYArg; ctrlKey = ctrlKeyArg; shiftKey = shiftKeyArg; altKey = altKeyArg; metaKey = metaKeyArg; button = buttonArg; relatedTarget = relatedTargetArg; }