Ejemplo n.º 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);
		}
        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);
        }
Ejemplo n.º 3
0
		protected override void OnStart()
		{
			var layout = new LinearPanel()
			{
				ItemSpan = new Vector2DF(0, 36),
			};
			var selector = new Selector<int, Control>(CreateController(), layout);
			selector.BindKey(Control.Down, Control.Up, Control.Decide, Control.Cancel);
			selector.Cursor.Texture = Engine.Graphics.CreateTexture2D("ListCursor.png");
			selector.IsControllerUpdated = true;

			var font = Engine.Graphics.CreateDynamicFont("", 20, new Color(255, 0, 0, 255), 0, new Color(0, 0, 0, 0));

			var size = selector.Cursor.Texture.Size;

			var scroll = new ScrollLayer()
			{
				Position = new Vector2DF(30, 30),
				CameraSize = new Vector2DF(200, 200),
				BindingAreaRange = new RectF(0, 25, 200, 150),
				BoundaryStartingPosition = new Vector2DF(0, 0),
				BoundaryEndingPosition = layout.ItemSpan * 10 + new Vector2DF(200, 0),
			};
			var areaChanged = selector.OnSelectionChanged
				.Select(c => selector.GetItemForChocie(c).Position)
				.Select(p => new RectF(p.X, p.Y, size.X, size.Y));
			scroll.SubscribeSeeingArea(areaChanged);

			var scene = new Scene();
			Engine.ChangeScene(scene);
			scene.AddLayer(scroll);
			scroll.AddObject(selector);

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

			var heart1 = new TextureObject2D()
			{
				Position = scroll.BoundaryEndingPosition - new Vector2DF(50, 50),
				Texture = Engine.Graphics.CreateTexture2D("Heart.png"),
			};
			scroll.AddObject(heart1);
			var heart2 = new TextureObject2D()
			{
				Position = scroll.BoundaryStartingPosition - new Vector2DF(0, 50),
				Texture = Engine.Graphics.CreateTexture2D("Heart.png"),
			};
			scroll.AddObject(heart2);

			var viewer = new ScrollBoundViewer(scroll);
			scroll.AddObject(viewer);
		}
Ejemplo n.º 4
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);
		}
Ejemplo n.º 5
0
		protected override void OnStart()
		{
			var cursorTexture = Engine.Graphics.CreateTexture2D("ListCursor.png");
			var font = Engine.Graphics.CreateFont("MPlusB.aff");

			Func<LinearPanel> createLayouter = () => new LinearPanel()
			{
				ItemSpan = new Vector2DF(0, 40)
			};
			Selector<int, Control>[] selectors = Enumerable.Range(0, 2)
				.Select(x => new Selector<int, Control>(CreateController(), createLayouter()))
				.ToArray();

			var topLayouter = new LinearPanel()
			{
				ItemSpan = new Vector2DF(300, 0)
			};
			var topSelector = new Selector<int, Control>(CreateController(), topLayouter);
			topSelector.BindKey(Control.Right, Control.Left, Control.Decide, Control.Cancel);
			topSelector.IsActive = true;

			topSelector.OnSelectionChanged.Subscribe(x =>
			{
				foreach (var selector in selectors)
				{
					selector.IsActive = false;
					selector.HideSelection = true;
				}
				selectors[x].IsActive = true;
				selectors[x].HideSelection = false;
			});

			for (int j = 0; j < selectors.Length; j++)
			{
				selectors[j].BindKey(Control.Down, Control.Up, Control.Decide, Control.Cancel);
				selectors[j].Cursor.Texture = cursorTexture;
				for(int i = 0; i < 5; i++)
				{
					selectors[j].AddChoice(i, new TextObject2D()
					{
						Text = $"選択肢{i}",
						Font = font,
					});
				}
				selectors[j].OnSelectionChanged.Subscribe(x =>
				{
					foreach (var selector in selectors)
					{
						selector.ChangeSelection(x);
					}
				});
				topSelector.AddChoice(j, selectors[j]);
			}

			Engine.AddObject2D(topSelector);
		}
Ejemplo n.º 6
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);
        }
		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);
		}
Ejemplo n.º 8
0
			public ItemInfo(LinearPanel owner, Object2D obj)
			{
				this.owner = owner;
				Object = obj;
				LayoutedPosition = obj.Position;
			}