public DebugConsole(SpriteFont font) { GenerateCommands(); #region GUI this.font = font; inputText = new GuiText(this.font) { Text = "", Position = new Vector2(10, ((Game1.ScreenHeight / 4) * 3)), Colour = Color.White, Layer = 0.975f }; outputText = new GuiText(this.font) { Text = "Type 'help' for a list of all available commands.\n", Position = new Vector2(10, 10), Colour = Color.White, Layer = 0.975f }; rectangle = new Rectangle( 0, 0, Game1.ScreenWidth, (Game1.ScreenHeight / 4) * 3 ); #endregion }
public EmptyPlanetView(Action onColonizationChange) { this.onColonizationChange = onColonizationChange; this.Background = new BackgroundTexture(GalaxyTextures.Get.PanelBackground, 6); this.Position.FixedSize(360, 116); this.title = new GuiText { Margins = new Vector2(8, 4), TextColor = Color.Black, TextHeight = 12 }; this.title.Position.WrapContent().Then.ParentRelative(-1, 1).UseMargins(); this.AddChild(this.title); this.colonizeButton = new GuiButton { BackgroundHover = new BackgroundTexture(GalaxyTextures.Get.ButtonHover, 9), BackgroundNormal = new BackgroundTexture(GalaxyTextures.Get.ButtonNormal, 9), Padding = 10, Margins = new Vector2(8, 8), TextColor = Color.Black, TextHeight = 12, ClickCallback = colonizeButton_Click }; this.colonizeButton.Position.FixedSize(88, 88).ParentRelative(-1, -1).UseMargins(); this.AddChild(this.colonizeButton); }
public void SetResults(ResultsController controller) { foreach (var cellText in this.tableCells) { this.RemoveElement(cellText); } //TODO(later) add table header var scores = controller.Scores.OrderByDescending(x => x.VictoryPoints).ToList(); var formatter = new DecimalsFormatter(0, 0); for (int i = 0; i < scores.Count; i++) { var score = new GuiText { TextColor = Color.White, TextHeight = 30, Text = formatter.Format(scores[i].VictoryPoints) }; score.Position.WrapContent().Then.RelativeTo(this.title, 0, -1, 1, 1).Then.Offset(-30, -20 + -40 * i); this.AddElement(score); this.tableCells.Add(score); var name = new GuiText { TextColor = Color.White, TextHeight = 30, Text = scores[i].Player.Name }; name.Position.WrapContent().Then.RelativeTo(this.title, 0, -1, -1, 1).Then.Offset(30, -20 + -40 * i); this.AddElement(name); this.tableCells.Add(name); } }
public void displayWin(SIDE type) { String str = "Dwarves win!"; String img = "Images\\dwarfbig.png"; if (type == SIDE.TROLL) { str = "Trolls win!"; img = "Images\\trollbig.png"; } GuiText text = new GuiText(300, 300); text.setText(str); text.setFontColor(Color.Black); text.setFontSize(75); text.receivesInput(false); this.addActor(text); GuiButton image = new GuiButton(400, 500); image.setImage(img); image.receivesInput(false); this.addActor(image); }
private void createGUI() { GuiButton stopButton = new GuiButton(890, 870); stopButton.OnClickEvent += new GuiButton.ClickEventHandler(stopButton_OnClickEvent); this.addActor(stopButton); turnButton = new GuiButton(890, 10); turnButton.OnClickEvent += new GuiButton.ClickEventHandler(turnButton_OnClickEvent); turnButton.setImage("Images\\turndwarf.png"); turnButton.setImageActive("Images\\turndwarf_a.png"); this.addActor(turnButton); GuiButton dwarf = new GuiButton(20, 0); dwarf.receivesInput(false); dwarf.setImage("Images\\dwarf.png"); this.addActor(dwarf); GuiButton troll = new GuiButton(20, 70); troll.receivesInput(false); troll.setImage("Images\\troll.png"); this.addActor(troll); dwarfScore = new GuiText(90, 0); dwarfScore.setText("32"); this.addActor(dwarfScore); trollScore = new GuiText(90, 70); trollScore.setText("32"); this.addActor(trollScore); }
public void addText(string name, CuiRectTransformComponent rectangle, GuiText text = null, float FadeIn = 0, float FadeOut = 0, string parent = "Hud") { if (string.IsNullOrEmpty(name)) { name = "text"; } else { name = PluginInstance.encodeName(this, name); } purgeDuplicates(name); text.FadeIn = FadeIn; this.Add(new CuiElement { Parent = PluginInstance.encodeName(this, parent), Name = name, Components = { text, rectangle }, FadeOut = FadeOut }); }
public void sendBounty(BasePlayer player, Bounty bounty) { #if DEBUG player.ChatMessage($"sendBounty: {bounty.placerName} -> {bounty.targetName}"); #endif closeBounty(player); GuiContainer c = new GuiContainer(this, "bountyPreview"); //template Rectangle templatePos = new Rectangle(623, 26, 673, 854, resX, resY, true); c.addImage("template", templatePos, "bounty_template", GuiContainer.Layer.hud, FadeIn: FadeIn, FadeOut: FadeOut); //targetName Rectangle targetNamePos = new Rectangle(680, 250, 560, 65, resX, resY, true); int fontsize = guiCreator.getFontsizeByFramesize(bounty.targetName.Length, targetNamePos); GuiText targetNameText = new GuiText(bounty.targetName, fontsize); c.addText("targetName", targetNamePos, GuiContainer.Layer.hud, targetNameText, FadeIn, FadeOut); //image if (config.showSteamImage) { Rectangle imagePos = new Rectangle(828, 315, 264, 264, resX, resY, true); c.addImage("image", imagePos, bounty.targetID.ToString(), GuiContainer.Layer.hud, FadeIn: FadeIn, FadeOut: FadeOut); } //reward Rectangle rewardPos = new Rectangle(680, 579, 560, 53, resX, resY, true); string reward = $"{bounty.rewardAmount} {bounty.reward.info.displayName.english}"; GuiText rewardText = new GuiText(reward, guiCreator.getFontsizeByFramesize(reward.Length, rewardPos)); c.addText("reward", rewardPos, GuiContainer.Layer.hud, rewardText, FadeIn, FadeOut); //reason Rectangle reasonPos = new Rectangle(680, 681, 560, 53, resX, resY, true); GuiText reasonText = new GuiText(bounty.reason, 14); c.addText("reason", reasonPos, GuiContainer.Layer.hud, reasonText, FadeIn, FadeOut); //placerName Rectangle placerNamePos = new Rectangle(680, 771, 560, 36, resX, resY, true); GuiText placerNameText = new GuiText(bounty.placerName, guiCreator.getFontsizeByFramesize(bounty.placerName.Length, placerNamePos)); c.addText("placerName", placerNamePos, GuiContainer.Layer.hud, placerNameText, FadeIn, FadeOut); //exitButton Rectangle closeButtonPos = new Rectangle(1296, 52, 60, 60, resX, resY, true); c.addButton("close", closeButtonPos, GuiContainer.Layer.hud, darkRed, FadeIn, FadeOut, new GuiText("X", 24, lightRed), blur: GuiContainer.Blur.medium); c.display(player); //button if (bounty.hunt != null) { huntButton(player, bounty, huntErrorType.huntActive); } else { huntButton(player, bounty); } }
public void Start() { _Time = 0; _Keys.Clear(); _TimeText = TimeUI.GetComponent <GuiText>(); _SpeedText = SpeedUI.GetComponent <GuiText>(); _LeftParticlesEmitter = LeftWheelParticles.GetComponent <ParticleEmitter>(); _RightParticlesEmitter = RightWheelParticles.GetComponent <ParticleEmitter>(); }
public GuiButton(Texture2D tex, Texture2D hoverTex = null, Texture2D pressTex = null, GuiText text = null) { this.texture = tex; this.hoverTexture = hoverTex; this.pressTexture = pressTex; this.Text = text; Origin = new Vector2((int)texture.Width / 2, (int)texture.Height / 2); }
public Button() { text = new GuiText(); text.Font = FontManager.Get("OpenSans-Regular"); text.FontSize = 20; text.Smooth = 0.5f; text.Text = "Button"; TextBaseline = 35; }
public UnitStatus() { this.Background = new BackgroundTexture(GalaxyTextures.Get.PanelBackground, 6); this.Position.FixedSize(360, 50); this.shipCount = new GuiText { Margins = new Vector2(8, 4), TextColor = Color.Black, TextHeight = 12 }; this.shipCount.Position.WrapContent().Then.ParentRelative(-1, 1).UseMargins(); this.AddChild(this.shipCount); this.movementInfo = new GuiText { Margins = new Vector2(0, 4), TextColor = Color.Black, TextHeight = 12 }; this.movementInfo.Position.WrapContent().Then.RelativeTo(this.shipCount, -1, -1, -1, 1).UseMargins(); this.AddChild(this.movementInfo); this.doneButon = new GuiButton { BackgroundHover = new BackgroundTexture(GalaxyTextures.Get.ButtonHover, 9), BackgroundNormal = new BackgroundTexture(GalaxyTextures.Get.ButtonNormal, 9), Padding = 6, Margins = new Vector2(0, 4), TextColor = Color.Black, TextHeight = 12, Text = textFor("UnitDone").Text(), ClickCallback = this.unitDone }; this.doneButon.Position.FixedSize(80, 40).ParentRelative(0, 1).UseMargins().StretchBottomTo(this, -1); this.AddChild(this.doneButon); this.armorInfo = new GuiText { Margins = new Vector2(15, 4), TextColor = Color.Black, TextHeight = 12 }; this.armorInfo.Position.WrapContent().Then.RelativeTo(this.doneButon, 1, 1, -1, 1).UseMargins(); this.AddChild(this.armorInfo); this.shieldsInfo = new GuiText { Margins = new Vector2(0, 4), TextColor = Color.Black, TextHeight = 12 }; this.shieldsInfo.Position.WrapContent().Then.RelativeTo(this.armorInfo, -1, -1, -1, 1).UseMargins(); this.AddChild(this.shieldsInfo); }
/// <summary> /// Loads the content. /// </summary> public override void LoadContent() { text = new GuiText { Margins = 2 }; Children.Add(text); 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 GameOverScene() { this.title = new GuiText { TextColor = Color.Red, TextHeight = 64, Text = LocalizationManifest.Get.CurrentLanguage["FormMain"]["GameOver"].Text() }; this.title.Position.WrapContent().Then.ParentRelative(0, 1).WithMargins(0, 20); this.AddElement(this.title); }
public void sendTargetIndicator(BasePlayer player, Hunt hunt) { if (!config.showTargetIndicator) { return; } #if DEBUG player.ChatMessage($"sendTargetIndicator: {hunt.hunterName} -> {hunt.bounty.targetName}"); #endif if (player == null) { return; } if (player.IsSleeping()) { return; } GuiContainer c = new GuiContainer(this, "targetIndicator"); //Background Rectangle bgPos = new Rectangle(50, 250, 350, 100, resX, resY, true); float distance = config.safeDistance; if (hunt.hunter?.transform != null && hunt.target?.transform != null) { distance = Vector3.Distance(hunt.hunter.transform.position, hunt.target.transform.position); } GuiColor bgColor = config.showDistance?gradientRedYellowGreen(Mathf.Clamp((distance / config.safeDistance), 0, 1)):lightGrey; bgColor.setAlpha(0.5f); c.addPlainPanel("Background", bgPos, GuiContainer.Layer.hud, bgColor, 0, 0, GuiContainer.Blur.medium); //TopLine Rectangle topLinePos = new Rectangle(50, 250, 350, 50, resX, resY, true); string TopLineString = $"You are being hunted{(config.showHunter?$" by {hunt.hunterName}":"")}!"; int topLineFontsize = guiCreator.getFontsizeByFramesize(TopLineString.Length, topLinePos); GuiText topLineText = new GuiText(TopLineString, topLineFontsize, opaqueWhite); c.addText("topline", topLinePos, GuiContainer.Layer.hud, topLineText); //BottomLine Rectangle bottomLinePos = new Rectangle(50, 300, 350, 20, resX, resY, true); string bottomLineString = "You can run, but you can't hide!"; int bottomLineFontsize = guiCreator.getFontsizeByFramesize(bottomLineString.Length, bottomLinePos); GuiText bottomLineText = new GuiText(bottomLineString, bottomLineFontsize, opaqueWhite); c.addText("bottomLine", bottomLinePos, GuiContainer.Layer.hud, bottomLineText); //Countdown Rectangle CountdownPos = new Rectangle(50, 320, 350, 30, resX, resY, true); string CountdownString = hunt.remaining.ToString(@"hh\:mm\:ss"); int CountdownFontsize = guiCreator.getFontsizeByFramesize(CountdownString.Length, CountdownPos); GuiText CountdownText = new GuiText(CountdownString, CountdownFontsize, opaqueWhite); c.addText("Countdown", CountdownPos, GuiContainer.Layer.hud, CountdownText); c.display(player); }
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); } } }
static void Main(string[] args) { GameSystems.Initialize(new GameStartInfo() { GameName = "GuiSystemTestUnit", WindowName = "GuiSystemTestUnit", IconName = "", WindowSize = new Size <int>(1920, 1080) }); var guiText = new GuiText("This is a test text!", new Font(20), new Color <float>(0, 0, 0, 1)); var guiButton = new GuiButton(); var guiInputText = new GuiInputText("input", 100, DefaultInputTextProperty.Background, DefaultInputTextProperty.Frontground, new Font(30)); //guiInputText.GetComponent<InputTextGuiComponent>().Content = "2333"; guiInputText.GetComponent <InputTextGuiComponent>().CursorLocation = 1; guiInputText.GetComponent <TransformGuiComponent>().Position = new Position <float>(100, 100); (guiButton.GetComponent <ButtonGuiComponent>().Shape as RectangleShape).Size = new Size <float>(80, 40); //guiButton.GetComponent<TransformGuiComponent>().Position = new Position<float>(100, 100); guiButton.GetComponent <LogicGuiComponent>().EventParts.Get(GuiComponentSupportEvent.MouseClick) .Solver += (x, y) => { var eventArg = y as GuiComponentMouseClickEvent; if (eventArg.IsDown && eventArg.Button == MouseButton.Left) { Console.WriteLine(1); } }; GameSystems.SystemScene.Root.AddChild(guiButton); //GameSystems.SystemScene.Root.AddChild(guiText); GameSystems.SystemScene.Root.AddChild(guiInputText); GameSystems.VisualGuiSystem.GuiRenderDebugProperty = new GuiRenderDebugProperty() { //ShapeProperty = new ShapeDebugProperty(2.0f, new Color<float>(1, 0, 0, 1)) }; GameSystems.RunLoop(); }
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); }
private void SendEntry(BasePlayer player, KeyValuePair <BasePlayer, PlayerSummary> kvp, int count, int sizeEach, int gap, Action <BasePlayer> callback) { if (GuiTracker.getGuiTracker(player).getContainer(PluginInstance, "PlayerSearch") == null) { return; } GuiColor black60 = new GuiColor(0, 0, 0, 0.6f); GuiColor black40 = new GuiColor(0, 0, 0, 0.4f); GuiColor white70 = new GuiColor(1, 1, 1, 0.7f); GuiContainer c = new GuiContainer(PluginInstance, $"{count}ImageContainer", "PlayerSearch"); //background Rectangle entryBgPos = new Rectangle(715, 360 + count * (sizeEach + gap), 490, 80, 1920, 1080, true); c.addPlainPanel($"{count}EntryBG", entryBgPos, GuiContainer.Layer.overall, black60, 0.2f, 0); //ID Rectangle idPos = new Rectangle(795, 365 + count * (sizeEach + gap), 405, 35, 1920, 1080, true); GuiText idText = new GuiText($"[{kvp.Key.userID}]", 14, white70); c.addText($"{count}id", idPos, GuiContainer.Layer.overall, idText, 0.2f, 0); //Name Rectangle namePos = new Rectangle(795, 400 + count * (sizeEach + gap), 405, 35, 1920, 1080, true); GuiText nameText = new GuiText($"{kvp.Key.displayName}", getFontsizeByFramesize(kvp.Key.displayName.Length, namePos), white70); c.addText($"{count}name", namePos, GuiContainer.Layer.overall, nameText, 0.2f, 0); //button Action <BasePlayer, string[]> buttonCb = (p2, a) => { GuiTracker.getGuiTracker(player).destroyGui(PluginInstance, "PlayerSearch"); callback(kvp.Key); }; c.addPlainButton($"{count}btnOverlay", entryBgPos, GuiContainer.Layer.overall, new GuiColor(0, 0, 0, 0), 0.2f, 0, callback: buttonCb, CursorEnabled: true); Rectangle imgPos = new Rectangle(720, 365 + count * (sizeEach + gap), 70, 70, 1920, 1080, true); c.addButton($"{count}Image", imgPos, GuiContainer.Layer.overall, null, 0.2f, 0, callback: buttonCb, close: "PlayerSearch", imgName: kvp.Key.UserIDString); c.display(player); }
private void SendButton() { GuiContainer c = new GuiContainer(PluginInstance, "Ok", nameof(ColorPicker)); Rectangle pos = new Rectangle(1160, 540, 150, 60, resX, resY, true); GuiColor color = new GuiColor(0, 1, 0, 0.5f); GuiText text = new GuiText("OK", 30, GuiColor.White.withAlpha(0.7f)); Action <BasePlayer, string[]> callback = (p, a) => { Callback?.Invoke(new GuiColor(Hue, Value, Saturation, 1)); GuiTracker.getGuiTracker(Player).destroyGui(PluginInstance, nameof(ColorPicker)); }; c.addPlainButton("button", pos, layer, color, fadeIn, fadeOut, text, callback); c.display(Player); }
public void sendHunterIndicator(BasePlayer player, Hunt hunt) { #if DEBUG player.ChatMessage($"sendHunterIndicator: {hunt.hunterName} -> {hunt.bounty.targetName}"); #endif if (player == null) { return; } if (player.IsSleeping()) { return; } GuiContainer c = new GuiContainer(this, "hunterIndicator"); //Background Rectangle bgPos = new Rectangle(50, 100, 350, 150, resX, resY, true); c.addPlainPanel("bg", bgPos, GuiContainer.Layer.hud, lightGrey, 0, 0, GuiContainer.Blur.medium); //Name Rectangle namePos = new Rectangle(50, 100, 350, 35, resX, resY, true); string nameTextString = $"You are hunting {hunt.bounty.targetName}"; int fontsize = guiCreator.getFontsizeByFramesize(nameTextString.Length, namePos); GuiText nameText = new GuiText(nameTextString, fontsize, opaqueWhite); c.addText("name", namePos, GuiContainer.Layer.hud, nameText); //Last Seen if (config.showLastSeen) { Rectangle lastSeenPos = new Rectangle(50, 135, 350, 80, resX, resY, true); string lastSeenString = hunt.lastSeen(); GuiText lastSeenText = new GuiText(lastSeenString, 10, opaqueWhite); c.addText("lastSeen", lastSeenPos, GuiContainer.Layer.hud, lastSeenText); } //Countdown Rectangle countdownPos = new Rectangle(50, 215, 350, 35, resX, resY, true); GuiText countdownText = new GuiText(hunt.remaining.ToString(@"hh\:mm\:ss"), 20, opaqueWhite); c.addText("countdown", countdownPos, GuiContainer.Layer.hud, countdownText); c.display(player); }
private void SetupGui() { _menuPanel = new GuiPanel(new Rect(20, 240, 200, 190), Color.red); _menuText = new GuiText(new Rect(75, 240, 180, 20), Color.red, MenuTextName); _authorText = new GuiText(new Rect(100, 257, 180, 20), Color.white, AuthorTextName); _wallHackButton = new GuiButton(new Rect(30, 280, 180, 20), WallHackButtonName); _aimHackButton = new GuiButton(new Rect(30, 310, 180, 20), AimHackButtonName); _speedHackButton = new GuiButton(new Rect(30, 340, 180, 20), SpeedHackButtonName); _flyHackButton = new GuiButton(new Rect(30, 370, 180, 20), FlyHackButtonName); _recoilHackButton = new GuiButton(new Rect(30, 400, 180, 20), RecoilHackButtonName); _statusText = new GuiText(new Rect(5, 5, 640, 20), Color.white, "Info"); _wallHackButton.OnButtonClicked += OnWallHackButtonClicked; _aimHackButton.OnButtonClicked += OnAimHackButtonClicked; _speedHackButton.OnButtonClicked += OnSpeedHackButtonClicked; _flyHackButton.OnButtonClicked += OnFlyHackButtonClicked; _recoilHackButton.OnButtonClicked += OnRecoilHackButtonClicked; }
private void SendBackgound() { GuiContainer c = new GuiContainer(PluginInstance, nameof(ColorPicker)); //clickout c.addPlainButton("close", new Rectangle(), layer, GuiColor.Transparent); //Panel Rectangle panelPos = new Rectangle(560, 265, 800, 550, resX, resY, true); GuiColor panelColor = new GuiColor(0, 0, 0, 0.5f); c.addPlainPanel("bgPanel", panelPos, layer, panelColor, fadeIn, fadeOut, GuiContainer.Blur.medium); //Label Rectangle labelPos = new Rectangle(560, 265, 800, 60, resX, resY, true); GuiText labelText = new GuiText(header, 30, GuiColor.White.withAlpha(0.7f)); c.addText("bgLabel", labelPos, layer, labelText, fadeIn, fadeOut); c.display(Player); }
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 ConstructionSiteView() { this.Background = new BackgroundTexture(GalaxyTextures.Get.PanelBackground, 6); this.Position.FixedSize(360, 116); this.title = new GuiText { Margins = new Vector2(8, 4), TextColor = Color.Black, TextHeight = 12 }; this.title.Position.WrapContent().Then.ParentRelative(-1, 1).UseMargins(); this.AddChild(this.title); this.projectButton = new GuiButton { BackgroundHover = new BackgroundTexture(GalaxyTextures.Get.ButtonHover, 9), BackgroundNormal = new BackgroundTexture(GalaxyTextures.Get.ButtonNormal, 9), Padding = 10, Margins = new Vector2(8, 8), TextColor = Color.Black, TextHeight = 12, ClickCallback = projectButton_Click }; this.projectButton.Position.FixedSize(88, 88).ParentRelative(-1, -1).UseMargins(); this.AddChild(this.projectButton); this.detailsButton = new GuiButton { BackgroundHover = new BackgroundTexture(GalaxyTextures.Get.ButtonHover, 9), BackgroundNormal = new BackgroundTexture(GalaxyTextures.Get.ButtonNormal, 9), Padding = 10, Margins = new Vector2(8, 8), TextColor = Color.Black, TextHeight = 12, Text = context["SiteDetails"].Text(), ClickCallback = detailsButton_Click }; this.detailsButton.Position.WrapContent().Then.ParentRelative(1, -1).UseMargins(); this.AddChild(this.detailsButton); this.investmentSlider = new GuiSlider { Margins = new Vector2(8, 0), ScrollStep = 0.05f, SlideCallback = investmentSlider_Change }; this.investmentSlider.Position.FixedSize(150, 15).RelativeTo(this.projectButton, 1, 1, -1, 1).UseMargins().StretchRightTo(this, 1); this.AddChild(this.investmentSlider); this.estimationLabel = new GuiText { Margins = new Vector2(0, 8), TextColor = Color.Black, TextHeight = 12 }; this.estimationLabel.Position.WrapContent().Then.RelativeTo(this.investmentSlider, -1, -1, -1, 1).UseMargins(); this.AddChild(this.estimationLabel); this.policyToggle = new CycleButton <PolicyInfo> { BackgroundHover = new BackgroundTexture(GalaxyTextures.Get.ToggleHover, 8), BackgroundNormal = new BackgroundTexture(GalaxyTextures.Get.ToggleNormal, 8), Padding = 4, Margins = new Vector2(8, 0), CycleCallback = x => { this.controller.Policy = x; this.investmentSlider.Value = (float)this.controller.DesiredSpendingRatio; this.resetView(); this.scene.ResetTooltipContents(); }, ItemImage = x => GalaxyTextures.Get.Sprite(x.Id + "Policy"), Tooltip = new DynamicTooltip("FormMain", () => this.controller.Policy.Id + "PolicyTooltip") }; this.policyToggle.Position.FixedSize(32, 32).RelativeTo(this.projectButton, 1, -1, -1, -1).UseMargins(); this.AddChild(this.policyToggle); this.policyName = new GuiText { Margins = new Vector2(8, 0), TextColor = Color.Black, TextHeight = 12 }; this.policyName.Position.WrapContent().Then.RelativeTo(this.policyToggle, 1, 0, -1, 0).UseMargins(); this.AddChild(this.policyName); }
public IntroScene(Action newGameCallback, Action loadGameCallback, Action settingsCallback, Action quitCallback) { this.cancelText = new GuiText() { Margins = new Vector2(5, 5), Text = LocalizationManifest.Get.CurrentLanguage["Intro"]["cancelTip"].Text(), TextColor = Color.FromArgb(0, Color.Gray), TextHeight = 16, Animation = textPolygons => new AnimationSequence( new AnimationDelay(1), new TweenAlpha(textPolygons, 0, 1, 0.5) ) }; this.cancelText.Position.WrapContent().Then.ParentRelative(-1, -1).UseMargins(); this.AddElement(this.cancelText); this.menuPanel = new GuiPanel(); this.menuPanel.Position.WrapContent().Then.ParentRelative(0, 0).Then.Offset(150, 0); var context = LocalizationManifest.Get.CurrentLanguage["FormMainMenu"]; var newGameButton = new GuiButton { ClickCallback = newGameCallback, BackgroundHover = new BackgroundTexture(GalaxyTextures.Get.ButtonHover, 9), BackgroundNormal = new BackgroundTexture(GalaxyTextures.Get.ButtonNormal, 9), Padding = 12, Text = context["NewGame"].Text(), TextColor = Color.Black, TextHeight = 20 }; newGameButton.Position.WrapContent().Then.ParentRelative(0, 1); this.menuPanel.AddChild(newGameButton); var loadButton = new GuiButton { ClickCallback = loadGameCallback, BackgroundHover = new BackgroundTexture(GalaxyTextures.Get.ButtonHover, 9), BackgroundNormal = new BackgroundTexture(GalaxyTextures.Get.ButtonNormal, 9), Padding = 12, Margins = new Vector2(0, 25), Text = context["Save"].Text(), TextColor = Color.Black, TextHeight = 20 }; loadButton.Position.WrapContent().Then.RelativeTo(newGameButton, 0, -1, 0, 1).UseMargins(); this.menuPanel.AddChild(loadButton); var settingsButton = new GuiButton { ClickCallback = settingsCallback, BackgroundHover = new BackgroundTexture(GalaxyTextures.Get.ButtonHover, 9), BackgroundNormal = new BackgroundTexture(GalaxyTextures.Get.ButtonNormal, 9), Padding = 12, Margins = new Vector2(0, 25), Text = context["Settings"].Text(), TextColor = Color.Black, TextHeight = 20 }; settingsButton.Position.WrapContent().Then.RelativeTo(loadButton, 0, -1, 0, 1).UseMargins(); this.menuPanel.AddChild(settingsButton); var quitButton = new GuiButton { ClickCallback = quitCallback, BackgroundHover = new BackgroundTexture(GalaxyTextures.Get.ButtonHover, 9), BackgroundNormal = new BackgroundTexture(GalaxyTextures.Get.ButtonNormal, 9), Padding = 12, Margins = new Vector2(0, 25), Text = context["Quit"].Text(), TextColor = Color.Black, TextHeight = 20 }; quitButton.Position.WrapContent().Then.RelativeTo(settingsButton, 0, -1, 0, 1).UseMargins(); this.menuPanel.AddChild(quitButton); }
public GalaxyScene(IGalaxyViewListener galaxyViewListener, Action mainMenuCallback) { this.galaxyViewListener = galaxyViewListener; this.reportOpener = new OpenReportVisitor(showDevelopment, showResearch); var mainMenuButton = new GuiButton { BackgroundHover = new BackgroundTexture(GalaxyTextures.Get.ToggleHover, 7), BackgroundNormal = new BackgroundTexture(GalaxyTextures.Get.ToggleNormal, 7), ForgroundImage = GalaxyTextures.Get.MainMenu, Padding = 4, ClickCallback = mainMenuCallback, Tooltip = new SimpleTooltip("GalaxyScene", "MainMenuTooltip") }; mainMenuButton.Position.FixedSize(36, 32).ParentRelative(-1, 1).WithMargins(5, 5); this.AddElement(mainMenuButton); this.fuelInfo = new GuiText { TextColor = Color.Yellow, TextHeight = 24, Tooltip = new SimpleTooltip("GalaxyScene", "FuelTooltip") }; this.fuelInfo.Position.WrapContent().Then.RelativeTo(mainMenuButton, 1, 0, -1, 0).WithMargins(20, 5); this.AddElement(this.fuelInfo); var designButton = new GuiButton { BackgroundHover = new BackgroundTexture(GalaxyTextures.Get.ToggleHover, 7), BackgroundNormal = new BackgroundTexture(GalaxyTextures.Get.ToggleNormal, 7), ForgroundImage = GalaxyTextures.Get.Design, PaddingX = 12, PaddingY = 4, ClickCallback = () => { using (var form = new FormShipDesignList(this.currentPlayer)) form.ShowDialog(); }, Tooltip = new SimpleTooltip("GalaxyScene", "DesignTooltip") }; designButton.Position.FixedSize(48, 32).RelativeTo(fuelInfo, 1, 0, -1, 0).WithMargins(20, 5); this.AddElement(designButton); var developmentButton = new GuiButton { BackgroundHover = new BackgroundTexture(GalaxyTextures.Get.ToggleHover, 7), BackgroundNormal = new BackgroundTexture(GalaxyTextures.Get.ToggleNormal, 7), ForgroundImage = GalaxyTextures.Get.Development, PaddingX = 12, PaddingY = 4, ClickCallback = this.showDevelopment, Tooltip = new SimpleTooltip("GalaxyScene", "DevelopmentTooltip") }; developmentButton.Position.FixedSize(48, 32).RelativeTo(designButton, 1, 0, -1, 0).WithMargins(5, 5); this.AddElement(developmentButton); var researchButton = new GuiButton { BackgroundHover = new BackgroundTexture(GalaxyTextures.Get.ToggleHover, 7), BackgroundNormal = new BackgroundTexture(GalaxyTextures.Get.ToggleNormal, 7), ForgroundImage = GalaxyTextures.Get.Research, PaddingX = 12, PaddingY = 4, ClickCallback = this.showResearch, Tooltip = new SimpleTooltip("GalaxyScene", "ResearchTooltip") }; researchButton.Position.FixedSize(48, 32).RelativeTo(developmentButton, 1, 0, -1, 0).WithMargins(5, 5); this.AddElement(researchButton); var diplomacyButton = new GuiButton { BackgroundHover = new BackgroundTexture(GalaxyTextures.Get.ToggleHover, 7), BackgroundNormal = new BackgroundTexture(GalaxyTextures.Get.ToggleNormal, 7), ForgroundImage = GalaxyTextures.Get.Diplomacy, PaddingX = 12, PaddingY = 4, ClickCallback = () => { using (var form = new FormRelations(this.currentPlayer)) form.ShowDialog(); }, Tooltip = new SimpleTooltip("GalaxyScene", "DiplomacyTooltip") }; diplomacyButton.Position.FixedSize(48, 32).RelativeTo(researchButton, 1, 0, -1, 0).WithMargins(5, 5); this.AddElement(diplomacyButton); var colonizationButton = new GuiButton { BackgroundHover = new BackgroundTexture(GalaxyTextures.Get.ToggleHover, 7), BackgroundNormal = new BackgroundTexture(GalaxyTextures.Get.ToggleNormal, 7), ForgroundImage = GalaxyTextures.Get.Colonization, PaddingX = 12, PaddingY = 4, ClickCallback = () => { using (var form = new FormColonization(this.currentPlayer)) form.ShowDialog(); }, Tooltip = new SimpleTooltip("GalaxyScene", "ColonizationTooltip") }; colonizationButton.Position.FixedSize(48, 32).RelativeTo(diplomacyButton, 1, 0, -1, 0).WithMargins(5, 5); this.AddElement(colonizationButton); var reportsButton = new GuiButton { BackgroundHover = new BackgroundTexture(GalaxyTextures.Get.ToggleHover, 7), BackgroundNormal = new BackgroundTexture(GalaxyTextures.Get.ToggleNormal, 7), ForgroundImage = GalaxyTextures.Get.Reports, PaddingX = 12, PaddingY = 4, ClickCallback = () => { using (var form = new FormReports(this.currentPlayer.Reports)) if (form.ShowDialog() == DialogResult.OK) { form.Result.Accept(this.reportOpener); } }, Tooltip = new SimpleTooltip("GalaxyScene", "ReportsTooltip") }; reportsButton.Position.FixedSize(48, 32).RelativeTo(colonizationButton, 1, 0, -1, 0).WithMargins(5, 5); this.AddElement(reportsButton); var stareaterButton = new GuiButton { BackgroundHover = new BackgroundTexture(GalaxyTextures.Get.ToggleHover, 7), BackgroundNormal = new BackgroundTexture(GalaxyTextures.Get.ToggleNormal, 7), ForgroundImage = GalaxyTextures.Get.Stareater, PaddingX = 12, PaddingY = 4, ClickCallback = () => { using (var form = new FormStareater(this.currentPlayer.Stareater)) form.ShowDialog(); }, Tooltip = new SimpleTooltip("GalaxyScene", "StareaterTooltip") }; stareaterButton.Position.FixedSize(48, 32).RelativeTo(reportsButton, 1, 0, -1, 0).WithMargins(5, 5); this.AddElement(stareaterButton); var libraryButton = new GuiButton { BackgroundHover = new BackgroundTexture(GalaxyTextures.Get.ToggleHover, 7), BackgroundNormal = new BackgroundTexture(GalaxyTextures.Get.ToggleNormal, 7), ForgroundImage = GalaxyTextures.Get.Library, PaddingX = 12, PaddingY = 4, ClickCallback = () => { using (var form = new FormLibrary(this.currentPlayer.Library)) form.ShowDialog(); }, Tooltip = new SimpleTooltip("GalaxyScene", "LibraryTooltip") }; libraryButton.Position.FixedSize(48, 32).RelativeTo(stareaterButton, 1, 0, -1, 0).WithMargins(5, 5); this.AddElement(libraryButton); this.turnCounter = new GuiText { TextColor = Color.LightGray, TextHeight = 24 }; this.turnCounter.Position.WrapContent().Then.ParentRelative(1, 1).WithMargins(10, 5); this.AddElement(this.turnCounter); var turnButton = new GuiButton { BackgroundHover = new BackgroundTexture(GalaxyTextures.Get.EndTurnHover, 0), BackgroundNormal = new BackgroundTexture(GalaxyTextures.Get.EndTurnNormal, 0), ClickCallback = this.galaxyViewListener.TurnEnded, Tooltip = new SimpleTooltip("GalaxyScene", "EndTurn") }; turnButton.Position.FixedSize(80, 80).ParentRelative(1, -1).WithMargins(10, 10); this.AddElement(turnButton); var radarToggle = new ToggleButton(SettingsWinforms.Get.ShowScanRange) { BackgroundHover = new BackgroundTexture(GalaxyTextures.Get.ToggleHover, 7), BackgroundNormal = new BackgroundTexture(GalaxyTextures.Get.ToggleNormal, 7), BackgroundToggled = new BackgroundTexture(GalaxyTextures.Get.ToggleToggled, 7), ForgroundImage = new BackgroundTexture(GalaxyTextures.Get.Radar, 0), ToggleCallback = this.toggleRadar, Tooltip = new SimpleTooltip("GalaxyScene", "RadarSwitchToolip") }; radarToggle.Position.FixedSize(24, 24).RelativeTo(turnButton, -1, 1, 1, 1).WithMargins(15, 0); this.AddElement(radarToggle); this.starInfo = new ConstructionSiteView(); this.starInfo.Position.ParentRelative(0, -1).WithMargins(0, 0); this.AddElement(this.starInfo); }
private void SendPlayerSearchUI(BasePlayer player, KeyValuePair <BasePlayer, PlayerSummary>[] results, Action <BasePlayer> callback, int page = 0) { List <List <KeyValuePair <BasePlayer, PlayerSummary> > > listOfLists = SplitIntoChunks(results.ToList(), 5); GuiContainer c = new GuiContainer(PluginInstance, "PlayerSearch"); //clickout c.addPlainButton("close", new Rectangle(), GuiContainer.Layer.overall, new GuiColor(0, 0, 0, 0.3f), 0.1f, 0.1f, blur: GuiContainer.Blur.medium); GuiColor black60 = new GuiColor(0, 0, 0, 0.6f); GuiColor black40 = new GuiColor(0, 0, 0, 0.4f); GuiColor white70 = new GuiColor(1, 1, 1, 0.7f); //background Rectangle bgPos = new Rectangle(710, 260, 500, 560, 1920, 1080, true); c.addPlainPanel("background", bgPos, GuiContainer.Layer.overall, black60, 0.2f, 0, GuiContainer.Blur.medium); c.addPlainPanel("background2", bgPos, GuiContainer.Layer.overall, black60, 0.2f, 0, GuiContainer.Blur.greyout); //header Rectangle headerPos = new Rectangle(710, 260, 500, 60, 1920, 1080, true); GuiText headerText = new GuiText("Players found:", 20, white70); c.addText("header", headerPos, GuiContainer.Layer.overall, headerText, 0.2f, 0); //navigators if (page != 0) { //up Rectangle upPos = new Rectangle(945, 325, 30, 30, 1920, 1080, true); Action <BasePlayer, string[]> upCb = (p, a) => { SendPlayerSearchUI(player, results, callback, page - 1); }; c.addButton("upbtn", upPos, GuiContainer.Layer.overall, white70, 0.2f, 0, callback: upCb, imgName: "triangle_up"); } if (page != listOfLists.Count - 1) { //down Rectangle downPos = new Rectangle(945, 785, 30, 30, 1920, 1080, true); Action <BasePlayer, string[]> downCb = (p, a) => { SendPlayerSearchUI(player, results, callback, page + 1); }; c.addButton("downbtn", downPos, GuiContainer.Layer.overall, white70, 0.2f, 0, callback: downCb, imgName: "triangle_down"); } c.display(player); //entries int count = 0; int sizeEach = 80; int gap = 5; foreach (KeyValuePair <BasePlayer, PlayerSummary> kvp in listOfLists[page]) { int ccount = count; int csizeEach = sizeEach; int cgap = gap; Action imageCb = () => { SendEntry(player, kvp, ccount, csizeEach, cgap, callback); }; registerImage(PluginInstance, kvp.Key.UserIDString, kvp.Value.avatarfull, imageCb, true); count++; } }
public static GuiLabel GetNewGuiLabel(string name, Rectangle rectangle, GuiElement parent = null, Layer layer = Layer.hud, GuiText text = null, float fadeIn = 0, float fadeOut = 0) { Layer higherLayer = layer; if (parent != null) { higherLayer = (Layer)Math.Min((int)layer, (int)parent.Layer); } if (text != null) { text.FadeIn = fadeIn; } return(new GuiLabel { Name = name, Rectangle = rectangle.WithParent(parent?.Rectangle), Layer = higherLayer, Parent = layers[(int)higherLayer], Text = text, FadeOut = fadeOut, Components = { text, rectangle.WithParent(parent?.Rectangle) } }); }
public static List <GuiElement> GetNewGuiInputField( Plugin plugin, GuiContainer container, string name, Rectangle rectangle, Action <BasePlayer, string[]> callback, GuiElement parent, Layer layer, string close = null, GuiColor panelColor = null, int charLimit = 100, GuiText text = null, float FadeIn = 0, float FadeOut = 0, bool isPassword = false, bool CursorEnabled = true, 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); } StringBuilder closeString = new StringBuilder(""); if (close != null) { closeString.Append(" --close "); closeString.Append(close); } if (text != null) { text.FadeIn = FadeIn; } if (imgName != null || panelColor != null) { elements.AddRange( GuiPanel.GetNewGuiPanel( plugin, name + "_label", rectangle, parent, layer, panelColor, FadeIn, FadeOut, null, imgName, blur )); } elements.Add(new GuiElement { Name = name, Rectangle = rectangle.WithParent(parent?.Rectangle), Layer = higherLayer, Parent = layers[(int)higherLayer], FadeOut = FadeOut, ParentElement = parent, Components = { new CuiInputFieldComponent { Align = text.Align, FontSize = text.FontSize, Color = text.Color, Command = $"gui.input {plugin.Name} {container.name} {removeWhiteSpaces(name)}{closeString} --input", CharsLimit = charLimit, IsPassword = isPassword }, rectangle.WithParent(parent?.Rectangle) } }); if (CursorEnabled) { elements.Add(new GuiElement() { Name = name + "_cursor", Parent = name, Components = { new CuiNeedsCursorComponent() } }); } return(elements); }
public static List <GuiElement> GetNewGuiPlainButton( Plugin plugin, GuiContainer container, string name, Rectangle rectangle, GuiElement parent = null, Layer layer = Layer.hud, GuiColor panelColor = null, float fadeIn = 0, float fadeOut = 0, GuiText text = null, Action <BasePlayer, string[]> callback = null, string close = null, bool CursorEnabled = true, 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); } StringBuilder closeString = new StringBuilder(""); if (close != null) { closeString.Append(" --close "); closeString.Append(close); } string materialString = "Assets/Icons/IconMaterial.mat"; if (blur != Blur.none) { materialString = blurs[(int)blur]; } if (text != null) { text.FadeIn = fadeIn; } GuiPlainButton button = new GuiPlainButton { Name = name, Rectangle = rectangle.WithParent(parent?.Rectangle), Layer = higherLayer, Parent = layers[(int)higherLayer], ParentElement = parent, FadeOut = fadeOut, Components = { new CuiButtonComponent { Command = $"gui.input {plugin.Name} {container.name} {removeWhiteSpaces(name)}{closeString}", FadeIn = fadeIn, Color = panelColor?.getColorString() ?? "0 0 0 0", Material = materialString }, rectangle.WithParent(parent?.Rectangle) }, Label = new GuiLabel { Name = name + "_txt", Rectangle = new Rectangle(), Layer = higherLayer, Parent = name, Text = text, FadeOut = fadeOut, Components = { text, new Rectangle() } } }; elements.Add(button); if (text != null) { elements.Add(button.Label); } if (CursorEnabled) { elements.Add(new GuiElement() { Name = name + "_cursor", Parent = name, Components = { new CuiNeedsCursorComponent() } }); } return(elements); }