Ejemplo n.º 1
0
        void createDialog()
        {
            ResourceComponent rc = editor.engine.resourceComponent;

            toolDialog = new GUIControl(editor.editorGui);

            GUILabel background = new GUILabel(editor.editorGui, editor.editorGui.leftBG, "Treequake options");

            background.size = new Vector2((editor.editorGui.graphics.width - EditorGUI.RIGHTBOUNDARY) - EditorGUI.LEFTBOUNDARY - 10, EditorGUI.BOTTOMBOUNDARY);
            toolDialog.pos  = new Vector2(toolButton.pos.x + 20, editor.editorGui.graphics.height - EditorGUI.BOTTOMBOUNDARY);
            toolDialog.add(background);

            minusButton     = new GUIButton(editor.editorGui, rc.get(Path.GetFullPath(Path.Combine(editor.editorGui.rootDirectory, "GUI/000_EngineGUI/029_minus.png"))), rc.get(Path.GetFullPath(Path.Combine(editor.editorGui.rootDirectory, "GUI/000_EngineGUI/030_minusPressed.png"))));
            minusButton.pos = new Vector2(5, 40);
            toolDialog.add(minusButton);

            defaultButton     = new GUIButton(editor.editorGui, rc.get(Path.GetFullPath(Path.Combine(editor.editorGui.rootDirectory, "GUI/000_EngineGUI/025_radio.png"))), rc.get(Path.GetFullPath(Path.Combine(editor.editorGui.rootDirectory, "GUI/000_EngineGUI/024_radio.png"))));
            defaultButton.pos = defaultButton.pos = new Vector2(20, 40);
            toolDialog.add(defaultButton);

            plusButton     = new GUIButton(editor.editorGui, rc.get(Path.GetFullPath(Path.Combine(editor.editorGui.rootDirectory, "GUI/000_EngineGUI/027_plus.png"))), rc.get(Path.GetFullPath(Path.Combine(editor.editorGui.rootDirectory, "GUI/000_EngineGUI/028_plusPressed.png"))));
            plusButton.pos = plusButton.pos = new Vector2(35, 40);
            toolDialog.add(plusButton);

            GUILabel zoomLabel = new GUILabel(editor.editorGui, text: "Enhance");

            zoomLabel.pos = new Vector2(55, 40);
            toolDialog.add(zoomLabel);

            centerButton     = new GUIButton(editor.editorGui, rc.get(Path.GetFullPath(Path.Combine(editor.editorGui.rootDirectory, "GUI/000_EngineGUI/025_radio.png"))), rc.get(Path.GetFullPath(Path.Combine(editor.editorGui.rootDirectory, "GUI/000_EngineGUI/024_radio.png"))));
            centerButton.pos = new Vector2(5, 60);
            toolDialog.add(centerButton);

            GUILabel centerLabel = new GUILabel(editor.editorGui, text: "Center");

            centerLabel.pos = new Vector2(25, 60);
            toolDialog.add(centerLabel);

            pauseCheckBox     = new GUICheckBox(editor.editorGui, editor.pauseEngine, "Pause Engine");
            pauseCheckBox.pos = new Vector2(5, 20);
            toolDialog.add(pauseCheckBox);

            gridCheckBox     = new GUICheckBox(editor.editorGui, editor.showGrid, "Show Grid");
            gridCheckBox.pos = new Vector2(105, 20);
            toolDialog.add(gridCheckBox);

            overlayCheckBox     = new GUICheckBox(editor.editorGui, editor.showOverlay, "Show Overlay");
            overlayCheckBox.pos = new Vector2(205, 20);
            toolDialog.add(overlayCheckBox);

            ambienceCheckBox     = new GUICheckBox(editor.editorGui, editor.fullAmbient, "Extra Light");
            ambienceCheckBox.pos = new Vector2(105, 40);
            toolDialog.add(ambienceCheckBox);

            closeButton      = new GUIButton(editor.editorGui, rc.get(Path.GetFullPath(Path.Combine(editor.editorGui.rootDirectory, "GUI/000_EngineGUI/000_solid.png"))), rc.get(Path.GetFullPath(Path.Combine(editor.editorGui.rootDirectory, "GUI/000_EngineGUI/000_solid.png"))));
            closeButton.pos  = new Vector2(background.size.x - 12, 4);
            closeButton.size = new Vector2(8, 8);
            toolDialog.add(closeButton);
        }
Ejemplo n.º 2
0
        public ResetTool(EditorComponent editor)
            : base(editor)
        {
            ResourceComponent rc = editor.engine.resourceComponent;

            toolButton.unpressedImg = rc.get(Path.GetFullPath(Path.Combine(editor.editorGui.rootDirectory, "GUI/000_EngineGUI/014_prince.png")));
            toolButton.pressedImg   = rc.get(Path.GetFullPath(Path.Combine(editor.editorGui.rootDirectory, "GUI/000_EngineGUI/015_prince.png")));
            editor.editorGui.addToolButton(toolButton, false);
        }
