Esempio n. 1
0
        /// <summary>
        /// Draws the window.
        /// </summary>
        /// <param name="gameTime"></param>
        /// <param name="viewRect"></param>
        public override void Draw(GameTime gameTime, ViewRect viewRect)
        {
            if (IsClosed || !IsInitialized || !Activated)
            {
                return;
            }

            if (!Hidden)
            {
                ViewRect windowRect = viewRect.AddGet(new ViewRect(RealX, RealY, Width, Height));
                windowRect.Add(GetDefaultBoundaries());
                IRender render = GraphicsManager.GetRender();
                render.SetViewRect(windowRect);
                Project(gameTime, RealX, RealY, render);

                if (!DialoguesAreHidden && DarkenWhenDialogueExists && GetCurrentDialogue() != null)
                {
                    DrawBox currentDialogue = GetCurrentDialogue();

                    foreach (DrawBox d in DrawBoxList)
                    {
                        if (currentDialogue != d)
                        {
                            d.Draw(gameTime, viewRect);
                        }
                    }

                    var r = GraphicsManager.GetRender();
                    r.Begin();
                    r.Clear(DarkeningMask);
                    r.End();

                    currentDialogue.Draw(gameTime, viewRect);
                }
                else
                {
                    foreach (DrawBox d in DrawBoxList)
                    {
                        if (DialoguesAreHidden && dialogues.Contains(d))
                        {
                            continue;
                        }

                        d.Draw(gameTime, viewRect);
                    }
                }

                foreach (var f in drawDelegates)
                {
                    f(gameTime, viewRect);
                }

                drawDelegates.Clear();
            }
        }
