示例#1
0
        public TutorialMenu (Application application, Base parent)
        {
            this.application = application;
            this.parent = parent;

            window = new WindowControl (parent);
            window.DisableResizing();
            window.Title = Localizer.Instance.GetValueForName("tutorial");
            window.IsMoveable = false;
            window.Hide();
            window.Height = parent.Height - (int) (parent.Height * 0.35);
            window.Y = (int) (parent.Height * 0.35) - 20;
            window.Width = parent.Width - 320;
            window.X = 280;

            scrollFrame = new ScrollControl (window);
            scrollFrame.AutoHideBars = true;
            scrollFrame.EnableScroll (false, true);
            scrollFrame.Width = window.Width - 12;
            scrollFrame.Height = window.Height - 32;

            updateTutorialText(Localizer.Instance.GetValueForName("tutorial_text"));

            ValidMessages = new[] { (int) MessageId.WindowResize, (int) MessageId.UpdateLocale };
            application.MessageManager += this;
        }
示例#2
0
        public ColorPickers(Base parent)
            : base(parent)
        {
            /* RGB Picker */
            {
                ColorPicker rgbPicker = new ColorPicker(this);
                rgbPicker.SetPosition(10, 10);
                rgbPicker.ColorChanged += ColorChanged;
            }

            /* HSVColorPicker */
            {
                HSVColorPicker hsvPicker = new HSVColorPicker(this);
                hsvPicker.SetPosition(300, 10);
                hsvPicker.ColorChanged += ColorChanged;
            }

            /* HSVColorPicker in Window */
            {
                Control.WindowControl Window = new WindowControl(this);
                Window.SetSize(300, 300);
                Window.Hide();

                HSVColorPicker hsvPicker = new HSVColorPicker(Window);
                hsvPicker.SetPosition(10, 10);
                hsvPicker.ColorChanged += ColorChanged;

                Control.Button OpenWindow = new Control.Button(this);
                OpenWindow.SetPosition(10, 200);
                OpenWindow.SetSize(200, 20);
                OpenWindow.Text = "Open Window";
                OpenWindow.Clicked += delegate(Base sender, ClickedEventArgs args) { Window.Show(); };
            }
        }
示例#3
0
        public PauseMenu (Application app, CompositorColorCorrectionNode colorCorrectionNode, Base parent,
            Action onContinue, Action onPause)
        {
            this.onContinue = onContinue;
            this.onPause = onPause;
            this.colorCorrectionNode = colorCorrectionNode;
            this.application = app;
            this.parent = parent;

            settings = new SettingsMenu (app, parent, colorCorrectionNode);

            window = new WindowControl (parent, Localizer.Instance.GetValueForName("pause"));
            window.DisableResizing();
            window.IsMoveable = false;
            window.OnClose += (sender, arguments) => Hide();
            window.Width = BUTTON_WIDTH + 20;
            window.Hide();

            continueButton = new Button (window);
            continueButton.Text = Localizer.Instance.GetValueForName("back_to_game");
            continueButton.Width = BUTTON_WIDTH;
            continueButton.X = 10;
            continueButton.Y = 10;
            continueButton.Clicked += (sender, arguments) => Hide();

            settingsButton = new Button (window);
            settingsButton.Text = Localizer.Instance.GetValueForName("settings");
            settingsButton.Width = BUTTON_WIDTH;
            settingsButton.X = 10;
            settingsButton.Y = 10 + continueButton.Y + continueButton.Height;
            settingsButton.Clicked += (sender, arguments) => settings.Show();

            exitButton = new Button (window);
            exitButton.Text = Localizer.Instance.GetValueForName("quit_game");
            exitButton.Width = BUTTON_WIDTH;
            exitButton.X = 10;
            exitButton.Y = 10 + settingsButton.Y + settingsButton.Height;
            exitButton.Clicked += (sender, arguments) => application.Window.Close ();

            window.Height += exitButton.Y + exitButton.Height + 10;
            window.X = (parent.Width - window.Width) / 2;
            window.Y = (parent.Height - window.Height) / 2;

            ValidMessages = new int[] { (int) MessageId.WindowResize, (int) MessageId.UpdateLocale,
                (int) MessageId.Input };

            app.MessageManager += this;
        }
        private void CreateEscapeWindow()
        {
            EscapeWindow = new WindowControl(MainCanvas.GetCanvas());
            EscapeWindow.SetPosition(10, 10);
            EscapeWindow.SetSize(200, 200);

            Button Close = new Button(EscapeWindow);
            Close.SetPosition(10, 10);
            Close.SetText("Continue");
            Close.Clicked += delegate(Base sender, ClickedEventArgs args) {
                EscapeWindow.Hide();
                Game.LockMouse = true;
            };

            Button Quit = new Button(EscapeWindow);
            Quit.SetPosition(10, 40);
            Quit.SetText("Quit");
            Quit.Clicked += delegate(Base sender, ClickedEventArgs args) {
                MainCanvas.Dispose();
                Environment.Exit(0);
            };
        }
