コード例 #1
0
		protected override void OnStart()
		{
			var scene = new ReactiveScene();
			var layer = new ReactiveLayer2D();

			var layout = new LinearPanel()
			{
				ItemSpan = new Vector2DF(0, 36),
				Position = new Vector2DF(20, 20),
			};
			layout.SetEasingBehaviorUp(EasingStart.StartRapidly2, EasingEnd.EndSlowly3, 10);
			Func<Object2D> cursorCreator = () => new TextureObject2D()
			{
				Texture = Engine.Graphics.CreateTexture2D("ListCursor.png"),
				Color = new Color(0, 255, 0, 128),
			};

			selector = new MultiSelector<int, Control>(CreateController(), layout, cursorCreator)
			{
				Loop = true,
				CursorOffset = new Vector2DF(-5, -3),
			};
			selector.Cursor.Texture = Engine.Graphics.CreateTexture2D("ListCursor.png");
			selector.BindKey(Control.Down, Control.Up, Control.Decide, Control.Cancel, Control.Sub);
			selector.SetEasingBehaviorUp(EasingStart.StartRapidly2, EasingEnd.EndSlowly3, 10);

			font = Engine.Graphics.CreateDynamicFont("", 20, new Color(255, 255, 255, 255), 0, new Color(0, 0, 0, 255));
			for(int i = 0; i < 8; i++)
			{
				var obj = new ListItem()
				{
					Text = $"選択肢{i}",
					Font = font,
				};
				Engine.AddObject2D(obj);
				selector.AddChoice(i, obj);
			}

			var moveSound = Engine.Sound.CreateSoundSource("kachi38.wav", true);
			var decideSound = Engine.Sound.CreateSoundSource("pi78.wav", true);
			var cancelSound = Engine.Sound.CreateSoundSource("pi11.wav", true);

			selector.OnSelectionChanged.Subscribe(i => Engine.Sound.Play(moveSound));
			selector.OnDecide.Subscribe(i => Engine.Sound.Play(decideSound));
			selector.OnCancel.Subscribe(i => Engine.Sound.Play(cancelSound));
			selector.OnAdd.Subscribe(i => Engine.Sound.Play(decideSound));
			selector.OnRemove.Subscribe(i => Engine.Sound.Play(cancelSound));
			selector.OnDecideForMulti.Subscribe(xs =>
			{
				foreach(var x in xs.ToList())
				{
					selector.GetItemForChocie(x)?.Dispose();
					selector.RemoveChoice(x);
				}
			});

			Engine.ChangeScene(scene);
			scene.AddLayer(layer);
			layer.AddObject(selector);
		}
コード例 #2
0
        protected override void OnStart()
        {
            collection = new ObservableCollection<int>();

			var scene = new ReactiveScene();
			var layer = new ReactiveLayer2D();

            var layout = new LinearPanel()
            {
                ItemSpan = new Vector2DF(0, 36),
            };

            var selector = new Selector<int, Control>(CreateController(), layout);
            selector.Cursor.Texture = Engine.Graphics.CreateTexture2D("ListCursor.png");
            selector.BindKey(Control.Down, Control.Up, Control.Decide, Control.Cancel);
            selector.Loop = true;

            font = Engine.Graphics.CreateDynamicFont("", 20, new Color(255, 255, 255, 255), 0, new Color(0, 0, 0, 255));
            CollectionBinderForSelector<int>.Bind(selector, collection, c => new ListItem()
            {
                Font = font,
                Text = $"追加アイテム{c}",
            }, false);

			Engine.ChangeScene(scene);
			scene.AddLayer(layer);
			layer.AddObject(selector);
        }
