Exemple #1
0
		private TopView()
		{
			//LogFile.Instance.WriteLine("Start TopView window creation");		

			InitializeComponent();
         
            var mainToolStripButtonsFactory = new MainToolStripButtonsFactory();
            mainToolStripButtonsFactory.MakeToolstrip(toolStrip);

			SuspendLayout();
			topViewPanel = new TopViewPanel();
			topViewPanel.Width = 100;
			topViewPanel.Height = 100;

			center.AutoScroll = true;
			center.Controls.Add(topViewPanel);

			center.Resize += delegate(object sender, EventArgs e)
			{
				topViewPanel.ParentSize(center.Width, center.Height);
			};

			//bottom.PanelClicked += new EventHandler(bottomClick);

			this.Menu = new MainMenu();
			MenuItem vis = Menu.MenuItems.Add("Visible");

			visibleHash = new Dictionary<MenuItem, int>();

			topViewPanel.Ground = vis.MenuItems.Add("Ground", new EventHandler(visibleClick));
			visibleHash[topViewPanel.Ground] = 0;
			topViewPanel.Ground.Shortcut = Shortcut.F1;

			topViewPanel.West = vis.MenuItems.Add("West", new EventHandler(visibleClick));
			visibleHash[topViewPanel.West] = 1;
			topViewPanel.West.Shortcut = Shortcut.F2;

			topViewPanel.North = vis.MenuItems.Add("North", new EventHandler(visibleClick));
			visibleHash[topViewPanel.North] = 2;
			topViewPanel.North.Shortcut = Shortcut.F3;

			topViewPanel.Content = vis.MenuItems.Add("Content", new EventHandler(visibleClick));
			visibleHash[topViewPanel.Content] = 3;
			topViewPanel.Content.Shortcut = Shortcut.F4;

			MenuItem edit = Menu.MenuItems.Add("Edit");
			edit.MenuItems.Add("Options", new EventHandler(options_click));
			edit.MenuItems.Add("Fill", new EventHandler(fill_click));

			//mapView.BlankChanged += new BoolDelegate(blankMode);

			//Controls.Add(bottom);

			topViewPanel.BottomPanel = bottom;

			MoreObservers.Add("BottomPanel", bottom);
			MoreObservers.Add("TopViewPanel", topViewPanel);

			ResumeLayout();
		}
