Esempio n. 1
0
        override public void paint(SdlDotNet.Graphics.Surface surface, bool focused, Point offset)
        {
            Caption.SizeWithIcon = false;

            Point dest = new Point((Width - Caption.Width) / 2 + offset.X,
                                   (Height - Caption.Height) / 2 + offset.Y);

            Rectangle rect = new Rectangle(offset, Dimensions);

            surface.Fill(rect, DisplaySettings.atomForeground);
            rect.Width  -= Compound.BorderPadding.Width * 2;
            rect.Height -= Compound.BorderPadding.Height * 2;
            rect.X      += Compound.BorderPadding.Width;
            rect.Y      += Compound.BorderPadding.Height;
            surface.Fill(rect, pressed ? DisplaySettings.atomBackgroundDimmed : DisplaySettings.atomBackground);
            rect.Width  -= Compound.BorderPadding.Width * 2;
            rect.Height -= Compound.BorderPadding.Height * 2;
            rect.X      += Compound.BorderPadding.Width;
            rect.Y      += Compound.BorderPadding.Height;

            Rectangle oldClipper = surface.ClipRectangle;

            surface.ClipRectangle = rect;

            Caption.Blit(surface, dest);

            surface.ClipRectangle = oldClipper;
        }
Esempio n. 2
0
 public static void Tick(SdlDotNet.Graphics.Surface screen, SdlDotNet.Core.TickEventArgs e)
 {
     for (int i = 0; i < mOpenWindows.Count; i++)
     {
         mOpenWindows[i].Tick(screen, e);
     }
 }
Esempio n. 3
0
        override public void paint(SdlDotNet.Graphics.Surface surface, bool focused, Point offset)
        {
            Point p = offset;

            Caption.SizeWithIcon = false;

            DisplayIcon box = boxChecked ? DisplaySettings.checkChecked : DisplaySettings.checkUnchecked;

            if (Caption.Height > box.Height)
            {
                p.Y += (Caption.Height - box.Height) / 2;

                box.Blit(surface, p);

                p.X += box.Width + Compound.Padding;
                p.Y  = offset.Y;

                Caption.Blit(surface, p);
            }
            else
            {
                box.Blit(surface, p);

                p.X += box.Width + Compound.Padding;
                p.Y += (box.Height - Caption.Height) / 2;

                Caption.Blit(surface, p);
            }
        }
Esempio n. 4
0
        //protected override void DrawBuffer() {
        //    base.DrawBuffer();
        //    if (Graphics.Renderers.Screen.ScreenRenderer.RenderOptions.Map != null && Graphics.Renderers.Screen.ScreenRenderer.RenderOptions.Map.Loaded) {
        //        //Graphics.Renderers.Screen.ScreenRenderer.RenderScreen(base.Buffer, this.Location);
        //        //gl.DrawScreen(base.Buffer, activeMap, mapAnim, this.cameraX, this.cameraX2, this.cameraY, this.cameraY2, displayAttributes, displayMapGrid, displayLocation, overlay);
        //        Logic.Graphics.Renderers.Screen.ScreenRenderer.RenderScreen(destData);
        //    }
        //    if (font != null) {
        //        //if (IO.Settings.DisplayCursorLocation) {
        //        //    fpsY += 27;
        //        //    DrawText("X: " + (Globals.CursorX + 1).ToString() + " Y: " + (Globals.CursorY + 1).ToString(), Color.Red, 5, 0);
        //        //}
        //        //if (IO.Settings.DisplayFPS) {
        //        //    DrawText("FPS: " + SdlDotNet.Core.Events.Fps.ToString(), Color.Red, 5, fpsY);
        //        //}
        //    }
        //    base.DrawBorder();
        //    base.DrawComplete();
        //}

        public SdlDotNet.Graphics.Surface CaptureMapImage(bool captureVisibleArea, bool captureAttributes, bool captureMapGrid)
        {
            int cameraX;
            int cameraX2;
            int cameraY;
            int cameraY2;

            if (captureVisibleArea)
            {
                cameraX  = ScreenRenderer.Camera.X;
                cameraX2 = ScreenRenderer.Camera.X2;
                cameraY  = ScreenRenderer.Camera.Y;
                cameraY2 = ScreenRenderer.Camera.Y2;
            }
            else
            {
                cameraX  = 0;
                cameraX2 = Graphics.Renderers.Screen.ScreenRenderer.RenderOptions.Map.MaxX;
                cameraY  = 0;
                cameraY2 = Graphics.Renderers.Screen.ScreenRenderer.RenderOptions.Map.MaxY;
            }
            SdlDotNet.Graphics.Surface screenshotSurf = new SdlDotNet.Graphics.Surface((cameraX2 - cameraX) * Constants.TILE_WIDTH, (cameraY2 - cameraY) * Constants.TILE_HEIGHT);
            screenshotSurf.Fill(Color.White);
            Client.Logic.Graphics.Renderers.Maps.MapRenderer.DrawTiles(new Logic.Graphics.Renderers.RendererDestinationData(screenshotSurf, new Point(0, 0), screenshotSurf.Size), Graphics.Renderers.Screen.ScreenRenderer.RenderOptions.Map, Graphics.Renderers.Screen.ScreenRenderer.RenderOptions.DisplayAnimation, cameraX, cameraX2, cameraY, cameraY2, captureAttributes, captureMapGrid);
            return(screenshotSurf);
        }
Esempio n. 5
0
 public override void BlitToScreen(SdlDotNet.Graphics.Surface destinationSurface)
 {
     base.BlitToScreen(destinationSurface);
     //rwLock.EnterReadLock();
     destSurf = destinationSurface;
     for (int i = 0; i < openMenus.Count; i++)
     {
         if (openMenus[i].MenuPanel.ReadyToConfigure)
         {
             openMenus[i].MenuPanel.Location = new Point(this.X + openMenus[i].MenuPanel.X, this.Y + openMenus[i].MenuPanel.Y);
             //openMenus[i].MenuPanel.RequestRedraw();
             openMenus[i].MenuPanel.ReadyToConfigure = false;
         }
         if (destSurf != null)
         {
             openMenus[i].MenuPanel.BlitToScreen(destSurf);
         }
     }
     try {
         //for (int i = 0; i < openMenus.Count; i++) {
         //    if (openMenus[i].MenuPanel.ReadyToConfigure) {
         //        openMenus[i].MenuPanel.Location = new Point(this.X + openMenus[i].MenuPanel.X, this.Y + openMenus[i].MenuPanel.Y);
         //        //openMenus[i].MenuPanel.RequestRedraw();
         //        openMenus[i].MenuPanel.ReadyToConfigure = false;
         //    }
         //    openMenus[i].MenuPanel.BlitToScreen(destinationSurface);
         //}
     } finally {
         //rwLock.ExitReadLock();
     }
     //foreach (IMenu menu in openMenus) {
     //    menu.MenuPanel.BlitToScreen(destinationSurface);//, new Point(this.X + menu.MenuPanel.X, this.Y + menu.MenuPanel.Y));
     //}
 }
Esempio n. 6
0
 /// <summary>
 /// Combines two surfaces together.
 /// </summary>
 /// <param name="bottomImage">The surface that will be used as the background.</param>
 /// <param name="topImage">The surface that will be used as the foreground.</param>
 /// <returns>The combined surface.</returns>
 public static SdlDotNet.Graphics.Surface CombineImage(SdlDotNet.Graphics.Surface bottomImage, SdlDotNet.Graphics.Surface topImage)
 {
     SdlDotNet.Graphics.Surface returnSurf = new SdlDotNet.Graphics.Surface(new System.Drawing.Size(System.Math.Max(bottomImage.Width, topImage.Width), System.Math.Max(bottomImage.Height, topImage.Height)));
     returnSurf.Blit(bottomImage, new System.Drawing.Point(0, 0));
     returnSurf.Blit(topImage, new System.Drawing.Point(0, 0));
     return returnSurf;
 }
