コード例 #1
0
        public void TestMethod1()
        {
            string expected = "Harry was slapped by somebody\n";
            string results  = "";

            // the order they are added does not matter
            Harry.Face(Baldy);
            Baldy.Face(Chump);
            Chump.Face(Harry);

            expected += "Baldy was slapped by Harry\n";
            expected += "Chump was slapped by Baldy\n";
            expected += "Harry was slapped by Chump\n";

            _stage.AddActor(Harry, 0);
            _stage.AddActor(Baldy, 1);
            _stage.AddActor(Chump, 2);

            results += Harry.Slap("somebody");

            for (int i = 0; i < NUMBER_OF_ACTORS + 1; i++)
            {
                results += _stage.Update(i);
            }

            Assert.AreEqual(expected, results);
        }
コード例 #2
0
        public void Initialize()
        {
            Image background = new Image("background");
            Image playButton = new Image("playButton");

            playButton.OnMouseClick = (button, x, y, self) => ScreenManager.SetScreen("Game");
            playButton.X            = GameContext.Graphics.PreferredBackBufferWidth / 2 - playButton.Width / 2;
            playButton.Y            = GameContext.Graphics.PreferredBackBufferHeight / 2 - playButton.Height / 2;
            stage.AddActor(background);
            stage.AddActor(playButton);
        }
コード例 #3
0
ファイル: test-threads.cs プロジェクト: Dynalon/clutter-sharp
        static void Main()
        {
            if (!GLib.Thread.Supported)
            {
                GLib.Thread.Init();
            }

            Clutter.Threads.Init();
            Clutter.Threads.Enter();

            ClutterRun.Init();

            stage       = Stage.Default;
            stage.Color = stage_color;
            stage.SetSize(800, 600);

            count_label = new Label("Mono 16", "Counter");
            count_label.SetPosition(350, 50);
            count_label.Show();

            label = new Label("Mono 16", "Press 's' to start");
            label.SetPosition(50, 50);
            label.Show();

            rect = new Rectangle(rect_color);
            rect.SetPosition(150, 150);
            rect.SetSize(25, 25);
            rect.Show();

            timeline      = new Timeline(150, 50);
            timeline.Loop = true;

            alpha     = new Alpha(timeline, Sine.Func);
            behaviour = new BehaviourRotate(alpha,
                                            RotateAxis.ZAxis,
                                            RotateDirection.Cw,
                                            0.0,
                                            360.0);
            behaviour.Apply(rect);

            stage.AddActor(rect);
            stage.AddActor(count_label);
            stage.AddActor(label);

            stage.ButtonPressEvent += delegate { Clutter.Main.Quit(); };
            stage.KeyPressEvent    += HandleKeyPress;

            stage.ShowAll();

            ClutterRun.Main();
            Clutter.Threads.Leave();
        }
コード例 #4
0
    public static void Main()
    {
        random = new Random();

        ClutterRun.Init();

        Stage stage = Stage.Default;

        stage.Fullscreen = true;

        stage.Color = new Clutter.Color(0x10, 0x10, 0x10, 0xff);
        flowers     = new Flower[N_FLOWERS];


        for (int i = 0; i < N_FLOWERS; i++)
        {
            flowers[i]    = new Flower();
            flowers[i].x  = (int)(rand() % stage.Width - (PETAL_MIN + PETAL_VAR) * 2);
            flowers[i].y  = (int)(rand() % stage.Height);
            flowers[i].rv = rand() % 5 + 1;
            flowers[i].v  = rand() % 10 + 2;

            stage.AddActor(flowers[i].ctex);
            flowers[i].ctex.SetPosition(flowers[i].x, flowers[i].y);
        }

        GLib.Timeout.Add(50, new GLib.TimeoutHandler(Tick));

        stage.ShowAll();
        stage.KeyPressEvent += HandleKeyPress;

        ClutterRun.Main();
    }
コード例 #5
0
ファイル: test-scale.cs プロジェクト: Dynalon/clutter-sharp
    static void Main()
    {
        ClutterRun.Init();
        Stage stage = Stage.Default;

        stage.SetSize(200, 200);

        template = new EffectTemplate(new Timeline(90, 120), Sine.Func);

        rect = new Rectangle();
        Clutter.Color rect_bg_color = new Clutter.Color(0x33, 0x22, 0x22, 0xff);
        rect.Color       = rect_bg_color;
        rect.BorderWidth = 10;

        rect.Reactive = true;
        rect.SetSize(100, 100);
        rect.AnchorPointFromGravity = Gravity.Center;
        rect.SetPosition(100, 100);
        rect.ButtonPressEvent += delegate { ScaleRect(); };

        stage.AddActor(rect);
        stage.ShowAll();

        ClutterRun.Main();
    }
