/*        public override RectangleF Bounds => new RectangleF(0, 0, 200, 200);
 */     public override void Initialize()
        {
            var skin  = Skin.CreateDefaultSkin();
            var table = Stage.AddElement(new Table());

            table.Defaults().SetPadTop(10).SetMinWidth(170).SetMinHeight(30);
            table.SetFillParent(true).Center();

            // add a button for each of the actions/AI types we need
            table.Add(new TextButton(Constants.MENU_PLAY, skin))
            .GetElement <TextButton>()
            .OnClicked += LoadGame;
            table.Row();

            table.Add(new TextButton(Constants.MENU_OPTION, skin))
            .GetElement <TextButton>()
            .OnClicked += OnClickBtLowerPriority;
            table.Row();

            table.Add(new TextButton(Constants.MENU_CREDITS, skin))
            .GetElement <TextButton>()
            .OnClicked += OnClickBtLowerPriority;
            table.Row();

            table.Add(new TextButton(Constants.MENU_EXIT, skin))
            .GetElement <TextButton>()
            .OnClicked += OnClickBtLowerPriority;
            table.Row();
        }
Exemple #2
0
        void PrepCanvas()
        {
            _skin = Skin.CreateDefaultSkin();

            // modify some of the default styles to better suit our needs
            var tfs = _skin.Get <TextFieldStyle>();

            tfs.Background.LeftWidth    = tfs.Background.RightWidth = 4;
            tfs.Background.BottomHeight = 0;
            tfs.Background.TopHeight    = 3;

            var checkbox = _skin.Get <CheckBoxStyle>();

            checkbox.CheckboxOn.MinWidth   = checkbox.CheckboxOn.MinHeight = 15;
            checkbox.CheckboxOff.MinWidth  = checkbox.CheckboxOff.MinHeight = 15;
            checkbox.CheckboxOver.MinWidth = checkbox.CheckboxOver.MinHeight = 15;

            // since we arent using this as a Component on an Entity we'll fake it here
            ui = new UICanvas();
            ui.OnAddedToEntity();
            ui.Stage.IsFullScreen = true;

            _table = new Table();
            _table.Top().Left();
            _table.Defaults().SetPadTop(4).SetPadLeft(4).SetPadRight(0).SetAlign(Align.Left);
            _table.SetBackground(new PrimitiveDrawable(new Color(40, 40, 40)));

            // wrap up the table in a ScrollPane
            _scrollPane = ui.Stage.AddElement(new ScrollPane(_table, _skin));

            // force a validate which will layout the ScrollPane and populate the proper scrollBarWidth
            _scrollPane.Validate();
            _scrollPane.SetSize(295 + _scrollPane.GetScrollBarWidth(), Screen.Height);
        }
        public override void Initialize()
        {
            BruhUi();

            Chat = new Label("inget mottaget").SetFontScale(3);

            Table.Add(Chat);

            Table.Row().SetPadTop(20);

            textFields = TextFieldStyle.Create(Color.White, Color.White, Color.Black, Color.DarkGray);

            textField = new TextField("", textFields);

            Table.Add(textField);

            Table.Row().SetPadTop(20);

            KörPå            = Table.Add(new TextButton("skicka", Skin.CreateDefaultSkin())).SetFillX().SetMinHeight(30).GetElement <TextButton>();
            KörPå.OnClicked += SickaMeddelade;

            Table.Row().SetPadRight(50);

            /*TextButton Kör = Table.Add(new TextButton("byebye borski" , Skin.CreateDefaultSkin())).SetFillX().SetMinHeight(30).GetElement<TextButton>();
             * Kör.OnClicked += Koppplafrån;*/
            Skin     skin     = Skin.CreateDefaultSkin();
            CheckBox checkbox = Table.Add(new CheckBox("Ready", skin)).GetElement <CheckBox>();

            checkbox.IsChecked  = false;
            checkbox.OnChanged += isChecked => { ReadyStart = isChecked; };
        }
