コード例 #1
0
ファイル: Label.cs プロジェクト: whztt07/DeltaEngine
		internal Label(Theme theme, Material material, Rectangle drawArea)
			: base(theme, material, drawArea)
		{
			var fontText = new FontText(theme.Font, "", GetFontTextDrawArea());
			Add(fontText);
			AddChild(fontText);
		}
コード例 #2
0
ファイル: ThemeTests.cs プロジェクト: whztt07/DeltaEngine
		public void LoadThemeFromFile()
		{
			CreateSampleTheme();
			var loadedData = new Theme();
			loadedData.LoadFromFile(dataStream);
			Assert.AreEqual(theme.Label, loadedData.Label);
			Assert.AreEqual(theme.Button, loadedData.Button);
			Assert.AreEqual(theme.ButtonDisabled, loadedData.ButtonDisabled);
			Assert.AreEqual(theme.ButtonMouseover, loadedData.ButtonMouseover);
			Assert.AreEqual(theme.ButtonPressed, loadedData.ButtonPressed);
			Assert.AreEqual(theme.DropdownListBox, loadedData.DropdownListBox);
			Assert.AreEqual(theme.DropdownListBoxDisabled, loadedData.DropdownListBoxDisabled);
			Assert.AreEqual(theme.RadioButtonBackground, loadedData.RadioButtonBackground);
			Assert.AreEqual(theme.RadioButtonBackgroundDisabled, loadedData.RadioButtonBackgroundDisabled);
			Assert.AreEqual(theme.RadioButtonDisabled, loadedData.RadioButtonDisabled);
			Assert.AreEqual(theme.RadioButtonNotSelected, loadedData.RadioButtonNotSelected);
			Assert.AreEqual(theme.RadioButtonNotSelectedMouseover, loadedData.RadioButtonNotSelectedMouseover);
			Assert.AreEqual(theme.RadioButtonSelected, loadedData.RadioButtonSelected);
			Assert.AreEqual(theme.RadioButtonSelectedMouseover, loadedData.RadioButtonSelectedMouseover);
			Assert.AreEqual(theme.Scrollbar, loadedData.Scrollbar);
			Assert.AreEqual(theme.ScrollbarDisabled, loadedData.ScrollbarDisabled);
			Assert.AreEqual(theme.ScrollbarPointer, loadedData.ScrollbarPointer);
			Assert.AreEqual(theme.ScrollbarPointerDisabled, loadedData.ScrollbarPointerDisabled);
			Assert.AreEqual(theme.ScrollbarPointerMouseover, loadedData.ScrollbarPointerMouseover);
			Assert.AreEqual(theme.SelectBox, loadedData.SelectBox);
			Assert.AreEqual(theme.SelectBoxDisabled, loadedData.SelectBoxDisabled);
			Assert.AreEqual(theme.Slider, loadedData.Slider);
			Assert.AreEqual(theme.SliderDisabled, loadedData.SliderDisabled);
			Assert.AreEqual(theme.SliderPointer, loadedData.SliderPointer);
			Assert.AreEqual(theme.SliderPointerDisabled, loadedData.SliderPointerDisabled);
			Assert.AreEqual(theme.SliderPointerMouseover, loadedData.SliderPointerMouseover);
			Assert.AreEqual(theme.TextBox, loadedData.TextBox);
			Assert.AreEqual(theme.TextBoxDisabled, loadedData.TextBoxDisabled);
			Assert.AreEqual(theme.TextBoxFocused, loadedData.TextBoxFocused);
		}
コード例 #3
0
ファイル: TextBox.cs プロジェクト: remy22/DeltaEngine
 public TextBox(Theme theme, Rectangle drawArea, string text = "")
     : base(theme, theme.TextBox, drawArea)
 {
     Text = text;
     PreviousText = text;
     State.CanHaveFocus = true;
     Start<Keyboard>();
 }
