Ejemplo n.º 1
0
		void TileRow (CALayer surf, Grp grp, byte[] pal, int l, int c, int r, int y)
		{
			CALayer l_layer = GuiUtil.CreateLayerFromBitmap (grp.GetFrame (l),
									 grp.Width, grp.Height,
									 pal,
									 41, 0);

			CALayer c_layer = GuiUtil.CreateLayerFromBitmap (grp.GetFrame (c),
									 grp.Width, grp.Height,
									 pal,
									 41, 0);


			CALayer r_layer = GuiUtil.CreateLayerFromBitmap (grp.GetFrame (r),
									 grp.Width, grp.Height,
									 pal,
									 41, 0);

#if notyet
			surf.Blit (lsurf, new Point (0,y));
			for (int x = grp.Width; x < surf.Width - grp.Width; x += grp.Width)
				surf.Blit (csurf, new Point (x, y));
			surf.Blit (rsurf, new Point (surf.Width - grp.Width,y));
#endif
		}
Ejemplo n.º 2
0
 public CALayer(CALayer other)
 {
     if (this.GetType () == typeof (CALayer)){
         Messaging.intptr_objc_msgSend_intptr (Handle, selInitWithLayer, other.Handle);
     } else {
         Messaging.intptr_objc_msgSendSuper_intptr (SuperHandle, selInitWithLayer, other.Handle);
         Clone (other);
     }
 }
Ejemplo n.º 3
0
		private CALayer SetupLayers()
		{
			backgroundLayer = SetupBackgroundLayer ();
			
			backgroundLayer.AddSublayer (SetupClockFaceLayer ());
			backgroundLayer.AddSublayer (SetupBorderLayer ());
			backgroundLayer.AddSublayer (SetupGlossyLayer ());

			return backgroundLayer;
		}
Ejemplo n.º 4
0
		protected UIDialog (UIScreen parent, Mpq mpq, string prefix, string binFile)
			: base (mpq, prefix, binFile)
		{
			this.parent = parent;
			background_translucent = 254;
			background_transparent = 0;
			
			dimScreen = true;
			
			dimLayer = CALayer.Create ();
			dimLayer.Bounds = parent.Bounds;
			dimLayer.AnchorPoint = new PointF (0, 0);
			dimLayer.BackgroundColor = new CGColor (0, 0, 0, .7f);
		}
Ejemplo n.º 5
0
		CALayer SetupBackgroundLayer() 
		{
			backgroundLayer = new CAGradientLayer ();
			
			CGColor gradColor1 = new CGColor (13.0f / 255.0f, 116.0f / 255.0f, 1.0f,1.0f);
			CGColor gradColor2 = new CGColor (0.0f, 53.0f / 255.0f, 126.0f / 255.0f,1.0f);
			
			((CAGradientLayer)backgroundLayer).Colors = new CGColor[2] { gradColor1, gradColor2 };
			backgroundLayer.CornerRadius = 12.0f;
			CAConstraintLayoutManager layout = CAConstraintLayoutManager.LayoutManager;
			backgroundLayer.LayoutManager = layout;
			
			return backgroundLayer;
		}
Ejemplo n.º 6
0
		protected override CALayer CreateLayer ()
		{
			layer = CALayer.Create ();
			layer.Bounds = new RectangleF (0, 0, Width, Height);
			layer.AnchorPoint = new PointF (0, 0);
			
			layer.Delegate = new MovieElementLayerDelegate (this);
			
			if (player == null)
				return layer;

			ScalePlayer ();
			
			if (dim != 0) {
				CreateDimLayer ();
				dimLayer.BackgroundColor = new CGColor (0, (float)dim / 255);
				layer.AddSublayer (dimLayer);
			}				
			
			return layer;
		}
Ejemplo n.º 7
0
 public override void AwakeFromNib ()
 {
         Layer = new CALayer ();
         Layer.AddSublayer (MovingLayer);
         WantsLayer = true;
 }
