Example #1
0
        public CodeEditor(CodeFile resource)
            : base(DevelopmentMenu.Instance)
        {
            this.Title = "Code Editor";
            this.Resource = resource;
            this.SetSize(600, 400);
            this.SetPosition((int)MouseManager.GetMousePositionWindows().X, (int)MouseManager.GetMousePositionWindows().Y);

            CodeArea = new MultilineTextBox(this);
            CodeArea.AcceptTabs = true;
            CodeArea.SetSize(400, 400);
            CodeArea.Text = Resource.Source;
            CodeArea.Font = new Gwen.Font(MainCanvas.Renderer, "Consolas");
            CodeArea.Dock = Gwen.Pos.Fill;
            CodeArea.TextChanged +=new GwenEventHandler<EventArgs>(CodeArea_TextChanged);

            TopBar = new Base(this);
            TopBar.Dock = Gwen.Pos.Top;
            TopBar.SetSize(0, 25);
            {
                Run = new Button(TopBar);
                Run.Text = "Run";
                Run.Clicked += new GwenEventHandler<ClickedEventArgs>(Run_Clicked);
            }

            ErrorList = new ListBox(this);
            ErrorList.Dock = Gwen.Pos.Bottom;
            ErrorList.Height = 50;
        }
Example #2
0
        Base ConstructFindGame()
        {
            Base FindGame = new Base(MainCanvas.GetCanvas());
            FindGame.SetSize(300, 300);

            Label EnterIP = new Label(FindGame);
            EnterIP.AutoSizeToContents = true;
            EnterIP.SetText("Enter an IP:");
            EnterIP.SetPosition(10, 10);

            TextBox IPAddress = new TextBox(FindGame);
            IPAddress.SetText("127.0.0.1");
            IPAddress.SetPosition(10, 40);
            IPAddress.SetSize(260, 20);

            TextBox Port = new TextBox(FindGame);
            Port.SetText("54987");
            Port.SetPosition(10, 70);
            Port.SetSize(260, 20);

            Button Connect = new Button(FindGame);
            Connect.SetText("Connect");
            Connect.SetPosition(10, 200);
            Connect.SetSize(200, 20);
            Connect.Clicked += delegate(Base sender, ClickedEventArgs args) {
                Program.Connect(IPAddress.Text, Int32.Parse(Port.Text));
                MainMenu.Hide();
                FindGame.Hide();

                Connecting.Show();
            };

            Button Back = new Button(FindGame);
            Back.SetText("Back");
            Back.SetPosition(10, 225);
            Back.SetSize(200, 20);
            Back.Clicked += delegate(Base sender, ClickedEventArgs args) {
                Mode = MenuMode.MainMenu;
                MainMenu.Show();
                FindGame.Hide();
            };

            return FindGame;
        }
Example #3
0
        public override void DragAndDrop_HoverEnter(Package p, int x, int y)
        {
            if (m_TabDragControl != null)
            {
                throw new InvalidOperationException("ERROR! TabStrip::DragAndDrop_HoverEnter");
            }

            m_TabDragControl = new Highlight(this);
            m_TabDragControl.MouseInputEnabled = false;
            m_TabDragControl.SetSize(3, Height);
        }
