예제 #1
0
        public EditWorldDialog(CreatorAPI creatorAPI)
        {
            this.creatorAPI = creatorAPI;
            this.player     = creatorAPI.componentMiner.ComponentPlayer;
            XElement node = ContentManager.Get <XElement>("NewWidgets/Dialog/编辑世界");

            WidgetsManager.LoadWidgetContents(this, this, node);
            this.worldSettings                    = player.Project.FindSubsystem <SubsystemGameInfo>(true).WorldSettings;
            this.OKButton                         = Children.Find <ButtonWidget>("确定");
            this.UpdataWorldButton                = Children.Find <ButtonWidget>("重载");
            this.UpdataButton                     = Children.Find <ButtonWidget>("刷新");
            this.paletteButton                    = this.Children.Find <ButtonWidget>("Palette", true);
            this.blocksTextureIcon                = this.Children.Find <RectangleWidget>("BlocksTextureIcon", true);
            this.blocksTextureLabel               = this.Children.Find <LabelWidget>("BlocksTextureLabel", true);
            this.blocksTextureDetails             = this.Children.Find <LabelWidget>("BlocksTextureDetails", true);
            this.blocksTextureButton              = this.Children.Find <ButtonWidget>("BlocksTextureButton", true);
            this.supernaturalCreaturesButton      = this.Children.Find <ButtonWidget>("SupernaturalCreatures", true);
            this.environmentBehaviorButton        = this.Children.Find <ButtonWidget>("EnvironmentBehavior", true);
            this.timeOfDayButton                  = this.Children.Find <ButtonWidget>("TimeOfDay", true);
            this.weatherEffectsButton             = this.Children.Find <ButtonWidget>("WeatherEffects", true);
            this.adventureRespawnButton           = this.Children.Find <ButtonWidget>("AdventureRespawn", true);
            this.adventureSurvivalMechanicsButton = this.Children.Find <ButtonWidget>("AdventureSurvivalMechanics", true);
            this.terrainGenerationLabel           = this.Children.Find <LabelWidget>("TerrainGenerationLabel", true);
            this.terrainGenerationButton          = this.Children.Find <ButtonWidget>("TerrainGeneration", true);
            this.seaLevelOffsetSlider             = this.Children.Find <SliderWidget>("SeaLevelOffset", true);
            this.temperatureOffsetSlider          = this.Children.Find <SliderWidget>("TemperatureOffset", true);
            this.humidityOffsetSlider             = this.Children.Find <SliderWidget>("HumidityOffset", true);
            this.biomeSizeSlider                  = this.Children.Find <SliderWidget>("BiomeSize", true);
            this.islandTerrainPanel               = this.Children.Find <Widget>("IslandTerrainPanel", true);
            this.islandSizeNS                     = this.Children.Find <SliderWidget>("IslandSizeNS", true);
            this.islandSizeEW                     = this.Children.Find <SliderWidget>("IslandSizeEW", true);
            this.flatTerrainPanel                 = this.Children.Find <Widget>("FlatTerrainPanel", true);
            this.continentTerrainPanel            = this.Children.Find <Widget>("ContinentTerrainPanel", true);
            this.flatTerrainLevelSlider           = this.Children.Find <SliderWidget>("FlatTerrainLevel", true);
            this.flatTerrainBlock                 = this.Children.Find <BlockIconWidget>("FlatTerrainBlock", true);
            this.flatTerrainBlockLabel            = this.Children.Find <LabelWidget>("FlatTerrainBlockLabel", true);
            this.flatTerrainBlockButton           = this.Children.Find <ButtonWidget>("FlatTerrainBlockButton", true);
            this.flatTerrainMagmaOceanCheckbox    = this.Children.Find <CheckboxWidget>("MagmaOcean", true);

            this.islandSizeEW.MinValue       = 0f;
            this.islandSizeEW.MaxValue       = (float)(this.islandSizes.Length - 1);
            this.islandSizeEW.Granularity    = 1f;
            this.islandSizeNS.MinValue       = 0f;
            this.islandSizeNS.MaxValue       = (float)(this.islandSizes.Length - 1);
            this.islandSizeNS.Granularity    = 1f;
            this.biomeSizeSlider.MinValue    = 0f;
            this.biomeSizeSlider.MaxValue    = (float)(this.biomeSizes.Length - 1);
            this.biomeSizeSlider.Granularity = 1f;
        }
