コード例 #1
0
ファイル: ScreenViewModel.cs プロジェクト: taradinoc/ZDebug
        void IScreen.ShowStatus()
        {
            Dispatch(() =>
            {
                var story = storyService.Story;
                if (story.Version > 3)
                {
                    return;
                }

                if (upperWindow == null)
                {
                    upperWindow = windowManager.Open(ZWindowType.TextGrid, mainWindow, ZWindowPosition.Above, ZWindowSizeType.Fixed, 1);
                }
                else
                {
                    int height = upperWindow.GetHeight();
                    if (height != 1)
                    {
                        upperWindow.SetHeight(1);
                        currStatusHeight = 1;
                        machStatusHeight = 1;
                    }
                }

                upperWindow.Clear();

                var charWidth    = ((IScreen)this).ScreenWidthInColumns;
                var locationText = " " + story.ObjectTable.GetByNumber(story.GlobalVariablesTable[0]).ShortName;

                upperWindow.SetReverse(true);

                if (charWidth < 5)
                {
                    upperWindow.PutString(new string(' ', charWidth));
                    return;
                }

                if (locationText.Length > charWidth)
                {
                    locationText = locationText.Substring(0, charWidth - 3) + "...";
                    upperWindow.PutString(locationText);
                    return;
                }

                upperWindow.PutString(locationText);

                string rightText;
                if (IsScoreGame())
                {
                    int score = (short)story.GlobalVariablesTable[1];
                    int moves = (ushort)story.GlobalVariablesTable[2];
                    rightText = string.Format("Score: {0,-8} Moves: {1,-6} ", score, moves);
                }
                else
                {
                    int hours   = (ushort)story.GlobalVariablesTable[1];
                    int minutes = (ushort)story.GlobalVariablesTable[2];
                    var pm      = (hours / 12) > 0;
                    if (pm)
                    {
                        hours = hours % 12;
                    }

                    rightText = string.Format("{0}:{1:n2} {2}", hours, minutes, (pm ? "pm" : "am"));
                }

                if (rightText.Length < charWidth - locationText.Length - 1)
                {
                    upperWindow.PutString(new string(' ', charWidth - locationText.Length - rightText.Length));
                    upperWindow.PutString(rightText);
                }
            });
        }
コード例 #2
0
 public override void PutString(string s)
 {
     window.PutString(s);
 }