// Use this for initialization
 public void OnSliderValueChanged(float newValue)
 {
     if (label != null)
     {
         label.SetText(newValue.ToString(format));
         OnValueChanged?.Invoke(newValue);
     }
 }
Esempio n. 2
0
        public static void ShowCalledLocationHP(CombatHUDCalledShotPopUp __instance)
        {
            try {
                if (title == null)
                {
                    title = UnityEngine.GameObject.Find("calledShot_Title")?.GetComponent <TMPro.TextMeshProUGUI>();
                    title.enableAutoSizing = false;
                    if (title == null)
                    {
                        return;
                    }
                }

                /*
                 * public void SetText(StringBuilder text);
                 * public void SetText(string text, float arg0, float arg1, float arg2);
                 * public void SetText(string text, float arg0, float arg1);
                 * public void SetText(string text, float arg0);
                 * public void SetText(string text, bool syncTextInputBox);
                 * public void SetText(string text);*/

                CombatHUDCalledShotPopUp me           = __instance;
                ArmorLocation            hoveredArmor = me.MechArmorDisplay.HoveredArmor;
                if (me.locationNameText.text.StartsWith("-"))
                {
                    title.SetText("Called Shot");
                }
                else if (me.DisplayedActor is Mech mech)
                {
                    float hp = mech.GetCurrentStructure(MechStructureRules.GetChassisLocationFromArmorLocation(hoveredArmor));
                    if (hp <= 0)
                    {
                        title.SetText("Called Shot");
                        me.locationNameText.SetText("-choose target-", ZeroObjects);
                    }
                    else
                    {
                        float mhp = mech.GetMaxStructure(MechStructureRules.GetChassisLocationFromArmorLocation(hoveredArmor)),
                              armour = mech.GetCurrentArmor(hoveredArmor), marmour = mech.GetMaxArmor(hoveredArmor);
                        title.text = me.locationNameText.text;
                        me.locationNameText.text = string.Format("{0:0}/{1:0} <#FFFFFF>{2:0}/{3:0}", hp, mhp, armour, marmour);
                    }
                }
            }                 catch (Exception ex) { Error(ex); }
        }
Esempio n. 3
0
        protected override void Awake()
        {
            // Hook up all button listeners and walkthrough event callbacks for UI updating
            m_PreviousStepButton.onClick.AddListener(OnPreviousStep);
            m_NextStepButton.onClick.AddListener(OnNextStep);
            m_MinimizeButton.onClick.AddListener(OnMinimizeMainPanel);
            m_MaximizeButton.onClick.AddListener(OnMaximizeMainPanel);
            m_PinButton.onClick.AddListener(OnPin);
            m_QuicknavButton.onClick.AddListener(OnOpenNavPanel);
            m_NavPanelBackButton.onClick.AddListener(OnBackNavPanel);
            m_NavPanelBackButton.gameObject.SetActive(false);
            m_NavPanel.gameObject.SetActive(false);
            m_WalkthroughLabel.SetText(m_Walkthrough.WalkthroughName);

            m_Walkthrough.WalkthroughChangedCallback += UpdateStepUI;

            UpdateStepUI();
            SetWorldMode(m_WorldMode);
            m_NavButtons.Clear();

            // Go through all walkthrough steps and create quick nav buttons for each
            var stepIndex        = 0;
            var buttonCount      = 0;
            var buttonParent     = m_NavButtonPrototype.transform.parent;
            var walkthroughSteps = m_Walkthrough.steps;

            foreach (var currentStep in walkthroughSteps)
            {
                // Duplicate the prototype
                var button = Instantiate(m_NavButtonPrototype, buttonParent);
                m_NavButtons.Add(button);

                // Hook up the on-click event to navigation
                var navToIndex = stepIndex;
                var buttonText = button.GetComponentInChildren <TMPro.TextMeshProUGUI>();
                if (buttonText != null)
                {
                    buttonText.SetText(walkthroughSteps[stepIndex].Description);
                }
                var toggleComp = button.GetComponent <Toggle>();
                toggleComp.onValueChanged.AddListener((bool toggleState) =>
                {
                    if (toggleState)
                    {
                        m_Walkthrough.SkipToStep(navToIndex);
                    }
                });

                buttonCount++;
                stepIndex++;
            }
            // Hide the prototype since we only want to use the instances
            m_NavButtonPrototype.gameObject.SetActive(false);
            ResizeMenuItems();
        }