Example #4
0
		public static void Main(string[] args) {
			g_testEntries = AllTests.GetTests();
			testCount = g_testEntries.Count();

			testIndex = Math.Max(0, Math.Min(testIndex, testCount - 1));
			testSelection = testIndex;

			entry = g_testEntries[testIndex];
			test = entry.createFcn();

			GraphicsManager.SetWindowState(OpenTK.WindowState.Maximized);
			string title = String.Format("Box2D Version {0}.{1}.{2}", Settings._version.major, Settings._version.minor, Settings._version.revision);
			GraphicsManager.SetTitle(title);

			camera = new Camera2D();
			camera.OnRender += SimulationLoop;

			camera.SetZoom(12);
			camera.CenterOnTarget(true);
			camera.SetLocation(0, 0);

			GraphicsManager.Update += new GraphicsManager.Updater(GraphicsManager_Update);

			WindowControl glui = new WindowControl(MainCanvas.GetCanvas());
			glui.Dock = Gwen.Pos.Left;

			Label text = new Label(glui);
			text.Text = "Tests";
			text.SetPosition(10, 10);

			testList = new ListBox(glui);
			testList.RowSelected += delegate(Base sender, ItemSelectedEventArgs tlargs) {
				testSelection = testList.SelectedRowIndex;
			};
			foreach (TestEntry e in g_testEntries) {
				testList.AddRow(e.name, "", e);
			}
			testList.SelectedRowIndex = testSelection;
			testList.SetPosition(10, 30);
			testList.SetSize(170, 180);

			//glui.add_separator();
			Base SettingsBox = new Base(glui);
			SettingsBox.SetSize(200, 185);
			SettingsBox.SetPosition(0, 250);
			{
				NumericUpDown spinner = new NumericUpDown(SettingsBox);
				spinner.Text = "Vel Iters";
				spinner.Min = 1;
				spinner.Max = 500;
				spinner.ValueChanged += delegate(Base sender, EventArgs vcargs) {
					settings.velocityIterations = (int)spinner.Value;
				};
				spinner.Value = settings.velocityIterations;
				spinner.SetPosition(10, 10);

				NumericUpDown posSpinner = new NumericUpDown(SettingsBox);
				posSpinner.Min = 0;
				posSpinner.Max = 100;
				posSpinner.Text = "Pos Iters";
				posSpinner.ValueChanged += delegate(Base sender, EventArgs psargs) {
					settings.positionIterations = (int)posSpinner.Value;
				};
				posSpinner.Value = settings.positionIterations;
				posSpinner.SetPosition(10, 35);

				NumericUpDown hertzSpinner = new NumericUpDown(SettingsBox);
				hertzSpinner.Text = "Hertz";
				hertzSpinner.Min = 5;
				hertzSpinner.Max = 200;
				hertzSpinner.ValueChanged += delegate(Base sender, EventArgs hargs) {
					settingsHz = hertzSpinner.Value;
				};
				hertzSpinner.Value = settingsHz;
				hertzSpinner.SetPosition(10, 60);

				LabeledCheckBox scb = new LabeledCheckBox(SettingsBox);
				scb.Text = "Sleep";
				scb.CheckChanged += delegate(Base sender, EventArgs argsscb) {
					settings.enableSleep = scb.IsChecked;
				};
				scb.IsChecked = settings.enableSleep;
				scb.SetPosition(10, 85);

				LabeledCheckBox wsu = new LabeledCheckBox(SettingsBox);
				wsu.Text = "Warm Starting";
				wsu.CheckChanged += delegate(Base sender, EventArgs argsscb) {
					settings.enableWarmStarting = wsu.IsChecked;
				};
				wsu.IsChecked = settings.enableWarmStarting;
				wsu.SetPosition(10, 110);

				LabeledCheckBox toi = new LabeledCheckBox(SettingsBox);
				toi.Text = "Time of Impact";
				toi.CheckChanged += delegate(Base sender, EventArgs argsscb) {
					settings.enableContinuous = toi.IsChecked;
				};
				toi.IsChecked = settings.enableContinuous;
				toi.SetPosition(10, 135);

				LabeledCheckBox ssb = new LabeledCheckBox(SettingsBox);
				ssb.Text = "Sub-Stepping";
				ssb.CheckChanged += delegate(Base sender, EventArgs argsscb) {
					settings.enableSubStepping = ssb.IsChecked;
				};
				ssb.IsChecked = settings.enableSubStepping;
				ssb.SetPosition(10, 160);
			}

			Base drawPanel = new Base(glui);
			drawPanel.Dock = Gwen.Pos.Bottom;
			drawPanel.SetSize(200, 225);
			{
				LabeledCheckBox cbShapes = new LabeledCheckBox(drawPanel);
				cbShapes.Text = "Shapes";
				cbShapes.IsChecked = settings.drawShapes;
				cbShapes.CheckChanged += delegate(Base cbshapes, EventArgs eacbshapes) {
					settings.drawShapes = cbShapes.IsChecked;
				};
				cbShapes.SetPosition(10, 10);



				//glui.add_checkbox_to_panel(drawPanel, "Joints", &settings.drawJoints);
				LabeledCheckBox cbJoints = new LabeledCheckBox(drawPanel);
				cbJoints.Text = "Joints";
				cbJoints.IsChecked = settings.drawJoints;
				cbJoints.CheckChanged += delegate(Base cbshapes, EventArgs eacbshapes) {
					settings.drawJoints = cbJoints.IsChecked;
				};
				cbJoints.SetPosition(10, 30);



				//glui.add_checkbox_to_panel(drawPanel, "AABBs", &settings.drawAABBs);
				LabeledCheckBox cbAABBs = new LabeledCheckBox(drawPanel);
				cbAABBs.Text = "AABBs";
				cbAABBs.IsChecked = settings.drawAABBs;
				cbAABBs.CheckChanged += delegate(Base cbshapes, EventArgs eacbshapes) {
					settings.drawAABBs = cbAABBs.IsChecked;
				};
				cbAABBs.SetPosition(10, 50);



				//glui.add_checkbox_to_panel(drawPanel, "Contact Points", &settings.drawContactPoints);
				LabeledCheckBox cbPoints = new LabeledCheckBox(drawPanel);
				cbPoints.Text = "Contact Points";
				cbPoints.IsChecked = settings.drawContactPoints;
				cbPoints.CheckChanged += delegate(Base cbshapes, EventArgs eacbshapes) {
					settings.drawContactPoints = cbPoints.IsChecked;
				};
				cbPoints.SetPosition(10, 70);



				//glui.add_checkbox_to_panel(drawPanel, "Contact Normals", &settings.drawContactNormals);
				LabeledCheckBox cbNormals = new LabeledCheckBox(drawPanel);
				cbNormals.Text = "Contact Normals";
				cbNormals.IsChecked = settings.drawContactNormals;
				cbNormals.CheckChanged += delegate(Base cbshapes, EventArgs eacbshapes) {
					settings.drawContactNormals = cbNormals.IsChecked;
				};
				cbNormals.SetPosition(10, 90);



				//glui.add_checkbox_to_panel(drawPanel, "Contact Impulses", &settings.drawContactImpulse);
				LabeledCheckBox cbImpulses = new LabeledCheckBox(drawPanel);
				cbImpulses.Text = "Contact Impulses";
				cbImpulses.IsChecked = settings.drawContactImpulse;
				cbImpulses.CheckChanged += delegate(Base cbshapes, EventArgs eacbshapes) {
					settings.drawContactImpulse = cbImpulses.IsChecked;
				};
				cbImpulses.SetPosition(10, 110);



				//glui.add_checkbox_to_panel(drawPanel, "Friction Impulses", &settings.drawFrictionImpulse);
				LabeledCheckBox cbFriction = new LabeledCheckBox(drawPanel);
				cbFriction.Text = "Friction Impulses";
				cbFriction.IsChecked = settings.drawFrictionImpulse;
				cbFriction.CheckChanged += delegate(Base cbshapes, EventArgs eacbshapes) {
					settings.drawFrictionImpulse = cbFriction.IsChecked;
				};
				cbFriction.SetPosition(10, 130);



				//glui.add_checkbox_to_panel(drawPanel, "Center of Masses", &settings.drawCOMs);
				LabeledCheckBox cbMasses = new LabeledCheckBox(drawPanel);
				cbMasses.Text = "Center of Masses";
				cbMasses.IsChecked = settings.drawCOMs;
				cbMasses.CheckChanged += delegate(Base cbshapes, EventArgs eacbshapes) {
					settings.drawCOMs = cbMasses.IsChecked;
				};
				cbMasses.SetPosition(10, 150);



				//glui.add_checkbox_to_panel(drawPanel, "Statistics", &settings.drawStats);
				LabeledCheckBox cbStatistics = new LabeledCheckBox(drawPanel);
				cbStatistics.Text = "Statistics";
				cbStatistics.IsChecked = settings.drawStats;
				cbStatistics.CheckChanged += delegate(Base cbshapes, EventArgs eacbshapes) {
					settings.drawStats = cbStatistics.IsChecked;
				};
				cbStatistics.SetPosition(10, 170);



				//glui.add_checkbox_to_panel(drawPanel, "Profile", &settings.drawProfile);
				LabeledCheckBox cbProfile = new LabeledCheckBox(drawPanel);
				cbProfile.Text = "Profile";
				cbProfile.IsChecked = settings.drawProfile;
				cbProfile.CheckChanged += delegate(Base cbshapes, EventArgs eacbshapes) {
					settings.drawProfile = cbProfile.IsChecked;
				};
				cbProfile.SetPosition(10, 190);
			}


			Base Buttons = new Base(glui);
			Buttons.Dock = Gwen.Pos.Bottom;
			Buttons.Height = 100;
			{
				Button btnPause = new Button(Buttons);
				btnPause.Text = "Pause";
				btnPause.IsToggle = true;
				btnPause.SetPosition(10, 10);
				btnPause.ToggleState = settings.pause;
				btnPause.Clicked += delegate(Base sender, ClickedEventArgs evargs) {
					settings.pause = btnPause.ToggleState;
				};

				Button btnSS = new Button(Buttons);
				btnSS.Text = "Single Step";
				btnSS.SetPosition(10, 40);
				btnSS.Clicked += delegate(Base sender, ClickedEventArgs evargs) {
					SingleStep();
				};

				Button btnRestart = new Button(Buttons);
				btnRestart.Text = "Restart";
				btnRestart.SetPosition(10, 70);
				btnRestart.Clicked += delegate(Base sender, ClickedEventArgs evargs) {
					Restart();
				};
			}

			glui.SetSize(200, 300);			
			GraphicsManager.Start();
		}
