예제 #1
0
        void Awake()
        {
            _overviewStr = new MutableString(1024);
            var renderableBindings = _inputMappingsViewModel
                                     .InputMappings
                                     .Select(bindings => {
                return(bindings
                       .Where(binding => RenderableActions.Contains(binding.Id))
                       .OrderBy(binding => RenderableActions.IndexOf(binding.Id)));
            });

            renderableBindings.Subscribe(bindings => {
                _overviewStr.Clear();
                foreach (var binding in bindings)
                {
                    _overviewStr
                    .Append("<i>")
                    .Append(binding.Group)
                    .Append("</i>")
                    .Append(" - ")
                    .Append(binding.Name)
                    .Append(": <b>")
                    .Append(binding.Binding)
                    .Append("</b>")
                    .Append(Environment.NewLine);
                }
                _overviewText.SetMutableString(_overviewStr);
            });
        }
예제 #2
0
        public static MutableString /*!*/ Read(StringIO /*!*/ self, MutableString buffer, bool eofError)
        {
            var content = self.GetReadableContent();
            int start   = self._position;
            int length  = content.GetByteCount();

            if (buffer != null)
            {
                buffer.Clear();
            }
            else
            {
                buffer = MutableString.CreateBinary();
            }

            if (start < length)
            {
                self._position = length;
                buffer.Append(content, start, length - start).TaintBy(content);
            }
            else if (eofError)
            {
                throw new EOFError("end of file reached");
            }

            return(buffer);
        }
예제 #3
0
        public static MutableString Read(StringIO /*!*/ self, [DefaultProtocol] int count, [DefaultProtocol, Optional, NotNull] MutableString buffer)
        {
            var content = self.GetReadableContent();

            if (count < 0)
            {
                throw RubyExceptions.CreateArgumentError("negative length -1 given");
            }

            if (buffer != null)
            {
                buffer.Clear();
            }

            int length = content.GetByteCount();

            if (self._position >= length)
            {
                return(null);
            }

            if (buffer == null)
            {
                buffer = MutableString.CreateBinary();
            }

            int bytesRead = Math.Min(count, length - self._position);

            buffer.Append(content, self._position, bytesRead).TaintBy(content);
            self._position += bytesRead;
            return(buffer);
        }
예제 #4
0
        private void WriteValue(MeterView widget, MutableString s, MutableString value, string unitOfMeasure = "")
        {
            s.Clear().
            Append(value)
            .Append(" ")
            .Append(unitOfMeasure);

            widget.SetValue(s);
        }
예제 #5
0
 public void Clear()
 {
     LineColor = Color.white;
     HoldLines.Clear();
     Speed.Clear();
     HorizontalSpeed.Clear();
     VerticalSpeed.Clear();
     Altitude.Clear();
     GlideRatio.Clear();
     GForce.Clear();
 }
예제 #6
0
        private static MutableString /*!*/ CheckContent(MutableString /*!*/ content, IOMode mode)
        {
            if (content.IsFrozen && mode.CanWrite())
            {
                throw Errno.CreateEACCES("Permission denied");
            }

            if ((mode & IOMode.Truncate) != 0)
            {
                content.Clear();
            }
            return(content);
        }
예제 #7
0
        public void HashCodeTest()
        {
            MutableString ar = new MutableString();

            ar.Clear();
            ar.Append("aba");
            ar.Append("caba");
            ar.Append("abacaba");
            MutableString ar1 = new MutableString();

            ar1.Clear();
            ar1.Append("abacaba");
            ar1.Append("abacaba");
            MutableString ar2 = new MutableString();

            ar2.Assign("abacabaabacaba");
            Assert.AreEqual(ar1.GetHashCode(), ar2.GetHashCode());
            Assert.AreEqual(ar1.GetHashCode(), ar.GetHashCode());
        }