Ejemplo n.º 8
0
 public RectangleF ConvertRectfromLayer(RectangleF rect, CALayer layer)
 {
     return(ConvertRectFromLayer(rect, layer));
 }
Ejemplo n.º 9
0
		public override void Clone (CALayer other)
		{
			ClockColor = ((ClockLayer) other).ClockColor;
			base.Clone (other);
		}
		public override void AwakeFromNib ()
		{
			// center our fire horizontally on the view and 15px from the bottom
			var firePosition = new PointF (view.Bounds.Width / 2, 15);

			rootLayer = new CALayer {
				BackgroundColor = new CGColor (0, 0, 0)
			};

			fireEmitter = new CAEmitterLayer {
				Position = firePosition,
				Mode = CAEmitterLayer.ModeOutline,
				Shape = CAEmitterLayer.ShapeLine,
				RenderMode = CAEmitterLayer.RenderAdditive,
				Size = SizeF.Empty,
				Cells = new [] {
					new CAEmitterCell {
						Name = "fire", // name the cell so that it can be animated later using keypaths
						EmissionLongitude = (float)Math.PI,
						BirthRate = 0,
						Velocity = 80,
						VelocityRange = 30,
						EmissionRange = 1.1f,
						AccelerationY = 200,
						ScaleSpeed = 0.3f,
						Color = new CGColor (0.8f, 0.4f, 0.2f, 0.10f),
						Contents = NSImage.ImageNamed ("fire.png").CGImage
					}
				}
			};

			smokeEmitter = new CAEmitterLayer {
				Position = firePosition,
				Mode = CAEmitterLayer.ModePoints,
				Cells = new [] {
					new CAEmitterCell {
						Name = "smoke", // name the cell so that it can be animated later using keypaths
						BirthRate = 11,
						EmissionLongitude = (float)Math.PI / 2,
						LifeTime = 0,
						Velocity = 40,
						VelocityRange = 20,
						EmissionRange = (float)Math.PI / 4,
						Spin = 1,
						SpinRange = 6,
						AccelerationY = 160,
						Scale = 0.1f,
						AlphaSpeed = -0.12f,
						ScaleSpeed = 0.7f,
						Contents = NSImage.ImageNamed ("smoke.png").CGImage
					}
				}
			};

			rootLayer.AddSublayer (smokeEmitter);
			rootLayer.AddSublayer (fireEmitter);

			view.Layer = rootLayer;
			view.WantsLayer = true;

			// Set the fire simulation to reflect the intial slider postion
			slidersChanged (this);

			// Force the view to update
			view.NeedsDisplay = true;
		}
Ejemplo n.º 11
0
		public override void DrawLayer (CALayer layer, CGContext context)
		{
			if (el.Items != null) {
				int y = el.Bounds.Height - el.Font.LineSize;
				for (int i = el.FirstVisible; i < el.FirstVisible + el.NumVisible; i ++) {
					if (i >= el.Items.Count)
						return;
					GuiUtil.RenderTextToContext (context, new PointF (0, y),
												el.Items[i], el.Font, el.Palette, 4);
#if notyet
												(!el.Selectable ||
									     		(!el.Selecting && el.SelectedIndex == i) ||
									     		(el.Selecting && el.SelectionIndex == i)) ? 4 : 24);
#endif
					y -= el.Font.LineSize;
				}
			}
		}
Ejemplo n.º 12
0
		CALayer SetupGlossyLayer()
		{
			// Create the CGImage by proxying it through an NSImage
			string filePath = NSBundle.MainBundle.PathForResource("clock-gloss","png");
			RectangleF rect = RectangleF.Empty;
			var glossyImage = new NSImage (filePath).AsCGImage (ref rect, null, null);

			CALayer glossLayer = new CALayer() {
				Opacity = 0.8f,
				CornerRadius = 12,
				MasksToBounds = true,
				Frame = this.Frame,
				Contents = glossyImage
			};
			return glossLayer;
		}
