Пример #1
0
		public GrpElement (UIScreen screen, Grp grp, byte[] palette, ushort x, ushort y)
			: base (screen, x, y, grp.Width, grp.Height)
		{
			this.Palette = palette;
			this.grp = grp;
			this.frame = 0;
		}
Пример #2
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
		}
Пример #3
0
		public CursorAnimator (Grp grp, byte[] palette)
		{
			this.grp = grp;
			this.x = 100;
			this.y = 100;
			this.palette = palette;
			frames = new CGImage[grp.FrameCount];
			
			Bounds = new RectangleF (100, 100, grp.Width, grp.Height);
			AnchorPoint = new PointF (0, 0);
			SetNeedsDisplay ();			
		}
Пример #4
0
	public static void Main (string[] args) {
		string filename = args[0];
		string palettename = args[1];

		Console.WriteLine ("grp file {0}", filename);
		Console.WriteLine ("palette file {0}", palettename);

		FileStream fs = File.OpenRead (filename);

		Grp grp = new Grp ();

		((MpqResource)grp).ReadFromStream (fs);
		Pcx pal = new Pcx ();
		pal.ReadFromStream (File.OpenRead(palettename), -1, -1);

		for (int i = 0; i < grp.FrameCount; i ++) {
			BMP.WriteBMP (String.Format ("output{0:0000}.bmp", i),
				      grp.GetFrame (i),
				      grp.Width, grp.Height,
				      pal.Palette);
		}
	}
Пример #5
0
		public Sprite (Mpq mpq, int sprite_entry, byte[] palette, int x, int y)
		{
			this.mpq = mpq;
			this.palette = palette;

			images_entry = GlobalResources.Instance.SpritesDat.ImagesDatEntries [sprite_entry];
			//			Console.WriteLine ("image_dat_entry == {0}", images_entry);

			uint grp_index = GlobalResources.Instance.ImagesDat.GrpIndexes [images_entry];
			//			Console.WriteLine ("grp_index = {0}", grp_index);
			grp_path = GlobalResources.Instance.ImagesTbl[(int)grp_index-1];
			//			Console.WriteLine ("grp_path = {0}", grp_path);

			grp = (Grp)mpq.GetResource ("unit\\" + grp_path);

			iscript_entry = GlobalResources.Instance.ImagesDat.IScriptIndexes [images_entry];
			script_entry_offset = GlobalResources.Instance.IScriptBin.GetScriptEntryOffset (iscript_entry);

			Console.WriteLine ("new sprite: unit\\{0} @ {1}x{2} (image {3}, iscript id {4}, script_entry_offset {5:X})",
					   grp_path, x, y, images_entry, iscript_entry, script_entry_offset);

			this.buf = GlobalResources.Instance.IScriptBin.Contents;

			/* make sure the offset points to "SCPE" */
			if (Util.ReadDWord (buf, script_entry_offset) != 0x45504353)
				Console.WriteLine ("invalid script_entry_offset");

			SetPosition (x,y);
		}
Пример #6
0
		public Sprite (Sprite parentSprite, ushort images_entry, byte[] palette)
		{
			this.parent_sprite = parentSprite;
			this.mpq = parentSprite.mpq;
			this.palette = palette;
			this.images_entry = images_entry;

			uint grp_index = GlobalResources.Instance.ImagesDat.GrpIndexes [images_entry];

			grp_path = GlobalResources.Instance.ImagesTbl[(int)grp_index-1];

			grp = (Grp)mpq.GetResource ("unit\\" + grp_path);

			this.buf = GlobalResources.Instance.IScriptBin.Contents;
			iscript_entry = GlobalResources.Instance.ImagesDat.IScriptIndexes [images_entry];

			script_entry_offset = GlobalResources.Instance.IScriptBin.GetScriptEntryOffset (iscript_entry);

			Console.WriteLine ("new dependent sprite: unit\\{0} (image {1}, iscript id {2}, script_entry_offset {3:X})",
					   grp_path, images_entry, iscript_entry, script_entry_offset);

			/* make sure the offset points to "SCEP" */
			if (Util.ReadDWord (buf, script_entry_offset) != 0x45504353)
				Console.WriteLine ("invalid script_entry_offset");

			int x, y;
			parentSprite.GetPosition (out x, out y);
			SetPosition (x,y);
		}
Пример #7
0
	public static void Main (string[] args) {
		Application.Init();

		string filename = args[0];

		Console.WriteLine ("grp file {0}", filename);

		FileStream fs = File.OpenRead (filename);

		grp = new Grp ();

		((MpqResource)grp).ReadFromStream (fs);

		CreateWindow ();
		drawing_area.ExposeEvent += OnExposed;

		GLib.Timeout.Add (100, Animate);

		Application.Run ();
	}
Пример #8
0
		public GrpButtonElement (UIScreen screen, Grp grp, byte[] palette, ushort x, ushort y)
			: base (screen, grp, palette, x, y)
		{
		}