Esempio n. 7
0
 /// <summary>
 /// Combines two surfaces together.
 /// </summary>
 /// <param name="bottomImage">The surface that will be used as the background.</param>
 /// <param name="topImage">The surface that will be used as the foreground.</param>
 /// <returns>The combined surface.</returns>
 public static SdlDotNet.Graphics.Surface CombineImage(SdlDotNet.Graphics.Surface bottomImage, SdlDotNet.Graphics.Surface topImage)
 {
     SdlDotNet.Graphics.Surface returnSurf = new SdlDotNet.Graphics.Surface(new System.Drawing.Size(System.Math.Max(bottomImage.Width, topImage.Width), System.Math.Max(bottomImage.Height, topImage.Height)));
     returnSurf.Blit(bottomImage, new System.Drawing.Point(0, 0));
     returnSurf.Blit(topImage, new System.Drawing.Point(0, 0));
     return(returnSurf);
 }
Esempio n. 8
0
 private void Resize(object sender, SdlDotNet.Graphics.VideoResizeEventArgs e)
 {
     this.width            = e.Width;
     this.height           = e.Height;
     screen                = SdlDotNet.Graphics.Video.SetVideoMode(width, height, currentBpp, true);
     screen.SourceColorKey = Color.Magenta;
     weatherOverlay.setSize(new Size(width, height));
     qView.Size = new Size(e.Width, e.Height);
 }
Esempio n. 9
0
        public override void paint(SdlDotNet.Graphics.Surface display, bool focused, Point offset)
        {
            PCLable.Text = String.Format("{0:X4}", atari.m_PC);
            ALable.Text  = String.Format("{0:X2}", atari.m_A);
            XLable.Text  = String.Format("{0:X2}", atari.m_X);
            YLable.Text  = String.Format("{0:X2}", atari.m_Y);
            SLable.Text  = String.Format("{0:X2}", atari.m_S);

            string flags = "CZIDB1VS";
            string p     = "";
            byte   mp    = atari.BuildStatus(false);

            for (int i = 0; i < 8; i++)
            {
                if ((mp & 1 << i) != 0)
                {
                    p += flags[i];
                }
                else
                {
                    p += "-";
                }
            }
            PLable.Text = String.Format(p);

            if (followPC)
            {
                addressChanged(atari.m_PC);
            }

            ushort pos = focusAddress;

            string adr = "";
            string dat = "";
            string ins = "";

            for (int i = 0; i < 13; i++)
            {
                adr += String.Format("{0:x4}\n", pos);
                ins += ((pos == atari.m_PC)?"--> ":"    ") + atari.instructionAsm(pos) + "\n";

                byte[] d = atari.instructionData(pos);
                for (int b = 0; b < d.Length; b++)
                {
                    dat += String.Format("{0:x2} ", d[b]);
                }
                dat += "\n";

                pos += (ushort)d.Length;
            }

            address.Text     = adr;
            instruction.Text = ins;
            data.Text        = dat;

            base.paint(display, focused, offset);
        }
Esempio n. 10
0
 /// <summary>
 /// Crops a surface from the specified surface.
 /// </summary>
 /// <param name="surfaceToCrop">The surface to crop.</param>
 /// <param name="cropRectangle">The rectangle bounds to crop.</param>
 /// <returns>The cropped surface.</returns>
 public static SdlDotNet.Graphics.Surface CropImage(SdlDotNet.Graphics.Surface surfaceToCrop, System.Drawing.Rectangle cropRectangle)
 {
     SdlDotNet.Graphics.Surface returnSurf = new SdlDotNet.Graphics.Surface(cropRectangle.Size);
     returnSurf.Transparent = surfaceToCrop.Transparent;
     //returnSurf.Fill(System.Drawing.Color.Transparent);
     //returnSurf.TransparentColor = surfaceToCrop.TransparentColor;
     returnSurf.Blit(surfaceToCrop, new System.Drawing.Point(0, 0), cropRectangle);
     return(returnSurf);
 }
Esempio n. 11
0
 /// <summary>
 /// Crops a surface from the specified surface.
 /// </summary>
 /// <param name="surfaceToCrop">The surface to crop.</param>
 /// <param name="cropRectangle">The rectangle bounds to crop.</param>
 /// <returns>The cropped surface.</returns>
 public static SdlDotNet.Graphics.Surface CropImage(SdlDotNet.Graphics.Surface surfaceToCrop, System.Drawing.Rectangle cropRectangle)
 {
     SdlDotNet.Graphics.Surface returnSurf = new SdlDotNet.Graphics.Surface(cropRectangle.Size);
     returnSurf.Transparent = surfaceToCrop.Transparent;
     //returnSurf.Fill(System.Drawing.Color.Transparent);
     //returnSurf.TransparentColor = surfaceToCrop.TransparentColor;
     returnSurf.Blit(surfaceToCrop, new System.Drawing.Point(0, 0), cropRectangle);
     return returnSurf;
 }
Esempio n. 12
0
 public Window()
     : base(true)
 {
     mControlBounds      = new Rectangle(0, 0, 300, 300);
     mMinimizeButtonSurf = new SdlDotNet.Graphics.Surface(IO.IO.CreateOSPath("Skins\\" + Globals.ActiveSkin + "\\General\\Windows\\minimizebutton.png"));
     mMaximizeButtonSurf = new SdlDotNet.Graphics.Surface(IO.IO.CreateOSPath("Skins\\" + Globals.ActiveSkin + "\\General\\Windows\\maximizebutton.png"));
     mCloseButtonSurf    = new SdlDotNet.Graphics.Surface(IO.IO.CreateOSPath("Skins\\" + Globals.ActiveSkin + "\\General\\Windows\\closebutton.png"));
     InitBuffer();
     mMaximizedControlBounds = new Rectangle(new Point(mMaximizedBounds.Location.X + 1, mMaximizedBounds.Location.Y + 1 + mTitleBarBounds.Height), SubtractBorderSize(mMaximizedBounds.Size));
 }
Esempio n. 13
0
 public virtual void Tick(SdlDotNet.Graphics.Surface dstSurf, SdlDotNet.Core.TickEventArgs e)
 {
     if (!mIsDisposing)
     {
         if (mWindowState != WindowManager.WindowState.Minimized)
         {
             this.UpdateControls(dstSurf, e);
         }
     }
 }
Esempio n. 14
0
 public Window()
     : base(true)
 {
     mControlBounds = new Rectangle(0, 0, 300, 300);
     mMinimizeButtonSurf = new SdlDotNet.Graphics.Surface(IO.IO.CreateOSPath("Skins\\" + Globals.ActiveSkin + "\\General\\Windows\\minimizebutton.png"));
     mMaximizeButtonSurf = new SdlDotNet.Graphics.Surface(IO.IO.CreateOSPath("Skins\\" + Globals.ActiveSkin + "\\General\\Windows\\maximizebutton.png"));
     mCloseButtonSurf = new SdlDotNet.Graphics.Surface(IO.IO.CreateOSPath("Skins\\" + Globals.ActiveSkin + "\\General\\Windows\\closebutton.png"));
     InitBuffer();
     mMaximizedControlBounds = new Rectangle(new Point(mMaximizedBounds.Location.X + 1, mMaximizedBounds.Location.Y + 1 + mTitleBarBounds.Height), SubtractBorderSize(mMaximizedBounds.Size));
 }
