コード例 #1
0
        public Scene createScene()
        {
            bool sceneCreated = false;

            //GUI
            Gui SC_gui = new Gui(window);

            mainPanel.Renderer.BackgroundColor = Color.Black;
            mainPanel.Renderer.BorderColor     = Color.White;
            mainPanel.PositionLayout           = new Layout2d("2.5%", "5%");
            mainPanel.SizeLayout       = new Layout2d("95%", "90%");
            mainPanel.Renderer.Borders = new Outline(5, 5, 5, 5);

            Button createButton = new Button("CREATE");

            createButton.Clicked       += (e, a) => { sceneCreated = true; };
            createButton.PositionLayout = new Layout2d("80%", "90%");

            mainPanel.Add(createButton);
            SC_gui.Add(mainPanel);


            //SIMULATIONS GUI
            Panel simulationsPanel = new Panel();

            simulationsPanel.Renderer.BackgroundColor = Color.Black;
            simulationsPanel.Renderer.BorderColor     = Color.White;
            simulationsPanel.PositionLayout           = new Layout2d("3%", "5%");
            simulationsPanel.SizeLayout       = new Layout2d("25%", "80%");
            simulationsPanel.Renderer.Borders = new Outline(2, 2, 2, 2);

            Panel AddedSimuationsPanel = new Panel(simulationsPanel);

            AddedSimuationsPanel.PositionLayout = new Layout2d("73%", "5%");

            //origin widgets
            originPanel.Renderer.BackgroundColor = Color.Black;
            originPanel.Renderer.BorderColor     = Color.White;
            originPanel.PositionLayout           = new Layout2d("30.5%", "5%");
            originPanel.SizeLayout       = new Layout2d("40%", "80%");
            originPanel.Renderer.Borders = new Outline(2, 2, 2, 2);

            originLabel = new Label();
            originLabel.Renderer.TextColor = Color.White;

            Label SimulationsNote = new Label("Simulations: ");

            SimulationsNote.Renderer       = originLabel.Renderer;
            SimulationsNote.PositionLayout = new Layout2d("3%", "1%");
            Label AddedSimulationsNote = new Label("Added: ");

            AddedSimulationsNote.Renderer       = originLabel.Renderer;
            AddedSimulationsNote.PositionLayout = new Layout2d("73%", "1%");

            mainPanel.Add(SimulationsNote);
            mainPanel.Add(AddedSimulationsNote);
            mainPanel.Add(simulationsPanel);
            mainPanel.Add(AddedSimuationsPanel);


            /////LAYER CREATING/////////
            image = Pixy.drawBorder(image);

            RenderObject picture       = new RenderObject(image);
            RenderObject flame_picture = new RenderObject(flame_field);
            RenderObject fire_picture  = new RenderObject(fire_field);

            Layer main_layer  = new Layer(1, "main");
            Layer Fire_layer  = new Layer(2, "fire_layer");
            Layer flame_layer = new Layer(3, "flame_layer");


            scene = new Scene(window);
            main_layer.setLayerRenderObject(picture);
            Fire_layer.setLayerRenderObject(fire_picture);
            flame_layer.setLayerRenderObject(flame_picture);
            scene.AddLayer(main_layer);
            scene.AddLayer(Fire_layer);
            scene.AddLayer(flame_layer);



            //SIMULATION CREATING PANELS
            SandSimulationPanelInit();
            LiquidSimulationPanelInit();
            FireSimulationPanelInit();
            flameSimulationPanelInit();
            lightningSimulationPanelInit();
            rainSimulationPanelInit();

            AddedSimsList            = new ListBox();
            AddedSimsList.SizeLayout = new Layout2d("100%", "100%");
            AddedSimuationsPanel.Add(AddedSimsList);
            ListBox SimulationsList = new ListBox();

            SimulationsList.AddItem("Sand Simulation", "Sand Simulation");
            SimulationsList.AddItem("Liquid Simulation", "Liquid Simulation");
            SimulationsList.AddItem("Fire Simulation", "Fire Simulation");
            SimulationsList.AddItem("Flame Simulation", "Flame Simulation");
            SimulationsList.AddItem("Lightning Simulation", "Lightning Simulation");
            SimulationsList.AddItem("Rain Simulation", "Rain Simulation");
            SimulationsList.ItemSelected += (e, a) =>
            {
                switch (SimulationsList.GetSelectedItemId())
                {
                case ("Sand Simulation"):
                    currentToolPanel.Visible = false;
                    currentToolPanel         = sandSimulationPanel;
                    currentToolPanel.Visible = true;
                    break;

                case ("Liquid Simulation"):
                    currentToolPanel.Visible = false;
                    currentToolPanel         = liquidSimulationPanel;
                    currentToolPanel.Visible = true;
                    break;

                case ("Fire Simulation"):
                    currentToolPanel.Visible = false;
                    currentToolPanel         = fireSimulationPanel;
                    currentToolPanel.Visible = true;
                    break;

                case ("Flame Simulation"):
                    currentToolPanel.Visible = false;
                    currentToolPanel         = flameSimulationPanel;
                    currentToolPanel.Visible = true;
                    break;

                case ("Lightning Simulation"):
                    currentToolPanel.Visible = false;
                    currentToolPanel         = lightningSimulationPanel;
                    currentToolPanel.Visible = true;
                    break;

                case ("Rain Simulation"):
                    currentToolPanel.Visible = false;
                    currentToolPanel         = rainSimulationPanel;
                    currentToolPanel.Visible = true;
                    break;
                }
            };
            simulationsPanel.Add(SimulationsList);

            while (window.IsOpen && !sceneCreated)
            {
                window.DispatchEvents();
                window.Clear(SFML.Graphics.Color.Black);
                //Draw here
                SC_gui.Draw();
                window.Display();
            }

            //Scene created!
            foreach (var obj in simulations)
            {
                scene.AddObject(obj);
            }
            SC_gui.RemoveAllWidgets();
            return(scene);
        }