コード例 #6
0
        public void Show(Stage stage)
        {
            ClearActions();
            //RemoveCaptureListener(_ignoreTouchDown);
            PreviewTouchDown -= CancelTouchDownHandler;

            _prevKeyboardFocus = null;
            Actor actor = stage.GetKeyboardFocus();

            if (actor != null && !actor.IsDescendentOf(this))
            {
                _prevKeyboardFocus = actor;
            }

            _prevScrollFocus = null;
            actor            = stage.GetScrollFocus();
            if (actor != null && !actor.IsDescendentOf(this))
            {
                _prevScrollFocus = actor;
            }

            Pack();
            SetPosition((float)Math.Round((stage.Width - Width) / 2), (float)Math.Round((stage.Height - Height) / 2));

            stage.AddActor(this);
            stage.SetKeyboardFocus(this);
            stage.SetScrollFocus(this);

            if (FadeDuration > 0)
            {
                Color = Color.MultiplyAlpha(0);
                AddAction(ActionRepo.FadeIn(FadeDuration, Interpolation.Fade));
            }
        }
コード例 #7
0
        public static void Main()
        {
            ClutterRun.Init();

            Stage stage = Stage.Default;

            stage.SetSize(800, 600);
            stage.Color = stage_color;
            stage.Title = "ClutterEntry Test";

            entry = new Entry("Sans 14",
                              "Type something, be sure to use the " +
                              "left/right arrow keys to move the " +
                              "cursor position.");

            entry.Color = entry_color;
            entry.SetSize(600, 50);
            entry.SetPosition(100, 100);

            stage.KeyFocus = entry;
            stage.AddActor(entry);
            stage.ShowAll();

            ClutterRun.Main();
        }
コード例 #8
0
        protected void SetupLabels()
        {
            caption_cover = new CoverCaption(cover_manager, "Sans Bold 10", Clutter.Color.New(1.0f, 1.0f, 1.0f, 1.0f));
            Stage.AddActor(caption_cover);

            caption_track = new TrackCaption(cover_manager, "Sans Bold 10", Clutter.Color.New(1.0f, 1.0f, 1.0f, 1.0f));
            Stage.AddActor(caption_track);
        }
コード例 #9
0
        public void Initialize()
        {
            Image gridBackground = new Image("gridBackground");

            gridBackground.X = 19;
            gridBackground.Y = 63;
            stage.AddActor(gridBackground);
            font   = GameContext.ContentManager.Load <SpriteFont>("Font");
            grid   = new Grid();
            grid.X = 29;
            grid.Y = 73;
            stage.AddActor(grid);
            stage.AddActor(new Image("gameBackground"));
            timer          = new Timer(1000);
            timer.Elapsed += TimerTick;
            timer.Start();
        }
コード例 #10
0
        protected void SetupWidgetBar()
        {
            pm_button   = new PartyModeButton();
            fs_button   = new FullscreenButton();
            sort_button = new SortButton();

            widget_bar = new ClutterWidgetBar(new Actor[] { pm_button, fs_button, sort_button });
            widget_bar.ShowAll();
            Stage.AddActor(widget_bar);
            widget_bar.SetPosition(5, 5);
        }
コード例 #11
0
        protected void SetupViewport()
        {
            Stage.BackgroundColor = Clutter.Color.New(0x00, 0x00, 0x00, 0xff);
            cover_manager.SetRotation(RotateAxis.XAxis, viewportAngleX, Stage.Width / 2, Stage.Height / 2, 0);
            Stage.AddActor(cover_manager);

            cover_manager.EmptyActor.SetToPb(
                IconThemeUtils.LoadIcon(cover_manager.TextureSize, "gtk-stop", "clutterflow-large.png")
                );
            CoverManager.DoubleClickTime = (uint)Gtk.Settings.GetForScreen(this.Screen).DoubleClickTime;
            cover_manager.LowerBottom();
            cover_manager.Show();
        }
コード例 #12
0
ファイル: test-shaders.cs プロジェクト: Dynalon/clutter-sharp
    public static void Main()
    {
        ClutterRun.Init();

        Stage stage = Stage.Default;

        stage.SetSize(512, 384);

        Shader shader = new Shader();

        shader.FragmentSource = shader_sources[current_shader];
        shader.Compile();

        stage.Title = "Shader Test";
        stage.Color = new Clutter.Color(0x61, 0x64, 0x8c, 0xff);

        Timeline timeline = new Timeline(360, 60);

        timeline.Loop = true;

        stage.AddActor(new Label("Mono 16", "Press the Hand"));

        Texture actor = new Texture("redhand.png");

        actor.SetShader(shader);
        actor.Reactive          = true;
        actor.ButtonPressEvent += HandleActorButtonPress;
        stage.AddActor(actor);
        actor.SetShaderParam("brightness", 0.4f);
        actor.SetShaderParam("contrast", -1.9f);
        actor.SetPosition(0, 20);

        stage.ShowAll();
        timeline.Start();

        ClutterRun.Main();
    }
コード例 #13
0
        public void Initialize()
        {
            Image background = new Image("background");

            stage.AddActor(background);

            Image okButton = new Image("okButton");

            okButton.OnMouseClick = (button, x, y, self) =>
            {
                ScreenManager.SetScreen("Menu");
            };
            okButton.Origin = new Vector2(okButton.X / 2, okButton.Y / 2);
            okButton.X      = GameContext.Graphics.PreferredBackBufferWidth / 2 - okButton.Width / 2;
            okButton.Y      = GameContext.Graphics.PreferredBackBufferHeight / 2 - okButton.Height / 2 + 200;
            stage.AddActor(okButton);

            Image gameOver = new Image("gameOver");

            gameOver.X      = GameContext.Graphics.PreferredBackBufferWidth / 2 - gameOver.Width / 2;
            gameOver.Y      = GameContext.Graphics.PreferredBackBufferHeight / 2 - gameOver.Height / 2 - 100;
            gameOver.Origin = new Vector2(gameOver.X / 2, gameOver.Y / 2);
            stage.AddActor(gameOver);
        }