Exemple #2
0
		//private LoadOfType<IMapDesc> loadedTypes;

		//public event StringDelegate SendMessage;

		public MainWindow()
        {
            /***********************/
            InitializeComponent();
            /***********************/

			#region Setup SharedSpace information and paths
			SharedSpace sharedSpace = SharedSpace.Instance;
			sharedSpace.GetObj("MapView", this);
			sharedSpace.GetObj("AppDir", Environment.CurrentDirectory);
			sharedSpace.GetObj("CustomDir", Environment.CurrentDirectory + "\\custom");
			sharedSpace.GetObj("SettingsDir", Environment.CurrentDirectory + "\\settings");

			PathInfo pathsFile = new PathInfo(SharedSpace.Instance.GetString("SettingsDir"), "Paths", "pth");
			PathInfo settingsFile = new PathInfo(SharedSpace.Instance.GetString("SettingsDir"), "MVSettings", "dat");
			PathInfo mapeditFile = new PathInfo(SharedSpace.Instance.GetString("SettingsDir"), "MapEdit", "dat");
			PathInfo imagesFile = new PathInfo(SharedSpace.Instance.GetString("SettingsDir"), "Images", "dat");

			sharedSpace.GetObj("MV_PathsFile", pathsFile);
			sharedSpace.GetObj("MV_SettingsFile", settingsFile);
			sharedSpace.GetObj("MV_MapEditFile", mapeditFile);
			sharedSpace.GetObj("MV_ImagesFile", imagesFile);
			#endregion

			if (!pathsFile.Exists())
			{
				InstallWindow iw = new InstallWindow();

				if (iw.ShowDialog(this) != DialogResult.OK)
					Environment.Exit(-1);
			}

			GameInfo.ParseLine += new ParseLineDelegate(parseLine);
			GameInfo.Init(Palette.TFTDBattle, pathsFile);
			LogFile.Instance.WriteLine("GameInfo.Init done");

			Palette.TFTDBattle.SetTransparent(true);
			Palette.UFOBattle.SetTransparent(true);
			Palette.TFTDBattle.Grayscale.SetTransparent(true);
			Palette.UFOBattle.Grayscale.SetTransparent(true);

			LogFile.Instance.WriteLine("Palette transparencies set");

			MapViewPanel.ImageUpdate += new EventHandler(update);

			mapView = MapViewPanel.Instance;
			mapView.Dock = DockStyle.Fill;

			instance = this;

			mapList.TreeViewNodeSorter = new System.Collections.CaseInsensitiveComparer();

			toolStripContainer1.ContentPanel.Controls.Add(mapView);
		    var mainToolStripButtonsFactory = new MainToolStripButtonsFactory();
            mainToolStripButtonsFactory.MakeToolstrip(toolStrip);
			toolStrip.Items.Add(new ToolStripSeparator());

			LogFile.Instance.WriteLine("Main view window created");

			settingsHash = new Dictionary<string, Settings>();
			loadDefaults();
			LogFile.Instance.WriteLine("Default settings loaded");

			try
			{
				mapView.View.Cursor = new Cursor(GameInfo.CachePck(SharedSpace.Instance.GetString("cursorFile"), "", 4, Palette.TFTDBattle));
			}
			catch
			{
				try
				{
					mapView.View.Cursor = new Cursor(GameInfo.CachePck(SharedSpace.Instance.GetString("cursorFile"), "", 2, Palette.UFOBattle));
				}
				catch { mapView.Cursor = null; }
			}

			LogFile.Instance.WriteLine("Cursor loaded");

			initList();

			LogFile.Instance.WriteLine("Map list created");

			registeredForms = new Dictionary<string, Form>();
			registerForm(TopView.Instance, "TopView", showMenu);
			registerForm(TileView.Instance, "TileView", showMenu);
			registerForm(RmpView.Instance, "RmpView", showMenu);

			if (XCom.Globals.UseBlanks)
				registerForm(mapView.BlankForm, "Blank Info", showMenu);

			//			addWindow(xConsole.Instance,"Console",showMenu);
			//			((MenuItem)windowMI[xConsole.Instance]).PerformClick();

			registerForm(new HelpScreen(), "Quick Help", miHelp);
			registerForm(new AboutWindow(), "About", miHelp);

			LogFile.Instance.WriteLine("Quick help and About created");

			if (settingsFile.Exists())
			{
				readMapViewSettings(new StreamReader(settingsFile.ToString()));
				LogFile.Instance.WriteLine("User settings loaded");
			}
			else
				LogFile.Instance.WriteLine("User settings NOT loaded - no settings file to load");

			OnResize(null);
			this.Closing += new CancelEventHandler(closing);

			lf = new LoadingForm();
			Bmp.LoadingEvent += new LoadingDelegate(lf.Update);

			//I should rewrite the hq2x wrapper for .net sometime (not the code, its pretty insane)
			//if(!File.Exists("hq2xa.dll"))
			miHq.Visible = false;
			//LogFile.Instance.WriteLine("Loading user-made plugins");

			/****************************************/
			//Copied from pckview
			//loadedTypes = new LoadOfType<IMapDesc>();
			//sharedSpace["MapMods"] = loadedTypes.AllLoaded;

			//There are no currently loadable maps in this assembly so this is more for future use
			//loadedTypes.LoadFrom(Assembly.GetAssembly(typeof(XCom.Interfaces.Base.IMapDesc)));

			//if (Directory.Exists(sharedSpace["CustomDir"].ToString()))
			//{
			//	xConsole.AddLine("Custom directory exists: " + sharedSpace["CustomDir"].ToString());
			//	foreach (string s in Directory.GetFiles(sharedSpace["CustomDir"].ToString()))
			//		if (s.EndsWith(".dll"))
			//		{
			//			xConsole.AddLine("Loading dll: " + s);
			//			loadedTypes.LoadFrom(Assembly.LoadFrom(s));
			//		}
			//}
			/****************************************/

			LogFile.Instance.WriteLine("About to show window");
			Show();
			LogFile.Instance.Close();			
		}