public OpenTkBMFontRenderer(Skinning.Skin ErrorSkin, BMFontReader.BMFont font)
        {
            this.font      = font;
            this.ErrorSkin = ErrorSkin;

            LoadFontTextures();
        }
Ejemplo n.º 2
0
        public PreviewBackgroundDialog(Skinning.Skin skin, string bgpath)
        {
            InitComponentNew();
            Skinning.SetBackCol(this, skin.UIColours[UIColours.UIColourDefs.Form_BG.TypeName]);
            Skinning.SetForeCol(this, skin.UIColours[UIColours.UIColourDefs.Form_Text.TypeName]);
            Skinning.SetUIStyle(this, skin.UIStyle);

            result = bgpath;

            ImagePathBox.Text = bgpath;
        }
Ejemplo n.º 3
0
 static public void LoadMusic(string path, Skinning.Skin errorskin)
 {
     try
     {
         LoadMusicInt(path);
     }
     catch
     {
         SkinnedMessageBox.Show(errorskin, DialogResMgr.GetString("MusicLoadError"), "", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
     }
 }
Ejemplo n.º 4
0
        // has skin, has owner
        public static DialogResult Show(Skinning.Skin skin, IWin32Window owner, string message, string caption = "", MessageBoxButtons buttons = MessageBoxButtons.OK, MessageBoxIcon icon = MessageBoxIcon.None, MessageBoxDefaultButton defaultbutton = MessageBoxDefaultButton.Button1, MessageBoxOptions options = 0)
        {
            // I probably shouldn't do this, but from what I can tell this should be safe enough -- out of thread owner is allowed
            // and it only seems to appear when debugging (???)
            Control.CheckForIllegalCrossThreadCalls = false;
            SkinnedMessageBoxForm mb  = new SkinnedMessageBoxForm(skin, owner, message, caption, buttons, icon, defaultbutton, options);
            DialogResult          res = mb.ShowDialog();

            Control.CheckForIllegalCrossThreadCalls = true;
            mb.Dispose();
            return(res);
        }
Ejemplo n.º 5
0
        public CharaIconDialog(Skinning.Skin skin, CharaIcons.CharaIconInfo icondef)
        {
            InitComponentNew();
            Skinning.SetBackCol(this, skin.UIColours[UIColours.UIColourDefs.Form_BG.TypeName]);
            Skinning.SetForeCol(this, skin.UIColours[UIColours.UIColourDefs.Form_Text.TypeName]);
            Skinning.SetUIStyle(this, skin.UIStyle);

            result = icondef;

            ImagePathBox.Text       = icondef.ImagePath;
            TypeBox.SelectedIndex   = icondef.Type;
            RarityBox.SelectedIndex = icondef.Rarity;
            SizeBox.Value           = icondef.IconSize;
        }
Ejemplo n.º 6
0
        public ChartInfoDialog(Skinning.Skin skin, string songname, string author, string timesigs)
        {
            InitComponentNew();
            Skinning.SetBackCol(this, skin.UIColours[UIColours.UIColourDefs.Form_BG.TypeName]);
            Skinning.SetForeCol(this, skin.UIColours[UIColours.UIColourDefs.Form_Text.TypeName]);
            Skinning.SetUIStyle(this, skin.UIStyle);

            TimesigsGrid.DefaultCellStyle.ForeColor = SystemColors.ControlText; // reset these because they inherit incorrectly
            TimesigsGrid.DefaultCellStyle.BackColor = SystemColors.Window;

            SongNameBox.Text = songname;
            AuthorBox.Text   = author;

            Notedata.TimeSigChange[] timesigsconverted = Notedata.ReadTimesigChangesFromString(timesigs);
            if (timesigsconverted != null)
            {
                foreach (Notedata.TimeSigChange sig in timesigsconverted)
                {
                    TimesigsGrid.Rows.Add(new object[] { sig.StartBar, sig.StartTick, sig.Numerator, sig.Denominator });
                }
            }
        }
        public GameCloneRenderer_OGL(int wndWidth, int wndHeight, int wndX, int wndY, WindowState wndState, Form1 mainform, Skinning.Skin skin, CharaIcons.CharaIconInfo[] charaicons, bool showcombo)
        {
            this.mainform   = mainform;
            this.skin       = skin;
            this.charaicons = (CharaIcons.CharaIconInfo[])charaicons.Clone();
            this.showcombo  = showcombo;
            numLanes        = skin.NumLanes;
            NodeStartLocs   = (Point[])skin.NodeStartLocs.Clone();
            NodeEndLocs     = (Point[])skin.NodeEndLocs.Clone();
            SetupNodeLocs(wndWidth, wndHeight);

            System.Threading.Thread oglThread = new System.Threading.Thread(() =>
            {
                // This is roughly coded to around OpenGL v3.0 -- it's the minimum needed to get GenerateMipmap, but some functions (MatrixMode, Color4, TexCoord2, Vertex2, Begin, End) are deprecated in this version or other 3.x versions.
                // v3 was a little easier to get started on for me (someone with very little graphics experience), and it doesn't seem to have major downsides. The compatibility profile allows for all this and is well supported on desktop.
                // I'm not sure if requesting v3.0 this here actually does anything useful -- it doesn't seem to make a difference at all on nvidia drivers
                myWindow = new GameWindow(wndWidth, wndHeight, OpenTK.Graphics.GraphicsMode.Default, "8beatMap Preview Window", GameWindowFlags.Default, DisplayDevice.Default, 3, 0, OpenTK.Graphics.GraphicsContextFlags.Default)
                {
                    Icon = (Icon)IconResMgr.GetObject("Icon")
                };
                // The line below this is just an alternate version that enables antialiasing. It looks better, but less similar to the original game... so... I'll leave it disabled
                //myWindow = new GameWindow(wndWidth, wndHeight, new OpenTK.Graphics.GraphicsMode(32, 0, 0, 4), "8beatMap Preview Window", GameWindowFlags.Default, DisplayDevice.Default, 3, 0, OpenTK.Graphics.GraphicsContextFlags.Default) { Icon = (Icon)IconResMgr.GetObject("Icon") };

                if ((wndX != -99999 | wndY != -99999) && wndState != WindowState.Maximized)
                {
                    myWindow.X = wndX;
                    myWindow.Y = wndY;
                }
                myWindow.WindowState = wndState;
                myWindow.VSync       = OpenTK.VSyncMode.Adaptive;


                myWindow.Load += (sender, e) =>
                {
                    //Console.WriteLine(GL.GetString(StringName.Version));
                    SetupTextures();

                    try
                    {
                        combofontrenderer = new OpenTkBMFontRenderer(skin, skin.ComboTextInfo.Font);
                    }
                    catch
                    {
                        Stop();
                    }

                    GL.ClearColor(clearColor);

                    GL.Enable(EnableCap.Texture2D);
                    GL.Enable(EnableCap.Blend);
                    //GL.BlendFuncSeparate(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha, BlendingFactorSrc.One, BlendingFactorDest.OneMinusSrcAlpha);
                    GL.BlendFunc(BlendingFactorSrc.One, BlendingFactorDest.OneMinusSrcAlpha);
                    //GL.Enable(EnableCap.PolygonSmooth);  // sometimes causes diagonal lines through quads

                    GL.BindTexture(TextureTarget.Texture2D, textures["spr_SwipeLocus"]);
                    GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)TextureWrapMode.Repeat);
                    GL.BindTexture(TextureTarget.Texture2D, textures["spr_HoldLocus"]);
                    GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)TextureWrapMode.Repeat);
                };

                myWindow.Resize += (sender, e) =>
                {
                    if (myWindow != null)
                    {
                        GL.Viewport(0, 0, myWindow.Width, myWindow.Height);
                        SetupNodeLocs(myWindow.Width, myWindow.Height);
                    }
                };

                myWindow.Closed += (sender, e) =>
                {
                    UnloadAllTextures();
                    combofontrenderer.Dispose();
                };


                myWindow.RenderFrame += new EventHandler <OpenTK.FrameEventArgs>(RenderFrame);


                //myWindow.TargetRenderFrequency = 60;
                myWindow.Run();
            });

            System.Threading.Thread.Sleep(10);

            oglThread.Start();

            while (myWindow == null)
            {
                System.Threading.Thread.Yield();
            }
        }