コード例 #14
0
ファイル: StageFactory.cs プロジェクト: scossgrove/RougeTiler
        public static Stage LoadStage(Game game, string heroName, int stageNumber)
        {
            // Get the Saved Data for the hero.
            var heroSave = game.Storage.Heroes.Single(h => h.Name == heroName);

            Stage stage = null;

            // Does the stage already exist?
            if (heroSave.Stages.Any() && heroSave.Stages.Count >= stageNumber + 1)
            {
                stage             = LoadExistingStage(stageNumber, heroSave);
                heroSave.Position = stage.LastHeroPosition;
            }
            else
            {
                stage = CreateNewStage(game, stageNumber);

                // where is the stair?
                VectorBase position = stage.LastHeroPosition;
                heroSave.Position = position;

                // Store the new stage to the system
                heroSave.Stages.Add(stage);
                game.Storage.Save();
            }

            stage.StageNumber = stageNumber;
            stage.CalculateExplorableTiles();

            // Need to associate the monsters with the game
            foreach (var actor in stage.Actors)
            {
                actor.Game = game;
            }

            // Need to load the hero into the stage
            var heroPos = heroSave.Position;

            game.Hero         = new Hero(game, heroPos, heroSave, null, heroName);
            stage.CurrentHero = game.Hero;
            stage.AddActor(game.Hero);
            stage.LastHeroPosition = heroPos;

            return(stage);
        }
コード例 #15
0
        protected override void InitializeCore()
        {
            ShowDebug = true;

            //Debugger.Launch();

            stage = new Stage(Context.GraphicsDevice.Viewport.Width, Context.GraphicsDevice.Viewport.Height, true, Context.GraphicsDevice);

            Skin skin = new Skin(Context.GraphicsDevice, "Data/uiskin.json");

            Context.Input.Processor = stage;

            SelectBox box = new SelectBox(selectItems, skin);

            box.SetPosition(200, 300);

            stage.AddActor(box);
        }
コード例 #16
0
        public static void Main()
        {
            ClutterRun.Init();

            Stage stage = Stage.Default;

            stage.SetSize(200, 200);
            stage.Color = stage_color;
            stage.Title = "Override Test";

            actor = new ScrollActor(actor_color, 20);
            actor.SetSize(100, 100);
            actor.AnchorPointFromGravity = Gravity.Center;
            actor.SetPosition(100, 100);
            stage.AddActor(actor);

            stage.ShowAll();
            ClutterRun.Main();
        }
コード例 #17
0
        protected override void InitializeCore()
        {
            ShowDebug = true;

            Skin skin = new Skin(new TextureAtlas(Context.GraphicsDevice, "Data/uiskin.atlas"));

            skin.Add("white", Color.White);
            skin.Add("red", Color.Red);
            skin.Add("default-font", new BitmapFont(Context.GraphicsDevice, "Data/default.fnt", false));
            skin.Add("default", new TextButtonStyle()
            {
                Down      = skin.GetDrawable("default-round-down"),
                Up        = skin.GetDrawable("default-round"),
                Font      = skin.GetFont("default-font"),
                FontColor = skin.GetColor("white"),
            });
            _stage = new Stage(Context.Window.ClientBounds.Width, Context.Window.ClientBounds.Height, false, Context.GraphicsDevice);

            Context.Input.Processor = _stage;

            TextButton button = new TextButton("Button " + 0, skin)
            {
                X = 200, Y = 200, Width = 150, Height = 100,

                /*X = _rand.Next(0, Context.GraphicsDevice.Viewport.Width - 200),
                 * Y = _rand.Next(0, Context.GraphicsDevice.Viewport.Height - 100),
                 * Width = _rand.Next(50, 200),
                 * Height = _rand.Next(0, 100),*/
            };

            _stage.AddActor(button);

            Context.Window.ClientSizeChanged += (s, e) => {
                _stage.SetViewport(Context.Window.ClientBounds.Width, Context.Window.ClientBounds.Height, false);
            };
        }