Ejemplo n.º 3
0
        public NewMapTool(EditorComponent editor) : base(editor)
        {
            ResourceComponent rc = editor.engine.resourceComponent;

            toolButton.unpressedImg = rc.get(Path.GetFullPath(Path.Combine(editor.editorGui.rootDirectory, "GUI/000_EngineGUI/033_newMap.png")));
            toolButton.pressedImg   = rc.get(Path.GetFullPath(Path.Combine(editor.editorGui.rootDirectory, "GUI/000_EngineGUI/034_newMap.png")));
            editor.editorGui.addToolButton(toolButton, false);

            createDialog();
            cancelButton.mouseClickEvent  += cancelAction;
            confirmButton.mouseClickEvent += confirmAction;
        }
        void createDialog()
        {
            ResourceComponent rc = editor.engine.resourceComponent;

            toolDialog = new GUIControl(editor.editorGui);

            GUILabel background = new GUILabel(editor.editorGui, editor.editorGui.leftBG, "World options");

            background.size = new Vector2((editor.editorGui.graphics.width - EditorGUI.RIGHTBOUNDARY) - EditorGUI.LEFTBOUNDARY - 10, EditorGUI.TOPBOUNDARY);
            toolDialog.pos  = new Vector2(toolButton.pos.x + 20, 0);
            toolDialog.add(background);

            selectBehaviorButton     = new GUIButton(editor.editorGui, rc.get(Path.GetFullPath(Path.Combine(editor.editorGui.rootDirectory, "GUI/000_EngineGUI/019_buttBack.png"))), rc.get(Path.GetFullPath(Path.Combine(editor.editorGui.rootDirectory, "GUI/000_EngineGUI/018_buttBack.png"))), "Select Behavior");
            selectBehaviorButton.pos = new Vector2(5, 20);
            toolDialog.add(selectBehaviorButton);

            removeBehaviorButton     = new GUIButton(editor.editorGui, rc.get(Path.GetFullPath(Path.Combine(editor.editorGui.rootDirectory, "GUI/000_EngineGUI/019_buttBack.png"))), rc.get(Path.GetFullPath(Path.Combine(editor.editorGui.rootDirectory, "GUI/000_EngineGUI/018_buttBack.png"))), "Remove Behavior");
            removeBehaviorButton.pos = new Vector2(105, 20);
            toolDialog.add(removeBehaviorButton);

            GUILabel widthLabel = new GUILabel(editor.editorGui, text: "Width");

            widthLabel.pos = new Vector2(4, 50);
            toolDialog.add(widthLabel);

            widthBox          = new GUITextBox(editor.editorGui, "0");
            widthBox.pos      = new Vector2(5, 70);
            widthBox.minWidth = 50;
            widthBox.onText('\b');
            toolDialog.add(widthBox);

            GUILabel heightLabel = new GUILabel(editor.editorGui, text: "Height");

            heightLabel.pos = new Vector2(60, 50);
            toolDialog.add(heightLabel);

            heightBox          = new GUITextBox(editor.editorGui, "0");
            heightBox.pos      = new Vector2(60, 70);
            heightBox.minWidth = 50;
            heightBox.onText('\b');
            toolDialog.add(heightBox);

            resizeButton     = new GUIButton(editor.editorGui, rc.get(Path.GetFullPath(Path.Combine(editor.editorGui.rootDirectory, "GUI/000_EngineGUI/019_buttBack.png"))), rc.get(Path.GetFullPath(Path.Combine(editor.editorGui.rootDirectory, "GUI/000_EngineGUI/018_buttBack.png"))), "Resize");
            resizeButton.pos = new Vector2(115, 70);
            toolDialog.add(resizeButton);

            closeButton      = new GUIButton(editor.editorGui, rc.get(Path.GetFullPath(Path.Combine(editor.editorGui.rootDirectory, "GUI/000_EngineGUI/000_solid.png"))), rc.get(Path.GetFullPath(Path.Combine(editor.editorGui.rootDirectory, "GUI/000_EngineGUI/000_solid.png"))));
            closeButton.pos  = new Vector2(background.size.x - 12, 4);
            closeButton.size = new Vector2(8, 8);
            toolDialog.add(closeButton);
        }