Esempio n. 4
0
        void SetText()
        {
            var text = playerManager.owner.NickName;

            if (playerCombat.IsDead)
            {
                text += "(Dead)";
            }

            nameField.SetText(text);
        }
Esempio n. 5
0
        private void BeginEmptyLungStep()
        {
            counterTimer.enabled   = true;
            countdownTimer.enabled = false;
            lastEmptyLungTimeText.gameObject.SetActive(true);

            timer.BeginTimer(Mathf.Infinity);
            lastEmptyLungTimeText.SetText(breathingData.LastEmptyLungHoldingTime.ToString("F2"));

            emptyLung = true;
        }
Esempio n. 6
0
        public void SetMessage(string message, int maxWidth = -1, int maxHeight = -1)
        {
            _messagesLabel.SetText(message);

            var preferedSize = _messagesLabel.GetPreferredValues();

            var layoutElement = _messagesLabel.GetComponent <LayoutElement>();

            layoutElement.preferredWidth  = Mathf.Min(maxWidth, preferedSize.x);
            layoutElement.preferredHeight = Mathf.Min(maxHeight, preferedSize.y);
        }
        public void DoLocalize_TMPUGUILabel(string MainTranslation, string SecondaryTranslation)
        {
            {
                //--[ Localize Font Object ]----------
                                #if TextMeshPro_Pre53
                TMPro.TextMeshProFont newFont = GetSecondaryTranslatedObj <TMPro.TextMeshProFont>(ref MainTranslation, ref SecondaryTranslation);
                                #else
                TMPro.TMP_FontAsset newFont = GetSecondaryTranslatedObj <TMPro.TMP_FontAsset>(ref MainTranslation, ref SecondaryTranslation);
                                #endif

                if (newFont != null)
                {
                    if (mTarget_TMPUGUILabel.font != newFont)
                    {
                        mTarget_TMPUGUILabel.font = newFont;
                    }
                }
                else
                {
                    //--[ Localize Font Material ]----------
                    Material newMat = GetSecondaryTranslatedObj <Material>(ref MainTranslation, ref SecondaryTranslation);
                    if (newMat != null && mTarget_TMPUGUILabel.fontMaterial != newMat)
                    {
                        mTarget_TMPUGUILabel.fontMaterial = newMat;
                    }
                }
            }
            if (mInitializeAlignment)
            {
                mInitializeAlignment    = false;
                mOriginalAlignmentTMPro = mTarget_TMPUGUILabel.alignment;
            }
            if (!string.IsNullOrEmpty(MainTranslation) && mTarget_TMPUGUILabel.text != MainTranslation)
            {
                if (Localize.CurrentLocalizeComponent.CorrectAlignmentForRTL)
                {
                    if (mTarget_TMPUGUILabel.alignment <= TMPro.TextAlignmentOptions.TopJustified)
                    {
                        mTarget_TMPUGUILabel.alignment = LocalizationManager.IsRight2Left ? TMPro.TextAlignmentOptions.TopRight : mOriginalAlignmentTMPro;
                    }
                    else
                    if (mTarget_TMPUGUILabel.alignment <= TMPro.TextAlignmentOptions.Justified)
                    {
                        mTarget_TMPUGUILabel.alignment = LocalizationManager.IsRight2Left ? TMPro.TextAlignmentOptions.Right : mOriginalAlignmentTMPro;
                    }
                    else
                    {
                        mTarget_TMPUGUILabel.alignment = LocalizationManager.IsRight2Left ? TMPro.TextAlignmentOptions.BottomRight : mOriginalAlignmentTMPro;
                    }
                }
                mTarget_TMPUGUILabel.text = MainTranslation;
                mTarget_TMPUGUILabel.SetText(MainTranslation, 0);
            }
        }
