public override void HandleType(ComponentTypeWithData componentType, BSMLParserParams parserParams) { ClickableText clickableText = componentType.component as ClickableText; if (componentType.data.TryGetValue("onClick", out string onClick)) { clickableText.OnClickEvent += delegate { if (!parserParams.actions.TryGetValue(onClick, out BSMLAction onClickAction)) { throw new Exception("on-click action '" + onClick + "' not found"); } onClickAction.Invoke(); }; } if (componentType.data.TryGetValue("clickEvent", out string clickEvent)) { clickableText.OnClickEvent += delegate { parserParams.EmitEvent(clickEvent); }; } }
public void AddMenuItem(ClickableText menuItem) { List<Transform> children = new List<Transform>(); // Unity's threading forces us to do this foreach (Transform child in contextBackground.transform) { children.Add(child); } contextBackground.transform.DetachChildren(); // Workaround because lossyScale is read-only Vector3 localScale = contextBackground.transform.localScale; localScale.y += 0.065f; contextBackground.transform.localScale = localScale; Vector3 position = contextBackground.transform.position; position.y -= 0.1f; contextBackground.transform.position = position; Transform[] childArray = children.ToArray(); // IGNORE ALL OF THIS for (int i = 0; i < childArray.Length; i++) { Transform child = childArray[i]; child.localScale = Vector3.one; child.parent = contextBackground.transform; child.GetComponentInChildren<ClickableText>().SetMaxBounds(contextBackground.renderer.bounds); // STOP IGNORING HERE Vector3 localPos = child.localPosition; float change = i + (i * 1.25f); localPos.y -= change; child.localPosition = localPos; } menuItem.SetDisplayParent(contextBackground); menuItem.Display(false); menuItem.contextObject = this; menuItems.Add(menuItem); }
public override void LoadContent() { int count = ScreenManager.Screens.Count; count--; int vzdalenost = 0; if (count != 0) { vzdalenost = ScreenManager.GraphicsDevice.Viewport.Bounds.Height / count; } for (int i = 0; i < count; i++) { int y = i * vzdalenost; y += vzdalenost / 2; Vector2 position = new Vector2(60, y); ClickableText ct = new ClickableText(this, ScreenManager.Screens[i].Name, position, MouseClick) { HorizontAlignment = TextObject.TextAlignment.Near }; Layers["Gui"].Objekty.Add(ct); } ClickableText end = new ClickableText(this, "Konec", new Vector2(ScreenManager.GraphicsDevice.Viewport.Bounds.Width - 20, ScreenManager.GraphicsDevice.Viewport.Bounds.Height - 20), EndGame) { HorizontAlignment = TextObject.TextAlignment.Far, VerticalAlignment = TextObject.TextAlignment.Far }; Layers["Gui"].Objekty.Add(end); base.LoadContent(); }
private Transform LoadClickableText(string content, Transform layout, Color color) { ClickableText _cTemp = m_TextPool.GetClickableText(); _cTemp.SetInfo(content, layout, color); m_CaptionTextList.Add(_cTemp); return(_cTemp.m_SelfTrans); }
private SubMenu AddSubMenu_Internal(string text, string hintText, bool addBackButton, SubMenu subMenu = null) { if (viewController == null) { throw new Exception("You cannot add a submenu using this method outside of the settings menu."); } if (subMenu == null) { _subSubMenus.TryGetValue(text, out subMenu); if (subMenu == null) { subMenu = SettingsUI.CreateSubMenu(text, false); _subSubMenus[text] = subMenu; if (addBackButton) { subMenu.AddSubMenu("Back", "Go back to the previous menu", this); } } } GameObject gameObj = new GameObject("CustomUIText"); gameObj.SetActive(false); ClickableText clickableText = gameObj.AddComponent <ClickableText>(); clickableText.font = GameObject.Instantiate(Resources.FindObjectsOfTypeAll <TMP_FontAsset>().First(t => t.name == "Teko-Medium SDF No Glow")); clickableText.rectTransform.SetParent(transform, false); clickableText.text = text; clickableText.fontSize = 5; clickableText.color = Color.white; clickableText.rectTransform.anchorMin = new Vector2(0f, -3); clickableText.rectTransform.anchorMax = new Vector2(0f, -3); //clickableText.rectTransform.anchoredPosition = new Vector2(0f, -1f); clickableText.OnClickEvent += (eventData) => { var settingsFlowCoordinator = Resources.FindObjectsOfTypeAll <SettingsFlowCoordinator>().FirstOrDefault(); if (settingsFlowCoordinator) { var navigationController = settingsFlowCoordinator.GetPrivateField <SettingsNavigationController>("_settingsNavigationController"); settingsFlowCoordinator.InvokePrivateMethod("PopViewControllerFromNavigationController", new object[] { navigationController, null, true }); settingsFlowCoordinator.InvokePrivateMethod("PushViewControllerToNavigationController", new object[] { navigationController, subMenu.viewController, null, true }); } }; gameObj.SetActive(true); if (hintText != String.Empty) { BeatSaberUI.AddHintText(clickableText.rectTransform, hintText); } viewController?.AddSubmenuOption(clickableText.gameObject); return(subMenu); }
public void Release(ClickableText item) { ItemPack _pack = FindPackage(item, m_ClickableTextBuffer); if (_pack == null) { Debug.Log("正在释放未知的ClickableText"); } else { RecyclePackage(_pack); } }
public ClickableText GetClickableText() { ItemPack _pack = GetIdlePackage(m_ClickableTextBuffer); if (_pack == null) { _pack = new ItemPack(ClickableText.GenerateItem(m_OriginalClickableText, m_PoolLayout)); m_ClickableTextBuffer.Add(_pack); } _pack.isUseing = true; return((ClickableText)_pack.m_Item); }
void Awake() { if (instance == null) { instance = this; } else { Destroy(gameObject); return; } DontDestroyOnLoad(gameObject); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); FogOfWar.LoadContent(Content); Planet.LoadContent(Content); //.LoadContent(Content); Chunk.LoadContent(Content); NoiseGenerator.LoadTextures(Content); Space.spriteFont = Content.Load <SpriteFont>("Fonts/MainFont"); GameOptions gameOptions = new GameOptions(NumberOfSolarSystems.Normal, NumberOfPlantes.Normal, GameSpeed.Normal); // TODO move and optimize imports to LIB , for client only //Fonts.Load(Content); TODO Implement Models.Load(Content); SpaceRts.Models.Base = Models.Zhus_Base; SpaceRts.Models.Load(Content); Textures.Load(Content); Shaders.Load(Content); Space = new Space(1423, gameOptions, 3, graphics); Global.Camera = new Camera(GraphicsDevice); PlayButton = new ClickableText(PlayPosition, "Play", Space.spriteFont, Color.White, new Point(0, 0), (GameTime gameTime) => { PlayButtonClicked = true; TimePlayClicked = gameTime.TotalGameTime.TotalSeconds; }); SettingsButton = new ClickableText(PlayPosition + new Point(0, (int)Space.spriteFont.MeasureString("Play").Y + 50), "Settigs", Space.spriteFont, Color.White, new Point(0, 0), (GameTime gameTime) => { GameSteate = GameSteates.Settings; }); ExitButton = new ClickableText(PlayPosition + new Point(0, (int)Space.spriteFont.MeasureString("Settigs").Y + 50) + new Point(0, (int)Space.spriteFont.MeasureString("Play").Y + 50), "Exit", Space.spriteFont, Color.White, new Point(0, 0), (GameTime gameTime) => { Exit(); }); _planetRenderTarget = new RenderTarget2D(GraphicsDevice, (int)(GraphicsDevice.Viewport.Width * 0.625f + 1), GraphicsDevice.Viewport.Height / 2, false, SurfaceFormat.Color, DepthFormat.None); Shaders.MainMenu.Parameters["resolution"].SetValue(new Vector2(_planetRenderTarget.Width * 1.25f, _planetRenderTarget.Height)); // TODO: use this.Content to load your game content here }
public override GameObject CreateObject(Transform parent) { GameObject gameObj = new GameObject("BSMLSubmenu"); gameObj.SetActive(false); ClickableText clickableText = gameObj.AddComponent <ClickableText>(); clickableText.font = BeatSaberUI.MainTextFont; clickableText.fontSharedMaterial = BeatSaberUI.MainUIFontMaterial; clickableText.rectTransform.SetParent(parent, false); clickableText.text = "Default Text"; clickableText.fontSize = 4; clickableText.fontStyle = FontStyles.Italic; clickableText.color = Color.white; clickableText.rectTransform.sizeDelta = new Vector2(90, 8); LocalizableText localizedText = CreateLocalizableText(gameObj); ViewController submenuController = BeatSaberUI.CreateViewController <ViewController>(); SettingsMenu.SetupViewControllerTransform(submenuController); clickableText.OnClickEvent += delegate { if (flow == null) { flow = Resources.FindObjectsOfTypeAll <ModSettingsFlowCoordinator>().FirstOrDefault(); } if (flow) { flow.OpenMenu(submenuController, true, false); } }; ExternalComponents externalComponents = submenuController.gameObject.AddComponent <ExternalComponents>(); externalComponents.components.Add(clickableText); externalComponents.components.Add(clickableText.rectTransform); externalComponents.components.Add(localizedText); gameObj.SetActive(true); return(submenuController.gameObject); }
public static ClickableText GenerateItem(GameObject originalText, Transform layout) { ClickableText _item = null; GameObject _go = InstantiateObject(originalText, layout); if (_go != null) { _item = new ClickableText(); _item.m_UnderlineImage = _go.transform.FindChild("UnderlineImage").GetComponent <Image>(); _item.m_CaptionText = _go.GetComponent <Text>(); _item.m_SelfTrans = _go.GetComponent <RectTransform>(); _item.m_SelfTrans.anchoredPosition = Vector2.zero; _item.m_ContentSizeFitter = _go.GetComponent <ContentSizeFitter>(); _item.m_ClickableAera = _go.GetComponent <Button>(); _item.m_ClickableAera.onClick.AddListener(_item.OnAeraClick); _go.SetActive(false); } return(_item); }
public override GameObject CreateObject(Transform parent) { GameObject gameObject = new GameObject(); gameObject.name = "BSMLClickableText"; gameObject.SetActive(false); ClickableText clickableText = gameObject.AddComponent <ClickableText>(); clickableText.font = GameObject.Instantiate(Resources.FindObjectsOfTypeAll <TMP_FontAsset>().First(t => t.name == "Teko-Medium SDF No Glow")); clickableText.rectTransform.SetParent(parent, false); clickableText.text = "Default Text"; clickableText.fontSize = 5; clickableText.color = Color.white; clickableText.rectTransform.sizeDelta = new Vector2(90, 8); gameObject.SetActive(true); return(gameObject); }
public ChainItemPool(int initialSize, GameObject originalStarItem, GameObject originalCaptionText, GameObject originalClickableText, Transform poolLayout) { if (originalStarItem == null || originalCaptionText == null || originalClickableText == null || poolLayout == null || initialSize < 0) { throw new Exception("参数不能为null或者小于0"); } m_OriginalStarItem = originalStarItem; m_OriginalCaptionText = originalCaptionText; m_OriginalClickableText = originalClickableText; m_PoolLayout = poolLayout; m_StarItemBuffer = new List <ItemPack>(); m_CaptionTextBuffer = new List <ItemPack>(initialSize); m_ClickableTextBuffer = new List <ItemPack>(); for (int i = 0; i < initialSize; i++) { m_CaptionTextBuffer.Add(new ItemPack(CaptionText.GenerateItem(m_OriginalCaptionText, m_PoolLayout))); } m_StarItemBuffer.Add(new ItemPack(StarItem.GenerateItem(m_OriginalStarItem, m_PoolLayout))); m_ClickableTextBuffer.Add(new ItemPack(ClickableText.GenerateItem(m_OriginalClickableText, m_PoolLayout))); }
public override GameObject CreateObject(Transform parent) { GameObject gameObject = new GameObject(); gameObject.name = "BSMLClickableText"; gameObject.SetActive(false); ClickableText clickableText = gameObject.AddComponent <ClickableText>(); clickableText.font = BeatSaberUI.MainTextFont; clickableText.fontSharedMaterial = BeatSaberUI.MainUIFontMaterial; clickableText.rectTransform.SetParent(parent, false); clickableText.text = "Default Text"; clickableText.fontSize = 5; clickableText.color = Color.white; clickableText.rectTransform.sizeDelta = new Vector2(90, 8); CreateLocalizableText(gameObject); gameObject.SetActive(true); return(gameObject); }
public override GameObject CreateObject(Transform parent) { GameObject gameObj = new GameObject("BSMLSubmenu"); gameObj.SetActive(false); ClickableText clickableText = gameObj.AddComponent <ClickableText>(); clickableText.font = GameObject.Instantiate(Resources.FindObjectsOfTypeAll <TMP_FontAsset>().First(t => t.name == "Teko-Medium SDF No Glow")); clickableText.rectTransform.SetParent(parent, false); clickableText.text = "Default Text"; clickableText.fontSize = 4; clickableText.fontStyle = FontStyles.Italic; clickableText.color = Color.white; clickableText.rectTransform.sizeDelta = new Vector2(90, 8); ViewController submenuController = BeatSaberUI.CreateViewController <ViewController>(); SettingsMenu.SetupViewControllerTransform(submenuController); clickableText.OnClickEvent += delegate { ModSettingsFlowCoordinator settingsFlowCoordinator = Resources.FindObjectsOfTypeAll <ModSettingsFlowCoordinator>().FirstOrDefault(); if (settingsFlowCoordinator) { settingsFlowCoordinator.OpenMenu(submenuController, true, false); } }; ExternalComponents externalComponents = submenuController.gameObject.AddComponent <ExternalComponents>(); externalComponents.components.Add(clickableText); externalComponents.components.Add(clickableText.rectTransform); gameObj.SetActive(true); return(submenuController.gameObject); }
void Start() { animator = GetComponent <Animator>(); clickableText = ClickableText.instance; }
public static void ChooseResponse(ClickableText response, string id) { DisplayBox(false); subject.Notify(response, id); ClearResponses(); }