Example #5
0
        public void Init(Base parent, Inventory inventory)
        {
            this.inventory = inventory;

            Item_Text = new Gwen.ControlInternal.Text (parent);
            Item_Text.Font = new Gwen.Font (application.RendererContext.GwenRenderer);
            Item_Text.Y = 5;
            Item_Text.Font.Size = 15;

            spaces = new InventorySpace[inventory.Size.X, inventory.Size.Y];
            barItems = new List<InventoryBarButton>();

            canvasFrame = new InventoryBackground(parent, inventory, this);
            canvasFrame.Width = parent.Width;
            canvasFrame.Height = parent.Height;

            window = new WindowControl (canvasFrame, Localizer.Instance.GetValueForName("inventory"));
            window.DisableResizing ();
            window.IsMoveable = false;
            window.OnClose += (sender, arguments) => application.Window.CaptureMouse ();

            itemGridFrame = new Base (window);
            itemGridFrame.SetSize ((BoxSize + 1) * inventory.Size.X, (BoxSize + 1) * inventory.Size.Y);


            bla_unfug_crosshair = new ImagePanel (canvasFrame);
            bla_unfug_crosshair.SetSize (16, 16);
            bla_unfug_crosshair.ImageName = "Content/crosshair.png";
            bla_unfug_crosshair.SetPosition ((canvasFrame.Width / 2.0f) - (bla_unfug_crosshair.Width / 2.0f), 
                (canvasFrame.Height / 2.0f) - (bla_unfug_crosshair.Width / 2.0f));
            bla_unfug_crosshair.BringToFront ();

            itemInfoFrame = new Base (window);
            itemInfoFrame.SetSize (infoFrameSize, itemGridFrame.Height);
            itemGridFrame.X += itemInfoFrame.Width + 4;

            toolbarFrame = new Base(window);
            toolbarFrame.Width = itemGridFrame.Width + itemInfoFrame.Width;
            toolbarFrame.Height = toolbarFrameSize;
            toolbarFrame.Y = itemGridFrame.Height - 4;

            dropBtn = new Button(toolbarFrame);
            dropBtn.AutoSizeToContents = true;
            dropBtn.Padding = btnPadding;
            dropBtn.Text = Localizer.Instance.GetValueForName("drop");
            dropBtn.X = toolbarFrame.Width - dropBtn.Width;
            dropBtn.Y = (toolbarFrameSize - dropBtn.Height) / 2;
            dropBtn.IsDisabled = true;
            dropBtn.Clicked += (sender, arguments) => {
                if (dropBtn.IsDisabled)
                    return;

                if (toggledBtn != null)
                {
                    dropItem(toggledBtn, toggledBtn.Item, inventory);
                }
            };

            useBtn = new Button(toolbarFrame);
            useBtn.AutoSizeToContents = true;
            useBtn.Padding = btnPadding;
            useBtn.Text = Localizer.Instance.GetValueForName("use");
            useBtn.X = dropBtn.X - useBtn.Width - 8;
            useBtn.Y = (toolbarFrameSize - useBtn.Height) / 2;
            useBtn.IsDisabled = true;
            useBtn.Clicked += (sender, arguments) => {
                if (useBtn.IsDisabled)
                    return;

                if (toggledBtn != null)
                {
                    if (MessageCreated != null)
                        MessageCreated(new ItemUseMessage(player, GameState.Scene, toggledBtn.Item, ItemUsage.Eatable));
                }
            };

            rotateBtn = new Button(toolbarFrame);
            rotateBtn.AutoSizeToContents = true;
            rotateBtn.Padding = btnPadding;
            rotateBtn.Text = Localizer.Instance.GetValueForName("rotate");
            rotateBtn.X = useBtn.X - rotateBtn.Width - 8;
            rotateBtn.Y = (toolbarFrameSize - rotateBtn.Height) / 2;
            rotateBtn.IsDisabled = true;

            rotateBtn.Clicked += (sender, argument) => {
                if (rotateBtn.IsDisabled)
                    return;

                var pos = inventory.GetPositionOfItem(toggledBtn.Item);
                var item = inventory.TakeOut(pos);
                var prev_orientation = item.Orientation;
                item.Orientation =
                    item.Orientation == Orientation.Horizontal ? Orientation.Vertical : Orientation.Horizontal;
                if (!inventory.Insert(item, pos))
                {
                    item.Orientation = prev_orientation;
                    if (!inventory.Insert(item, pos))
                    {
                        Logger.Log.AddLogEntry(LogLevel.Error, "InventoryGUI",
                            "Lost an inventory item while rotating!");
                        toggledBtn.DelayedDelete();
                        toggledBtn = null;
                        return;
                    }
                }
                toggledBtn.UpdateSize();
            };

            inventoryBar = new TextBox(canvasFrame);
            inventoryBar.Disable();
            inventoryBar.KeyboardInputEnabled = false;
            inventoryBar.Height = barBoxSize + 2;
            inventoryBar.Width = barBoxSize * inventory.InventoryBar.Length + 1;
            inventoryBar.Y = canvasFrame.Height - inventoryBar.Height;
            inventoryBar.X = (canvasFrame.Width - inventoryBar.Width) / 2;
            barSpaces = new InventoryBarSpace[inventory.InventoryBar.Length];
            for (int i = 0; i < inventory.InventoryBar.Length; i++)
            {
                barSpaces[i] = new InventoryBarSpace(inventoryBar, MessageProvider, inventory, this, barItems, barBoxSize);
                barSpaces[i].X = i * barBoxSize;
                barSpaces[i].Y = 1;
                barSpaces[i].Width = barBoxSize + 1;
                barSpaces[i].Height = barBoxSize + 1;
                barSpaces[i].DrawDebugOutlines = false;

                if (i == inventory.ActiveBarPosition)
                {
                    barSpaces[i].DrawDebugOutlines = true;
                    barSpaces[i].Children.ForEach(c => c.DrawDebugOutlines = false);
                }
            }

            window.SetSize (itemGridFrame.Width + itemInfoFrame.Width + 16,
                itemGridFrame.Height + toolbarFrameSize + 28);
            window.SetPosition ((canvasFrame.Width - window.Width) / 2,
                (canvasFrame.Height - window.Height - inventoryBar.Height) / 2);
            window.Hide();

            int w = 0, h = 0;

            for (int y = 0; y < inventory.Size.Y; y++)
            {
                for (int x = 0; x < inventory.Size.X; x++)
                {
                    spaces [x, y] = new InventorySpace (itemGridFrame, BoxSize, inventory);
                    spaces [x, y].X = w;
                    spaces [x, y].Y = h;
                    spaces [x, y].Width = BoxSize + 1;
                    spaces [x, y].Height = BoxSize + 1;

                    w += BoxSize;
                }
                h += BoxSize;
                w = 0;
            }

            imagePanel = new ImagePanel(itemInfoFrame);
            imagePanel.Width = infoFrameSize;
            imagePanelHeight = itemGridFrame.Height / 3;
            imagePanel.Hide();

            items = new List<InventoryButton>();
            inventory.Items.ForEach((item, position) => {
                AddItem(item, position);
            });
        }
