Ejemplo n.º 1
0
		public MapRenderer (Mpq mpq, Chk chk)
		{
			this.mpq = mpq;
			this.chk = chk;

			pixel_width = (ushort)(chk.Width * 32);
			pixel_height = (ushort)(chk.Height * 32);

			Stream cv5_fs = (Stream)mpq.GetResource (String.Format ("tileset\\{0}.cv5", Util.TilesetNames[(int)chk.Tileset]));
			cv5 = new byte [cv5_fs.Length];
			cv5_fs.Read (cv5, 0, (int)cv5_fs.Length);
			cv5_fs.Close ();

			Stream vx4_fs = (Stream)mpq.GetResource (String.Format ("tileset\\{0}.vx4", Util.TilesetNames[(int)chk.Tileset]));
			vx4 = new byte [vx4_fs.Length];
			vx4_fs.Read (vx4, 0, (int)vx4_fs.Length);
			vx4_fs.Close ();

			Stream vr4_fs = (Stream)mpq.GetResource (String.Format ("tileset\\{0}.vr4", Util.TilesetNames[(int)chk.Tileset]));
			vr4 = new byte [vr4_fs.Length];
			vr4_fs.Read (vr4, 0, (int)vr4_fs.Length);
			vr4_fs.Close ();

			Stream vf4_fs = (Stream)mpq.GetResource (String.Format ("tileset\\{0}.vf4", Util.TilesetNames[(int)chk.Tileset]));
			vf4 = new byte [vf4_fs.Length];
			vf4_fs.Read (vf4, 0, (int)vf4_fs.Length);
			vf4_fs.Close ();

			Stream wpe_fs = (Stream)mpq.GetResource (String.Format ("tileset\\{0}.wpe", Util.TilesetNames[(int)chk.Tileset]));
			wpe = new byte [wpe_fs.Length];
			wpe_fs.Read (wpe, 0, (int)wpe_fs.Length);
			wpe_fs.Close ();
			
			mapLayer = (CATiledLayer)CATiledLayer.Create ();
			mapLayer.TileSize = new SizeF (32, 32);
			mapLayer.Bounds = new RectangleF (0, 0, pixel_width, pixel_height);
			mapLayer.AnchorPoint = new PointF (0, 0);
			mapLayerDelegate = new MapLayerDelegate (this);
			mapLayer.Delegate = mapLayerDelegate;
			mapLayer.SetNeedsDisplay ();
		}
Ejemplo n.º 2
0
		public BriefingRunner (ReadyRoomScreen screen, Chk scenario,
				       string scenario_prefix)
		{
			this.screen = screen;
			this.scenario = scenario;
			this.prefix = scenario_prefix;
			triggerData = scenario.BriefingData;
		}
Ejemplo n.º 3
0
		public GameScreen (Mpq mpq,
				   string prefix,
				   Chk scenario) : base (mpq)
		{
			this.effectpal_path = "game\\tblink.pcx";
			this.arrowgrp_path = "cursor\\arrow.grp";
			this.fontpal_path = "game\\tfontgam.pcx";
			//this.scenario_mpq = scenario_mpq;
			this.scenario = scenario;
			ScrollCursors = new CursorAnimator[8];
		}
Ejemplo n.º 4
0
		public GameScreen (Mpq mpq,
				   Mpq scenario_mpq,
				   Chk scenario,
				   Got template) : base (mpq)
		{
			effectpal_path = "game\\tblink.pcx";
			arrowgrp_path = "cursor\\arrow.grp";
			fontpal_path = "game\\tfontgam.pcx";
			//this.scenario_mpq = scenario_mpq;
			this.scenario = scenario;
			this.template = template;
			ScrollCursors = new CursorAnimator[8];
		}
Ejemplo n.º 5
0
		public MapRenderer (Mpq mpq, Chk chk, int width, int height)
			: this (mpq, chk)
		{
			this.width = width;
			this.height = height;
		}