Exemple #4
0
/*        public override RectangleF Bounds => new RectangleF(0, 0, 200, 200);
 */     public override void Initialize()
        {
            var skin  = Skin.CreateDefaultSkin();
            var table = Stage.AddElement(new Table());

            table.Defaults().SetPadTop(10).SetMinWidth(170).SetMinHeight(30);
            table.SetFillParent(true).Center();

            // add a button for each of the actions/AI types we need
            table.Add(new TextButton("Continue", skin))
            .GetElement <TextButton>()
            .OnClicked += OnClickBtLowerPriority;
            table.Row();

            table.Add(new TextButton("New game", skin))
            .GetElement <TextButton>()
            .OnClicked += LoadGame;
            table.Row();

            table.Add(new TextButton("Settings", skin))
            .GetElement <TextButton>()
            .OnClicked += OnClickBtLowerPriority;
            table.Row();

            table.Add(new TextButton("Credits", skin))
            .GetElement <TextButton>()
            .OnClicked += OnClickBtLowerPriority;
            table.Row();

            table.Add(new TextButton("Quit game", skin))
            .GetElement <TextButton>()
            .OnClicked += OnClickBtLowerPriority;
            table.Row();
        }
        void CreateUi()
        {
            // stick a UI in so we can play with the sprite light effect
            var uiCanvas = CreateEntity("sprite-light-ui").AddComponent(new UICanvas());

            uiCanvas.IsFullScreen = true;
            uiCanvas.RenderLayer  = ScreenSpaceRenderLayer;
            var skin = Skin.CreateDefaultSkin();

            var table = uiCanvas.Stage.AddElement(new Table());

            table.SetFillParent(true).Left().Top().PadLeft(10).PadTop(50);


            var checkbox = table.Add(new CheckBox("Toggle PostProcessor", skin)).GetElement <CheckBox>();

            checkbox.IsChecked  = true;
            checkbox.OnChanged += isChecked => { _spriteLightPostProcessor.Enabled = isChecked; };

            table.Row().SetPadTop(20).SetAlign(Align.Left);

            table.Add("Blend Multiplicative Factor");
            table.Row().SetPadTop(0).SetAlign(Align.Left);

            var slider = table.Add(new Slider(0.5f, 3f, 0.1f, false, skin.Get <SliderStyle>())).SetFillX()
                         .GetElement <Slider>();

            slider.SetValue(1f);
            slider.OnChanged += value => { _spriteLightPostProcessor.MultiplicativeFactor = value; };

            table.Row().SetPadTop(20).SetAlign(Align.Left);

            table.Add("Ambient Light Intensity");
            table.Row().SetPadTop(0).SetAlign(Align.Left);

            var ambientColorStyle = table.Add(new Slider(10, 75, 1f, false, skin.Get <SliderStyle>())).SetFillX()
                                    .GetElement <Slider>();

            ambientColorStyle.SetValue(10f);
            ambientColorStyle.OnChanged += value =>
            {
                var valueInt = Mathf.RoundToInt(value);
                _lightRenderer.RenderTargetClearColor = new Color(valueInt, valueInt, valueInt * 2, 255);
            };

            table.Row().SetPadTop(20).SetAlign(Align.Left).SetFillX();

            var button = table.Add(new TextButton("Add Light", skin)).SetFillX().SetMinHeight(30)
                         .GetElement <TextButton>();

            button.OnClicked += butt =>
            {
                var lightTex = Content.Load <Texture2D>(Nez.Content.SpriteLights.Spritelight);
                var position = new Vector2(Random.Range(0, Screen.Width), Random.Range(0, Screen.Height));
                AddSpriteLight(lightTex, position, Random.Range(2f, 3f));
            };
        }