Ejemplo n.º 13
0
			public MarkupPage (Stream background)
			{
				newBackground = GuiUtil.LayerFromStream (background, 254, 0);
				newBackground.AnchorPoint = new PointF (0, 0);
				newBackground.Position = new PointF (0, 0);
			}
Ejemplo n.º 14
0
			public void CreateLineLayers ()
			{
				lineContainer = CALayer.Create ();
				lineContainer.AnchorPoint = new PointF (0, 0);
				lineContainer.Bounds = new RectangleF (0, 0, 640, 480);
				
				lineLayers = new List<CALayer> ();
				foreach (string l in lines) {
					CALayer layer;
					if (l.Trim() == "")
						layer = null;
					else
						layer = GuiUtil.ComposeText (l, fnt, pal, 640/*Painter.SCREEN_RES_X*/ - X_OFFSET * 2, -1, 4);
					lineLayers.Add (layer);
					if (layer != null)
						lineContainer.AddSublayer (layer);
				}
			}
Ejemplo n.º 15
0
		void AdvanceToNextPage ()
		{
			if (currentLines != null)
				currentLines.RemoveFromSuperLayer ();
			while (pageEnumerator.MoveNext ()) {
				if (pageEnumerator.Current.Background != null) {
					if (currentBackground != null)
						currentBackground.RemoveFromSuperLayer ();
					currentBackground = pageEnumerator.Current.Background;
					AddSublayer (currentBackground);
				}
				if (pageEnumerator.Current.HasText) {
					currentLines = pageEnumerator.Current.Lines;
					AddSublayer (currentLines);
					return;
				}
			}

            Game.Instance.Tick -= FlipPage;
			MarkupFinished ();
		}
Ejemplo n.º 16
0
		public override void DrawLayer (CALayer layer, CGContext context)
		{
			GuiUtil.RenderTextToContext (context, new PointF (0, el.Height / 2), el.Text, el.Font, el.Palette, el.Sensitive ? 4 : 24);
		}
Ejemplo n.º 17
0
		public override void DrawLayer (CALayer layer, CGContext context)
		{
			if (el.Player.CurrentFrame != null)
				context.DrawImage (new RectangleF ( 0, el.Height - el.Player.CurrentFrame.Height * el.playerZoom, el.Player.CurrentFrame.Width, el.Player.CurrentFrame.Height), el.Player.CurrentFrame);
		}
Ejemplo n.º 18
0
 public virtual void Clone(CALayer other)
 {
     // Subclasses must copy any instance values that they care from other
 }
Ejemplo n.º 19
0
		public override void DrawLayer (CALayer layer, CGContext context)
		{
			int y = 0;
			for (int i = el.Items.Count - 1; i >=0 ; i --) {
				GuiUtil.RenderTextToContext (context, new PointF (0, y), el.Items[i], el.Font, el.Palette,
											 i == el.DropdownHoverIndex ? 4 : 24);
				
				y += (int)el.Font.LineSize;
			}
			
		}
Ejemplo n.º 20
0
 RectangleF ConvertRectfromLayer(RectangleF rect, CALayer layer)
 {
     return ConvertRectFromLayer (rect, layer);
 }
Ejemplo n.º 21
0
 public virtual void Clone(CALayer other)
 {
     // Subclasses must copy any instance values that they care from other
 }
Ejemplo n.º 22
0
			public override void DrawLayer (CALayer layer, CGContext context)
			{
				RectangleF box = context.GetClipBoundingBox ();
				int tile_x = (int)(box.X / 32);
				int tile_y = (int)((renderer.pixel_height - box.Y) / 32);
				
				try {
					ushort[,] mapTiles = renderer.Chk.MapTiles;
				
					CGImage image = renderer.GetTile (mapTiles[tile_x, tile_y]);
					context.DrawImage (box, image);
				}
				catch (Exception e) {
					Console.WriteLine (e);
				}
			}
