public void LoadContent(ContentManager content) { mLibSans72 = content.Load <SpriteFont>("LibSans72"); mLibSans14 = content.Load <SpriteFont>("LibSans14"); mLibSans20 = content.Load <SpriteFont>("LibSans20"); mSingularityText = content.Load <Texture2D>("SingularityText"); mSingularityLogo = content.Load <Texture2D>("Logo"); mStatisticsWindow = new WindowObject("// Statistics", new Vector2((mScreenSize.X - mScreenSize.X / 2) / 2, mScreenSize.Y - (mScreenSize.Y / 2.8f) - 20), new Vector2(mScreenSize.X / 2, mScreenSize.Y / 2.8f), Color.White, new Color(0.467f, 0.534f, 0.6f, 0.8f), 10, 20, false, mLibSans20, mDirector, EScreen.LoseScreen) { Active = false }; mStatisticsWindow.AddItem(new TextAndAmountIWindowItem("Units created: ", mDirector.GetStoryManager.UnitsCount["created"], Vector2.Zero, new Vector2(mStatisticsWindow.Size.X, mLibSans14.MeasureString("A").Y), mLibSans14, Color.White)); mStatisticsWindow.AddItem(new TextAndAmountIWindowItem("Units lost: ", mDirector.GetStoryManager.UnitsCount["lost"], Vector2.Zero, new Vector2(mStatisticsWindow.Size.X, mLibSans14.MeasureString("A").Y), mLibSans14, Color.White)); mStatisticsWindow.AddItem(new TextAndAmountIWindowItem("Units killed: ", mDirector.GetStoryManager.UnitsCount["killed"], Vector2.Zero, new Vector2(mStatisticsWindow.Size.X, mLibSans14.MeasureString("A").Y), mLibSans14, Color.White)); mStatisticsWindow.AddItem(new TextAndAmountIWindowItem("Resources created: ", mDirector.GetStoryManager.ResourcesCount.Sum(x => x.Value), Vector2.Zero, new Vector2(mStatisticsWindow.Size.X, mLibSans14.MeasureString("A").Y), mLibSans14, Color.White)); mStatisticsWindow.AddItem(new TextAndAmountIWindowItem("Platforms created: ", mDirector.GetStoryManager.PlatformsCount["created"], Vector2.Zero, new Vector2(mStatisticsWindow.Size.X, mLibSans14.MeasureString("A").Y), mLibSans14, Color.White)); mStatisticsWindow.AddItem(new TextAndAmountIWindowItem("Platforms lost: ", mDirector.GetStoryManager.PlatformsCount["lost"], Vector2.Zero, new Vector2(mStatisticsWindow.Size.X, mLibSans14.MeasureString("A").Y), mLibSans14, Color.White)); mStatisticsWindow.AddItem(new TextAndAmountIWindowItem("Platforms destroyed: ", mDirector.GetStoryManager.PlatformsCount["destroyed"], Vector2.Zero, new Vector2(mStatisticsWindow.Size.X, mLibSans14.MeasureString("A").Y), mLibSans14, Color.White)); var measuredButtonStringSize = mLibSans20.MeasureString("Main Menu"); var buttonPositionX = mScreenSize.X - measuredButtonStringSize.X - 20; var buttonPositionY = 20; mMainMenuButton = new Button("Main Menu", mLibSans20, new Vector2(buttonPositionX, buttonPositionY), Color.White, true) { Opacity = 1f }; mMainMenuButton.ButtonReleased += ReturnToMainMenu; }
protected override void OnValidate() { base.OnValidate(); if (Application.isPlaying == false) { return; } if (this.windowObject == null) { this.windowObject = this.GetComponent <WindowObject>(); } if (this.windowObject == null && this.rootScaler == null) { this.rootScaler = ME.Utilities.FindReferenceParent <CanvasScaler>(this); if (this.rootScaler != null) { this.rootTransform = this.rootScaler.transform as RectTransform; } } if (this.rect == null) { this.rect = this.GetComponent <RectTransform>(); this.rect.anchorMin = Vector2.one * 0.5f; this.rect.anchorMax = Vector2.one * 0.5f; this.rect.pivot = Vector2.one * 0.5f; } this.Calculate(); }
public void FindRootWindowObject() { var objs = this.GetComponentsInParent<WindowObject>(true); if (objs == null || objs.Length == 0) return; this.windowObject = objs[0]; }
public void UnRegister(WindowObject instance, WindowEvent windowEvent) { var key = UIWSMath.GetKey(instance.GetHashCode(), (int)windowEvent); if (this.cache.ContainsKey(key) == true) { this.cache[key] = null; } }
void OnEnable() { for (int i = 0; i < 3; i++) { WindowObject obj = ScriptableObject.CreateInstance <WindowObject>(); obj.index = i; this.m_windows.Add(obj); } }
public void UnRegister(WindowObject instance, WindowEvent windowEvent, System.Action callback) { var key = UIWSMath.GetKey(instance.GetHashCode(), (int)windowEvent); if (this.cache.TryGetValue(key, out var actions) == true) { actions -= callback; this.cache[key] = actions; } }
public void Dispose() { this.internalCall = default; this.animationComplete = default; this.hierarchyComplete = default; this.baseComplete = default; this.instance = null; this.parameters = default; PoolClass <ShowHideClosureParametersClass> .Recycle(this); }
public void FindRootWindowObject() { var objs = this.GetComponentsInParent <WindowObject>(true); if (objs == null || objs.Length == 0) { return; } this.windowObject = objs[0]; }
public static void SetResetState(WindowObject instance) { if (instance.animationParameters == null) { return; } var state = instance.animationParameters.GetResetState(); instance.animationParameters.ApplyState(state); }
void IWindowContainer.AddChild(WindowObject child) { if (child is Widget) { AddChild((Widget)child); } else { throw new ArgumentException(nameof(child)); } }
public void DeInitialize(WindowObject handler) { if (this.play == WindowEvent.None && this.stop == WindowEvent.None) { return; } var events = WindowSystem.GetEvents(); events.UnRegister(handler, this.play, this.onPlayCallback); events.UnRegister(handler, this.stop, this.onStopCallback); this.onPlayCallback = null; this.onStopCallback = null; }
public void Initialize(WindowObject handler) { if (this.play == WindowEvent.None && this.stop == WindowEvent.None) { return; } this.onPlayCallback = this.DoPlay; this.onStopCallback = this.DoStop; var events = WindowSystem.GetEvents(); events.Register(handler, this.play, this.onPlayCallback); events.Register(handler, this.stop, this.onStopCallback); }
public bool RemoveChild(WindowObject child) { var childWidget = child as Widget; if (child.Parent != this) { return(false); } if (childWidget == null) { throw new ArgumentException(nameof(child)); } m_children.Remove(childWidget); return(true); }
public void Raise(WindowObject instance, WindowEvent windowEvent) { var key = UIWSMath.GetKey(instance.GetHashCode(), (int)windowEvent); { if (this.cache.TryGetValue(key, out var actions) == true) { actions.Invoke(); } } { if (this.cacheOnce.TryGetValue(key, out var actions) == true) { actions.Invoke(); this.cacheOnce.Remove(key); } } }
public void Clear(WindowObject instance) { for (int i = 0; i < this.eventsCount; ++i) { var key = UIWSMath.GetKey(instance.GetHashCode(), i); { if (this.cache.ContainsKey(key) == true) { this.cache[key] = null; } } { if (this.cacheOnce.ContainsKey(key) == true) { this.cacheOnce[key] = null; } } } }
internal static bool FocusNext(IFocusableWidget widget) { WindowObject obj = widget as WindowObject; if (obj == null) { throw new ArgumentException(nameof(widget) + " is not a WindowObject!"); } IWindowContainer window = obj.Window; if (window == null) { return(false); } List <WindowObject> focusables = new List <WindowObject>(); Window.FindChildren(window, (WindowObject arg) => arg is IFocusableWidget, focusables); WindowObject nextFocusable = null; for (int i = 0; i < focusables.Count; i++) { if (focusables[i] == widget) { nextFocusable = focusables[(i + 1) % focusables.Count]; break; } } if (nextFocusable == null || nextFocusable == widget) { return(false); // do nothing } UpdateFocus((IFocusableWidget)nextFocusable, true); return(true); }
protected override void OnLoadScreenAsync(System.Action onComplete) { if (this.autoLoad == true) { this.LoadAsync <WindowObject>(this.prefab, (instance) => { if (instance != null) { instance.DoLoadScreenAsync(() => { base.OnLoadScreenAsync(onComplete); }); this.loadedAsset = instance; } else { base.OnLoadScreenAsync(onComplete); } }); return; } base.OnLoadScreenAsync(onComplete); }
public static void Hide <T>(T closureParameters, WindowObject instance, TransitionParameters parameters, System.Action <T> onComplete) { WindowObjectAnimation.Play(closureParameters, AnimationState.Hide, instance.animationParameters, parameters, onComplete); }
public bool RemoveChild(WindowObject child) { return(m_contentView.RemoveChild(child)); }
private IEnumerator InitLayoutInstance(LayoutWindowType windowInstance, WindowObject root, WindowLayout windowLayout, HashSet <WindowLayout> used, System.Action onComplete, bool isInner = false) { if (((ILayoutInstance)root).windowLayoutInstance != null) { if (onComplete != null) { onComplete.Invoke(); } yield break; } if (windowLayout.createPool == true) { WindowSystem.GetPools().CreatePool(windowLayout); } var windowLayoutInstance = WindowSystem.GetPools().Spawn(windowLayout, root.transform); windowLayoutInstance.isRootLayout = (isInner == false); if (isInner == true) { windowLayoutInstance.canvasScaler.enabled = false; } windowLayoutInstance.Setup(windowInstance); windowLayoutInstance.SetCanvasOrder(0); root.RegisterSubObject(windowLayoutInstance); ((ILayoutInstance)root).windowLayoutInstance = windowLayoutInstance; this.ApplyLayoutPreferences(this.layoutPreferences); windowLayoutInstance.SetTransformFullRect(); used.Add(this.windowLayout); var arr = this.components; for (int i = 0; i < arr.Length; ++i) { var layoutComponent = arr[i]; if (layoutComponent.windowLayout != windowLayout) { continue; } var layoutElement = windowLayoutInstance.GetLayoutElementByTagId(layoutComponent.tag); if (layoutComponent.componentInstance == null) { layoutElement.Setup(windowInstance); if (layoutComponent.component.IsEmpty() == false) { var index = i; var resources = WindowSystem.GetResources(); var loaded = false; yield return(resources.LoadAsync <WindowComponent>(windowInstance, layoutComponent.component, (asset) => { if (asset == null) { Debug.LogWarning("Component is null while component resource not empty. Skipped."); return; } var instance = layoutElement.Load(asset); instance.SetInvisible(); layoutComponent.componentInstance = instance; arr[index] = layoutComponent; instance.DoLoadScreenAsync(() => { loaded = true; }); })); while (loaded == false) { yield return(null); } } arr[i] = layoutComponent; } if (layoutElement.innerLayout != null) { if (used.Contains(layoutElement.innerLayout) == false) { yield return(this.InitLayoutInstance(windowInstance, layoutElement, layoutElement.innerLayout, used, null, isInner: true)); } else { Debug.LogWarning("Ignoring inner layout because of a cycle"); } } } if (onComplete != null) { onComplete.Invoke(); } }
/// <summary> /// The on context created. /// </summary> /// <param name="browser"> /// The browser. /// </param> /// <param name="frame"> /// The frame. /// </param> /// <param name="context"> /// The context. /// </param> protected override void OnContextCreated(CefBrowser browser, CefFrame frame, CefV8Context context) { #region Initialize var global = context.GetGlobal(); #endregion #region Exposed CefV8Value exposed = CefV8Value.CreateObject(); global.SetValue("exposed", exposed, CefV8PropertyAttribute.None); #endregion #region Cef Assembly var extension = new CefAssembly(browser, frame, context); extension.CreateObject(global, new List <string>() { "mscorlib", "System", "System.Core" }); //extension.CreateObject(global, AppDomain.CurrentDomain.GetAssemblies().Where(s => //{ // if (s.GetName().Name.StartsWith("blis")) return true; // return false; //}) //.Select(s => s.GetName().Name).ToList()); #endregion #region Custom XHR var xhr = new xhrObject(browser, frame, context); global.SetValue("xHttpRequest", xhr.CreateObject(), CefV8PropertyAttribute.None); #endregion #region V8 Engine API var v8Engine = new V8EngineObject(browser, frame, context); global.SetValue("V8Engine", v8Engine.CreateObject(), CefV8PropertyAttribute.None); #endregion #region Database API var database = new DatabaseObject(browser, frame, context); global.SetValue("DB", database.CreateObject(), CefV8PropertyAttribute.None); #endregion #region Console API var console = new ConsoleObject(browser, frame, context); global.SetValue("Console", database.CreateObject(), CefV8PropertyAttribute.None); #endregion #region Window API var window = new WindowObject(browser, frame, context); global.SetValue("Window", window.CreateObject(), CefV8PropertyAttribute.None); #endregion #region Server API var server = new ServerObject(browser, frame, context, this); global.SetValue("Server", server.CreateObject(), CefV8PropertyAttribute.None); #endregion #region ChromeDevToosProtocol Object var chromeDevToolsProtocol = new ChromeDevToolsProtocol(browser, frame, context); global.SetValue("DevTools", chromeDevToolsProtocol.CreateObject(), CefV8PropertyAttribute.None); #endregion #region OnContextCreated MessageRouter.OnContextCreated(browser, frame, context); context.Dispose(); #endregion }
private IEnumerator InitLayoutInstance(LayoutWindowType windowInstance, WindowObject root, WindowLayout windowLayout, HashSet <WindowLayout> used, System.Action onComplete, bool isInner = false) { if (((ILayoutInstance)root).windowLayoutInstance != null) { if (onComplete != null) { onComplete.Invoke(); } yield break; } if (windowLayout.createPool == true) { WindowSystem.GetPools().CreatePool(windowLayout); } var windowLayoutInstance = WindowSystem.GetPools().Spawn(windowLayout, root.transform); windowLayoutInstance.isRootLayout = (isInner == false); if (isInner == true) { windowLayoutInstance.canvasScaler.enabled = false; } windowLayoutInstance.Setup(windowInstance); windowLayoutInstance.SetCanvasOrder(0); root.RegisterSubObject(windowLayoutInstance); ((ILayoutInstance)root).windowLayoutInstance = windowLayoutInstance; this.ApplyLayoutPreferences(this.layoutPreferences); windowLayoutInstance.SetTransformFullRect(); used.Add(this.windowLayout); this.loadingCount = 0; var arr = this.components; for (int i = 0; i < arr.Length; ++i) { var layoutComponent = arr[i]; if (layoutComponent.windowLayout != windowLayout) { continue; } var layoutElement = windowLayoutInstance.GetLayoutElementByTagId(layoutComponent.tag); layoutComponent.componentInstance = windowLayoutInstance.GetLoadedComponent(layoutComponent.tag); layoutElement.Setup(windowInstance); arr[i] = layoutComponent; if (layoutComponent.componentInstance == null) { if (layoutComponent.component.IsEmpty() == false) { var resources = WindowSystem.GetResources(); var data = new LoadingClosure() { index = i, element = layoutElement, windowLayoutInstance = windowLayoutInstance, layoutComponentItems = arr, instance = this, }; ++this.loadingCount; yield return(resources.LoadAsync <WindowComponent, LoadingClosure>(windowInstance, data, layoutComponent.component, (asset, closure) => { if (asset == null) { Debug.LogWarning("Component is null while component resource is not empty. Skipped."); return; } ref var item = ref closure.layoutComponentItems[closure.index]; var instance = closure.element.Load(asset); instance.SetInvisible(); closure.windowLayoutInstance.SetLoadedComponent(item.tag, instance); item.componentInstance = instance; instance.DoLoadScreenAsync(() => { --closure.instance.loadingCount; }); }));