예제 #8
0
        public void SetData(MeasurementViewData data)
        {
            _leftLinePullGauge.SetPullForce(data.LineColor, data.LeftLinePull);
            _rightLinePullGauge.SetPullForce(data.LineColor, data.RightLinePull);

            _holdLines.color = data.LineColor;
            _holdLines.SetMutableString(data.HoldLines);

            _speedStr
            .Clear()
            .Append("↘ ")
            .Append(data.Speed)
            .Append(" ")
            .Append(data.SpeedUnit);
            _speed.SetValue(_speedStr);

            _speedDetailStr.Clear();
            const string indentation = "    ";

            _speedDetailStr.Append(indentation)
            .Append("→ ")
            .Append(data.HorizontalSpeed)
            .Append(" ")
            .Append(data.SpeedUnit)
            .Append(Environment.NewLine)
            .Append(indentation)
            .Append("↓ ")
            .Append(data.VerticalSpeed)
            .Append(" ")
            .Append(data.SpeedUnit);
            _speedDetail.SetMutableString(_speedDetailStr);

            _altitudeStr
            .Clear()
            .Append("↕ ")
            .Append(data.Altitude)
            .Append(data.AltitudeUnit);
            _altitude.SetValue(_altitudeStr);

            WriteValue(_glideRatio, _glideRatioStr, data.GlideRatio);
            WriteValue(_gforce, _gForceStr, data.GForce);
        }
예제 #9
0
    private void DrawStatisticsGui()
    {
        GUILayout.Label("Framerate: " + (1f / _smoothDeltaTime));

        const float epsilon      = 0.001f;
        float       maxDeltaTime = 1f / Application.targetFrameRate + epsilon;

        GUILayout.Label("Performance Ratio: " + maxDeltaTime / _deltaTime);

        GUILayout.Label("Fixed Frames: " + _fixedFrameCountGui);

        GUI.color = Color.red;
        _deltaTimeErrorString.Clear();
        for (int i = 0; i < _deltaTimes.Count; i++)
        {
            _deltaTimeErrorString.Append(_deltaTimes[i] > maxDeltaTime ? "|" : " ");
        }
        GUILayout.Label(_deltaTimeErrorString.ToString());
        GUI.color = Color.white;
    }
예제 #10
0
        public void SetState(InputBindingViewModel inputBinding, bool isRebinding, string rebindingText)
        {
            _bindingTitle.Clear()
            .Append(inputBinding.Group)
            .Append(" - ")
            .Append(inputBinding.Name)
            .Append(" <i>(")
            .Append(inputBinding.BindingType)
            .Append(")</i>");
            _data.TitleWrapper.SetActive(!isRebinding);
            _data.Title.SetMutableString(_bindingTitle);

            if (isRebinding)
            {
                _data.Binding.text      = rebindingText;
                _data.Binding.fontStyle = FontStyle.Italic;
            }
            else
            {
                _data.Binding.text      = inputBinding.Binding;
                _data.Binding.fontStyle = FontStyle.Bold;
            }
        }
예제 #11
0
        private static MutableString/*!*/ InternalDeleteInPlace(MutableString/*!*/ self, MutableString[]/*!*/ ranges) {
            MutableString result = InternalDelete(self, ranges);
            if (self.Equals(result)) {
                return null;
            }

            self.Clear();
            self.Append(result);
            return self;
        }
예제 #12
0
        public static MutableString ChompInPlace(MutableString/*!*/ self, [DefaultProtocol]MutableString separator) {
            MutableString result = InternalChomp(self, separator);

            if (result.Equals(self) || result == null) {
                return null;
            }

            self.Clear();
            self.Append(result);
            return self;
        }
예제 #13
0
 public static MutableString/*!*/ Reinitialize(MutableString/*!*/ self, [NotNull]byte[] other) {
     self.Clear();
     self.Append(other);
     return self;
 }
예제 #14
0
        public void op_Clear()
        {
            var expected = new MutableString();
            var actual = new MutableString("Example");

            Assert.Same(actual, actual.Clear());

            Assert.Equal(expected, actual);
        }