コード例 #4
0
ファイル: RadioButton.cs プロジェクト: whztt07/DeltaEngine
		public RadioButton(Theme theme, Rectangle drawArea, string text = "")
			: base(theme, theme.RadioButtonBackground, drawArea)
		{
			Text = text;
			var selector = new Picture(theme, theme.RadioButtonNotSelected, GetSelectorDrawArea());
			Add(selector);
			AddChild(selector);
		}
コード例 #5
0
ファイル: Scrollbar.cs プロジェクト: remy22/DeltaEngine
 public Scrollbar(Theme theme, Rectangle drawArea)
     : base(theme, theme.Scrollbar, drawArea)
 {
     var data = new Data { MinValue = 0, MaxValue = 99, LeftValue = 90, ValueWidth = 10 };
     Add(data);
     Add(new Picture(theme, theme.ScrollbarPointer, Rectangle.Unused));
     AddChild(Pointer);
 }
コード例 #6
0
ファイル: Slider.cs プロジェクト: whztt07/DeltaEngine
		public Slider(Theme theme, Rectangle drawArea)
			: base(theme, theme.Slider, drawArea)
		{
			var data = new Data { MinValue = 0, Value = 100, MaxValue = 100 };
			Add(data);
			Add(new Picture(theme, theme.SliderPointer, Rectangle.Unused));
			AddChild(Pointer);
		}
コード例 #7
0
ファイル: Menu.cs プロジェクト: whztt07/DeltaEngine
			public HowToPlaySubMenu(Scene parent, Theme menuTheme)
			{
				this.parent = parent;
				this.menuTheme = menuTheme;
				SetQuadraticBackground("SidescrollerMainMenuBackground");
				AddControlDescription();
				AddBackButton();
			}
コード例 #8
0
ファイル: DrenchMenu.cs プロジェクト: whztt07/DeltaEngine
		private void CreateTheme()
		{
			theme = new Theme
			{
				Button = new Material(ShaderFlags.Position2DTextured, "SimpleButtonNormal"),
				ButtonMouseover = new Material(ShaderFlags.Position2DTextured, "SimpleButtonHover"),
				ButtonPressed = new Material(ShaderFlags.Position2DTextured, "SimpleButtonPressed"),
			};
		}
コード例 #9
0
ファイル: ThemeTests.cs プロジェクト: whztt07/DeltaEngine
		public void SaveAndLoadDefaultTheme()
		{
			var theme = new Theme();
			var stream = BinaryDataExtensions.SaveToMemoryStream(theme);
			var loadedTheme = (Theme)stream.CreateFromMemoryStream();
			Assert.IsTrue(AreMaterialsEqual(theme.ButtonMouseover, loadedTheme.ButtonMouseover));
			Assert.IsTrue(AreMaterialsEqual(theme.ScrollbarPointer, loadedTheme.ScrollbarPointer));
			Assert.IsTrue(AreMaterialsEqual(theme.TextBoxFocused, loadedTheme.TextBoxFocused));
		}
コード例 #10
0
ファイル: Menu.cs プロジェクト: whztt07/DeltaEngine
		private void CreateMenuTheme()
		{
			SetQuadraticBackground("SidescrollerMainMenuBackground");
			menuTheme = new Theme
			{
				Button = new Material(ShaderFlags.Position2DTextured, "SidescrollerButtonDefault"),
				ButtonMouseover = new Material(ShaderFlags.Position2DTextured, "SidescrollerButtonHover"),
				ButtonPressed = new Material(ShaderFlags.Position2DTextured, "SidescrollerButtonPressed")
			};
		}
コード例 #11
0
ファイル: Menu.cs プロジェクト: whztt07/DeltaEngine
		private void CreateMenuTheme()
		{
			SetViewportBackground("SnakeMainMenuBackground");
			menuTheme = new Theme
			{
				Button = new Material(ShaderFlags.Position2DTextured, "SnakeButtonDefault"),
				ButtonMouseover = new Material(ShaderFlags.Position2DTextured, "SnakeButtonHover"),
				ButtonPressed = new Material(ShaderFlags.Position2DTextured, "SnakeButtonPressed")
			};
		}