示例#5
0
        public SettingsMenu (Application app, Base parent, CompositorColorCorrectionNode colorCorrectionNode)
        {
            this.application = app;
            this.parent = parent;
            this.colorCorrectionNode = colorCorrectionNode;
            window = new WindowControl (parent);
            window.DisableResizing();
            window.Title = Localizer.Instance.GetValueForName("settings");
            window.Hide();

            float gamma = (float) ConfigManager.Instance["freezing_archer"].GetDouble("general", "gamma");
            colorCorrectionNode.Gamma = gamma;
            string language = ConfigManager.Instance["freezing_archer"].GetString("general", "language");
            Localizer.Instance.CurrentLocale = (LocaleEnum) Enum.Parse(typeof (LocaleEnum), language);

            languageLabel = new Label (window);
            languageLabel.AutoSizeToContents = true;
            languageLabel.Y = 10;
            languageLabel.Text = Localizer.Instance.GetValueForName("language");

            languageDropdown = new ComboBox (window);
            languageDropdown.Width = CONTROL_WIDTH;
            languageDropdown.Y = 10;
            foreach (var lang in Localizer.Instance.Locales)
            {
                var item = languageDropdown.AddItem(Localizer.Instance.GetValueForName(lang.Key.ToString()), lang.Key.ToString());
                item.AutoSizeToContents = false;
                item.Width = CONTROL_WIDTH;
            }
            languageDropdown.SelectByText(Localizer.Instance.GetValueForName(Localizer.Instance.CurrentLocale.ToString()));
            languageDropdown.ItemSelected += handleSelect;

            gammaSlider = new HorizontalSlider (window);
            gammaSlider.SnapToNotches = false;
            gammaSlider.Min = 0;
            gammaSlider.Max = 3;
            gammaSlider.Value = gamma;
            gammaSlider.ValueChanged += (sender, arguments) => {
                var slider = sender as HorizontalSlider;
                ConfigManager.Instance["freezing_archer"].SetDouble("general", "gamma", slider.Value);
                if (slider != null)
                    this.colorCorrectionNode.Gamma = slider.Value;
            };
            gammaSlider.Width = CONTROL_WIDTH;
            gammaSlider.Height = 20;
            gammaSlider.Y = 10 + languageDropdown.Y + languageDropdown.Height;

            gammaLabel = new Label (window);
            gammaLabel.AutoSizeToContents = true;
            gammaLabel.Y = 10 + languageLabel.Y + languageLabel.Height;
            gammaLabel.Text = Localizer.Instance.GetValueForName("gamma");

            int max_width = languageLabel.Width > gammaLabel.Width ? languageLabel.Width : gammaLabel.Width;

            languageLabel.X = 10 + max_width - languageLabel.Width;
            gammaLabel.X = 10 + max_width - gammaLabel.Width;
            languageDropdown.X = 10 + max_width + 5;
            gammaSlider.X = 10 + max_width + 5;

            window.Width = 40 + max_width + CONTROL_WIDTH;

            resetButton = new Button (window);
            resetButton.Text = Localizer.Instance.GetValueForName("reset");
            resetButton.Width = (window.Width / 2) - 20;
            resetButton.X = 10;
            resetButton.Y = gammaSlider.Y + gammaSlider.Height + 10;
            resetButton.Clicked += (sender, arguments) => {
                var general = ConfigManager.DefaultConfig.B.FirstOrDefault (a => a.Key == "general");
                var gamma_pair = general.Value.FirstOrDefault(a => a.Key == "gamma");
                
                float _gamma = (float) gamma_pair.Value.Double;
                gammaSlider.Value = _gamma;
                colorCorrectionNode.Gamma = _gamma;

                var language_pair = general.Value.FirstOrDefault(a => a.Key == "language");

                string lang = language_pair.Value.String;
                Localizer.Instance.CurrentLocale = (LocaleEnum) Enum.Parse(typeof (LocaleEnum), lang);
            };

            saveButton = new Button (window);
            saveButton.Text = Localizer.Instance.GetValueForName("save");
            saveButton.Width = (window.Width / 2) - 20;
            saveButton.X = resetButton.X + resetButton.Width + 10;
            saveButton.Y = gammaSlider.Y + gammaSlider.Height + 10;
            saveButton.Clicked += (sender, arguments) => ConfigManager.Instance.SaveAll();

            window.Height += languageDropdown.Height + gammaSlider.Height + 50;
            window.X = (parent.Width - window.Width) / 2;
            window.Y = (parent.Height - window.Height) / 2;

            ValidMessages = new[] { (int) MessageId.UpdateLocale };
            application.MessageManager += this;
        }
示例#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);
            });
        }