void UpdateFPS(double delta)
        {
            frames++;
            accumulator += delta;
            if (accumulator < 1)
            {
                return;
            }

            int index = 0;

            totalSeconds++;
            int fps = (int)(frames / accumulator);

            text.Clear()
            .AppendNum(ref index, fps).Append(ref index, " fps, ");
            if (game.ClassicMode)
            {
                text.AppendNum(ref index, game.ChunkUpdates).Append(ref index, " chunk updates");
            }
            else
            {
                text.AppendNum(ref index, game.ChunkUpdates).Append(ref index, " chunks/s, ")
                .AppendNum(ref index, game.Vertices).Append(ref index, " vertices");
            }

            CheckClock();
            string textString = text.ToString();

            fpsText.SetText(textString);
            accumulator       = 0;
            frames            = 0;
            game.ChunkUpdates = 0;
        }
Esempio n. 2
0
        void UpdateStatus(double delta)
        {
            frames++;
            accumulator += delta;
            if (accumulator < 1)
            {
                return;
            }

            int index = 0;

            totalSeconds++;
            int fps = (int)(frames / accumulator);

            statusBuffer.Clear()
            .AppendNum(ref index, fps).Append(ref index, " fps, ");
            if (game.ClassicMode)
            {
                statusBuffer.AppendNum(ref index, game.ChunkUpdates).Append(ref index, " chunk updates");
            }
            else
            {
                if (game.ChunkUpdates > 0)
                {
                    statusBuffer.AppendNum(ref index, game.ChunkUpdates).Append(ref index, " chunks/s, ");
                }
                int indices = (game.Vertices >> 2) * 6;
                statusBuffer.AppendNum(ref index, indices).Append(ref index, " vertices");

                int ping = PingList.AveragePingMilliseconds();
                if (ping != 0)
                {
                    statusBuffer.Append(ref index, ", ping ").AppendNum(ref index, ping).Append(ref index, " ms");
                }
            }

            status.SetText(statusBuffer.ToString());
            accumulator       = 0;
            frames            = 0;
            game.ChunkUpdates = 0;
        }
Esempio n. 3
0
        void UpdateStatus(double delta)
        {
            frames++;
            accumulator += delta;
            if (accumulator < 1)
            {
                return;
            }

            int fps = (int)(frames / accumulator);

            statusBuffer.Clear().AppendNum(fps).Append(" fps, ");

            if (game.ClassicMode)
            {
                statusBuffer.AppendNum(game.ChunkUpdates).Append(" chunk updates");
            }
            else
            {
                if (game.ChunkUpdates > 0)
                {
                    statusBuffer.AppendNum(game.ChunkUpdates).Append(" chunks/s, ");
                }
                int indices = (game.Vertices >> 2) * 6;
                statusBuffer.AppendNum(indices).Append(" vertices");

                int ping = PingList.AveragePingMilliseconds();
                if (ping != 0)
                {
                    statusBuffer.Append(", ping ").AppendNum(ping).Append(" ms");
                }
            }

            line1.Set(statusBuffer.ToString(), font);
            accumulator       = 0;
            frames            = 0;
            game.ChunkUpdates = 0;
        }
Esempio n. 4
0
        void UpdateBlockInfoString(byte block)
        {
            int index = 0;

            buffer.Clear();
            buffer.Append(ref index, "&f");
            string value = game.BlockInfo.Name[block];

            buffer.Append(ref index, value);
            if (game.ClassicMode)
            {
                return;
            }

            buffer.Append(ref index, " (ID ");
            buffer.AppendNum(ref index, block);
            buffer.Append(ref index, "&f, place ");
            buffer.Append(ref index, game.Inventory.CanPlace[block] ? "&aYes" : "&cNo");
            buffer.Append(ref index, "&f, delete ");
            buffer.Append(ref index, game.Inventory.CanDelete[block] ? "&aYes" : "&cNo");
            buffer.Append(ref index, "&f)");
        }