Ejemplo n.º 5
0
        /**
         * desc here
         *
         * @param paramsdeschere
         *
         * @return returndeschere
         */
        public FillTool(EditorComponent editor)
            : base(editor)
        {
            ResourceComponent rc = editor.engine.resourceComponent;

            toolButton.unpressedImg = rc.get(Path.GetFullPath(Path.Combine(editor.editorGui.rootDirectory, "GUI/000_EngineGUI/005_fill.png")));
            toolButton.pressedImg   = rc.get(Path.GetFullPath(Path.Combine(editor.editorGui.rootDirectory, "GUI/000_EngineGUI/006_fill_inv.png")));
            editor.editorGui.addToolButton(toolButton, true);

            createDialog();

            isDragging = false;
            fillCriteria.setToIgnore();
            fillCriteria.texture = "";

            textureCritBox.toggleEvent += (isDown) =>
            {
                if (isDown)
                {
                    fillCriteria.texture = "";
                }
                else
                {
                    fillCriteria.texture = Mapfile.TileData.IGNORESTRING;
                }
            };

            solidityCritBox.toggleEvent += (isDown) =>
            {
                if (isDown)
                {
                    fillCriteria.solidity = 0;
                }
                else
                {
                    fillCriteria.solidity = Mapfile.TileData.IGNOREBYTE;
                }
            };

            opacityCritBox.toggleEvent += (isDown) =>
            {
                if (isDown)
                {
                    fillCriteria.opacityFlip = 0;
                }
                else
                {
                    fillCriteria.opacityFlip = Mapfile.TileData.IGNOREBYTE;
                }
            };
        }
        public SaveMapTool(EditorComponent editor) : base(editor)
        {
            ResourceComponent rc = editor.engine.resourceComponent;

            toolButton.unpressedImg = rc.get(Path.GetFullPath(Path.Combine(editor.editorGui.rootDirectory, "GUI/000_EngineGUI/016_save (1).png")));
            toolButton.pressedImg   = rc.get(Path.GetFullPath(Path.Combine(editor.editorGui.rootDirectory, "GUI/000_EngineGUI/017_save (2).png")));
            editor.editorGui.addToolButton(toolButton, false);

            saveDlg = new SaveFileDialog();
            saveDlg.InitialDirectory = Path.GetFullPath(Path.Combine(ResourceComponent.DEVELOPROOTPREFIX + ResourceComponent.DEFAULTROOTDIRECTORY, "Maps"));
            saveDlg.Filter           = "Map files (*.map)|*.map";

            saveFile = "";
        }
Ejemplo n.º 7
0
        /**
         * desc here
         *
         * @param paramsdeschere
         *
         * @return returndeschere
         */
        public ActorTool(EditorComponent editor)
            : base(editor)
        {
            ResourceComponent rc = editor.engine.resourceComponent;

            toolButton.unpressedImg = rc.get(Path.GetFullPath(Path.Combine(editor.editorGui.rootDirectory, "GUI/000_EngineGUI/001_actor.png")));
            toolButton.pressedImg   = rc.get(Path.GetFullPath(Path.Combine(editor.editorGui.rootDirectory, "GUI/000_EngineGUI/002_actor.png")));
            editor.editorGui.addToolButton(toolButton, true);

            createDialog();
            discoverThumbnails();

            isDragging = false;

            floatingPic         = new GUILabel(editor.editorGui);
            floatingPic.tintTex = new Color(1f, 1f, 1f, .5f);
        }
        /**
         * desc here
         *
         * @param paramsdeschere
         *
         * @return returndeschere
         */
        public SelectionTool(EditorComponent editor)
            : base(editor)
        {
            ResourceComponent rc = editor.engine.resourceComponent;

            toolButton.unpressedImg = rc.get(Path.GetFullPath(Path.Combine(editor.editorGui.rootDirectory, "GUI/000_EngineGUI/selection.png")));
            toolButton.pressedImg   = rc.get(Path.GetFullPath(Path.Combine(editor.editorGui.rootDirectory, "GUI/000_EngineGUI/selectioninv.png")));
            editor.editorGui.addToolButton(toolButton, true);

            createDialog();

            copyButton.mouseClickEvent  += copyAction;
            pasteButton.mouseClickEvent += pasteAction;
            clearButton.mouseClickEvent += clearAction;

            selection = new RectangleF(-1, -1, 0, 0);
        }
        /*  Constructor
         *
         * @param gui The game gui
         * @param isDown The default state for this radio button
         * @param uncheckedImg A handle for the image that will be drawn if the button is unpressed (isDown = false).
         * @param checkedImg A handle for the image that will be drawn if the button is pressed (isDown = true).
         */
        public GUIRadioButton(GUI gui, bool isDown, string text, Handle uncheckedImg = null, Handle checkedImg = null)
            : base(gui, uncheckedImg, checkedImg, text)
        {
            ResourceComponent rc = gui.graphics.engine.resourceComponent;

            radioUpImage   = uncheckedImg;
            radioDownImage = checkedImg;

            //Sets default radio buttons if none are specified
            if (radioUpImage == null)
            {
                radioUpImage = rc.get(Path.GetFullPath(Path.Combine(gui.rootDirectory, RADIOUP)));
            }
            if (radioDownImage == null)
            {
                radioDownImage = rc.get(Path.GetFullPath(Path.Combine(gui.rootDirectory, RADIODOWN)));
            }

            this.isDown = isDown;
            //Will make the picture display correctly based on the default pressed state
            refresh();

            // Size the text and image
            Vector2 textSize = Vector2.Zero;
            Vector2 imgSize  = Vector2.Zero;

            if (text != null)
            {
                if (this.font == null)
                {
                    this.font = rc.get(gui.defaultFontPath);
                }
                textSize = Font.calcTextSize(font, text, fontSize);
            }
            if (texture != null)
            {
                Texture2D bgTex = texture.getResource <Texture2D>();
                imgSize = new Vector2(bgTex.width, bgTex.height);
            }

            size         = new Vector2(imgSize.x + textSize.x, Math.Max(imgSize.y, textSize.y));
            stretchImage = false;
            textOffset   = new Vector2(imgSize.x + 2, 0);
            this.pos     = Vector2.Zero;
        }