コード例 #3
0
        protected override void OnStart()
        {
			var scene = new ReactiveScene();
			var layer = new ReactiveLayer2D();

            var controller = new KeyboardController<int>();
            controller.BindKey(Keys.Down, 0);
            controller.BindKey(Keys.Up, 1);
            controller.BindKey(Keys.Z, 2);
            controller.BindKey(Keys.X, 3);

            var layout = new LinearPanel()
            {
                ItemSpan = new Vector2DF(0, 36),
                Position = new Vector2DF(20, 20),
            };
            layout.SetEasingBehaviorUp(EasingStart.StartRapidly2, EasingEnd.EndSlowly3, 10);
            selector = new Selector<int, int>(controller, layout)
            {
                Loop = true,
                CursorOffset = new Vector2DF(-5, -3),
            };
			selector.Cursor.Texture = Engine.Graphics.CreateTexture2D("ListCursor.png");
			selector.BindKey(0, 1, 2, 3);
            selector.SetEasingBehaviorUp(EasingStart.StartRapidly2, EasingEnd.EndSlowly3, 10);

            font = Engine.Graphics.CreateDynamicFont("", 20, new Color(255, 255, 255, 255), 0, new Color(0, 0, 0, 255));
            for(int i = 0; i < 8; i++)
            {
                var obj = new ListItem()
                {
                    Text = $"選択肢{i}",
                    Font = font,
                };
                Engine.AddObject2D(obj);
                selector.AddChoice(i, obj);
            }

            var moveSound = Engine.Sound.CreateSoundSource("kachi38.wav", true);
            var decideSound = Engine.Sound.CreateSoundSource("pi78.wav", true);
            var cancelSound = Engine.Sound.CreateSoundSource("pi11.wav", true);

            selector.OnSelectionChanged.Subscribe(i => Engine.Sound.Play(moveSound));
            selector.OnDecide.Subscribe(i =>
            {
                Engine.Sound.Play(decideSound);
            });
            selector.OnCancel.Subscribe(i =>
            {
                Engine.Sound.Play(cancelSound);
            });

			Engine.ChangeScene(scene);
			scene.AddLayer(layer);
			layer.AddObject(selector);
		}
コード例 #4
0
        protected override void OnStart()
        {
            selector = new ScrollingSelector<int, Control>(CreateController())
            {
                Position = new Vector2DF(60, 32),
                CursorOffset = new Vector2DF(-5, 3),
                LineSpan = 36,
                LineWidth = 360,
                BoundLines = 8,
                ExtraLinesOnStarting = 1,
                ExtraLinesOnEnding = 1,
                IsControllerUpdated = true,
				Loop = true,
            };
            selector.BindKey(Control.Down, Control.Up, Control.Decide, Control.Cancel);
            selector.Cursor.Texture = Engine.Graphics.CreateTexture2D("ListCursor.png");
            selector.SetEasingScrollUp(EasingStart.StartRapidly2, EasingEnd.EndSlowly3, 10);

            font = Engine.Graphics.CreateFont("MPlusB.aff");

            var scene = new ReactiveScene();

			var background = new Layer2D();
			background.AddObject(new GeometryObject2D()
			{
				Shape = new RectangleShape() { DrawingArea = new RectF(0, 0, 640, 480) },
				Color = new Color(255, 255, 255, 255),
			});
			background.AddObject(new TextureObject2D()
			{
				Texture = Engine.Graphics.CreateTexture2D("ListWindowLarge.png"),
				Position = new Vector2DF(30, 30),
				DrawingPriority = 1,
			});
			scene.AddLayer(background);

			scene.AddLayer(selector);
			Engine.ChangeScene(scene);

			for(int i = 0; i < 15; i++)
            {
                var obj = new TextObject2D()
                {
                    Font = font,
                    Text = $"アイテム{i}",
					Color = new Color(225, 160, 0, 255),
                };
                selector.AddChoice(i, obj);
            }

            selector.SetDebugCameraUp();
        }
コード例 #5
0
        protected override void OnStart()
        {
            layout = new LinearPanel();
            Engine.AddObject2D(layout);

            font = Engine.Graphics.CreateDynamicFont("", 20, new Color(255, 255, 255, 255), 0, new Color(0, 0, 0, 255));
            for(int i = 0; i < 7; i++)
            {
                var obj = new TextObject2D()
                {
                    Font = font,
                    Text = $"選択肢{i}",
                };
                layout.AddItem(obj);
                Engine.AddObject2D(obj);
            }

            layout.StartingOffset = new Vector2DF(10, 10);
            layout.ItemSpan = new Vector2DF(5, 20);
        }
コード例 #6
0
		protected override void OnStart()
		{
			font = Engine.Graphics.CreateDynamicFont("", 20, new Color(255, 0, 0, 255), 0, new Color(0, 0, 0, 0));

			selector = new ScrollingSelector<int, Control>(CreateController())
			{
				IsControllerUpdated = true,
				Position = new Vector2DF(30, 30),
				LineSpan = 36,
				BoundLines = 4,
				LineWidth = 360,
				ExtraLinesOnStarting = 1,
				ExtraLinesOnEnding = 1,
			};
			selector.BindKey(Control.Down, Control.Up, Control.Decide, Control.Cancel);
			selector.Cursor.Texture = Engine.Graphics.CreateTexture2D("ListCursor.png");
			selector.SetEasingScrollUp(EasingStart.StartRapidly2, EasingEnd.EndSlowly3, 10);

			collection = new ObservableCollection<int>();

			for(int i = 0; i < 5; i++)
			{
				collection.Add(i);
			}

			CollectionBinderForSelector<int>.Bind(selector, collection, i => new ActivatableItem($"アイテム{i}"), true);

			for(int i = 5; i < 10; i++)
			{
				collection.Add(i);
			}

			var scene = new Scene();
			scene.AddLayer(selector);
			Engine.ChangeScene(scene);
		}