예제 #2
0
        public void DrawMethod_Should_Render_Size_XY_Positions_Height_Width()
        {
            // Arrange
            var widget = new RectangleWidget(70, 30)
            {
                Height = 4, Width = 8, Size = 32
            };

            // Act
            var renderedWidget = widget.Draw();

            // Assert
            Assert.NotNull(widget);
            Assert.Equal("Rectangle (70, 30) Height=4 Width=8 Size= 32", renderedWidget);
        }
예제 #3
0
        static void Main(string[] args)
        {
            var requestedWidgets = new List <BaseWidget>();

            var rectangle = new RectangleWidget()
            {
                XCoOrd = 10,
                YCoOrd = 10,
                Height = 30,
                Width  = 40
            };
            var square = new SquareWidget()
            {
                XCoOrd = 15,
                YCoOrd = 30,
                Size   = 35
            };
            var ellipse = new EllipseWidget()
            {
                XCoOrd             = 100,
                YCoOrd             = 150,
                HorizontalDiameter = -300,
                VerticalDiameter   = 200
            };
            var circle = new CircleWidget()
            {
                XCoOrd = 1,
                YCoOrd = 1,
                Size   = 300
            };
            var textBox = new TextBoxWidget()
            {
                XCoOrd = 5,
                YCoOrd = 5,
                Width  = 200,
                Height = 100,
                Text   = "sample text"
            };

            requestedWidgets.Add(rectangle);
            requestedWidgets.Add(square);
            requestedWidgets.Add(ellipse);
            requestedWidgets.Add(circle);
            requestedWidgets.Add(textBox);

            WidgetPrinter.PrintRequestList(requestedWidgets);
        }
예제 #4
0
        public void CreateWidget_CheckRectangleForNegativeYPosition_ReturnsErrorBill()
        {
            // Arrange
            var widget = new RectangleWidget
            {
                XPosition = 10,
                YPosition = -10,
                Width     = 30,
                Height    = 40
            };

            // Act
            var result = MaterialGenService.CreateWidget(widget);

            // Assert
            Assert.IsNotNull(result);
            Assert.IsFalse(string.IsNullOrWhiteSpace(result));
            Assert.AreEqual("+++++Abort+++++", result);
            MockRepository.VerifyAll();
        }
예제 #5
0
        public void CreateWidget_CreateRectangleMaterials_ReturnsCorrectBill()
        {
            // Arrange
            var widget = new RectangleWidget
            {
                XPosition = 10,
                YPosition = 10,
                Width     = 30,
                Height    = 40
            };

            // Act
            var result = MaterialGenService.CreateWidget(widget);

            // Assert
            Assert.IsNotNull(result);
            Assert.IsFalse(string.IsNullOrWhiteSpace(result));
            Assert.AreEqual("Rectangle (10,10) width=30 height=40", result);
            MockRepository.VerifyAll();
        }
예제 #6
0
        private static void Main(string[] args)
        {
            var squareWidget = new SquareWidget(10, 10)
            {
                Size = 1600
            };
            var circleWidget = new CircleWidget(100, 100)
            {
                Size = 20
            };
            var ellipseWidget = new EllipseWidget(50, 50)
            {
                HorizontalDiameter = 30, VerticalDiameter = 30, Size = 6283
            };
            var rectangleWidget = new RectangleWidget(70, 30)
            {
                Height = 4, Width = 8, Size = 32
            };
            var textBoxWithBackgroundColourWidget = new TextBoxWidget(20, 90)
            {
                Height = 6, Width = 24, Size = 144, Text = "Sample text", BackgroundColour = "Blue"
            };
            var textBoxWithDefaultBackgroundColour = new TextBoxWidget(30, 150)
            {
                Height = 6, Width = 24, Size = 144, Text = "Sample text with default colour"
            };

            var canvas = new Canvas();

            canvas.Add(squareWidget);
            canvas.Add(circleWidget);
            canvas.Add(ellipseWidget);
            canvas.Add(rectangleWidget);
            canvas.Add(textBoxWithBackgroundColourWidget);
            canvas.Add(textBoxWithDefaultBackgroundColour);

            canvas.PrintCanvas();
            Console.ReadKey();
        }