Ejemplo n.º 10
0
        void discoverThumbnails()
        {
            //Get actor sprite directories
            ResourceComponent    rc          = editor.engine.resourceComponent;
            String               contentPath = Path.Combine(ResourceComponent.rootDirectory, "Sprites");
            IEnumerable <string> actorPaths  = null;

            try
            {
                actorPaths = Directory.EnumerateDirectories(contentPath);
            }
            catch (Exception e)
            {
                return;
            }

            //Add thumbnail buttons to the ScrollingImageTable
            int i = 0;

            foreach (string s in actorPaths)
            {
                //Get thumbnail location
                String actorThumbnail;
                try{
                    actorThumbnail = Directory.GetFiles(s)[0];
                }catch (Exception e) {
                    try{
                        actorThumbnail = Directory.GetFiles(Directory.GetDirectories(s)[0])[0];
                    }catch (Exception x) {
                        continue;
                    }
                }
                actorThumbnail = actorThumbnail.Substring(ResourceComponent.rootDirectory.Length + 1);

                //Get Handle
                Handle tempH = rc.get(actorThumbnail);

                //Create Button
                GUIButton tempB = new GUIButton(editor.editorGui, tempH, tempH);
                tempB.size = new Vector2(32, 32);

                //Add click event to button
                int actorIndex = i;
                tempB.mouseClickEvent += (pos, button) =>
                {
                    if (active)
                    {
                        currentActorIndex = (byte)actorIndex;
                    }
                };

                //Add the thumbnail
                thumbs.add(tempB);
                i++;
            }
            thumbs.performLayout();
        }
        /* Constructs the checkbox.
         *
         * @param gui The gui to draw on
         * @param isDown The initial checked state for the button
         * @param text The text to display on the button
         * @param uncheckedImg The image to display when the button is unchecked.
         * @param checkedImg The image to display when the button is checked.
         */
        public GUICheckBox(GUI gui, bool isDown, string text, Handle uncheckedImg = null, Handle checkedImg = null)
            : base(gui, uncheckedImg, checkedImg, text)
        {
            ResourceComponent rc = gui.graphics.engine.resourceComponent;

            checkUpImage   = uncheckedImg;
            checkDownImage = checkedImg;

            //If no images are specified in the constructor, we'll use the default ones
            if (checkUpImage == null)
            {
                checkUpImage = rc.get(Path.GetFullPath(Path.Combine(gui.rootDirectory, CHECKUP)));
            }
            if (checkDownImage == null)
            {
                checkDownImage = rc.get(Path.GetFullPath(Path.Combine(gui.rootDirectory, CHECKDOWN)));
            }

            this.isDown = isDown;
            refresh();

            // Size the text and image
            Vector2 textSize = Vector2.Zero;
            Vector2 imgSize  = Vector2.Zero;

            if (text != null)
            {
                if (font == null)
                {
                    font = rc.get(gui.defaultFontPath);
                }
                textSize = Font.calcTextSize(font, text, fontSize);
            }
            if (texture != null)
            {
                Texture2D bgTex = texture.getResource <Texture2D>();
                imgSize = new Vector2(bgTex.width, bgTex.height);
            }

            size         = new Vector2(imgSize.x + textSize.x, Math.Max(imgSize.y, textSize.y));
            stretchImage = false;
            textOffset   = new Vector2(imgSize.x + 2, 0);
            this.pos     = Vector2.Zero;
        }
