Esempio n. 1
0
        public override void Draw(SdlDotNet.Graphics.Surface screen)
        {
            // Draw the title
            titleTextSprite.X = 20;
            titleTextSprite.Y = _BaseY;
            titleTextSprite.Color = Color.Yellow;
            titleTextSprite.Text = this.Name;
            screen.Blit(titleTextSprite);

            int item_y = _BaseY + _SpaceBetweenItems + 20;
            // Draw the lines
            for (int i = 0; i < Lines.Length; i++)
            {
                lineTextSprite.X = 20;
                lineTextSprite.Y = item_y;
                lineTextSprite.Color = Color.White; 
                lineTextSprite.Text = Lines[i];
                screen.Blit(lineTextSprite);

                item_y += 15;
            }

            // Draw the item
            itemTextSprite.X = 20;
            itemTextSprite.Y = screen.Height - 40;
            itemTextSprite.Color = Color.LightYellow;
            itemTextSprite.Text = Items[0].Text;
            screen.Blit(itemTextSprite);
        }
Esempio n. 2
0
 public override void Update(SdlDotNet.Graphics.Surface dstSrf, SdlDotNet.Core.TickEventArgs e)
 {
     if (e.Tick > lastTick + 35) {
         mGameLoop.DrawScreen(mGameSurface, e);
         lastTick = e.Tick;
     }
     dstSrf.Blit(mGameSurface, this.Location);
 }
Esempio n. 3
0
        /// <summary>
        /// Retrieve a Tile from it's tilemap, given its coordinates and its size
        /// </summary>
        /// <param name="toFill">Surface which will reprensent the tile</param>
        /// <param name="fileName">Filename of the tilemap</param>
        /// <param name="offsetX">Horizontal offset of the tile in the tile map</param>
        /// <param name="offsetY">Vertical offset of the tile in the tile map</param>
        public static void FromTilemap(SdlDotNet.Graphics.Surface toFill, string fileName, int offsetX, int offsetY)
        {
            if (!tilemap.ContainsKey(fileName))
            {
                tilemap.Add(fileName, new Surface(System.IO.Path.Combine(Path, fileName)));
            }

            toFill.Blit(tilemap[fileName], new Point(0, 0), new Rectangle(offsetX, offsetY, toFill.Width, toFill.Height));
        }
Esempio n. 4
0
 public override void Render(int x, int y, SdlDotNet.Graphics.Surface dest)
 {
     //Code copied from Dialogs.DrawWindow
     int Border = dialogs.Border;
     Color bgColor = dialogs.bgColor;
     SdlDotNet.Graphics.Surface surface = dialogs.surface;
     SdlDotNet.Graphics.Primitives.Box box = new SdlDotNet.Graphics.Primitives.Box(
         new Point(x - dialogs.Margin / 2, y - dialogs.Margin / 2),
         size);
     dest.Draw(box, bgColor, false, true);
     for (int i = Border; i < box.Width - Border; i += Border) {
         dest.Blit(surface, new Point(box.XPosition1 + i, box.YPosition1), new Rectangle(2 * Border, 0, Border, Border));
         dest.Blit(surface, new Point(box.XPosition1 + i, box.YPosition2 - Border + 1), new Rectangle(2 * Border, Border, Border, Border));
     }
     for (int i = Border; i < box.Height - Border; i += Border) {
         dest.Blit(surface, new Point(box.XPosition1, box.YPosition1 + i), new Rectangle(3 * Border, 0, Border, Border));
         dest.Blit(surface, new Point(box.XPosition2 - Border + 1, box.YPosition1 + i), new Rectangle(3 * Border, Border, Border, Border));
     }
     dest.Blit(surface, new Point(box.XPosition1, box.YPosition1), new Rectangle(0, 0, Border, Border));
     dest.Blit(surface, new Point(box.XPosition2 - Border + 1, box.YPosition1), new Rectangle(Border, 0, Border, Border));
     dest.Blit(surface, new Point(box.XPosition1, box.YPosition2 - Border + 1), new Rectangle(0, Border, Border, Border));
     dest.Blit(surface, new Point(box.XPosition2 - Border + 1, box.YPosition2 - Border + 1), new Rectangle(Border, Border, Border, Border));
 }