Esempio n. 5
0
        void UpdateBlockInfoString(BlockID block)
        {
            buffer.Clear();
            if (game.PureClassic)
            {
                buffer.Append("Select block"); return;
            }

            buffer.Append(BlockInfo.Name[block]);
            if (game.ClassicMode)
            {
                return;
            }

            buffer.Append(" (ID ");
            buffer.AppendNum(block);
            buffer.Append("&f, place ");
            buffer.Append(BlockInfo.CanPlace[block] ? "&aYes" : "&cNo");
            buffer.Append("&f, delete ");
            buffer.Append(BlockInfo.CanDelete[block] ? "&aYes" : "&cNo");
            buffer.Append("&f)");
        }
        void TabKey()
        {
            int pos = caretPos == -1 ? buffer.Length - 1 : caretPos;
            int start = pos;
            char[] value = buffer.value;

            while( start >= 0 && IsNameChar( value[start] ) )
                start--;
            start++;
            if( pos < 0 || start > pos ) return;

            string part = new String( value, start, pos + 1 - start );
            List<string> matches = new List<string>();
            game.Chat.Add( null, MessageType.ClientStatus5 );

            bool extList = game.Network.UsingExtPlayerList;
            CpeListInfo[] info = game.CpePlayersList;
            Player[] players = game.Players.Players;
            for( int i = 0; i < EntityList.MaxCount; i++ ) {
                if( extList && info[i] == null ) continue;
                if( !extList && players[i] == null ) continue;

                string rawName = extList ? info[i].PlayerName : players[i].DisplayName;
                string name = Utils.StripColours( rawName );
                if( name.StartsWith( part, StringComparison.OrdinalIgnoreCase ) )
                    matches.Add( name );
            }

            if( matches.Count == 1 ) {
                if( caretPos == -1 ) pos++;
                int len = pos - start;
                for( int i = 0; i < len; i++ )
                    buffer.DeleteAt( start );
                if( caretPos != -1 ) caretPos -= len;
                AppendText( matches[0] );
            } else if( matches.Count > 1 ) {
                StringBuffer sb = new StringBuffer( 64 );
                int index = 0;
                sb.Append( ref index, "&e" );
                sb.AppendNum( ref index, matches.Count );
                sb.Append( ref index, " matching names: " );

                foreach( string match in matches ) {
                    if( (match.Length + 1 + sb.Length) > LineLength ) break;
                    sb.Append( ref index, match );
                    sb.Append( ref index, ' ' );
                }
                game.Chat.Add( sb.ToString(), MessageType.ClientStatus5 );
            }
        }
Esempio n. 7
0
        void TabKey()
        {
            int pos   = caret == -1 ? Text.Length - 1 : caret;
            int start = pos;

            char[] value = Text.value;

            while (start >= 0 && IsNameChar(value[start]))
            {
                start--;
            }
            start++;
            if (pos < 0 || start > pos)
            {
                return;
            }

            string        part    = new String(value, start, pos + 1 - start);
            List <string> matches = new List <string>();

            game.Chat.Add(null, MessageType.ClientStatus3);

            TabListEntry[] entries = game.TabList.Entries;
            for (int i = 0; i < EntityList.MaxCount; i++)
            {
                if (entries[i] == null)
                {
                    continue;
                }

                string rawName = entries[i].PlayerName;
                string name    = Utils.StripColours(rawName);
                if (name.StartsWith(part, StringComparison.OrdinalIgnoreCase))
                {
                    matches.Add(name);
                }
            }

            if (matches.Count == 1)
            {
                if (caret == -1)
                {
                    pos++;
                }
                int len = pos - start;
                for (int i = 0; i < len; i++)
                {
                    Text.DeleteAt(start);
                }
                if (caret != -1)
                {
                    caret -= len;
                }
                Append(matches[0]);
            }
            else if (matches.Count > 1)
            {
                StringBuffer sb    = new StringBuffer(Utils.StringLength);
                int          index = 0;
                sb.Append(ref index, "&e");
                sb.AppendNum(ref index, matches.Count);
                sb.Append(ref index, " matching names: ");

                for (int i = 0; i < matches.Count; i++)
                {
                    string match = matches[i];
                    if ((sb.Length + match.Length + 1) > sb.Capacity)
                    {
                        break;
                    }
                    sb.Append(ref index, match);
                    sb.Append(ref index, ' ');
                }
                game.Chat.Add(sb.ToString(), MessageType.ClientStatus3);
            }
        }