private void PerformLayout() { MouseFilter = MouseFilterMode.Stop; ToolTip = "Click to expand"; CustomMinimumSize = new Vector2(0, 25); VBox = new VBoxContainer { SeparationOverride = 0 }; AddChild(VBox); TopContainer = new HBoxContainer { SizeFlagsVertical = SizeFlags.FillExpand }; VBox.AddChild(TopContainer); BottomContainer = new HBoxContainer { Visible = false }; VBox.AddChild(BottomContainer); var smallFont = new VectorFont(_resourceCache.GetResource <FontResource>("/Fonts/CALIBRI.TTF"), 10); _bottomLabel = new Label { FontOverride = smallFont, FontColorOverride = Color.DarkGray }; BottomContainer.AddChild(_bottomLabel); NameLabel = new Label(); TopContainer.AddChild(NameLabel); }
protected override void LoadContent() { base.LoadContent(); vectorFont = Content.Load <VectorFont>("Arial-24-Vector"); bounceSound = Content.Load <SoundEffect>("rubber_ball_01"); }
public override void Draw(GameTime gameTime) { StateManager.graphicsDevice.Clear(Color.Black); Vector2 center = new Vector2(StateManager.graphicsDevice.Viewport.Width / 4, StateManager.graphicsDevice.Viewport.Height / 2); VectorFont.DrawString("Paused. Press P to resume", 7, center, Color.CornflowerBlue); }
public override void LoadContent() { VectorFont.Initialize(StateManager.game); spriteBatch = new SpriteBatch(StateManager.graphicsDevice); spriteFont = StateManager.Content.Load <SpriteFont>("Font"); oldKeyState = Keyboard.GetState(); }
protected static Control MakeTopBar(string top, string bottom) { if (top == bottom) { return(new Label { Text = top }); } var smallFont = new VectorFont(IoCManager.Resolve <IResourceCache>().GetResource <FontResource>("/Fonts/CALIBRI.TTF"), 10); // Custom ToString() implementation. var headBox = new VBoxContainer { SeparationOverride = 0 }; headBox.AddChild(new Label { Text = top }); headBox.AddChild(new Label { Text = bottom, FontOverride = smallFont, FontColorOverride = Color.DarkGray }); return(headBox); }
/// <summary> /// Create a 3D text with the font name (the asset name of the spritefont file), the text to render, /// and the mesh style /// </summary> /// <param name="fontToUse">String of the font type to use (the asset name of the spritefont file)</param> /// <param name="textToRender">String of the text to render</param> /// <param name="styleToUse">Type of rendering to use in how we create the 3D mesh</param> /// public Text3D(String fontToUse, String textToRender, UI3DRenderer.Text3DStyle styleToUse) : base() { basicTextToRender = textToRender; basicTextVectorFont = State.Content.Load <VectorFont>(fontToUse); this.styleToUse = styleToUse; CreateText(); }
/// <summary> /// Create a 3D text with the font, the text to render, and the mesh style /// </summary> /// <param name="fontToUse">Font type to use</param> /// <param name="textToRender">String of the text to render</param> /// <param name="styleToUse">Type of rendering to use in how we create the 3D mesh</param> public Text3D(VectorFont fontToUse, String textToRender, UI3DRenderer.Text3DStyle styleToUse) : base() { basicTextToRender = textToRender; basicTextVectorFont = fontToUse; this.styleToUse = styleToUse; CreateText(); }
public override void Draw(GameTime gameTime) { StateManager.graphicsDevice.Clear(Color.Black); float scale = 7f; Vector2 location = new Vector2(3, 3); VectorFont.DrawString("Programmed by", scale, location, Color.CornflowerBlue); location.Y += 3 * scale; VectorFont.DrawString("Aidan Fairman", scale, location, Color.Coral); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); textFont = Content.Load <SpriteFont>("Sample"); vectorFont = Content.Load <VectorFont>("Arial-24-Vector"); // TODO: use this.Content to load your game content here }
public override void Draw(GameTime gameTime) { StateManager.graphicsDevice.Clear(bgColor); lander.Draw(gameTime); terrain.Draw(gameTime); if (lander.State == Lander.landerState.playing) { float newFontScale = fontScale * 2.0f / 3.0f; Vector2 fontLocation = new Vector2(3, 3); VectorFont.DrawString(string.Format("Fuel {0:000.0}", lander.Fuel), fontScale, fontLocation, Color.CornflowerBlue); fontLocation.Y += (3 * fontScale); VectorFont.DrawString(string.Format("XSpeed {0:00.0}", lander.XSpeed), fontScale, fontLocation, Color.Coral); fontLocation.Y += (3 * fontScale); VectorFont.DrawString(string.Format("YSpeed {0:00.0}", lander.YSpeed), fontScale, fontLocation, Color.Coral); fontLocation.Y += (3 * fontScale); VectorFont.DrawString(string.Format("Angle {0:000}", lander.Angle), fontScale, fontLocation, Color.Coral); fontLocation.X = (StateManager.graphicsDevice.Viewport.Width / 10) * 7; fontLocation.Y = 3; VectorFont.DrawString("Esc to quit", newFontScale, fontLocation, Color.Coral); fontLocation.Y += 3 * newFontScale; VectorFont.DrawString("Space to thrust", newFontScale, fontLocation, Color.Coral); fontLocation.Y += 3 * newFontScale; VectorFont.DrawString("Right to rotate CW", newFontScale, fontLocation, Color.Coral); fontLocation.Y += 3 * newFontScale; VectorFont.DrawString("Left to rotate CCW", newFontScale, fontLocation, Color.Coral); } else if (lander.State == Lander.landerState.crashed) { Vector2 fontPlace = new Vector2(StateManager.graphicsDevice.Viewport.Width / 5 * 2, 4 * fontScale); VectorFont.DrawString("You Crashed", fontScale, fontPlace, Color.White); fontPlace.Y += 3 * fontScale; fontPlace.X = StateManager.graphicsDevice.Viewport.Width / 5; VectorFont.DrawString("You get no more points and are dead", fontScale, fontPlace, Color.White); fontPlace.Y += 3 * fontScale; VectorFont.DrawString(string.Format("You had {0:000000} points", StateManager.Score), fontScale, fontPlace, Color.White); fontPlace.Y += 3 * fontScale; VectorFont.DrawString("Press ESC to go back to menu", fontScale, fontPlace, Color.White); } else { Vector2 fontPlace = new Vector2(StateManager.graphicsDevice.Viewport.Width / 5 * 2, 4 * fontScale); VectorFont.DrawString("You Landed", fontScale, fontPlace, Color.Black); fontPlace.Y += 3 * fontScale; fontPlace.X = StateManager.graphicsDevice.Viewport.Width / 5; VectorFont.DrawString(string.Format("You get {0:0000} points", (lander.Fuel * 100)), fontScale, fontPlace, Color.Black); fontPlace.Y += 3 * fontScale; VectorFont.DrawString(string.Format("You have {0:0000} points", StateManager.Score), fontScale, fontPlace, Color.Black); fontPlace.Y += 3 * fontScale; fontPlace.X = StateManager.graphicsDevice.Viewport.Width / 10; VectorFont.DrawString("Press Enter to go to next landing site", fontScale, fontPlace, Color.Black); fontPlace.Y += 3 * fontScale; fontPlace.X = StateManager.graphicsDevice.Viewport.Width / 5; VectorFont.DrawString("Press ESC to go back to menu", fontScale, fontPlace, Color.Black); } }
public static Font GetFont(this IResourceCache cache, ResourcePath[] path, int size) { var fs = new Font[path.Length]; for (var i = 0; i < path.Length; i++) { fs[i] = new VectorFont(cache.GetResource <FontResource>(path[i]), size); } return(new StackedFont(fs)); }
public override void Draw(GameTime gameTime) { StateManager.graphicsDevice.Clear(Color.Black); float Scale = 7; Vector2 location = new Vector2(3, 3); VectorFont.DrawString("Press Enter to Play", Scale, location, Color.CornflowerBlue); location.Y += (3 * Scale); VectorFont.DrawString("Press C to see credits", Scale, location, Color.CornflowerBlue); location.Y += (3 * Scale); VectorFont.DrawString("Press Q to quit", Scale, location, Color.CornflowerBlue); }
public override void LoadContent() { lander = new Lander(StateManager.game); lander.Initialize(); VectorFont.Initialize(StateManager.game); terrain = new Terrain(StateManager.game); terrain.TerrainName = terrainFileName; terrain.Initialize(); sentScore = false; win = StateManager.Content.Load <SoundEffect>("LanderVictorySound"); lose = StateManager.Content.Load <SoundEffect>("LanderExplosionSound"); bgColor = Color.Black; oldKeyboardState = Keyboard.GetState(); }
public void TestVectorFontReading() { MockedGraphicsDeviceService service = new MockedGraphicsDeviceService(); using (IDisposable keeper = service.CreateDevice()) { using ( ResourceContentManager contentManager = new ResourceContentManager( GraphicsDeviceServiceHelper.MakePrivateServiceProvider(service), Resources.UnitTestResources.ResourceManager ) ) { VectorFont font = contentManager.Load <VectorFont>("UnitTestVectorFont"); Assert.IsNotNull(font); } } }
protected override void Initialize() { base.Initialize(); IoCManager.InjectDependencies(this); MouseFilter = MouseFilterMode.Stop; ToolTip = "Click to expand"; CustomMinimumSize = new Vector2(0, 25); VBox = new VBoxContainer { SeparationOverride = 0 }; AddChild(VBox); TopContainer = new HBoxContainer { SizeFlagsVertical = SizeFlags.FillExpand }; VBox.AddChild(TopContainer); BottomContainer = new HBoxContainer { Visible = false }; VBox.AddChild(BottomContainer); var resc = IoCManager.Resolve <IResourceCache>(); var smallFont = new VectorFont(resc.GetResource <FontResource>("/Fonts/CALIBRI.TTF")) { Size = 10, }; _bottomLabel = new Label { FontOverride = smallFont, FontColorOverride = Color.DarkGray }; BottomContainer.AddChild(_bottomLabel); NameLabel = new Label(); TopContainer.AddChild(NameLabel); }
public UIThemeDefault() { var res = IoCManager.Resolve <IResourceCache>(); var calibri = res.GetResource <FontResource>("/Fonts/CALIBRI.TTF"); DefaultFont = LabelFont = new VectorFont(calibri, 16); PanelPanel = new StyleBoxFlat { BackgroundColor = new Color(37, 37, 45) }; ButtonStyle = new StyleBoxFlat { BackgroundColor = Color.Gray }; ButtonStyle.SetContentMarginOverride(StyleBox.Margin.All, 5); LineEditBox = new StyleBoxFlat { BackgroundColor = Color.Blue }; LineEditBox.SetContentMarginOverride(StyleBox.Margin.All, 5); }
////////////////////////////////////////////////////////////////////////////// #region Console protected virtual CConsole CreateConsole() { Font consoleFont = new VectorFont(m_contentManager.Load <SpriteFont>("ConsoleFont")); CConsole console = new CConsole(consoleFont); console.RegisterCommand(new Cmd_exit()); console.RegisterCommand(new Cmd_listcmds()); console.RegisterCommand(new Cmd_listcvars()); console.RegisterCommand(new Cmd_exec()); console.RegisterCommand(new Cmd_write()); console.RegisterCommand(new Cmd_bind()); console.RegisterCommand(new Cmd_unbind()); console.RegisterCommand(new Cmd_unbind_all()); console.RegisterCommand(new Cmd_bindlist()); console.RegisterCommand(new Cmd_ctoggle()); console.RegisterCvar(CVars.g_drawViewBorders); console.RegisterCvar(CVars.d_demoTargetFrame); return(console); }
public TutorialWindow() { Title = "The Tutorial!"; //Get section header font var cache = IoCManager.Resolve <IResourceCache>(); Font headerFont = new VectorFont(cache.GetResource <FontResource>("/Nano/NotoSans/NotoSans-Regular.ttf"), _headerFontSize); var scrollContainer = new ScrollContainer(); scrollContainer.AddChild(VBox = new VBoxContainer()); Contents.AddChild(scrollContainer); //Intro VBox.AddChild(new Label { FontOverride = headerFont, Text = "Intro" }); AddFormattedText(IntroContents); //Controls VBox.AddChild(new Label { FontOverride = headerFont, Text = "Controls" }); AddFormattedText(QuickControlsContents); //Gameplay VBox.AddChild(new Label { FontOverride = headerFont, Text = "Gameplay" }); AddFormattedText(GameplayContents); //Feedback VBox.AddChild(new Label { FontOverride = headerFont, Text = "Feedback" }); AddFormattedText(FeedbackContents); }
public TutorialWindow() { Title = "The Tutorial!"; //Get section header font var cache = IoCManager.Resolve <IResourceCache>(); var inputManager = IoCManager.Resolve <IInputManager>(); Font headerFont = new VectorFont(cache.GetResource <FontResource>("/Nano/NotoSans/NotoSans-Regular.ttf"), _headerFontSize); var scrollContainer = new ScrollContainer(); scrollContainer.AddChild(VBox = new VBoxContainer()); Contents.AddChild(scrollContainer); //Intro VBox.AddChild(new Label { FontOverride = headerFont, Text = "Intro" }); AddFormattedText(IntroContents); string Key(BoundKeyFunction func) { return(FormattedMessage.EscapeText(inputManager.GetKeyFunctionButtonString(func))); } //Controls VBox.AddChild(new Label { FontOverride = headerFont, Text = "\nControls" }); // Moved this down here so that Rider shows which args correspond to which format spot. AddFormattedText(Loc.GetString(@"Movement: [color=#a4885c]{0} {1} {2} {3}[/color] Switch hands: [color=#a4885c]{4}[/color] Use held item: [color=#a4885c]{5}[/color] Drop held item: [color=#a4885c]{6}[/color] Open inventory: [color=#a4885c]{7}[/color] Open character window: [color=#a4885c]{8}[/color] Open crafting window: [color=#a4885c]{9}[/color] Focus chat: [color=#a4885c]{10}[/color] Use targeted entity: [color=#a4885c]{11}[/color] Throw held item: [color=#a4885c]{12}[/color] Examine entity: [color=#a4885c]{13}[/color] Open entity context menu: [color=#a4885c]{14}[/color] Toggle combat mode: [color=#a4885c]{15}[/color] Toggle console: [color=#a4885c]{16}[/color] Toggle UI: [color=#a4885c]{17}[/color] Toggle debug overlay: [color=#a4885c]{18}[/color] Toggle entity spawner: [color=#a4885c]{19}[/color] Toggle tile spawner: [color=#a4885c]{20}[/color] Toggle sandbox window: [color=#a4885c]{21}[/color]", Key(MoveUp), Key(MoveLeft), Key(MoveDown), Key(MoveRight), Key(SwapHands), Key(ActivateItemInHand), Key(Drop), Key(OpenInventoryMenu), Key(OpenCharacterMenu), Key(OpenCraftingMenu), Key(FocusChat), Key(ActivateItemInWorld), Key(ThrowItemInHand), Key(ExamineEntity), Key(OpenContextMenu), Key(ToggleCombatMode), Key(ShowDebugConsole), Key(HideUI), Key(ShowDebugMonitors), Key(OpenEntitySpawnWindow), Key(OpenTileSpawnWindow), Key(OpenSandboxWindow))); //Gameplay VBox.AddChild(new Label { FontOverride = headerFont, Text = Loc.GetString("\nSandbox spawner", Key(OpenSandboxWindow)) }); AddFormattedText(SandboxSpawnerContents); //Gameplay VBox.AddChild(new Label { FontOverride = headerFont, Text = "\nGameplay" }); AddFormattedText(GameplayContents); //Feedback VBox.AddChild(new Label { FontOverride = headerFont, Text = "\nFeedback" }); AddFormattedText(FeedbackContents); }
public static Stylesheet Make() { var res = IoCManager.Resolve <IResourceCache>(); var textureCloseButton = res.GetResource <TextureResource>("/cross.svg.png").Texture; var notoSansFont = res.GetResource <FontResource>("/Fonts/NotoSans-Regular.ttf"); var notoSansBoldFont = res.GetResource <FontResource>("/Fonts/NotoSans-Bold.ttf"); var notoSansFont10 = new VectorFont(notoSansFont, 10); var notoSansFont12 = new VectorFont(notoSansFont, 12); var notoSansBoldFont14 = new VectorFont(notoSansBoldFont, 14); var scrollBarNormal = new StyleBoxFlat { BackgroundColor = Color.Gray.WithAlpha(0.35f), ContentMarginLeftOverride = 10, ContentMarginTopOverride = 10 }; var scrollBarHovered = new StyleBoxFlat { BackgroundColor = new Color(140, 140, 140).WithAlpha(0.35f), ContentMarginLeftOverride = 10, ContentMarginTopOverride = 10 }; var scrollBarGrabbed = new StyleBoxFlat { BackgroundColor = new Color(160, 160, 160).WithAlpha(0.35f), ContentMarginLeftOverride = 10, ContentMarginTopOverride = 10 }; return(new Stylesheet(new StyleRule[] { Element <WindowRoot>() .Prop("background", Color.White), Element <PanelContainer>().Class("MapBackground") .Prop("panel", new StyleBoxFlat { BackgroundColor = Color.Black }), // Default font. Element() .Prop("font", notoSansFont12) .Prop("font-color", Color.Black), // VScrollBar grabber normal Element <VScrollBar>() .Prop(ScrollBar.StylePropertyGrabber, scrollBarNormal), // VScrollBar grabber hovered Element <VScrollBar>().Pseudo(ScrollBar.StylePseudoClassHover) .Prop(ScrollBar.StylePropertyGrabber, scrollBarHovered), // VScrollBar grabber grabbed Element <VScrollBar>().Pseudo(ScrollBar.StylePseudoClassGrabbed) .Prop(ScrollBar.StylePropertyGrabber, scrollBarGrabbed), // HScrollBar grabber normal Element <HScrollBar>() .Prop(ScrollBar.StylePropertyGrabber, scrollBarNormal), // HScrollBar grabber hovered Element <HScrollBar>().Pseudo(ScrollBar.StylePseudoClassHover) .Prop(ScrollBar.StylePropertyGrabber, scrollBarHovered), // HScrollBar grabber grabbed Element <HScrollBar>().Pseudo(ScrollBar.StylePseudoClassGrabbed) .Prop(ScrollBar.StylePropertyGrabber, scrollBarGrabbed), // Window background default color. Element().Class(DefaultWindow.StyleClassWindowPanel) .Prop("panel", new StyleBoxFlat { BackgroundColor = Color.FromHex("#4A4A4A") }), // Window title properties Element().Class(DefaultWindow.StyleClassWindowTitle) // Color .Prop(Label.StylePropertyFontColor, Color.FromHex("#000000")) // Font .Prop(Label.StylePropertyFont, notoSansBoldFont14), // Window header color. Element().Class(DefaultWindow.StyleClassWindowHeader) .Prop(PanelContainer.StylePropertyPanel, new StyleBoxFlat { BackgroundColor = Color.FromHex("#636396"), Padding = new Thickness(1, 1) }), // Window close button Element().Class(DefaultWindow.StyleClassWindowCloseButton) // Button texture .Prop(TextureButton.StylePropertyTexture, textureCloseButton) // Normal button color .Prop(Control.StylePropertyModulateSelf, Color.FromHex("#000000")), // Window close button hover color Element().Class(DefaultWindow.StyleClassWindowCloseButton).Pseudo(TextureButton.StylePseudoClassHover) .Prop(Control.StylePropertyModulateSelf, Color.FromHex("#505050")), // Window close button pressed color Element().Class(DefaultWindow.StyleClassWindowCloseButton).Pseudo(TextureButton.StylePseudoClassPressed) .Prop(Control.StylePropertyModulateSelf, Color.FromHex("#808080")), // Button style normal Element <ContainerButton>().Class(ContainerButton.StyleClassButton).Pseudo(ContainerButton.StylePseudoClassNormal) .Prop(ContainerButton.StylePropertyStyleBox, new StyleBoxFlat { BackgroundColor = Color.FromHex("#C0C0C0"), BorderThickness = new Thickness(1), BorderColor = Color.FromHex("#707070") }), // Button style hovered Element <ContainerButton>().Class(ContainerButton.StyleClassButton).Pseudo(ContainerButton.StylePseudoClassHover) .Prop(ContainerButton.StylePropertyStyleBox, new StyleBoxFlat { BackgroundColor = Color.FromHex("#D0D0D0"), BorderThickness = new Thickness(1), BorderColor = Color.FromHex("#707070") }), // Button style pressed Element <ContainerButton>().Class(ContainerButton.StyleClassButton).Pseudo(ContainerButton.StylePseudoClassPressed) .Prop(ContainerButton.StylePropertyStyleBox, new StyleBoxFlat { BackgroundColor = Color.FromHex("#E0E0E0"), BorderThickness = new Thickness(1), BorderColor = Color.FromHex("#707070") }), // Button style disabled Element <ContainerButton>().Class(ContainerButton.StyleClassButton).Pseudo(ContainerButton.StylePseudoClassDisabled) .Prop(ContainerButton.StylePropertyStyleBox, new StyleBoxFlat { BackgroundColor = Color.FromHex("#FAFAFA"), BorderThickness = new Thickness(1), BorderColor = Color.FromHex("#707070") }), // DMF ControlButton Element <Label>().Class(ControlButton.StyleClassDMFButton) .Prop(Label.StylePropertyAlignMode, Label.AlignMode.Center) .Prop(Label.StylePropertyFont, notoSansFont10), // CheckBox unchecked Element <TextureRect>().Class(CheckBox.StyleClassCheckBox) .Prop(TextureRect.StylePropertyTexture, Texture.Black), // TODO: Add actual texture instead of this. // CheckBox unchecked Element <TextureRect>().Class(CheckBox.StyleClassCheckBox, CheckBox.StyleClassCheckBoxChecked) .Prop(TextureRect.StylePropertyTexture, Texture.White), // TODO: Add actual texture instead of this. // LineEdit Element <LineEdit>() // background color .Prop(LineEdit.StylePropertyStyleBox, new StyleBoxFlat { BackgroundColor = Color.FromHex("#D3B5B5"), BorderThickness = new Thickness(1), BorderColor = Color.FromHex("#abadb3") }) // default font color .Prop("font-color", Color.Black) .Prop("cursor-color", Color.Black), // LineEdit non-editable text color Element <LineEdit>().Class(LineEdit.StyleClassLineEditNotEditable) .Prop("font-color", Color.FromHex("#363636")), // LineEdit placeholder text color Element <LineEdit>().Pseudo(LineEdit.StylePseudoClassPlaceholder) .Prop("font-color", Color.FromHex("#7d7d7d")), // TabContainer Element <TabContainer>() // Panel style .Prop(TabContainer.StylePropertyPanelStyleBox, new StyleBoxFlat { BackgroundColor = Color.White, BorderThickness = new Thickness(1), BorderColor = Color.Black }) // Active tab style .Prop(TabContainer.StylePropertyTabStyleBox, new StyleBoxFlat { BackgroundColor = Color.FromHex("#707070"), PaddingLeft = 1, PaddingRight = 1, ContentMarginLeftOverride = 5, ContentMarginRightOverride = 5 }) // Inactive tab style .Prop(TabContainer.StylePropertyTabStyleBoxInactive, new StyleBoxFlat { BackgroundColor = Color.FromHex("#D0D0D0"), PaddingLeft = 1, PaddingRight = 1, ContentMarginLeftOverride = 5, ContentMarginRightOverride = 5 }) .Prop("font", notoSansFont10), })); }
public TutorialWindow() { Title = "The Tutorial!"; //Get section header font var cache = IoCManager.Resolve <IResourceCache>(); var inputManager = IoCManager.Resolve <IInputManager>(); Font headerFont = new VectorFont(cache.GetResource <FontResource>("/Fonts/NotoSans/NotoSans-Regular.ttf"), _headerFontSize); var scrollContainer = new ScrollContainer(); scrollContainer.AddChild(VBox = new VBoxContainer()); Contents.AddChild(scrollContainer); //Intro VBox.AddChild(new Label { FontOverride = headerFont, Text = "Intro" }); AddFormattedText(IntroContents); string Key(BoundKeyFunction func) { return(FormattedMessage.EscapeText(inputManager.GetKeyFunctionButtonString(func))); } //Controls VBox.AddChild(new Label { FontOverride = headerFont, Text = "\nControls" }); // Moved this down here so that Rider shows which args correspond to which format spot. AddFormattedText(Loc.GetString(@"Movement: [color=#a4885c]{0} {1} {2} {3}[/color] Switch hands: [color=#a4885c]{4}[/color] Use held item: [color=#a4885c]{5}[/color] Drop held item: [color=#a4885c]{6}[/color] Smart equip from backpack: [color=#a4885c]{24}[/color] Smart equip from belt: [color=#a4885c]{25}[/color] Open inventory: [color=#a4885c]{7}[/color] Open character window: [color=#a4885c]{8}[/color] Open crafting window: [color=#a4885c]{9}[/color] Open action menu: [color=#a4885c]{33}[/color] Focus chat: [color=#a4885c]{10}[/color] Focus OOC: [color=#a4885c]{26}[/color] Focus Admin Chat: [color=#a4885c]{27}[/color] Use hand/object in hand: [color=#a4885c]{22}[/color] Do wide attack: [color=#a4885c]{23}[/color] Use targeted entity: [color=#a4885c]{11}[/color] Throw held item: [color=#a4885c]{12}[/color] Pull entity: [color=#a4885c]{30}[/color] Move pulled entity: [color=#a4885c]{29}[/color] Stop pulling: [color=#a4885c]{32}[/color] Examine entity: [color=#a4885c]{13}[/color] Point somewhere: [color=#a4885c]{28}[/color] Open entity context menu: [color=#a4885c]{14}[/color] Toggle combat mode: [color=#a4885c]{15}[/color] Toggle console: [color=#a4885c]{16}[/color] Toggle UI: [color=#a4885c]{17}[/color] Toggle debug overlay: [color=#a4885c]{18}[/color] Toggle entity spawner: [color=#a4885c]{19}[/color] Toggle tile spawner: [color=#a4885c]{20}[/color] Toggle sandbox window: [color=#a4885c]{21}[/color] Toggle admin menu [color=#a4885c]{31}[/color] Hotbar slot 1: [color=#a4885c]{34}[/color] Hotbar slot 2: [color=#a4885c]{35}[/color] Hotbar slot 3: [color=#a4885c]{36}[/color] Hotbar slot 4: [color=#a4885c]{37}[/color] Hotbar slot 5: [color=#a4885c]{38}[/color] Hotbar slot 6: [color=#a4885c]{39}[/color] Hotbar slot 7: [color=#a4885c]{40}[/color] Hotbar slot 8: [color=#a4885c]{41}[/color] Hotbar slot 9: [color=#a4885c]{42}[/color] Hotbar slot 0: [color=#a4885c]{43}[/color] ", Key(MoveUp), Key(MoveLeft), Key(MoveDown), Key(MoveRight), Key(SwapHands), Key(ActivateItemInHand), Key(Drop), Key(OpenInventoryMenu), Key(OpenCharacterMenu), Key(OpenCraftingMenu), Key(FocusChat), Key(ActivateItemInWorld), Key(ThrowItemInHand), Key(ExamineEntity), Key(OpenContextMenu), Key(ToggleCombatMode), Key(ShowDebugConsole), Key(HideUI), Key(ShowDebugMonitors), Key(OpenEntitySpawnWindow), Key(OpenTileSpawnWindow), Key(OpenSandboxWindow), Key(Use), Key(WideAttack), Key(SmartEquipBackpack), Key(SmartEquipBelt), Key(FocusOOC), Key(FocusAdminChat), Key(Point), Key(TryPullObject), Key(MovePulledObject), Key(OpenAdminMenu), Key(ReleasePulledObject), Key(OpenActionsMenu), Key(Hotbar1), Key(Hotbar2), Key(Hotbar3), Key(Hotbar4), Key(Hotbar5), Key(Hotbar6), Key(Hotbar7), Key(Hotbar8), Key(Hotbar9), Key(Hotbar0))); //Gameplay VBox.AddChild(new Label { FontOverride = headerFont, Text = "\nGameplay" }); AddFormattedText(GameplayContents); //Gameplay VBox.AddChild(new Label { FontOverride = headerFont, Text = Loc.GetString("\nSandbox spawner", Key(OpenSandboxWindow)) }); AddFormattedText(SandboxSpawnerContents); //Feedback VBox.AddChild(new Label { FontOverride = headerFont, Text = "\nFeedback" }); AddFormattedText(FeedbackContents); }
public void Initialize() { var fontRes = _resourceCache.GetResource <FontResource>("/Fonts/NotoSans/NotoSans-Regular.ttf"); var font = new VectorFont(fontRes, 10); var bigFont = new VectorFont(fontRes, 32); var panelTex = _resourceCache.GetResource <TextureResource>("/Textures/Interface/panel.png"); var panel = new StyleBoxTexture { Texture = panelTex }; panel.SetPatchMargin(StyleBox.Margin.All, 2); panel.SetExpandMargin(StyleBox.Margin.All, 2); var panelDarkTex = _resourceCache.GetResource <TextureResource>("/Textures/Interface/panelDark.png"); var panelDark = new StyleBoxTexture { Texture = panelDarkTex }; panelDark.SetPatchMargin(StyleBox.Margin.All, 2); panelDark.SetExpandMargin(StyleBox.Margin.All, 2); var tabContainerPanelTex = _resourceCache.GetResource <TextureResource>("/Textures/Interface/tabPanel.png"); var tabContainerPanel = new StyleBoxTexture { Texture = tabContainerPanelTex.Texture, }; tabContainerPanel.SetPatchMargin(StyleBox.Margin.All, 2); var tabContainerBoxActive = new StyleBoxFlat { BackgroundColor = new Color(64, 64, 64) }; tabContainerBoxActive.SetContentMarginOverride(StyleBox.Margin.Horizontal, 5); var tabContainerBoxInactive = new StyleBoxFlat { BackgroundColor = new Color(32, 32, 32) }; tabContainerBoxInactive.SetContentMarginOverride(StyleBox.Margin.Horizontal, 5); var textureCloseButton = _resourceCache.GetResource <TextureResource>("/Textures/Interface/cross.png").Texture; _userInterfaceManager.Stylesheet = new Stylesheet(new[] { new StyleRule( new SelectorElement(null, null, null, null), new[] { new StyleProperty("font", font), new StyleProperty(PanelContainer.StylePropertyPanel, panel), new StyleProperty(LineEdit.StylePropertyStyleBox, panelDark) }), // TabContainer new StyleRule(new SelectorElement(typeof(TabContainer), null, null, null), new[] { new StyleProperty(TabContainer.StylePropertyPanelStyleBox, tabContainerPanel), new StyleProperty(TabContainer.StylePropertyTabStyleBox, tabContainerBoxActive), new StyleProperty(TabContainer.StylePropertyTabStyleBoxInactive, tabContainerBoxInactive), }), // Window close button base texture. new StyleRule( new SelectorElement(typeof(TextureButton), new[] { SS14Window.StyleClassWindowCloseButton }, null, null), new[] { new StyleProperty(TextureButton.StylePropertyTexture, textureCloseButton), new StyleProperty(Control.StylePropertyModulateSelf, Color.FromHex("#BB88BB")), }), // Window close button hover. new StyleRule( new SelectorElement(typeof(TextureButton), new[] { SS14Window.StyleClassWindowCloseButton }, null, new[] { TextureButton.StylePseudoClassHover }), new[] { new StyleProperty(Control.StylePropertyModulateSelf, Color.FromHex("#DD88DD")), }), // Window close button pressed. new StyleRule( new SelectorElement(typeof(TextureButton), new[] { SS14Window.StyleClassWindowCloseButton }, null, new[] { TextureButton.StylePseudoClassPressed }), new[] { new StyleProperty(Control.StylePropertyModulateSelf, Color.FromHex("#FFCCFF")), }), // Game label. new StyleRule( new SelectorElement(typeof(Label), new [] { StyleClassLabelGame }, null, null), new [] { new StyleProperty(Label.StylePropertyFont, bigFont) }) }); }
public override void LoadContent() { VectorFont.Initialize(StateManager.game); oldKeyState = Keyboard.GetState(); }
public Layer(ClientResourceLocator?resourceLocator = null, string?layerPathLua = null, params object[] args) { ResourceLocator = resourceLocator ?? ClientResourceLocator.Default; m_spriteRenderer = new BasicSpriteRenderer(ResourceLocator); m_resources = new ClientResourceManager(ResourceLocator); m_script = new ScriptProgram(ResourceLocator); m_renderer2D = new RenderBatch2D(m_resources); m_drivingScriptFileName = layerPathLua; m_drivingScriptArgs = args; m_script["KeyCode"] = typeof(KeyCode); m_script["MouseButton"] = typeof(MouseButton); m_script["ControllerAxisStyle"] = typeof(ControllerAxisStyle); m_script["theori"] = tblTheori = m_script.NewTable(); tblTheori["isFirstLaunch"] = (Func <bool>)(() => Host.IsFirstLaunch); tblTheori["audio"] = tblTheoriAudio = m_script.NewTable(); tblTheori["charts"] = tblTheoriCharts = m_script.NewTable(); tblTheori["config"] = tblTheoriConfig = m_script.NewTable(); tblTheori["game"] = tblTheoriGame = m_script.NewTable(); tblTheori["graphics"] = tblTheoriGraphics = m_script.NewTable(); tblTheori["input"] = tblTheoriInput = m_script.NewTable(); tblTheori["layer"] = tblTheoriLayer = m_script.NewTable(); tblTheori["modes"] = tblTheoriModes = m_script.NewTable(); tblTheori["net"] = tblTheoriNet = m_script.NewTable(); tblTheoriInput["textInput"] = evtTextInput = m_script.NewEvent(); tblTheoriInput["keyboard"] = tblTheoriInputKeyboard = m_script.NewTable(); tblTheoriInput["mouse"] = tblTheoriInputMouse = m_script.NewTable(); tblTheoriInput["gamepad"] = tblTheoriInputGamepad = m_script.NewTable(); tblTheoriInput["controller"] = tblTheoriInputController = m_script.NewTable(); tblTheoriInputKeyboard["isDown"] = (Func <KeyCode, bool>)(key => UserInputService.IsKeyDown(key)); tblTheoriInputKeyboard["pressed"] = evtKeyPressed = m_script.NewEvent(); tblTheoriInputKeyboard["released"] = evtKeyReleased = m_script.NewEvent(); tblTheoriInputKeyboard["pressedRaw"] = evtRawKeyPressed = m_script.NewEvent(); tblTheoriInputKeyboard["releasedRaw"] = evtRawKeyReleased = m_script.NewEvent(); tblTheoriInputMouse["pressed"] = evtMousePressed = m_script.NewEvent(); tblTheoriInputMouse["released"] = evtMouseReleased = m_script.NewEvent(); tblTheoriInputMouse["moved"] = evtMouseMoved = m_script.NewEvent(); tblTheoriInputMouse["scrolled"] = evtMouseScrolled = m_script.NewEvent(); tblTheoriInputMouse["pressedRaw"] = evtRawMousePressed = m_script.NewEvent(); tblTheoriInputMouse["releasedRaw"] = evtRawMouseReleased = m_script.NewEvent(); tblTheoriInputMouse["movedRaw"] = evtRawMouseMoved = m_script.NewEvent(); tblTheoriInputMouse["scrolledRaw"] = evtRawMouseScrolled = m_script.NewEvent(); tblTheoriInputMouse["getMousePosition"] = (Func <DynValue>)(() => NewTuple(NewNumber(UserInputService.MouseX), NewNumber(UserInputService.MouseY))); tblTheoriInputGamepad["connected"] = evtGamepadConnected = m_script.NewEvent(); tblTheoriInputGamepad["disconnected"] = evtGamepadDisconnected = m_script.NewEvent(); tblTheoriInputGamepad["pressed"] = evtGamepadPressed = m_script.NewEvent(); tblTheoriInputGamepad["released"] = evtGamepadReleased = m_script.NewEvent(); tblTheoriInputGamepad["axisChanged"] = evtGamepadAxisChanged = m_script.NewEvent(); tblTheoriInputGamepad["pressedRaw"] = evtRawGamepadPressed = m_script.NewEvent(); tblTheoriInputGamepad["releasedRaw"] = evtRawGamepadReleased = m_script.NewEvent(); tblTheoriInputGamepad["axisChangedRaw"] = evtRawGamepadAxisChanged = m_script.NewEvent(); tblTheoriInputController["added"] = evtControllerAdded = m_script.NewEvent(); tblTheoriInputController["removed"] = evtControllerRemoved = m_script.NewEvent(); tblTheoriInputController["pressed"] = evtControllerPressed = m_script.NewEvent(); tblTheoriInputController["released"] = evtControllerReleased = m_script.NewEvent(); tblTheoriInputController["axisChanged"] = evtControllerAxisChanged = m_script.NewEvent(); tblTheoriInputController["axisTicked"] = evtControllerAxisTicked = m_script.NewEvent(); tblTheori["doStaticLoadsAsync"] = (Func <bool>)(() => StaticResources.LoadAll()); tblTheori["finalizeStaticLoads"] = (Func <bool>)(() => StaticResources.FinalizeLoad()); tblTheoriAudio["queueStaticAudioLoad"] = (Func <string, AudioHandle>)(audioName => StaticResources.QueueAudioLoad($"audio/{ audioName }")); tblTheoriAudio["getStaticAudio"] = (Func <string, AudioHandle>)(audioName => StaticResources.GetAudio($"audio/{ audioName }")); tblTheoriAudio["queueAudioLoad"] = (Func <string, AudioHandle>)(audioName => m_resources.QueueAudioLoad($"audio/{ audioName }")); tblTheoriAudio["getAudio"] = (Func <string, AudioHandle>)(audioName => m_resources.GetAudio($"audio/{ audioName }")); tblTheoriAudio["createFakeAudio"] = (Func <int, int, AudioHandle>)((sampleRate, channels) => new FakeAudioSource(sampleRate, channels)); tblTheoriCharts["setDatabaseToIdle"] = (Action)(() => Client.DatabaseWorker.SetToIdle()); tblTheoriCharts["getDatabaseState"] = (Func <string>)(() => Client.DatabaseWorker.State.ToString()); tblTheoriCharts["setDatabaseToClean"] = (Action <DynValue>)(arg => { Client.DatabaseWorker.SetToClean(arg == DynValue.Void ? (Action?)null : () => m_script.Call(arg)); }); tblTheoriCharts["setDatabaseToPopulate"] = NewCallback((ctx, args) => { Action?callback = args.Count == 0 ? (Action?)null : () => ctx.Call(args[0]); Client.DatabaseWorker.SetToPopulate(callback); return(Nil); }); tblTheoriCharts["create"] = (Func <string, ChartHandle>)(modeName => { var mode = GameMode.GetInstance(modeName); //if (mode == null) return DynValue.Nil; return(new ChartHandle(m_resources, m_script, Client.DatabaseWorker, mode !.GetChartFactory().CreateNew())); }); tblTheoriCharts["newEntity"] = (Func <string, Entity>)(entityTypeId => { var entityType = Entity.GetEntityTypeById(entityTypeId); return((Entity)Activator.CreateInstance(entityType !)); }); tblTheoriCharts["saveChartToDatabase"] = (Action <Chart>)(chart => { var ser = chart.GameMode.CreateChartSerializer(TheoriConfig.ChartsDirectory, chart.Info.ChartFileType) ?? new TheoriChartSerializer(TheoriConfig.ChartsDirectory, chart.GameMode); var setSer = new ChartSetSerializer(TheoriConfig.ChartsDirectory); setSer.SaveToFile(chart.SetInfo); ser.SaveToFile(chart); }); tblTheoriCharts["createCollection"] = (Action <string>)(collectionName => Client.DatabaseWorker.CreateCollection(collectionName)); tblTheoriCharts["addChartToCollection"] = (Action <string, ChartInfoHandle>)((collectionName, chart) => Client.DatabaseWorker.AddChartToCollection(collectionName, chart)); tblTheoriCharts["removeChartFromCollection"] = (Action <string, ChartInfoHandle>)((collectionName, chart) => Client.DatabaseWorker.RemoveChartFromCollection(collectionName, chart)); tblTheoriCharts["getCollectionNames"] = (Func <string[]>)(() => Client.DatabaseWorker.CollectionNames); tblTheoriCharts["getFolderNames"] = (Func <string[]>)(() => Directory.GetDirectories(TheoriConfig.ChartsDirectory).Select(d => Path.GetFileName(d)).ToArray()); tblTheoriCharts["getChartSets"] = (Func <List <ChartSetInfoHandle> >)(() => Client.DatabaseWorker.ChartSets.Select(info => new ChartSetInfoHandle(m_resources, m_script, Client.DatabaseWorker, info)).ToList()); tblTheoriCharts["getScores"] = (Func <ChartInfoHandle, ScoreData[]>)(chart => ChartDatabaseService.GetScoresForChart(chart.Object)); tblTheoriCharts["getChartSetsFiltered"] = (Func <string?, DynValue, DynValue, DynValue, List <List <ChartInfoHandle> > >)((col, a, b, c) => { Logger.Log("Attempting to filter charts..."); var setInfoHandles = new Dictionary <ChartSetInfo, ChartSetInfoHandle>(); ChartSetInfoHandle GetSetInfoHandle(ChartSetInfo chartSet) { if (!setInfoHandles.TryGetValue(chartSet, out var result)) { result = setInfoHandles[chartSet] = new ChartSetInfoHandle(m_resources, m_script, Client.DatabaseWorker, chartSet); } return(result); } Logger.Log(col ?? "null"); var charts = col != null ? Client.DatabaseWorker.GetChartsInCollection(col) : Client.DatabaseWorker.Charts; var filteredCharts = from initialChart in charts let handle = new ChartInfoHandle(GetSetInfoHandle(initialChart.Set), initialChart) where m_script.Call(a, handle).CastToBool() select handle; var groupedCharts = filteredCharts.OrderBy(chart => m_script.Call(b, chart), DynValueComparer.Instance) .GroupBy(chart => m_script.Call(b, chart)) .Select(theGroup => (theGroup.Key, Value: theGroup .OrderBy(chart => chart.DifficultyIndex) .ThenBy(chart => chart.DifficultyName) .ThenBy(chart => m_script.Call(c, chart), DynValueComparer.Instance) .Select(chart => chart) .ToList())) .OrderBy(l => l.Key, DynValueComparer.Instance) .Select(l => l.Value) .ToList(); return(groupedCharts); }); tblTheoriConfig["get"] = (Func <string, DynValue>)(key => FromObject(m_script.Script, UserConfigManager.GetFromKey(key))); tblTheoriConfig["set"] = (Action <string, DynValue>)((key, value) => UserConfigManager.SetFromKey(key, value.ToObject())); tblTheoriConfig["save"] = (Action)(() => UserConfigManager.SaveToFile()); tblTheoriGame["exit"] = (Action)(() => Host.Exit()); tblTheoriGraphics["queueStaticTextureLoad"] = (Func <string, Texture>)(textureName => StaticResources.QueueTextureLoad($"textures/{ textureName }")); tblTheoriGraphics["getStaticTexture"] = (Func <string, Texture>)(textureName => StaticResources.GetTexture($"textures/{ textureName }")); tblTheoriGraphics["queueTextureLoad"] = (Func <string, Texture>)(textureName => m_resources.QueueTextureLoad($"textures/{ textureName }")); tblTheoriGraphics["getTexture"] = (Func <string, Texture>)(textureName => m_resources.GetTexture($"textures/{ textureName }")); tblTheoriGraphics["createStaticFont"] = (Func <string, VectorFont?>)(fontName => ResourceLocator.OpenFileStreamWithExtension($"fonts/{ fontName }", new[] { ".ttf", ".otf" }, out string _) is Stream fs ? staticFonts[fontName] = new VectorFont(fs) : null); tblTheoriGraphics["createFont"] = (Func <string, VectorFont?>)(fontName => ResourceLocator.OpenFileStreamWithExtension($"fonts/{ fontName }", new[] { ".ttf", ".otf" }, out string _) is Stream fs ? new VectorFont(fs) : null); tblTheoriGraphics["getStaticFont"] = (Func <string, VectorFont?>)(fontName => staticFonts.TryGetValue(fontName, out var font) ? font : null); //tblTheoriGraphics["getFont"] = (Func<string, VectorFont>)(fontName => m_resources.GetTexture($"fonts/{ fontName }")); tblTheoriGraphics["getViewportSize"] = (Func <DynValue>)(() => NewTuple(NewNumber(Window.Width), NewNumber(Window.Height))); tblTheoriGraphics["createPathCommands"] = (Func <Path2DCommands>)(() => new Path2DCommands()); tblTheoriGraphics["flush"] = (Action)(() => m_batch?.Flush()); tblTheoriGraphics["saveTransform"] = (Action)(() => m_batch?.SaveTransform()); tblTheoriGraphics["restoreTransform"] = (Action)(() => m_batch?.RestoreTransform()); tblTheoriGraphics["resetTransform"] = (Action)(() => m_batch?.ResetTransform()); tblTheoriGraphics["translate"] = (Action <float, float>)((x, y) => m_batch?.Translate(x, y)); tblTheoriGraphics["rotate"] = (Action <float>)(d => m_batch?.Rotate(d)); tblTheoriGraphics["scale"] = (Action <float, float>)((x, y) => m_batch?.Scale(x, y)); tblTheoriGraphics["shear"] = (Action <float, float>)((x, y) => m_batch?.Shear(x, y)); tblTheoriGraphics["setFillToColor"] = (Action <float, float, float, float>)((r, g, b, a) => m_batch?.SetFillColor(r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f)); tblTheoriGraphics["setFillToTexture"] = (Action <Texture, float, float, float, float>)((texture, r, g, b, a) => m_batch?.SetFillTexture(texture, new Vector4(r, g, b, a) / 255.0f)); tblTheoriGraphics["fillRect"] = (Action <float, float, float, float>)((x, y, w, h) => m_batch?.FillRectangle(x, y, w, h)); tblTheoriGraphics["fillRoundedRect"] = (Action <float, float, float, float, float>)((x, y, w, h, r) => m_batch?.FillRoundedRectangle(x, y, w, h, r)); tblTheoriGraphics["fillRoundedRectVarying"] = (Action <float, float, float, float, float, float, float, float>)((x, y, w, h, rtl, rtr, rbr, rbl) => m_batch?.FillRoundedRectangleVarying(x, y, w, h, rtl, rtr, rbr, rbl)); tblTheoriGraphics["setFont"] = (Action <VectorFont?>)(font => m_batch?.SetFont(font)); tblTheoriGraphics["setFontSize"] = (Action <int>)(size => m_batch?.SetFontSize(size)); tblTheoriGraphics["setTextAlign"] = (Action <Anchor>)(align => m_batch?.SetTextAlign(align)); tblTheoriGraphics["fillString"] = (Action <string, float, float>)((text, x, y) => m_batch?.FillString(text, x, y)); tblTheoriGraphics["measureString"] = (Func <string, DynValue>)(text => { var bounds = m_batch?.MeasureString(text) !.Value; return(NewTuple(NewNumber(bounds.X), NewNumber(bounds.Y))); }); tblTheoriGraphics["fillPathAt"] = (Action <Path2DCommands, float, float, float, float>)((path, x, y, sx, sy) => m_batch?.FillPathAt(path, x, y, sx, sy)); tblTheoriGraphics["saveScissor"] = (Action)(() => m_batch?.SaveScissor()); tblTheoriGraphics["restoreScissor"] = (Action)(() => m_batch?.RestoreScissor()); tblTheoriGraphics["resetScissor"] = (Action)(() => m_batch?.ResetScissor()); tblTheoriGraphics["scissor"] = (Action <float, float, float, float>)((x, y, w, h) => m_batch?.Scissor(x, y, w, h)); tblTheoriGraphics["openCurtain"] = (Action)OpenCurtain; tblTheoriGraphics["closeCurtain"] = (Action <float, DynValue?>)((duration, callback) => { Action?onClosed = (callback == null || callback == Nil) ? (Action?)null : () => m_script.Call(callback !); if (duration <= 0) { CloseCurtain(onClosed); } else { CloseCurtain(duration, onClosed); } });
public override void Initialize(SS14Window window, object obj) { _entity = (IEntity)obj; var type = obj.GetType(); var scrollContainer = new ScrollContainer(); scrollContainer.SetAnchorPreset(Control.LayoutPreset.Wide, true); window.Contents.AddChild(scrollContainer); var vBoxContainer = new VBoxContainer { SizeFlagsHorizontal = Control.SizeFlags.FillExpand, SizeFlagsVertical = Control.SizeFlags.FillExpand, }; scrollContainer.AddChild(vBoxContainer); // Handle top bar displaying type and ToString(). { Control top; var stringified = obj.ToString(); if (type.FullName != stringified) { var smallFont = new VectorFont(_resourceCache.GetResource <FontResource>("/Fonts/CALIBRI.TTF"), 10); // Custom ToString() implementation. var headBox = new VBoxContainer { SeparationOverride = 0 }; headBox.AddChild(new Label { Text = stringified, ClipText = true }); headBox.AddChild(new Label { Text = type.FullName, FontOverride = smallFont, FontColorOverride = Color.DarkGray, ClipText = true }); top = headBox; } else { top = new Label { Text = stringified }; } if (_entity.TryGetComponent(out ISpriteComponent sprite)) { var hBox = new HBoxContainer(); top.SizeFlagsHorizontal = Control.SizeFlags.FillExpand; hBox.AddChild(top); hBox.AddChild(new SpriteView { Sprite = sprite }); vBoxContainer.AddChild(hBox); } else { vBoxContainer.AddChild(top); } } _tabs = new TabContainer(); _tabs.OnTabChanged += _tabsOnTabChanged; vBoxContainer.AddChild(_tabs); var clientVBox = new VBoxContainer { SeparationOverride = 0 }; _tabs.AddChild(clientVBox); _tabs.SetTabTitle(TabClientVars, "Client Variables"); foreach (var control in LocalPropertyList(obj, ViewVariablesManager, _resourceCache)) { clientVBox.AddChild(control); } var clientComponents = new VBoxContainer { SeparationOverride = 0 }; _tabs.AddChild(clientComponents); _tabs.SetTabTitle(TabClientComponents, "Client Components"); // See engine#636 for why the Distinct() call. var componentList = _entity.GetAllComponents().Distinct().OrderBy(c => c.GetType().ToString()); foreach (var component in componentList) { var button = new Button { Text = component.GetType().ToString(), TextAlign = Button.AlignMode.Left }; button.OnPressed += args => { ViewVariablesManager.OpenVV(component); }; clientComponents.AddChild(button); } if (!_entity.Uid.IsClientSide()) { _serverVariables = new VBoxContainer { SeparationOverride = 0 }; _tabs.AddChild(_serverVariables); _tabs.SetTabTitle(TabServerVars, "Server Variables"); _serverComponents = new VBoxContainer { SeparationOverride = 0 }; _tabs.AddChild(_serverComponents); _tabs.SetTabTitle(TabServerComponents, "Server Components"); } }
public override void Initialize() { pb = new PrimitiveBatch(Game.GraphicsDevice); isThrusting = false; gravityPerMS = gravity / 1000.0f; thrustPower = 0 - (gravityPerMS * 2.0f); VectorFont.Initialize(Game); fullLander = new LanderParts(new List <Vector2>(), new Vector2(15.0f, 5.0f)); Fuel = 100; angleRad = MathHelper.ToRadians(0); rocketBoosterEffect = Game.Content.Load <SoundEffect>("RocketThrust"); #region initialize parts landerCan = new LanderParts(LanderTextToVector.GetPoints(string.Format("{0}\\{1}", Game.Content.RootDirectory, "LanderCan.txt")), fullLander.Position); manCan = new LanderParts(LanderTextToVector.GetPoints(string.Format("{0}\\{1}", Game.Content.RootDirectory, "ManCap.txt")), fullLander.Position); thrust1 = new LanderParts(LanderTextToVector.GetPoints(string.Format("{0}\\{1}", Game.Content.RootDirectory, "Thrust.txt")), fullLander.Position); thrust2 = new LanderParts(LanderTextToVector.GetXMirrorPoints(string.Format("{0}\\{1}", Game.Content.RootDirectory, "Thrust.txt")), fullLander.Position); thruster = new LanderParts(LanderTextToVector.GetPoints(string.Format("{0}\\{1}", Game.Content.RootDirectory, "Thruster.txt")), fullLander.Position); legRight = new LanderParts(LanderTextToVector.GetPoints(string.Format("{0}\\{1}", Game.Content.RootDirectory, "LegR.txt")), fullLander.Position); legLeft = new LanderParts(LanderTextToVector.GetXMirrorPoints(string.Format("{0}\\{1}", Game.Content.RootDirectory, "LegR.txt")), fullLander.Position); #endregion #region construct lander LinkedList <Vector2> tempLander = new LinkedList <Vector2>(); Vector2 partPosition = new Vector2(0f, 0f); foreach (Vector2 v2 in manCan.Part) { tempLander.AddLast(v2 + partPosition); } partPosition.Y += 4; foreach (Vector2 v2 in landerCan.Part) { tempLander.AddLast(v2 + partPosition); } partPosition.Y += 3; partPosition.X -= 5; foreach (Vector2 v2 in legLeft.Part) { tempLander.AddLast(v2 + partPosition); } partPosition.X += 11; foreach (Vector2 v2 in legRight.Part) { tempLander.AddLast(v2 + partPosition); } partPosition.X -= 5; partPosition.Y += 3; foreach (Vector2 v2 in thruster.Part) { tempLander.AddLast(v2 + partPosition); } partPosition.Y += 1; thrustLocation = new Vector2(partPosition.X * landerScale, partPosition.Y * landerScale); LinkedListNode <Vector2> node = tempLander.First; for (int i = 0; i < tempLander.Count; ++i) { node.Value *= landerScale; node = node.Next; if (i < thrust1.Part.Count) { thrust1.Part[i] *= landerScale; thrust2.Part[i] *= landerScale; } } float minimumLanderXPosition = 0; float maximumLanderXPosition = 0; float minimumLanderYPosition = 0; float maximumLanderYPosition = 0; foreach (Vector2 v2 in tempLander) { if (minimumLanderXPosition > v2.X) { minimumLanderXPosition = v2.X; } if (maximumLanderXPosition < v2.X) { maximumLanderXPosition = v2.X; } if (minimumLanderYPosition > v2.Y) { minimumLanderYPosition = v2.Y; } if (maximumLanderYPosition < v2.Y) { maximumLanderYPosition = v2.Y; } } Vector2 cornerModifier = new Vector2(0 - minimumLanderXPosition, 0 - minimumLanderYPosition); thrustLocation += cornerModifier; for (int i = 0; i < thrust1.Part.Count; ++i) { thrust1.Part[i] += thrustLocation; thrust2.Part[i] += thrustLocation; } landerCenter = new Vector2((maximumLanderXPosition - minimumLanderXPosition) / 2, (maximumLanderYPosition - minimumLanderYPosition) / 2); foreach (Vector2 v2 in tempLander) { fullLander.Part.Add(v2 + cornerModifier); } #endregion Start(); oldKeyboardState = new KeyboardState(); landerColor = Color.Silver; thrustColor = Color.OrangeRed; fullLanderUnmodified = new List <Vector2>(fullLander.Part); thrust1Unmodified = new List <Vector2>(thrust1.Part); thrust2Unmodified = new List <Vector2>(thrust2.Part); base.Initialize(); }
////////////////////////////////////////////////////////////////////////////// #region Console protected virtual CConsole CreateConsole() { Font consoleFont = new VectorFont(m_contentManager.Load<SpriteFont>("ConsoleFont")); CConsole console = new CConsole(consoleFont); console.RegisterCommand(new Cmd_exit()); console.RegisterCommand(new Cmd_listcmds()); console.RegisterCommand(new Cmd_listcvars()); console.RegisterCommand(new Cmd_exec()); console.RegisterCommand(new Cmd_write()); console.RegisterCommand(new Cmd_bind()); console.RegisterCommand(new Cmd_unbind()); console.RegisterCommand(new Cmd_unbind_all()); console.RegisterCommand(new Cmd_bindlist()); console.RegisterCommand(new Cmd_ctoggle()); console.RegisterCvar(CVars.g_drawViewBorders); console.RegisterCvar(CVars.d_demoTargetFrame); return console; }
public void Initialize() { var notoSans12 = new VectorFont(ResC.GetResource <FontResource>("/Fonts/NotoSans/NotoSans-Regular.ttf"), 12); var notoSansBold15 = new VectorFont(ResC.GetResource <FontResource>("/Fonts/NotoSans/NotoSans-Bold.ttf"), 15); var buttonTexture = ResC.GetResource <TextureResource>("/Textures/UI/button.png"); var windowBackgroundTex = ResC.GetResource <TextureResource>("/Textures/UI/button.png"); var windowBackground = new StyleBoxTexture { Texture = windowBackgroundTex, }; var buttonBase = new StyleBoxTexture { Texture = buttonTexture, }; var lineEditTex = ResC.GetResource <TextureResource>("/Textures/UI/edit.png"); var lineEdit = new StyleBoxTexture { Texture = lineEditTex, }; lineEdit.SetPatchMargin(StyleBox.Margin.All, 3); lineEdit.SetContentMarginOverride(StyleBox.Margin.Horizontal, 5); buttonBase.SetPatchMargin(StyleBox.Margin.All, 10); buttonBase.SetPadding(StyleBox.Margin.All, 1); buttonBase.SetContentMarginOverride(StyleBox.Margin.Vertical, 2); buttonBase.SetContentMarginOverride(StyleBox.Margin.Horizontal, 14); var openRightButtonBase = new StyleBoxTexture(buttonBase) { Texture = new AtlasTexture(buttonTexture, UIBox2.FromDimensions((0, 0), (14, 24))), }; openRightButtonBase.SetPatchMargin(StyleBox.Margin.Right, 0); openRightButtonBase.SetContentMarginOverride(StyleBox.Margin.Right, 8); openRightButtonBase.SetPadding(StyleBox.Margin.Right, 2); var openLeftButtonBase = new StyleBoxTexture(buttonBase) { Texture = new AtlasTexture(buttonTexture, UIBox2.FromDimensions((10, 0), (14, 24))), }; openLeftButtonBase.SetPatchMargin(StyleBox.Margin.Left, 0); openLeftButtonBase.SetContentMarginOverride(StyleBox.Margin.Left, 8); openLeftButtonBase.SetPadding(StyleBox.Margin.Left, 1); var openBothButtonBase = new StyleBoxTexture(buttonBase) { Texture = new AtlasTexture(buttonTexture, UIBox2.FromDimensions((10, 0), (3, 24))), }; openBothButtonBase.SetPatchMargin(StyleBox.Margin.Horizontal, 0); openBothButtonBase.SetContentMarginOverride(StyleBox.Margin.Horizontal, 8); openBothButtonBase.SetPadding(StyleBox.Margin.Right, 2); openBothButtonBase.SetPadding(StyleBox.Margin.Left, 1); Stylesheet = new Stylesheet(new StyleRule[] { new StyleRule( new SelectorElement(null, null, null, null), new[] { new StyleProperty("font", notoSans12), }), new StyleRule(new SelectorElement(typeof(LineEdit), null, null, null), new[] { new StyleProperty(LineEdit.StylePropertyStyleBox, lineEdit), }), Element <Label>().Class(StyleClassLabelHeading) .Prop(Label.StylePropertyFont, notoSansBold15), Element <Label>().Class(StyleClassLabelSubText) .Prop(Label.StylePropertyFont, notoSans12) .Prop(Label.StylePropertyFontColor, Color.White), Element <PanelContainer>().Class(ClassHighDivider) .Prop(PanelContainer.StylePropertyPanel, new StyleBoxFlat { BackgroundColor = Color.Gray, ContentMarginBottomOverride = 2, ContentMarginLeftOverride = 2 }), // Shapes for the buttons. Element <ContainerButton>().Class(ContainerButton.StyleClassButton) .Prop(ContainerButton.StylePropertyStyleBox, buttonBase), Element <ContainerButton>().Class(ContainerButton.StyleClassButton) .Class(ButtonOpenRight) .Prop(ContainerButton.StylePropertyStyleBox, openRightButtonBase), Element <ContainerButton>().Class(ContainerButton.StyleClassButton) .Class(ButtonOpenLeft) .Prop(ContainerButton.StylePropertyStyleBox, openLeftButtonBase), Element <ContainerButton>().Class(ContainerButton.StyleClassButton) .Class(ButtonOpenBoth) .Prop(ContainerButton.StylePropertyStyleBox, openBothButtonBase), // Colors for the buttons. Element <ContainerButton>().Class(ContainerButton.StyleClassButton) .Pseudo(ContainerButton.StylePseudoClassNormal) .Prop(Control.StylePropertyModulateSelf, ButtonColorDefault), Element <ContainerButton>().Class(ContainerButton.StyleClassButton) .Pseudo(ContainerButton.StylePseudoClassHover) .Prop(Control.StylePropertyModulateSelf, ButtonColorHovered), Element <ContainerButton>().Class(ContainerButton.StyleClassButton) .Pseudo(ContainerButton.StylePseudoClassPressed) .Prop(Control.StylePropertyModulateSelf, ButtonColorPressed), Element <ContainerButton>().Class(ContainerButton.StyleClassButton) .Pseudo(ContainerButton.StylePseudoClassDisabled) .Prop(Control.StylePropertyModulateSelf, ButtonColorDisabled), // Colors for the caution buttons. Element <ContainerButton>().Class(ContainerButton.StyleClassButton).Class(ButtonCaution) .Pseudo(ContainerButton.StylePseudoClassNormal) .Prop(Control.StylePropertyModulateSelf, ButtonColorCautionDefault), Element <ContainerButton>().Class(ContainerButton.StyleClassButton).Class(ButtonCaution) .Pseudo(ContainerButton.StylePseudoClassHover) .Prop(Control.StylePropertyModulateSelf, ButtonColorCautionHovered), Element <ContainerButton>().Class(ContainerButton.StyleClassButton).Class(ButtonCaution) .Pseudo(ContainerButton.StylePseudoClassPressed) .Prop(Control.StylePropertyModulateSelf, ButtonColorCautionPressed), Element <ContainerButton>().Class(ContainerButton.StyleClassButton).Class(ButtonCaution) .Pseudo(ContainerButton.StylePseudoClassDisabled) .Prop(Control.StylePropertyModulateSelf, ButtonColorCautionDisabled), Element <Label>().Class(ContainerButton.StyleClassButton) .Prop(Label.StylePropertyAlignMode, Label.AlignMode.Center), Child() .Parent(Element <Button>().Class(ContainerButton.StylePseudoClassDisabled)) .Child(Element <Label>()) .Prop("font-color", Color.FromHex("#FFFFFF")), }); _userInterfaceManager.Stylesheet = Stylesheet; }
/// <summary> /// Draws a 3D text with the given font, style, color, transformation, horizontal align, and vertical /// align. /// </summary> /// <remarks> /// This 3D text won't be actually drawn until Flush() method is called. If this method is called before /// base.Draw(...) in your main Game class's Draw(...) function, then it's automatically flushed when /// base.Draw(...) is called. If this method is called after base.Draw(...) function, then you need to /// call Flush() function after calling one or more of this function. Otherwise, the 3D texts drawing will /// be deferred until the next base.Draw(...) or Flush() call. /// </remarks> /// <param name="text">Text string to be displayed in 3D.</param> /// <param name="font">Font to use for the 3D text.</param> /// <param name="style">3D text style (Outline, Fill, or Extrude).</param> /// <param name="color">Color of the 3D text.</param> /// <param name="transform">Transformation of the 3D text.</param> /// <param name="hAlign">The horizontal (x-axis) shifting</param> /// <param name="vAlign"></param> public static void Write3DText(String text, VectorFont font, Text3DStyle style, Color color, Matrix transform, GoblinEnums.HorizontalAlignment hAlign, GoblinEnums.VerticalAlignment vAlign) { if (queued3DTexts == null) { queued3DTexts = new List <Text3DInfo>(); } Text3DInfo textInfo = new Text3DInfo(); Text text3d = null; if (font == null) { throw new ArgumentException("'font' must be non-null value"); } switch (style) { case Text3DStyle.Outline: text3d = font.Outline(text); break; case Text3DStyle.Fill: text3d = font.Fill(text); break; case Text3DStyle.Extrude: text3d = font.Extrude(text); break; } textInfo.text3d = text3d; textInfo.color = color; Matrix shiftTransform = Matrix.Identity; switch (hAlign) { case GoblinEnums.HorizontalAlignment.None: case GoblinEnums.HorizontalAlignment.Left: // The default is aligned to left, so nothing to do break; case GoblinEnums.HorizontalAlignment.Center: shiftTransform.Translation -= Vector3.UnitX * text3d.Width / 2; break; case GoblinEnums.HorizontalAlignment.Right: shiftTransform.Translation -= Vector3.UnitX * text3d.Width; break; } switch (vAlign) { case GoblinEnums.VerticalAlignment.None: case GoblinEnums.VerticalAlignment.Bottom: // The default is aligned to bottom, so nothing to do break; case GoblinEnums.VerticalAlignment.Center: shiftTransform.Translation -= Vector3.UnitY * text3d.Height / 2; break; case GoblinEnums.VerticalAlignment.Top: shiftTransform.Translation -= Vector3.UnitY * text3d.Height; break; } shiftTransform *= MatrixHelper.GetRotationMatrix(transform); transform.Translation += shiftTransform.Translation; textInfo.transform = transform; queued3DTexts.Add(textInfo); }
/// <summary> /// Draws a 3D text with the given font, style, color, and transformation. /// </summary> /// <remarks> /// This 3D text won't be actually drawn until Flush() method is called. If this method is called before /// base.Draw(...) in your main Game class's Draw(...) function, then it's automatically flushed when /// base.Draw(...) is called. If this method is called after base.Draw(...) function, then you need to /// call Flush() function after calling one or more of this function. Otherwise, the 3D texts drawing will /// be deferred until the next base.Draw(...) or Flush() call. /// </remarks> /// <param name="text">Text string to be displayed in 3D.</param> /// <param name="font">Font to use for the 3D text.</param> /// <param name="style">3D text style (Outline, Fill, or Extrude).</param> /// <param name="color">Color of the 3D text.</param> /// <param name="transform">Transformation of the left-bottom corner of the 3D text.</param> public static void Write3DText(String text, VectorFont font, Text3DStyle style, Color color, Matrix transform) { Write3DText(text, font, style, color, transform, GoblinEnums.HorizontalAlignment.None, GoblinEnums.VerticalAlignment.None); }