Esempio n. 15
0
 public void DrawToScreen(SdlDotNet.Graphics.Surface destinationSurface)
 {
     //for (int i = 0; i < openMenus.Count; i++) {
     //    if (openMenus[i].MenuPanel.ReadyToConfigure) {
     //        openMenus[i].MenuPanel.Location = new Point(this.X + openMenus[i].MenuPanel.X, this.Y + openMenus[i].MenuPanel.Y);
     //        //openMenus[i].MenuPanel.RequestRedraw();
     //        openMenus[i].MenuPanel.ReadyToConfigure = false;
     //    }
     //    openMenus[i].MenuPanel.BlitToScreen(destinationSurface);
     //}
 }
Esempio n. 16
0
 void lblAllMoves_MouseDown(object sender, MouseButtonEventArgs e)
 {
     if (Windows.WindowSwitcher.GameWindow.MenuManager.FindMenu("mnuMoveSelected") == null)
     {
         Label label = (Label)sender;
         SdlDotNet.Graphics.Surface dragSurf = new SdlDotNet.Graphics.Surface(label.Buffer.Size);
         dragSurf.Fill(Color.Black);
         dragSurf.Blit(label.Buffer, new Point(0, 0));
         label.DoDragDrop(Array.IndexOf(lblAllMoves, sender), DragDropEffects.Copy, dragSurf);
     }
 }
Esempio n. 17
0
 /// <summary>
 /// Default constructor
 /// </summary>
 public Turtle()
 {
     _backColor = Color.White;
     _foreColor = Color.Black;
     _image = null;
     _location = new Point(0, 0);
     _penDown = true;
     _penWidth = 1F;
     _size = new Size(640, 480);
     _surface = null;
 }
Esempio n. 18
0
        public SdlDotNet.Graphics.Surface RenderPassword(char passwordChar)
        {
            int charWidth = mFont.SizeText(passwordChar.ToString()).Width;

            SdlDotNet.Graphics.Surface tempSurf = new SdlDotNet.Graphics.Surface(mMaxWidth, mFont.Height);
            tempSurf.Fill(Color.Transparent);
            tempSurf.TransparentColor = Color.Transparent;
            tempSurf.Transparent      = true;
            int lastX = 0;

            for (int i = 0; i < mChars.Count; i++)
            {
                if (mChars[i].Char != "\n")
                {
                    if (mChars[i].CharOptions != null)
                    {
                        mFont.Bold      = mChars[i].CharOptions.Bold;
                        mFont.Italic    = mChars[i].CharOptions.Italic;
                        mFont.Underline = mChars[i].CharOptions.Underline;
                    }
                    Color bltColor;
                    if (mChars[i].CharColor == Color.Empty)
                    {
                        bltColor = mDefaultForeColor;
                    }
                    else
                    {
                        bltColor = mChars[i].CharColor;
                    }
                    SdlDotNet.Graphics.Surface charSurf = mFont.Render(passwordChar.ToString(), bltColor, false);
                    tempSurf.Blit(charSurf, new Point(lastX, 0));
                    charSurf.Close();
                    if (mFont.Bold == true)
                    {
                        mFont.Bold = false;
                    }
                    if (mFont.Italic == true)
                    {
                        mFont.Italic = false;
                    }
                    if (mFont.Underline == true)
                    {
                        mFont.Underline = false;
                    }
                    lastX += charWidth;
                }
            }

            return(tempSurf);
        }
Esempio n. 19
0
 void lblVisibleItems_MouseDown(object sender, MouseButtonEventArgs e)
 {
     if (mode == Enums.InvMenuType.Use)
     {
         if (Windows.WindowSwitcher.GameWindow.MenuManager.FindMenu("mnuItemSelected") == null)
         {
             Label label = (Label)sender;
             SdlDotNet.Graphics.Surface dragSurf = new SdlDotNet.Graphics.Surface(label.Buffer.Size);
             dragSurf.Fill(Color.Black);
             dragSurf.Blit(label.Buffer, new Point(0, 0));
             label.DoDragDrop(Array.IndexOf(lblVisibleItems, sender) + 1 + (currentTen * 10), DragDropEffects.Copy, dragSurf);
         }
     }
 }
Esempio n. 20
0
        public override void UpdateControls(SdlDotNet.Graphics.Surface dstSurf, SdlDotNet.Core.TickEventArgs e)
        {
            try {
                if (!mIsDisposing)
                {
//					mBuffer.Fill(SystemColors.Control);
                    base.UpdateControls(mBuffer, e);
                    if (mWindowed)
                    {
                        dstSurf.Blit(mBorderBuffer, mFullBounds.Location, new Rectangle(0, 0, this.FullBounds.Width, this.FullBounds.Height));
                    }
                    dstSurf.Blit(mBuffer, mControlBounds.Location, new Rectangle(0, 0, this.ControlBounds.Width, this.ControlBounds.Height));
                }
            } catch {
            }
        }
Esempio n. 21
0
        public override void paint(SdlDotNet.Graphics.Surface surface, bool focused, Point offset)
        {
            Point p = offset;

            foreach (Atom a in docked)
            {
                DisplayCaption dc;
                if (a == null)
                {
                    dc = DisplaySettings.defaultCaption;
                }
                else
                {
                    dc = a.Caption;
                    dc.UseDefaultIcon = true;
                }

                if (selectedAtom != a)
                {
                    DisplayIcon i = dc.Icon;

                    p.Y = (Height - i.Height) / 2 + offset.Y;
                    i.Blit(surface, p);

                    p.X += i.Width + Compound.Padding;
                }
                else
                {
                    Rectangle oldClipper = surface.ClipRectangle;
                    Rectangle newClipper = new Rectangle(p, new Size(decompressedSize, dc.Height));

                    newClipper.Intersect(oldClipper);
                    surface.ClipRectangle = newClipper;

                    p.Y = (Height - dc.Height) / 2 + offset.Y;
                    dc.Blit(surface, p);

                    surface.ClipRectangle = oldClipper;
                    p.X += decompressedSize + Compound.Padding;

                    if (decompressedSize < dc.Width)
                    {
                        decompressedSize++;
                    }
                }
            }
        }
Esempio n. 22
0
        void btnTakeScreenshot_Click(object sender, SdlDotNet.Widgets.MouseButtonEventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Filter       = "Portable Network Graphic File|*.png|GIF File|*.gif|JPEG File|*.jpg|Bitmap File|*.bmp|Icon File|*.ico";
            sfd.AddExtension = true;
            if (sfd.ShowDialog() == SdlDotNet.Widgets.DialogResult.OK)
            {
                if (WindowSwitcher.GameWindow.MapViewer.ActiveMap != null && WindowSwitcher.GameWindow.MapViewer.ActiveMap.Loaded)
                {
                    SdlDotNet.Graphics.Surface surf = WindowSwitcher.GameWindow.MapViewer.CaptureMapImage(chkCaptureRegion.Checked, chkCaptureAttributes.Checked, chkCaptureMapGrid.Checked);
                    Graphics.SurfaceManager.SaveSurface(surf, sfd.FileName);
                    tmrHideInfo.Start();
                    lblSaved.Visible = true;
                }
            }
        }
