Exemplo n.º 1
0
        public Screen_TechTree(Base parent)
            : base(parent)
        {
            Gwen.Control.Button buttonOK = new Gwen.Control.Button(this);
            buttonOK.Text = "Back";
            buttonOK.Font = Program.fontButtonLabels;
            buttonOK.SetBounds(500, 500, 50, 50);
            buttonOK.Clicked += onButtonOKClick;

            Tech.Inint();
            SetSize(parent.Width, parent.Height);

            label      = new Gwen.Control.Label(this);
            label.Text = "Tech_Tree Probe";
            label.SetPosition(Program.percentW(85), Program.percentH(85));
            label.TextColor = Color.FromArgb(200, 80, 0, 250);
            label.Font      = Program.fontLogo;

            img = new Gwen.Control.ImagePanel(this);


            updateDrawing();

            img.SetPosition(Program.percentW(0), Program.percentH(0));
            img.SetSize(Program.percentW(80), Program.percentH(80));
            //img.Clicked += new GwenEventHandler<ClickedEventArgs>(img_Clicked);
            img.MouseMoved += new GwenEventHandler <MovedEventArgs>(img_MouseMoved);
            img.MouseDown  += new GwenEventHandler <ClickedEventArgs>(img_MouseDown);
            img.MouseUp    += new GwenEventHandler <ClickedEventArgs>(img_MouseUp);
        }
Exemplo n.º 2
0
        public Screen_GameScreen(Base parent)
            : base(parent)
        {
            SetSize(parent.Width, parent.Height);

            label      = new Gwen.Control.Label(this);
            label.Text = "GAME!!!";
            label.SetPosition(Program.percentW(5), Program.percentH(5));
            label.TextColor = Color.FromArgb(200, 80, 0, 250);
            label.Font      = Program.fontLogo;

            img = new Gwen.Control.ImagePanel(this);


            galaxyImage = new Bitmap(Program.percentW(100), Program.percentH(80), PixelFormat.Format32bppArgb);
            DrawControl = new DrawController(galaxyImage);

            updateDrawing();

            img.SetPosition(Program.percentW(0), Program.percentH(20));
            img.SetSize(Program.percentW(100), Program.percentH(80));
            //img.Clicked += new GwenEventHandler<ClickedEventArgs>(img_Clicked);
            img.MouseMoved += new GwenEventHandler <MovedEventArgs>(img_MouseMoved);
            img.MouseDown  += new GwenEventHandler <ClickedEventArgs>(img_MouseDown);
            img.MouseUp    += new GwenEventHandler <ClickedEventArgs>(img_MouseUp);

            Gwen.Control.Button buttonTech = new Gwen.Control.Button(this);
            buttonTech.Text = "Tech Tree";
            buttonTech.Font = Program.fontButtonLabels;
            buttonTech.SetBounds(Program.percentW(80), Program.percentH(84), Program.percentW(20), Program.percentH(8));
            buttonTech.Clicked += onButtonTechClick;

            Gwen.Control.Button buttonMenu = new Gwen.Control.Button(this);
            buttonMenu.Text = "Menu";
            buttonMenu.Font = Program.fontButtonLabels;
            buttonMenu.SetBounds(Program.percentW(0), Program.percentH(0), Program.percentW(13), Program.percentH(8));
            buttonMenu.Clicked += onButtonMenuClick;

            Gwen.Control.Button buttonSolarSystem = new Gwen.Control.Button(this);
            buttonSolarSystem.Text = "Solar System";
            buttonSolarSystem.Font = Program.fontButtonLabels;
            buttonSolarSystem.SetBounds(Program.percentW(0), Program.percentH(92), Program.percentW(19), Program.percentH(8));
            buttonSolarSystem.Clicked += onSolarSystemClick;

            Gwen.Control.Button buttonStep = new Gwen.Control.Button(this);
            buttonStep.Text = "Step";
            buttonStep.Font = Program.fontButtonLabels;
            buttonStep.SetBounds(Program.percentW(90), Program.percentH(92), Program.percentW(10), Program.percentH(8));
            buttonStep.Clicked += onSolarSystemClick;

            buttonCombat      = new Gwen.Control.Button(this);
            buttonCombat.Text = "Combat";
            buttonCombat.Font = Program.fontButtonLabels;
            buttonCombat.SetBounds(Program.percentW(19), Program.percentH(92), Program.percentW(18), Program.percentH(8));
            buttonCombat.Clicked += onCombatClick;
        }