Ejemplo n.º 12
0
        void createDialog()
        {
            ResourceComponent rc = editor.engine.resourceComponent;

            toolDialog = new GUIControl(editor.editorGui);

            GUILabel background = new GUILabel(editor.editorGui, editor.editorGui.leftBG, "Create a new map");

            background.size = new Vector2(editor.editorGui.graphics.width * .40f, editor.editorGui.graphics.height * .20f);
            toolDialog.pos  = new Vector2(toolButton.pos.x + 20, toolButton.pos.y - background.size.y + 12);
            toolDialog.add(background);

            GUILabel widthPrompt = new GUILabel(editor.editorGui, text: "Width:");

            widthPrompt.pos = new Vector2(5, 20);
            toolDialog.add(widthPrompt);

            widthEntry          = new GUITextBox(editor.editorGui);
            widthEntry.minWidth = 40f;
            widthEntry.maxWidth = 40f;
            widthEntry.pos      = new Vector2(5, 40);
            widthEntry.size     = new Vector2(widthEntry.minWidth, widthEntry.size.y);
            toolDialog.add(widthEntry);

            GUILabel heightPrompt = new GUILabel(editor.editorGui, text: "Height:");

            heightPrompt.pos = new Vector2(widthEntry.maxWidth + 20, 20);
            toolDialog.add(heightPrompt);

            heightEntry          = new GUITextBox(editor.editorGui);
            heightEntry.minWidth = 40f;
            heightEntry.maxWidth = 40f;
            heightEntry.size     = new Vector2(heightEntry.minWidth, widthEntry.size.y);
            heightEntry.pos      = new Vector2(widthEntry.maxWidth + 20, 40);
            toolDialog.add(heightEntry);

            confirmButton     = new GUIButton(editor.editorGui, rc.get(Path.GetFullPath(Path.Combine(editor.editorGui.rootDirectory, "GUI/000_EngineGUI/019_buttBack.png"))), rc.get(Path.GetFullPath(Path.Combine(editor.editorGui.rootDirectory, "GUI/000_EngineGUI/018_buttBack.png"))), "OK");
            confirmButton.pos = new Vector2(5, 60);
            toolDialog.add(confirmButton);

            cancelButton     = new GUIButton(editor.editorGui, rc.get(Path.GetFullPath(Path.Combine(editor.editorGui.rootDirectory, "GUI/000_EngineGUI/019_buttBack.png"))), rc.get(Path.GetFullPath(Path.Combine(editor.editorGui.rootDirectory, "GUI/000_EngineGUI/018_buttBack.png"))), "CANCEL");
            cancelButton.pos = new Vector2(30, 60);
            toolDialog.add(cancelButton);
        }
        public WorldSettingsTool(EditorComponent editor)
            : base(editor)
        {
            ResourceComponent rc = editor.engine.resourceComponent;

            toolButton.unpressedImg = rc.get(Path.GetFullPath(Path.Combine(editor.editorGui.rootDirectory, "GUI/000_EngineGUI/021_cogs (2).png")));
            toolButton.pressedImg   = rc.get(Path.GetFullPath(Path.Combine(editor.editorGui.rootDirectory, "GUI/000_EngineGUI/020_cogs (1).png")));
            editor.editorGui.addToolButton(toolButton, true);

            createDialog();

            closeButton.mouseClickEvent          += closeAction;
            selectBehaviorButton.mouseClickEvent += selectBehaviorAction;
            removeBehaviorButton.mouseClickEvent += removeBehaviorAction;
            resizeButton.mouseClickEvent         += (pos, button) => { resize(); };

            openDlg = new OpenFileDialog();
            openDlg.InitialDirectory = Path.GetFullPath(Path.Combine(ResourceComponent.DEVELOPROOTPREFIX + ResourceComponent.DEFAULTROOTDIRECTORY, "Scripts"));
            openDlg.Filter           = "Script (*.py)|*.py";
        }
        /**
         * EraserTool constructor. Sets the images for the buttons, registers events, and initializes data
         *
         * @param editor The current EditorComponent
         */
        public EraserTool(EditorComponent editor)
            : base(editor)
        {
            ResourceComponent rc = editor.engine.resourceComponent;

            toolButton.unpressedImg = rc.get(Path.GetFullPath(Path.Combine(editor.editorGui.rootDirectory, "GUI/000_EngineGUI/009_eraser.png")));
            toolButton.pressedImg   = rc.get(Path.GetFullPath(Path.Combine(editor.editorGui.rootDirectory, "GUI/000_EngineGUI/010_eraser_inv.png")));
            editor.editorGui.addToolButton(toolButton, true);

            createDialog();
            plus.mouseClickEvent  += increaseSizeAction;
            minus.mouseClickEvent += decreaseSizeAction;

            isDragging = false;

            floatingPic         = new GUILabel(editor.editorGui, rc.get(Path.GetFullPath(Path.Combine(editor.editorGui.rootDirectory, "GUI/000_EngineGUI/026_eraserCircle.png"))));
            floatingPic.tintTex = new Color(1f, 1f, 1f, .5f);
            floatingPic.size    = new Vector2(32, 32);
            minSize             = new Vector2(16, 16);
            maxSize             = new Vector2(32 * 32, 32 * 32);
        }
