Example #1
0
        protected override void Initialize()
        {
            base.Initialize();

            IsMouseVisible = true;

            input = new Input();

            //initialize GUI
            gui = new GUIContainer(new Rectangle(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT));

            //structure editor
            structureEditPanel = new StructureEditPanel(new Rectangle(0, FILE_BAR_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT - FILE_BAR_HEIGHT - EDIT_BAR_HEIGHT), this);
            gui.Add(structureEditPanel);

            //top bar (new, load, save)
            Panel fileBar = new Panel(new Rectangle(0, 0, SCREEN_WIDTH, FILE_BAR_HEIGHT));

            gui.Add(fileBar);

            Button newButton = new Button(new Rectangle(0, 0, FILE_BUTTON_WIDTH, FILE_BAR_HEIGHT), "New", New, fileBar);

            gui.Add(newButton);

            Button openButton = new Button(new Rectangle(FILE_BUTTON_WIDTH, 0, FILE_BUTTON_WIDTH, FILE_BAR_HEIGHT), "Open", Open, fileBar);

            gui.Add(openButton);

            Button saveButton = new Button(new Rectangle(2 * FILE_BUTTON_WIDTH, 0, FILE_BUTTON_WIDTH, FILE_BAR_HEIGHT), "Save", Save, fileBar);

            gui.Add(saveButton);

            //bottom bar (block palette, anchors, properties)
            ScrollPanel palette = new ScrollPanel(new Rectangle(0, SCREEN_HEIGHT - EDIT_BAR_HEIGHT, PALETTE_WIDTH, EDIT_BAR_HEIGHT), "Blocks");

            gui.Add(palette);
            AddBlocks(palette);

            ScrollPanel anchors = new ScrollPanel(new Rectangle(PALETTE_WIDTH, SCREEN_HEIGHT - EDIT_BAR_HEIGHT, ANCHOR_WIDTH, EDIT_BAR_HEIGHT), "Anchors");

            gui.Add(anchors);
            //TODO: add stuff to anchors

            ContainerPanel propertiesPanel = new ContainerPanel(new Rectangle(PALETTE_WIDTH + ANCHOR_WIDTH, SCREEN_HEIGHT - EDIT_BAR_HEIGHT, PROPERTIES_WIDTH, EDIT_BAR_HEIGHT), "Properties");

            gui.Add(propertiesPanel);
            //TODO: add stuff to properties
            nameTextBox = new TextBox(new Rectangle(PALETTE_WIDTH + ANCHOR_WIDTH, SCREEN_HEIGHT - EDIT_BAR_HEIGHT, PROPERTIES_WIDTH, TEXT_BOX_HEIGHT), propertiesPanel);
            //freqTextBox
            //minPerChunkTextBox
            //maxPerChunkTextBox

            //TODO: draw current layer button (foreground/background)
        }
Example #2
0
        private void ConfirmUnsavedChanges(Action action)
        {
            if (unsavedChanges)
            {
                Action yes = () =>
                {
                    Save();
                    action();
                };
                Action no = () =>
                {
                    action();
                };

                ConfirmationPopup popup = new ConfirmationPopup(new Rectangle(SCREEN_WIDTH / 2 - ConfirmationPopup.TOTAL_WIDTH / 2, 100, ConfirmationPopup.TOTAL_WIDTH, ConfirmationPopup.TOTAL_HEIGHT),
                                                                gui, "Save unsaved changes?", yes, no);
                gui.Add(popup);
            }
            else
            {
                action();
            }
        }