コード例 #18
0
    public static void Main()
    {
        ClutterRun.Init();
        Gtk.Application.Init();

        Gtk.Window window = new Gtk.Window(WindowType.Toplevel);
        window.DeleteEvent += HandleDelete;
        Toplevel            = window;

        Gtk.VBox vbox = new Gtk.VBox(false, 6);
        window.Add(vbox);

        Embed clutter = new Embed();

        vbox.Add(clutter);

        Stage stage = clutter.Stage as Stage;

        Gtk.Label label = new Gtk.Label("This is a label");
        vbox.PackStart(label, false, false, 0);

        Gtk.Button button = Gtk.Button.NewWithLabel("This is a button...clicky");
        button.Clicked += HandleClickity;
        vbox.PackStart(button, false, false, 0);

        button          = new Gtk.Button(Gtk.Stock.Quit);
        button.Clicked += delegate { Gtk.Application.Quit(); };

        vbox.PackEnd(button, false, false, 0);

        stage.Color = new Clutter.Color(0x61, 0x64, 0x8c, 0xff);

        uint radius = stage.Width / n_hands / 2;

        SuperOH oh = new SuperOH();

        CurrentOH = oh;
        oh.Group  = new Group();
        oh.Hands  = new Actor[n_hands];

        for (int i = 0; i < n_hands; i++)
        {
            Texture hand_text = new Texture("redhand.png");
            uint    w         = hand_text.Width;
            uint    h         = hand_text.Height;

            oh.Hands[i] = hand_text;

            int x = (int)(stage.Width / 2
                          + radius
                          * Math.Cos(i * Math.PI / (n_hands / 2))
                          - w / 2);
            int y = (int)(stage.Height / 2
                          + radius
                          * Math.Sin(i * Math.PI / (n_hands / 2))
                          - h / 2);

            oh.Hands[i].SetPosition(x, y);

            oh.Group.AddActor(oh.Hands[i]);
        }

        oh.Group.ShowAll();

        oh.FadeTimeline      = new Timeline(2000);
        oh.FadeTimeline.Loop = true;
        BehaviourOpacity behaviour = new BehaviourOpacity(new Alpha(oh.FadeTimeline, Sine.Func), 0xff, 0x00);

        behaviour.Apply(oh.Group);

        stage.AddActor(oh.Group);
        stage.ButtonPressEvent += HandleButtonPress;
        stage.KeyPressEvent    += HandleKeyPress;

        stage.ShowAll();

        timeline      = new Timeline(360, 90);
        timeline.Loop = true;

        timeline.NewFrame += HandleNewFrame;

        window.ExposeEvent += delegate { timeline.Start(); };

        window.SetDefaultSize(400, 600);
        window.ShowAll();

        Gtk.Application.Run();
    }
コード例 #19
0
ファイル: Area.cs プロジェクト: scossgrove/RougeTiler
        /// <summary>
        /// This will build a stage.
        ///
        /// This involves:
        /// 1. Generating TileTypeFactory, Shadows & Explored matrixes.
        /// 2. Generating Items/Loot
        /// 3. Generating and placing Breeds.
        ///
        /// This DOES NOT invole:
        /// 1. placing of the hero.
        /// </summary>
        /// <param name="depth"></param>
        /// <param name="hasExitUp"></param>
        /// <param name="hasExitDown"></param>
        /// <returns></returns>
        public Stage BuildStage(Game game, int depth, bool hasExitUp, bool hasExitDown)
        {
            var level = Levels[depth];

            var stage = new Stage(Width, Height);

            stage.HasExitUp   = hasExitUp;
            stage.HasExitDown = hasExitDown;
            level.BuildStage(stage);


            // Allocate a Hero Position in order to do calculations below
            var heroPosition = stage.StairUpPosition;

            if (heroPosition == null)
            {
                heroPosition = stage.FindOpenTile();
            }
            var tmpHeroSave = new HeroSave("temp", new Warrior());
            var tempHero    = new Hero(game, heroPosition, tmpHeroSave, null, tmpHeroSave.Name);

            stage.CurrentHero = tempHero;
            stage.AddActor(tempHero);
            stage.LastHeroPosition = heroPosition;


            // Place the items.
            var numItems = Rng.Instance.taper(level.NumItems.Value, 3);

            for (var i = 0; i < numItems; i++)
            {
                var itemDepth = PickDepth(depth);
                var drop      = Levels[itemDepth].FloorDrop;

                Action <Item> myAddItem = delegate(Item item)
                {
                    item.Position = stage.FindOpenTile();
                    stage.Items.Add(item);
                };

                drop.SpawnDrop(new AddItem(myAddItem));
            }

            // Place the monsters.
            var numMonsters      = Rng.Instance.taper(level.NumMonsters.Value, 3);
            var placesOfMonsters = new List <VectorBase>();

            for (var i = 0; i < numMonsters; i++)
            {
                var monsterDepth = PickDepth(depth);

                // Place strong monsters farther from the hero.
                var tries = 1;
                if (monsterDepth > depth)
                {
                    tries = 1 + (monsterDepth - depth) * 2;
                }

                VectorBase pos = null;
                for (var attempts = 0; attempts < 5; attempts++)
                {
                    pos = stage.FindDistantOpenTile(tries);
                    if (placesOfMonsters.Contains(pos))
                    {
                        continue;
                    }

                    if (pos != null)
                    {
                        break;
                    }
                }

                if (pos == null)
                {
                    throw new ApplicationException("Invalid position found....");
                }

                var breed = Rng.Instance.Item(Levels[monsterDepth].Breeds);
                stage.SpawnMonster(game, breed, pos);
                placesOfMonsters.Add(pos);
            }

            // TODO: no quest system....
            //game.quest = level.quest.generate(stage);
            //game.quest.announce(game.log);

            // TODO: Temp. Wizard light it.

            /*
             * for (var pos in stage.bounds) {
             * for (var dir in Direction.all) {
             *  if (stage.bounds.contains(pos + dir) &&
             *      stage[pos + dir].isTransparent) {
             *    stage[pos].visible = true;
             *    break;
             *  }
             * }
             * }
             */

            return(stage);
        }
