示例#1
0
        private MapImage AddImage(string name, string filename, int texw, int texh, float origx, float origy, float uppx, float uppy)
        {
            string filepath = "maps\\" + filename;

            try
            {
                MapImage mi = new MapImage(name, filepath, texw, texh, origx, origy, uppx, uppy);
                Images.Add(mi);
                return(mi);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Could not load map image " + filepath + " for " + name + " map!\n\n" + ex.ToString());
            }
            return(null);
        }
示例#2
0
        private void MapComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            MapImage mi = MapComboBox.SelectedItem as MapImage;

            if ((mi != null) && (mi != CurrentMap) && (device != null))
            {
                SetIsLoading(true);
                if ((CurrentMap != null) && (CurrentMap.Tex != null))
                {
                    CurrentMap.Tex.Dispose();
                    CurrentMap.Tex = null;
                }

                if (mi.Tex == null)
                {
                    LoadImageTexture(mi);
                }
                else
                {
                    SetIsLoading(false);
                }

                CurrentMap  = mi;
                NeedsUpdate = true;

                if (CurrentMap != null)
                {
                    TextureNameLabel.Text      = CurrentMap.Name;
                    TextureFileLabel.Text      = CurrentMap.Filepath;
                    TextureOriginTextBox.Text  = string.Format("{0}, {1}", CurrentMap.Origin.X, CurrentMap.Origin.Y);
                    UnitsPerTexelXTextBox.Text = CurrentMap.UnitsPerTexelX.ToString();
                    UnitsPerTexelYTextBox.Text = CurrentMap.UnitsPerTexelY.ToString();
                    if (LocatorMarker != null)
                    {
                        UpdateMarkerTexturePos(LocatorMarker);
                        WorldCoordTextBox.Text   = LocatorMarker.Get2DWorldPosString();
                        TextureCoordTextBox.Text = LocatorMarker.Get2DTexturePosString();
                    }
                }
                else
                {
                    TextureNameLabel.Text = "(No texture)";
                    TextureFileLabel.Text = "(No texture)";
                }
            }
        }
示例#3
0
        private void LoadImageTexture(MapImage mi)
        {
            SetIsLoading(true);

            Task.Run(() =>
            {
                try
                {
                    if (device != null)
                    {
                        mi.Tex = Texture.FromFile(device, mi.Filepath);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Could not load map image " + mi.Filepath + " for " + mi.Name + " map!\n\n" + ex.ToString());
                }

                LoadCurrentImageComplete();
            });
        }
示例#4
0
 private void LoadImagesComplete()
 {
     try
     {
         if (InvokeRequired)
         {
             Invoke(new Action(() => { LoadImagesComplete(); }));
         }
         else
         {
             if (Images.Count > 0)
             {
                 foreach (MapImage mi in Images)
                 {
                     MapComboBox.Items.Add(mi);
                 }
                 CurrentMap = Images[0];
                 MapComboBox.SelectedItem = CurrentMap;
             }
             SetIsLoading(false);
         }
     }
     catch { }
 }
示例#5
0
        public MapForm()
        {
            InitializeComponent();


            Icons = new List <MapIcon>();
            AddIcon("Google Marker", "icon_google_marker_64x64.png", 64, 64, 11.0f, 40.0f, 1.0f);
            AddIcon("Glokon Marker", "icon_glokon_normal_32x32.png", 32, 32, 11.0f, 32.0f, 1.0f);
            AddIcon("Glokon Debug", "icon_glokon_debug_32x32.png", 32, 32, 11.5f, 32.0f, 1.0f);
            MarkerIcon  = Icons[1];
            LocatorIcon = Icons[2];
            foreach (MapIcon icon in Icons)
            {
                MarkerStyleComboBox.Items.Add(icon);
                LocatorStyleComboBox.Items.Add(icon);
            }
            MarkerStyleComboBox.SelectedItem  = MarkerIcon;
            LocatorStyleComboBox.SelectedItem = LocatorIcon;
            LocatorMarker           = new MapMarker();
            LocatorMarker.Icon      = LocatorIcon;
            LocatorMarker.IsMovable = true;


            ////for google map calibration...
            //var game_1_x = 1972.606; //var map_1_lng = -60.8258056640625;
            //var game_1_y = 3817.044; //var map_1_lat = 72.06379257078102;
            //var game_2_x = -1154.11; //var map_2_lng = -72.1417236328125;
            //var game_2_y = -2715.203; //var map_2_lat = 48.41572128171852;

            ////reference point:
            //501.4398, 5603.9600, 795.9738, 0x4CC3BAFC, cs1_10_redeye

            //origin in 8192x8192 textures is at approx:
            //3755.2, 5525.5

            float ox   = 3755.2f;
            float oy   = 5525.5f;
            float uptx = 1.517952f; //this seems pretty close...
            float upty = -1.517952f;

            Images = new List <MapImage>();
            AddImage("Satellite", "gtav_satellite_8192x8192.jpg", 8192, 8192, ox, oy, uptx, upty);
            AddImage("Roads", "gtav_roadmap_8192x8192.jpg", 8192, 8192, ox, oy, uptx, upty);
            AddImage("Atlas", "gtav_atlas_8192x8192.jpg", 8192, 8192, ox, oy, uptx, upty);
            foreach (MapImage mi in Images)
            {
                MapComboBox.Items.Add(mi);
            }

            InitializeDevice();

            if (Images.Count > 0)
            {
                MapImage mi = Images[0];
                MapComboBox.SelectedItem = mi;
                TargetViewCenter         = mi.Origin;
                CurrentViewCenter        = mi.Origin;
            }

            this.MouseWheel += MapForm_MouseMove;

            FrameTimer.Restart();
            SlimDX.Windows.MessagePump.Run(this, new SlimDX.Windows.MainLoop(SlimDX_Render));
        }