Exemple #6
0
        /// <summary>
        /// All we need when setting up is the renderlayer.  This assumes that you've already set up a ScreenSpaceRenderer and set its renderLayer.
        /// </summary>
        /// <param name="renderLayer">The renderLayer of your ScreenSpaceRenderer</param>
        /// <param name="skin">The skin to store in our class</param>
        public BaseUI(int renderLayer, Skin skin = null)
        {
            _renderLayer = renderLayer;

            // if we didn't pass in a skin, we'll just use a default one
            // we don't actually use this anywhere in the base class but it can be useful to store it here
            if (skin == null)
            {
                _skin = Skin.CreateDefaultSkin();
            }
        }
        /// <summary>
        /// Create checkbox on table
        /// </summary>
        /// <param name="t">Target table</param>
        /// <param name="label">Text</param>
        /// <param name="defaultState">Default state of check</param>
        /// <param name="onChanged">On state changed handler</param>
        /// <returns>Element</returns>
        public CheckBox CreateCheckBox(Table t, string label, bool defaultState, Action <bool> onChanged = null)
        {
            var checkBox = new CheckBox(label, Skin.CreateDefaultSkin());

            checkBox.GetLabel().GetStyle().Font = _skin.Skin.Get <LabelStyle>("label").Font;
            checkBox.GetLabel().SetFontScale(0.75f);
            checkBox.IsChecked  = defaultState;
            checkBox.OnChanged += onChanged;
            onChanged?.Invoke(defaultState);
            t.Add(checkBox);

            return(checkBox);
        }
        public override void Initialize()
        {
            ServerHanterare = new VärdHanterare();
            Core.RegisterGlobalManager(ServerHanterare);
            BruhUi();
            Table.Add(new Label("ok").SetFontScale(5));

            Table.Row().SetPadTop(20);

            TextButton KörPå = Table.Add(new TextButton("Klicka", Skin.CreateDefaultSkin())).SetFillX().SetMinHeight(30).GetElement <TextButton>();


            KörPå.OnClicked += TextFält;
        }
Exemple #9
0
        /// <summary>
        /// displays a simple dialog with a button to close it
        /// </summary>
        /// <returns>The dialog.</returns>
        /// <param name="title">Title.</param>
        /// <param name="messageText">Message text.</param>
        /// <param name="closeButtonText">Close button text.</param>
        public Dialog ShowDialog(string title, string messageText, string closeButtonText)
        {
            var skin = Skin.CreateDefaultSkin();

            var style = new WindowStyle
            {
                Background      = new PrimitiveDrawable(new Color(50, 50, 50)),
                StageBackground = new PrimitiveDrawable(new Color(0, 0, 0, 150))
            };

            var dialog = new Dialog(title, style);

            dialog.GetTitleLabel().GetStyle().Background = new PrimitiveDrawable(new Color(55, 100, 100));
            dialog.Pad(20, 5, 5, 5);
            dialog.AddText(messageText);
            dialog.AddButton(new TextButton(closeButtonText, skin)).OnClicked += butt => dialog.Hide();
            dialog.Show(Stage);

            return(dialog);
        }
Exemple #10
0
        public override void OnAddedToEntity()
        {
            base.OnAddedToEntity();

            // setup a Skin and a Table for our UI
            var skin  = Skin.CreateDefaultSkin();
            var table = Stage.AddElement(new Table());

            table.Defaults().SetPadTop(10).SetMinWidth(170).SetMinHeight(30);
            table.SetFillParent(true).Center();

            // add a button for each of the actions/AI types we need
            table.Add(new TextButton("BT: LowerPriority Abort Tree", skin))
            .GetElement <TextButton>()
            .OnClicked += OnClickBtLowerPriority;
            table.Row();

            table.Add(new TextButton("BT: Self Abort Tree", skin))
            .GetElement <TextButton>()
            .OnClicked += OnClickBtSelfAbort;
            table.Row();

            table.Add(new TextButton("Utility AI", skin))
            .GetElement <TextButton>()
            .OnClicked += OnClickUtilityAi;
            table.Row();

            table.Add(new TextButton("GOAP", skin))
            .GetElement <TextButton>()
            .OnClicked += OnClickGoap;
            table.Row().SetPadTop(40);

            table.Add(new TextButton("Stop All Running AI", skin))
            .GetElement <TextButton>()
            .OnClicked += OnClickStopAllAi;

            // fetch our different AI Components
            _miner        = Entity.Scene.FindComponentOfType <BehaviorTreeMiner>();
            _utilityMiner = Entity.Scene.FindComponentOfType <UtilityMiner>();
            _goapMiner    = Entity.Scene.FindComponentOfType <GoapMiner>();
        }
Exemple #11
0
        public override void Initialize()
        {
            BruhUi();

            Table.Add(new Label("Main Menu").SetFontScale(5));

            Table.Row().SetPadTop(20);

            Table.Add(new Label("Host Eller Klient?").SetFontScale(2));

            Table.Row().SetPadTop(40);

            TextButton KnappFörVärd = Table.Add(new TextButton("Host", Skin.CreateDefaultSkin())).SetFillX().SetMinHeight(30).GetElement <TextButton>();

            KnappFörVärd.OnClicked += VärdKnapp;

            Table.Row().SetPadTop(40);

            TextButton KnappFörKlient = Table.Add(new TextButton("Klient", Skin.CreateDefaultSkin())).SetFillX().SetMinHeight(30).GetElement <TextButton>();

            KnappFörKlient.OnClicked += KlientKnapp;
        }
