public override void FinishedLaunching (NSObject notification) { mainWindowController = new MainWindowController (); mainWindowController.Window.MakeKeyAndOrderFront (this); string sc_dir = "/Users/toshok/src/scsharp/starcraft-data/starcraft"; string bw_cd_dir = "/Users/toshok/src/scsharp/starcraft-data/bw-cd"; string sc_cd_dir = "/Users/toshok/src/scsharp/starcraft-data/sc-cd"; //string sc_cd_dir = ConfigurationManager.AppSettings["StarcraftCDDirectory"]; //string bw_cd_dir = ConfigurationManager.AppSettings["BroodwarCDDirectory"]; /* catch this pathological condition where someone has set the cd directories to the same location. */ if (sc_cd_dir != null && bw_cd_dir != null && bw_cd_dir == sc_cd_dir) { Console.WriteLine ("The StarcraftCDDirectory and BroodwarCDDirectory configuration settings must have unique values."); return; } game = new Game (sc_dir /*ConfigurationManager.AppSettings["StarcraftDirectory"]*/, sc_cd_dir, bw_cd_dir); mainWindowController.Window.ContentView = game; mainWindowController.Window.MakeFirstResponder (game); game.Startup(); }
public Game (string starcraftDir, string scCDDir, string bwCDDir) { instance = this; Layer = CALayer.Create(); Layer.BackgroundColor = new CGColor (0, 0, 0, 1); #if USE_TRACKING_RECTS AddTrackingRect (new Rectangle (0, 0, 640, 480), this, IntPtr.Zero, false); #endif WantsLayer = true; starcraftDir = starcraftDir.Replace ('\\', Path.DirectorySeparatorChar) .Replace ('/', Path.DirectorySeparatorChar); scCDDir = scCDDir.Replace ('\\', Path.DirectorySeparatorChar) .Replace ('/', Path.DirectorySeparatorChar); bwCDDir = bwCDDir.Replace ('\\', Path.DirectorySeparatorChar) .Replace ('/', Path.DirectorySeparatorChar); screens = new UIScreen[(int)UIScreenType.ScreenCount]; installedMpq = new MpqContainer (); playingMpq = new MpqContainer (); Mpq scMpq = null, bwMpq = null; if (starcraftDir != null) { foreach (string path in Directory.GetFileSystemEntries (starcraftDir)) { if (Path.GetFileName (path).ToLower() == "broodat.mpq" || Path.GetFileName (path).Equals ("Brood War Data")) { if (broodatMpq != null) throw new Exception ("You have multiple broodat.mpq files in your starcraft directory."); try { bwMpq = GetMpq (path); Console.WriteLine ("found BrooDat.mpq"); } catch (Exception e) { throw new Exception (String.Format ("Could not read mpq archive {0}", path), e); } } else if (Path.GetFileName (path).ToLower() == "stardat.mpq" || Path.GetFileName (path).Equals ("Starcraft Data")) { if (stardatMpq != null) throw new Exception ("You have multiple stardat.mpq files in your starcraft directory."); try { scMpq = GetMpq (path); Console.WriteLine ("found StarDat.mpq"); } catch (Exception e) { throw new Exception (String.Format ("could not read mpq archive {0}", path), e); } } else if (Path.GetFileName (path).ToLower() == "patch_rt.mpq" || Path.GetFileName (path).Equals ("Starcraft Mac Patch")) { if (patchRtMpq != null) throw new Exception ("You have multiple patch_rt.mpq files in your starcraft directory."); try { patchRtMpq = GetMpq (path); Console.WriteLine ("found patch_rt.mpq"); } catch (Exception e) { throw new Exception (String.Format ("could not read mpq archive {0}", path), e); } } else if (Path.GetFileName (path).ToLower() == "starcraft.mpq") { try { scInstallExe = GetMpq (path); Console.WriteLine ("found starcraft.mpq"); } catch (Exception e) { throw new Exception (String.Format ("could not read mpq archive {0}", path), e); } } else if (Path.GetFileName (path).ToLower() == "broodwar.mpq") { try { bwInstallExe = GetMpq (path); Console.WriteLine ("found broodwar.mpq"); } catch (Exception e) { throw new Exception (String.Format ("could not read mpq archive {0}", path), e); } } } } if (scMpq == null) { throw new Exception ("unable to locate stardat.mpq, please check your StarcraftDirectory configuration setting"); } if (!string.IsNullOrEmpty (scCDDir)) { foreach (string path in Directory.GetFileSystemEntries (scCDDir)) { if (Path.GetFileName (path).ToLower() == "install.exe" || Path.GetFileName (path).Equals ("Starcraft Archive")) { try { scInstallExe = GetMpq (path); Console.WriteLine ("found SC install.exe"); } catch (Exception e) { throw new Exception (String.Format ("could not read mpq archive {0}", path), e); } } } } if (!string.IsNullOrEmpty (bwCDDir)) { foreach (string path in Directory.GetFileSystemEntries (bwCDDir)) { if (Path.GetFileName (path).ToLower() == "install.exe" || Path.GetFileName (path).Equals ("Brood War Archive")) { try { bwInstallExe = GetMpq (path); Console.WriteLine ("found BW install.exe"); } catch (Exception e) { throw new Exception (String.Format ("could not read mpq archive {0}", path), e); } } } } if (bwInstallExe == null) throw new Exception ("unable to locate broodwar cd's install.exe, please check your BroodwarCDDirectory configuration setting"); if (bwMpq != null) { if (patchRtMpq != null) { broodatMpq = new MpqContainer (); ((MpqContainer)broodatMpq).Add (patchRtMpq); ((MpqContainer)broodatMpq).Add (bwMpq); } else broodatMpq = bwMpq; } if (scMpq != null) { if (patchRtMpq != null) { stardatMpq = new MpqContainer (); ((MpqContainer)stardatMpq).Add (patchRtMpq); ((MpqContainer)stardatMpq).Add (scMpq); } else stardatMpq = bwMpq; } if (broodatMpq != null) installedMpq.Add (broodatMpq); if (bwInstallExe != null) installedMpq.Add (bwInstallExe); if (stardatMpq != null) installedMpq.Add (stardatMpq); if (scInstallExe != null) installedMpq.Add (scInstallExe); PlayingBroodWar = isBroodWar = (broodatMpq != null); this.rootDir = starcraftDir; }