Пример #1
0
        public EditorWorld(EditorScreen screen)
        {
            this.screen = screen;

            terrainPhys   = new TerrainPhysicsExtension();
            renderer      = MasterRenderer.Instance;
            debugRenderer = renderer.GetRenderer3D <DebugRenderer>();
        }
Пример #2
0
 public EditorTool(EditorScreen screen, WorldEditor editor,
                   EditorToolType type, Key keyBind)
 {
     Renderer = screen.Window.Renderer;
     Editor   = editor;
     UI       = screen.UI;
     Screen   = screen;
     Type     = type;
     KeyBind  = keyBind;
 }
        public TerrainEditorTool(EditorScreen screen, WorldEditor editor,
                                 EditorToolType type, Key keyBind)
            : base(screen, editor, type, keyBind)
        {
            TerrainEditor = Editor.TerrainEditor;
            entRenderer   = Renderer.GetRenderer3D <EntityRenderer>();

            if (cursorCube == null)
            {
                cursorCube = new DebugCube(Color4.White, Block.CUBE_SIZE);
            }
        }
Пример #4
0
        public WorldEditor(EditorScreen screen)
        {
            this.screen   = screen;
            TerrainEditor = new TerrainEditor(screen);
            tools         = new Dictionary <EditorToolType, EditorTool>();

            AddTool(new SelectTool(screen, this));
            AddTool(new AddTool(screen, this));
            AddTool(new RemoveTool(screen, this));
            AddTool(new PaintTool(screen, this));
            AddTool(new TerrainMoveTool(screen, this));
            AddTool(new TerraformTool(screen, this));

            SetToolType(EditorToolType.Select);
        }
        public TerrainEditor(EditorScreen screen)
        {
            this.screen = screen;
            editor      = screen.WorldEditor;
            renderer    = screen.Window.Renderer;
            terrainPhys = new TerrainPhysicsExtension();
            entRenderer = renderer.GetRenderer3D <EntityRenderer>();
            colorPicker = screen.UI.ColorWindow.ColorPicker;

            blockCursorCube = new DebugCube(Color4.White, Block.CUBE_SIZE);
            SelectionBox    = new EditorSelectionBox();

            undoStack      = new Stack <TerrainOperationBatch>();
            redoStack      = new Stack <TerrainOperationBatch>();
            operationBatch = new TerrainOperationBatch();

            rayIntersection = new TerrainRaycastResult(new Ray(Vector3.Zero, Vector3.UnitZ));
        }
Пример #6
0
        protected override void Load()
        {
            SetVSync(false);
            TargetFrameRate = 144;

            Renderer.GFXSettings.ShadowResolution = 4096;
            Renderer.FogEnabled = false;
            //Renderer.GFXSettings.ApplyFXAA = true;

            Renderer.AddRenderer(new VoxelRenderer(Renderer));
            Renderer.AddRenderer(new ChunkRenderer(Renderer));
            Renderer.AddRenderer(new EntityRenderer(Renderer));
            Renderer.AddRenderer(new DebugRenderer(Renderer));

            Renderer.Sun = new Light(Vector3.Zero, LightType.Directional, 1, Color.White);
            Renderer.Lights.Add(Renderer.Sun);

            Camera.Active.SetMode(CameraMode.ArcBall);
            Camera.Active.SmoothCamera = true;

            screen = new EditorScreen(this, Renderer);
        }