コード例 #20
0
ファイル: SelectBox.cs プロジェクト: jaquadro/MonoGdx
            public void Show(Stage stage)
            {
                stage.AddActor(this);

                Vector2 stageCoords = _selectBox.LocalToStageCoordinates(Vector2.Zero);
                _screenCoords = stageCoords;

                _list.SetItems(_selectBox.Items);
                _list.SelectedIndex = _selectBox.SelectionIndex;

                // Show the list above or below the select box, limited to a number of items and the available height in the stage.
                float itemHeight = _list.ItemHeight;
                float height = itemHeight * (_selectBox.MaxListCount <= 0 ? _selectBox.Items.Length
                    : Math.Min(_selectBox.MaxListCount, _selectBox.Items.Length));
                ISceneDrawable background = Style.Background;
                if (background != null)
                    height += background.TopHeight + background.BottomHeight;

                float heightBelow = stageCoords.Y;
                float heightAbove = stage.Camera.ViewportHeight - stageCoords.Y - _selectBox.Height;

                bool below = true;
                if (height > heightBelow) {
                    if (heightAbove > heightBelow) {
                        below = false;
                        height = Math.Min(height, heightAbove);
                    }
                    else
                        height = heightBelow;
                }

                if (below)
                    Y = stageCoords.Y - height;
                else
                    Y = stageCoords.Y + _selectBox.Height;

                X = stageCoords.X + _selectBox.Style.ListLeftOffset;
                Width = _selectBox.Width + _selectBox.Style.ListLeftOffset + _selectBox.Style.ListRightOffset;
                Height = height;

                ScrollToCenter(0, _list.Height - _selectBox.SelectionIndex * itemHeight - itemHeight / 2, 0, 0);
                UpdateVisualScroll();

                ClearActions();
                Color = new Color(Color.R, Color.G, Color.B, 0);
                AddAction(ActionRepo.FadeIn(.3f, Interpolation.Fade));

                stage.SetScrollFocus(this);
            }
コード例 #21
0
    public VideoApp(string filename)
    {
        Stage stage = Stage.Default;

        stage.Color = new Color(0x00, 0x00, 0x00, 0x00);
        stage.SetSize(1200, 1024);

        vtexture          = new GstVideoTexture();
        vtexture.SyncSize = false;

        // add size changed call back here
        vtexture.SizeChange += HandleSizeChange;

        vtexture.Filename = filename;
        control           = new Group();

        // panel
        control_bg = new Texture("vid-panel.png");

        // play button
        control_play = new Texture("media-actions-start.png");

        // pause button
        control_pause = new Texture("media-actions-pause.png");

        control_seek1           = new Rectangle(new Color(73, 74, 77, 0xee));
        control_seek2           = new Rectangle(new Color(0xcc, 0xcc, 0xcc, 0xff));
        control_seekbar         = new Rectangle(new Color(73, 74, 77, 0xee));
        control_seekbar.Opacity = 0x99;

        // label with name
        string text = System.IO.Path.GetFileName(filename);

        control_label       = new Label("Sans Bold 24", text);
        control_label.Color = new Color(73, 74, 77, 0xee);

        control.AddActor(control_bg);
        control.AddActor(control_play);

        control.AddActor(control_pause);
        control.AddActor(control_seek1);
        control.AddActor(control_seek2);
        control.AddActor(control_seekbar);
        control.AddActor(control_label);

        control.Opacity = 0xee;
        control_play.SetPosition(30, 30);
        control_pause.SetPosition(30, 30);

        control_seek1.SetSize(SEEK_W + 10, SEEK_H + 10);
        control_seek1.SetPosition(200, 100);

        control_seek2.SetSize(SEEK_W, SEEK_H);
        control_seek2.SetPosition(205, 105);

        control_seekbar.SetSize(0, SEEK_H);
        control_seekbar.SetPosition(205, 105);

        control_label.SetPosition(200, 40);

        stage.AddActor(vtexture);
        stage.AddActor(control);

        int x = (int)((stage.Width - control.Width) / 2);
        int y = (int)(stage.Height - (stage.Height / 3));

        control.SetPosition(x, y);

        controls_tl            = new Timeline(10, 30);
        controls_tl.NewFrame  += HandleControlTlNewFrame;
        controls_tl.Completed += HandleControlTimelineCompleted;

        effect1_tl           = new Timeline(30, 90);
        effect1_tl.NewFrame += HandleEffect1TlNewFrame;

        GLib.Timeout.Add(1000, new GLib.TimeoutHandler(Tick));
        stage.MotionEvent      += delegate { ShowControls(true); };
        stage.ButtonPressEvent += HandleButtonPressEvent;
        stage.KeyReleaseEvent  += HandleKeyReleaseEvent;

        vtexture.Playing = true;
        stage.ShowAll();
        control_play.Hide();
    }
