private string currentColor = "undefined"; //цвет, которым будет рисовать кисть при нажатии мышки public static BrushManager instance() { if (Instance == null) { Instance = new BrushManager(); } return(Instance); }
static public void Main(string[] args) { // //Font font = new Font("C:/Users/Пользователь/source/repos/SandySharp/SandySharp/EightBitDragon-anqx.ttf"); //WINDOW window = new RenderWindow(new SFML.Window.VideoMode(640, 480), "SandySharp"); window.SetVerticalSyncEnabled(true); window.Closed += Window_Closed; window.SetFramerateLimit(60); SceneManager.instance().start(window); SceneCreator.instance().start(window); //////////SCENE CREATION////////////// //.instance().loadScene1(); SceneManager.instance().loadScene(SceneCreator.instance().createScene()); Stopwatch stopwatch = new Stopwatch(); ////////////////////////////////////// while (window.IsOpen) { stopwatch.Restart(); //SYSTEMS UPDATES SceneManager.instance().GlobalUpdate(); TimeManager.instance().update(); ViewSystem.Instance.update(); BrushManager.instance().update(); stopwatch.Stop(); UI_SYSTEM.instance().update(stopwatch.ElapsedMilliseconds); //передаем gui данные для обновления window.DispatchEvents(); window.Clear(SFML.Graphics.Color.Black); //DrawHere SceneManager.instance().DrawScene(); UI_SYSTEM.instance().Draw(); window.Display(); } }
public void loadScene(Scene scene) { scene.initialisation(); SceneManager.instance().setCurrentScene(scene); TimeManager.instance().start(); ViewSystem.instance().start(scene.getLayers()[0].getSpriteToDraw()); BrushManager.instance().start(scene.getLayers()[0].picture.image); foreach (var key in scene.colors.Keys) { BrushManager.instance().AddColor(scene.colors[key], key); } UI_SYSTEM.instance().start(); }
public void loadScene1() { //COLORS Color sand1 = new Color(252, 235, 145); Color emptyP = new Color(0, 0, 0); Color waterP = new Color(101, 175, 182, 150); Color lightning = new Color(108, 233, 236); Color fire = new Color(191, 106, 2); byte fireoffset = 42; Color fireActive = new Color(191, 148, 2); Color wood = new Color(53, 33, 21); byte woodoffset = 29; //MAIN__FIELD //Image image = new Image("C:/Users/Пользователь/Desktop/SandySharp/SandySharp/FirstScene.png"); Image image = new Image(160, 120, Color.Transparent); Image flame_field = new Image(160, 120, Color.Transparent); Image fire_field = new Image(160, 120, Color.Transparent); image = Pixy.drawBorder(image); RenderObject picture = new RenderObject(image); RenderObject flame_picture = new RenderObject(flame_field); RenderObject fire_picture = new RenderObject(fire_field); //starts //SCENES AND LAYERS Scene scene = new Scene(window); Layer main_layer = new Layer(1, "main"); Layer Fire_layer = new Layer(2, "fire_layer"); Layer flame_layer = new Layer(3, "flame_layer"); //SIMULATIONS SandSimulation sandSim = new SandSimulation(sand1, image, "sand_sim"); LiquidSimulation liqSim = new LiquidSimulation(waterP, image, "liquid_sim"); FireSimulation fireSim = new FireSimulation(fire, fireoffset, wood, woodoffset, fire_field, image, waterP, "fire_sim"); FlameSimulation flameSim = new FlameSimulation(fire, fireSim.getActiveFire(), fire_field, flame_field, "flame_sim"); LightningSimulation lightningSim = new LightningSimulation(lightning, fireSim.getActiveFire(), fire_field, image, "lightning_sim"); RainSimulation rainSim = new RainSimulation(waterP, lightning, image, fire_field, 0.1f, 0.08f, "rain_sim"); scene.AddLayer(main_layer); scene.AddLayer(Fire_layer); scene.AddLayer(flame_layer); scene.AddObject(fireSim); scene.AddObject(flameSim); scene.AddObject(liqSim); scene.AddObject(sandSim); //scene.AddObject(lightningSim); //scene.AddObject(rainSim); main_layer.setLayerRenderObject(picture); Fire_layer.setLayerRenderObject(fire_picture); flame_layer.setLayerRenderObject(flame_picture); scene.initialisation(); //SYSTEMS INICIALIZATION SceneManager.instance().setCurrentScene(scene); TimeManager.instance().start(); ViewSystem.instance().start(picture.sprite); BrushManager.instance().start(image); BrushManager.instance().AddColor(waterP, "water"); BrushManager.instance().AddColor(fireSim.getActiveFire(), "fire"); BrushManager.instance().AddColor(sand1, "sand"); BrushManager.instance().AddColor(wood, "wood"); UI_SYSTEM.instance().start(); //testPHYSICS }
public void start() { if (gui != null) { gui.RemoveAllWidgets(); } gui = new Gui(SceneManager.instance().window); font = new Font("EightBitDragon-anqx.ttf"); gui.Font = font; //Создание главной панели MainPanel = new Panel(); Layout2d layout2D = new Layout2d("20%", "100%"); MainPanel.SizeLayout = layout2D; MainPanel.Renderer.BackgroundColor = Color.Black; MainPanel.Renderer.BorderColor = Color.White; MainPanel.Renderer.Borders = new Outline(5); gui.Add(MainPanel); font = new Font("EightBitDragon-anqx.ttf"); //Создание панели с кистями. BrushesPanel = new ScrollablePanel(); BrushesPanel.ScrollbarWidth = 8; BrushesPanel.Renderer.BackgroundColor = Color.Black; BrushesPanel.Renderer.BorderColor = Color.White; BrushesPanel.PositionLayout = new Layout2d("0%", "5%"); BrushesPanel.SizeLayout = new Layout2d("100%", "25%"); MainPanel.Add(BrushesPanel); //Кисти. RadioButtonGroup brushes = new RadioButtonGroup(); Dictionary <string, Color> tempColors = BrushManager.instance().getColors(); //получаем список цветов от менеджера кистей int positionOffset = 0; //определяет смещение для кнопки foreach (var colorKey in tempColors.Keys) { positionOffset += 15; RadioButton colorBrush_Btn = new RadioButton(colorKey); //создаем кнопку с именем colorBrush_Btn.Renderer.TextColor = Color.White; colorBrush_Btn.Renderer.TextColorHover = Color.Blue; colorBrush_Btn.PositionLayout = new Layout2d("0%", positionOffset + "%"); //производим смещение colorBrush_Btn.Toggled += (e, a) => { if (colorBrush_Btn.Checked) { BrushManager.instance().changeCurrentColor(colorKey); } }; //привязываем к кнопке метод изменяющий текущий цвет у менеджера кистей BrushesPanel.Add(colorBrush_Btn); //добавляем кнопку на панель } BrushesPanel.Add(brushes); //список слоев ListBox LayerList = new ListBox(); LayerList.Renderer.TextColor = Color.White; layers = new Dictionary <string, Image>(); Layer[] tempLayerList = SceneManager.instance().currentScene.getLayers(); foreach (var lay in tempLayerList) { //добавляем слои в словарь. При выборе значения в списке - значение будет передано словарю в качестве ключа и будет получение изображение, которое будет передано менеджеру кисти //таким образом рисование будет происходить на выбранном пользователем слое layers.Add(lay.name, lay.picture.image); LayerList.AddItem(lay.name, lay.name); } LayerList.ItemSelected += (e, a) => { BrushManager.instance().changeCurrentImage(layers[LayerList.GetSelectedItemId()]); }; LayerList.Renderer.BackgroundColor = Color.Transparent; LayerPanel = new Panel(); LayerPanel.Renderer.BackgroundColor = Color.Black; LayerPanel.Renderer.BorderColor = Color.White; LayerPanel.PositionLayout = new Layout2d("0%", "30%"); LayerPanel.SizeLayout = new Layout2d("100%", "30%"); LayerPanel.Renderer.Borders = new Outline(0, 5, 0, 0); LayerPanel.Add(LayerList); MainPanel.Add(LayerPanel); //Данные производительности performancePanel = new Panel(); performancePanel.Renderer.BackgroundColor = Color.Black; performancePanel.Renderer.BorderColor = Color.White; performancePanel.Renderer.Borders = new Outline(0, 5, 0, 5); performancePanel.PositionLayout = new Layout2d("0%", "50%"); performancePanel.SizeLayout = new Layout2d("100%", "10%"); frameDelay = new TextBox(); frameDelay.Renderer.BackgroundColor = Color.Transparent; frameDelay.Renderer.TextColor = Color.White; performancePanel.Add(frameDelay); MainPanel.Add(performancePanel); //Контроль симуляций (включение/выключение) objectsControlPanel = new ScrollablePanel(); objectsControlPanel.ScrollbarWidth = 8; GameObject[] Scene_objects = SceneManager.instance().GetGameObjects(); positionOffset = 0; foreach (var obj in Scene_objects) { CheckBox gameObjectSwitcher = new CheckBox(); gameObjectSwitcher.Checked = true; gameObjectSwitcher.Text = obj.name; gameObjectSwitcher.Toggled += (e, a) => { obj.toggleActive(); }; gameObjectSwitcher.PositionLayout = new Layout2d("0%", positionOffset + "%"); gameObjectSwitcher.Renderer.TextColor = Color.White; gameObjectSwitcher.Renderer.TextColorHover = Color.Green; gameObjectSwitcher.Renderer.Font = font; positionOffset += 13; objectsControlPanel.Add(gameObjectSwitcher); } objectsControlPanel.Renderer.BackgroundColor = Color.Black; objectsControlPanel.Renderer.BorderColor = Color.White; objectsControlPanel.Renderer.Borders = new Outline(0, 5, 0, 5); objectsControlPanel.PositionLayout = new Layout2d("0%", "60%"); objectsControlPanel.SizeLayout = new Layout2d("100%", "30%"); MainPanel.Add(objectsControlPanel); }