Exemplo n.º 3
0
        public Screen_Combat(Base parent)
            : base(parent)
        {
            SetSize(parent.Width, parent.Height);

            imgCombatMap = new Gwen.Control.ImagePanel(this);

            tacticState.New(ref seed);
            ShipsCounter.ShipsCount(ref seed);
            pictureMap.Width  = Program.percentW(100);
            pictureMap.Height = Program.percentH(82);
            tacticDraw.New(pictureMap, seed, tacticState);

            UpdateDrawing();

            imgCombatMap.SetPosition(Program.percentW(0), Program.percentH(0));
            imgCombatMap.SetSize(pictureMap.Width, pictureMap.Height);
            imgCombatMap.MouseDown += new GwenEventHandler <ClickedEventArgs>(imgCombatMap_MouseDown);

            buttonStep      = new Gwen.Control.Button(this);
            buttonStep.Text = "Step";
            buttonStep.Font = Program.fontButtonLabels;
            buttonStep.SetBounds(Program.percentW(82), Program.percentH(82), Program.percentW(18), Program.percentH(6));
            buttonStep.Clicked += onStepClick;

            buttonConcede      = new Gwen.Control.Button(this);
            buttonConcede.Text = "Concede";
            buttonConcede.Font = Program.fontButtonLabels;
            buttonConcede.SetBounds(Program.percentW(82), Program.percentH(88), Program.percentW(18), Program.percentH(6));
            buttonConcede.Clicked += onConcedeClick;

            buttonAutoBattle      = new Gwen.Control.Button(this);
            buttonAutoBattle.Text = "Auto Battle";
            buttonAutoBattle.Font = Program.fontButtonLabels;
            buttonAutoBattle.SetBounds(Program.percentW(82), Program.percentH(94), Program.percentW(18), Program.percentH(6));
            buttonAutoBattle.Clicked += onAutoBattleClick;

            labelStep           = new Gwen.Control.Label(this);
            labelStep.Text      = "Ходит 1-й игрок";
            labelStep.Font      = Program.fontText;
            labelStep.TextColor = Color.GreenYellow;
            labelStep.SetBounds(Program.percentW(65), Program.percentH(90), Program.percentW(20), Program.percentH(8));

            labelDescription           = new Gwen.Control.Label(this);
            labelDescription.Text      = "";
            labelDescription.Font      = Program.fontText;
            labelDescription.TextColor = Color.GreenYellow;
            labelDescription.SetBounds(Program.percentW(0), Program.percentH(82), Program.percentW(50), Program.percentH(18));
        }