コード例 #12
0
ファイル: MainMenu.cs プロジェクト: whztt07/DeltaEngine
			public HowToPlaySubMenu(MainMenu parent, Theme backTheme)
			{
				this.parent = parent;
				this.backTheme = backTheme;
				Add(new Sprite(new Material(ShaderFlags.Position2DColoredTextured, "BreakoutLogo"),
					Rectangle.FromCenter(0.5f, ScreenSpace.Current.Viewport.Top + 0.2f, 0.7f, 0.3f)));
				SetViewportBackground("Background");
				AddControlDescription();
				AddBackButton();
			}
コード例 #13
0
ファイル: Game.cs プロジェクト: whztt07/DeltaEngine
		protected Game(Logic logic)
		{
			this.logic = logic;
			buttonShader =
				ContentLoader.Create<Shader>(new ShaderCreationData(ShaderFlags.Position2DColoredTextured));
			buttonImage = new Theme().Button.DiffuseMap;
			buttons = new InteractiveButton[logic.Board.Width, logic.Board.Height];
			ArrangeScene();
			ScreenSpace.Current.ViewportSizeChanged += ArrangeScene;
		}
コード例 #14
0
ファイル: ThemeTests.cs プロジェクト: whztt07/DeltaEngine
		public void SaveAndLoadModifiedTheme()
		{
			var theme = new Theme();
			theme.Slider = new Material(ShaderFlags.Position2DColoredTextured, "DeltaEngineLogo")
			{
				DefaultColor = Color.Red
			};
			var stream = BinaryDataExtensions.SaveToMemoryStream(theme);
			var loadedTheme = (Theme)stream.CreateFromMemoryStream();
			Assert.IsTrue(AreMaterialsEqual(theme.Slider, loadedTheme.Slider));
		}
コード例 #15
0
ファイル: PictureTests.cs プロジェクト: remy22/DeltaEngine
 public void SaveAndLoad()
 {
     var material = new Material(Shader.Position2DColorUV, "DeltaEngineLogo");
     var theme = new Theme();
     theme.SliderPointer = material;
     var picture = new Picture(theme, material, Rectangle.HalfCentered);
     var stream = BinaryDataExtensions.SaveToMemoryStream(picture);
     var loadedPicture = (Picture)stream.CreateFromMemoryStream();
     Assert.AreEqual("DeltaEngineLogo", loadedPicture.Material.DiffuseMap.Name);
     Assert.AreEqual("DeltaEngineLogo", loadedPicture.Get<Theme>().SliderPointer.DiffuseMap.Name);
     Assert.AreEqual(Rectangle.HalfCentered, loadedPicture.DrawArea);
 }
コード例 #16
0
ファイル: DropdownList.cs プロジェクト: whztt07/DeltaEngine
		public DropdownList(Theme theme, Rectangle drawArea, List<object> values)
			: base(theme, theme.DropdownListBox, drawArea)
		{
			var selectBox = new SelectBox(theme,
				new Rectangle(drawArea.Left, drawArea.Top + drawArea.Height, drawArea.Width,
					drawArea.Height), values) { IsVisible = false };
			selectBox.LineClicked += SelectNewValue;
			Add(selectBox);
			AddChild(selectBox);
			Values = values;
			Clicked += ToggleSelectionBoxVisibility;
			FontText.HorizontalAlignment = HorizontalAlignment.Left;
		}
コード例 #17
0
ファイル: SelectBox.cs プロジェクト: whztt07/DeltaEngine
		public SelectBox(Theme theme, Rectangle firstLineDrawArea, List<object> values)
			: base(theme, theme.SelectBox, firstLineDrawArea)
		{
			var scrollbar = new Scrollbar(theme, Rectangle.Unused) { Rotation = 90 };
			Add(scrollbar);
			AddChild(scrollbar);
			Clicked += ClickLine;
			if (values == null || values.Count == 0)
				throw new MustBeAtLeastOneValue();
			Add(new Data(values, firstLineDrawArea, values.Count));
			DrawArea = new Rectangle(firstLineDrawArea.Left, firstLineDrawArea.Top,
				firstLineDrawArea.Width, firstLineDrawArea.Height * values.Count);
			Values = values;
		}