Ejemplo n.º 15
0
        public EditorSettingsTool(EditorComponent editor)
            : base(editor)
        {
            ResourceComponent rc = editor.engine.resourceComponent;

            toolButton.unpressedImg = rc.get(Path.GetFullPath(Path.Combine(editor.editorGui.rootDirectory, "GUI/000_EngineGUI/021_cogs (2).png")));
            toolButton.pressedImg   = rc.get(Path.GetFullPath(Path.Combine(editor.editorGui.rootDirectory, "GUI/000_EngineGUI/020_cogs (1).png")));
            editor.editorGui.addToolButton(toolButton, false);

            createDialog();

            closeButton.mouseClickEvent += closeAction;

            pauseCheckBox.toggleEvent    += pauseToggle;
            gridCheckBox.toggleEvent     += gridToggle;
            ambienceCheckBox.toggleEvent += ambienceToggle;
            overlayCheckBox.toggleEvent  += overlayToggle;

            centerButton.mouseClickEvent  += (pos, button) => { editor.center(); };
            defaultButton.mouseClickEvent += (pos, button) => { editor.zoomMouse = EditorComponent.ZOOMDEFAULT; };
            minusButton.mouseClickEvent   += (pos, button) => { editor.zoomCenter--; };
            plusButton.mouseClickEvent    += (pos, button) => { editor.zoomCenter++; };
        }
        /*
         * Creates all of the GUI components for display
         */

        void createDialog()
        {
            ResourceComponent rc = editor.engine.resourceComponent;

            toolDialog = new GUIControl(editor.editorGui);

            //Right menu
            GUILabel background = new GUILabel(editor.editorGui, editor.editorGui.leftBG, text: "Eraser Tool");

            background.size = new Vector2(EditorGUI.RIGHTBOUNDARY, editor.engine.graphicsComponent.height - EditorGUI.BOTTOMBOUNDARY);
            toolDialog.pos  = new Vector2(editor.engine.graphicsComponent.width - EditorGUI.RIGHTBOUNDARY, 0);
            toolDialog.add(background);

            minus           = new GUIButton(editor.editorGui, rc.get(Path.GetFullPath(Path.Combine(editor.editorGui.rootDirectory, "GUI/000_EngineGUI/029_minus.png"))), rc.get(Path.GetFullPath(Path.Combine(editor.editorGui.rootDirectory, "GUI/000_EngineGUI/030_minusPressed.png"))));
            minus.textColor = new Color(0, 0, 0);
            minus.pos       = new Vector2(0, 20);
            toolDialog.add(minus);

            plus           = new GUIButton(editor.editorGui, rc.get(Path.GetFullPath(Path.Combine(editor.editorGui.rootDirectory, "GUI/000_EngineGUI/027_plus.png"))), rc.get(Path.GetFullPath(Path.Combine(editor.editorGui.rootDirectory, "GUI/000_EngineGUI/028_plusPressed.png"))));
            plus.textColor = new Color(0, 0, 0);
            plus.pos       = new Vector2(minus.size.x, 20);
            toolDialog.add(plus);
        }
Ejemplo n.º 17
0
        /**
         * desc here
         *
         * @param paramsdeschere
         *
         * @return returndeschere
         */
        public PencilTool(EditorComponent editor)
            : base(editor)
        {
            ResourceComponent rc = editor.engine.resourceComponent;

            toolButton.unpressedImg = rc.get(Path.GetFullPath(Path.Combine(editor.editorGui.rootDirectory, "GUI/000_EngineGUI/003_pencil.png")));
            toolButton.pressedImg   = rc.get(Path.GetFullPath(Path.Combine(editor.editorGui.rootDirectory, "GUI/000_EngineGUI/004_pencil_inv.png")));
            editor.editorGui.addToolButton(toolButton, true);

            openDlg = new OpenFileDialog();
            openDlg.InitialDirectory = Path.GetFullPath(Path.Combine(ResourceComponent.DEVELOPROOTPREFIX + ResourceComponent.DEFAULTROOTDIRECTORY, "Scripts"));
            openDlg.Filter           = "Script (*.py)|*.py";

            createDialog();
            discoverThumbnails();

            textureOverwriteBox.toggleEvent += (isDown) =>
            {
                if (isDown)
                {
                    editor.currentTile.texture = editor.currentValues.texture;
                }
                else
                {
                    editor.currentTile.texture = Mapfile.TileData.IGNORESTRING;
                }
            };

            solidityOverwriteBox.toggleEvent += (isDown) =>
            {
                if (isDown)
                {
                    editor.currentTile.solidity = editor.currentValues.solidity;
                }
                else
                {
                    editor.currentTile.solidity = Mapfile.TileData.IGNOREBYTE;
                }
            };

            solidityCheckBox.toggleEvent += (isDown) =>
            {
                editor.currentValues.solidity = (byte)(isDown ? 1 : 0);
                if (!solidityOverwriteBox.isDown)
                {
                    solidityOverwriteBox.toggle();
                }
                editor.currentTile.solidity = editor.currentValues.solidity;
            };

            opacityOverwriteBox.toggleEvent += (isDown) =>
            {
                if (isDown)
                {
                    editor.currentTile.opacityFlip = editor.currentValues.opacityFlip;
                }
                else
                {
                    editor.currentTile.opacityFlip = Mapfile.TileData.IGNOREBYTE;
                }
            };

            opacityFlipCheckBox.toggleEvent += (isDown) =>
            {
                editor.currentValues.opacityFlip = (byte)(isDown ? 1 : 0);
                if (!opacityOverwriteBox.isDown)
                {
                    opacityOverwriteBox.toggle();
                }
                editor.currentTile.opacityFlip = editor.currentValues.opacityFlip;
            };

            behaviorOverwriteBox.toggleEvent += (isDown) =>
            {
                if (isDown)
                {
                    editor.currentTile.behavior = editor.currentValues.behavior;
                }
                else
                {
                    editor.currentTile.behavior = Mapfile.TileData.IGNORESTRING;
                }
            };

            behaviorSetButton.mouseClickEvent    += (pos, button) => { setTileBehavior(); };
            behaviorRemoveButton.mouseClickEvent += (pos, button) =>
            {
                editor.currentValues.behavior = "";
                if (editor.currentTile.behavior != Mapfile.TileData.IGNORESTRING)
                {
                    editor.currentTile.behavior = "";
                }
            };

            addButton.mouseClickEvent += (pos, button) => { this.addNewTile(); };
        }