Exemplo n.º 4
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.º 5
0
        public override void InitUi(Canvas canvas) {
            _canvas = canvas;
            Game.BackgroundColor = Color.Black;

            var windowAction = new WindowControl(canvas, "Options", false);
            windowAction.DisableResizing();
            windowAction.IsClosable = false;
            windowAction.SetSize(200, 150);
            windowAction.SetPosition(0, 0);

            var addScriptButton = new Button(windowAction);
            addScriptButton.SetText("Ajouter un script");
            addScriptButton.Clicked += (sender, arguments) => ShowAddScriptWindow(canvas);
            Align.CenterHorizontally(addScriptButton);


            // Fenêtre sur les informations du script sélectionné 
            _windowInfoScript = new WindowControl(canvas, "Paramètres du script");
            _windowInfoScript.DisableResizing();
            _windowInfoScript.IsClosable = false;
            _windowInfoScript.SetSize(200, 300);
            _windowInfoScript.SetPosition(Game.GetWindowSize().X - _windowInfoScript.Width, 0);

            var labelX = new Label(_windowInfoScript);
            labelX.SetPosition(0, 10);
            labelX.SetText("X :");

            _uiInfoTextBoxPosX = new TextBoxNumeric(_windowInfoScript);
            _uiInfoTextBoxPosX.SetSize(100, _uiInfoTextBoxPosX.Height);
            _uiInfoTextBoxPosX.TextChanged += (sender, arguments) => {
                if (_selectScript != null) {
                    _selectScript.RectShape.Position = new Vector2f((int) _uiInfoTextBoxPosX.Value,
                        _selectScript.RectShape.Position.Y);
                }
            };
            Align.PlaceRightBottom(_uiInfoTextBoxPosX, labelX, 10);

            var labelY = new Label(_windowInfoScript);
            labelY.SetText("Y :");
            Align.PlaceDownLeft(labelY, labelX, 10);

            _uiInfoTextBoxPosY = new TextBoxNumeric(_windowInfoScript);
            _uiInfoTextBoxPosY.SetSize(100, _uiInfoTextBoxPosY.Height);
            _uiInfoTextBoxPosY.TextChanged += (sender, arguments) => {
                if (_selectScript != null) {
                    _selectScript.RectShape.Position = new Vector2f(_selectScript.RectShape.Position.X,
                        (int) _uiInfoTextBoxPosY.Value);
                }
            };
            Align.PlaceRightBottom(_uiInfoTextBoxPosY, labelY, 10);

            var labelSizeX = new Label(_windowInfoScript);
            labelSizeX.SetText("Largeur :");
            Align.PlaceDownLeft(labelSizeX, labelY, 10);

            _uiInfoTextBoxSizeX = new TextBoxNumeric(_windowInfoScript);
            _uiInfoTextBoxSizeX.SetSize(100, _uiInfoTextBoxPosY.Height);
            _uiInfoTextBoxSizeX.TextChanged += (sender, arguments) => {
                if (_selectScript != null) {
                    _selectScript.RectShape.Size = new Vector2f((int)_uiInfoTextBoxSizeX.Value,
                        _selectScript.RectShape.Size.Y);
                    _selectScript.RectShape.Origin = new Vector2f(_selectScript.RectShape.Size.X / 2, _selectScript.RectShape.Size.Y / 2);
                }
            };
            Align.PlaceRightBottom(_uiInfoTextBoxSizeX, labelSizeX, 10);

            var labelSizeY = new Label(_windowInfoScript);
            labelSizeY.SetText("Hauteur :");
            Align.PlaceDownLeft(labelSizeY, labelSizeX, 10);

            _uiInfoTextBoxSizeY = new TextBoxNumeric(_windowInfoScript);
            _uiInfoTextBoxSizeY.SetSize(100, _uiInfoTextBoxSizeY.Height);
            _uiInfoTextBoxSizeY.TextChanged += (sender, arguments) => {
                if (_selectScript != null) {
                    _selectScript.RectShape.Size = new Vector2f(_selectScript.RectShape.Size.X,
                        (int)_uiInfoTextBoxSizeY.Value);
                    _selectScript.RectShape.Origin = new Vector2f(_selectScript.RectShape.Size.X / 2, _selectScript.RectShape.Size.Y / 2);
                }
            };
            Align.PlaceRightBottom(_uiInfoTextBoxSizeY, labelSizeY, 10);

            _uiInfoScriptImage = new ImagePanel(_windowInfoScript);
            _uiInfoScriptImage.SetSize(75, 75);
            _uiInfoScriptImage.Hide();

            Align.PlaceDownLeft(_uiInfoScriptImage, _uiInfoTextBoxSizeY, 10);
            Align.CenterHorizontally(_uiInfoScriptImage);

            UnSelect_SelectScript();
        }