コード例 #18
0
ファイル: BasePage.cs プロジェクト: whztt07/DeltaEngine
		public void AddButton(MenuButton code, float width, float ratio)
		{
			var material = new Material(ShaderFlags.Position2DTextured, code + "Button");
			var theme = new Theme
			{
				Button = material,
				ButtonMouseover =
					new Material(ShaderFlags.Position2DTextured, code + "Button")
					{
						DefaultColor = DefaultColors.HoverButton
					},
				ButtonPressed = material,
				Font = ContentLoader.Load<Font>("Verdana12"),
			};
			buttonTop += 0.1f;
			var button = new Button(theme, new Rectangle(0.4f, buttonTop, width, width / ratio));
			button.RenderLayer = 9000;
			button.IsVisible = false;
			button.Clicked += () => OnButtonClicked(code);
			Add(button);
		}
コード例 #19
0
ファイル: Label.cs プロジェクト: whztt07/DeltaEngine
		public Label(Theme theme, Rectangle drawArea, string text = "")
			: this(theme, theme.Label, drawArea)
		{
			Text = text;
			PreviousText = Text;
		}
コード例 #20
0
		private void AddButton(Theme theme, Action clicked, string text)
		{
			var button = new InteractiveButton(theme, new Rectangle(Vector2D.Zero, ButtonSize), text);
			button.Clicked += clicked;
			buttons.Add(button);
			Add(button);
		}
コード例 #21
0
		public void AddMenuOption(Theme theme, Action clicked, string text = "")
		{
			AddButton(theme, clicked, text);
			ArrangeButtons();
		}
コード例 #22
0
ファイル: SceneTests.cs プロジェクト: whztt07/DeltaEngine
		private static Button CreateButton()
		{
			var theme = new Theme
			{
				Button =
					new Material(ShaderFlags.Position2DColoredTextured, "DeltaEngineLogo")
					{
						DefaultColor = NormalColor
					},
				ButtonMouseover =
					new Material(ShaderFlags.Position2DColoredTextured, "DeltaEngineLogo")
					{
						DefaultColor = MouseoverColor
					},
				ButtonPressed =
					new Material(ShaderFlags.Position2DColoredTextured, "DeltaEngineLogo")
					{
						DefaultColor = PressedColor
					}
			};
			return new Button(theme, Small);
		}
コード例 #23
0
ファイル: MainMenu.cs プロジェクト: whztt07/DeltaEngine
			private void AddSoundOption()
			{
				var labelTheme = new Theme();
				labelTheme.Label = new Material(ShaderFlags.Position2DColoredTextured, "SoundLabel");
				var label = new Label(labelTheme,
					Rectangle.FromCenter(0.3f, ScreenSpace.Current.Viewport.Top + 0.6f, 0.2f, 0.1f));
				Add(label);

				var soundSlider = new Slider(menuTheme,
					Rectangle.FromCenter(0.6f, ScreenSpace.Current.Viewport.Top + 0.6f, 0.4f, 0.05f))
				{
					MaxValue = 100,
					MinValue = 0,
					Value = (int)(Settings.Current.SoundVolume * 100)
				};
				soundSlider.ValueChanged += val =>
				{
					Settings.Current.SoundVolume = val / 100.0f;
					if (!parent.EnterSound.IsAnyInstancePlaying)
						parent.EnterSound.Play(Settings.Current.SoundVolume);
				};
				soundSlider.Start<SettingsUpdater>();
				Add(soundSlider);
			}