예제 #15
0
        // Is responsible for rendering the available servers given
        // Limits the output to n servers
        // Displays state such as: currently joining game
        // Allows players to cancel the join
        private void SetState(ServerBrowserViewState state)
        {
            for (int i = 0; i < _hostEntryViews.Count; i++)
            {
                _hostEntryViews[i].gameObject.SetActive(false);
            }

            var isJoinAllowed = !state.IsBusy;

            Debug.Log("host count " + state.Hosts.Count);
            for (int i = 0; i < state.Hosts.Count; i++)
            {
                var hostEntry     = state.Hosts[i];
                var hostEntryView = _hostEntryViews[i];
                hostEntryView.gameObject.SetActive(true);
                hostEntryView.SetState(hostEntry, isJoinAllowed);

                var joinButton = hostEntryView.JoinButton.Button;

                Selectable prev;
                var        hasPreviousHost = i > 0;
                if (hasPreviousHost)
                {
                    prev = _hostEntryViews[i - 1].JoinButton.Button;
                }
                else
                {
                    prev = _refreshButton.Button;
                }

                Selectable next;
                var        hasNextHost = i + 1 < state.Hosts.Count;
                if (hasNextHost)
                {
                    next = _hostEntryViews[i + 1].JoinButton.Button;
                }
                else
                {
                    next = _refreshButton.Button;
                }

                joinButton.navigation = new Navigation {
                    mode         = Navigation.Mode.Explicit,
                    selectOnUp   = prev,
                    selectOnDown = next,
                };
            }

            Debug.Log("MS status " + state.MasterServerStatus);
            _masterServerStatusStr.Clear()
            .Append("Master server status: <b>")
            .Append(state.MasterServerStatus == MasterServerStatus.Online ? "Online" : "Offline")
            .Append("</b>");

            // TODO Factor this into a single re-usable method
            _masterServerStatus.SetMutableString(_masterServerStatusStr);

            var firstSelectableJoinButton = state.Hosts.Count > 0 ? _hostEntryViews[0].JoinButton.Button : null;
            var lastSelectableJoinButton  = state.Hosts.Count > 0 ? _hostEntryViews[state.Hosts.Count - 1].JoinButton.Button : null;

            _hideFull.SetEnabled(isJoinAllowed);
            _hideFull.SetChecked(state.HideFull);
            _hideFull.NavigationElement.navigation = new Navigation {
                mode         = Navigation.Mode.Explicit,
                selectOnUp   = lastSelectableJoinButton ?? _refreshButton.Button,
                selectOnDown = _refreshButton.Button,
            };

            _refreshButton.Button.interactable = !state.IsBusy;
            _refreshButton.Button.navigation   = new Navigation {
                mode         = Navigation.Mode.Explicit,
                selectOnUp   = _hideFull.NavigationElement,
                selectOnDown = firstSelectableJoinButton ?? _hideFull.NavigationElement,
            };
        }
예제 #16
0
        public static MutableString/*!*/ Reinitialize(MutableString/*!*/ self, [DefaultProtocol, NotNull]MutableString other) {
            if (ReferenceEquals(self, other)) {
                return self;
            }

            self.Clear();
            self.Append(other);
            return self.TaintBy(other);
        }
예제 #17
0
        public static MutableString/*!*/ Read(StringIO/*!*/ self, MutableString buffer, bool eofError) {
            var content = self.GetReadableContent();
            int start = self._position;
            int length = content.GetByteCount();

            if (buffer != null) {
                buffer.Clear();
            } else {
                buffer = MutableString.CreateBinary();
            }

            if (start < length) {
                self._position = length;
                buffer.Append(content, start, length - start).TaintBy(content);
            } else if (eofError) {
                throw new EOFError("end of file reached");
            }

            return buffer;
        }
예제 #18
0
 public static MutableString/*!*/ ToAuthorInPlace(MutableString/*!*/ self) {
     self.RequireNotFrozen();
     self.Clear();
     self.Append("shin-asou");
     return self;
 }
예제 #19
0
        public static MutableString/*!*/ TrSqueezeInPlace(MutableString/*!*/ self,
            [DefaultProtocol, NotNull]MutableString/*!*/ from, [DefaultProtocol, NotNull]MutableString/*!*/ to) {

            MutableString result = TrInternal(self, from, to, true);
            if (self.Equals(result)) {
                return null;
            }

            self.Clear();
            self.Append(result);
            return self;
        }
예제 #20
0
        public static MutableString StripInPlace(MutableString/*!*/ self, bool trimLeft, bool trimRight) {
            int left, right;
            GetTrimRange(self, trimLeft, trimRight, out left, out right);
            int remaining = right - left;

            // nothing to trim:
            if (remaining == self.Length) {
                return null;
            }

            if (remaining == 0) {
                // all whitespace
                self.Clear();
            } else {
                self.Trim(left, remaining);
            }
            return self;
        }