Ejemplo n.º 6
0
		// TODO: make this code use a paletted CGImage instead of doing the expansion ourselves (can CGImage do rgba paletted images?)
		public byte[] RenderToBitmap (Mpq mpq, Chk chk)
		{
			ushort[,] mapTiles = chk.MapTiles;

			byte[] image = new byte[pixel_width * pixel_height * 4];

			for (int map_y = 0; map_y < chk.Height; map_y++) {
				for (int map_x = 0; map_x < chk.Width; map_x ++) {
					int mapTile = mapTiles[map_x,map_y];

					//					bool odd = (mapTile & 0x10) == 0x10;

					int tile_group = mapTile >> 4; /* the tile's group in the cv5 file */
					int tile_number = mapTile & 0x0F;    /* the megatile within the tile group */

					int megatile_id = Util.ReadWord (cv5, (tile_group * 26 + 10 + tile_number) * 2);

					int minitile_x, minitile_y;

					for (minitile_y = 0; minitile_y < 4; minitile_y ++) {
						for (minitile_x = 0; minitile_x < 4; minitile_x ++) {
							ushort minitile_id = Util.ReadWord (vx4, megatile_id * 32 + minitile_y * 8 + minitile_x * 2);
							bool flipped = (minitile_id & 0x01) == 0x01;
							minitile_id >>= 1;

							int pixel_x, pixel_y;
							if (flipped) {
								for (pixel_y = 0; pixel_y < 8; pixel_y++)
									for (pixel_x = 0; pixel_x < 8; pixel_x ++) {
										int x = map_x * 32 + (minitile_x + 1) * 8 - pixel_x - 1;
										int y = (map_y * 32 + minitile_y * 8) * pixel_width + pixel_y * pixel_width;

										byte palette_entry = vr4[minitile_id * 64 + pixel_y * 8 + pixel_x];

										image[0 + 4 * (x + y)] = wpe[palette_entry * 4 + 2];
										image[1 + 4 * (x + y)] = wpe[palette_entry * 4 + 1];
										image[2 + 4 * (x + y)] = wpe[palette_entry * 4 + 0];
										image[3 + 4 * (x + y)] = (byte)(255 - wpe[palette_entry * 4 + 3]);
									}
							}
							else {
								for (pixel_y = 0; pixel_y < 8; pixel_y++) {
									for (pixel_x = 0; pixel_x < 8; pixel_x ++) {
										int x = map_x * 32 + minitile_x * 8 + pixel_x;
										int y = (map_y * 32 + minitile_y * 8) * pixel_width + pixel_y * pixel_width;

										byte palette_entry = vr4[minitile_id * 64 + pixel_y * 8 + pixel_x];

										image[0 + 4 * (x + y)] = wpe[palette_entry * 4 + 2];
										image[1 + 4 * (x + y)] = wpe[palette_entry * 4 + 1];
										image[2 + 4 * (x + y)] = wpe[palette_entry * 4 + 0];
										image[3 + 4 * (x + y)] = (byte)(255 - wpe[palette_entry * 4 + 3]);
									}
								}
							}
						}
					}
				}
			}

			return image;
		}
Ejemplo n.º 7
0
		void FileListSelectionChanged (int selectedIndex)
		{
			string map_path = Path.Combine (curdir, file_listbox.SelectedItem);

			if (selectedScenario !=null)
				selectedScenario.Dispose ();

			if (selectedIndex < directories.Length) {
				selectedScenario = null;
				selectedChk = null;
			}
			else {
				selectedScenario = new MpqArchive (map_path);

				selectedChk = (Chk)selectedScenario.GetResource ("staredit\\scenario.chk");
			}

			Elements[MAPTITLE_ELEMENT_INDEX].Text = selectedChk == null ? "" : selectedChk.Name;
			Elements[MAPDESCRIPTION_ELEMENT_INDEX].Text = selectedChk == null ? "" : selectedChk.Description;

			string mapSizeString = GlobalResources.Instance.GluAllTbl.Strings[MAPSIZE_FORMAT_INDEX];
			//			string mapDimString = GlobalResources.Instance.GluAllTbl.Strings[MAPDIM_FORMAT_INDEX];
			string tileSetString = GlobalResources.Instance.GluAllTbl.Strings[TILESET_FORMAT_INDEX];

			mapSizeString = mapSizeString.Replace ("%c", " "); /* should probably be a tab.. */
			mapSizeString = mapSizeString.Replace ("%s",
							       (selectedChk == null
								? ""
								: String.Format ("{0}x{1}",
										 selectedChk.Width,
										 selectedChk.Height)));

			tileSetString = tileSetString.Replace ("%c", " "); /* should probably be a tab.. */
			tileSetString = tileSetString.Replace ("%s",
							       (selectedChk == null
								? ""
								: String.Format ("{0}",
										 selectedChk.Tileset)));

			Elements[MAPSIZE_ELEMENT_INDEX].Text = mapSizeString;
			Elements[MAPTILESET_ELEMENT_INDEX].Text = tileSetString;

			UpdatePlayersDisplay ();
		}