コード例 #24
0
ファイル: ThemeTests.cs プロジェクト: whztt07/DeltaEngine
		private void CreateSampleTheme()
		{
			theme = new Theme
			{
				Label = new Material(Color.Blue, ShaderFlags.Colored),
				Button = new Material(Color.Red, ShaderFlags.Colored),
				ButtonDisabled = new Material(Color.Blue, ShaderFlags.Colored),
				ButtonMouseover = new Material(Color.Red, ShaderFlags.Colored),
				ButtonPressed = new Material(Color.Blue, ShaderFlags.Colored),
				DropdownListBox = new Material(Color.Red, ShaderFlags.Colored),
				DropdownListBoxDisabled = new Material(Color.Blue, ShaderFlags.Colored),
				RadioButtonBackground = new Material(Color.Red, ShaderFlags.Colored),
				RadioButtonBackgroundDisabled = new Material(Color.Blue, ShaderFlags.Colored),
				RadioButtonDisabled = new Material(Color.Red, ShaderFlags.Colored),
				RadioButtonNotSelected = new Material(Color.Blue, ShaderFlags.Colored),
				RadioButtonNotSelectedMouseover = new Material(Color.Red, ShaderFlags.Colored),
				RadioButtonSelected = new Material(Color.Blue, ShaderFlags.Colored),
				RadioButtonSelectedMouseover = new Material(Color.Red, ShaderFlags.Colored),
				Scrollbar = new Material(Color.Blue, ShaderFlags.Colored),
				ScrollbarDisabled = new Material(Color.Red, ShaderFlags.Colored),
				ScrollbarPointerMouseover = new Material(Color.Blue, ShaderFlags.Colored),
				ScrollbarPointerDisabled = new Material(Color.Red, ShaderFlags.Colored),
				ScrollbarPointer = new Material(Color.Blue, ShaderFlags.Colored),
				SelectBox = new Material(Color.Red, ShaderFlags.Colored),
				SelectBoxDisabled = new Material(Color.Blue, ShaderFlags.Colored),
				Slider = new Material(Color.Red, ShaderFlags.Colored),
				SliderDisabled = new Material(Color.Blue, ShaderFlags.Colored),
				SliderPointer = new Material(Color.Red, ShaderFlags.Colored),
				SliderPointerDisabled = new Material(Color.Blue, ShaderFlags.Colored),
				SliderPointerMouseover = new Material(Color.Red, ShaderFlags.Colored),
				TextBox = new Material(Color.Blue, ShaderFlags.Colored),
				TextBoxFocused = new Material(Color.Red, ShaderFlags.Colored),
				TextBoxDisabled = new Material(Color.Blue, ShaderFlags.Colored),
			};
			SaveDataToStream();
		}
コード例 #25
0
ファイル: MainMenu.cs プロジェクト: remy22/DeltaEngine
 private void CreateMenuTheme()
 {
     menuTheme = new Theme
     {
         Button = new Material(Shader.Position2DUV, "BlocksButtonDefault"),
         ButtonMouseover = new Material(Shader.Position2DUV, "BlocksButtonHover"),
         ButtonPressed = new Material(Shader.Position2DUV, "BlocksButtonPressed")
     };
 }
コード例 #26
0
 protected BaseSlider(Theme theme, Material material, Rectangle drawArea)
     : base(theme, material, drawArea)
 {
 }
コード例 #27
0
ファイル: PictureTests.cs プロジェクト: whztt07/DeltaEngine
		public void SetUp()
		{
			material = new Material(ShaderFlags.Position2DColoredTextured, "DeltaEngineLogo");
			var theme = new Theme { SliderPointer = material };
			picture = new Picture(theme, material, Rectangle.HalfCentered);
		}