Esempio n. 23
0
        private void AddBorder()
        {
            Size newSize = this.Size;

            switch (mWindowState)
            {
            case WindowManager.WindowState.Normal:
                newSize = this.Size;
                break;

            case WindowManager.WindowState.Maximized:
                newSize = new Size(SdlDotNet.Graphics.Video.Screen.Width, SdlDotNet.Graphics.Video.Screen.Height - Globals.GameScreen.TaskBar.Height);
                break;

            case WindowManager.WindowState.Minimized:
                return;
            }
            mBorderBuffer = new SdlDotNet.Graphics.Surface(AddBorderSize(newSize));
            mBorderBuffer.AlphaBlending = true;
            mBorderBuffer.Alpha         = mBorderAlpha;
            mTitleBarBounds             = new Rectangle(0, 0, newSize.Width + 2, 20);
            mTitleBarSurface            = new SdlDotNet.Graphics.Surface(mTitleBarBounds.Size);
            mTitleBarSurface.Fill(Color.Blue);
            if (mText != "")
            {
                mTitleBarSurface.Blit(Logic.Graphics.FontManager.TextBoxFont.Render(mText, Color.Black, false), new Point(20, 3));
            }
            mCloseButtonBounds = new Rectangle(new Point(mTitleBarSurface.Width - 3 - mCloseButtonSurf.Width, 0), mCloseButtonSurf.Size);
            if (mCloseable)
            {
                mTitleBarSurface.Blit(mCloseButtonSurf, new Point(mTitleBarSurface.Width - 3 - mCloseButtonSurf.Width, 0));
            }
            mMaximizeButtonBounds = new Rectangle(new Point(mTitleBarSurface.Width - 3 - mCloseButtonSurf.Width - mMaximizeButtonSurf.Width, 0), mMaximizeButtonSurf.Size);
            if (mMaximizable)
            {
                mTitleBarSurface.Blit(mMaximizeButtonSurf, new Point(mTitleBarSurface.Width - 3 - mCloseButtonSurf.Width - mMaximizeButtonSurf.Width, 0));
            }
            mMinimizeButtonBounds = new Rectangle(new Point(mTitleBarSurface.Width - 3 - mCloseButtonSurf.Width - mMinimizeButtonSurf.Width - mMinimizeButtonSurf.Width, 0), mMinimizeButtonSurf.Size);
            if (mMinimizable)
            {
                mTitleBarSurface.Blit(mMinimizeButtonSurf, new Point(mTitleBarSurface.Width - 3 - mCloseButtonSurf.Width - mMinimizeButtonSurf.Width - mMinimizeButtonSurf.Width, 0));
            }
            mBorderBuffer.Blit(mTitleBarSurface, mTitleBarBounds.Location);
        }
Esempio n. 24
0
        private void InitBuffer()
        {
            Size newSize = this.Size;

            switch (mWindowState)
            {
            case WindowManager.WindowState.Normal:
                newSize = this.Size;
                break;

            case WindowManager.WindowState.Maximized:
                newSize = new Size(SdlDotNet.Graphics.Video.Screen.Width, SdlDotNet.Graphics.Video.Screen.Height - Globals.GameScreen.TaskBar.Height);
                break;

            case WindowManager.WindowState.Minimized:
                return;
            }
            if (mBuffer != null)
            {
                mBuffer.Close();
                mBuffer.Dispose();
            }
            mBuffer = new SdlDotNet.Graphics.Surface(AddBorderSize(newSize));
            mBuffer.AlphaBlending = true;
            mBuffer.Alpha         = mControlsAlpha;
            mBuffer.Fill(SystemColors.Control);
            if (mWindowed)
            {
                AddBorder();
            }
            else
            {
                mCloseable   = false;
                mMinimizable = false;
                mMaximizable = false;
            }
        }
Esempio n. 25
0
        private void DrawTiles()
        {
            if (vScroll != null && hScroll != null & activeItemSurf != null)
            {
                int maxTilesX = System.Math.Min(activeItemSurf.Size.Width, (this.Width - vScroll.Width)) / Constants.TILE_WIDTH;
                int maxTilesY = System.Math.Min(activeItemSurf.Size.Height, (this.Height - hScroll.Height)) / Constants.TILE_HEIGHT;
                int startX    = hScroll.Value;
                int startY    = vScroll.Value;

                for (int y = startY; y < maxTilesY + startY; y++)
                {
                    for (int x = startX; x < maxTilesX + startX; x++)
                    {
                        //int num = DetermineTileNumber(x, y);
                        //if (x < (activeItemSurf.Size.Width / Constants.TILE_WIDTH) && y < (activeItemSurf.Size.Height / Constants.TILE_HEIGHT))
                        //{
                        SdlDotNet.Graphics.Surface tile = new SdlDotNet.Graphics.Surface(Constants.TILE_WIDTH, Constants.TILE_HEIGHT);
                        tile.Blit(activeItemSurf, new Point(0, 0), new Rectangle(x * Constants.TILE_WIDTH, y * Constants.TILE_HEIGHT, Constants.TILE_WIDTH, Constants.TILE_HEIGHT));
                        base.Buffer.Blit(tile, new Point((x - startX) * Constants.TILE_WIDTH, (y - startY) * Constants.TILE_HEIGHT));
                        //}
                    }
                }
            }
        }
Esempio n. 26
0
 public Point GetCenter(SdlDotNet.Graphics.Surface mTexture, Size graphicSize)
 {
     return(new Point((mTexture.Width / 2) - (graphicSize.Width / 2), (mTexture.Height / 2) - (graphicSize.Height / 2)));
 }
Esempio n. 27
0
 //protected override void DrawBuffer() {
 //    base.DrawBuffer();
 //    if (Graphics.Renderers.Screen.ScreenRenderer.RenderOptions.Map != null && Graphics.Renderers.Screen.ScreenRenderer.RenderOptions.Map.Loaded) {
 //        //Graphics.Renderers.Screen.ScreenRenderer.RenderScreen(base.Buffer, this.Location);
 //        //gl.DrawScreen(base.Buffer, activeMap, mapAnim, this.cameraX, this.cameraX2, this.cameraY, this.cameraY2, displayAttributes, displayMapGrid, displayLocation, overlay);
 //        Logic.Graphics.Renderers.Screen.ScreenRenderer.RenderScreen(destData);
 //    }
 //    if (font != null) {
 //        //if (IO.Settings.DisplayCursorLocation) {
 //        //    fpsY += 27;
 //        //    DrawText("X: " + (Globals.CursorX + 1).ToString() + " Y: " + (Globals.CursorY + 1).ToString(), Color.Red, 5, 0);
 //        //}
 //        //if (IO.Settings.DisplayFPS) {
 //        //    DrawText("FPS: " + SdlDotNet.Core.Events.Fps.ToString(), Color.Red, 5, fpsY);
 //        //}
 //    }
 //    base.DrawBorder();
 //    base.DrawComplete();
 //}
 public SdlDotNet.Graphics.Surface CaptureMapImage(bool captureVisibleArea, bool captureAttributes, bool captureMapGrid)
 {
     int cameraX;
     int cameraX2;
     int cameraY;
     int cameraY2;
     if (captureVisibleArea) {
         cameraX = ScreenRenderer.Camera.X;
         cameraX2 = ScreenRenderer.Camera.X2;
         cameraY = ScreenRenderer.Camera.Y;
         cameraY2 = ScreenRenderer.Camera.Y2;
     } else {
         cameraX = 0;
         cameraX2 = Graphics.Renderers.Screen.ScreenRenderer.RenderOptions.Map.MaxX;
         cameraY = 0;
         cameraY2 = Graphics.Renderers.Screen.ScreenRenderer.RenderOptions.Map.MaxY;
     }
     SdlDotNet.Graphics.Surface screenshotSurf = new SdlDotNet.Graphics.Surface((cameraX2 - cameraX) * Constants.TILE_WIDTH, (cameraY2 - cameraY) * Constants.TILE_HEIGHT);
     screenshotSurf.Fill(Color.White);
     Client.Logic.Graphics.Renderers.Maps.MapRenderer.DrawTiles(new Logic.Graphics.Renderers.RendererDestinationData(screenshotSurf, new Point(0, 0), screenshotSurf.Size), Graphics.Renderers.Screen.ScreenRenderer.RenderOptions.Map, Graphics.Renderers.Screen.ScreenRenderer.RenderOptions.DisplayAnimation, cameraX, cameraX2, cameraY, cameraY2, captureAttributes, captureMapGrid);
     return screenshotSurf;
 }