Esempio n. 8
0
        public void SetMessage(string message, int maxWidth = -1, int maxHeight = -1)
        {
            m_RefMaximumSize    = new Vector2Int(maxWidth, maxHeight);
            m_SizeCheckRequired = true;

            var layoutElement = m_MessagesLabel.GetComponent <LayoutElement>();

            layoutElement.preferredWidth  = -1;
            layoutElement.preferredHeight = -1;

            m_MessagesLabel.SetText(message);
            LayoutRebuilder.MarkLayoutForRebuild(transform as RectTransform);
        }
        public void OnCommandInput(string command)
        {
            if (string.IsNullOrWhiteSpace(command))
            {
                return;
            }

            m_StringBuilder.Clear();
            m_StringBuilder.Append(m_CommandHistory.text);

            m_StringBuilder.Append('\n');
            m_StringBuilder.Append(command);

            m_CommandHistory.SetText(m_StringBuilder.ToString());

            m_OnCommandProcessed?.Invoke(command);
        }
Esempio n. 10
0
 private void UpdateText()
 {
     _messageLag += Time.deltaTime;
     if (_messageLag >= _messageRepeater)
     {
         if (_msgPointer < _texts.Count)
         {
             _textArea.SetText(_texts[_msgPointer]);
             _msgPointer++;
             _messageLag = 0;
         }
         else
         {
             _isDialog = false;
             _dialogPanel.SetActive(false);
         }
     }
 }
Esempio n. 11
0
        void UpdateStepUI()
        {
            // Conditionally activate the next and previous buttons if there are steps to move to and progression is allowed
            var currentStep = m_Walkthrough.CurrentStep;
            var stepList    = m_Walkthrough.steps;

            currentStep = Mathf.Clamp(currentStep, 0, stepList.Length - 1);
            var stepData = stepList[currentStep];

            var nextStepAvailable = currentStep < (stepList.Length - 1) && stepData.CanProgress;
            var prevStepAvailable = currentStep > 0;

            m_NextStepButton.gameObject.SetActive(nextStepAvailable);
            m_PreviousStepButton.gameObject.SetActive(prevStepAvailable);

            m_StepLabel.SetText(stepData.Description);
            m_StepCountLabel.SetText($"Step {currentStep} / {stepList.Length - 1}");

            UpdateQuickNavUI();
        }
Esempio n. 12
0
 public void SetCharacterName(string name)
 {
     m_NamePanel.SetText(name);
 }
Esempio n. 13
0
 public void SetTitle(string title)
 {
     m_TitleLabel.SetText(title);
 }
Esempio n. 14
0
 public void SetText(string text)
 {
     m_ChannelNameLabel.SetText(text);
     GetComponent <LayoutElement>().preferredWidth = Mathf.Max(120, m_ChannelNameLabel.preferredWidth * 1.5f);
 }
 private void SetSpheresCount(int visibleSpheresCount)
 {
     spheresCounter.SetText(visibleSpheresCount.ToString());
 }
Esempio n. 16
0
 internal void SetTitle(string title)
 {
     m_TitleLabel.SetText(title);
 }
 // Update is called once per frame
 void Update()
 {
     Text.SetText("Doom Level: " + GameState.Instance.DoomCounter.CurrentDoomCounter + "");
 }