Esempio n. 5
0
        private void drawOctaveSelecting(SdlDotNet.Graphics.Surface s)
        {
            if (_octaveSelectingSurface == null)
            {
                using (Surface ts = ImageUtil.CreateMultilineStringSurface(new string[] { 
                Properties.Resources.Str_OctaveSelecting,
                null, null, null,
                Properties.Resources.Str_OctaveSelecting_Operation },
                    ResourceManager.SmallPFont, Constants.Color_Background, TextAlign.Center))
                {
                    _octaveSelectingSurface = new Surface(
                        ts.Width + Constants.WindowPadding * 2,
                        ts.Height + Constants.WindowPadding * 2);

                    _octaveSelectingSurface.Fill(Constants.Color_Foreground);
                    _octaveSelectingSurface.Blit(ts, new Point(Constants.WindowPadding, Constants.WindowPadding));
                    _octaveSelectingSurface.Update();
                }

                _octaveUpSurface = ResourceManager.SmallPFont.Render(Properties.Resources.Str_UpArrow, Constants.Color_Background);
                _octaveDownSurface = ResourceManager.SmallPFont.Render(Properties.Resources.Str_DownArrow, Constants.Color_Background);
            }

            s.Blit(_octaveSelectingSurface, new Point(
                    (int)(Constants.ScreenWidth / 2.0 - _octaveSelectingSurface.Width / 2.0),
                    (int)(Constants.ScreenHeight / 2.0 - _octaveSelectingSurface.Height / 2.0)));

            int fh = (int)(ResourceManager.SmallPFont.Height * Constants.LineHeight);
            int y = Constants.WindowPadding + 
                (int)(Constants.ScreenHeight / 2.0 - _octaveSelectingSurface.Height / 2.0) + fh;

            if (_octave < Constants.MaxOctave)
            {
                s.Blit(_octaveUpSurface, new Point((int)(Constants.ScreenWidth / 2.0 - _octaveUpSurface.Width / 2.0), y));
            }
            y += fh;

            using (Surface ts = ResourceManager.SmallPFont.Render(_octave.ToString(), Constants.Color_Background))
            {
                s.Blit(ts, new Point((int)(Constants.ScreenWidth / 2.0 - ts.Width / 2.0), y));
            }
            y += fh;

            if (_octave > Constants.MinOctave)
            {
                s.Blit(_octaveDownSurface, new Point((int)(Constants.ScreenWidth / 2.0 - _octaveDownSurface.Width / 2.0), y));
            }
        }
Esempio n. 6
0
 //TODO: Candidate for optimization: two much Point creation
 public override void Render(int x, int y, SdlDotNet.Graphics.Surface dest)
 {
     int yLocal = 0;
     if (align == Align.Left) {
         foreach (Surface surf in textSurfaces) {
             dest.Blit(surf, new Point(x + location.X, yLocal + y + location.Y));
             yLocal += surf.Height;
         }
     }
     else if (align == Align.Right) {
         foreach (Surface surf in textSurfaces) {
             dest.Blit(surf, new Point(x + location.X + width - surf.Width, yLocal + y + location.Y));
             yLocal += surf.Height;
         }
     }
     else {
         foreach (Surface surf in textSurfaces) {
             dest.Blit(surf, new Point(x + location.X + (width - surf.Width) / 2, yLocal + y + location.Y));
             yLocal += surf.Height;
         }
     }
 }
Esempio n. 7
0
 private void drawLoading(SdlDotNet.Graphics.Surface s)
 {
     s.Fill(Constants.Color_Foreground);
     if (_loadingSurface == null)
     {
         _loadingSurface = ResourceManager.SmallPFont.Render(Properties.Resources.Str_MapLoading, Constants.Color_Background);
     }
     s.Blit(_loadingSurface, new Point(
         (int)(Constants.ScreenWidth / 2.0 - _loadingSurface.Width / 2.0),
         (int)(Constants.ScreenHeight / 2.0 - _loadingSurface.Height / 2.0)));
 }
Esempio n. 8
0
        private void drawMaps(SdlDotNet.Graphics.Surface s)
        {
            s.Fill(Constants.Color_Background);

            // ヘッダ
            if (_headerSurface == null)
            {
                _headerSurface = ResourceManager.LargePFont.Render(Properties.Resources.HeaderTitle_MapSelect,
                    Constants.Color_Strong);
            }
            s.Blit(_headerSurface, new Point(Constants.HeaderX, Constants.HeaderY));

            // 説明文
            if (_expSurface == null)
            {
                _expSurface = ResourceManager.SmallPFont.Render(Properties.Resources.Explanation_MapSelect,
                    Constants.Color_Strong);
            }
            s.Blit(_expSurface, _expRect.Location);

            // ビルトインマップメニュー
            ImageUtil.DrawSelections(s, _randSurfaces, _randRects, _cursor,
                _randRect.Location, ((_mapFocus || _escFocus) ? -1 : _randSelectedIdx), MenuItemAlign.MiddleLeft);

            // 読み込んだマップメニュー
            ImageUtil.DrawSelections(s, _mapDrawSurfaces, _mapDrawRects, _cursor,
                _mapRect.Location, (_mapFocus ? _mapSelectedIdx - _mapDrawFirstIdx : -1), MenuItemAlign.MiddleLeft);

            // タイトルに戻るメニュー
            ImageUtil.DrawSelections(s, _escSurfaces, _escRects, _strongCursor,
                _escRect.Location, (_escFocus ? 0 : -1), MenuItemAlign.MiddleLeft);
        }
