mirror of
				https://github.com/KevinMidboe/linguist.git
				synced 2025-10-29 17:50:22 +00:00 
			
		
		
		
	| @@ -3596,6 +3596,13 @@ Unity3D Asset: | ||||
|   - .unity | ||||
|   tm_scope: source.yaml | ||||
|  | ||||
| Uno: | ||||
|   type: programming | ||||
|   extensions: | ||||
|   - .uno | ||||
|   ace_mode: csharp | ||||
|   tm_scope: source.cs | ||||
|  | ||||
| UnrealScript: | ||||
|   type: programming | ||||
|   color: "#a54c4d" | ||||
| @@ -3802,6 +3809,7 @@ XML: | ||||
|   - .tsx | ||||
|   - .ui | ||||
|   - .urdf | ||||
|   - .ux | ||||
|   - .vbproj | ||||
|   - .vcxproj | ||||
|   - .vxml | ||||
|   | ||||
							
								
								
									
										154
									
								
								samples/Uno/PlayerPads.uno
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										154
									
								
								samples/Uno/PlayerPads.uno
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,154 @@ | ||||
| using Uno; | ||||
| using Uno.Collections; | ||||
| using Uno.Graphics; | ||||
| using Uno.Scenes; | ||||
| using Uno.Designer; | ||||
| using Uno.Content; | ||||
| using Uno.Content.Models; | ||||
| using Uno.UI; | ||||
|  | ||||
| namespace PONG2D | ||||
| { | ||||
| 	public class PlayerPads : Node | ||||
| 	{ | ||||
|  | ||||
| 		Image _player1Image; | ||||
| 		Image _player2Image; | ||||
|  | ||||
| 		[Inline] | ||||
| 		public Image Player1 | ||||
| 		{ | ||||
| 			get { return _player1Image; } | ||||
| 			set | ||||
| 			{ | ||||
| 				if (_player1Image != value) | ||||
| 				{ | ||||
| 					_player1Image = value; | ||||
| 					 | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		[Inline] | ||||
| 		public Image Player2 | ||||
| 		{ | ||||
| 			get { return _player2Image; } | ||||
| 			set | ||||
| 			{ | ||||
| 				if (_player2Image != value) | ||||
| 				{ | ||||
| 					_player2Image = value; | ||||
| 					 | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		[Hide] | ||||
| 		public float2 Player1Pos | ||||
| 		{ | ||||
| 			get { return (Player1.ActualPosition); } | ||||
| 			set | ||||
| 			{ | ||||
| 				if (Player1 != null) | ||||
| 					Player1.Position = value; | ||||
| 				 | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		[Hide] | ||||
| 		public float2 Player2Pos | ||||
| 		{ | ||||
| 			get { return (Player2.ActualPosition); } | ||||
| 			set | ||||
| 			{ | ||||
| 				if (Player2 != null) | ||||
| 					Player2.Position = value; | ||||
| 				 | ||||
| 			} | ||||
| 		} | ||||
| 		 | ||||
| 		public Rect Player1Rect | ||||
| 		{ | ||||
| 			get { return new Rect(Player1Pos, float2(Player1.Width, Player2.Height)); } | ||||
| 			set | ||||
| 			{ | ||||
| 				Player1Pos = value.Position; | ||||
| 				if (Player1 != null) | ||||
| 				{ | ||||
| 					Player1.Width = value.Size.X; | ||||
| 					Player1.Height = value.Size.Y; | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 		 | ||||
| 		public Rect Player2Rect | ||||
| 		{ | ||||
| 			get { return new Rect(Player2Pos, float2(Player2.Width, Player2.Height)); } | ||||
| 			set | ||||
| 			{ | ||||
| 				Player2Pos = value.Position; | ||||
| 				if (Player2 != null) | ||||
| 				{ | ||||
| 					Player2.Width = value.Size.X; | ||||
| 					Player2.Height = value.Size.Y; | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		public Ball Ball | ||||
| 		{ | ||||
| 			get; | ||||
| 			set; | ||||
| 		} | ||||
| 		 | ||||
| 		public float PadVelocity { get; set; } | ||||
|  | ||||
| 		public PlayerPads() | ||||
| 		{ | ||||
|  | ||||
| 		} | ||||
|  | ||||
| 		void UpdatePositions() | ||||
| 		{ | ||||
| 			 | ||||
| 		} | ||||
|  | ||||
| 		protected override void OnUpdate() | ||||
| 		{ | ||||
| 			base.OnUpdate(); | ||||
|  | ||||
| 			if (Input.IsKeyDown(Uno.Platform.Key.W)) | ||||
| 			{ | ||||
| 				Player1Pos = float2(0, Player1Pos.Y - PadVelocity); | ||||
| 			} | ||||
|  | ||||
| 			if (Input.IsKeyDown(Uno.Platform.Key.S)) | ||||
| 			{ | ||||
| 				Player1Pos = float2(0, Player1Pos.Y + PadVelocity); | ||||
| 			} | ||||
|  | ||||
| 			if (Input.IsKeyDown(Uno.Platform.Key.Up)) | ||||
| 			{ | ||||
| 				Player2Pos = float2(0, Player2Pos.Y - PadVelocity); | ||||
| 			} | ||||
|  | ||||
| 			if (Input.IsKeyDown(Uno.Platform.Key.Down)) | ||||
| 			{ | ||||
| 				Player2Pos = float2(0, Player2Pos.Y + PadVelocity); | ||||
| 			} | ||||
| 			 | ||||
| 			if (Ball != null) | ||||
| 			{ | ||||
| 				 | ||||
| 				if (Ball.BallRectangle.Intersects(Player1Rect) || | ||||
| 					Ball.BallRectangle.Intersects(Player2Rect)) | ||||
| 				{ | ||||
| 					 | ||||
| 					Ball.BallVelocity = float2(Ball.BallVelocity.X * -1f, Ball.BallVelocity.Y); | ||||
| 				} | ||||
| 			} | ||||
| 			 | ||||
| 		} | ||||
|  | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										139
									
								
								samples/Uno/Pong.uno
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										139
									
								
								samples/Uno/Pong.uno
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,139 @@ | ||||
| using Uno; | ||||
| using Uno.Collections; | ||||
| using Uno.Graphics; | ||||
| using Uno.Scenes; | ||||
| using Uno.Content; | ||||
| using Uno.Content.Models; | ||||
|  | ||||
| namespace PONG2D | ||||
| { | ||||
| 	public class Pong : Node | ||||
| 	{ | ||||
| 		float2 _player1Pos; | ||||
| 		float2 _player2Pos; | ||||
| 		float2 ballPosition; | ||||
| 		float2 ballVelocity; | ||||
| 		float2 rectangleSize; | ||||
| 		 | ||||
| 		Rect player1Rect; | ||||
| 		Rect player2Rect; | ||||
| 		Rect ballRect; | ||||
| 		 | ||||
| 		float2 resolution = Context.VirtualResolution; | ||||
| 		 | ||||
| 		Random random = new Random(1); | ||||
| 		 | ||||
| 		 | ||||
| 		float2 Player1Pos | ||||
| 		{ | ||||
| 			get { return _player1Pos; } | ||||
| 			set | ||||
| 			{ | ||||
| 				_player1Pos = Math.Clamp(value, float2(0, 0), resolution - rectangleSize); | ||||
| 			} | ||||
| 		} | ||||
| 		 | ||||
| 		float2 Player2Pos | ||||
| 		{ | ||||
| 			get { return _player2Pos; } | ||||
| 			set | ||||
| 			{ | ||||
| 				_player2Pos = Math.Clamp(value, float2(0, 0), resolution - rectangleSize); | ||||
| 			} | ||||
| 		} | ||||
| 		 | ||||
| 		public Pong() | ||||
| 		{ | ||||
| 			Uno.Scenes.Input.AddGlobalListener(this); | ||||
| 		} | ||||
| 		 | ||||
| 		protected override void OnInitialize() | ||||
| 		{ | ||||
| 			base.OnInitialize(); | ||||
| 			UpdateValues();	 | ||||
| 			 | ||||
| 		} | ||||
|  | ||||
| 		void UpdateValues() | ||||
| 		{ | ||||
| 			rectangleSize = float2(resolution.X / 80f, resolution.Y / 5f); | ||||
| 			_player1Pos = float2(0f); | ||||
| 			_player2Pos = float2(Context.VirtualResolution.X - rectangleSize.X, 0f); | ||||
| 			 | ||||
| 			player1Rect = new Rect(_player1Pos, rectangleSize); | ||||
| 			player2Rect = new Rect(_player2Pos, rectangleSize); | ||||
| 			 | ||||
| 			ballPosition = float2(resolution.X * 0.5f - 10f, resolution.Y * 0.5f - 10f); | ||||
| 			ballRect = new Rect(ballPosition, float2(20f)); | ||||
| 			 | ||||
| 			 | ||||
| 			SpwanBall(); | ||||
| 			 | ||||
| 		} | ||||
| 		 | ||||
| 		void SpwanBall() | ||||
| 		{ | ||||
| 			ballRect.Position = float2(resolution.X * 0.5f - 10f, resolution.Y * 0.5f - 10f); | ||||
| 			ballVelocity = float2(5f, 10f) * 0.5f; | ||||
| 		} | ||||
| 		 | ||||
| 		void OnWindowResize(object sender, EventArgs args) | ||||
| 		{ | ||||
| 			//UpdateValues(); | ||||
| 		} | ||||
| 		 | ||||
| 		protected override void OnUpdate() | ||||
| 		{ | ||||
| 			base.OnUpdate(); | ||||
| 			 | ||||
| 			var padVelocity = resolution.Y * (float)Application.Current.FrameInterval * 4f; | ||||
| 			if (Input.IsKeyDown(Uno.Platform.Key.Up)) | ||||
| 			{ | ||||
| 				Player1Pos = float2(Player1Pos.X, Player1Pos.Y - padVelocity);	 | ||||
| 			} | ||||
| 			 | ||||
| 			if (Input.IsKeyDown(Uno.Platform.Key.Down)) | ||||
| 			{ | ||||
| 				Player1Pos = float2(Player1Pos.X, Player1Pos.Y + padVelocity);	 | ||||
| 			} | ||||
|  | ||||
| 			if (Input.IsKeyDown(Uno.Platform.Key.W)) | ||||
| 			{ | ||||
| 				Player2Pos = float2(Player2Pos.X, Player2Pos.Y - padVelocity);	 | ||||
| 			} | ||||
|  | ||||
| 			if (Input.IsKeyDown(Uno.Platform.Key.S)) | ||||
| 			{ | ||||
| 				Player2Pos = float2(Player2Pos.X, Player2Pos.Y + padVelocity);	 | ||||
| 			} | ||||
| 			player1Rect.Position = Player1Pos; | ||||
| 			player2Rect.Position = Player2Pos; | ||||
| 			 | ||||
| 			if (ballRect.Position.X > resolution.X || ballRect.Position.X < 0) | ||||
| 			{ | ||||
| 				SpwanBall(); | ||||
| 			} | ||||
| 			if (ballRect.Position.Y > resolution.Y || | ||||
| 				ballRect.Position.Y < 0) | ||||
| 			{ | ||||
| 				ballVelocity.Y *= -1f; | ||||
| 			} | ||||
| 			 | ||||
| 			if (ballRect.Intersects(player1Rect) || | ||||
| 				ballRect.Intersects(player2Rect)) | ||||
| 			{ | ||||
| 				ballVelocity.X *= -1f; | ||||
| 			} | ||||
| 			 | ||||
| 			ballRect.Position += ballVelocity; | ||||
| 			 | ||||
| 		} | ||||
| 		 | ||||
|         protected override void OnDraw() | ||||
|         { | ||||
| 			Uno.Drawing.RoundedRectangle.Draw(player1Rect.Position, player1Rect.Size, float4(1f), 0); | ||||
| 			Uno.Drawing.RoundedRectangle.Draw(player2Rect.Position, player2Rect.Size, float4(1f), 0); | ||||
| 			Uno.Drawing.RoundedRectangle.Draw(ballRect.Position, ballRect.Size, float4(1f), 0f); | ||||
|         } | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										136
									
								
								samples/Uno/TowerBlock.uno
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										136
									
								
								samples/Uno/TowerBlock.uno
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,136 @@ | ||||
| using Uno; | ||||
| using Uno.Collections; | ||||
| using Uno.Graphics; | ||||
| using Uno.Scenes; | ||||
| using Uno.Content; | ||||
| using Uno.Content.Models; | ||||
| using Uno.Physics.Box2D; | ||||
|  | ||||
| using TowerBuilder.Box2DMath; | ||||
|  | ||||
| namespace TowerBuilder | ||||
| { | ||||
| 	public class TowerBlock : TestBed | ||||
| 	{ | ||||
| 		Body floorBody, deleteBody, mouseBody; | ||||
|  | ||||
| 		private List<Body> bodies = new List<Body>(); | ||||
| 		private List<Body> bodiesToDelete = new List<Body>(); | ||||
|  | ||||
| 		private ContactListener contactListener; | ||||
|  | ||||
| 		protected override void OnInitializeTestBed() | ||||
| 		{ | ||||
| 			World.Gravity = float2(0, -25.0f); | ||||
| 			World.ContactListener = contactListener = new ContactListener(this); | ||||
| 			 | ||||
| 			bodies.Clear(); | ||||
| 			bodiesToDelete.Clear(); | ||||
|  | ||||
| 			CreateFloor(); | ||||
| 			CreateDeleteBody(); | ||||
| 			CreateBox2(); | ||||
| 		} | ||||
|  | ||||
| 		void CreateFloor() | ||||
| 		{ | ||||
| 			var bodyDef = new BodyDef(); | ||||
| 			bodyDef.position = float2(0, -40.0f); | ||||
|  | ||||
| 			floorBody = World.CreateBody(bodyDef); | ||||
|  | ||||
| 			var shape = new PolygonShape(); | ||||
| 			shape.SetAsBox(30.0f, 10.0f); | ||||
|  | ||||
| 			var fixtureDef = new FixtureDef(); | ||||
| 			fixtureDef.shape = shape; | ||||
| 			fixtureDef.density = 1.0f; | ||||
|  | ||||
| 			floorBody.CreateFixture(fixtureDef); | ||||
| 		} | ||||
|  | ||||
| 		void CreateDeleteBody() | ||||
| 		{ | ||||
| 			var bodyDef = new BodyDef(); | ||||
| 			bodyDef.position = float2(0, -44.0f); | ||||
|  | ||||
| 			deleteBody = World.CreateBody(bodyDef); | ||||
|  | ||||
| 			var shape = new PolygonShape(); | ||||
| 			shape.SetAsBox(200.0f, 10.0f); | ||||
|  | ||||
| 			var fixtureDef = new FixtureDef(); | ||||
| 			fixtureDef.shape = shape; | ||||
| 			fixtureDef.density = 1.0f; | ||||
|  | ||||
| 			deleteBody.CreateFixture(fixtureDef); | ||||
| 		} | ||||
|  | ||||
| 		Random random = new Random((int) (Uno.Diagnostics.Clock.GetSeconds() * 1000000)); | ||||
| 		void CreateBox2() | ||||
| 		{ | ||||
| 			var bodyDef = new BodyDef(); | ||||
| 			bodyDef.type = BodyType.Dynamic; | ||||
| 			bodyDef.position = float2(random.NextFloat(-25f, 25f), 50.0f); | ||||
| 			bodyDef.angularVelocity = random.NextFloat() * 40 - 20; | ||||
| 			bodyDef.userData = float3(0, 0, 0); | ||||
|  | ||||
| 			var body = World.CreateBody(bodyDef); | ||||
|  | ||||
| 			var shape = new PolygonShape(); | ||||
| 			shape.SetAsBox(0.75f, 0.75f); | ||||
|  | ||||
| 			var fixtureDef = new FixtureDef(); | ||||
| 			fixtureDef.shape = shape; | ||||
| 			fixtureDef.density = 5.0f; | ||||
| 			//fixtureDef.friction = 0.75f; | ||||
|  | ||||
| 			body.CreateFixture(fixtureDef); | ||||
|  | ||||
| 			bodies.Add(body); | ||||
| 		} | ||||
| 		 | ||||
| 		private int c = 0; | ||||
| 		protected override void OnFixedUpdate() | ||||
| 		{ | ||||
| 			base.OnFixedUpdate(); | ||||
| 			 | ||||
| 			debug_log bodies.Count; | ||||
| 			if(c++ % 8 == 0 && bodies.Count < 20) CreateBox2(); | ||||
|  | ||||
| 			foreach(var body in bodiesToDelete) | ||||
| 			{ | ||||
| 				World.DestroyBody(body); | ||||
| 				bodies.Remove(body); | ||||
| 			} | ||||
|  | ||||
| 			bodiesToDelete.Clear(); | ||||
| 		} | ||||
|  | ||||
| 		public class ContactListener : IContactListener | ||||
| 		{ | ||||
| 			private TowerBlock b; | ||||
| 			public ContactListener(TowerBlock b) | ||||
| 			{ | ||||
| 				this.b = b; | ||||
| 			} | ||||
|  | ||||
| 			public void BeginContact(Contact contact) | ||||
| 			{ | ||||
| 				if(contact.GetFixtureA().GetBody() == b.deleteBody) | ||||
| 				{ | ||||
| 					b.bodiesToDelete.Add(contact.GetFixtureB().GetBody()); | ||||
| 				} | ||||
| 				else if(contact.GetFixtureB().GetBody() == b.deleteBody) | ||||
| 				{ | ||||
| 					b.bodiesToDelete.Add(contact.GetFixtureA().GetBody()); | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
|         	public void EndContact(Contact contact)  {} | ||||
| 			public void PreSolve(Contact contact, ref Manifold manifold) {} | ||||
| 			public void PostSolve(Contact contact, ref ContactImpulse impulse) {} | ||||
| 		} | ||||
|  | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										57
									
								
								samples/XML/MainView.ux
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										57
									
								
								samples/XML/MainView.ux
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,57 @@ | ||||
| <App Theme="Basic"> | ||||
| 	<DockPanel> | ||||
| 		<TopFrameBackground Dock="Top" /> | ||||
| 		<Panel> | ||||
| 			<Rectangle ux:Name="newLayoutMaster" Width="50" Height="50" Color="#8889" Alignment="TopLeft" Margin="20,50"/> | ||||
| 			<StackPanel Alignment="Top"> | ||||
| 				<TextInput PlaceholderText="Click me to show the keyboard" Alignment="Center"> | ||||
| 					<WhileKeyboardVisible> | ||||
| 						<Move Target="rect3" RelativeTo="Keyboard" Y="-1" Duration="0.5" /> | ||||
| 					</WhileKeyboardVisible> | ||||
| 				</TextInput> | ||||
| 				<Button Text="Click me" Alignment="Center"> | ||||
| 					<WhilePressed> | ||||
| 						<Move Target="rect1" RelativeTo="Size" Y="-1" Duration="0.5" /> | ||||
| 						<Move Target="rect2" RelativeTo="ParentSize" Y="-1" Duration="0.5" /> | ||||
| 						<Move Target="rect5" RelativeTo="Size" RelativeNode="relativeNode" Y="-1" Duration="0.5" /> | ||||
| 					</WhilePressed> | ||||
| 				</Button> | ||||
| 				<Switch> | ||||
| 					<WhileTrue> | ||||
| 						<Change rect4.LayoutMaster="newLayoutMaster" /> | ||||
| 					</WhileTrue> | ||||
| 				</Switch> | ||||
| 			</StackPanel> | ||||
| 			<Rectangle ux:Name="relativeNode" Height="400" Width="50" Color="#bbf" Alignment="BottomRight"> | ||||
| 				<VerticalText Alignment="Center" Width="200">relativeNode</VerticalText> | ||||
| 			</Rectangle> | ||||
|  | ||||
| 			<Text ux:Class="VerticalText" TransformOrigin="Center" Alignment="Bottom" TextColor="#000"> | ||||
| 				<Rotation Degrees="-90" /> | ||||
| 			</Text> | ||||
|  | ||||
| 			<Grid ColumnCount="5" Rows="3*,1*" Color="#ddd" Width="80%" Height="100%" Alignment="BottomLeft"> | ||||
| 				<VerticalText Width="200">RelativeTo="Size"</VerticalText> | ||||
| 				<VerticalText Width="200">RelativeTo="ParentSize"</VerticalText> | ||||
| 				<VerticalText Width="200">RelativeTo="Keyboard"</VerticalText> | ||||
| 				<VerticalText Width="200">RelativeTo="PositionChange"</VerticalText> | ||||
| 				<VerticalText Width="200">RelativeNode="relativeNode"</VerticalText> | ||||
|  | ||||
|  | ||||
|  | ||||
| 				<Rectangle ux:Name="rect1" Width="50" Height="50" Color="#f00" Alignment="Bottom"/> | ||||
| 				<Rectangle ux:Name="rect2" Width="50" Height="50" Color="#0f0" Alignment="Bottom"/> | ||||
| 				<Rectangle ux:Name="rect3" Width="50" Height="50" Color="#00f" Alignment="Bottom"/> | ||||
| 				<Panel Alignment="Bottom" Width="50" Height="50"> | ||||
| 					<Rectangle ux:Name="rect4" Width="50" Height="50" Color="#0ff" LayoutMaster="layoutMaster"> | ||||
| 						<LayoutAnimation> | ||||
| 							<Move RelativeTo="PositionChange" X="1" Y="1" Duration="0.5" /> | ||||
| 						</LayoutAnimation> | ||||
| 					</Rectangle> | ||||
| 					<Rectangle ux:Name="layoutMaster" Width="50" Height="50"/> | ||||
| 				</Panel> | ||||
| 				<Rectangle ux:Name="rect5" Width="50" Height="50" Color="#f0f" Alignment="Bottom"/> | ||||
| 			</Grid> | ||||
| 		</Panel> | ||||
| 	</DockPanel> | ||||
| </App> | ||||
							
								
								
									
										11
									
								
								samples/XML/MyApp.ux
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								samples/XML/MyApp.ux
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,11 @@ | ||||
| <App Theme="Basic"> | ||||
| 	<EdgeNavigator HitTestMode="LocalBoundsAndChildren"> | ||||
| 		<Panel Width="150" EdgeNavigation.Edge="Left" Background="#f63" /> | ||||
|  | ||||
| 		<Panel> | ||||
| 			<Text Alignment="Center"> | ||||
| 				This is an example of EdgeNavigator! | ||||
| 			</Text> | ||||
| 		</Panel> | ||||
| 	</EdgeNavigator> | ||||
| </App> | ||||
		Reference in New Issue
	
	Block a user