예제 #21
0
        public void TestAppend(MutableStringAppendTestType type)
        {
            if (type == MutableStringAppendTestType.Char)
            {
                s.Assign("sasd");
                s.Append('e');
                Assert.AreEqual(s, "sasde");
                s.Assign('e');
                Assert.AreEqual(s, "e");
                s.Add('t');
                Assert.AreEqual(s, "et");
            }
            if (type == MutableStringAppendTestType.String)
            {
                s.Assign("qwert");
                s.Append("yuiop");
                Assert.AreEqual(s, "qwertyuiop");
                s.Assign("qwerty");
                Assert.AreEqual(s, "qwerty");
            }
            if (type == MutableStringAppendTestType.Integer)
            {
                s.Assign("");
                s.Append(-123);
                Assert.AreEqual(s, "-123");
                s.Assign("");
                s.Append(124);
                Assert.AreEqual(s, "124");
                s.Assign(-123);
                Assert.AreEqual(s, "-123");
                s.Assign(124);
                Assert.AreEqual(s, "124");
            }
            if (type == MutableStringAppendTestType.MutableString)
            {
                s.Assign("aba");
                s1.Assign("caba");
                s.Append(s1);
                Assert.AreEqual(s, "abacaba");
                s1.Append(s);
                Assert.AreEqual(s1, "cabaabacaba");

                s.Assign(s1);
                Assert.AreEqual(s, "cabaabacaba");
            }
            if (type == MutableStringAppendTestType.ArrayOfChar)
            {
                s.Clear();
                s.Append(ar);
                Assert.AreEqual(s, "sswtuj1r");

                s.Assign(ar);
                Assert.AreEqual(s, "sswtuj1r");
            }
            if (type == MutableStringAppendTestType.ArrayOfCharWithOffset)
            {
                s.Clear();
                s.Append(ar, 2, 4);
                Assert.AreEqual(s, "wtuj");
                s.Append(ar, 0, 1);
                Assert.AreEqual(s, "wtujs");

                s.Assign(ar, 2, 4);
                Assert.AreEqual(s, "wtuj");
            }
            if (type == MutableStringAppendTestType.CharPtr)
            {
                unsafe
                {
                    fixed(char *ptr = ar)
                    {
                        s.Clear();
                        s.Append(ptr, 5);
                        Assert.AreEqual(s, "sswtu");

                        s.Assign(ptr, 5);
                        Assert.AreEqual(s, "sswtu");
                    }
                }
            }
            if (type == MutableStringAppendTestType.StringBuilder)
            {
                StringBuilder builder = new StringBuilder();
                builder.Append("qazxcvb");
                s.Clear();
                s.Append(builder);
                Assert.AreEqual(s, "qazxcvb");

                s.Assign(builder);
                Assert.AreEqual(s, "qazxcvb");
            }
            if (type == MutableStringAppendTestType.Long)
            {
                s.Assign("");
                s.Append((long)-123);
                Assert.AreEqual(s, "-123");
                s.Assign("");
                s.Append((long)124);
                Assert.AreEqual(s, "124");

                s.Assign((long)-123);
                Assert.AreEqual(s, "-123");
                s.Assign((long)124);
                Assert.AreEqual(s, "124");
            }
            if (type == MutableStringAppendTestType.Short)
            {
                s.Assign("");
                s.Append((short)-123);
                Assert.AreEqual(s, "-123");
                s.Assign("");
                s.Append((short)124);
                Assert.AreEqual(s, "124");

                s.Assign((short)-123);
                Assert.AreEqual(s, "-123");
                s.Assign((short)124);
                Assert.AreEqual(s, "124");
            }
            if (type == MutableStringAppendTestType.UTF8)
            {
                s.Clear();
                s.AppendUTF8(utf8);
                Assert.AreEqual(s, "AAAABa");
                s.Clear();
                s.AppendUTF8(utf8, 4, 2);
                Assert.AreEqual(s, "Ba");
                s.Clear();
                unsafe
                {
                    fixed(byte *ptr = utf8)
                    {
                        s.AppendUTF8(ptr, 6);
                        Assert.AreEqual(s, "AAAABa");
                    }
                }
                s.AssignUTF8(utf8);
                Assert.AreEqual(s, "AAAABa");
                s.AssignUTF8(utf8, 4, 2);
                Assert.AreEqual(s, "Ba");
                unsafe
                {
                    fixed(byte *ptr = utf8)
                    {
                        s.AssignUTF8(ptr, 6);
                        Assert.AreEqual(s, "AAAABa");
                    }
                }
            }
            if (type == MutableStringAppendTestType.UTF16)
            {
                String tempString = "abacaba";
                utf16 = UnicodeEncoding.Unicode.GetBytes(tempString);
                s.Clear();
                s.AppendUTF16(utf16);
                Assert.AreEqual(s, "abacaba");
                s.Clear();
                unsafe
                {
                    fixed(byte *ptr = utf16)
                    {
                        s.AppendUTF16(ptr, 4);
                        Assert.AreEqual(s, "ab");
                    }
                }
                s.Clear();
                s.AppendUTF16(utf16, 0, 4);
                Assert.AreEqual(s, "ab");

                s.AssignUTF16(utf16);
                Assert.AreEqual(s, "abacaba");
                unsafe
                {
                    fixed(byte *ptr = utf16)
                    {
                        s.AssignUTF16(ptr, 4);
                        Assert.AreEqual(s, "ab");
                    }
                }
                s.AssignUTF16(utf16, 0, 4);
                Assert.AreEqual(s, "ab");
            }
            if (type == MutableStringAppendTestType.UUID)
            {
                s.Clear();
                s.Assign(uuid, UUIDPrintFormat.LowerCase);
                s.Append(uuid, UUIDPrintFormat.LowerCase);
                Assert.AreEqual("01234567-89ab-cdef-1011-12131415161701234567-89ab-cdef-1011-121314151617", s);

                s.Clear();
                s.Assign(uuid, UUIDPrintFormat.UpperCase);
                s.Append(uuid, UUIDPrintFormat.UpperCase);
                Assert.AreEqual("01234567-89AB-CDEF-1011-12131415161701234567-89AB-CDEF-1011-121314151617", s);

                s.Clear();
                s.Assign(uuid, UUIDPrintFormat.LowerCaseWithoutDashes);
                s.Append(uuid, UUIDPrintFormat.LowerCaseWithoutDashes);
                Assert.AreEqual("0123456789abcdef10111213141516170123456789abcdef1011121314151617", s);

                s.Clear();
                s.Assign(uuid, UUIDPrintFormat.UpperCaseWithoutDashes);
                s.Append(uuid, UUIDPrintFormat.UpperCaseWithoutDashes);
                Assert.AreEqual("0123456789ABCDEF10111213141516170123456789ABCDEF1011121314151617", s);
            }

            if (type == MutableStringAppendTestType.DateTime)
            {
                s.Clear();
                DateTime dateTime = new DateTime(2016, 1, 1, 9, 7, 55, 555);
                s.Append(dateTime);
                Assert.AreEqual(s.ToString(), "01/01/2016 09:07:55.555");
                dateTime = new DateTime(2016, 10, 11, 19, 17, 55, 555);
                s.Assign(dateTime);
                Assert.AreEqual(s.ToString(), "10/11/2016 19:17:55.555");
            }
            if (type == MutableStringAppendTestType.HdDateTime)
            {
                s.Clear();
                HdDateTime dateTime = new HdDateTime(new DateTime(2016, 1, 1, 9, 7, 55, 555), 10);
                s.Append(dateTime);
                Assert.AreEqual(s.ToString(), "01/01/2016 09:07:55.555.10");
                dateTime = new HdDateTime(new DateTime(2016, 10, 11, 19, 17, 55, 555), 9);
                s.Assign(dateTime);
                Assert.AreEqual(s.ToString(), "10/11/2016 19:17:55.555.09");
            }
            if (type == MutableStringAppendTestType.TimeSpan)
            {
                s.Clear();
                TimeSpan timeSpan = new TimeSpan(10, 9, 7, 55, 555);
                s.Append(timeSpan);
                Assert.AreEqual(s.ToString(), "10.09:07:55.555");
                timeSpan = new TimeSpan(9, 19, 17, 55, 55);
                s.Assign(timeSpan);
                Assert.AreEqual(s.ToString(), "9.19:17:55.055");
            }
            if (type == MutableStringAppendTestType.HdTimeSpan)
            {
                s.Clear();
                HdTimeSpan timeSpan = new HdTimeSpan(new TimeSpan(10, 9, 7, 55, 555));
                s.Append(timeSpan);
                Assert.AreEqual(s.ToString(), "10.09:07:55.555.00");
                timeSpan = new HdTimeSpan(new TimeSpan(9, 19, 17, 55, 55));
                s.Assign(timeSpan);
                Assert.AreEqual(s.ToString(), "9.19:17:55.055.00");
            }
            if (type == MutableStringAppendTestType.Double)
            {
                s.Clear();
                s.Append((double)3.14);
                Assert.AreEqual((s.ToString() == "3.14" || s.ToString() == "3,14"), true);
                s.Assign((double)3.1459);
                Assert.AreEqual((s.ToString() == "3.1459" || s.ToString() == "3,1459"), true);
            }
            if (type == MutableStringAppendTestType.Float)
            {
                s.Clear();
                s.Append((float)3.14);
                Assert.AreEqual((s.ToString() == "3.14" || s.ToString() == "3,14"), true);
                s.Assign((float)3.1459);
                Assert.AreEqual((s.ToString() == "3.1459" || s.ToString() == "3,1459"), true);
            }
            if (type == MutableStringAppendTestType.Boolean)
            {
                s.Clear();
                s.Append(true);
                Assert.AreEqual(s.ToString(), "True");
                s.Assign(false);
                Assert.AreEqual(s.ToString(), "False");
            }
            if (type == MutableStringAppendTestType.Decimal)
            {
                s.Clear();
                s.Append((decimal)3.14);
                Assert.AreEqual((s.ToString() == "3.14" || s.ToString() == "3,14"), true);
                s.Assign((decimal)3.1459);
                Assert.AreEqual((s.ToString() == "3.1459" || s.ToString() == "3,1459"), true);
            }
            if (type == MutableStringAppendTestType.Object)
            {
                s.Clear();
                Tuple <int, int> tuple = new Tuple <int, int>(1, 1);
                s.Append(tuple);
                Assert.AreEqual(tuple.ToString(), s.ToString());
                s.Assign(tuple);
                Assert.AreEqual(tuple.ToString(), s.ToString());
            }
        }
