Ejemplo n.º 1
0
        public void Initialize(ContentManager contentManager, GraphicsDevice graphicsDevice)
        {
            if (!isInitialized) {
                Resources.Initialize(contentManager, graphicsDevice);
                GameData.Initialize();
                EditorResources.Initialize();

                this.inventory		= new Inventory(null);
                this.rewardManager	= new RewardManager(null);
                this.timer			= Stopwatch.StartNew();
                this.ticks			= 0;
                this.roomSpacing	= 1;
                this.playAnimations = false;
                this.tileset		= GameData.TILESET_CLIFFS;
                this.zone			= GameData.ZONE_PRESENT;
                this.selectedTilesetTileData = this.tileset.GetTileData(0, 0);
                this.eventMode		= false;

                GameData.LoadInventory(inventory);
                GameData.LoadRewards(rewardManager);

                // Create tileset combo box.
                editorForm.ComboBoxTilesets.Items.Clear();
                foreach (KeyValuePair<string, Tileset> entry in Resources.GetResourceDictionary<Tileset>()) {
                    editorForm.ComboBoxTilesets.Items.Add(entry.Key);
                }
                foreach (KeyValuePair<string, EventTileset> entry in Resources.GetResourceDictionary<EventTileset>()) {
                    editorForm.ComboBoxTilesets.Items.Add(entry.Key);
                }
                editorForm.ComboBoxTilesets.SelectedIndex = 0;

                // Create zone combo box.
                editorForm.ComboBoxZones.Items.Clear();
                foreach (KeyValuePair<string, Zone> entry in Resources.GetResourceDictionary<Zone>()) {
                    if (tileset.SpriteSheet.Image.HasVariant(entry.Key))
                        editorForm.ComboBoxZones.Items.Add(entry.Key);
                }
                editorForm.ComboBoxZones.SelectedIndex = 0;

                // Create tools.
                tools = new List<EditorTool>();
                AddTool(toolPointer		= new ToolPointer());
                AddTool(toolPlace		= new ToolPlace());
                AddTool(toolSquare		= new ToolSquare());
                AddTool(toolFill		= new ToolFill());
                AddTool(toolSelection	= new ToolSelection());
                AddTool(toolEyedrop		= new ToolEyedrop());
                currentToolIndex = 0;
                tools[currentToolIndex].OnBegin();

                this.isInitialized = true;

                Application.Idle += delegate {
                    Update();
                };
            }
        }
Ejemplo n.º 2
0
        //-----------------------------------------------------------------------------
        // Constructors
        //-----------------------------------------------------------------------------
        public EditorControl(EditorForm editorForm)
        {
            this.editorForm		= editorForm;

            //this.propertyGridControl	= null;
            this.worldFilePath	= String.Empty;
            this.worldFileName	= "untitled";
            this.world			= null;
            this.level			= null;
            this.tileset		= null;
            this.zone			= null;
            this.rewardManager	= null;
            this.inventory		= null;
            this.timer			= null;
            this.ticks			= 0;
            this.roomSpacing	= 1;
            this.playAnimations	= false;
            this.isInitialized	= false;
            this.hasMadeChanges	= false;
            this.needsRecompiling	= false;
            this.compileTask		= null;
            this.compileCallback	= null;

            this.currentLayer				= 0;
            this.currentToolIndex			= 0;
            this.aboveTileDrawMode			= TileDrawModes.Fade;
            this.belowTileDrawMode			= TileDrawModes.Fade;
            this.showRewards				= true;
            this.showGrid					= false;
            this.showEvents					= false;
            this.highlightMouseTile			= true;
            this.selectedRoom				= -Point2I.One;
            this.selectedTilesetTile		= Point2I.Zero;
            this.selectedTilesetTileData	= null;
            this.playerPlaceMode			= false;
        }
Ejemplo n.º 3
0
        public void ChangeTileset(string name)
        {
            if (Resources.ExistsResource<Tileset>(name))
                tileset = Resources.GetResource<Tileset>(name);
            else if (Resources.ExistsResource<EventTileset>(name))
                tileset = Resources.GetResource<EventTileset>(name);

            if (tileset.SpriteSheet != null) {
                // Determine which zone to begin using for this tileset.
                int index = 0;
                if (!tileset.SpriteSheet.Image.HasVariant(zone.ID)) {
                    zone = Resources.GetResource<Zone>(tileset.SpriteSheet.Image.VariantName);
                    if (zone == null)
                        zone = GameData.ZONE_DEFAULT;
                }

                // Setup zone combo box for the new tileset.
                editorForm.ComboBoxZones.Items.Clear();
                foreach (KeyValuePair<string, Zone> entry in Resources.GetResourceDictionary<Zone>()) {
                    if (tileset.SpriteSheet.Image.HasVariant(entry.Key)) {
                        editorForm.ComboBoxZones.Items.Add(entry.Key);
                        if (entry.Key == zone.ID)
                            editorForm.ComboBoxZones.SelectedIndex = index;
                        index++;
                    }
                }
            }

            editorForm.TileDisplay.UpdateTileset();
            editorForm.TileDisplay.UpdateZone();
        }