Esempio n. 9
0
 private void DrawBackground(SdlDotNet.Graphics.Surface dstSrf, SdlDotNet.Core.TickEventArgs e)
 {
     mBackground.Fill(Color.White);
     dstSrf.Blit(mBackground, new Point(this.ScreenLocation.X, this.ScreenLocation.Y + buttonHeight));
 }
Esempio n. 10
0
        protected override void draw(SdlDotNet.Graphics.Surface s)
        {
            if (_prevSurface == null)
            {
                _prevSurface = new Surface(s);
                _prevSurface.Transparent = true;
                _prevSurface.AlphaBlending = true;
                _prevSurface.Alpha = 64;
            }

            s.Fill(Color.Black);
            s.Blit(_prevSurface, Point.Empty);

            if (_errorMessageSurface == null && _errorMessages != null)
            {
                _errorMessageSurface = new SurfaceCollection();
                _errorMessageRects = new Rectangle[_errorMessages.Length];
                ImageUtil.CreateStrMenu(_errorMessages, Color.White, ref _errorMessageSurface, ref _errorMessageRects, s.Width);
            }
            if (_errorMessageSurface != null)
            {
                ImageUtil.DrawSurfaces(s, _errorMessageSurface, _errorMessageRects, new Point(0, 100), MenuItemAlign.TopCenter);
            }
        }
Esempio n. 11
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. 12
0
 protected override void renderMiniMapForeground(SdlDotNet.Graphics.Surface s, Rectangle r)
 {
     using (Surface ts = ResourceManager.LargePFont.Render("Endless Map", _backColor))
     {
         s.Blit(ts, new Point((int)(r.Width / 2.0 - ts.Width / 2.0), (int)(r.Height / 2.0 - ts.Height / 2.0)));
     }
 }
Esempio n. 13
0
        private void DrawCursor(SdlDotNet.Graphics.Surface dstSrf, SdlDotNet.Core.TickEventArgs e)
        {
            cursorArea.Height = System.Math.Max(20, mBackground.Height-System.Math.Max(20, max/4));
            cursorArea.Width = 12;

            cursorPos.X = this.ScreenLocation.X;
            if (!isScrolling) {
                if (!inverted)
                    cursorPos.Y = (this.ScreenLocation.Y + buttonHeight) + (Height - 21 - cursorArea.Height) + ((value * 100) / max);
                else
                    cursorPos.Y = (this.ScreenLocation.Y + buttonHeight ) + (Height - 21 - cursorArea.Height) * ((max - value) / max);
            }

            cursorArea.X = (int)(cursorPos.X + this.ScreenLocation.X);
            cursorArea.Y = (int)(cursorPos.Y + this.ScreenLocation.Y);

            cursorSurf = new SdlDotNet.Graphics.Surface(cursorArea.Size);
            cursorSurf.Fill(Color.Gray);

            dstSrf.Blit(cursorSurf, cursorPos);
            //spriteBatch.Draw(cursorTex, cursorPos, cursorLeft, BackColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);

            //cursorMidDest.X = (int)cursorPos.X + 3;
            //cursorMidDest.Y = (int)cursorPos.Y;
            //cursorMidDest.Width = cursorArea.Width - 6;
            //spriteBatch.Draw(cursorTex, cursorMidDest, cursorMiddle, BackColor, 0f, Vector2.Zero, SpriteEffects.None, 0f);

            //spriteBatch.Draw(cursorTex, cursorPos + new Vector2(cursorMidDest.Width, 0f), cursorRight, BackColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
        }
Esempio n. 14
0
        public override void Update(SdlDotNet.Graphics.Surface dstSrf, SdlDotNet.Core.TickEventArgs e)
        {
            dstSrf.Blit(mBackground, this.ScreenLocation);

            base.Update(dstSrf, e);
        }