Ejemplo n.º 23
0
		protected virtual void ResourceLoader ()
		{
			Stream s;

			fontpal = null;
			effectpal = null;

			if (fontpal_path != null) {
				Console.WriteLine ("loading font palette");
				s = (Stream)mpq.GetResource (fontpal_path);
				if (s != null) {
					fontpal = new Pcx ();
					fontpal.ReadFromStream (s, -1, -1);
				}
			}
			if (effectpal_path != null) {
				Console.WriteLine ("loading cursor palette");
				s = (Stream)mpq.GetResource (effectpal_path);
				if (s != null) {
					effectpal = new Pcx ();
					effectpal.ReadFromStream (s, -1, -1);
				}
				if (effectpal != null && arrowgrp_path != null) {
					Console.WriteLine ("loading arrow cursor");
					Grp arrowgrp = (Grp)mpq.GetResource (arrowgrp_path);
					if (arrowgrp != null) {
						Cursor = new CursorAnimator (arrowgrp, effectpal.Palette);
						Cursor.SetHotSpot (64, 64);
					}
				}
			}

			if (background_path != null) {
				Console.WriteLine ("loading background");
					background = GuiUtil.LayerFromStream ((Stream)mpq.GetResource (background_path),
														  background_translucent, background_transparent);
				
				background.AnchorPoint = new PointF (0, 0);
				AddSublayer (background);
				// FIXME: we should center the background (and scale it?)
			}

			Elements = new List<UIElement> ();
			if (binFile != null) {
				Console.WriteLine ("loading ui elements");
				Bin = (Bin)mpq.GetResource (binFile);

				if (Bin == null)
					throw new Exception (String.Format ("specified file '{0}' does not exist",
									    binFile));

				/* convert all the BinElements to UIElements for our subclasses to use */
				foreach (BinElement el in Bin.Elements) {
					//					Console.WriteLine ("{0}: {1}", el.text, el.flags);

					UIElement ui_el = null;
					switch (el.type) {
					case ElementType.DialogBox:
						ui_el = new DialogBoxElement (this, el, fontpal.RGBData);
						break;
					case ElementType.Image:
						ui_el = new ImageElement (this, el, fontpal.RGBData, translucentIndex);
						break;
					case ElementType.TextBox:
						ui_el = new TextBoxElement (this, el, fontpal.RGBData);
						break;
					case ElementType.ListBox:
						ui_el = new ListBoxElement (this, el, fontpal.RGBData);
						break;
					case ElementType.ComboBox:
						ui_el = new ComboBoxElement (this, el, fontpal.RGBData);
						break;
					case ElementType.LabelLeftAlign:
					case ElementType.LabelCenterAlign:
					case ElementType.LabelRightAlign:
						ui_el = new LabelElement (this, el, fontpal.RGBData);
						break;
					case ElementType.Button:
					case ElementType.DefaultButton:
					case ElementType.ButtonWithoutBorder:
						ui_el = new ButtonElement(this, el, fontpal.RGBData);
						break;
					case ElementType.Slider:
					case ElementType.OptionButton:
					case ElementType.CheckBox:
						ui_el = new UIElement (this, el, fontpal.RGBData);
						break;
					default:
						Console.WriteLine ("unhandled case {0}", el.type);
						ui_el = new UIElement (this, el, fontpal.RGBData);
						break;
					}

					Elements.Add (ui_el);	
				}
			}
		}