Ejemplo n.º 18
0
        void createDialog()
        {
            ResourceComponent rc = editor.engine.resourceComponent;

            toolDialog = new GUIControl(editor.editorGui);

            //Right menu
            GUILabel background = new GUILabel(editor.editorGui, editor.editorGui.leftBG, text: "Pencil Tool");

            background.size = new Vector2(EditorGUI.RIGHTBOUNDARY, editor.engine.graphicsComponent.height - EditorGUI.BOTTOMBOUNDARY);
            toolDialog.pos  = new Vector2(editor.engine.graphicsComponent.width - EditorGUI.RIGHTBOUNDARY, 0);
            toolDialog.add(background);

            GUILabel textureLabel = new GUILabel(editor.editorGui, text: "Texture");

            textureLabel.pos = new Vector2(0, 25);
            toolDialog.add(textureLabel);

            textureOverwriteBox     = new GUICheckBox(editor.editorGui, editor.currentTile.texture != Mapfile.TileData.IGNORESTRING, "Overwrite");
            textureOverwriteBox.pos = new Vector2(0, 40);
            toolDialog.add(textureOverwriteBox);

            int numCols = EditorGUI.RIGHTBOUNDARY / Tile.size;
            int numRows = (editor.engine.graphicsComponent.height / Tile.size) / 3;

            thumbs         = new ScrollingImageTable(editor.editorGui, numRows, numCols, Tile.size, Tile.size, ScrollingImageTable.ScrollDirection.VERTICAL, new Vector2(0, 55));
            thumbs.padding = 2;
            toolDialog.add(thumbs);

            GUILabel solidityLabel = new GUILabel(editor.editorGui, text: "Solidity");

            solidityLabel.pos = new Vector2(0, thumbs.size.y);
            toolDialog.add(solidityLabel);

            solidityOverwriteBox     = new GUICheckBox(editor.editorGui, editor.currentTile.solidity != Mapfile.TileData.IGNOREBYTE, "Overwrite");
            solidityOverwriteBox.pos = new Vector2(0, thumbs.size.y + 15);
            toolDialog.add(solidityOverwriteBox);

            solidityCheckBox     = new GUICheckBox(editor.editorGui, editor.currentValues.solidity == 1, "Is solid");
            solidityCheckBox.pos = new Vector2(0, thumbs.size.y + 30);
            toolDialog.add(solidityCheckBox);

            GUILabel opacityLabel = new GUILabel(editor.editorGui, text: "Opacity");

            opacityLabel.pos = new Vector2(0, thumbs.size.y + 50);
            toolDialog.add(opacityLabel);

            opacityOverwriteBox     = new GUICheckBox(editor.editorGui, editor.currentTile.opacityFlip != Mapfile.TileData.IGNOREBYTE, "Overwrite");
            opacityOverwriteBox.pos = new Vector2(0, thumbs.size.y + 65);
            toolDialog.add(opacityOverwriteBox);

            opacityFlipCheckBox     = new GUICheckBox(editor.editorGui, editor.currentValues.opacityFlip == 1, "Is inverted");
            opacityFlipCheckBox.pos = new Vector2(0, thumbs.size.y + 80);
            toolDialog.add(opacityFlipCheckBox);

            GUILabel behaviorLabel = new GUILabel(editor.editorGui, text: "Behavior");

            behaviorLabel.pos = new Vector2(0, thumbs.size.y + 100);
            toolDialog.add(behaviorLabel);

            behaviorOverwriteBox     = new GUICheckBox(editor.editorGui, editor.currentTile.behavior != Mapfile.TileData.IGNORESTRING, "Overwrite");
            behaviorOverwriteBox.pos = new Vector2(0, thumbs.size.y + 115);
            toolDialog.add(behaviorOverwriteBox);

            behaviorSetButton     = new GUIButton(editor.editorGui, rc.get(Path.GetFullPath(Path.Combine(editor.editorGui.rootDirectory, "GUI/000_EngineGUI/019_buttBack.png"))), rc.get(Path.GetFullPath(Path.Combine(editor.editorGui.rootDirectory, "GUI/000_EngineGUI/018_buttBack.png"))), "Set");
            behaviorSetButton.pos = new Vector2(0, thumbs.size.y + 135);
            toolDialog.add(behaviorSetButton);

            behaviorRemoveButton     = new GUIButton(editor.editorGui, rc.get(Path.GetFullPath(Path.Combine(editor.editorGui.rootDirectory, "GUI/000_EngineGUI/019_buttBack.png"))), rc.get(Path.GetFullPath(Path.Combine(editor.editorGui.rootDirectory, "GUI/000_EngineGUI/018_buttBack.png"))), "Remove");
            behaviorRemoveButton.pos = new Vector2(25, thumbs.size.y + 135);
            toolDialog.add(behaviorRemoveButton);

            addButton     = new GUIButton(editor.editorGui, rc.get(Path.GetFullPath(Path.Combine(editor.editorGui.rootDirectory, "GUI/000_EngineGUI/019_buttBack.png"))), rc.get(Path.GetFullPath(Path.Combine(editor.editorGui.rootDirectory, "GUI/000_EngineGUI/018_buttBack.png"))), "Add custom tile");
            addButton.pos = new Vector2(0, background.size.y - 25);
            toolDialog.add(addButton);
        }
        void createDialog()
        {
            toolDialog = new GUIControl(editor.editorGui);

            ResourceComponent rc = editor.engine.resourceComponent;

            //Right menu
            GUILabel background = new GUILabel(editor.editorGui, editor.editorGui.leftBG, text: "Selection Tool");

            background.size = new Vector2(EditorGUI.RIGHTBOUNDARY, editor.engine.graphicsComponent.height - EditorGUI.BOTTOMBOUNDARY);
            toolDialog.pos  = new Vector2(editor.engine.graphicsComponent.width - EditorGUI.RIGHTBOUNDARY, 0);
            toolDialog.add(background);

            GUILabel modeLabel = new GUILabel(editor.editorGui, text: "Mode:");

            modeLabel.pos = new Vector2(0, 25);
            toolDialog.add(modeLabel);

            modeControl = new GUIRadioControl(editor.editorGui);
            modeControl.addRadioButton((isdown) => { if (isdown)
                                                     {
                                                         mode = Mode.select;
                                                     }
                                       }, "Select");
            modeControl.addRadioButton((isdown) =>
            {
                if (isdown)
                {
                    //Update mode
                    if (copiedTiles == null)
                    {
                        modeControl.pressed = (int)mode;
                    }
                    else
                    {
                        mode = Mode.paste;

                        //Update selection for copying
                        isDragging  = true;
                        Vector2 pos = editor.engine.graphicsComponent.camera.world2Screen(selection.topLeft * Tile.size);
                        moveAction(pos);
                        isDragging = false;
                    }
                }
            }, "Paste");
            modeControl.pos = new Vector2(0, 45);
            toolDialog.add(modeControl);

            clearButton     = new GUIButton(editor.editorGui, rc.get(Path.GetFullPath(Path.Combine(editor.editorGui.rootDirectory, "GUI/000_EngineGUI/019_buttBack.png"))), rc.get(Path.GetFullPath(Path.Combine(editor.editorGui.rootDirectory, "GUI/000_EngineGUI/018_buttBack.png"))), "Erase");
            clearButton.pos = new Vector2(0, 105);
            toolDialog.add(clearButton);

            GUILabel selectLabel = new GUILabel(editor.editorGui, text: "Select Mode:");

            selectLabel.pos = new Vector2(0, 145);
            toolDialog.add(selectLabel);

            copyButton     = new GUIButton(editor.editorGui, rc.get(Path.GetFullPath(Path.Combine(editor.editorGui.rootDirectory, "GUI/000_EngineGUI/019_buttBack.png"))), rc.get(Path.GetFullPath(Path.Combine(editor.editorGui.rootDirectory, "GUI/000_EngineGUI/018_buttBack.png"))), "Copy");
            copyButton.pos = new Vector2(0, 165);
            toolDialog.add(copyButton);

            GUILabel pasteLabel = new GUILabel(editor.editorGui, text: "Paste Mode:");

            pasteLabel.pos = new Vector2(0, 205);
            toolDialog.add(pasteLabel);

            pasteButton     = new GUIButton(editor.editorGui, rc.get(Path.GetFullPath(Path.Combine(editor.editorGui.rootDirectory, "GUI/000_EngineGUI/019_buttBack.png"))), rc.get(Path.GetFullPath(Path.Combine(editor.editorGui.rootDirectory, "GUI/000_EngineGUI/018_buttBack.png"))), "Paste");
            pasteButton.pos = new Vector2(0, 225);
            toolDialog.add(pasteButton);
        }