Esempio n. 28
0
 void lblVisibleItems_MouseDown(object sender, MouseButtonEventArgs e)
 {
     if (mode == Enums.InvMenuType.Use) {
         if (Windows.WindowSwitcher.GameWindow.MenuManager.FindMenu("mnuItemSelected") == null) {
             Label label = (Label)sender;
             SdlDotNet.Graphics.Surface dragSurf = new SdlDotNet.Graphics.Surface(label.Buffer.Size);
             dragSurf.Fill(Color.Black);
             dragSurf.Blit(label.Buffer, new Point(0, 0));
             label.DoDragDrop(Array.IndexOf(lblVisibleItems, sender) + 1 + (currentTen * 10), DragDropEffects.Copy, dragSurf);
         }
     }
 }
Esempio n. 29
0
 public override void Tick(SdlDotNet.Graphics.Surface dstSurf, SdlDotNet.Core.TickEventArgs e)
 {
     base.Tick(dstSurf, e);
 }
Esempio n. 30
0
        private void frmMain_Load(object sender, EventArgs e)
        {
            // "Fix" T7G path
            if (!Properties.Settings.Default.T7GPath.EndsWith("\\"))
            {
                Properties.Settings.Default.T7GPath = Properties.Settings.Default.T7GPath + "\\";
                Properties.Settings.Default.Save();
            }

            game = Detector.detectGame(path);
            readGameData();
            s = new SdlDotNet.Graphics.Surface(this.surface.Width, this.surface.Height);
            SdlDotNet.Core.Events.Tick += new EventHandler<SdlDotNet.Core.TickEventArgs>(this.Tick);
            SdlDotNet.Core.Events.TargetFps = 15;
            Thread thread = new Thread(new ThreadStart(SdlDotNet.Core.Events.Run));
            thread.IsBackground = true;
            thread.Name = "SDL.NET";
            thread.Priority = ThreadPriority.Normal;
            /*
            GJD.RLData rl;
            rl.length = (uint)(new System.IO.FileInfo("tmp.vdx")).Length;
            rl.filename = "tmp.vdx";
            rl.offset = 0;
            rl.number = 0;
            vdx = new VDX(new System.IO.BinaryReader(System.IO.File.Open("tmp.vdx", System.IO.FileMode.Open)), rl, s);
            */
            thread.Start();
        }
Esempio n. 31
0
 void lblAllMoves_MouseDown(object sender, MouseButtonEventArgs e)
 {
     if (Windows.WindowSwitcher.GameWindow.MenuManager.FindMenu("mnuMoveSelected") == null) {
         Label label = (Label)sender;
         SdlDotNet.Graphics.Surface dragSurf = new SdlDotNet.Graphics.Surface(label.Buffer.Size);
         dragSurf.Fill(Color.Black);
         dragSurf.Blit(label.Buffer, new Point(0, 0));
         label.DoDragDrop(Array.IndexOf(lblAllMoves, sender), DragDropEffects.Copy, dragSurf);
     }
 }
Esempio n. 32
0
 abstract public void paint(SdlDotNet.Graphics.Surface surface, bool focused, Point offset);
Esempio n. 33
0
        public ActiveTeamPanel(string name)
            : base(name)
        {
            base.BackColor = Color.Transparent;

            //base.BackgroundImageSizeMode = ImageSizeMode.StretchImage;
            base.BackgroundImage = Skins.SkinManager.LoadGui("Game Window/TeamPanel");

            selectedSlot = -1;

            picActiveRecruitBorder           = new PictureBox("picActiveRecruitBorder");
            picActiveRecruitBorder.Size      = new Size(48, 48);
            picActiveRecruitBorder.BackColor = Color.Transparent;
            picActiveRecruitBorder.Visible   = false;
            SdlDotNet.Graphics.Surface surf = Skins.SkinManager.LoadGuiElement("Game Window", "TeamPanel\\selected.png");
            picActiveRecruitBorder.Image = surf;

            this.AddWidget(picActiveRecruitBorder);

            picRecruit      = new PictureBox[4];
            picStatus       = new PictureBox[4];
            picHeldItem     = new PictureBox[4];
            lblRecruitLevel = new Label[4];
            lblRecruitHP    = new Label[4];
            pgbRecruitHP    = new ProgressBar[4];
            lblRecruitExp   = new Label[4];
            pgbRecruitExp   = new ProgressBar[4];

            for (int i = 0; i < 4; i++)
            {
                picRecruit[i]             = new PictureBox("picRecruit" + i.ToString());
                picRecruit[i].Size        = new Size(40, 40);
                picRecruit[i].Location    = new Point(19 + i * 208, 20);
                picRecruit[i].SizeMode    = ImageSizeMode.StretchImage;
                picRecruit[i].BorderStyle = SdlDotNet.Widgets.BorderStyle.FixedSingle;
                picRecruit[i].BorderColor = Color.Black;
                picRecruit[i].BorderWidth = 1;
                picRecruit[i].Click      += new EventHandler <SdlDotNet.Widgets.MouseButtonEventArgs>(picRecruit_Click);

                picStatus[i]           = new PictureBox("picStatus" + i.ToString());
                picStatus[i].Size      = new Size(32, 16);
                picStatus[i].BackColor = Color.Transparent;
                picStatus[i].Location  = new Point(59 + i * 208, 18);

                picHeldItem[i]           = new PictureBox("picHeldItem" + i.ToString());
                picHeldItem[i].Size      = new Size(32, 32);
                picHeldItem[i].BackColor = Color.Transparent;
                picHeldItem[i].Location  = new Point(55 + i * 208, 32);
                //picHeldItem[i].Click += new EventHandler<SdlDotNet.Widgets.MouseButtonEventArgs>(picHeldItem_Click);

                lblRecruitLevel[i]          = new Label("lblRecruitLevel" + i.ToString());
                lblRecruitLevel[i].Font     = Logic.Graphics.FontManager.LoadFont("PMDCP", 16);
                lblRecruitLevel[i].Location = new Point(83 + i * 208, 14);
                lblRecruitLevel[i].AutoSize = true;

                lblRecruitHP[i]          = new Label("lblRecruitHP" + i.ToString());
                lblRecruitHP[i].Font     = Logic.Graphics.FontManager.LoadFont("PMDCP", 16);
                lblRecruitHP[i].Location = new Point(82 + i * 208, 28);
                lblRecruitHP[i].AutoSize = true;
                lblRecruitHP[i].Text     = "HP:";

                pgbRecruitHP[i]          = new ProgressBar("pgbRecruitHP" + i.ToString());
                pgbRecruitHP[i].Size     = new Size(100, 14);
                pgbRecruitHP[i].Location = new Point(107 + i * 208, 31);
                pgbRecruitHP[i].Maximum  = 100;
                pgbRecruitHP[i].Minimum  = 0;

                lblRecruitExp[i]          = new Label("lblRecruitExp" + i.ToString());
                lblRecruitExp[i].Font     = Logic.Graphics.FontManager.LoadFont("PMDCP", 16);
                lblRecruitExp[i].Location = new Point(82 + i * 208, 44);
                lblRecruitExp[i].Text     = "Exp:";

                pgbRecruitExp[i]          = new ProgressBar("pgbRecruitExp" + i.ToString());
                pgbRecruitExp[i].Location = new Point(107 + i * 208, 47);
                pgbRecruitExp[i].Size     = new Size(100, 14);
                pgbRecruitExp[i].BarColor = Color.CornflowerBlue;
                pgbRecruitExp[i].Font     = Logic.Graphics.FontManager.LoadFont("tahoma", 10);
                pgbRecruitExp[i].Maximum  = 100;
                pgbRecruitExp[i].Minimum  = 0;


                this.AddWidget(picRecruit[i]);
                this.AddWidget(picStatus[i]);
                this.AddWidget(picHeldItem[i]);
                this.AddWidget(lblRecruitLevel[i]);
                this.AddWidget(lblRecruitHP[i]);
                this.AddWidget(pgbRecruitHP[i]);
                this.AddWidget(lblRecruitExp[i]);
                this.AddWidget(pgbRecruitExp[i]);
            }
        }
