Exemplo n.º 1
0
        public void Initialize()
        {
            TextBox IP = new TextBox(MainCanvas.Instance);
            IP.Text = "127.0.0.1";
            IP.SetPosition(10, 10);

            NumericUpDown Port = new NumericUpDown(MainCanvas.Instance);
            Port.Max = ushort.MaxValue;
            Port.Min = 0;
            Port.Value = 54987;
            Port.SetPosition(10, 40);

            Button Connect = new Button(MainCanvas.Instance);
            Connect.Text = "Connect";
            Connect.SetPosition(10, 70);
            Connect.Clicked += delegate(Base sender, ClickedEventArgs args) {
                NetPeerConfiguration config = new NetPeerConfiguration("Xanatos");
                Program.Connection = new NetClient(config);
                Program.Connection.Start();
                Program.Connection.Connect(IP.Text, (int)Port.Value);

                while (((NetClient)Program.Connection).ConnectionStatus != NetConnectionStatus.Connected) {
                    Thread.Sleep(500);
                    Program.Connection.ReadMessages(new List<NetIncomingMessage>());
                }
                Message.RegisterClient(Program.Connection);

                new PlayerJoining().Send();
            };
        }
Exemplo n.º 2
0
 public override void PostLoad()
 {
     Gwen.Control.TextBox tbx = new Gwen.Control.TextBox (canvas);
     tbx.Height = 50;
     tbx.Dock = Gwen.Pos.Top;
     tbx.SetText ("TEXTBOX");
     tbx.TextChanged += (s, e) =>
     {
         Console.WriteLine ("TextChanged {0}", tbx.Text);
     };
     tbx.SubmitPressed += (s, e) =>
     {
         Console.WriteLine ("SubmitPressed {0}", tbx.Text);
     };
 }
Exemplo n.º 3
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;
        }
Exemplo n.º 4
0
        public PackageEditor(Package package)
            : base(DevelopmentMenu.Instance)
        {
            this.Resource = package;
            this.SetPosition((int)MouseManager.GetMousePositionWindows().X, (int)MouseManager.GetMousePositionWindows().Y);

            Label lblName = new Label(this);
            lblName.AutoSizeToContents = true;
            lblName.Text = "Name";
            lblName.SetPosition(10, 10);

            TextBox tbName = new TextBox(this);
            tbName.SetPosition(50, 10);
            tbName.SetSize(150, 20);
            tbName.Text = Resource.Name;
            tbName.TextChanged += tbName_TextChanged;

            this.SetSize(220, 80);
        }
Exemplo n.º 5
0
        public ResourceNode(Base parent, Resource res)
            : base(parent)
        {
            this.Resource = res;

            this.Text = res.Name;
            this.m_Title.Font = new Gwen.Font(MainCanvas.Renderer, "Arial");

            tbRename = new TextBox(m_Title);
            tbRename.SetPosition(16, 0);
            tbRename.Height = 16;
            tbRename.AutoSizeToContents = true;
            tbRename.Hide();

            tbRename.BoundsChanged += new GwenEventHandler<EventArgs>(tbRename_BoundsChanged);

            tbRename.SubmitPressed += delegate(Base sender, EventArgs args) { EndRename(); };
            //this.Unselected += delegate(Base sender, EventArgs args) { EndRename(); };
        }
Exemplo n.º 6
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);
            });
        }
