public static Parent TestTextArea() { var parent = new Parent(new LineStrategy { Gap = 1 }); var tf = new TextField(); parent.AddComponent(new BoxContainer(tf)); var tc = new TextComponent { HAlign = HorizontalAlignment.Centered }; var p = new Parent(new BorderStrategy()) { ClearAreaBeforePrint = true }; p.AddComponent(tc, BorderStrategy.Center); parent.AddComponent(p); tf.ActionOnComponent += (sender, args) => { tc.Text = tf.Text; p.Print(args.Graphics); }; return(parent); }
public ViuDemo() { var mainContainer = new Parent { ClearAreaBeforePrint = true }; var cons = new ConsoleParent(mainContainer); cons.SetTitle("Viu/SCFE Demo"); var switcher = new SwitcherStrategy(mainContainer); mainContainer.Strategy = switcher; var menu = new Parent(new LineStrategy { Centered = true }); mainContainer.AddComponent(menu); menu.AddComponent(new TextComponent("~ SCFE Demo ~") { Foreground = ConsoleColor.Yellow, HAlign = HorizontalAlignment.Centered }); menu.AddComponent(new Separator()); switcher.SwitchToComponent(menu, null); var table = new TableComponent <ViuDemoType> { Data = _demos }; menu.AddComponent(table); table.AddColumn(new IndicatorColumnType <ViuDemoType>()); table.AddColumn( new BasicColumnType <ViuDemoType>("Choose a demo to get started. Exit a demo with the Escape key.", vdt => vdt.Name)); table.ActionOnListElement += (sender, args) => { switcher.SwitchToComponent(args.Item.Parent, args.Graphics); mainContainer.Validate(); mainContainer.Print(args.Graphics); }; foreach (var vdt in _demos) { mainContainer.AddComponent(vdt.Parent); } mainContainer.ActionMap.Put(StandardActionNames.CancelAction, (o, args) => { mainContainer.SetFocused(false, args.Graphics); switcher.SwitchToComponent(menu, args.Graphics); mainContainer.Validate(); mainContainer.SetFocused(true, args.Graphics); mainContainer.Print(args.Graphics); }); cons.Validate(); cons.FocusFirst(); cons.Print(); }
public static Parent TestBorders() { var parent = new Parent(new BorderStrategy()); TextComponent txt = new ColorfulLabel("HELLO!") { VAlign = VerticalAlignment.Centered, HAlign = HorizontalAlignment.Centered, Focusable = true }; parent.AddComponent(new BoxContainer(txt), BorderStrategy.Center); var p2 = new Parent(new FlowStrategy(1)); var text = "Flow Lay".Split(' '); foreach (var s in text) { var tc = new TextComponent(s) { Focusable = true }; p2.AddComponent(tc); } parent.AddComponent(p2, BorderStrategy.Left); TextComponent txtr = new ColorfulLabel("Right!") { VAlign = VerticalAlignment.Centered, Focusable = true }; parent.AddComponent(txtr, BorderStrategy.Right); p2 = new Parent(new FlowStrategy(true, 1, 0)); text = "This is a test of the flow layout! How amazing".Split(' '); foreach (var s in text) { var tc = new TextComponent(s) { Focusable = true }; p2.AddComponent(tc); } parent.AddComponent(p2, BorderStrategy.Top); TextComponent txtb = new ColorfulLabel("Down!") { HAlign = HorizontalAlignment.Centered, Focusable = true }; parent.AddComponent(txtb, BorderStrategy.Bottom); return(parent); }
public FileOptionsPanel(ImmutableList <File> f, AbstractHierarchicalDictionary <KeyStroke, string> inputMap) { TextComponent fileName; Strategy = new BorderStrategy(); var topParent = new Parent(new LineStrategy { Orientation = Orientation.Vertical }); AddComponent(topParent, BorderStrategy.Top); fileName = new TextComponent(f == null ? "Current directory options" : f.Count == 1 ? f[0].GetFileName() : f.Count + " files...") { HAlign = HorizontalAlignment.Centered }; topParent.AddComponent(fileName); topParent.AddComponent(new Separator()); var table = new TableComponent <FileOption> { Data = new ObservableCollection <FileOption>(f == null ? FileOption.OptionsForCurrentDirectory .Where(opt => opt.CanActionBeApplied?.Invoke(null, null) ?? true).ToList() : FileOption.Options .Where(opt => opt.CanActionBeApplied(f, null)).ToList()), ShowHeader = false }; table.AddColumn(new IndicatorColumnType <FileOption>()); table.AddColumn(new BasicColumnType <FileOption>("", option => option.Title) { GrowPriority = 1 }); table.AddColumn( new BasicColumnType <FileOption>("", option => SearchForShortcut(option.ActionName, inputMap)) { HAlign = HorizontalAlignment.Right }); table.ActionOnListElement += (sender, args) => { RemovalCallback(args.Item.ActionName, args.Graphics); }; AddComponent(table, BorderStrategy.Center); var btn = new Button("Back"); btn.ActionOnComponent += (sender, args) => RemovalCallback?.Invoke(null, args.Graphics); AddComponent(btn, BorderStrategy.Bottom); ActionMap.Put(StandardActionNames.CancelAction, (o, args) => RemovalCallback?.Invoke(null, args.Graphics)); }
public override void Update(GameTime gameTime) { if (!_createdBoxes) { _createdBoxes = true; var scale = Vector3.One * 20f; for (int i = 0; i < 10; i++) { Parent.AddComponent( new Drawable3DComponent(RootComponent.ModelData) { Position = new Vector3(i + 5, 0f, 0f) * scale.X, Scale = scale } ); } var material = new PhysicsMaterial("box") { Friction = 0.8f }; Parent.AddComponent( new StaticBodyComponent(new Box(2f, 2f, 2f, 1f)) { Material = material, } ); Parent.Scale = scale; } }
public void OpenActionSecondaryAction(ImmutableList <File> files, GraphicsContext g1) { if (files != null && _table.FocusedElement == null) { return; } if (TextBoxHandler != null) { CancelTextBoxHandler(g1); } TextBox.Focusable = false; var fop = new FileOptionsPanel(files, _cons.InputMap); var container = new BoxContainer(fop, LineStyle.Dotted); fop.RemovalCallback = (actionToDo, g) => { ((SwitcherStrategy)_wrapper.Strategy).SwitchToComponentWithHint(0, g); _wrapper.RemoveComponent(container); _wrapper.Validate(); _wrapper.Print(g); TextBox.Focusable = true; if (actionToDo != null) { _table.ActionMap.Get(actionToDo)?.Invoke(null, new ActionEventArgs(_wrapper, null, g)); } }; _wrapper.AddComponent(container, 1); ((SwitcherStrategy)_wrapper.Strategy).SwitchToComponentWithHint(1, g1); _wrapper.Validate(); _wrapper.Print(g1); }
public static Parent LaunchExample() { var data = new ObservableCollection <Example> { new Example { Name = "Test", Number = 7, Color = ConsoleColor.Cyan }, new Example { Name = "Woosh", Number = 18, Color = ConsoleColor.Red }, new Example { Name = "Yeet", Number = 68, Color = ConsoleColor.Gray } }; var par = new Parent(new BorderStrategy()) { ClearAreaBeforePrint = true }; var table = new TableComponent <Example> { Data = data }; table.ActionOnListElement += (o, args) => { data.Remove(args.Item); }; table.AddColumn(new IndicatorColumnType <Example>()); table.AddColumn(new BasicColumnType <Example>("Name", e => e.Name)); table.AddColumn(new ColorColumnType()); par.AddComponent(table, BorderStrategy.Center); return(par); }
void OnPlayerJoining(PlayerJoiningEvent @event) { foreach (var type in _componentTypes) { Parent.AddComponent(type, @event.Player); } }
protected override void OnParentSet(IHexGridCell oldParent) { if (oldParent != null) { oldParent.RemoveComponent <UnselectableComponent>(); } Parent.AddComponent(new UnselectableComponent()); }
public static Parent TestSimpleBorder() { var par = new Parent(new BorderStrategy()); par.AddComponent(new TextComponent("Hey!") { VAlign = VerticalAlignment.Centered }, BorderStrategy.Left); par.AddComponent( new TextComponent("This is at the top of the window!") { HAlign = HorizontalAlignment.Centered }, BorderStrategy.Top); par.AddComponent( new TextComponent("This is at the bottom of the window!") { HAlign = HorizontalAlignment.Centered }, BorderStrategy.Bottom); par.AddComponent(new TextComponent("Bye!") { VAlign = VerticalAlignment.Centered }, BorderStrategy.Right); var center = new Parent(new LineStrategy { Centered = true }); par.AddComponent(center, BorderStrategy.Center); center.AddComponent(new TextComponent("This is a simple demo of the 'BorderStrategy'.") { HAlign = HorizontalAlignment.Centered, Focusable = true }); center.AddComponent(new TextComponent("The middle container uses a 'LineStrategy'") { HAlign = HorizontalAlignment.Centered, Focusable = true }); center.AddComponent(new TextComponent("with multiple Text components on top of each other.") { HAlign = HorizontalAlignment.Centered, Focusable = true }); return(par); }
/// <summary> /// Method invoked when the component is ready to start, having received its /// initial parameters from its parent in the render tree. /// </summary> protected override void OnInitialized() { if (Parent != null) { UI = false; Parent.AddComponent(this); } }
public void Add(Type type) { var playerList = this.Get <PlayerList>(); foreach (var player in playerList.Where(p => p.IsJoined())) { Parent.AddComponent(type, player); } }
public override void Initialize() { base.Initialize(); if (ModelPath != null) { RootComponent = new Drawable3DComponent(ModelPath); Parent.AddComponent(RootComponent); } }
public override void Initialize() { base.Initialize(); CounterText = new TextComponent("fonts/font", Color.Black, Game.DefaultSpriteShader, "") { Position = Komodo.Lib.Math.Vector3.Zero }; Parent.AddComponent(CounterText); }
public static Parent TestButtons() { var par = new Parent(new LineStrategy { Centered = true, Gap = 1 }); var txt = new TextComponent("I am a text! I do texty stuff!") { HAlign = HorizontalAlignment.Centered }; par.AddComponent(new TextComponent( "Use arrow keys to move around options. " + "Press Enter to apply the color.")); var btns = new Parent(new FlowStrategy(true, 1, 0)); foreach (ConsoleColor col in Enum.GetValues(typeof(ConsoleColor))) { if (col == ConsoleColor.Black) { continue; } var b = new Button("I like " + Enum.GetName(typeof(ConsoleColor), col)) { Foreground = col }; btns.AddComponent(b); b.ActionOnComponent += (sender, args) => { txt.Foreground = col; txt.Print(args.Graphics); }; } par.AddComponent(btns); par.AddComponent(txt); return(par); }
void ButtonOptions_Click(UIButton sender) { var optionsWindow = ResourceManager.LoadSeparateInstance <UIWindow>(@"Base\UI\Screens\OptionsWindow.ui", false, true); if (optionsWindow != null) { Parent.AddComponent(optionsWindow); Dispose(); } }
public override void Initialize() { base.Initialize(); Parent.AddComponent(new Drawable3DComponent("models/cube")); if (PlayerIndex == 0) { Parent.AddComponent(new MoveBehavior(PlayerIndex)); } Scale = Vector3.One * 10f; }
public void Update(GameTime gameTime) { if (LinearVelocity.LengthSquared() >= 1e-7) { var step = LinearVelocity * World.TimeScale * (float)gameTime.ElapsedGameTime.TotalSeconds; bool stopped = false; var rf = this; World.Physics.RayCast((Fixture arg1, Vector2 arg2, Vector2 arg3, float arg4) => { if (arg1.Body.Tag is TerrainComponent) { Position = arg2 * 64f; LinearVelocity = Vector2.Zero; stopped = true; } else if (arg1.Body.Tag is Entity) { var ent = arg1.Body.Tag as Entity; if (ent.Tags.Any(t => TargetedTags.Contains(t))) { var ch = ent.GetComponent <CharacterComponent>(); if (ch != null) { ch.Damage(World.GetEntity(OwnerID), Damage); Position = arg2 * 64f; LinearVelocity = Vector2.Zero; stopped = true; Parent.AddComponent(new BindedBodyComponent().BindTo(ent, Position, Rotation)); rf.Remove = true; return(0); } } } return(arg4); }, Position / 64f, (Position + step) / 64f); if (!stopped) { Position += step; } else { Gravity = false; } } if (Gravity) { LinearVelocity += new Vector2(0, World.Physics.Gravity.Y * 64f * (float)gameTime.ElapsedGameTime.TotalSeconds * World.TimeScale); } if (Friction > 0) { LinearVelocity /= Friction; } }
private void CancelAnimation() { attackAnimation = false; Parent.RemoveComponent <DrawAnimationComponent>(); Parent.AddComponent(orginalTexture); if (!damaged) { DamageTarget(); } }
public override void Initialize() { base.Initialize(); if (ModelPath != null) { RootComponent = new Drawable3DComponent(ModelPath) { TexturePath = "player/idle/player_idle_01" }; Parent.AddComponent(RootComponent); } }
public static Parent TestTable() { var par = new Parent(new BorderStrategy()) { ClearAreaBeforePrint = false }; var data = new ObservableCollection <string[]> { new[] { "Hello!", "This is a table", "A nice one" }, new[] { "hey", "bonjour", "buon giorno" }, new[] { "who", "are", "you?" } }; var table = new TableComponent <string[]> { Data = data }; //table.AddColumn(new BasicColumnInformationType<string[]>("Test.", s => s[0])); //table.AddColumn(new BasicColumnInformationType<string[]>("Zboui zboui zboui.", s => s[1])); //table.AddColumn(new BasicColumnInformationType<string[]>("Test...", s => s[2])); table.AddColumn(new IndicatorColumnType <string[]>()); table.AddColumn(new MultistateColumnType <string[]>(new[] { "This is a screenshot", "Screenshot" }, x => new[] { x[0], x[0].Split(' ')[0], x[0].ToCharArray()[0] + "" } ) { Priority = 1, GrowPriority = 10 }); table.AddColumn(new MultistateColumnType <string[]>( new[] { "A fairly long column name", "A shorter one", "A" }, x => new[] { x[1], x[1].Split(' ')[0], x[1].ToCharArray()[0] + "" } ) { Priority = 2, GrowPriority = 20 }); table.AddColumn(new MultistateColumnType <string[]>(new[] { "I am running out of ideas", "Ideas", "I" }, x => new[] { x[2], x[2].Split(' ')[0], x[2].ToCharArray()[0] + "" } ) { Priority = 2, GrowPriority = 10 }); par.AddComponent(table, BorderStrategy.Center); return(par); }
internal override void CommandOperation() { if (CreatedContainer == null) { CreatedContainer = new Helpers.ElementHolder <PSMContentContainer>(); } PSMSubordinateComponent first = Parent.Components.FirstOrDefault(component => containedComponents.Contains(component)); PSMContentContainer psmContainer; if (Parent != null) { if (first == null) { psmContainer = (PSMContentContainer)Parent.AddComponent(PSMContentContainerFactory.Instance); } else { psmContainer = (PSMContentContainer)Parent.AddComponent( PSMContentContainerFactory.Instance, Parent.Components.IndexOf(first)); } } else //add as root { PSMDiagram diagram = (PSMDiagram)Diagram; PSMContentContainer contentContainer = (PSMContentContainer)PSMContentContainerFactory.Instance.Create(null, diagram.Project.Schema); contentContainer.Diagram = diagram; psmContainer = contentContainer; diagram.Roots.Add(psmContainer); } psmContainer.Name = Name; CreatedContainer.Element = psmContainer; AssociatedElements.Add(psmContainer); foreach (PSMSubordinateComponent containedComponent in containedComponents) { oldIndexes[containedComponent] = containedComponent.ComponentIndex(); Parent.Components.Remove(containedComponent); psmContainer.Components.Add(containedComponent); } Debug.Assert(CreatedContainer.HasValue); Diagram.AddModelElement(psmContainer, ViewHelper = new PSMElementViewHelper(Diagram)); }
public static Parent TestFlow() { var parent = new Parent(new FlowStrategy(1)); var text = "This is a test of the flow layout! How amazing".Split(' '); foreach (var s in text) { var tc = new TextComponent(s) { Focusable = true }; parent.AddComponent(tc); } return(parent); }
public override void Initialize() { base.Initialize(); var material = new PhysicsMaterial("player") { Restitution = 1f, LinearDamping = 1f, LinearDampingLimit = 0.1f, }; Body = new DynamicBodyComponent( new Box(2f, 2f, 2f, 1f) ) { Position = new Vector3(0, 0f, 0f), Material = material, }; Parent.AddComponent(Body); }
public override void Use() { if (!Activated) { base.Use(); shieldImg = new Image(Library.GetTexture("shield_active.png")); shieldImg.CenterOO(); shieldImg.Alpha = 0.0f; shieldImg.Y = 10 - (shieldImg.Height / 2); Parent.AddComponent(shieldImg); Tweener.Tween(shieldImg, new { Alpha = 0.6f }, 0.45f); owner.OnMessage(Shield.Message.Set, true); Mixer.ShieldUp.Play(); } }
public override void Update(GameTime gameTime) { if (!_createdBoxes) { _createdBoxes = true; var component = new Drawable3DComponent(RootComponent.ModelData); var model = component.ModelData; float scale = 20f; for (int i = 0; i < 50; ++i) { for (int j = 0; j < 20; ++j) { Parent.AddComponent( new Drawable3DComponent(model) { Position = new Vector3(50f * i, 50f * j, 0f) } ); } } Parent.Scale = new Vector3(scale, scale, scale); } }
public override void Initialize() { base.Initialize(); Parent.AddComponent( new SpriteComponent("player/idle/player_idle_01", Game?.DefaultSpriteShader) { IsBillboard = false } ); if (PlayerIndex == 0) { Parent.AddComponent(new MoveBehavior(PlayerIndex)); } Parent.AddComponent( new TextComponent("fonts/font", Color.Black, Game?.DefaultSpriteShader, $"Test {PlayerIndex}") { IsBillboard = false, Position = new Komodo.Lib.Math.Vector3(0f, 20f, 0) } ); }
internal override void CommandOperation() { if (CreatedChoice == null) { CreatedChoice = new Helpers.ElementHolder <PSMContentChoice>(); } PSMSubordinateComponent first = Parent.Components.FirstOrDefault(component => containedComponents.Contains(component)); PSMContentChoice psmChoice; if (first == null) { psmChoice = (PSMContentChoice)Parent.AddComponent(PSMContentChoiceFactory.Instance); } else { psmChoice = (PSMContentChoice)Parent.AddComponent(PSMContentChoiceFactory.Instance, first.ComponentIndex()); } psmChoice.Name = Name; CreatedChoice.Element = psmChoice; AssociatedElements.Add(psmChoice); foreach (PSMSubordinateComponent containedComponent in containedComponents) { oldIndexes[containedComponent] = containedComponent.ComponentIndex(); Parent.Components.Remove(containedComponent); psmChoice.Components.Add(containedComponent); } Debug.Assert(CreatedChoice.HasValue); Diagram.AddModelElement(psmChoice, ViewHelper = new PSMElementViewHelper(Diagram)); }
public override void Use() { if (!Activated) { base.Use(); shield_1 = new Image(Library.GetTexture("rebound_active_1.png")); shield_2 = new Image(Library.GetTexture("rebound_active_2.png")); shield_1.CenterOO(); shield_2.CenterOO(); shield_1.Alpha = 0.0f; shield_2.Alpha = 0.0f; Parent.AddComponent(shield_1); Parent.AddComponent(shield_2); shield_1.Y = 10 - (shield_1.Height / 2); shield_2.Y = 10 - (shield_2.Height / 2); Tweener.Tween(shield_1, new { Alpha = 0.6f }, 0.45f); Tweener.Tween(shield_2, new { Alpha = 0.6f }, 0.45f); owner.OnMessage(Rebound.Message.Set, true); Mixer.ReboundUp.Play(); var existingCollisions = new List <Entity>(); Parent.CollideInto(Parent.Type, Parent.X, Parent.Y, existingCollisions); foreach (var player in existingCollisions) { player.OnMessage(PhysicsBody.Message.Impulse, 0, -Fist.BASE_PUNCH_FORCE); } } }
public Gun(GameObject parent) : base(parent) { currentClipIndex = 1; ShootSoundComponent = Parent.AddComponent(new Audio.AudioSource(Parent, Audio.SoundContainer.Instance.GetSoundEffect("GunShoot"))); }