Beispiel #1
0
        //Initializes the world data given its initial state
        public void initWorldData(string filePath = "", int width = 0, int height = 0, string behavior = null, List <ActorData> actors = null)
        {
            this.worldName        = ResourceComponent.getKeyFromPath(filePath);
            this.filePath         = ResourceComponent.getFullPathFromKey(filePath);
            this.worldBehaviorKey = behavior;
            this.worldTileData    = new TileData[1, width, height];
            this.worldActorData   = actors;

            if (this.worldActorData == null)
            {
                this.worldActorData = new List <ActorData>();
            }
            if (this.worldBehaviorKey == null)
            {
                this.worldBehaviorKey = "";
            }

            //Construct tiles
            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    worldTileData[0, x, y] = new TileData("");
                }
            }
        }
Beispiel #2
0
        public GUIComponent(GraphicsComponent theGraphics) : base(theGraphics.tileEngine)
        {
            this.graphics  = theGraphics;
            this.resources = tileEngine.resourceComponent;

            staticBindings = new InputBinding[Enum.GetValues(typeof(StaticBindings)).Length];
        }
        private void setTileBehavior()
        {
            string       openFile = "";
            DialogResult res;

            try
            {
                res = openDlg.ShowDialog();

                if (res == DialogResult.OK)
                {
                    openFile = openDlg.FileName;
                }
            }
            catch (Exception e) { }

            if (!openFile.Equals(""))
            {
                string key = ResourceComponent.getKeyFromPath(openFile);
                editor.currentValues.behavior = key;
                editor.currentTile.behavior   = key;
                if (!behaviorOverwriteBox.isDown)
                {
                    behaviorOverwriteBox.toggle();
                }
            }
        }
Beispiel #4
0
 public void load(ResourceComponent rc, string path)
 {
     if ((handle = SdlMixer.Mix_LoadMUS(path)) == IntPtr.Zero)
     {
         throw new Exception("Could not load music file '" + path + "'");
     }
 }
Beispiel #5
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);
        }
Beispiel #6
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();
        }
Beispiel #7
0
        public void load(ResourceComponent rc, string path)
        {
            handle = SdlMixer.Mix_LoadWAV(path);

            if (handle == IntPtr.Zero)
            {
                throw new Exception("Could not load sound file '" + path + "'");
            }
        }
Beispiel #8
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);
        }
Beispiel #9
0
        public void load(ResourceComponent rc, string path)
        {
            this.path = path;

            // Initialize font handle dictionary
            handles = new Dictionary <int, IntPtr>();

            // Attempt to parse the font with the initial font size (to immediately detect if the font is invalid)
            getFontHandle(12);
        }
Beispiel #10
0
 public Graven()
 {
     // NOTE: This defines the order of the game loop as well
     resourceComponent = new ResourceComponent(this.Content, this); //new GameResources(this.Content, this);
     inputComponent    = new GameInput(this);
     //Some of our current physics should probably be in Game Physics
     physicsComponent  = new PhysicsComponent(this); //new GamePhysics(this);
     graphicsComponent = new GameGraphics(this);
     audioComponent    = new GameAudio(this);        //new GameAudio(this);
 }
        /**
         * Constructor. Constructs all engine components.
         */
        public MirrorEngine(string gameTitle = "Mirror Engine")
        {
            resourceComponent = new ResourceComponent(this);
            inputComponent    = new InputComponent(this);
            physicsComponent  = new PhysicsComponent(this);
            graphicsComponent = new GraphicsComponent(this);
            audioComponent    = new AudioComponent(this);
            editorComponent   = new EditorComponent(this);

            this.gameTitle = gameTitle;
        }
        public void load(ResourceComponent rc, string path)
        {
            IntPtr surf = SdlImage.IMG_Load(path);

            if (surf == IntPtr.Zero)
            {
                throw new Exception("Error: failed to load resource at " + path + ": " + Sdl.SDL_GetError());
            }

            initFromSurface(surf);
        }
        protected virtual void drawText()
        {
            ResourceComponent rc = gui.graphics.engine.resourceComponent;

            // Draw text
            if (text != null && text.Length != 0 && font != null)
            {
                Vector2 adjPos = pos + textOffset;
                gui.graphics.drawTex(textTex, (int)adjPos.x, (int)adjPos.y, textTex.width, textTex.height, textColor);
            }
        }