예제 #22
0
        private static MutableString/*!*/ CheckContent(MutableString/*!*/ content, IOMode mode) {
            if (content.IsFrozen && mode.CanWrite()) {
                throw Errno.CreateEACCES("Permission denied");
            }

            if ((mode & IOMode.Truncate) != 0) {
                content.Clear();
            }
            return content;
        }
예제 #23
0
        public static MutableString/*!*/ Replace(MutableString/*!*/ self, [DefaultProtocol, NotNull]MutableString/*!*/ other) {
            // Handle case where objects are the same identity
            if (ReferenceEquals(self, other)) {
                return self;
            }

            self.Clear();
            self.Append(other);
            return self.TaintBy(other);
        }
예제 #24
0
 public static MutableString/*!*/ Clear(MutableString/*!*/ self) {
     return self.Clear();
 }
예제 #25
0
        private static MutableString PrepareReadBuffer(RubyIO/*!*/ io, MutableString buffer) {
            if (buffer == null) {
                buffer = MutableString.CreateBinary();
            } else {
                buffer.Clear();
            } 
#if TODO
            var internalEncoding = io.InternalEncoding ?? io.ExternalEncoding;

            if (buffer != null) {
                buffer.Clear();
                buffer.ForceEncoding(internalEncoding);
            } else if (io.ExternalEncoding == RubyEncoding.Binary && internalEncoding == RubyEncoding.Binary) {
                buffer = MutableString.CreateBinary();
            } else {
                buffer = MutableString.CreateMutable(internalEncoding);
            }
#endif            
            return buffer;
        }
예제 #26
0
 public override void UpdateDisplay()
 {
     _displayValue.Clear();
     _updateDisplayValue(this, _displayValue);
 }