コード例 #7
0
		protected override void OnStart()
		{
			font = Engine.Graphics.CreateDynamicFont("", 20, new Color(255, 0, 0, 255), 0, new Color(0, 0, 0, 0));

			var layout = new LinearPanel()
			{
				ItemSpan = new Vector2DF(0, 40),
			};

			var texture = Engine.Graphics.CreateTexture2D("ListCursor.png");
			selector = new MultiSelector<int, Control>(
				CreateController(),
				layout,
				() => new TextureObject2D
				{
					Texture = texture,
					Color = new Color(0, 255, 0, 128),
				})
			{
				IsControllerUpdated = true,
				Position = new Vector2DF(30, 30),
			};
			
			selector.BindKey(Control.Down, Control.Up, Control.Decide, Control.Cancel, Control.Sub);
			selector.Cursor.Texture = Engine.Graphics.CreateTexture2D("ListCursor.png");
			layout.SetEasingBehaviorUp(EasingStart.StartRapidly2, EasingEnd.EndSlowly3, 10);
			selector.SetEasingBehaviorUp(EasingStart.StartRapidly2, EasingEnd.EndSlowly3, 10);
			selector.OnDecideForMulti.Subscribe(xs =>
			{
				foreach(var item in xs.ToArray())
				{
					collection.Remove(item);
				}
			});

			collection = new ObservableCollection<int>();

			for(int i = 0; i < 5; i++)
			{
				collection.Add(i);
			}

			CollectionBinderForSelector<int>.Bind(selector, collection, i => new TextObject2D()
			{
				Font = font,
				Text = $"アイテム{i}",
				Color = new Color(0, 0, 0, 255),
			}, true);

			for(int i = 5; i < 10; i++)
			{
				collection.Add(i);
			}

			Engine.AddObject2D(new GeometryObject2D
			{
				Shape = new RectangleShape { DrawingArea = new RectF(0, 0, 640, 480) },
				DrawingPriority = -1
			});
			Engine.AddObject2D(selector);
		}
コード例 #8
0
ファイル: Object2D.cs プロジェクト: Pctg-x8/Altseed
 /// <summary>
 /// 通常の描画に加えて文字列を描画する。
 /// </summary>
 /// <param name="pos">描画位置</param>
 /// <param name="color">頂点色</param>
 /// <param name="font">フォント</param>
 /// <param name="text">文字列</param>
 /// <param name="writingDirection">行方向</param>
 /// <param name="alphaBlend">アルファブレンドの種類</param>
 /// <param name="priority">描画の優先順位(大きいほど前面に描画される)</param>
 /// <remarks>
 /// OnDrawAdditionallyの中以外では実行してはいけない。
 /// </remarks>
 protected void DrawTextAdditionally(Vector2DF pos, Color color, Font font, string text, WritingDirection writingDirection, AlphaBlendMode alphaBlend, int priority)
 {
     Layer.DrawTextAdditionally(pos, color, font, text, writingDirection, alphaBlend, priority);
 }
コード例 #9
0
ファイル: Layer2D.cs プロジェクト: Pctg-x8/Altseed
 /// <summary>
 /// 通常の描画に加えて文字列を描画する。
 /// </summary>
 /// <param name="pos">描画位置</param>
 /// <param name="color">頂点色</param>
 /// <param name="font">フォント</param>
 /// <param name="text">文字列</param>
 /// <param name="writingDirection">行方向</param>
 /// <param name="alphaBlend">アルファブレンドの種類</param>
 /// <param name="priority">描画の優先順位(大きいほど前面に描画される)</param>
 /// <remarks>
 /// OnDrawAdditionallyの中以外では実行してはいけない。
 /// </remarks>
 public void DrawTextAdditionally(Vector2DF pos, Color color, Font font, string text, WritingDirection writingDirection, AlphaBlendMode alphaBlend, int priority)
 {
     if (coreLayer2D == null) return;
     coreLayer2D.DrawTextAdditionally(pos, color, IG.GetFont(font), text, (swig.WritingDirection)writingDirection, (swig.AlphaBlendMode)alphaBlend, priority);
 }
コード例 #10
0
ファイル: InternalGetter.cs プロジェクト: Pctg-x8/Altseed
 public static swig.Font GetFont(Font o)
 {
     if (o == null) return null;
     return o.CoreInstance;
 }