Beispiel #14
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;
        }
        internal ILoadable resource;   //Resource that this handle represents

        /* Handle constructor
         *
         * Initialize the handle. Sets up the internal data, but does not actually perform loading from disk.
         *
         * @param rc The engine resource component object
         * @param s The relative path to the resource (see key above)
         *
         */
        public Handle(ResourceComponent rc, string s)
        {
            this.rc = rc;
            //In order to load the resource from disk, we need the full path to it.
            this.fullPath = ResourceComponent.getFullPathFromKey(s);
            if (s.Length < 1)
            {
                key = "";
                return;
            }
            //Makes sure the key is well-formed to be a handle-key
            this.key = ResourceComponent.getKeyFromPath(s);
        }
        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);
        }
Beispiel #17
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 = "";
        }
Beispiel #19
0
        //Prepare the world object so that it can work with other components to prepare for initialization.
        //World is passed the Engine object and the filename of a saved map.
        public World(MirrorEngine theEngine, string fileName) : base(theEngine)
        {
            //Load the map from the filename passed to it.
            worldName = Path.GetFileNameWithoutExtension(fileName);
            FileStream fileStream = new FileStream(fileName, FileMode.Open);

            this.file = new MapFile(fileStream);

            //Make sure there are resources. If the world has no resources, something has gone wrong and it should exit.
            ResourceComponent res = theEngine.resourceComponent;

            if (res == null)
            {
                throw new Exception("World: Error retrieving TileSet: ResourceComponent not initialized");
            }
        }
        /**
         * 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);
        }
        public delegate void Action(int frame); //Delegate for an action

        /**
         * Constructor. Loads the frame handles
         */
        public Animation(ResourceComponent rc, string animDir, int xoffset = 0, int yoffset = 0, float ticksPerFrame = 6, bool loop = true, int delay = 0)
        {
            if (animDir.Equals(""))
            {
                throw new Exception("Animation directory not provided.");
            }

            this.animDir       = animDir;
            this.xoffset       = xoffset;
            this.yoffset       = yoffset;
            this.ticksPerFrame = ticksPerFrame;
            this.loop          = loop;
            this.delay         = delay;

            frames = rc.discoverHandles(animDir).ToArray();
            AnimationList.Add(frames);
        }
Beispiel #22
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);
        }
        /*  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;
        }
        /**
         * Sets the currently running world
         *
         * @param filePath the map-key to load
         * @param mapFile the mapFile to load, overrides the filePath
         */
        public virtual void setWorld(string filePath, Mapfile mapFile = null)
        {
            string worldName = ResourceComponent.getKeyFromPath(filePath);

            if (worldName != currentWorldName)
            {
                resourceComponent.discardScriptStates();
            }

            if (!resourceComponent.loadWorld(filePath, mapFile))
            {
                return;
            }
            world = resourceComponent.getWorld(worldName);

            world.firstUpdate = true;
            currentWorldName  = worldName;
        }
        void discoverThumbnails()
        {
            String            directory = "Tiles/Tiles";
            ResourceComponent rc        = editor.engine.resourceComponent;
            List <Handle>     tempSet   = rc.discoverHandles(directory);

            //Null Tile
            GUIButton nullTile = new GUIButton(editor.editorGui, null, null, text: "nul");

            nullTile.size            = new Vector2(Tile.size, Tile.size);
            nullTile.mouseDownEvent += (pos, button) =>
            {
                editor.currentValues.texture = "";
                if (!textureOverwriteBox.isDown)
                {
                    textureOverwriteBox.toggle();
                }
                editor.currentTile.texture = editor.currentValues.texture;
            };
            thumbs.add(nullTile);

            //Dynamic tile discovery
            if (tempSet == null)
            {
                return;
            }
            for (int i = 0; i < tempSet.Count; i++)
            {
                GUIButton temp = new GUIButton(editor.editorGui, tempSet[i], tempSet[i], "");
                temp.size = new Vector2(Tile.size, Tile.size);
                string texturePath = tempSet[i].key;
                temp.mouseDownEvent += (pos, button) =>
                {
                    editor.currentValues.texture = texturePath;
                    if (!textureOverwriteBox.isDown)
                    {
                        textureOverwriteBox.toggle();
                    }
                    editor.currentTile.texture = editor.currentValues.texture;
                };
                thumbs.add(temp);
            }
            thumbs.performLayout();
        }
Beispiel #26
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);
        }
        /* 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;
        }
        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";
        }
        public void load(ResourceComponent resourceComponent, string path)
        {
            rc             = resourceComponent;
            this.scriptKey = ResourceComponent.getKeyFromPath(path);

            ScriptEngine engine = rc.scriptEngine;

            try
            {
                script = engine.CreateScriptSourceFromFile(path).Compile();
            }
            catch (SyntaxErrorException e)
            {
                ExceptionOperations eo;
                eo = engine.GetService <ExceptionOperations>();
                string error = eo.FormatException(e);

                throw new Exception("\nPython syntax error:\n" + error);
            }
        }
        /**
         * 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);
        }