public CockpitFile(string filename) : base(filename) { string folderName = Path.GetDirectoryName(filename); if (filename.Contains("64x48")) { IsHighRes = true; } Forward = GetTextureFromPixFile(folderName, ReadLine()); ForwardRect = ReadLineAsRect(); Left = GetTextureFromPixFile(folderName, ReadLine()); LeftRect = ReadLineAsRect(); Right = GetTextureFromPixFile(folderName, ReadLine()); RightRect = ReadLineAsRect(); SkipLines(6); //internal & external speedo, tacho, gears int nbrHandFrames = ReadLineAsInt(); int center = nbrHandFrames / 2; for (int i = 0; i < nbrHandFrames; i++) { CockpitHandFrame frame = new CockpitHandFrame(); string[] frameParts = ReadLine().Split(','); frame.Position1 = new Vector2(int.Parse(frameParts[0]), int.Parse(frameParts[1])); frame.Position2 = new Vector2(int.Parse(frameParts[3]), int.Parse(frameParts[4])); frame.Texture1 = GetTextureFromPixFile(folderName, frameParts[2]); frame.Texture2 = GetTextureFromPixFile(folderName, frameParts[5]); if (i < center) { LeftHands.Insert(0, frame); } else if (i == center) { CenterHands = frame; } else { RightHands.Add(frame); } } SkipLines(2); //mirror CloseFile(); int w = 640; int h = 480; if (!IsHighRes) { w = 320; h = 200; } foreach (var x in LeftHands) { x.Position1 += new Vector2(-20, 0); x.Position2 += new Vector2(-20, 0); x.Position1 /= new Vector2(w, h); x.Position2 /= new Vector2(w, h); } foreach (var x in RightHands) { x.Position1 += new Vector2(-20, 0); x.Position2 += new Vector2(-20, 0); x.Position1 /= new Vector2(w, h); x.Position2 /= new Vector2(w, h); } CenterHands.Position1 += new Vector2(-20, 0); CenterHands.Position2 += new Vector2(-20, 0); CenterHands.Position1 /= new Vector2(w, h); CenterHands.Position2 /= new Vector2(w, h); }
public CockpitFile(string filename) : base(filename) { string folderName = Path.GetDirectoryName(filename); if (filename.Contains("64x48")) IsHighRes = true; Forward = GetTextureFromPixFile(folderName, ReadLine()); ForwardRect = ReadLineAsRect(); Left = GetTextureFromPixFile(folderName, ReadLine()); LeftRect = ReadLineAsRect(); Right = GetTextureFromPixFile(folderName, ReadLine()); RightRect = ReadLineAsRect(); SkipLines(6); //internal & external speedo, tacho, gears int nbrHandFrames = ReadLineAsInt(); int center = nbrHandFrames / 2; for (int i = 0; i < nbrHandFrames; i++) { CockpitHandFrame frame = new CockpitHandFrame(); string[] frameParts = ReadLine().Split(','); frame.Position1 = new Vector2(int.Parse(frameParts[0]), int.Parse(frameParts[1])); frame.Position2 = new Vector2(int.Parse(frameParts[3]), int.Parse(frameParts[4])); frame.Texture1 = GetTextureFromPixFile(folderName, frameParts[2]); frame.Texture2 = GetTextureFromPixFile(folderName, frameParts[5]); if (i < center) LeftHands.Insert(0, frame); else if (i == center) CenterHands = frame; else RightHands.Add(frame); } SkipLines(2); //mirror CloseFile(); int w = 640; int h = 480; if (!IsHighRes) { w = 320; h = 200; } foreach (var x in LeftHands) { x.Position1 += new Vector2(-20, 0); x.Position2 += new Vector2(-20, 0); x.Position1 /= new Vector2(w, h); x.Position2 /= new Vector2(w, h); } foreach (var x in RightHands) { x.Position1 += new Vector2(-20, 0); x.Position2 += new Vector2(-20, 0); x.Position1 /= new Vector2(w, h); x.Position2 /= new Vector2(w, h); } CenterHands.Position1 += new Vector2(-20, 0); CenterHands.Position2 += new Vector2(-20, 0); CenterHands.Position1 /= new Vector2(w, h); CenterHands.Position2 /= new Vector2(w, h); }