Esempio n. 2
0
        public override void Project(GameTime gameTime, int x, int y, IRender render)
        {
            ViewRect orig = render.GetViewRect();

            render.Begin();

            ISprite iconUpSignInUse = UpIsPressed ? IconUpSignPressed : IconUpSign;
            ISprite iconInsideInUse = UpIsPressed ? IconInsidePressed : IconInside;

            //	/-------\
            //  |  /|\  |
            //  | / | \ |
            //  |   |   |
            //  \-------/
            render.DrawSprite(IconTop, new Vector2(x, y), Color.White);
            render.DrawSprite(IconLeft, new Rectangle(x, y + IconTop.Height, IconLeft.Width, UpperFieldHeight - IconTop.Height - IconBottom.Height), Color.White);
            render.DrawSprite(IconRight, new Rectangle(x + IconTop.Width - IconRight.Width, y + IconTop.Height, IconRight.Width, UpperFieldHeight - IconTop.Height - IconBottom.Height), Color.White);
            render.DrawSprite(IconBottom, new Vector2(x, y + UpperFieldHeight - IconBottom.Height), Color.White);
            render.DrawSprite(iconInsideInUse, new Rectangle(x + IconLeft.Width, y + IconTop.Height, IconTop.Width - IconLeft.Width - IconRight.Width, UpperFieldHeight - IconTop.Height - IconBottom.Height), Color.White);
            render.DrawSprite(IconUpSign, new Vector2(x + IconLeft.Width + ((IconTop.Width - IconLeft.Width - IconRight.Width) / 2) - (IconUpSign.Width / 2), y + (UpperFieldHeight / 2) - (IconUpSign.Height / 2)), Color.White);

            //UPPER FIELD:
            //Top
            render.DrawSprite(TopBorder, new Rectangle(x + IconTop.Width, y, Width - IconTop.Width - TopRightCorner.Width, TopBorder.Height), Color.White);
            //TopRight
            render.DrawSprite(TopRightCorner, new Vector2(x + Width - TopRightCorner.Width, y), Color.White);
            //Right
            render.DrawSprite(RightBorder, new Rectangle(x + Width - RightBorder.Width, y + TopRightCorner.Height, RightBorder.Width, UpperFieldHeight - TopRightCorner.Height - UpperFieldBottomRightCorner.Height), Color.White);
            //BottomRight
            render.DrawSprite(UpperFieldBottomRightCorner, new Vector2(x + Width - UpperFieldBottomRightCorner.Width, y + UpperFieldHeight - UpperFieldBottomRightCorner.Height), Color.White);
            //Bottom
            render.DrawSprite(BottomBorder, new Rectangle(x + IconTop.Width, y + UpperFieldHeight - BottomBorder.Height, Width - IconTop.Width - TopRightCorner.Width, BottomBorder.Height), Color.White);
            //Inside
            render.DrawSprite(Inside, new Rectangle(x + IconTop.Width, y + TopBorder.Height, Width - IconTop.Width - RightBorder.Width, UpperFieldHeight - TopBorder.Height - BottomBorder.Height), Color.White);

            //LOWER FIELD:
            //Middle
            render.DrawSprite(MiddleBorder, new Rectangle(x + LeftBorder.Width, y + UpperFieldHeight, LowerFieldWidth - LeftBorder.Width - RightBorder.Width, MiddleBorder.Height), Color.White);
            //Right
            render.DrawSprite(RightBorder, new Rectangle(x + LowerFieldWidth - RightBorder.Width, y + UpperFieldHeight, RightBorder.Width, LowerFieldHeight - BottomRightCorner.Height), Color.White);
            //BottomRight
            render.DrawSprite(BottomRightCorner, new Vector2(x + LowerFieldWidth - BottomRightCorner.Width, y + UpperFieldHeight + LowerFieldHeight - BottomRightCorner.Height), Color.White);
            //Bottom
            render.DrawSprite(BottomBorder, new Rectangle(x + BottomLeftCorner.Width, y + UpperFieldHeight + LowerFieldHeight - BottomBorder.Height, LowerFieldWidth - BottomLeftCorner.Width - BottomRightCorner.Width, BottomBorder.Height), Color.White);
            //BottomLeft
            render.DrawSprite(BottomLeftCorner, new Vector2(x, y + UpperFieldHeight + LowerFieldHeight - BottomLeftCorner.Height), Color.White);
            //Left
            render.DrawSprite(LeftBorder, new Rectangle(x, y + UpperFieldHeight, LeftBorder.Width, LowerFieldHeight - BottomLeftCorner.Height), Color.White);
            //Inside
            render.DrawSprite(Inside, new Rectangle(x + LeftBorder.Width, y + UpperFieldHeight + MiddleBorder.Height, LowerFieldWidth - LeftBorder.Width - RightBorder.Width, LowerFieldHeight - MiddleBorder.Height - BottomBorder.Height), Color.White);

            render.End();

            render.SetViewRect(orig.AddGet(new ViewRect(RealX + IconTop.Width + TextMargin, RealY + TopBorder.Height + TextMargin, Width - IconTop.Width - RightBorder.Width - TextMargin * 2, UpperFieldHeight - TopBorder.Height - MiddleBorder.Height - TextMargin * 2)));
            render.Begin();

            string textToDraw = Text;

            if (HasFocus)
            {
                textToDraw = Text.Insert(CursorPosition, "|");
            }
            Font.DrawString(textToDraw, new Point(RealX + IconTop.Width + TextMargin, RealY + TopBorder.Height + TextMargin), FontColor, render);

            render.End();

            render.SetViewRect(orig.AddGet(new ViewRect(selectorX, selectorY, selectorWidth, selectorHeight)));
            render.Begin();

            int drawX = selectorX + textAreaOriginX;
            int drawY = selectorY + textAreaOriginY;

            //DrawSprite filedir
            Font.DrawString(CurrentDirectory.FullName, new Point(drawX, drawY), FontColor, render);
            drawY += TextMargin + Font.CharHeight;
            render.DrawLine(new Vector2(drawX, drawY), new Vector2(selectorX + selectorWidth, drawY), SeparatorColor);
            drawY += 1 + TextMargin;

            foreach (DirectoryInfo d in directoryList)
            {
                if (selectedDirectories.Contains(d))
                {
                    render.DrawRect(new Rectangle(selectorX, drawY, selectorWidth, Font.CharHeight + Font.VerticalSpace), SelectedColor);
                }

                render.DrawSprite(FolderSign, new Vector2(drawX, drawY), Color.White);

                Font.DrawString(d.Name, new Point(drawX + FolderSign.Width + TextMargin, drawY), FontColor, render);
                drawY += Font.CharHeight + Font.VerticalSpace;
            }

            foreach (FileInfo f in fileList)
            {
                if (selectedFiles.Contains(f))
                {
                    render.DrawRect(new Rectangle(selectorX, drawY, selectorWidth, Font.CharHeight + Font.VerticalSpace), SelectedColor);
                }

                Font.DrawString(f.Name, new Point(drawX, drawY), FontColor, render);
                drawY += Font.CharHeight + Font.VerticalSpace;
            }

            render.End();
        }