Example #6
0
        Base ConstructMainMenu()
        {
            Base MainMenu = new Base(MainCanvas.GetCanvas());
            MainMenu.SetSize(300, 300);
            MainMenu.Dock = Gwen.Pos.Center;

            Button SinglePlayer = new Button(MainMenu);
            SinglePlayer.SetText("Single Player");
            SinglePlayer.SetPosition(10, 10);
            SinglePlayer.SetSize(220, 20);
            //SinglePlayer.Clicked += delegate(Base caller) {
            //    Mode = SINGLEPLAYER;
            //    MainMenu.Hide();
            //};
            SinglePlayer.Disable();

            Button JoinGame = new Button(MainMenu);
            JoinGame.SetText("Join Game");
            JoinGame.SetPosition(10, 70);
            JoinGame.SetSize(220, 20);
            JoinGame.Clicked += delegate(Base sender, ClickedEventArgs args) {
                MainMenu.Hide();
                FindGame.Show();

                Mode = MenuMode.JoiningGame;
            };

            Button Quit = new Button(MainMenu);
            Quit.SetText("Quit");
            Quit.SetPosition(10, 100);
            Quit.SetSize(220, 20);
            Quit.Clicked += delegate(Base sender, ClickedEventArgs args) {
                MainCanvas.Dispose();
                Environment.Exit(0);
            };

            return MainMenu;
        }