Esempio n. 1
0
    static void OnProjectWindowItemOnGUI(string guid, Rect selectionRect)
    {
        string noteId = guid;

        bool isHoldingRequiredKeys = (Event.current.modifiers & EditorNotesSettings.MODIFIER_KEY) != EventModifiers.None;

        if (isHoldingRequiredKeys)                                   // user pressed the correct key
        {
            if (selectionRect.Contains(Event.current.mousePosition)) // we're drawing the item that the user is pointing on
            {
                // _________________________________________ Begin / End note _________________________________________ //
                if (!EditorNotesViewData.IsEditingNote)
                {
                    s_noteId.Set(noteId);

                    if (s_noteId.ClearDirty())
                    {
                        if (!string.IsNullOrEmpty(s_noteId.GetPrevious()))
                        {
                            OnEndNote(s_noteId.GetPrevious());
                        }

                        OnBeginNote(s_noteId.Get());
                    }
                }


                s_lastDrawTime = EditorApplication.timeSinceStartup;
            }
        }
        else if (CanEndNoteAndClose())
        {
            EndNoteAndClose();
        }


        // _________________________________________ Draw _________________________________________ //
        if (s_noteId.Get() == noteId)
        {
            EditorNotesDrawer.DrawNote(selectionRect);
            EditorNotesDrawer.DrawSelectionBorder(selectionRect);

            if (!EditorNotesViewData.IsEditingNote)
            {
                EditorNotesDrawer.DrawEditNoteButton(selectionRect);
            }
        }

        if (EditorNotesDatabase.Instance.ContainsNote(noteId))
        {
            EditorNotesDrawer.DrawNoteIcon(selectionRect);
        }



        s_requestRepaint = isHoldingRequiredKeys || EditorNotesViewData.IsEditingNote; // needed for responsive UI
    }
    protected override void OnGamePresentationUpdate()
    {
        _lifePoints.Set(Cache.GroupLifePoints);

        if (_lifePoints.ClearDirty())
        {
            _counterText.text = _lifePoints.Get().ToString();
        }
    }
    private void UpdateView()
    {
        if (_messagePosition.ClearDirty())
        {
            _container.transform.position = (Vector3)_messagePosition.Get();
        }

        if (_displayedMessage.ClearDirty())
        {
            if (_displayedMessage.Get().HasValue)
            {
                _container.SetActive(true);
                _text.text = _displayedMessage.Get().Value.ToString();
            }
            else
            {
                _container.SetActive(false);
            }
        }
    }
    protected override IEnumerator SurveyRoutine(Context context, List <GameAction.ParameterData> result, System.Action complete, System.Action cancel)
    {
        _currentNumber.Set(0);

        while (!_clicked)
        {
            yield return(null);
        }

        // wait for punch anim to be done
        while (_clickAnim != null && _clickAnim.IsPlaying())
        {
            yield return(null);
        }

        yield return(new WaitForSeconds(_finishPauseDuration));

        result.Add(new GameActionParameterSuccessRate.Data((SurveySuccessRating)_currentNumber.Get()));
        complete();
    }
 private void UpdateSuggestionList()
 {
     if (_tryDisplaySuggestions.ClearDirty() || _inputText.ClearDirty())
     {
         if (_tryDisplaySuggestions.Get())
         {
             _suggestionList.DisplaySuggestionsFor(_inputText.Get());
         }
         else
         {
             _suggestionList.Hide();
         }
     }
 }
Esempio n. 6
0
    protected override void OnGamePresentationUpdate()
    {
        if (SimWorld.TryGetComponent(SimEntity, out DoodleId doodleId))
        {
            _doodleAssetGuid.Set(doodleId.Guid);
        }
        else
        {
            _doodleAssetGuid.Set(Guid.Empty);
        }

        if (_doodleAssetGuid.ClearDirty())
        {
            _doodleAsset.Set(PlayerAssetManager.Instance.GetAsset <PlayerDoodleAsset>(_doodleAssetGuid.Get()));
        }

        if (_doodleAsset.ClearDirty())
        {
            var previousDoodle = _doodleAsset.GetPrevious();
            var newDoodle      = _doodleAsset.Get();

            if (previousDoodle != null)
            {
                previousDoodle.SpriteUpdated -= SetSprite;
            }

            if (newDoodle != null)
            {
                SetSprite(newDoodle.Sprite);
                newDoodle.SpriteUpdated += SetSprite;
            }
            else
            {
                SetSprite(null);
            }
        }
    }
Esempio n. 7
0
 public TurnState GetState()
 {
     return(_viewState.Get());
 }
        //public void SetMiniFormat(bool miniFormat)
        //{
        //    _miniFormat = miniFormat;
        //    _channels.SetActive(!miniFormat);
        //    _channelsToggle.SetActive(!miniFormat);
        //    _buildIdText.gameObject.SetActive(!miniFormat);
        //    _lines.gameObject.SetActive(!miniFormat);
        //    _fullBackground.SetActive(!miniFormat);
        //    _smallBackground.SetActive(miniFormat);
        //    _inputField.text = "";
        //}

        public void ConsoleUpdate()
        {
            if (IsAnyToggleKeyPressed())
            {
                SetOpen(!IsOpen());
                //if (IsOpen())
                //{
                //    if (_miniFormat && _inputField.text.Length == 0)
                //    {
                //        SetMiniFormat(false);
                //    }
                //    else
                //    {
                //        SetOpen(false);
                //    }
                //}
                //else
                //{
                //    SetOpen(true);
                //    SetMiniFormat(true);
                //}
            }

            if (!IsOpen())
            {
                return;
            }

            _canvasScaler.scaleFactor = s_consoleScale * 1.36f; // 1.36 being the 'default' scale

            // This is to prevent clicks outside input field from removing focus
            _inputField.ActivateInputField();

            _inputText.Set(_inputField.text);

            if (string.IsNullOrEmpty(_inputField.text))
            {
                _tryDisplaySuggestions.Set(false);
            }
            else if (_inputText.IsDirty && !string.IsNullOrEmpty(_inputText.Get()))
            {
                _tryDisplaySuggestions.Set(true);
            }

            UpdateSuggestionList();

            if (!_suggestionList.gameObject.activeSelf)
            {
                if (Input.GetKeyDown(KeyCode.UpArrow))
                {
                    _inputField.text     = GameConsole.HistoryUp();
                    _wantedCaretPosition = _inputField.text.Length;
                    _inputText.Set(_inputField.text);
                    _inputText.ClearDirty();
                }
                else if (Input.GetKeyDown(KeyCode.DownArrow))
                {
                    _inputField.text          = GameConsole.HistoryDown();
                    _inputField.caretPosition = _inputField.text.Length;
                    _inputText.Set(_inputField.text);
                    _inputText.ClearDirty();
                }
            }
            else
            {
                GameConsole.HistoryDownCompletely();
            }

            if (_submitCommandKeys.Any(k => Input.GetKeyDown(k)))
            {
                OnSubmit(_inputField.text);
            }

            HandleScrollInput();
        }