Ejemplo n.º 24
0
		void CreateDropdownLayer ()
		{
			dropdownLayer = CALayer.Create ();
			dropdownLayer.Bounds = new RectangleF (0, 0, Width, items.Count * Font.LineSize);
			
			dropdownLayer.Delegate = new ComboBoxElementDropdownLayerDelegate (this);
			
			dropdownLayer.BackgroundColor = new CGColor (0, 0, 0, 1);
			dropdownLayer.BorderWidth = 1;
			dropdownLayer.BorderColor = new CGColor (1,1,0, 1);
			dropdownLayer.SetNeedsDisplay ();
			ParentScreen.AddSublayer (dropdownLayer);
		}
		public override void AwakeFromNib ()
		{
			// Create the root layer
			rootLayer = new CALayer ();

			// Set the root layer;s background color to black
			rootLayer.BackgroundColor = new CGColor (0,0,0);

			// Create the fire emitter layer
			fireEmitter = new CAEmitterLayer ();
			fireEmitter.Position = new System.Drawing.PointF (225,50);
			fireEmitter.Mode = CAEmitterLayer.ModeOutline;
			fireEmitter.Shape = CAEmitterLayer.ShapeLine;
			fireEmitter.RenderMode = CAEmitterLayer.RenderAdditive;
			fireEmitter.Size = new SizeF (0,0);

			// Create the smoke emitter layer
			smokeEmitter = new CAEmitterLayer ();
			smokeEmitter.Position = new PointF (225,50);
			smokeEmitter.Mode = CAEmitterLayer.ModePoints;

			// Create the fire emitter cell
			CAEmitterCell fire = CAEmitterCell.EmitterCell ();
			fire.EmissionLongitude = (float)Math.PI;
			fire.BirthRate = 0;
			fire.Velocity = 80;
			fire.VelocityRange = 30;
			fire.EmissionRange = 1.1f;
			fire.AccelerationY = 200;
			fire.ScaleSpeed = 0.3f;

			RectangleF rect = RectangleF.Empty;
			CGColor color = new CGColor (0.8f,0.4f,0.2f,0.10f);
			fire.Color = color;
			fire.Contents = NSImage.ImageNamed ("fire.png").AsCGImage (ref rect, null, null);

			// Name the cell so that it can be animated later using keypaths
			fire.Name = "fire";

			// Add the fire emitter cell to the fire emitter layer
			fireEmitter.Cells = new CAEmitterCell[] { fire };

			//Create the smoke emitter cell
			CAEmitterCell smoke = CAEmitterCell.EmitterCell ();
			smoke.BirthRate = 11;
			smoke.EmissionLongitude = (float)Math.PI / 2;
			smoke.LifeTime = 0;
			smoke.Velocity = 40;
			smoke.VelocityRange = 20;
			smoke.EmissionRange = (float)Math.PI / 4;
			smoke.Spin = 1;
			smoke.SpinRange = 6;
			smoke.AccelerationY = 160;
			smoke.Scale = 0.1f;
			smoke.AlphaSpeed = -0.12f;
			smoke.ScaleSpeed = 0.7f;
			smoke.Contents = NSImage.ImageNamed ("smoke.png").AsCGImage (ref rect, null, null);
			//Name the cell so that it can be animated later using keypaths
			smoke.Name = "smoke";

			// Add the smoke emitter cell to the smoke emitter layer
			smokeEmitter.Cells = new CAEmitterCell[] { smoke };

			// Add the two emitter layers to the root layer
			rootLayer.AddSublayer (smokeEmitter);
			rootLayer.AddSublayer (fireEmitter);

			// Set the view's layer to the base layer
			view.Layer = rootLayer;
			view.WantsLayer = true;

			// Set the fire simulation to reflect the intial slider postion
			slidersChanged (this);

			// Force the view to update
			view.NeedsDisplay = true;

		}
Ejemplo n.º 26
0
		public override void DrawLayer (CALayer layer, CGContext context)
		{
			/* XXX draw the arrow (and border) */

			if (el.SelectedIndex != -1) {
				GuiUtil.RenderTextToContext (context, new PointF (0, 0), el.SelectedItem, el.Font, el.Palette, 4);
			}
			
		}
Ejemplo n.º 27
0
		public override void DrawLayer (CALayer layer, CGContext context)
		{
			GuiUtil.RenderTextToContext (context, el.TextPosition, el.Text, el.Font, el.Palette, el.Sensitive ? 4 : 24);
		}
Ejemplo n.º 28
0
		public ClockLayer (CALayer other)
			: base (other)
		{
		}
Ejemplo n.º 29
0
 public CGRect ConvertRectfromLayer(CGRect rect, CALayer layer)
 {
     return(ConvertRectFromLayer(rect, layer));
 }