Exemple #12
0
        public override void Initialize()
        {
            BruhUi();
            KlientHanterare = new KlientHanterare();
            Core.RegisterGlobalManager(KlientHanterare);
            Table.Add(new Label("ip pls").SetFontScale(5));

            Table.Row().SetPadTop(20);

            TextFieldStyle textFields = TextFieldStyle.Create(Color.White, Color.White, Color.Black, Color.DarkGray);

            textField = new TextField("", textFields);

            Table.Add(textField);

            Table.Row().SetPadTop(20);

            TextButton KörPå = Table.Add(new TextButton("Klicka", Skin.CreateDefaultSkin())).SetFillX().SetMinHeight(30).GetElement <TextButton>();


            KörPå.OnClicked += TextFält;
        }
Exemple #13
0
 protected UIComponent(Skin skin = null)
 {
     Skin = skin ?? Skin.CreateDefaultSkin();
 }
        void CreateUi()
        {
            var uiCanvas = Entity.Scene.CreateEntity("particles-ui").AddComponent(new UICanvas());

            uiCanvas.IsFullScreen = true;
            var skin = Skin.CreateDefaultSkin();

            CondenseSkin(skin);

            // Stolen from RuntimeInspector.cs
            var table = new Table();

            table.Top().Left();
            table.Defaults().SetPadTop(4).SetPadLeft(4).SetPadRight(0).SetAlign(Align.Left);
            table.SetBackground(new PrimitiveDrawable(new Color(40, 40, 40, 220)));

            // wrap up the table in a ScrollPane
            var scrollPane = uiCanvas.Stage.AddElement(new ScrollPane(table, skin));

            // force a validate which will layout the ScrollPane and populate the proper scrollBarWidth
            scrollPane.Validate();
            scrollPane.SetSize(340 + scrollPane.GetScrollBarWidth(), Screen.Height);

            table.Row().SetPadTop(40);             // Leave room for the directions

            var collisionCheckBox = table.Add(new CheckBox("Toggle Collision", skin)).GetElement <CheckBox>();

            collisionCheckBox.IsChecked  = _isCollisionEnabled;
            collisionCheckBox.OnChanged += isChecked =>
            {
                _particleEmitter.CollisionConfig.Enabled = isChecked;
                _isCollisionEnabled = isChecked;
            };

            table.Row();

            var worldSpaceCheckbox = table.Add(new CheckBox("Simulate in World Space", skin)).GetElement <CheckBox>();

            worldSpaceCheckbox.IsChecked  = _simulateInWorldSpace;
            worldSpaceCheckbox.OnChanged += isChecked =>
            {
                _particleEmitter.SimulateInWorldSpace = isChecked;
                _simulateInWorldSpace = isChecked;
            };

            table.Row();

            var button = table.Add(new TextButton("Toggle Play/Pause", skin)).SetFillX().SetMinHeight(30)
                         .GetElement <TextButton>();

            button.OnClicked += butt =>
            {
                if (_particleEmitter.IsPlaying)
                {
                    _particleEmitter.Pause();
                }
                else
                {
                    _particleEmitter.Play();
                }
            };

            table.Add("");
            var save = table.Add(new TextButton("Save as .pex", skin)).SetFillX().SetMinHeight(30)
                       .GetElement <TextButton>();

            save.OnClicked += butt => { ExportPexClicked(skin); };

            table.Row();
            MakeSection(table, skin, "General");
            table.Row();
            MakeEmitterDropdown(table, skin, "Emitter Type");
            table.Row();
            MakeBlendDropdown(table, skin, "Source Blend Function", "BlendFuncSource");
            table.Row();
            MakeBlendDropdown(table, skin, "Destination Blend Function", "BlendFuncDestination");

            table.Row();
            MakeSection(table, skin, "Emitter Parameters");
            table.Row();
            MakeVector2(table, skin, "Source Position Variance", "SourcePositionVariance");
            table.Row();
            MakeSlider(table, skin, "Particle Lifespan", 0, 30, 0.5f, "ParticleLifespan");
            table.Row();
            MakeSlider(table, skin, "Particle Lifespan Variance", 0, 30, 0.5f, "ParticleLifespanVariance");
            table.Row();
            MakeSlider(table, skin, "Emission rate", 0, 4000, 1, "EmissionRate");
            table.Row();
            MakeSlider(table, skin, "Duration", -1, 2000, 1, "Duration");
            table.Row();
            MakeSlider(table, skin, "Angle", 0, 360, 1, "Angle");
            table.Row();
            MakeSlider(table, skin, "Angle Variance", 0, 360, 1, "AngleVariance");
            table.Row();
            MakeSlider(table, skin, "Maximum Particles", 0, 2000, 1, "MaxParticles");
            table.Row();
            MakeSlider(table, skin, "Start Particle Size", 0, 2000, 1, "StartParticleSize");
            table.Row();
            MakeSlider(table, skin, "Start Size Variance", 0, 2000, 1, "StartParticleSizeVariance");
            table.Row();
            MakeSlider(table, skin, "Finish Particle Size", 0, 2000, 1, "FinishParticleSize");
            table.Row();
            MakeSlider(table, skin, "Finish Size Variance", 0, 2000, 1, "FinishParticleSizeVariance");
            table.Row();
            MakeSlider(table, skin, "Rotation Start", 0, 2000, 1, "RotationStart");
            table.Row();
            MakeSlider(table, skin, "Rotation Start Variance", 0, 2000, 1, "RotationStartVariance");
            table.Row();
            MakeSlider(table, skin, "Rotation End", 0, 2000, 1, "RotationEnd");
            table.Row();
            MakeSlider(table, skin, "Rotation End Variance", 0, 2000, 1, "RotationEndVariance");
            table.Row();
            MakeColor(table, skin, "Start Color (R G B A)", "StartColor");
            table.Row();
            MakeColor(table, skin, "Start Color Variance", "StartColorVariance");
            table.Row();
            MakeColor(table, skin, "Finish Color (R G B A)", "FinishColor");
            table.Row();
            MakeColor(table, skin, "Finish Color Variance", "FinishColorVariance");


            if (_particleEmitterConfig.EmitterType == ParticleEmitterType.Gravity)
            {
                table.Row();
                MakeSection(table, skin, "Gravity Emitter");
                table.Row();
                MakeVector2(table, skin, "Gravity X/Y", "Gravity");
                table.Row();
                MakeSlider(table, skin, "Speed", 0, 2000, 1, "Speed");
                table.Row();
                MakeSlider(table, skin, "Speed Variance", 0, 2000, 1, "SpeedVariance");
                table.Row();
                MakeSlider(table, skin, "Radial Acceleration", -2000, 2000, 1, "RadialAcceleration");
                table.Row();
                MakeSlider(table, skin, "Radial Accel Variance", 0, 2000, 1, "RadialAccelVariance");
                table.Row();
                MakeSlider(table, skin, "Tangential Acceleration", -2000, 2000, 1, "TangentialAcceleration");
                table.Row();
                MakeSlider(table, skin, "Tangential Accel Variance", 0, 2000, 1, "TangentialAccelVariance");
            }
            else
            {
                table.Row();
                MakeSection(table, skin, "Radial Emitter");
                table.Row();
                MakeSlider(table, skin, "Maximum Radius", 0, 1000, 1, "MaxRadius");
                table.Row();
                MakeSlider(table, skin, "Maximum Radius Variance", 0, 1000, 1, "MaxRadiusVariance");
                table.Row();
                MakeSlider(table, skin, "Minimum Radius", 0, 1000, 1, "MinRadius");
                table.Row();
                MakeSlider(table, skin, "Minimum Radius Variance", 0, 1000, 1, "MinRadiusVariance");
                table.Row();
                MakeSlider(table, skin, "Rotation/Sec", 0, 1000, 1, "RotatePerSecond");
                table.Row();
                MakeSlider(table, skin, "Rotation/Sec Variance", 0, 1000, 1, "RotatePerSecondVariance");
            }
        }
Exemple #15
0
 public static void SetSkin()
 {
     skin = Skin.CreateDefaultSkin();
 }