Ejemplo n.º 8
0
            public SkinnedMessageBoxForm(Skinning.Skin skin, IWin32Window owner, string message, string caption = "", MessageBoxButtons buttons = MessageBoxButtons.OK, MessageBoxIcon icon = MessageBoxIcon.None, MessageBoxDefaultButton defaultbutton = MessageBoxDefaultButton.Button1, MessageBoxOptions options = 0)
            {
                InitComponentNew();

                //if (owner != null)
                //{
                //    this.Owner = owner;
                //}
                if (owner != null)
                {
                    Owner = Control.FromHandle(owner.Handle).FindForm();
                }
                else
                {
                    Owner = Form.ActiveForm;
                }

                this.Text = caption;

                Padding lblMargin   = new Padding(14, 0, 14, 45);
                Point   lblLocation = new Point(14, 14);
                Size    lblMinSize  = new Size(this.ClientSize.Width - lblLocation.X - lblMargin.Right, 0);
                Size    lblMaxSize  = new Size(600, 0);
                Label   MessageLbl  = new Label()
                {
                    Text = message, AutoSize = true, Margin = lblMargin, Location = lblLocation, MinimumSize = lblMinSize, MaximumSize = lblMaxSize
                };

                Controls.Add(MessageLbl);

                if (buttons == MessageBoxButtons.OK)
                {
                    numbuttons = 1;
                    Button OkBtn = AddBtn(DialogResMgr.GetString("BtnOK"), DialogResult.OK, 0);
                    this.CancelButton = OkBtn;
                    //(not sure why, but this matches official .NET behaviour)
                }
                else if (buttons == MessageBoxButtons.OKCancel)
                {
                    numbuttons = 2;
                    AddBtn(DialogResMgr.GetString("BtnOK"), DialogResult.OK, 0);
                    Button CancelBtn = AddBtn(DialogResMgr.GetString("BtnCancel"), DialogResult.Cancel, 1);
                    this.CancelButton = CancelBtn;
                }
                else if (buttons == MessageBoxButtons.YesNo)
                {
                    numbuttons = 2;
                    AddBtn(DialogResMgr.GetString("BtnYes"), DialogResult.Yes, 0);
                    Button NoBtn = AddBtn(DialogResMgr.GetString("BtnNo"), DialogResult.No, 1);
                    this.CancelButton = NoBtn;
                    //(official .NET doesn't set cancel button, but this seems pretty clear to me...)
                }
                else if (buttons == MessageBoxButtons.RetryCancel)
                {
                    numbuttons = 2;
                    AddBtn(DialogResMgr.GetString("BtnRetry"), DialogResult.Retry, 0);
                    Button CancelBtn = AddBtn(DialogResMgr.GetString("BtnCancel"), DialogResult.Cancel, 1);
                    this.CancelButton = CancelBtn;
                }
                else if (buttons == MessageBoxButtons.YesNoCancel)
                {
                    numbuttons = 3;
                    AddBtn(DialogResMgr.GetString("BtnYes"), DialogResult.Yes, 0);
                    AddBtn(DialogResMgr.GetString("BtnNo"), DialogResult.No, 1);
                    Button CancelBtn = AddBtn(DialogResMgr.GetString("BtnCancel"), DialogResult.Cancel, 2);
                    this.CancelButton = CancelBtn;
                }
                else if (buttons == MessageBoxButtons.AbortRetryIgnore)
                {
                    numbuttons = 3;
                    AddBtn(DialogResMgr.GetString("BtnAbort"), DialogResult.Abort, 0);
                    AddBtn(DialogResMgr.GetString("BtnRetry"), DialogResult.Retry, 1);
                    AddBtn(DialogResMgr.GetString("BtnIgnore"), DialogResult.Ignore, 2);
                    //this.CancelButton = IgnoreBtn;
                    //(official .NET doesn't set cancel button)
                }
                else
                {
                    throw new InvalidEnumArgumentException("buttons", (int)buttons, typeof(MessageBoxButtons));
                }

                if (this.CancelButton == null)
                {
                    this.ControlBox = false;
                }


                if (icon != MessageBoxIcon.None)
                {
                    int iconsize    = 32;
                    int iconpadding = 12;
                    int textpadding = -8;

                    PictureBox iconPB = new PictureBox()
                    {
                        Width = iconsize, Height = iconsize, Top = 10, Left = 10, AccessibleName = "Icon"
                    };

                    // there are many duplicated values:
                    // https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.messageboxicon?view=netframework-4.7.2
                    if (icon == MessageBoxIcon.Error) // also Hand and Stop
                    {
                        Icon erricon = new Icon(SystemIcons.Error, iconsize, iconsize);
                        iconPB.Image = erricon.ToBitmap();
                        iconPB.AccessibleDescription = "Error";
                        //this.Icon = SystemIcons.Error;
                        System.Media.SystemSounds.Hand.Play();
                    }
                    else if (icon == MessageBoxIcon.Question)
                    {
                        Icon qicon = new Icon(SystemIcons.Question, iconsize, iconsize);
                        iconPB.Image = qicon.ToBitmap();
                        iconPB.AccessibleDescription = "Question";
                        //this.Icon = SystemIcons.Question;
                        System.Media.SystemSounds.Question.Play();
                    }
                    else if (icon == MessageBoxIcon.Warning) // also Exclamation
                    {
                        Icon warnicon = new Icon(SystemIcons.Warning, iconsize, iconsize);
                        iconPB.Image = warnicon.ToBitmap();
                        iconPB.AccessibleDescription = "Warning";
                        //this.Icon = SystemIcons.Warning;
                        textpadding -= 2; // triangle shape looks worse without this
                        System.Media.SystemSounds.Exclamation.Play();
                    }
                    else if (icon == MessageBoxIcon.Information) // also Asterisk
                    {
                        Icon infoicon = new Icon(SystemIcons.Information, iconsize, iconsize);
                        iconPB.Image = infoicon.ToBitmap();
                        iconPB.AccessibleDescription = "Information";
                        //this.Icon = SystemIcons.Information;
                        System.Media.SystemSounds.Asterisk.Play();
                    }
                    else
                    {
                        throw new InvalidEnumArgumentException("icon", (int)icon, typeof(MessageBoxIcon));
                    }

                    MessageLbl.MinimumSize = new Size(MessageLbl.MinimumSize.Width - (iconsize + iconpadding + textpadding), MessageLbl.MinimumSize.Height);
                    MessageLbl.Left       += (iconsize + iconpadding + textpadding);
                    Controls.Add(iconPB);
                }

                if (defaultbutton == MessageBoxDefaultButton.Button1)
                {
                    this.AcceptButton = buttonrefs[0];
                    ActiveControl     = buttonrefs[0];
                }
                else if (defaultbutton == MessageBoxDefaultButton.Button2)
                {
                    if (buttonrefs[1] == null)
                    {
                        throw new ArgumentOutOfRangeException("defaultbutton", "defaultbutton cannot be set to a button number that does not exist");
                    }
                    this.AcceptButton = buttonrefs[1];
                    ActiveControl     = buttonrefs[1];
                }
                else if (defaultbutton == MessageBoxDefaultButton.Button3)
                {
                    if (buttonrefs[2] == null)
                    {
                        throw new ArgumentOutOfRangeException("defaultbutton", "defaultbutton cannot be set to a button number that does not exist");
                    }
                    this.AcceptButton = buttonrefs[2];
                    ActiveControl     = buttonrefs[2];
                }
                else
                {
                    throw new InvalidEnumArgumentException("defaultbutton", (int)defaultbutton, typeof(MessageBoxDefaultButton));
                }


                // MessageBoxOptions are more like flags than concrete settings.
                // For ease of use, we assume default value is whatever winforms gives us in current locale -- but we override if any value is set
                if ((options & MessageBoxOptions.RightAlign) == MessageBoxOptions.RightAlign)
                {
                    MessageLbl.TextAlign = ContentAlignment.TopRight;
                }
                else if (options != 0)
                {
                    MessageLbl.TextAlign = ContentAlignment.TopLeft;
                }

                // RtlReading should be what actually affects layout, and RightAlign only affects the text label
                if ((options & MessageBoxOptions.RtlReading) == MessageBoxOptions.RtlReading)
                {
                    foreach (Control control in this.Controls)
                    {
                        control.Left        = this.ClientSize.Width - control.Right;
                        control.RightToLeft = RightToLeft.Yes;
                    }
                    this.RightToLeft       = RightToLeft.Yes;
                    this.RightToLeftLayout = true;
                }
                else if (options != 0)
                {
                    foreach (Control control in this.Controls)
                    {
                        control.RightToLeft = RightToLeft.No;
                    }
                    this.RightToLeft       = RightToLeft.No;
                    this.RightToLeftLayout = false;
                }


                Skinning.SetBackCol(this, skin.UIColours[UIColours.UIColourDefs.Form_BG.TypeName]);
                Skinning.SetForeCol(this, skin.UIColours[UIColours.UIColourDefs.Form_Text.TypeName]);
                Skinning.SetUIStyle(this, skin.UIStyle);

                //Can use this to compare against official .NET
                //DialogResult test = MessageBox.Show("test test test test test test test test test test test test", "", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.RtlReading);
                //Console.WriteLine(test);
            }
Ejemplo n.º 9
0
 // has skin, no owner
 public static DialogResult Show(Skinning.Skin skin, string message, string caption = "", MessageBoxButtons buttons = MessageBoxButtons.OK, MessageBoxIcon icon = MessageBoxIcon.None, MessageBoxDefaultButton defaultbutton = MessageBoxDefaultButton.Button1, MessageBoxOptions options = 0)
 {
     return(Show(skin, null, message, caption, buttons, icon, defaultbutton, options));
 }