Esempio n. 34
0
        public SdlDotNet.Graphics.Surface RenderPassword(char passwordChar)
        {
            int charWidth = mFont.SizeText(passwordChar.ToString()).Width;
            SdlDotNet.Graphics.Surface tempSurf = new SdlDotNet.Graphics.Surface(mMaxWidth, mFont.Height);
            tempSurf.Fill(Color.Transparent);
            tempSurf.TransparentColor = Color.Transparent;
            tempSurf.Transparent = true;
            int lastX = 0;
            for (int i = 0; i < mChars.Count; i++) {
                if (mChars[i].Char != "\n") {
                    if (mChars[i].CharOptions != null) {
                        mFont.Bold = mChars[i].CharOptions.Bold;
                        mFont.Italic = mChars[i].CharOptions.Italic;
                        mFont.Underline = mChars[i].CharOptions.Underline;
                    }
                    Color bltColor;
                    if (mChars[i].CharColor == Color.Empty)
                        bltColor = mDefaultForeColor;
                    else
                        bltColor = mChars[i].CharColor;
                    SdlDotNet.Graphics.Surface charSurf = mFont.Render(passwordChar.ToString(), bltColor, false);
                    tempSurf.Blit(charSurf, new Point(lastX, 0));
                    charSurf.Close();
                    if (mFont.Bold == true) {
                        mFont.Bold = false;
                    }
                    if (mFont.Italic == true) {
                        mFont.Italic = false;
                    }
                    if (mFont.Underline == true) {
                        mFont.Underline = false;
                    }
                    lastX += charWidth;
                }
            }

            return tempSurf;
        }
Esempio n. 35
0
        private void DrawTiles()
        {
            if (vScroll != null && hScroll != null & activeItemSurf != null)
            {
                int maxTilesX = System.Math.Min(activeItemSurf.Size.Width, (this.Width - vScroll.Width)) / Constants.TILE_WIDTH;
                int maxTilesY = System.Math.Min(activeItemSurf.Size.Height, (this.Height - hScroll.Height)) / Constants.TILE_HEIGHT;
                int startX = hScroll.Value;
                int startY = vScroll.Value;

                for (int y = startY; y < maxTilesY + startY; y++)
                {
                    for (int x = startX; x < maxTilesX + startX; x++)
                    {
                        //int num = DetermineTileNumber(x, y);
                        //if (x < (activeItemSurf.Size.Width / Constants.TILE_WIDTH) && y < (activeItemSurf.Size.Height / Constants.TILE_HEIGHT))
                        //{
                        SdlDotNet.Graphics.Surface tile = new SdlDotNet.Graphics.Surface(Constants.TILE_WIDTH, Constants.TILE_HEIGHT);
                        tile.Blit(activeItemSurf, new Point(0, 0), new Rectangle(x * Constants.TILE_WIDTH, y * Constants.TILE_HEIGHT, Constants.TILE_WIDTH, Constants.TILE_HEIGHT));
                        base.Buffer.Blit(tile, new Point((x - startX) * Constants.TILE_WIDTH, (y - startY) * Constants.TILE_HEIGHT));
                        //}
                    }
                }
            }
        }
Esempio n. 36
0
        /// <summary>
        /// Encrypts all png graphics
        /// </summary>
        private static void DoGraphicConversions()
        {
            //if (IO.IO.FileExists("GFX\\Arrows.png")) {
            //    System.IO.File.WriteAllBytes(IO.IO.GetGfxPath("Arrows.pmugfx"), Graphics.SurfaceManager.EncryptSurface(IO.IO.GetGfxPath("Arrows.png")));
            //    System.IO.File.Delete(IO.IO.GetGfxPath("Arrows.png"));
            //}
            //if (IO.IO.FileExists("GFX\\BigSpells.png")) {
            //    System.IO.File.WriteAllBytes(IO.IO.GetGfxPath("BigSpells.pmugfx"), Graphics.SurfaceManager.EncryptSurface(IO.IO.GetGfxPath("BigSpells.png")));
            //    System.IO.File.Delete(IO.IO.GetGfxPath("BigSpells.png"));
            //}
            //if (IO.IO.FileExists("GFX\\BigSprites.png")) {
            //    System.IO.File.WriteAllBytes(IO.IO.GetGfxPath("BigSprites0.pmugfx"), Graphics.SurfaceManager.EncryptSurface(IO.IO.GetGfxPath("BigSprites.png")));
            //    System.IO.File.Delete(IO.IO.GetGfxPath("BigSprites.png"));
            //}
            //if (IO.IO.FileExists("GFX\\Spells.png")) {
            //    System.IO.File.WriteAllBytes(IO.IO.GetGfxPath("Spells.pmugfx"), Graphics.SurfaceManager.EncryptSurface(IO.IO.GetGfxPath("Spells.png")));
            //    System.IO.File.Delete(IO.IO.GetGfxPath("Spells.png"));
            //}
            //for (int i = 0; i < Graphics.GraphicsManager.MAX_TILES; i++) {
            //    if (IO.IO.FileExists(IO.Paths.GfxPath + "Tiles" + i.ToString() + ".png")) {
            //        System.IO.File.WriteAllBytes(IO.Paths.GfxPath + "Tiles" + i.ToString() + ".pmugfx", Graphics.SurfaceManager.EncryptSurface(IO.Paths.GfxPath + "Tiles" + i.ToString() + ".png"));
            //        System.IO.File.Delete(IO.Paths.GfxPath + "Tiles" + i.ToString() + ".png");
            //    }
            //}
            string[] files = System.IO.Directory.GetFiles(IO.Paths.GfxPath + "Sprites/", "*", SearchOption.TopDirectoryOnly);
            for (int i = 0; i < files.Length; i++)
            {
                if (files[i].EndsWith(".png"))
                {
                    System.IO.File.WriteAllBytes(System.IO.Path.ChangeExtension(files[i], ".pmugfx"), Graphics.SurfaceManager.EncryptSurface(files[i]));
                    System.IO.File.Delete(files[i]);
                }
            }
            files = System.IO.Directory.GetFiles(IO.Paths.GfxPath + "Spells/", "*", SearchOption.TopDirectoryOnly);
            for (int i = 0; i < files.Length; i++)
            {
                if (files[i].EndsWith(".png"))
                {
                    System.IO.File.WriteAllBytes(System.IO.Path.ChangeExtension(files[i], ".pmugfx"), Graphics.SurfaceManager.EncryptSurface(files[i]));
                    System.IO.File.Delete(files[i]);
                }
            }
            files = System.IO.Directory.GetFiles(IO.Paths.GfxPath + "Mugshots/", "*", SearchOption.TopDirectoryOnly);


            for (int i = 0; i < files.Length; i++)
            {
                if (files[i].EndsWith(".png"))
                {
                    string path = System.IO.Path.GetDirectoryName(files[i]) + "/" + System.IO.Path.GetFileNameWithoutExtension(files[i]) + ".pmugfx";

                    SdlDotNet.Graphics.Surface mugshotSurface = new SdlDotNet.Graphics.Surface(files[i]);
                    mugshotSurface.ReplaceColor(Color.FromArgb(255, 254, 254, 254), Color.FromArgb(254, 254, 254, 254));
                    mugshotSurface.ReplaceColor(Color.FromArgb(255, 255, 255, 255), Color.FromArgb(254, 255, 255, 255));
                    SurfaceManager.SaveSurface(mugshotSurface, files[i]);

                    System.IO.File.WriteAllBytes(path, Graphics.SurfaceManager.EncryptSurface(files[i]));
                    System.IO.File.Delete(files[i]);
                }
            }
        }