Пример #9
0
		protected override void ResourceLoader ()
		{
			base.ResourceLoader ();

			/* create the element corresponding to the hud */
			hudElement = new ImageElement (this, 0, 0, 640, 480, TranslucentIndex);
			hudElement.Palette = fontpal.RGBData;
			hudElement.Text = String.Format (Builtins.Game_ConsolePcx, Util.RaceCharLower[(int)Game.Instance.Race]);
			hudElement.Visible = true;
			Elements.Add (hudElement);

			/* create the portrait playing area */
			portraitElement = new MovieElement (this, 415, 415, 48, 48, false);
			portraitElement.Visible = true;
			Elements.Add (portraitElement);
			
			Pcx pcx = new Pcx ();
			pcx.ReadFromStream ((Stream)mpq.GetResource ("game\\tunit.pcx"), -1, -1);
			//unit_palette = pcx.Palette;

			pcx = new Pcx ();
			pcx.ReadFromStream ((Stream)mpq.GetResource ("tileset\\badlands\\dark.pcx"), 0, 0);
			tileset_palette = pcx.Palette;

#if notyet
			if (scenario.Tileset == Tileset.Platform) {
				Spk starfield = (Spk)mpq.GetResource ("parallax\\star.spk");

				starfield_layers = new Surface [starfield.Layers.Length];
				for (int i = 0; i < starfield_layers.Length; i ++) {
					starfield_layers[i] = new Surface (Painter.SCREEN_RES_X, Painter.SCREEN_RES_Y);

					starfield_layers[i].TransparentColor = Color.Black;

					for (int o = 0; o < starfield.Layers[i].Objects.Length; o ++) {
						ParallaxObject obj = starfield.Layers[i].Objects[o];

						starfield_layers[i].Fill (new Rectangle (new Point (obj.X, obj.Y), new Size (2,2)),
									  Color.White);
					}
				}
			}
#endif

			mapRenderer = new MapRenderer (mpq, scenario, 640/*Painter.SCREEN_RES_X*/, 480/*Painter.SCREEN_RES_Y*/);
			mapRenderer.MapLayer.AnchorPoint = new PointF (0, 0);
			
#if notyet
			// load the cursors we'll show when scrolling with the mouse
			string[] cursornames = new string[] {
				"cursor\\ScrollUL.grp",
				"cursor\\ScrollU.grp",
				"cursor\\ScrollUR.grp",
				"cursor\\ScrollR.grp",
				"cursor\\ScrollDR.grp",
				"cursor\\ScrollD.grp",
				"cursor\\ScrollDL.grp",
				"cursor\\ScrollL.grp",
			};
			ScrollCursors = new CursorAnimator [cursornames.Length];
			for (int i = 0; i < cursornames.Length; i ++) {
				ScrollCursors[i] = new CursorAnimator ((Grp)mpq.GetResource (cursornames[i]),
								       effectpal.Palette);
				ScrollCursors[i].SetHotSpot (60, 60);
			}

			// load the mag cursors
			string[] magcursornames = new string[] {
				"cursor\\MagG.grp",
				"cursor\\MagY.grp",
				"cursor\\MagR.grp"
			};
			MagCursors = new CursorAnimator [magcursornames.Length];
			for (int i = 0; i < magcursornames.Length; i ++) {
				MagCursors[i] = new CursorAnimator ((Grp)mpq.GetResource (magcursornames[i]),
								    effectpal.Palette);
				MagCursors[i].SetHotSpot (60, 60);
			}

			// load the targeting cursors
			string[] targetcursornames = new string[] {
				"cursor\\TargG.grp",
				"cursor\\TargY.grp",
				"cursor\\TargR.grp"
			};
			TargetCursors = new CursorAnimator [targetcursornames.Length];
			for (int i = 0; i < targetcursornames.Length; i ++) {
				TargetCursors[i] = new CursorAnimator ((Grp)mpq.GetResource (targetcursornames[i]),
								       effectpal.Palette);
				TargetCursors[i].SetHotSpot (60, 60);
			}
#endif
			/* the following could be made global to speed up the entry to the game screen.. */
			statTxt = (Tbl)mpq.GetResource ("rez\\stat_txt.tbl");

			// load the wireframe image info
			wireframe = (Grp)mpq.GetResource ("unit\\wirefram\\wirefram.grp");

			// load the command icons
			cmdicons = (Grp)mpq.GetResource ("unit\\cmdbtns\\cmdicons.grp");
			pcx = new Pcx ();
			pcx.ReadFromStream ((Stream)mpq.GetResource ("unit\\cmdbtns\\ticon.pcx"), 0, 0);
			cmdicon_palette = pcx.Palette;

			// create the wireframe display element
			wireframeElement = new GrpElement (this, wireframe, cmdicon_palette, 170, 390);
			wireframeElement.Visible = false;
			Elements.Add (wireframeElement);

			labelElements = new LabelElement [(int)HudLabels.Count];

			labelElements[(int)HudLabels.UnitName] = new LabelElement (this, fontpal.Palette,
										   GuiUtil.GetFonts (Mpq)[1],
										   254, 390);
			labelElements[(int)HudLabels.ResourceUsed] = new LabelElement (this, fontpal.Palette,
										       GuiUtil.GetFonts (Mpq)[0],
										       292, 420);
			labelElements[(int)HudLabels.ResourceProvided] = new LabelElement (this, fontpal.Palette,
											   GuiUtil.GetFonts (Mpq)[0],
											   292, 434);
			labelElements[(int)HudLabels.ResourceTotal] = new LabelElement (this, fontpal.Palette,
											GuiUtil.GetFonts (Mpq)[0],
											292, 448);
			labelElements[(int)HudLabels.ResourceMax] = new LabelElement (this, fontpal.Palette,
										      GuiUtil.GetFonts (Mpq)[0],
										      292, 462);

			for (int i = 0; i < labelElements.Length; i ++)
				Elements.Add (labelElements[i]);

			cmdButtonElements = new GrpButtonElement[9];
			int x = 0;
			int y = 0;
			for (int i = 0; i < cmdButtonElements.Length; i ++) {
				cmdButtonElements[i] = new GrpButtonElement (this, cmdicons, cmdicon_palette, button_xs[x], button_ys[y]);
				x++;
				if (x == 3) {
					x = 0;
					y++;
				}
				cmdButtonElements[i].Visible = false;
				Elements.Add (cmdButtonElements[i]);
			}

			PlaceInitialUnits ();
		}