コード例 #22
0
            public void Show(Stage stage)
            {
                stage.AddActor(this);

                Vector2 stageCoords = _selectBox.LocalToStageCoordinates(Vector2.Zero);

                _screenCoords = stageCoords;

                _list.SetItems(_selectBox.Items);
                _list.SelectedIndex = _selectBox.SelectionIndex;

                // Show the list above or below the select box, limited to a number of items and the available height in the stage.
                float itemHeight = _list.ItemHeight;
                float height     = itemHeight * (_selectBox.MaxListCount <= 0 ? _selectBox.Items.Length
                    : Math.Min(_selectBox.MaxListCount, _selectBox.Items.Length));
                ISceneDrawable background = Style.Background;

                if (background != null)
                {
                    height += background.TopHeight + background.BottomHeight;
                }

                float heightBelow = stageCoords.Y;
                float heightAbove = stage.Camera.ViewportHeight - stageCoords.Y - _selectBox.Height;

                bool below = true;

                if (height > heightBelow)
                {
                    if (heightAbove > heightBelow)
                    {
                        below  = false;
                        height = Math.Min(height, heightAbove);
                    }
                    else
                    {
                        height = heightBelow;
                    }
                }

                if (below)
                {
                    Y = stageCoords.Y - height;
                }
                else
                {
                    Y = stageCoords.Y + _selectBox.Height;
                }

                X      = stageCoords.X + _selectBox.Style.ListLeftOffset;
                Width  = _selectBox.Width + _selectBox.Style.ListLeftOffset + _selectBox.Style.ListRightOffset;
                Height = height;

                ScrollToCenter(0, _list.Height - _selectBox.SelectionIndex * itemHeight - itemHeight / 2, 0, 0);
                UpdateVisualScroll();

                ClearActions();
                Color = new Color(Color.R, Color.G, Color.B, 0);
                AddAction(ActionRepo.FadeIn(.3f, Interpolation.Fade));

                stage.SetScrollFocus(this);
            }
コード例 #23
0
ファイル: Dialog.cs プロジェクト: jaquadro/MonoGdx
        public void Show(Stage stage)
        {
            ClearActions();
            //RemoveCaptureListener(_ignoreTouchDown);
            PreviewTouchDown -= CancelTouchDownHandler;

            _prevKeyboardFocus = null;
            Actor actor = stage.GetKeyboardFocus();
            if (actor != null && !actor.IsDescendentOf(this))
                _prevKeyboardFocus = actor;

            _prevScrollFocus = null;
            actor = stage.GetScrollFocus();
            if (actor != null && !actor.IsDescendentOf(this))
                _prevScrollFocus = actor;

            Pack();
            SetPosition((float)Math.Round((stage.Width - Width) / 2), (float)Math.Round((stage.Height - Height) / 2));

            stage.AddActor(this);
            stage.SetKeyboardFocus(this);
            stage.SetScrollFocus(this);

            if (FadeDuration > 0) {
                Color = Color.MultiplyAlpha(0);
                AddAction(ActionRepo.FadeIn(FadeDuration, Interpolation.Fade));
            }
        }
コード例 #24
0
        protected override void InitializeCore()
        {
            //Debugger.Launch();
            _stage = new Stage(Context.Window.ClientBounds.Width, Context.Window.ClientBounds.Height, true, Context.GraphicsDevice);
            Skin skin = new Skin(Context.GraphicsDevice, "Data/uiskin.json");

            Context.Input.Processor = _stage;

            _container = new Table();
            _stage.AddActor(_container);
            _container.SetFillParent(true);

            Table table = new Table();

            ScrollPane scroll = new ScrollPane(table, skin);

            /*InputListener stopTouchDown = new DispatchInputListener() {
             *  OnTouchDown = (ev, x, y, pointer, button) => {
             *      ev.Stop();
             *      return false;
             *  },
             * };*/

            table.Pad(10);
            table.Defaults().Configure.ExpandX().Space(4);

            for (int i = 0; i < 100; i++)
            {
                table.Row();
                Cell rowCell = table.Add(new Label(i + "uno", skin));
                rowCell.ExpandX = 1;
                rowCell.FillX   = 1;

                TextButton button = new TextButton(i + "dos", skin);
                table.Add(button);
                button.Clicked += (a, e) => {
                    Console.WriteLine("Clicked");
                };

                Slider slider = new Slider(0, 100, 1, false, skin);
                slider.TouchDown += (s, e) => { e.Stopped = true; };
                table.Add(slider);

                table.Add(new Label(i + "tres long0 long1 long2 long3 long4 long5 long6 long7 long8 long9 long10 long11 long12", skin));
            }

            TextButton flickButton = new TextButton("Flick Scroll", skin.Get <TextButtonStyle>("toggle"))
            {
                IsToggle  = true,
                IsChecked = false,
            };

            flickButton.Checked   += (sender, e) => { scroll.FlickScroll = true; };
            flickButton.Unchecked += (sender, e) => { scroll.FlickScroll = false; };

            TextButton fadeButton = new TextButton("Fade Scrollbars", skin.Get <TextButtonStyle>("toggle"))
            {
                IsToggle  = true,
                IsChecked = false,
            };

            fadeButton.Checked   += (sender, e) => { scroll.FadeScrollBars = true; };
            fadeButton.Unchecked += (sender, e) => { scroll.FadeScrollBars = false; };

            TextButton smoothButton = new TextButton("Smooth Scrolling", skin.Get <TextButtonStyle>("toggle"))
            {
                IsToggle  = true,
                IsChecked = false,
            };

            smoothButton.Checked   += (sender, e) => { scroll.SmoothScrolling = true; };
            smoothButton.Unchecked += (sender, e) => { scroll.SmoothScrolling = false; };

            TextButton onTopButton = new TextButton("Scrollbars On Top", skin.Get <TextButtonStyle>("toggle"))
            {
                IsToggle  = true,
                IsChecked = false,
            };

            onTopButton.Checked   += (sender, e) => { scroll.ScrollBarsOnTop = true; };
            onTopButton.Unchecked += (sender, e) => { scroll.ScrollBarsOnTop = false; };

            _container.Add(scroll).Configure.Expand().Fill().Colspan(4);
            _container.Row().Configure.Space(10).PadBottom(10);
            _container.Add(flickButton).Configure.Right().ExpandX();
            _container.Add(onTopButton);
            _container.Add(smoothButton);
            _container.Add(fadeButton).Configure.Left().ExpandX();
        }