Exemplo n.º 7
0
        private void InitializeUI()
        {
            settings = NavMeshGenerationSettings.Default;
            areaSettings = new AreaIdGenerationSettings();

            DockBase dock = new DockBase(gwenCanvas);
            dock.Dock = Pos.Fill;
            dock.SetSize(Width, Height);
            dock.RightDock.Width = 280;
            dock.BottomDock.Height = 150;

            statusBar = new StatusBar(gwenCanvas);

            Label genTime = new Label(statusBar);
            genTime.Name = "GenTime";
            genTime.Text = "Generation Time: 0ms";
            genTime.Dock = Pos.Left;

            LabeledCheckBox catchCheckBox = new LabeledCheckBox(statusBar);
            catchCheckBox.Text = "Intercept and log exceptions";
            catchCheckBox.Dock = Pos.Right;
            catchCheckBox.CheckChanged += (s, e) => interceptExceptions = catchCheckBox.IsChecked;
            catchCheckBox.IsChecked = true;

            Base genBase = new Base(dock);
            dock.RightDock.TabControl.AddPage("NavMesh Generation", genBase);

            Button generateButton = new Button(genBase);
            generateButton.Text = "Generate!";
            generateButton.Height = 30;
            generateButton.Dock = Pos.Top;
            generateButton.Released += (s, e) => GenerateNavMesh();

            Base clientBase = new Base(dock);
            dock.RightDock.TabControl.AddPage("Game Loading", clientBase);

            TextBox clientInput = new TextBox(clientBase);
            clientInput.Text = @"C:\Dark Age of Camelot1118L";
            clientInput.Height = 30;
            clientInput.Dock = Pos.Top;

            Button clientButton = new Button(clientBase);
            clientButton.Text = "Load!";
            clientButton.Height = 30;
            clientButton.Dock = Pos.Top;
            clientButton.Released += (s, e) => LoadClient(clientInput.Text);

            GroupBox displaySettings = new GroupBox(genBase);
            displaySettings.Text = "Display";
            displaySettings.Dock = Pos.Top;
            displaySettings.Height = 85;

            Base levelCheckBase = new Base(displaySettings);
            levelCheckBase.Dock = Pos.Top;

            Label levelCheckLabel = new Label(levelCheckBase);
            levelCheckLabel.Text = "Level";
            levelCheckLabel.Dock = Pos.Left;

            CheckBox levelCheckBox = new CheckBox(levelCheckBase);
            levelCheckBox.Dock = Pos.Right;
            levelCheckBox.Checked += (s, e) => displayLevel = true;
            levelCheckBox.UnChecked += (s, e) => displayLevel = false;
            levelCheckBox.IsChecked = true;

            levelCheckBase.SizeToChildren();

            Base displayModeBase = new Base(displaySettings);
            displayModeBase.Dock = Pos.Top;
            displayModeBase.Padding = new Padding(0, 4, 0, 0);

            Label displayModeLabel = new Label(displayModeBase);
            displayModeLabel.Text = "Generation Step";
            displayModeLabel.Dock = Pos.Left;
            displayModeLabel.Padding = new Padding(0, 0, 4, 0);

            ComboBox displayModes = new ComboBox(displayModeBase);
            displayModes.Dock = Pos.Top;
            displayModes.AddItem("None", "", DisplayMode.None);
            displayModes.AddItem("Heightfield", "", DisplayMode.Heightfield);
            displayModes.AddItem("Compact Heightfield", "", DisplayMode.CompactHeightfield);
            displayModes.AddItem("Distance Field", "", DisplayMode.DistanceField);
            displayModes.AddItem("Regions", "", DisplayMode.Regions);
            displayModes.AddItem("Contours", "", DisplayMode.Contours);
            displayModes.AddItem("Polygon Mesh", "", DisplayMode.PolyMesh);
            displayModes.AddItem("Polygon Mesh Detail", "", DisplayMode.PolyMeshDetail);
            displayModes.AddItem("NavMesh", "", DisplayMode.NavMesh);
            displayModes.AddItem("Pathfinding", "", DisplayMode.Pathfinding);
            displayModes.ItemSelected += (s, e) => displayMode = (DisplayMode)e.SelectedItem.UserData;

            displayModes.SelectByUserData(DisplayMode.PolyMeshDetail);
            displayModeBase.SizeToChildren();
            displayModeBase.Height += 4; //accounts for the padding, GWEN.NET should do this

            Base ZoneSelectBase = new Base(displaySettings);
            ZoneSelectBase.Dock = Pos.Top;
            ZoneSelectBase.Padding = new Padding(0, 4, 0, 0);

            Label ZoneSelect = new Label(ZoneSelectBase);
            ZoneSelect.Text = "Select Zone";
            ZoneSelect.Dock = Pos.Left;
            ZoneSelect.Padding = new Padding(0, 0, 4, 0);

            _levelDisplay = new ComboBox(ZoneSelectBase);
            _levelDisplay.Dock = Pos.Top;
            _levelDisplay.AddItem("--- None ---", "", -1);
            _levelDisplay.SelectByUserData(-1);

            ZoneSelectBase.SizeToChildren();
            ZoneSelectBase.Height += 4; //accounts for the padding, GWEN.NET should do this

            const int leftMax = 125;
            const int rightMax = 20;

            GroupBox areaSetting = new GroupBox(genBase);
            areaSetting.Text = "Area";
            areaSetting.Dock = Pos.Top;
            areaSetting.Height = 90;

            var levelTris = new [] { new Triangle3(new Vector3(0, 0, 0), new Vector3(0, 0, 0), new Vector3(0, 0, 0)) };
            BBox3 bounds = TriangleEnumerable.FromTriangle(levelTris, 0, levelTris.Length).GetBoundingBox();

            Base maxTriSlope = CreateSliderOption(areaSetting, "Max Tri Slope:", 0.0001f, 3.14f, 3.14f, "N2", leftMax, rightMax, v => areaSettings.MaxTriSlope = v);
            Base minLevelHeight = CreateSliderOption(areaSetting, "Min Height:", bounds.Min.Y, bounds.Max.Y, bounds.Min.Y, "N0", leftMax, rightMax, v => areaSettings.MinLevelHeight = v);
            Base maxLevelHeight = CreateSliderOption(areaSetting, "Max Height:", bounds.Min.Y, bounds.Max.Y, bounds.Max.Y, "N0", leftMax, rightMax, v => areaSettings.MaxLevelHeight = v);

            _levelDisplay.ItemSelected += (s, e) => {
                _levelId = (int)e.SelectedItem.UserData;
                areaSetting.RemoveChild(minLevelHeight, true);
                areaSetting.RemoveChild(maxLevelHeight, true);
                bounds = _level != null ? _level.BoundingBox
                    : TriangleEnumerable.FromTriangle(new []{ new Triangle3 { A = new Vector3(0, 0, 0), B = new Vector3(0, 0, 0), C = new Vector3(0, 0, 0) } }, 0, 1).GetBoundingBox();
                minLevelHeight = CreateSliderOption(areaSetting, "Min Height:", bounds.Min.Y, bounds.Max.Y, bounds.Min.Y, "N0", leftMax, rightMax, v => areaSettings.MinLevelHeight = v);
                maxLevelHeight = CreateSliderOption(areaSetting, "Max Height:", bounds.Min.Y, bounds.Max.Y, bounds.Max.Y, "N0", leftMax, rightMax, v => areaSettings.MaxLevelHeight = v);
            };

            GroupBox rsSettings = new GroupBox(genBase);
            rsSettings.Text = "Rasterization";
            rsSettings.Dock = Pos.Top;
            rsSettings.Height = 90;

            Base cellSizeSetting = CreateSliderOption(rsSettings, "Cell Size:", 0.001f, 2.0f, 0.125f, "N3", leftMax, rightMax, v => settings.CellSize = v);
            Base cellHeightSetting = CreateSliderOption(rsSettings, "Cell Height:", 0.001f, 2f, 0.063f, "N3", leftMax, rightMax, v => settings.CellHeight = v);

            GroupBox agentSettings = new GroupBox(genBase);
            agentSettings.Text = "Agent";
            agentSettings.Dock = Pos.Top;
            agentSettings.Height = 115;

            Base maxSlopeSetting = CreateSliderOption(agentSettings, "Max Climb:", 0.001f, 5.0f, 1.500f, "N3", leftMax, rightMax, v => settings.MaxClimb = v);
            Base maxHeightSetting = CreateSliderOption(agentSettings, "Height:", 0.001f, 2.0f, 0.250f, "N3", leftMax, rightMax, v => { settings.AgentHeight = v; agentCylinder.Height = v; });
            Base erodeRadius = CreateSliderOption(agentSettings, "Radius:", 0.001f, 1.0f, 0.125f, "N3", leftMax, rightMax, v => { settings.AgentRadius = v; agentCylinder.Radius = v; });
            Base addRemoveAgent = CreateAddRemoveButton(agentSettings, "Count", leftMax, rightMax, 0, MAX_AGENTS, () => { numActiveAgents++; GenerateCrowd(); }, () => { numActiveAgents--; GenerateCrowd(); });

            GroupBox regionSettings = new GroupBox(genBase);
            regionSettings.Text = "Region";
            regionSettings.Dock = Pos.Top;
            regionSettings.Height = 65;

            Base minRegionSize = CreateSliderOption(regionSettings, "Min Region Size:", 0f, 150f, 8f, "N0", leftMax, rightMax, v => settings.MinRegionSize = (int)Math.Round(v));
            Base mrgRegionSize = CreateSliderOption(regionSettings, "Merged Region Size:", 0f, 150f, 20f, "N0", leftMax, rightMax, v => settings.MergedRegionSize = (int)Math.Round(v));

            GroupBox navMeshSettings = new GroupBox(genBase);
            navMeshSettings.Text = "NavMesh";
            navMeshSettings.Dock = Pos.Top;
            navMeshSettings.Height = 90;

            Base maxEdgeLength = CreateSliderOption(navMeshSettings, "Max Edge Length:", 0f, 50f, 12f, "N0", leftMax, rightMax, v => settings.MaxEdgeLength = (int)Math.Round(v));
            Base maxEdgeErr = CreateSliderOption(navMeshSettings, "Max Edge Error:", 0f, 3f, 1.8f, "N1", leftMax, rightMax, v => settings.MaxEdgeError = v);
            Base vertsPerPoly = CreateSliderOption(navMeshSettings, "Verts Per Poly:", 3f, 12f, 6f, "N0", leftMax, rightMax, v => settings.VertsPerPoly = (int)Math.Round(v));

            GroupBox navMeshDetailSettings = new GroupBox(genBase);
            navMeshDetailSettings.Text = "NavMeshDetail";
            navMeshDetailSettings.Dock = Pos.Top;
            navMeshDetailSettings.Height = 65;

            Base sampleDistance = CreateSliderOption(navMeshDetailSettings, "Sample Distance:", 0f, 16f, 6f, "N0", leftMax, rightMax, v => settings.SampleDistance = (int)Math.Round(v));
            Base maxSampleError = CreateSliderOption(navMeshDetailSettings, "Max Sample Error:", 0f, 16f, 1f, "N0", leftMax, rightMax, v => settings.MaxSampleError = (int)Math.Round(v));

            Base logBase = new Base(dock);
            dock.BottomDock.TabControl.AddPage("Log", logBase);

            ListBox logBox = new ListBox(logBase);
            logBox.Dock = Pos.Fill;
            logBox.AllowMultiSelect = false;
            logBox.EnableScroll(true, true);
            Console.SetOut(new GwenTextWriter(logBox));
        }