예제 #7
0
    public ManageContentScreen()
    {
        XElement node = ContentManager.Get <XElement>("Screens/ManageContentScreen");

        LoadContents(this, node);
        m_contentList                   = Children.Find <ListPanelWidget>("ContentList");
        m_deleteButton                  = Children.Find <ButtonWidget>("DeleteButton");
        m_uploadButton                  = Children.Find <ButtonWidget>("UploadButton");
        m_changeFilterButton            = Children.Find <ButtonWidget>("ChangeFilter");
        m_filterLabel                   = Children.Find <LabelWidget>("Filter");
        m_contentList.ItemWidgetFactory = delegate(object obj)
        {
            ListItem        listItem = (ListItem)obj;
            ContainerWidget containerWidget;
            if (listItem.Type == ExternalContentType.BlocksTexture)
            {
                XElement node2 = ContentManager.Get <XElement>("Widgets/BlocksTextureItem");
                containerWidget = (ContainerWidget)Widget.LoadWidget(this, node2, null);
                RectangleWidget rectangleWidget = containerWidget.Children.Find <RectangleWidget>("BlocksTextureItem.Icon");
                LabelWidget     labelWidget     = containerWidget.Children.Find <LabelWidget>("BlocksTextureItem.Text");
                LabelWidget     labelWidget2    = containerWidget.Children.Find <LabelWidget>("BlocksTextureItem.Details");
                Texture2D       texture         = m_blocksTexturesCache.GetTexture(listItem.Name);
                BlocksTexturesManager.GetCreationDate(listItem.Name);
                rectangleWidget.Subtexture = new Subtexture(texture, Vector2.Zero, Vector2.One);
                labelWidget.Text           = listItem.DisplayName;
                labelWidget2.Text          = string.Format(LanguageControl.Get(fName, 1), texture.Width, texture.Height);
                if (!listItem.IsBuiltIn)
                {
                    labelWidget2.Text += $" | {listItem.CreationTime.ToLocalTime():dd MMM yyyy HH:mm}";
                    if (listItem.UseCount > 0)
                    {
                        labelWidget2.Text += string.Format(LanguageControl.Get(fName, 2), listItem.UseCount);
                    }
                }
            }
            else
            {
                if (listItem.Type != ExternalContentType.CharacterSkin)
                {
                    if (listItem.Type == ExternalContentType.FurniturePack)
                    {
                        XElement node3 = ContentManager.Get <XElement>("Widgets/FurniturePackItem");
                        containerWidget = (ContainerWidget)Widget.LoadWidget(this, node3, null);
                        LabelWidget labelWidget3 = containerWidget.Children.Find <LabelWidget>("FurniturePackItem.Text");
                        LabelWidget labelWidget4 = containerWidget.Children.Find <LabelWidget>("FurniturePackItem.Details");
                        labelWidget3.Text = listItem.DisplayName;
                        try
                        {
                            List <FurnitureDesign> designs = FurniturePacksManager.LoadFurniturePack(null, listItem.Name);
                            labelWidget4.Text = string.Format(LanguageControl.Get(fName, 3), FurnitureDesign.ListChains(designs).Count);
                            if (string.IsNullOrEmpty(listItem.Name))
                            {
                                return(containerWidget);
                            }
                            labelWidget4.Text += $" | {listItem.CreationTime.ToLocalTime():dd MMM yyyy HH:mm}";
                            return(containerWidget);
                        }
                        catch (Exception ex)
                        {
                            labelWidget4.Text = labelWidget4.Text + LanguageControl.Get("Usual", "error") + ex.Message;
                            return(containerWidget);
                        }
                    }
                    throw new InvalidOperationException(LanguageControl.Get(fName, 10));
                }
                XElement node4 = ContentManager.Get <XElement>("Widgets/CharacterSkinItem");
                containerWidget = (ContainerWidget)Widget.LoadWidget(this, node4, null);
                PlayerModelWidget playerModelWidget = containerWidget.Children.Find <PlayerModelWidget>("CharacterSkinItem.Model");
                LabelWidget       labelWidget5      = containerWidget.Children.Find <LabelWidget>("CharacterSkinItem.Text");
                LabelWidget       labelWidget6      = containerWidget.Children.Find <LabelWidget>("CharacterSkinItem.Details");
                Texture2D         texture2          = m_characterSkinsCache.GetTexture(listItem.Name);
                playerModelWidget.PlayerClass          = PlayerClass.Male;
                playerModelWidget.CharacterSkinTexture = texture2;
                labelWidget5.Text = listItem.DisplayName;
                labelWidget6.Text = string.Format(LanguageControl.Get(fName, 4), texture2.Width, texture2.Height);
                if (!listItem.IsBuiltIn)
                {
                    labelWidget6.Text += $" | {listItem.CreationTime.ToLocalTime():dd MMM yyyy HH:mm}";
                    if (listItem.UseCount > 0)
                    {
                        labelWidget6.Text += string.Format(LanguageControl.Get(fName, 2), listItem.UseCount);
                    }
                }
            }
            return(containerWidget);
        };
    }