Пример #7
0
        public EditorUI(MasterRenderer renderer, EditorScreen screen)
        {
            this.renderer = renderer;
            this.screen   = screen;

            GUISystem = renderer.Sprites.GUISystem;

            area = new GUIArea(GUISystem);
            renderer.Sprites.Add(area);

            Theme = EditorTheme.Glass;

            TranslateTerrainWindow transTerrainWindow;

            newWindow = new NewWorldWindow(GUISystem, screen, Theme);

            transTerrainWindow          = new TranslateTerrainWindow(GUISystem, Theme);
            transTerrainWindow.OnApply += (sender, d) => { screen.World.TranslateTerrain(d); };

            GUIFrame topBar = new GUIFrame(UDim2.Zero, new UDim2(1, 0, 0, 40), Theme);

            float menuItemWidth = 220;

            GUIDropDown fileMenu = new GUIDropDown(UDim2.Zero, new UDim2(0, menuItemWidth, 1, 0), Theme, false)
            {
                Parent = topBar, Text = "File"
            };

            fileMenu.AddItem("New", null, (d, b) => { newWindow.Visible = true; });
            fileMenu.AddItem("Open", null, (d, b) => { openWorldWindow.Visible = true; });
            fileMenu.AddItem("Save", null, (d, b) => { if (screen.CurrentFile != null)
                                                       {
                                                           screen.SaveWorld();
                                                       }
                                                       else
                                                       {
                                                           saveWorldWindow.Visible = true;
                                                       } });
            fileMenu.AddItem("Save As...", null, (d, b) => { saveWorldWindow.Visible = true; });

            GUIDropDown editMenu = new GUIDropDown(new UDim2(0, menuItemWidth, 0, 0), new UDim2(0, menuItemWidth, 1, 0), Theme, false)
            {
                Parent = topBar, Text = "Edit"
            };

            GUIDropDown editModeMenu = new GUIDropDown(UDim2.Zero, new UDim2(0, menuItemWidth, 1, 0), Theme, false)
            {
                HideMainButton = true
            };

            editMenu.AddItemSub("Mode", editModeMenu);
            editModeButtons = new GUIDropDownButton[] {
                editModeMenu.AddItem("Select", null, OnEditModeSelected),
                editModeMenu.AddItem("Add", null, OnEditModeSelected),
                editModeMenu.AddItem("Delete", null, OnEditModeSelected),
                editModeMenu.AddItem("Paint", null, OnEditModeSelected),
                editModeMenu.AddItem("Terrain Move", null, OnEditModeSelected),
                editModeMenu.AddItem("Terraform", null, OnEditModeSelected),
            };

            GUIDropDown insertSubMenu = new GUIDropDown(UDim2.Zero, new UDim2(0, menuItemWidth, 1, 0), Theme, false)
            {
                HideMainButton = true
            };

            editMenu.AddItemSub("Insert", insertSubMenu);
            GUIDropDownButton[] insertButtons = new GUIDropDownButton[] {
                insertSubMenu.AddItem("Command Post", null, (d, b) => { screen.World.AddNewCommandPost(); }),
                insertSubMenu.AddItem("Intel", null, (d, b) => { screen.World.AddNewIntel(); }),
            };

            editMenu.AddItem("Bake Damage Colors", null, (d, b) => { screen.WorldEditor.TerrainEditor.BakeDamageColors(); });
            editMenu.AddItem("Translate Terrain", null, (d, b) => { transTerrainWindow.Visible = true; });

            editModeButtons[0].Toggled = true;

            GUIDropDown gfxMenu = new GUIDropDown(new UDim2(0, menuItemWidth * 2, 0, 0), new UDim2(0, menuItemWidth, 1, 0), Theme, false)
            {
                Parent = topBar, Text = "Graphics"
            };

            gfxMenu.AddItem("FXAA", null, (d, b) => { TogglePostProcess(b, true); });
            gfxMenu.AddItem("Shadows", null, (d, b) => { b.Toggled = renderer.GFXSettings.RenderShadows = !renderer.GFXSettings.RenderShadows; });

            GUIDropDown gfxFogMenu = new GUIDropDown(UDim2.Zero, new UDim2(0, menuItemWidth, 1, 0), Theme, false)
            {
                HideMainButton = true
            };

            gfxMenu.AddItemSub("Fog", gfxFogMenu);
            fogButtons    = new GUIDropDownButton[4];
            fogButtons[0] = gfxFogMenu.AddItem("Off", null, OnFogSelected);
            fogButtons[1] = gfxFogMenu.AddItem("Low", null, OnFogSelected);
            fogButtons[2] = gfxFogMenu.AddItem("Medium", null, OnFogSelected);
            fogButtons[3] = gfxFogMenu.AddItem("High", null, OnFogSelected);

            GUIDropDown gfxPCFMenu = new GUIDropDown(UDim2.Zero, new UDim2(0, menuItemWidth, 1, 0), Theme, false)
            {
                HideMainButton = true
            };

            gfxMenu.AddItemSub("PCF Samples", gfxPCFMenu);
            pcfButtons    = new GUIDropDownButton[5];
            pcfButtons[0] = gfxPCFMenu.AddItem("1", 1, OnPCFSelected);
            pcfButtons[1] = gfxPCFMenu.AddItem("2", 2, OnPCFSelected);
            pcfButtons[2] = gfxPCFMenu.AddItem("4", 4, OnPCFSelected);
            pcfButtons[3] = gfxPCFMenu.AddItem("6", 6, OnPCFSelected);
            pcfButtons[4] = gfxPCFMenu.AddItem("12", 12, OnPCFSelected);

            GUIDropDown viewMenu = new GUIDropDown(new UDim2(0, menuItemWidth * 3, 0, 0), new UDim2(0, menuItemWidth, 1, 0), Theme, false)
            {
                Parent = topBar, Text = "View"
            };

            viewMenu.AddItem("Color Picker", null, (d, b) => { ColorWindow.Visible = true; });
            viewMenu.AddItem("Chunk Borders", null, (d, b) => { b.Toggled = screen.World.ShowChunkBorders = !screen.World.ShowChunkBorders; });

            currentToolLabel = new GUILabel(new UDim2(1f, -5, 0, 5), UDim2.Zero, "Current Tool: Add", TextAlign.TopRight, Theme)
            {
                Parent = topBar
            };

            SetupDefaultGraphicsSettings(gfxMenu);
            area.AddTopLevel(topBar);

            GUIFrame bottomBar = new GUIFrame(new UDim2(0, 0, 1, -30), new UDim2(1, 0, 0, 30), Theme);

            statusLeft = new GUILabel(UDim2.Zero, new UDim2(0.5f, 0, 1, 0), "<left status>", TextAlign.Left, Theme)
            {
                Parent = bottomBar
            };
            statusRight = new GUILabel(new UDim2(0.5f, 0, 0, 0), new UDim2(0.5f, 0, 1, 0), "<right status>", TextAlign.Right, Theme)
            {
                Parent = bottomBar
            };
            statusMid = new GUILabel(new UDim2(0.25f, 0, 0, 0), new UDim2(0.5f, 0, 1f, 0), "", TextAlign.Center, Theme)
            {
                Parent = bottomBar
            };

            area.AddTopLevel(bottomBar);

            openWorldWindow = new FileBrowserWindow(GUISystem, Theme, new UDim2(0.75f, 0, 0.75f, 0), "Open World",
                                                    FileBrowserMode.OpenFile, new string[] { ".aosw" },
                                                    (window) =>
            {
                if (File.Exists(window.FileName))
                {
                    screen.LoadWorld(window.FileName);
                }
            });

            saveWorldWindow = new FileBrowserWindow(GUISystem, Theme, new UDim2(0.75f, 0, 0.75f, 0), "Save World",
                                                    FileBrowserMode.Save, new string[] { ".aosw" },
                                                    (window) =>
            {
                string fullPath = Path.Combine(window.CurrentDirectory, window.FileName);

                if (!Path.HasExtension(fullPath))
                {
                    fullPath += ".aosw";
                }

                screen.SaveWorld(fullPath);
            });

            ColorWindow          = new GUIColorPickerWindow(GUISystem, new UDim2(0.3f, 0, 0.3f, 0), Theme);
            ColorWindow.Visible  = true;
            ColorWindow.Position = new UDim2(0.7f, -10, 0.7f, -10);
            ColorWindow.MinSize  = new UDim2(0, 400, 0, 300);
            ColorWindow.MaxSize  = new UDim2(0, 550, 0, 400);
            popup         = new MessageWindow(GUISystem, Theme, new UDim2(0.6f, 0, 0.3f, 0), "Alert!");
            popup.MinSize = new UDim2(0, 215, 0, 200);
            popup.MaxSize = new UDim2(0, 600, 0, 275);

            GUISystem.Add(ColorWindow, transTerrainWindow, openWorldWindow, saveWorldWindow, newWindow, popup);
        }
