protected override void StateStarted()
        {
            AbstractWindow pwin = Game.RenderSystem.Window;

            pwin.RemoveAllRegions();
            pwin.Clear();

            Window mainwin = new Window(pwin);

            mainwin.Size  = pwin.Size;
            mainwin.Title = "Sharplike.Tests.UI";
            mainwin.Style = BorderStyle.Double;

            ListBox ols = new ListBox(mainwin);

            ols.Location = new System.Drawing.Point(1, 1);
            ols.Size     = new System.Drawing.Size(11, 5);
            ListBoxItem def = ols.AddItem("New Game");

            ols.AddItem("Load Game");
            ols.AddItem("Quit");

            ols.SelectedItem = def;

            ols.Focus();

            Game.InputSystem.Command.CommandSet = "MainMenu";
        }
Exemple #2
0
        protected override void StateStarted()
        {
            AbstractWindow pwin = Game.RenderSystem.Window;

            pwin.RemoveAllRegions();
            pwin.Clear();

            Window mainwin = new Window(pwin);

            mainwin.Size  = pwin.Size;
            mainwin.Title = "(Press Escape)";
            mainwin.Style = BorderStyle.Double;


            Game.InputSystem.Command.CommandSet = "MainMenu";
        }
Exemple #3
0
        static void game_GameProcessing(object sender, EventArgs e)
        {
            AbstractWindow gwin = Game.RenderSystem.Window;

            gwin.Clear();
            for (Int32 i = 0; i < 256; i++)
            {
                Int32 x = i % 16;
                Int32 y = i / 16;

                Int32 r = Program.RNG.Next(0, 255);
                Int32 g = Program.RNG.Next(0, 255);
                Int32 b = Program.RNG.Next(0, 255);

                //gwin[x, y].AddGlyph(i, Color.White, Color.FromArgb(r, g, b));
            }
        }
Exemple #4
0
        void Main_Load(object sender, EventArgs e)
        {
            Game.Initialize();
            Game.SetRenderSystem("OpenTK");

            String glyphPath = Game.PathTo("curses_640x300.png");

            using (Stream imgstream = File.OpenRead(glyphPath))
            {
                GlyphPalette pal = new GlyphPalette(imgstream, 16, 16);

                window = Game.RenderSystem.CreateWindow(SharplikeView.Size, pal, SharplikeView);
            }

            SharplikeView.Controls[0].MouseDown += new MouseEventHandler(SharplikeView_MouseDown);
            SharplikeView.Controls[0].MouseUp   += new MouseEventHandler(SharplikeView_MouseUp);
            SharplikeView.Controls[0].MouseMove += new MouseEventHandler(SharplikeView_MouseMove);

            EntityList.ItemDrag += new ItemDragEventHandler(EntityList_ItemDrag);
            SharplikeView.Controls[0].AllowDrop  = true;
            SharplikeView.Controls[0].DragDrop  += new DragEventHandler(Main_DragDrop);
            SharplikeView.Controls[0].DragOver  += new DragEventHandler(Main_DragOver);
            SharplikeView.Controls[0].DragEnter += new DragEventHandler(Main_DragEnter);
            SharplikeView.Controls[0].DragLeave += new EventHandler(Main_DragLeave);

            //Game.SetInputSystem("OpenTK");

            window.Clear();

            ReplaceMap(new MapStack(window.Size, 20, 15, "EditorMap", null));
            Map.ViewFrom(new Vector3(0, 0, 0), true);

            Bitmap    glyphs    = Game.RenderSystem.Window.GlyphPalette.SourceBitmap;
            ImageList il        = new ImageList();
            Size      glyphSize = Game.RenderSystem.Window.GlyphPalette.GlyphDimensions;

            for (int y = 0; y < Game.RenderSystem.Window.GlyphPalette.RowCount; ++y)
            {
                for (int x = 0; x < Game.RenderSystem.Window.GlyphPalette.ColumnCount; ++x)
                {
                    Rectangle area = new Rectangle(x * glyphSize.Width, y * glyphSize.Height,
                                                   glyphSize.Width, glyphSize.Height);
                    Bitmap b = new Bitmap(glyphSize.Width, glyphSize.Height, glyphs.PixelFormat);
                    using (Graphics bg = Graphics.FromImage(b))
                    {
                        bg.Clear(Color.Black);
                        bg.DrawImageUnscaled(glyphs.Clone(area, glyphs.PixelFormat), new Point(0, 0));
                    }
                    il.Images.Add(b);
                }
            }
            EntityList.LargeImageList = il;
            EntityList.SmallImageList = il;

            SquareList.LargeImageList = il;
            SquareList.SmallImageList = il;

            foreach (EditorExtensionNode node in AddinManager.GetExtensionNodes("/Sharplike/Entities"))
            {
                ListViewItem i = new ListViewItem();
                i.Text        = node.Id;
                i.ToolTipText = node.TooltipText;
                i.Tag         = node;
                i.ImageIndex  = node.GlyphID;

                EntityList.Items.Add(i);
            }

            foreach (EditorExtensionNode node in AddinManager.GetExtensionNodes("/Sharplike/Squares"))
            {
                ListViewItem i = new ListViewItem();
                i.Text        = node.Id;
                i.ToolTipText = node.TooltipText;
                i.Tag         = node;
                i.ImageIndex  = node.GlyphID;

                SquareList.Items.Add(i);
            }

            foreach (ToolGroupExtensionNode node in AddinManager.GetExtensionNodes("/Sharplike/Editlike/Tools"))
            {
                foreach (ExtensionNode mapnode in node.ChildNodes)
                {
                    if (mapnode.GetType() == typeof(MapToolExtensionNode))
                    {
                        ToolStripButton btn = new ToolStripButton();
                        BuildButton(mapnode as MapToolExtensionNode, btn);
                        EditorTools.Items.Add(btn);
                    }
                    else
                    {
                        ToolStripDropDownButton ddbtn = new ToolStripDropDownButton();
                        ddbtn.DropDown.Width = 200;
                        foreach (MapToolExtensionNode mnode in mapnode.ChildNodes)
                        {
                            ToolStripButton btn = new ToolStripButton();
                            BuildButton(mnode, btn);
                            if (btn.DisplayStyle == ToolStripItemDisplayStyle.Image)
                            {
                                btn.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText;
                            }

                            Image i = mnode.Icon;
                            btn.Click += delegate(object send, EventArgs ea)
                            {
                                ddbtn.Image = i;
                                ddbtn.Tag   = btn;
                            };

                            ddbtn.DropDownItems.Add(btn);

                            if (ddbtn.Tag == null)
                            {
                                ddbtn.Tag   = btn;
                                ddbtn.Image = mnode.Icon;
                            }
                        }

                        ddbtn.Click += delegate(object send, EventArgs ea)
                        {
                            btn_Click(ddbtn.Tag, ea);
                        };

                        EditorTools.Items.Add(ddbtn);
                    }
                }
                EditorTools.Items.Add(new ToolStripSeparator());
            }

            viewTool = new ViewportTool();
            viewTool.SetActive(this, "");

            Game.Run();
        }