コード例 #25
0
        protected override void InitializeCore()
        {
            ShowDebug = true;

            //Debugger.Launch();

            _spriteBatch = new GdxSpriteBatch(Context.GraphicsDevice);
            _skin        = new Skin(Context.GraphicsDevice, "Data/uiskin.json");
            _texture1    = new TextureContext(Context.GraphicsDevice, "Data/badlogicsmall.jpg", true);
            _texture2    = new TextureContext(Context.GraphicsDevice, "Data/badlogic.jpg", true);

            TextureRegion image        = new TextureRegion(_texture1);
            TextureRegion imageFlipped = new TextureRegion(image);

            imageFlipped.Flip(true, true);
            TextureRegion image2 = new TextureRegion(_texture2);

            _stage = new Stage(Context.GraphicsDevice.Viewport.Width, Context.GraphicsDevice.Viewport.Height, true, Context.GraphicsDevice);

            Context.Input.Processor = _stage;

            ImageButtonStyle style = new ImageButtonStyle(_skin.Get <ButtonStyle>())
            {
                ImageUp   = new TextureRegionDrawable(image),
                ImageDown = new TextureRegionDrawable(imageFlipped),
            };
            ImageButton iconButton = new ImageButton(style);

            Button buttonMulti = new TextButton("Multi\nLine\nToggle", _skin, "toggle")
            {
                IsToggle = true,
            };
            Button imgButton       = new Button(new Image(image), _skin);
            Button imgToggleButton = new Button(new Image(image), _skin, "toggle")
            {
                IsToggle = true,
            };

            Label myLabel = new Label("This is some text.", _skin);

            myLabel.TextWrapping = true;

            Table t = new Table();

            t.Row();
            t.Add(myLabel);

            t.Layout();

            CheckBox  checkbox  = new CheckBox("Check me", _skin);
            Slider    slider    = new Slider(0, 10, 1, false, _skin);
            TextField textField = new TextField("", _skin)
            {
                MessageText = "Click here!",
            };
            SelectBox  dropdown   = new SelectBox(selectEntries, _skin);
            Image      imageActor = new Image(image2);
            ScrollPane scrollPane = new ScrollPane(imageActor);

            MonoGdx.Scene2D.UI.List list = new MonoGdx.Scene2D.UI.List(listEntries, _skin);
            ScrollPane scrollPane2       = new ScrollPane(list, _skin);
            //scrollPane2.FlickScroll = false;
            SplitPane splitPane = new SplitPane(scrollPane, scrollPane2, false, _skin, "default-horizontal");

            _fpsLabel = new Label("fps:", _skin);

            Label     passwordLabel = new Label("Textfield in password mode: ", _skin);
            TextField passwordField = new TextField("", _skin)
            {
                MessageText       = "password",
                PasswordCharacter = '*',
                IsPasswordMode    = true,
            };

            Window window = new Window("Dialog", _skin);

            window.SetPosition(0, 0);
            window.Defaults().SpaceBottom = 10;
            window.Row().Configure.Fill().ExpandX();
            window.Add(iconButton);
            window.Add(buttonMulti);
            window.Add(imgButton);
            window.Add(imgToggleButton);
            window.Row();
            window.Add(checkbox);
            window.Add(slider).Configure.MinWidth(100).FillX().Colspan(3);
            window.Row();
            window.Add(dropdown).Configure.MinWidth(100).FillX();
            window.Add(textField).Configure.MinWidth(100).ExpandX().FillX().Colspan(3);
            window.Row();
            window.Add(splitPane).Configure.Fill().Expand().Colspan(4).MaxHeight(200);
            window.Row();
            window.Add(passwordLabel).Configure.Colspan(2);
            window.Add(passwordField).Configure.MinWidth(100).ExpandX().FillX().Colspan(2);

            window.Pack();

            /*textField.KeyUp += (field, c) => {
             *  if (c == '\n')
             *      field.OnscreenKeyboard.Show(false);
             * };*/

            _stage.AddActor(window);

            MonoGdx.Scene2D.UI.List list2 = new MonoGdx.Scene2D.UI.List(listEntries, _skin);
            ScrollPane scrollPane22       = new ScrollPane(list2, _skin);
            Window     window2            = new Window("ScrollPane", _skin);

            window2.SetPosition(300, 300);
            window2.Defaults().SpaceBottom = 10;
            window2.Row().Configure.Fill().ExpandX();
            window2.Add(scrollPane22).Configure.MaxHeight(250).MaxWidth(150);
            window2.Pack();

            _stage.AddActor(window2);
        }
