private void DialogDemo() { var dialog = Skin.Create <GuiDialog>("dialog"); var stackPanel = new GuiStackPanel { Controls = { Skin.Create <GuiLabel>("label", c => { c.Text = "Are you sure you want to do that?"; c.Margin = new Thickness(0, 20, 0, 0); }), Skin.Create <GuiLabel>("label", c => { c.Text = "If you do you'll be in some serious trouble."; }), new GuiStackPanel { Orientation = GuiOrientation.Horizontal, VerticalAlignment = VerticalAlignment.Bottom, HorizontalAlignment = HorizontalAlignment.Centre, Controls = { Skin.Create <GuiButton>("white-button", c => { c.Text = "Yes"; c.Width = 100; c.Margin = new Thickness(2); c.Offset = new Vector2(0, 20); }), Skin.Create <GuiButton>("white-button", c => { c.Text = "No"; c.Width = 100; c.Margin = new Thickness(2); c.Offset = new Vector2(0, 20); }) } } } }; dialog.Controls.Add(stackPanel); dialog.Controls.Add(Skin.Create <GuiLabel>("label", c => { c.Text = "Please confirm"; c.VerticalAlignment = VerticalAlignment.Top; c.HorizontalAlignment = HorizontalAlignment.Centre; c.Offset = new Vector2(0, -30); c.BackgroundRegion = Skin.NinePatches.FirstOrDefault(i => i.Name == "progress-bar-blue"); })); dialog.Controls.Add(Skin.Create <GuiButton>("close-button", c => { c.HorizontalAlignment = HorizontalAlignment.Right; c.VerticalAlignment = VerticalAlignment.Top; c.Offset = new Vector2(20, -20); })); dialog.Show(this); }
public SelectDemoScreen(GuiSkin skin, IDictionary <string, DemoBase> demos, Action <string> loadDemo, Action exitGameAction) : base(skin) { _demos = demos; _loadDemo = loadDemo; //var button = Skin.Create<GuiButton>("white-button", c => //{ // c.Position = new Vector2(670, 430); // c.Size = new Size2(120, 42); // c.Text = "Next Demo"; //}); //var canvas = new GuiCanvas //{ // Controls = { button } //}; //Controls.Add(canvas); //button.Clicked += (sender, args) => onNextDemo(); var dialog = Skin.Create <GuiDialog>("dialog"); var grid = new GuiUniformGrid { Columns = 3 }; foreach (var demo in _demos.Values.OrderBy(i => i.Name)) { var button = Skin.Create <GuiButton>("white-button", c => { c.Text = demo.Name; c.Margin = new Thickness(4); c.Clicked += (sender, args) => LoadDemo(demo); }); grid.Controls.Add(button); } // Close button var atlas = skin.TextureAtlases[0]; var closeButtonRegion = atlas?.GetRegion("buttonRound_close"); if (closeButtonRegion != null) { var closeButton = Skin.Create <GuiButton>("white-button", c => { c.IconRegion = closeButtonRegion; c.Margin = new Thickness(4); c.Clicked += (sender, args) => exitGameAction(); }); grid.Controls.Add(closeButton); } dialog.Controls.Add(grid); Controls.Add(dialog); //DialogDemo(); }
public GuiLayoutScreen(GuiSkin skin, GraphicsDevice graphicsDevice) : base(skin) { _texture = new Texture2D(graphicsDevice, 1, 1); _texture.SetData(new[] { new Color(Color.Black, 0.5f) }); var backgroundRegion = new TextureRegion2D(_texture); var uniformGrid = new GuiUniformGrid(skin) { Text = "Uniform Grid", Controls = { new GuiCanvas(skin) { Text = "Canvas", Controls = { Skin.Create <GuiButton>("white-button", c =>{ c.Text = "Reasonably long text"; c.Position = new Vector2(0, 0); }), Skin.Create <GuiButton>("white-button", c =>{ c.Text = "Child 2"; c.Position = new Vector2(50, 50); }), Skin.Create <GuiButton>("white-button", c =>{ c.Text = "Child 3"; c.Position = new Vector2(100, 100); }), } }, new GuiStackPanel(skin) { Text = "Stack Panel (Vertical)", Orientation = GuiOrientation.Vertical, Controls = { Skin.Create <GuiButton>("white-button", c =>{ c.Text = "Child 1"; c.HorizontalAlignment = HorizontalAlignment.Centre; }), Skin.Create <GuiButton>("white-button", c =>{ c.Text = "Child 2"; c.HorizontalAlignment = HorizontalAlignment.Right; }), Skin.Create <GuiButton>("white-button", c =>{ c.Text = "Child 3"; c.HorizontalAlignment = HorizontalAlignment.Left; }), Skin.Create <GuiButton>("white-button", c =>{ c.Text = "Child 4"; }), } }, new GuiStackPanel(skin) { Text = "Stack Panel (Horizontal)", Orientation = GuiOrientation.Horizontal, Controls = { Skin.Create <GuiButton>("white-button", c =>{ c.Text = "Child 1"; c.Width =80; c.VerticalAlignment = VerticalAlignment.Centre; }), Skin.Create <GuiButton>("white-button", c =>{ c.Text = "Child 2"; c.Width =80; c.VerticalAlignment = VerticalAlignment.Top; }), Skin.Create <GuiButton>("white-button", c =>{ c.Text = "Child 3"; c.Width =80; c.VerticalAlignment = VerticalAlignment.Bottom; }), Skin.Create <GuiButton>("white-button", c =>{ c.Text = "Child 3"; c.Width = 80; }), } }, new GuiListBox(skin) { Name = "DisplayModesListBox" } } }; //var stackPanel = ; //stackPanel.PerformLayout(); Controls.Add(uniformGrid); var listBox = FindControl <GuiListBox>("DisplayModesListBox"); listBox.Items.AddRange(GraphicsAdapter.DefaultAdapter.SupportedDisplayModes.Select(i => $"{i.Width}x{i.Height}")); }
internal void CreateAndAddSkin(CharacterModel model, String nameToken, String unlockableName, Sprite icon) { var rampTex = this.knifeTrail.OutputTextureAndDispose(); using (var skin = Skin.Create(model)) { var snipermeshInd = -1; var throwkinfeInd = -1; var knifeInd = -1; var railgunInd = -1; var gaussgunInd = -1; var ammomeshInd = -1; var armormeshInd = -1; var bodymeshInd = -1; var cloakmeshInd = -1; var emismeshInd = -1; var classicRifleInd = -1; var classicMeshInd = -1; CharacterModel.RendererInfo[] rendInfos = skin.rendererInfos; for (Int32 i = 0; i < rendInfos.Length; ++i) { CharacterModel.RendererInfo info = rendInfos[i]; Renderer smr = info.renderer; switch (smr.name) { default: #if ASSERT Log.Warning(String.Format("{0} is not a handled renderer name", smr.name)); #endif info.defaultMaterial = null; break; case "SniperMesh": info.defaultMaterial = null; snipermeshInd = i; break; case "ThrowKnife": info.defaultMaterial = this.throwknifeMat; throwkinfeInd = i; break; case "Knife": info.defaultMaterial = this.isTrash ? null : this.knifeMat; knifeInd = i; break; case "RailGun": info.defaultMaterial = this.isTrash ? null : this.railMat; railgunInd = i; break; case "GaussGun": info.defaultMaterial = null; gaussgunInd = i; break; case "AmmoMesh": info.defaultMaterial = this.isTrash ? null : this.ammoMat; ammomeshInd = i; break; case "ArmorMesh": info.defaultMaterial = this.isTrash ? null : this.armorMat; armormeshInd = i; break; case "BodyMesh": info.defaultMaterial = this.isTrash ? null : this.bodyMat; bodymeshInd = i; break; case "CloakMesh": info.defaultMaterial = this.isTrash ? null : this.cloakMat; cloakmeshInd = i; break; case "EmissionMesh": info.defaultMaterial = this.isTrash ? null : this.emisMat; emismeshInd = i; break; case "ClassicRifle": info.defaultMaterial = !this.isTrash ? null : this.railMat; classicRifleInd = i; break; case "ClassicMesh": info.defaultMaterial = !this.isTrash ? null : this.armorMat; classicMeshInd = i; break; } rendInfos[i] = info; } skin.rendererInfos = rendInfos; skin.projectileGhostReplacements = new[] { new SkinDef.ProjectileGhostReplacement { projectilePrefab = ProjectileModule.GetKnifeProjectile(), projectileGhostReplacementPrefab = ProjectileGhostModule.GetKnifeGhost(this.throwknifeMat, MaterialModule.GetKnifeTrailMaterial(rampTex).material), }, }; if (this.isTrash) { skin.gameObjectActivations = new[] { new SkinDef.GameObjectActivation { shouldActivate = false, gameObject = rendInfos[armormeshInd].renderer.gameObject, }, new SkinDef.GameObjectActivation { shouldActivate = false, gameObject = rendInfos[ammomeshInd].renderer.gameObject, }, new SkinDef.GameObjectActivation { shouldActivate = false, gameObject = rendInfos[bodymeshInd].renderer.gameObject, }, new SkinDef.GameObjectActivation { shouldActivate = false, gameObject = rendInfos[cloakmeshInd].renderer.gameObject, }, new SkinDef.GameObjectActivation { shouldActivate = false, gameObject = rendInfos[emismeshInd].renderer.gameObject, }, new SkinDef.GameObjectActivation { shouldActivate = false, gameObject = rendInfos[railgunInd].renderer.gameObject, }, new SkinDef.GameObjectActivation { shouldActivate = false, gameObject = rendInfos[knifeInd].renderer.gameObject, }, new SkinDef.GameObjectActivation { shouldActivate = true, gameObject = rendInfos[classicMeshInd].renderer.gameObject, }, new SkinDef.GameObjectActivation { shouldActivate = true, gameObject = rendInfos[classicRifleInd].renderer.gameObject, } }; } else { skin.gameObjectActivations = new[] { new SkinDef.GameObjectActivation { shouldActivate = true, gameObject = rendInfos[armormeshInd].renderer.gameObject, }, new SkinDef.GameObjectActivation { shouldActivate = true, gameObject = rendInfos[ammomeshInd].renderer.gameObject, }, new SkinDef.GameObjectActivation { shouldActivate = true, gameObject = rendInfos[bodymeshInd].renderer.gameObject, }, new SkinDef.GameObjectActivation { shouldActivate = true, gameObject = rendInfos[cloakmeshInd].renderer.gameObject, }, new SkinDef.GameObjectActivation { shouldActivate = true, gameObject = rendInfos[emismeshInd].renderer.gameObject, }, new SkinDef.GameObjectActivation { shouldActivate = true, gameObject = rendInfos[railgunInd].renderer.gameObject, }, new SkinDef.GameObjectActivation { shouldActivate = true, gameObject = rendInfos[knifeInd].renderer.gameObject, }, new SkinDef.GameObjectActivation { shouldActivate = false, gameObject = rendInfos[classicMeshInd].renderer.gameObject, }, new SkinDef.GameObjectActivation { shouldActivate = false, gameObject = rendInfos[classicRifleInd].renderer.gameObject, } }; } skin.icon = icon; skin.nameToken = nameToken; skin.unlockableName = unlockableName; } var index = model.GetComponent <ModelSkinController>().skins.Length - 1; var material = MaterialModule.GetSlashMaterial(rampTex); VFXModule.AddKnifePickupSlash((UInt32)index, material); }