Пример #8
0
        public NewWorldWindow(GUISystem system, EditorScreen screen, GUITheme theme)
            : base(system, new UDim2(0.4f, 0, 0.3f, 0), "New World", theme, true)
        {
            this.screen = screen;
            MinSize     = new UDim2(0, 400, 0, 300);
            MaxSize     = new UDim2(0, 575, 0, 475);

            GUIForm form = new GUIForm(new UDim2(0, 5, 0, 25), new UDim2(1f, -10, 1f, -30), Theme);

            GUILabel    useNoiseLabel;
            GUICheckbox useNoiseCheckBox;

            form.AddLabledCheckbox("Use Noise:", false, UDim2.Zero, out useNoiseLabel, out useNoiseCheckBox);

            GUILabel sizeLabel = new GUILabel(new UDim2(0, 0, 0, 45), UDim2.Zero, "World Size:", TextAlign.TopLeft, Theme)
            {
                Parent = form
            };

            GUILabel     xSizeLabel, ySizeLabel, zSizeLabel;
            GUITextField xSizeField, ySizeField, zSizeField;

            form.AddLabledTextField("X:", "8", new UDim2(0, 0, 0, 70),
                                    out xSizeLabel, out xSizeField, new UDim(0, 40));
            float sizeInputLength = xSizeField.Position.X.Offset + xSizeField.Size.X.Offset;

            form.AddLabledTextField("Y:", "3", new UDim2(0, sizeInputLength + 5, 0, 70),
                                    out ySizeLabel, out ySizeField, new UDim(0, 40));
            form.AddLabledTextField("Z:", "8", new UDim2(0, (sizeInputLength + 5) * 2, 0, 70),
                                    out zSizeLabel, out zSizeField, new UDim(0, 40));

            xSizeField.Label.TextAlign = TextAlign.Center;
            ySizeField.Label.TextAlign = TextAlign.Center;
            zSizeField.Label.TextAlign = TextAlign.Center;

            GUIButton cancelBtn = new GUIButton(new UDim2(1f, -100, 1f, -30), new UDim2(0, 100, 0, 30), "Cancel", theme)
            {
                Parent = form
            };

            cancelBtn.OnMouseClick += (btn, mbtn) =>
            {
                if (mbtn == MouseButton.Left)
                {
                    Visible = false;
                }
            };

            GUIButton createBtn = new GUIButton(new UDim2(1f, -205, 1f, -30), new UDim2(0, 100, 0, 30), "Create", theme)
            {
                Parent = form
            };

            createBtn.OnMouseClick += (btn, mbtn) =>
            {
                if (mbtn == MouseButton.Left)
                {
                    int x = 1, y = 1, z = 1;
                    if (int.TryParse(xSizeField.Text, out x))
                    {
                        x = Math.Max(x, 0);
                    }
                    if (int.TryParse(ySizeField.Text, out y))
                    {
                        y = Math.Max(y, 0);
                    }
                    if (int.TryParse(zSizeField.Text, out z))
                    {
                        z = Math.Max(z, 0);
                    }

                    if (!useNoiseCheckBox.IsChecked)
                    {
                        screen.LoadNewFlatWorld(x, y, z);
                    }
                    else
                    {
                        screen.LoadNewWorld(x, y, z);
                    }

                    Visible = false;
                }
            };

            AddTopLevel(form);
        }