예제 #1
0
        //Creates a new game world and allows editing
        private void mi_New_World_Click(object sender, EventArgs e)
        {
            //Get the background name from the user
            StringPromptDialog dialog = new StringPromptDialog("Enter background/music", "background");

            //Create the world.
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                world = new ScrollingWorld(dialog.UserInput);
                Size pbLevelSize = new Size(world.Background.Width, world.Background.Height);
                pb_Level.MaximumSize = (pb_Level.MinimumSize = (pb_Level.Size = pbLevelSize));

                enableEditing(true);

                switchRooms();
            }
        }
예제 #2
0
        private void load_file(bool loadWorld, string filter, string title)
        {
            //First, choose the file we want to load.
            OpenFileDialog dialog = new OpenFileDialog();
            dialog.Filter = filter;
            string currdir = GameEngine.GetCurrDir() + "\\Levels";
            //Console.WriteLine("Current Directory " + currdir);
            dialog.InitialDirectory = currdir; //".";
            dialog.Title = title;

            DialogResult result = dialog.ShowDialog();

            //If the result was ok, load the resultant file, otherwise, just return.
            if (result == DialogResult.OK)
            {
                if (loadWorld)
                {
                    //world = Serializer.OLDDeSerialize(dialog.FileName); // HACK so we can convert the old levels into the new format
                    world = new ScrollingWorld(dialog.FileName, true);
                    world.Background = GameEngine.TextureList[world.backgroundName];
                    switchRooms();
                }
                Size pbLevelSize = new Size(world.Background.Width, world.Background.Height);
                pb_Level.MaximumSize = (pb_Level.MinimumSize = (pb_Level.Size = pbLevelSize));
                    /*
                else
                {
                    currentlySelectedRoom = Serializer.DeserializeRoom(dialog.FileName);
                    switchRooms(currentlySelectedRoom);
                }
                */

                currentFileName = dialog.FileName;

                enableEditing(loadWorld);

                Texture2D backgroundTexture = GameEngine.TextureList[world.backgroundName];

                pb_Level.Width = backgroundTexture.Width;
                pb_Level.Height = backgroundTexture.Height;
                pb_Level.Refresh();
            }
        }