コード例 #26
0
 protected void SetupSlider()
 {
     slider = new ClutterFlowSlider(400, 40, cover_manager);
     Stage.AddActor(slider);
 }
コード例 #27
0
        protected override void InitializeCore()
        {
            ShowDebug = true;

            _stage = new Stage(Context.GraphicsDevice);
            Context.Input.Processor = _stage;

            Skin skin = new Skin(Context.GraphicsDevice, "Data/uiskin.json");

            Table table = new Table();

            table.SetFillParent(true);
            _stage.AddActor(table);

            Tree tree = new Tree(skin);

            TreeNode node1 = new TreeNode(new TextButton("moo1", skin));
            TreeNode node2 = new TreeNode(new TextButton("moo2", skin));
            TreeNode node3 = new TreeNode(new TextButton("moo3", skin));
            TreeNode node4 = new TreeNode(new TextButton("moo4", skin));
            TreeNode node5 = new TreeNode(new TextButton("moo5", skin));

            tree.Add(node1);
            tree.Add(node2);
            node2.Add(node3);
            node3.Add(node4);
            tree.Add(node5);

            Label label = new Label("", skin, "default");

            tree.SelectionChanged += (sender, e) => {
                if (e.AddedItems.Count == 0)
                {
                    return;
                }

                StringBuilder txt = new StringBuilder();
                foreach (TreeNode node in e.AddedItems)
                {
                    TextButton button = node.Actor as TextButton;
                    txt.Append(button.Text + ", ");
                }

                label.Text = txt.ToString();
                label.Invalidate();
            };

            (node5.Actor as Button).Clicked += (sender, e) => {
                tree.Remove(node4);
            };

            //node5.Actor.AddListener(new DispatchClickListener() {
            //    OnClicked = (ev, x, y) => { tree.Remove(node4); }
            //});

            table.Add(tree).Configure.Fill().Expand();
            table.Row();
            table.Add(label).Configure.Fill().Expand();

            //Debugger.Launch();
        }
コード例 #28
0
        protected override void InitializeCore()
        {
            ShowDebug = true;

            _texture = new TextureContext(Context.GraphicsDevice, "Data/badlogicsmall.jpg", true);
            _font    = new BitmapFont(Context.GraphicsDevice, "Data/arial-15.fnt", "data/arial-15_00.png", false);

            _stage = new Stage(480, 320, true, Context.GraphicsDevice);

            float loc = (NumSprites * (32 + Spacing) - Spacing) / 2;

            for (int i = 0; i < NumGroups; i++)
            {
                Group group = new Group()
                {
                    X       = (float)(_rand.NextDouble() * (_stage.Width - NumSprites * (32 + Spacing))),
                    Y       = (float)(_rand.NextDouble() * (_stage.Height - NumSprites * (32 + Spacing))),
                    OriginX = loc,
                    OriginY = loc,
                    //Rotation = MathHelper.ToRadians(30),
                };

                FillGroup(group, _texture);
                _stage.AddActor(group);
            }

            _uiTexture = new TextureContext(Context.GraphicsDevice, "Data/ui.png", true);
            _ui        = new Stage(480, 320, false, Context.GraphicsDevice);

            Image blend = new Image(new TextureRegion(_uiTexture, 0, 0, 64, 32))
            {
                Align   = Alignment.Center,
                Scaling = Scaling.None,
            };

            // Listener
            blend.Y = _ui.Height - 64;

            Image rotate = new Image(new TextureRegion(_uiTexture, 64, 0, 64, 32))
            {
                Align   = Alignment.Center,
                Scaling = Scaling.None,
            };

            rotate.TouchDown += (s, e) => {
                _rotateSprites = !_rotateSprites;
                e.Handled      = true;
            };

            /*rotate.AddListener(new TouchListener() {
             *  Down = (e, x, y, pointer, button) => {
             *      _rotateSprites = !_rotateSprites;
             *      return true;
             *  }
             * });*/
            rotate.SetPosition(64, blend.Y);

            Image scale = new Image(new TextureRegion(_uiTexture, 64, 32, 64, 32))
            {
                Align   = Alignment.Center,
                Scaling = Scaling.None,
            };

            scale.TouchDown += (s, e) => {
                _scaleSprites = !_scaleSprites;
                e.Handled     = true;
            };

            /*scale.AddListener(new TouchListener() {
             *  Down = (e, x, y, pointer, button) => {
             *      _scaleSprites = !_scaleSprites;
             *      return true;
             *  }
             * });*/
            scale.SetPosition(128, blend.Y);

            _ui.AddActor(blend);
            _ui.AddActor(rotate);
            _ui.AddActor(scale);

            /*_fps = new Label("fps: 0", new LabelStyle(_font, Color.White));
             * _fps.SetPosition(10, 30);
             * _fps.Color = new Color(0, 1f, 0, 1f);
             * _ui.AddActor(_fps);*/
        }