Esempio n. 15
0
        protected override void draw(SdlDotNet.Graphics.Surface s)
        {
            s.Fill(Constants.Color_Background);

            // タイトル
            if (_optSurface == null)
            {
                _optSurface = ResourceManager.LargePFont.Render(Properties.Resources.HeaderTitle_Option, Constants.Color_Strong);
            }
            s.Blit(_optSurface, new Point(Constants.HeaderX, Constants.HeaderY));

            // 今選択中のドメイン
            if (_state == SelectionState.Device)
            {
                s.Fill(new Rectangle(_devHeadRect.Left, _devRect.Top, _devHeadRect.Width, _devRect.Height), Constants.Color_Selection);
            }
            else if (_state == SelectionState.Calibration)
            {
                s.Fill(new Rectangle(_calHeadRect.Left, _calMenuRect.Top, _calHeadRect.Width, _calMenuRect.Height), Constants.Color_Selection);
            }

            // Audio Device / Calibration Header
            if (_devHeadSurface == null)
            {
                _devHeadSurface = ResourceManager.MiddlePFont.Render(Properties.Resources.HeaderTitle_AudioDevices, Constants.Color_Foreground);
            }
            s.Blit(_devHeadSurface, _devHeadRect.Location);

            if (_calHeadSurface == null)
            {
                _calHeadSurface = ResourceManager.MiddlePFont.Render(Properties.Resources.HeaderTitle_Calibration, Constants.Color_Foreground);
            }
            s.Blit(_calHeadSurface, _calHeadRect.Location);

            if(_expSurface == null)
            {
                _expSurface = ResourceManager.SmallPFont.Render(Properties.Resources.Explanation_Calibration, Constants.Color_Strong);
            }
            s.Blit(_expSurface, new Point(_calHeadRect.X, _calRect.Y));

            // 選択肢
            ImageUtil.DrawSelections(s, _endHeadSurfaces, _endHeadRects, _headCursor,
                _endHeadRect.Location,
                (_state == SelectionState.Back ? 0 : -1), MenuItemAlign.TopLeft);

            ImageUtil.DrawSelections(s, _calSurfaces, _calRects, _cursor,
                _calMenuRect.Location,
                (_state == SelectionState.Calibration ? _calSelectedIdx : -1),
                MenuItemAlign.TopLeft);

            ImageUtil.DrawSelections(s, _devDrawSurfaces, _devDrawRects, _cursor,
                _devRect.Location, 
                _devSelectedIdx - _devDrawFirstIdx, 
                MenuItemAlign.TopLeft);

            // 高音・低音の値
            Surface hs = _calSurfaces[0];
            Surface ls = _calSurfaces[1];
            double maxFreq = Config.Instance.MaxFreq;
            double minFreq = Config.Instance.MinFreq;
            if (_isCalStarted)
            {
                switch (_calSelectedIdx)
                {
                    case IDX_MAXPITCH:
                        maxFreq = getAvgValue(IDX_MAXPITCH);
                        break;
                    case IDX_MINPITCH:
                        minFreq = getAvgValue(IDX_MINPITCH);
                        break;
                }
            }
            using (Surface ts = ResourceManager.SmallPFont.Render(maxFreq.ToString("F1"), Constants.Color_Foreground))
            {
                s.Blit(ts, new Point(_calRects[0].X + hs.Width + _calMenuRect.X + 10, _calRects[0].Y + _calMenuRect.Y));
            }
            using (Surface ts = ResourceManager.SmallPFont.Render(minFreq.ToString("F1"), Constants.Color_Foreground))
            {
                s.Blit(ts,
                    new Point(_calRects[1].X + ls.Width + _calMenuRect.X + 10, _calRects[1].Y + _calMenuRect.Y));
            }

            // 計測中かどうか
            if (_isCalStarted)
            {
                using (Surface ts = ResourceManager.SmallPFont.Render(Properties.Resources.Str_Calibrating, Constants.Color_Strong))
                {
                    s.Blit(ts, new Point(_calMenuRect.X, _calMenuRect.Bottom));
                }
            }

            // 波形
            if (_audioInput.Capturing)
            {
                using (Surface ts = ResourceManager.SmallTTFont.Render(
                    _curToneResult.ToString(), Constants.Color_Strong))
                {
                    s.Blit(ts, new Point(_calMenuRect.X, _calMenuRect.Bottom + ResourceManager.SmallPFont.Height + 5));
                }
                drawWave(s, _parent.PitchResult, _parent.ToneResult, ResourceManager.SmallTTFont, _calWaveRect);
            }
        }
Esempio n. 16
0
 public override void Render(SdlDotNet.Graphics.Surface surface)
 {
     from.Alpha = alphaCounter;
     from.AlphaBlending = true;
     surface.Blit(from);
 }
Esempio n. 17
0
 public virtual void Update(SdlDotNet.Graphics.Surface dstSrf, SdlDotNet.Core.TickEventArgs e)
 {
     try {
         if (!mIsDisposing) {
     //					Point totalAddLoc = GetTotalAddLocation(new Point(mBounds.X, mBounds.Y), this);
     //					if (mScreenBounds.Location != totalAddLoc) {
     //						mScreenBounds = new Rectangle(totalAddLoc, this.Size);
     //					}
     //					int addX = totalAddLoc.X;
     //					int addY = totalAddLoc.Y;
             if (mBuffer.Size != mBounds.Size) {
                 ReinitBuffer();
             }
             dstSrf.Blit(mBuffer, this.Location);
             UpdateControls(mBuffer, e);
         }
     } catch (Exception ex) {
         Console.WriteLine(ex.ToString());
     }
 }