Esempio n. 18
0
        public void Refresh(Item selected, bool force)
        {
            if (Items == null)
            {
                return;
            }

            var inventoryItems = new Dictionary <Item, InventoryItem>();
            var emptyCells     = new List <GameObject>();
            var groups         = Items.OrderBy(GenericSorting).ToList().GroupBy(i => i.Params.Type);
            var items          = new List <Item>();

            foreach (var group in groups)
            {
                items.AddRange(group.OrderBy(i => i.Params.Class).ThenBy(i => i.Params.Price));
            }

            if (GenericFilter != null)
            {
                items.RemoveAll(i => !GenericFilter(i));
            }

            if (!force && _initialized && _hash == JsonConvert.SerializeObject(items).GetHashCode())
            {
                var dict = new Dictionary <Item, InventoryItem>();

                for (var i = 0; i < items.Count; i++)
                {
                    var inventoryItem = _inventoryItems.ElementAt(i).Value;

                    inventoryItem.Item = items[i];
                    dict.Add(items[i], inventoryItem);
                }

                _inventoryItems = dict;

                return;
            }

            foreach (var item in items)
            {
                InventoryItem inventoryItem;

                if (_inventoryItems.ContainsKey(item))
                {
                    inventoryItem = _inventoryItems[item];
                    inventoryItem.transform.SetAsLastSibling();
                    inventoryItems.Add(item, inventoryItem);
                    _inventoryItems.Remove(item);
                }
                else
                {
                    var instance = Instantiate(item.Params.SpriteId.IsEmpty() ? ItemNoSpritesPrefab : ItemPrefab, Grid.transform);

                    inventoryItem      = instance.GetComponent <InventoryItem>();
                    inventoryItem.Item = item;
                    inventoryItems.Add(item, inventoryItem);
                }

                inventoryItem.Count.text    = item.Count.ToString();
                inventoryItem.Count.enabled = !HideCountLabels;

                if (SelectOnRefresh)
                {
                    inventoryItem.Select(item == selected);
                }
            }

            if (AddEmptyCells)
            {
                var columns = 0;
                var rows    = 0;

                switch (Grid.constraint)
                {
                case GridLayoutGroup.Constraint.FixedColumnCount:
                {
                    var height = Mathf.FloorToInt((ScrollRect.GetComponent <RectTransform>().rect.height + Grid.spacing.y) / (Grid.cellSize.y + Grid.spacing.y));

                    columns = Grid.constraintCount;
                    rows    = Mathf.Max(height, Mathf.FloorToInt((float)items.Count / columns));

                    if (Extend)
                    {
                        rows++;
                    }

                    break;
                }

                case GridLayoutGroup.Constraint.FixedRowCount:
                {
                    var width = Mathf.FloorToInt((ScrollRect.GetComponent <RectTransform>().rect.width + Grid.spacing.x) / (Grid.cellSize.x + Grid.spacing.x));

                    rows    = Grid.constraintCount;
                    columns = Mathf.Max(width, Mathf.FloorToInt((float)items.Count / rows));

                    if (Extend)
                    {
                        columns++;
                    }

                    break;
                }
                }

                for (var i = items.Count; i < columns * rows; i++)
                {
                    var existing = _emptyCells.LastOrDefault();

                    if (existing != null)
                    {
                        existing.transform.SetAsLastSibling();
                        emptyCells.Add(existing);
                        _emptyCells.Remove(existing);
                    }
                    else
                    {
                        emptyCells.Add(Instantiate(CellPrefab, Grid.transform));
                    }
                }
            }

            foreach (var instance in _inventoryItems.Values)
            {
                DestroyImmediate(instance.gameObject);
            }

            foreach (var instance in _emptyCells)
            {
                DestroyImmediate(instance);
            }

            _inventoryItems = inventoryItems;
            _emptyCells     = emptyCells;
            _initialized    = true;
            _hash           = JsonConvert.SerializeObject(items).GetHashCode();

            OnRefresh?.Invoke();

                        #if TAP_HEROES
            var gold = Items.Where(i => i.Id == "Gold").Sum(i => i.Count);

            Gold?.SetText($"{gold} <sprite=0>");

            TapHeroes.Scripts.Interface.Elements.ItemComparer.Compare(_inventoryItems.Values.ToList());
            #endif
        }
 // Update is called once per frame
 void Update()
 {
     Text.SetText(GameState.Instance.DoomCounter.GetCurrentDoomLevel().Description);
 }