コード例 #28
0
ファイル: MainMenu.cs プロジェクト: whztt07/DeltaEngine
		private void SetUpTheme()
		{
			SetViewportBackground("Background");
			menuTheme = new Theme();
			menuTheme.Button = new Material(ShaderFlags.Position2DColoredTextured, "BackButtonDefault");
			menuTheme.ButtonMouseover = new Material(ShaderFlags.Position2DColoredTextured, "BackButtonHover");
			menuTheme.ButtonPressed = new Material(ShaderFlags.Position2DColoredTextured, "BackButtonHover");
			menuTheme.Slider = new Material(ShaderFlags.Position2DColoredTextured, "SliderBackground");
			menuTheme.SliderPointer = new Material(ShaderFlags.Position2DColoredTextured, "SliderDefault");
			menuTheme.SliderPointerMouseover = new Material(ShaderFlags.Position2DColoredTextured, "SliderHover");

			startGameTheme = new Theme();
			startGameTheme.Button = new Material(ShaderFlags.Position2DColoredTextured, "StartGameButtonDefault");
			startGameTheme.ButtonMouseover = new Material(ShaderFlags.Position2DColoredTextured,
				"StartGameButtonHover");
			startGameTheme.ButtonPressed = new Material(ShaderFlags.Position2DColoredTextured, "StartGameButtonHover");

			optionsTheme = new Theme();
			optionsTheme.Button = new Material(ShaderFlags.Position2DColoredTextured, "OptionsButtonDefault");
			optionsTheme.ButtonMouseover = new Material(ShaderFlags.Position2DColoredTextured, "OptionsButtonHover");
			optionsTheme.ButtonPressed = new Material(ShaderFlags.Position2DColoredTextured, "OptionsButtonHover");
			optionsTheme.Label = new Material(ShaderFlags.Position2DColoredTextured, "OptionsButtonDefault");

			exitTheme = new Theme();
			exitTheme.Button = new Material(ShaderFlags.Position2DColoredTextured, "ExitButtonDefault");
			exitTheme.ButtonMouseover = new Material(ShaderFlags.Position2DColoredTextured, "ExitButtonHover");
			exitTheme.ButtonPressed = new Material(ShaderFlags.Position2DColoredTextured, "ExitButtonHover");

			howToPlayTheme = new Theme();
			howToPlayTheme.Button = new Material(ShaderFlags.Position2DColoredTextured, "HowToPlayButtonDefault");
			howToPlayTheme.ButtonMouseover = new Material(ShaderFlags.Position2DColoredTextured,
				"HoWToPlayButtonHover");
			howToPlayTheme.ButtonPressed = new Material(ShaderFlags.Position2DColoredTextured, "HowtoPlayButtonHover");
		}
コード例 #29
0
ファイル: Game.cs プロジェクト: whztt07/DeltaEngine
		protected virtual Theme CreateButtonTheme(Color color)
		{
			var darkColor = new Color(color.RedValue * 0.7f, color.GreenValue * 0.7f,
				color.BlueValue * 0.7f);
			var lightColor = new Color(color.RedValue * 0.85f, color.GreenValue * 0.85f,
				color.BlueValue * 0.85f);
			var buttonTheme = new Theme
			{
				Button = new Material(buttonShader, buttonImage) { DefaultColor = darkColor },
				ButtonMouseover = new Material(buttonShader, buttonImage) { DefaultColor = lightColor },
				ButtonPressed = new Material(buttonShader, buttonImage) { DefaultColor = color },
				ButtonDisabled = new Material(buttonShader, buttonImage) { DefaultColor = Color.Gray }
			};
			cachedButtonThemes.Add(color, buttonTheme);
			return buttonTheme;
		}
コード例 #30
0
ファイル: MainMenu.cs プロジェクト: whztt07/DeltaEngine
			public OptionSubmenu(MainMenu parent, Theme menuTheme)
			{
				this.parent = parent;
				this.menuTheme = menuTheme;
				SetViewportBackground("Background");
				Add(new Sprite(new Material(ShaderFlags.Position2DColoredTextured, "BreakoutLogo"),
					Rectangle.FromCenter(0.5f, ScreenSpace.Current.Viewport.Top + 0.2f, 0.7f, 0.3f)));
				AddMusicOption();
				AddSoundOption();
				AddBackButton();
			}
コード例 #31
0
ファイル: RadioDialog.cs プロジェクト: whztt07/DeltaEngine
		public RadioDialog(Theme theme, Rectangle drawArea)
			: base(drawArea)
		{
			Add(theme);
			Add(new List<RadioButton>());
		}
コード例 #32
0
 public Label(Theme theme, Rectangle drawArea, string text = "")
     : this(theme, theme.Label, drawArea)
 {
     Text         = text;
     PreviousText = Text;
 }