Esempio n. 37
0
 private void AddBorder()
 {
     Size newSize = this.Size;
     switch (mWindowState) {
         case WindowManager.WindowState.Normal:
             newSize = this.Size;
             break;
         case WindowManager.WindowState.Maximized:
             newSize = new Size(SdlDotNet.Graphics.Video.Screen.Width, SdlDotNet.Graphics.Video.Screen.Height - Globals.GameScreen.TaskBar.Height);
             break;
         case WindowManager.WindowState.Minimized:
             return;
     }
     mBorderBuffer = new SdlDotNet.Graphics.Surface(AddBorderSize(newSize));
     mBorderBuffer.AlphaBlending = true;
     mBorderBuffer.Alpha = mBorderAlpha;
     mTitleBarBounds = new Rectangle(0, 0, newSize.Width + 2, 20);
     mTitleBarSurface = new SdlDotNet.Graphics.Surface(mTitleBarBounds.Size);
     mTitleBarSurface.Fill(Color.Blue);
     if (mText != "") {
         mTitleBarSurface.Blit(Logic.Graphics.FontManager.TextBoxFont.Render(mText, Color.Black, false), new Point(20, 3));
     }
     mCloseButtonBounds = new Rectangle(new Point(mTitleBarSurface.Width - 3 - mCloseButtonSurf.Width, 0), mCloseButtonSurf.Size);
     if (mCloseable) {
         mTitleBarSurface.Blit(mCloseButtonSurf, new Point(mTitleBarSurface.Width - 3 - mCloseButtonSurf.Width, 0));
     }
     mMaximizeButtonBounds = new Rectangle(new Point(mTitleBarSurface.Width - 3 - mCloseButtonSurf.Width - mMaximizeButtonSurf.Width, 0), mMaximizeButtonSurf.Size);
     if (mMaximizable) {
         mTitleBarSurface.Blit(mMaximizeButtonSurf, new Point(mTitleBarSurface.Width - 3 - mCloseButtonSurf.Width - mMaximizeButtonSurf.Width, 0));
     }
     mMinimizeButtonBounds = new Rectangle(new Point(mTitleBarSurface.Width - 3 - mCloseButtonSurf.Width - mMinimizeButtonSurf.Width - mMinimizeButtonSurf.Width, 0), mMinimizeButtonSurf.Size);
     if (mMinimizable) {
         mTitleBarSurface.Blit(mMinimizeButtonSurf, new Point(mTitleBarSurface.Width - 3 - mCloseButtonSurf.Width - mMinimizeButtonSurf.Width - mMinimizeButtonSurf.Width, 0));
     }
     mBorderBuffer.Blit(mTitleBarSurface, mTitleBarBounds.Location);
 }
Esempio n. 38
0
 private void InitBuffer()
 {
     Size newSize = this.Size;
     switch (mWindowState) {
         case WindowManager.WindowState.Normal:
             newSize = this.Size;
             break;
         case WindowManager.WindowState.Maximized:
             newSize = new Size(SdlDotNet.Graphics.Video.Screen.Width, SdlDotNet.Graphics.Video.Screen.Height - Globals.GameScreen.TaskBar.Height);
             break;
         case WindowManager.WindowState.Minimized:
             return;
     }
     if (mBuffer != null) {
         mBuffer.Close();
         mBuffer.Dispose();
     }
     mBuffer = new SdlDotNet.Graphics.Surface(AddBorderSize(newSize));
     mBuffer.AlphaBlending = true;
     mBuffer.Alpha = mControlsAlpha;
     mBuffer.Fill(SystemColors.Control);
     if (mWindowed) {
         AddBorder();
     } else {
         mCloseable = false;
         mMinimizable = false;
         mMaximizable = false;
     }
 }
Esempio n. 39
0
        /// <summary>
        /// Encrypts all png graphics
        /// </summary>
        private static void DoGraphicConversions()
        {
            //if (IO.IO.FileExists("GFX\\Arrows.png")) {
            //    System.IO.File.WriteAllBytes(IO.IO.GetGfxPath("Arrows.pmugfx"), Graphics.SurfaceManager.EncryptSurface(IO.IO.GetGfxPath("Arrows.png")));
            //    System.IO.File.Delete(IO.IO.GetGfxPath("Arrows.png"));
            //}
            //if (IO.IO.FileExists("GFX\\BigSpells.png")) {
            //    System.IO.File.WriteAllBytes(IO.IO.GetGfxPath("BigSpells.pmugfx"), Graphics.SurfaceManager.EncryptSurface(IO.IO.GetGfxPath("BigSpells.png")));
            //    System.IO.File.Delete(IO.IO.GetGfxPath("BigSpells.png"));
            //}
            //if (IO.IO.FileExists("GFX\\BigSprites.png")) {
            //    System.IO.File.WriteAllBytes(IO.IO.GetGfxPath("BigSprites0.pmugfx"), Graphics.SurfaceManager.EncryptSurface(IO.IO.GetGfxPath("BigSprites.png")));
            //    System.IO.File.Delete(IO.IO.GetGfxPath("BigSprites.png"));
            //}
            //if (IO.IO.FileExists("GFX\\Spells.png")) {
            //    System.IO.File.WriteAllBytes(IO.IO.GetGfxPath("Spells.pmugfx"), Graphics.SurfaceManager.EncryptSurface(IO.IO.GetGfxPath("Spells.png")));
            //    System.IO.File.Delete(IO.IO.GetGfxPath("Spells.png"));
            //}
            //for (int i = 0; i < Graphics.GraphicsManager.MAX_TILES; i++) {
            //    if (IO.IO.FileExists(IO.Paths.GfxPath + "Tiles" + i.ToString() + ".png")) {
            //        System.IO.File.WriteAllBytes(IO.Paths.GfxPath + "Tiles" + i.ToString() + ".pmugfx", Graphics.SurfaceManager.EncryptSurface(IO.Paths.GfxPath + "Tiles" + i.ToString() + ".png"));
            //        System.IO.File.Delete(IO.Paths.GfxPath + "Tiles" + i.ToString() + ".png");
            //    }
            //}
            string[] files = System.IO.Directory.GetFiles(IO.Paths.GfxPath + "Sprites/", "*", SearchOption.TopDirectoryOnly);
            for (int i = 0; i < files.Length; i++) {
                if (files[i].EndsWith(".png")) {
                    System.IO.File.WriteAllBytes(System.IO.Path.ChangeExtension(files[i], ".pmugfx"), Graphics.SurfaceManager.EncryptSurface(files[i]));
                    System.IO.File.Delete(files[i]);
                }
            }
            files = System.IO.Directory.GetFiles(IO.Paths.GfxPath + "Spells/", "*", SearchOption.TopDirectoryOnly);
            for (int i = 0; i < files.Length; i++) {
                if (files[i].EndsWith(".png")) {
                    System.IO.File.WriteAllBytes(System.IO.Path.ChangeExtension(files[i], ".pmugfx"), Graphics.SurfaceManager.EncryptSurface(files[i]));
                    System.IO.File.Delete(files[i]);
                }
            }
            files = System.IO.Directory.GetFiles(IO.Paths.GfxPath + "Mugshots/", "*", SearchOption.TopDirectoryOnly);

            for (int i = 0; i < files.Length; i++) {
                if (files[i].EndsWith(".png")) {
                    string path = System.IO.Path.GetDirectoryName(files[i]) + "/" + System.IO.Path.GetFileNameWithoutExtension(files[i]) + ".pmugfx";

                    SdlDotNet.Graphics.Surface mugshotSurface = new SdlDotNet.Graphics.Surface(files[i]);
                    mugshotSurface.ReplaceColor(Color.FromArgb(255, 254, 254, 254), Color.FromArgb(254, 254, 254, 254));
                    mugshotSurface.ReplaceColor(Color.FromArgb(255, 255, 255, 255), Color.FromArgb(254, 255, 255, 255));
                    SurfaceManager.SaveSurface(mugshotSurface, files[i]);

                    System.IO.File.WriteAllBytes(path, Graphics.SurfaceManager.EncryptSurface(files[i]));
                    System.IO.File.Delete(files[i]);
                }
            }
        }
