/** Creates a new notification with given text and optional graphic */ public GuiNotification(string content, Sprite sprite = null) : base(260, 60) { Stage = NotificationStage.AnimateOn; stageLife = AnimationDuration; Color = new Color(0.2f, 0.2f, 0.2f); text = new GuiLabel(content); text.AutoHeight = false; text.AutoWidth = false; text.X = 5; text.Y = 5; text.Width = (int)ContentsBounds.width - 10; text.Height = (int)ContentsBounds.height - 10; text.FontSize = 12; text.WordWrap = true; text.TextAlign = TextAnchor.MiddleLeft; Add(text); OuterShadow = true; if (sprite != null) { image = new GuiImage(3, 3, sprite); image.Scale = (Height - 10) / sprite.rect.height; text.X = 60; text.Width = (int)ContentsBounds.width - text.X - 5; var frame = new GuiFillRect(1, 1, image.Width + 4, image.Height + 4, Color.black.Faded(0.50f)); Add(frame); Add(image); var shadow = new GuiFrameRect(3, 3, image.Width, image.Height, Color.black.Faded(0.5f)); Add(shadow); } }
/// <summary> /// Loads the content. /// </summary> public override void LoadContent() { BackgroundImage = new GuiImage { ContentFile = "SplashScreen/Background", RotationEffect = new RotationEffect { Speed = 0.1f, MaximumRotation = 0.2f }, ZoomEffect = new ZoomEffect { Speed = 0.1f, MinimumZoom = 1.25f, MaximumZoom = 2.00f }, EffectsActive = true }; OverlayImage = new GuiImage { ContentFile = "SplashScreen/Overlay" }; LogoImage = new GuiImage { ContentFile = "SplashScreen/Logo" }; GuiManager.Instance.GuiElements.Add(BackgroundImage); GuiManager.Instance.GuiElements.Add(OverlayImage); GuiManager.Instance.GuiElements.Add(LogoImage); base.LoadContent(); BackgroundImage.RotationEffect.Activate(); BackgroundImage.ZoomEffect.Activate(); }
private void setupColonizationMarkers() { foreach (var marker in this.colonizationMarkers.Values) { this.RemoveElement(marker); } this.colonizationMarkers.Clear(); foreach (var planet in this.controller.Planets.Where(x => this.controller.IsColonizing(x.Position))) { if (!this.planetSelectors.ContainsKey(planet.Position)) { continue; } var marker = new GuiImage { Images = new[] { new Sprite(GalaxyTextures.Get.ColonizationMark, Color.White), new Sprite(GalaxyTextures.Get.ColonizationMarkColor, this.currentPlayer.Info.Color) } }; marker.Position.FixedSize(40, 40).RelativeTo(this.planetSelectors[planet.Position], 0.8f, 0.8f, -1, -1); this.colonizationMarkers[planet.Position] = marker; this.AddElement(marker); } }
/// <summary> /// Loads the content. /// </summary> public override void LoadContent() { LogoImage = new GuiImage { ContentFile = "SplashScreen/Logo" }; GuiManager.Instance.GuiElements.Add(LogoImage); base.LoadContent(); }
public override void LoadContent() { background = new GuiImage { ContentFile = "Interface/SideBar/panel" }; Children.Add(background); base.LoadContent(); }
public static List <GuiElement> GetNewGuiPanel( Plugin plugin, string name, Rectangle rectangle, GuiElement parent, Layer layer, GuiColor panelColor = null, float FadeIn = 0, float FadeOut = 0, GuiText text = null, string imgName = null, Blur blur = Blur.none) { List <GuiElement> elements = new List <GuiElement>(); Layer higherLayer = layer; if (parent != null) { higherLayer = (Layer)Math.Min((int)layer, (int)parent.Layer); } if (string.IsNullOrEmpty(imgName)) { GuiPlainPanel plainPanel = GuiPlainPanel.GetNewGuiPlainPanel(name, rectangle, parent, layer, panelColor, FadeIn, FadeOut, blur); elements.Add(plainPanel); } else { GuiImage image = GuiImage.GetNewGuiImage(plugin, name, rectangle, imgName, false, parent, layer, panelColor, FadeIn, FadeOut); elements.Add(image); } if (text != null) { text.FadeIn = FadeIn; GuiLabel label = new GuiLabel { Name = name + "_txt", Rectangle = new Rectangle(), Layer = higherLayer, Parent = name, Text = text, FadeOut = FadeOut, Components = { text, new Rectangle() } }; elements.Add(label); } return(elements); }
public InventoryWindow(Module App, InventorySide Side) : base(App) { side = (Side == InventorySide.Right); back = side ? "inv.raw?2" : "gfx/inventory_left.png"; basePos = new Vector2(15, 15); Size = new Vector2(back.Width, back.Height) + basePos; face = new FaceWindow(App); face.Position = side ? (basePos + new Vector2(67, 0)) : basePos; face.DisplayOnly = true; Windows += face; grid = new ItemGridWindow(App); grid.LockPositions = true; grid.Position = new Vector2(side ? 9 : 19, side ? 72 : 83) + basePos; grid.Spacing = new Vector2(4, side ? 16 : 5); grid.Grid = new Vector2(3, 2); grid.LeftClickItemEvent += OnLeftClickItem; grid.RightClickItemEvent += OnRightClickItem; Windows += grid; font = new GuiFont(BurntimeClassic.FontName, new PixelColor(128, 136, 192)); font.Borders = TextBorders.Screen; nameFont = new GuiFont(BurntimeClassic.FontName, new PixelColor(240, 64, 56)); nameFont.Borders = TextBorders.Screen; pageName = ""; for (int i = 0; i < 5; i++) { pageButtons[i] = new Button(App); pageButtons[i].Image = "munt.raw?" + (5 + i); if (side) { pageButtons[i].Position = basePos + new Vector2(120 + 3 * i, 142 - 18 * i); } else { pageButtons[i].Position = basePos + new Vector2(-3 * i, 142 - 18 * i); } pageButtons[i].Hide(); pageButtons[i].Command += new CommandHandler(OnPage, i); pageIndices[i] = i; Windows += pageButtons[i]; } pages = new List <InventoryPage>(); activePageIndex = 0; activePage = null; }
public GuiImage addRawImage(string name, Rectangle rectangle, string imgData, GuiElement Parent, Layer layer, GuiColor panelColor = null, float FadeIn = 0, float FadeOut = 0) { if (string.IsNullOrEmpty(name)) { name = "image"; } purgeDuplicates(name); GuiImage img = GuiImage.GetNewGuiImage(plugin, name, rectangle, imgData, true, Parent, layer, panelColor, FadeIn, FadeOut); Add(img); return(img); }
/// <summary> /// Metoda zajistí vytvoření obrázku <see cref="GuiImage.Image"/> z dat uložených v <see cref="GuiImage.ImageContent"/>. /// Pokud z dat nelze vytvořit obrázek, pak nuluje obsah <see cref="GuiImage.ImageContent"/>, aby se o to někdo nepokoušel opakovaně. /// </summary> /// <param name="guiImage"></param> private static void _ReloadGuiImage(GuiImage guiImage) { try { using (System.IO.MemoryStream ms = new System.IO.MemoryStream(guiImage.ImageContent)) { guiImage.Image = Bitmap.FromStream(ms); } } catch { guiImage.ImageContent = null; guiImage.Image = null; } }
private void setupUi() { foreach (var element in planetElements) { this.RemoveElement(element); } this.planetElements = new List <AGuiElement>(); foreach (var planet in this.controller.Planets) { var planetImage = new GuiImage { Image = GalaxyTextures.Get.PlanetSprite(planet.Type), }; planetImage.Position.FixedSize(100, 100).RelativeTo(this.planetAnchor(planet.Planet)); this.addPlanetElement(planetImage); if (planet.Owner == null) { continue; } var colony = planet.Colony; var formatter = new ThousandsFormatter(); var popInfo = new GuiText { Margins = new Vector2(0, 20), TextHeight = 20, Text = formatter.Format(colony.Population) + " / " + formatter.Format(colony.PopulationMax), TextColor = colony.Owner.Color }; popInfo.Position.WrapContent().Then.RelativeTo(planetImage, 0, -1, 0, 1).UseMargins(); this.addPlanetElement(popInfo); if (this.controller.Targets.Contains(planet)) { var bombButton = new GuiButton { BackgroundHover = new BackgroundTexture(GalaxyTextures.Get.BombButton, 6), BackgroundNormal = new BackgroundTexture(GalaxyTextures.Get.BombButton, 6), ClickCallback = () => this.controller.Bombard(planet.OrdinalPosition), Margins = new Vector2(0, 20) }; bombButton.Position.FixedSize(80, 80).RelativeTo(popInfo, 0, -1, 0, 1).UseMargins(); this.addPlanetElement(bombButton); } } }
public BombardmentScene() { var titleText = new GuiText { Margins = new Vector2(0, 10), Text = LocalizationManifest.Get.CurrentLanguage["FormMain"]["BombardTitle"].Text(), TextColor = Color.White, TextHeight = 32 }; titleText.Position.WrapContent().Then.ParentRelative(0, 1).UseMargins(); this.AddElement(titleText); this.starImage = new GuiImage(); this.starImage.Position.FixedSize(400, 400).RelativeTo(this.StarAnchor); this.AddElement(this.starImage); }
public VersionSelectionState(GuiPanoramaSkyBox skyBox, Action onJavaConfirmed, Action <PlayerProfile> onBedrockConfirmed) { _skyBox = skyBox; JavaConfirmed = onJavaConfirmed; BedrockConfirmed = onBedrockConfirmed; Background = new GuiTexture2D(_skyBox, TextureRepeatMode.Stretch); _mainMenu = new GuiStackMenu() { Margin = new Thickness(15, 0, 15, 0), Width = 125, Anchor = Alignment.MiddleCenter, ChildAnchor = Alignment.CenterY | Alignment.FillX, //BackgroundOverlay = new Color(Color.Black, 0.35f), ModernStyle = false, }; _mainMenu.AddMenuItem($"Java - Version {JavaProtocol.FriendlyName}", JavaEditionButtonPressed); _mainMenu.AddMenuItem($"Bedrock - Version {McpeProtocolInfo.GameVersion}", BedrockEditionButtonPressed); _mainMenu.AddSpacer(); _mainMenu.AddMenuItem($"Go Back", SinglePlayerButtonPressed); AddChild(_mainMenu); AddChild(_logo = new GuiImage(GuiTextures.AlexLogo) { Margin = new Thickness(0, 25, 0, 0), Anchor = Alignment.TopCenter }); AddChild(_textElement = new GuiTextElement() { TextColor = TextColor.Yellow, Margin = new Thickness(0, 64, 0, 0), Anchor = Alignment.TopCenter, Text = "Select the edition you want to play on...", Scale = 1f }); }
public override void Show() { base.Show(); var guiLayer = new GuiLayer(GraphicsDevice, Game.Camera); Layers.Add(guiLayer); var guiButtonRegion = AssetManager.Load <Texture>("play-button.png").ToTextureRegion(); var guiButton = new GuiButton(guiButtonRegion) { Position = new Vector2(400, 240) }; guiLayer.Controls.Add(guiButton); _mouseCursor = guiButton; var font = AssetManager.Load("courier-new-32.fnt", new BitmapFontLoader()); var guiLabel = new GuiLabel(font) { Text = "This is a label", HorizontalAlignment = HorizontalAlignment.Left, Position = new Vector2(100, 100), TextColor = Color.Black }; guiLayer.Controls.Add(guiLabel); var guiImageTexture = AssetManager.Load <Texture>("photo.png"); var guiImage = new GuiImage(guiImageTexture) { Position = new Vector2(800, 0), Origin = new Vector2(1.0f, 0.0f) }; guiLayer.Controls.Add(guiImage); var guiCheckboxTexture = AssetManager.Load <Texture>("play-button.png"); var guiCheckbox = new GuiCheckbox(guiCheckboxTexture.ToTextureRegion()) { Position = new Vector2(500, 100), }; guiLayer.Controls.Add(guiCheckbox); }
public MenuWindow(Module App) : base(App) { top = "munt.raw?24"; middle = "munt.raw?25"; bottom = "munt.raw?26"; list = new List <MenuItem>(); font = new GuiFont(BurntimeClassic.FontName, new PixelColor(108, 116, 168)); font.Borders = TextBorders.Screen; hoverFont = new GuiFont(BurntimeClassic.FontName, new PixelColor(240, 64, 56)); hoverFont.Borders = TextBorders.Screen; hover = -1; IsModal = true; CaptureAllMouseClicks = true; }
public TownBuildingState(string name) : base(name) { int uiMargin = 10; GuiImage Background = new GuiImage(0, 0, ResourceManager.GetSprite("Backgrounds/Town")); Background.BestFit(ContentsFrame); Add(Background, 0, 0); LeftTwoThirds = new GuiContainer(Width - 340, Height); Add(LeftTwoThirds); LowerSection = new GuiWindow(0, 0); LowerSection.Background.Color = new Color(0.4f, 0.4f, 0.4f); LeftTwoThirds.Add(LowerSection); MainWindow = new GuiWindow(600, 500, name); LeftTwoThirds.Add(MainWindow, 0, 0); BackButton = new GuiButton("Back"); BackButton.OnMouseClicked += delegate { Engine.PopState(); }; LowerSection.Add(BackButton); // UI Party = new GuiPartyInfo(0, 0); Party.Party = CoM.Party; Add(Party, -uiMargin, -uiMargin); CharacterInfo = new GuiCharacterTabControl(); Add(CharacterInfo, -uiMargin, uiMargin); ItemInventory = new GuiItemInventory(); Add(ItemInventory, -uiMargin, CharacterInfo.Height + uiMargin); RepositionControls(); }
/// <summary> /// Metoda vrátí grafickou instanci <see cref="Image"/> z dat předaných v instanci <see cref="GuiImage"/>. /// Může vrátit null. /// </summary> /// <param name="guiImage"></param> /// <returns></returns> public Image GetImage(GuiImage guiImage) { if (guiImage == null) { return(null); } if (guiImage.Image != null) { return(guiImage.Image); } if (guiImage.ImageContent != null) { _ReloadGuiImage(guiImage); if (guiImage.Image != null) { return(guiImage.Image); } } if (!String.IsNullOrEmpty(guiImage.ImageFile)) { return(this.GetImageByName(guiImage.ImageFile)); } return(null); }
public void SetStarSystem(StarSystemController controller, PlayerController playerController) { this.setupSystem(controller.Planets.ToList(), controller.PlanetsColony); this.controller = controller; this.currentPlayer = playerController; var colonies = controller.Planets.Select(x => controller.PlanetsColony(x)).Where(x => x != null); if (colonies.Any()) { this.panTo(Methods.FindBest(colonies, x => x.Population).Location); } else { this.panToStar(); } this.starSelector.ForgroundImageColor = controller.HostStar.Color; this.starSelector.Select(); foreach (var element in this.planetSelectors.Values.Concat(this.colonizationMarkers.Values).Concat(this.otherPlanetElements)) { this.RemoveElement(element); } this.planetSelectors.Clear(); this.colonizationMarkers.Clear(); this.otherPlanetElements.Clear(); var traitGridBuilder = new GridPositionBuilder(2, 20, 20, 3); foreach (var trait in controller.HostStar.Traits) { var traitImage = new GuiImage { Below = this.starSelector, Margins = new Vector2(3, 0), Image = GalaxyTextures.Get.Sprite(trait.ImagePath), Tooltip = new SimpleTooltip("Traits", trait.LangCode) }; traitImage.Position.FixedSize(20, 20).RelativeTo(this.starSelector, 0.8f, -0.8f, -1, 1).UseMargins(); traitGridBuilder.Add(traitImage.Position); this.addPlanetElement(traitImage); } foreach (var planet in this.controller.Planets) { var planetSelector = new SelectableImage <int>(planet.Position) { ForgroundImage = GalaxyTextures.Get.PlanetSprite(planet.Type), SelectorImage = GalaxyTextures.Get.SelectedStar, SelectCallback = select, Padding = 16, }; planetSelector.Position.FixedSize(100, 100).RelativeTo(this.planetAnchor(planet)); planetSelector.GroupWith(starSelector); this.planetSelectors[planet.Position] = planetSelector; this.AddElement(planetSelector); var popInfo = new GuiText { Margins = new Vector2(0, 20), TextHeight = 20 }; popInfo.Position.WrapContent().Then.RelativeTo(planetSelector, 0, -1, 0, 1).UseMargins(); var formatter = new ThousandsFormatter(); var colony = this.controller.PlanetsColony(planet); if (colony != null) { popInfo.Text = formatter.Format(colony.Population) + " / " + formatter.Format(colony.PopulationMax); popInfo.TextColor = colony.Owner.Color; } else { popInfo.Text = formatter.Format(planet.PopulationMax); popInfo.TextColor = Color.Gray; } this.addPlanetElement(popInfo); traitGridBuilder = new GridPositionBuilder(4, 20, 20, 3); foreach (var trait in planet.Traits) { var traitImage = new GuiImage { Margins = new Vector2(0, 10), Image = GalaxyTextures.Get.Sprite(trait.ImagePath), Tooltip = new SimpleTooltip("Traits", trait.LangCode) }; traitImage.Position.FixedSize(20, 20).RelativeTo(popInfo, 0, -1, 0, 1).UseMargins().Offset(-40, 0); traitGridBuilder.Add(traitImage.Position); this.addPlanetElement(traitImage); } } this.setupColonizationMarkers(); }
public void SetStarSystem(StarSystemController controller, PlayerController playerController) { this.controller = controller; this.currentPlayer = playerController; this.maxOffset = (controller.Planets.Count() + 1) * OrbitStep + OrbitOffset; var bestColony = controller.Planets. Select(x => controller.PlanetsColony(x)). Aggregate( (ColonyInfo)null, (prev, next) => next == null || (prev != null && prev.Population >= next.Population) ? prev : next ); this.originOffset = bestColony != null ? bestColony.Location.Position * OrbitStep + OrbitOffset : 0.5f; this.lastMousePosition = null; this.starSelector.ForgroundImageColor = controller.HostStar.Color; this.starSelector.Select(); foreach (var anchor in this.planetAnchors) { this.RemoveAnchor(anchor); } this.planetAnchors.Clear(); foreach (var element in this.planetSelectors.Values.Concat(this.colonizationMarkers.Values).Concat(this.otherPlanetElements)) { this.RemoveElement(element); } this.planetSelectors.Clear(); this.colonizationMarkers.Clear(); this.otherPlanetElements.Clear(); var traitGridBuilder = new GridPositionBuilder(2, 20, 20, 3); foreach (var trait in controller.HostStar.Traits) { var traitImage = new GuiImage { Below = this.starSelector, Image = GalaxyTextures.Get.Sprite(trait.ImagePath), Tooltip = new SimpleTooltip("Traits", trait.LangCode) }; traitImage.Position.FixedSize(20, 20).RelativeTo(this.starSelector, 0.8f, -0.8f, -1, 1).WithMargins(3, 0); traitGridBuilder.Add(traitImage.Position); this.addPlanetElement(traitImage); } foreach (var planet in this.controller.Planets) { var anchor = new GuiAnchor(planet.Position * OrbitStep + OrbitOffset, 0); this.AddAnchor(anchor); this.planetAnchors.Add(anchor); var planetSelector = new SelectableImage <int>(planet.Position) { ForgroundImage = GalaxyTextures.Get.PlanetSprite(planet.Type), SelectorImage = GalaxyTextures.Get.SelectedStar, SelectCallback = select, Padding = 16, }; planetSelector.Position.FixedSize(100, 100).RelativeTo(anchor); planetSelector.GroupWith(starSelector); this.planetSelectors[planet.Position] = planetSelector; this.AddElement(planetSelector); var popInfo = new GuiText { TextHeight = 20 }; popInfo.Position.WrapContent().Then.RelativeTo(planetSelector, 0, -1, 0, 1).WithMargins(0, 20); var formatter = new ThousandsFormatter(); var colony = this.controller.PlanetsColony(planet); if (colony != null) { popInfo.Text = formatter.Format(colony.Population) + " / " + formatter.Format(colony.PopulationMax); popInfo.TextColor = colony.Owner.Color; } else { popInfo.Text = formatter.Format(planet.PopulationMax); popInfo.TextColor = Color.Gray; } this.addPlanetElement(popInfo); traitGridBuilder = new GridPositionBuilder(4, 20, 20, 3); foreach (var trait in planet.Traits) { var traitImage = new GuiImage { Image = GalaxyTextures.Get.Sprite(trait.ImagePath), Tooltip = new SimpleTooltip("Traits", trait.LangCode) }; traitImage.Position.FixedSize(20, 20).RelativeTo(popInfo, 0, -1, 0, 1).WithMargins(0, 10).Offset(-40, 0); traitGridBuilder.Add(traitImage.Position); this.addPlanetElement(traitImage); } } this.setupColonizationMarkers(); }
public InfoScene(Module App) : base(App) { Background = "info.pac"; Music = "13_MUS 13_HSC.ogg"; Position = (app.Engine.GameResolution - new Vector2(320, 200)) / 2; Button button = new Button(App); button.Position = new Vector2(5, 174); button.Command += OnButtonBack; //btn.SetHover(TextDB.Singleton.GetString(TextRegion.MenuStrings, 4), ColorTable.HoverGray); button.Image = "gfx/mapbutton.png"; button.HoverImage = "gfx/mapbuttonh.png"; Windows += button; button = new Button(App); button.Position = new Vector2(107, 122); button.Command += OnButtonListUp; button.HoverImage = "gfx/up.png"; Windows += button; button = new Button(App); button.Position = new Vector2(107, 141); button.Command += OnButtonListDown; button.HoverImage = "gfx/down.png"; Windows += button; Image image = new Image(App); image.Background = "inf.ani?0-2"; image.Background.Animation.Speed = 6.0f; image.Position = new Vector2(4, 105); Windows += image; image = new Image(App); image.Background = "inf.ani?4-6"; image.Background.Animation.Speed = 6; image.Background.Animation.Progressive = false; image.Position = new Vector2(234, 150); Windows += image; danger = new Image(App); danger.Position = new Vector2(229, 27); Windows += danger; production = new ItemWindow(App); production.Position = new Vector2(230, 105); production.ItemID = ""; production.LeftClickEvent += OnProductionLeft; production.RightClickEvent += OnProductionRight; Windows += production; grid = new ItemGridWindow(App); grid.Position = new Vector2(137, 105); grid.Spacing = new Vector2(0, 6); grid.Grid = new Vector2(1, 2); Windows += grid; titleFont = new GuiFont(BurntimeClassic.FontName, new PixelColor(156, 156, 156), new PixelColor(76, 32, 4)); font = new GuiFont(BurntimeClassic.FontName, new PixelColor(184, 184, 184), new PixelColor(92, 92, 96)); items = new SortedList <string, int>(); fighterImage = "syssze.raw?32"; doctorImage = "syssze.raw?16"; technicianImage = "syssze.raw?48"; }
public override void Show() { _music = AssetManager.Load <Music>("song.mp3"); _soundEffect = AssetManager.Load <SoundEffect>("click.wav"); var backgroundLayer = new SpriteLayer(GraphicsDevice, Game.Camera); Layers.Add(backgroundLayer); var backgroundTexture = AssetManager.Load <Texture>("hills_800x480.png"); var backgroundSprite = Sprite.Create(backgroundTexture, 0, 0, 800, 480); backgroundLayer.Sprites.Add(backgroundSprite); var guiLayer = new GuiLayer(GraphicsDevice, Game.Camera); var font = AssetManager.Load("courier-new-32.fnt", new BitmapFontLoader()); var label = new GuiLabel(font) { Text = "Welcome to", TextColor = new Color(81, 32, 0), Position = new Vector2(400, 45) }; guiLayer.Controls.Add(label); var logoTexture = AssetManager.Load <Texture>("astrid-logo.png"); var image = new GuiImage(logoTexture) { Position = new Vector2(400, -150), Origin = new Vector2(0.5f, 1.0f) }; guiLayer.Controls.Add(image); var parameters = new TransitionParameters(1.0f, EasingFunctions.QuadraticEaseIn); Animations.CreateSequence(image) .MoveTo(new Vector2(400, 150), parameters) .ScaleTo(new Vector2(1.2f, 0.6f), new TransitionParameters(0.2f, EasingFunctions.CubicEaseOut)) .ScaleTo(new Vector2(1.0f, 1.0f), new TransitionParameters(0.2f, EasingFunctions.CubicEaseIn)) .ScaleTo(new Vector2(0.8f, 1.2f), new TransitionParameters(0.2f, EasingFunctions.CubicEaseOut)) .ScaleTo(new Vector2(1.0f, 1.0f), new TransitionParameters(0.2f, EasingFunctions.CubicEaseIn)) .Play(); var buttonTexture = AssetManager.Load <Texture>("play-button.png"); var playButton = new GuiButton(buttonTexture.ToTextureRegion()) { Position = new Vector2(400, -260), Rotation = MathHelper.TwoPi }; playButton.Click += PlayButtonOnClick; guiLayer.Controls.Add(playButton); Layers.Add(guiLayer); var transitionParameters = new TransitionParameters(1.0f, EasingFunctions.CubicEaseInOut); Animations .CreateSequence(playButton) .MoveTo(new Vector2(50, 50), transitionParameters) .MoveTo(new Vector2(700, 400), transitionParameters) .MoveTo(new Vector2(700, 230), transitionParameters) .MoveTo(new Vector2(400, 250), transitionParameters) .Delay(1.0f) .RotateTo(0, transitionParameters) .Delay(1.0f) .RotateTo(MathHelper.TwoPi, transitionParameters) .FadeOut(transitionParameters) .FadeIn(transitionParameters) .Play(); base.Show(); }
/** Create the store ui */ //todo: remove sizes public GuiStore(MDRStore store, int width = 800, int height = 600) : base(width, height) { int splitWidth = (width / 2) + 50; const int HEADER_HEIGHT = 50; WindowStyle = GuiWindowStyle.ThinTransparent; StoreSelectedItemID = -1; Store = store; CanReceiveFocus = true; DragDropEnabled = true; // ----------------------------------------- // Main areas var mainArea = new GuiContainer(0, (int)ContentsBounds.height - HEADER_HEIGHT); mainArea.Align = GuiAlignment.Bottom; // ----------------------------------------- // Header var headerArea = new GuiContainer((int)ContentsBounds.width, HEADER_HEIGHT); headerArea.EnableBackground = true; headerArea.Style = Engine.GetStyleCopy("Frame"); headerArea.Y -= 4; headerArea.X -= 4; headerArea.Width += 8; modeButtons = new GuiRadioButtonGroup(); modeButtons.AddItem("Buy"); modeButtons.AddItem("Sell"); modeButtons.ButtonSize = new Vector2(120, 30); modeButtons.ButtonSpacing = 50; modeButtons.EnableBackground = false; headerArea.Add(modeButtons, 0, 0, true); modeButtons.OnValueChanged += delegate { _mode = (StoreMode)modeButtons.SelectedIndex; updateStoreMode(); }; Add(headerArea); Add(mainArea); // ----------------------------------------- // Item Info Area GuiPanel itemInfoPanel = new GuiPanel((int)ContentsBounds.width - splitWidth); itemInfoPanel.Align = GuiAlignment.Right; itemInfoPanel.EnableBackground = false; mainArea.Add(itemInfoPanel, -1, 1, true); itemInfoBackground = new GuiImage(0, 0, ResourceManager.GetSprite("Gui/InnerWindow")); itemInfoBackground.Align = GuiAlignment.Full; itemInfoBackground.Color = Colors.StoreItemInfoBackgroundColor; itemInfoPanel.Add(itemInfoBackground); SelectedItemInfo = new GuiItemToolTip(); SelectedItemInfo.EnableBackground = false; SelectedItemInfo.Align = GuiAlignment.Full; SelectedItemInfo.ShowAllInfo = true; itemInfoPanel.Add(SelectedItemInfo); // ----------------------------------------- // Item Buy Area buyItemArea = new GuiContainer(splitWidth, (int)ContentsBounds.height); buyItemArea.Align = GuiAlignment.Left; mainArea.Add(buyItemArea); itemListingScrollArea = new GuiScrollableArea(buyItemArea.Width, buyItemArea.Height, ScrollMode.VerticalOnly); buyItemArea.Add(itemListingScrollArea); filterItemsToggle = new GuiToggleButton(); filterItemsToggle.OnValueChanged += delegate { ShowOnlyUsableItems = filterItemsToggle.Value; }; mainArea.Add(filterItemsToggle, -10, -10); filterItemsToggle.Visible = false; buyButton = new GuiButton("Buy"); buyButton.OnMouseClicked += DoBuy; itemInfoPanel.Add(buyButton, 0, -30); notEnoughGold = new GuiLabel("No enough coins"); notEnoughGold.FontColor = new Color(0.5f, 0.5f, 0.5f, 0.9f); notEnoughGold.Visible = false; itemInfoPanel.Add(notEnoughGold, 0, -56); // ----------------------------------------- // item Sell area sellItemArea = new GuiSellItemArea((int)mainArea.ContentsBounds.width - splitWidth, (int)mainArea.ContentsBounds.height, store); sellItemArea.Align = GuiAlignment.Right; sellItemArea.OnSell += delegate { Mode = StoreMode.Buy; }; mainArea.Add(sellItemArea); // ----------------------------------------- CoM.Party.OnSelectedChanged += createStoreListings; store.OnInventoryChanged += createStoreListings; updateStoreMode(); createStoreListings(); }
/// <summary> /// Zobrazí daný dialog a vrátí odpověď. /// </summary> /// <param name="message"></param> /// <param name="title"></param> /// <param name="guiButtons"></param> /// <param name="icon"></param> /// <returns></returns> public GuiDialogButtons ShowDialog(string message, string title = null, GuiDialogButtons guiButtons = GuiDialogButtons.None, GuiImage icon = null) { if (String.IsNullOrEmpty(message)) { return(GuiDialogButtons.None); } if (this.InvokeRequired) { return((GuiDialogButtons)this.Invoke(new Func <string, string, GuiDialogButtons, GuiImage, GuiDialogButtons>(_ShowDialogGUI), message, title, guiButtons, icon)); } else { return(this._ShowDialogGUI(message, title, guiButtons, icon)); } }
/// <summary> /// Zobrazí dialog, vrátí volbu uživatele /// </summary> /// <param name="message"></param> /// <param name="title"></param> /// <param name="guiButtons"></param> /// <param name="guiIcon"></param> /// <returns></returns> private GuiDialogButtons _ShowDialogGUI(string message, string title, GuiDialogButtons guiButtons, GuiImage guiIcon) { return(WinFormDialog.ShowDialog(this.FindForm(), message, title, guiButtons, guiIcon)); }
public TownState() : base("TownState") { GuiImage Background = new GuiImage(0, 0, ResourceManager.GetSprite("Backgrounds/Town")); Background.BestFit(ContentsFrame); Add(Background, 0, 0); GuiWindow window = new GuiWindow(400, 260, "Town"); window.Background.Color = Colors.BackgroundGray; Add(window, 0, 0); GuiButton MainMenuButton = new GuiButton("Exit", 150); MainMenuButton.ColorTransform = ColorTransform.BlackAndWhite; MainMenuButton.ColorTransform += ColorTransform.Multiply(1.2f, 1.2f, 1.2f); MainMenuButton.Color = new Color(1f, 0.4f, 0.3f); GuiButton storeButton = new GuiButton("General Store", 150); GuiButton templeButton = new GuiButton("Temple", 150); GuiButton guildButton = new GuiButton("Guild", 150); GuiButton tavernButton = new GuiButton("Tavern", 150); GuiButton libraryButton = new GuiButton("Library", 150); GuiButton bankButton = new GuiButton("Bank", 150); GuiButton dungeonButton = new GuiButton("Dungeon", 150); int buttonY = 25; window.Add(MainMenuButton, 0, buttonY - 5); window.Add(storeButton, 20, buttonY + 40 * 1); window.Add(templeButton, 20, buttonY + 40 * 2); window.Add(guildButton, 20, buttonY + 40 * 3); window.Add(tavernButton, -20, buttonY + 40 * 1); window.Add(libraryButton, -20, buttonY + 40 * 2); window.Add(bankButton, -20, buttonY + 40 * 3); window.Add(dungeonButton, 0, -20); storeButton.OnMouseClicked += delegate { Engine.PushState(new StoreState()); }; guildButton.OnMouseClicked += delegate { Engine.PushState(new GuildState()); }; templeButton.OnMouseClicked += delegate { Engine.PushState(new TempleState()); }; bankButton.OnMouseClicked += delegate { Engine.PushState(new BankState()); }; libraryButton.OnMouseClicked += delegate { Engine.PushState(new LibraryState()); }; MainMenuButton.OnMouseClicked += CoM.ReturnToMainMenu; OnStateShow += delegate { SoundManager.PlayMusicPlaylist("City"); }; // these are not implemented yet. tavernButton.SelfEnabled = false; bankButton.SelfEnabled = false; dungeonButton.OnMouseClicked += delegate { if (CoM.Party.LivingMembers == 0) { Engine.ShowModal("Can Not Enter Dungeon.", "All party memebers are dead."); } else { CoM.Party.Depth = 1; PartyController.Instance.SyncCamera(); Engine.PopState(); } }; }
public TitleState() { FpsMonitor = new FpsMonitor(); _backgroundSkyBox = new GuiPanoramaSkyBox(Alex); Background.Texture = _backgroundSkyBox; Background.RepeatMode = TextureRepeatMode.Stretch; #region Create MainMenu _mainMenu = new GuiStackMenu() { Margin = new Thickness(15, 0, 15, 0), Padding = new Thickness(0, 50, 0, 0), Width = 125, Anchor = Alignment.FillY | Alignment.MinX, ChildAnchor = Alignment.CenterY | Alignment.FillX, BackgroundOverlay = new Color(Color.Black, 0.35f) }; _mainMenu.AddMenuItem("Multiplayer", JavaEditionButtonPressed, EnableMultiplayer); _mainMenu.AddMenuItem("SinglePlayer", OnSinglePlayerPressed); _mainMenu.AddMenuItem("Options", () => { Alex.GameStateManager.SetActiveState("options"); }); _mainMenu.AddMenuItem("Exit", () => { Alex.Exit(); }); #endregion #region Create DebugMenu _debugMenu = new GuiStackMenu() { Margin = new Thickness(15, 0, 15, 0), Padding = new Thickness(0, 50, 0, 0), Width = 125, Anchor = Alignment.FillY | Alignment.MinX, ChildAnchor = Alignment.CenterY | Alignment.FillX, BackgroundOverlay = new Color(Color.Black, 0.35f), }; _debugMenu.AddMenuItem("Debug Blockstates", DebugWorldButtonActivated); _debugMenu.AddMenuItem("Debug Flatland", DebugFlatland); //_debugMenu.AddMenuItem("Debug Anvil", DebugAnvil); _debugMenu.AddMenuItem("Debug Chunk", DebugChunkButtonActivated); // _debugMenu.AddMenuItem("Debug XBL Login", BedrockEditionButtonPressed); _debugMenu.AddMenuItem("Go Back", DebugGoBackPressed); #endregion #region Create SPMenu _spMenu = new GuiStackMenu() { Margin = new Thickness(15, 0, 15, 0), Padding = new Thickness(0, 50, 0, 0), Width = 125, Anchor = Alignment.FillY | Alignment.MinX, ChildAnchor = Alignment.CenterY | Alignment.FillX, BackgroundOverlay = new Color(Color.Black, 0.35f), }; _spMenu.AddMenuItem("SinglePlayer", () => {}, false); _spMenu.AddMenuItem("Debug Worlds", OnDebugPressed); _spMenu.AddMenuItem("Return to main menu", SpBackPressed); #endregion CreateProtocolMenu(); AddChild(_mainMenu); AddChild(_logo = new GuiImage(GuiTextures.AlexLogo) { Margin = new Thickness(95, 25, 0, 0), Anchor = Alignment.TopCenter }); AddChild(_splashText = new GuiTextElement() { TextColor = TextColor.Yellow, Rotation = 17.5f, Margin = new Thickness(240, 15, 0, 0), Anchor = Alignment.TopCenter, Text = "Who liek minecwaf?!", }); _debugInfo = new GuiDebugInfo(); _debugInfo.AddDebugRight(() => $"GPU Memory: {API.Extensions.GetBytesReadable(GpuResourceManager.GetMemoryUsage)}"); _debugInfo.AddDebugLeft(() => $"FPS: {FpsMonitor.Value:F0}"); _playerProfileService = Alex.Services.GetService <IPlayerProfileService>(); _playerProfileService.ProfileChanged += PlayerProfileServiceOnProfileChanged; Alex.GameStateManager.AddState("options", new OptionsState(_backgroundSkyBox)); }