Esempio n. 40
0
        private void Go()
        {
            splashscreen = new Splash();
            splashscreen.Show();
            splashscreen.BringToFront();
            splashscreen.Refresh();
            Core.Init(null, null, null, new ProgressHandler(UpdateMessage), true);
            world = new WorldDefinition(new Distance(150, 150, 7), 3);
            WorldDefinition.World = world;
            mainWindowMDI         = new MainWindow();
            timer = new System.Windows.Forms.Timer();
            Events.KeyboardDown    += new EventHandler <KeyboardEventArgs>(this.KeyDown);
            Events.MouseButtonDown +=
                new EventHandler <MouseButtonEventArgs>(this.MouseButtonDown);
            Events.MouseButtonUp +=
                new EventHandler <MouseButtonEventArgs>(this.MouseButtonUp);
            Events.Quit          += new EventHandler <QuitEventArgs>(this.Quit);
            Events.Tick          += new EventHandler <TickEventArgs>(this.Tick);
            Events.VideoResize   += new EventHandler <SdlDotNet.Graphics.VideoResizeEventArgs>(this.Resize);
            Events.MusicFinished +=
                new EventHandler <MusicFinishedEventArgs>(this.MusicFinished);
            Events.MouseMotion     += new EventHandler <MouseMotionEventArgs>(this.MouseMotion);
            dragStartMousePosition  = new Point(0, 0);
            dragStartScrollPosition = new Point(0, 0);
            ScrollPosition          = new Point(0, 0);
            this.width  = Properties.Settings.Default.RenderWindowWidth;
            this.height = Properties.Settings.Default.RenderWindowHeight;

            try
            {
                SdlDotNet.Graphics.Video.WindowIcon();
                SdlDotNet.Graphics.Video.WindowCaption = Translation.GetString("MAIN_WINDOW_TITLE");
                SdlDotNet.Graphics.Video.Initialize();
                splashscreen.BringToFront();
            }
            catch
            {
                MessageBox.Show(Translation.GetString("SDL_NOT_FOUND"));
                return;
            }

            Mixer.Initialize();

            SdlMixer.MusicFinishedDelegate musicStopped = new SdlMixer.MusicFinishedDelegate(MusicHasStopped);
            SdlMixer.Mix_HookMusicFinished(musicStopped);


            screen = SdlDotNet.Graphics.Video.SetVideoMode(width, height, currentBpp, true);
            screen.SourceColorKey = Color.Magenta;
            IntPtr videoInfoPointer = Sdl.SDL_GetVideoInfo();

            if (videoInfoPointer != IntPtr.Zero)
            {
                videoInfo   = (Sdl.SDL_VideoInfo)Marshal.PtrToStructure(videoInfoPointer, typeof(Sdl.SDL_VideoInfo));
                pixelFormat = (Sdl.SDL_PixelFormat)Marshal.PtrToStructure(videoInfo.vfmt, typeof(Sdl.SDL_PixelFormat));
            }
            splashscreen.status.AppendText("FreeTrain SDL Starting...");
            splashscreen.status.AppendText("\n");
            splashscreen.Refresh();

            FinalDraw();

            splashscreen.status.AppendText("Loading plugins...");
            splashscreen.status.AppendText("\n");
            splashscreen.Refresh();
            FinalDraw();


            weatherOverlay = NullWeatherOverlay.theInstance;
            FinalDraw();
            qView = new QuarterViewDrawer(world, new Rectangle(0, 0, world.Size.x * 32 - 16, (world.Size.y - 2 * world.Size.z - 1) * 8));
            qView.OffscreenBuffer = new Surface(world.Size.x * 32 - 16, (world.Size.y - 2 * world.Size.z - 1) * 8, screen.CreateCompatibleSurface().Pixels);
            qView.OffscreenBuffer.SourceColorKey = Color.Magenta;
            qView.RecreateDrawBuffer(new Size(width, height), true);
            splashscreen.status.AppendText("Creating Map...");
            splashscreen.status.AppendText("\n");
            splashscreen.Refresh();
            FinalDraw();

            qView.Draw(new Rectangle(0, 0, world.Size.x * 32 - 16, (world.Size.y - 2 * world.Size.z - 1) * 8), null);
            timer.Tick    += new EventHandler(TimerTick);
            timer.Interval = 33;
            timer.Enabled  = true;
            timer.Start();

            mainWindowMDI.Show();
            splashscreen.BringToFront();
            splashscreen.Close();

            Events.Run();
        }
Esempio n. 41
0
 public void Dispose()
 {
     if (_surface != null)
     {
         _surface.Dispose();
         _surface = null;
     }
 }
Esempio n. 42
0
 public override void BlitToScreen(SdlDotNet.Graphics.Surface destinationSurface)
 {
     base.BlitToScreen(destinationSurface);
     //rwLock.EnterReadLock();
     destSurf = destinationSurface;
     for (int i = 0; i < openMenus.Count; i++) {
         if (openMenus[i].MenuPanel.ReadyToConfigure) {
             openMenus[i].MenuPanel.Location = new Point(this.X + openMenus[i].MenuPanel.X, this.Y + openMenus[i].MenuPanel.Y);
             //openMenus[i].MenuPanel.RequestRedraw();
             openMenus[i].MenuPanel.ReadyToConfigure = false;
         }
         if (destSurf != null) {
             openMenus[i].MenuPanel.BlitToScreen(destSurf);
         }
     }
     try {
         //for (int i = 0; i < openMenus.Count; i++) {
         //    if (openMenus[i].MenuPanel.ReadyToConfigure) {
         //        openMenus[i].MenuPanel.Location = new Point(this.X + openMenus[i].MenuPanel.X, this.Y + openMenus[i].MenuPanel.Y);
         //        //openMenus[i].MenuPanel.RequestRedraw();
         //        openMenus[i].MenuPanel.ReadyToConfigure = false;
         //    }
         //    openMenus[i].MenuPanel.BlitToScreen(destinationSurface);
         //}
     } finally {
         //rwLock.ExitReadLock();
     }
     //foreach (IMenu menu in openMenus) {
     //    menu.MenuPanel.BlitToScreen(destinationSurface);//, new Point(this.X + menu.MenuPanel.X, this.Y + menu.MenuPanel.Y));
     //}
 }