コード例 #1
0
        /// <summary>
        /// Set texture set of current sky.
        /// </summary>
        /// <param name="skyIndex">Index.</param>
        private void SetSkyIndex(int skyIndex)
        {
            // Validate path
            if (string.IsNullOrEmpty(arena2Path))
            {
                return;
            }

            // Validate index
            if (skyIndex < 0 || skyIndex > 31)
            {
                return;
            }

            // Store new value
            this.skyIndex = skyIndex;

            // Load a sample sky file
            string filename = string.Format("SKY{0:00}.DAT", skyIndex);

            skyFile = new SkyFile(
                Path.Combine(arena2Path, filename),
                FileUsage.UseDisk,
                true);

            // Update textures
            UpdateTextures();
        }
コード例 #2
0
        private void LoadDaySky(int frame)
        {
            skyFile = new SkyFile(Path.Combine(dfUnity.Arena2Path, SkyFile.IndexToFileName(SkyIndex)), FileUsage.UseMemory, true);

            skyFile.Palette      = skyFile.GetDFPalette(frame);
            skyColors.east       = skyFile.GetColor32(0, frame);
            skyColors.west       = skyFile.GetColor32(1, frame);
            skyColors.clearColor = skyColors.west[0];
        }
コード例 #3
0
        /// <summary>
        /// Loads day sky from arena files
        /// </summary>
        /// <param name="skyIndex"></param>
        /// <returns>SkyColors loaded</returns>
        private SkyColors LoadVanillaDaySky(int skyIndex, int frame)
        {
            SkyFile skyFile = new SkyFile(Path.Combine(dfUnity.Arena2Path, SkyFile.IndexToFileName(skyIndex)), FileUsage.UseMemory, true);

            skyFile.Palette = skyFile.GetDFPalette(frame);

            SkyColors colors = new SkyColors();

            colors.east       = skyFile.GetColor32(0, frame);
            colors.west       = skyFile.GetColor32(1, frame);
            colors.clearColor = colors.west[0];
            colors.imageSize  = new Vector2Int(512, 220);

            return(colors);
        }
コード例 #4
0
        private LoksimFile LoadFile(L3dFilePath path)
        {
            LoksimFile file = null;

            try
            {
                switch (System.IO.Path.GetExtension(path.AbsolutePath).ToLower())
                {
                case ".l3dwth":
                {
                    WeatherFile f = new WeatherFile();
                    f.LoadFromFile(path);
                    file = f;
                }
                break;

                case ".l3dsky":
                {
                    SkyFile f = new SkyFile();
                    f.LoadFromFile(path);
                    file = f;
                }
                break;

                case ".l3dfst":
                {
                    DrivingCabFile f = new DrivingCabFile();
                    f.LoadFromFile(path);
                    file = f;
                }
                break;

                default:
                    Debug.Assert(false, "Unknown File Type");
                    break;
                }
                this.Title = Loksim3D.WetterEdit.Resources.Strings.AppName + " [" + path.Filename + "]";
                Settings.RegistrySettings.Default.AddRecentFile(path);
            }
            catch (Exception ex)
            {
                Mouse.OverrideCursor = null;
                MessageBox.Show(String.Format(Loksim3D.WetterEdit.Resources.Strings.ErrorLoadingFile_0_Msg_1_, path.Filename, ex.Message),
                                Loksim3D.WetterEdit.Resources.Strings.AppName, MessageBoxButton.OK, MessageBoxImage.Error);
            }
            return(file);
        }
コード例 #5
0
        internal void CreateNewFile(string fileToOpen)
        {
            if (fileToOpen != null)
            {
                string     arg0 = _fileToOpen.Trim();
                LoksimFile file = null;
                switch (arg0.ToLower())
                {
                case "-l3dsky":
                    file = new SkyFile();
                    break;

                case "-l3dwth":
                    file = WeatherFile.CreateNewDefaultFile();
                    break;

                case "-l3dfst":
                    file = new DrivingCabFile();
                    break;

                default:
                    file = LoadFile(new L3dFilePath(arg0));
                    break;
                }
                if (file != null)
                {
                    SetCtrlAndViewModel(file);
                }
            }
#if DEBUG
            //TODO Just for driving cab dev

            /*
             * else
             * {
             *  LoksimFile f = new DrivingCabFile();
             *  SetCtrlAndViewModel(f);
             * }
             */
#endif
        }
コード例 #6
0
        private void ButtonOK_Click(object sender, RoutedEventArgs e)
        {
            ListViewItem it = listView.SelectedItem as ListViewItem;

            if (it != null && it.Tag != null)
            {
                switch (it.Tag.ToString())
                {
                case "l3dsky":
                    SelectedFile = new SkyFile();
                    break;

                case "l3dwth":
                    SelectedFile = WeatherFile.CreateNewDefaultFile();
                    break;

                case "l3dfst":
                    SelectedFile = new DrivingCabFile();
                    break;
                }
                DialogResult = true;
                Close();
            }
        }
コード例 #7
0
        public SkyFileViewModel(SkyFile skyFile, Window parentWindow)
            : base(skyFile, parentWindow)
        {
            _skyFile         = skyFile;
            _selectedWeather = skyFile.WeatherSets.FirstOrDefault();

            RemoveFileCmd = new RelayCommand(obj =>
            {
                _skyFile.WeatherSets.Remove(_selectedWeather);
                SelectedWeatherFile = null;
            },
                                             obj =>
            {
                return(SelectedWeatherFile != null);
            });

            AddFileCmd = new RelayCommand(obj =>
            {
                string s = DialogHelpers.OpenLoksimFile(string.Empty, FileExtensions.WeatherFiles, parentWindow, WEATHER_DLG_GUID);
                if (!string.IsNullOrEmpty(s))
                {
                    Weather w = new Weather(SkyFile, new L3dFilePath(s));
                    _skyFile.WeatherSets.Add(w);
                    SelectedWeatherFile = w;
                }
            });

            CopyWeatherFile = new RelayCommand(arg =>
            {
                if (SelectedWeatherFile != null)
                {
                    try
                    {
                        Clipboard.SetText(SelectedWeatherFile.ConvertToXml().ToString(), TextDataFormat.UnicodeText);
                    }
                    catch (Exception)
                    {
                        SystemSounds.Exclamation.Play();
                    }
                }
            },
                                               arg =>
            {
                return(SelectedWeatherFile != null);
            }
                                               );

            CutWeatherFile = new RelayCommand(arg =>
            {
                if (SelectedWeatherFile != null)
                {
                    try
                    {
                        Clipboard.SetText(SelectedWeatherFile.ConvertToXml().ToString(), TextDataFormat.UnicodeText);
                        SkyFile.WeatherSets.Remove(SelectedWeatherFile);
                    }
                    catch (Exception)
                    {
                        SystemSounds.Exclamation.Play();
                    }
                }
            },
                                              arg =>
            {
                return(SelectedWeatherFile != null);
            }
                                              );

            PasteWeatherFile = new RelayCommand(arg =>
            {
                var w = Weather.ReadFromXml(Clipboard.GetText(), SkyFile);
                if (w != null)
                {
                    SkyFile.WeatherSets.Add(w);
                    SelectedWeatherFile = w;
                }
            },
                                                arg =>
            {
                return(Clipboard.ContainsText() && Weather.ReadFromXml(Clipboard.GetText(), SkyFile) != null);
            }
                                                );

            WeatherFileDown = new RelayCommand(arg =>
            {
                int ind = SelectedWeatherFileIndex;
                if (ind >= 0 && ind < SkyFile.WeatherSets.Count - 1)
                {
                    var w = SkyFile.WeatherSets[ind];
                    SkyFile.WeatherSets.RemoveAt(ind);
                    SkyFile.WeatherSets.Insert(ind + 1, w);
                }
            },
                                               arg =>
            {
                return(SelectedWeatherFileIndex >= 0 && SelectedWeatherFileIndex < SkyFile.WeatherSets.Count - 1);
            }
                                               );

            WeatherFileUp = new RelayCommand(arg =>
            {
                int ind = SelectedWeatherFileIndex;
                if (ind > 0 && ind < SkyFile.WeatherSets.Count)
                {
                    var w = SkyFile.WeatherSets[ind];
                    SkyFile.WeatherSets.RemoveAt(ind);
                    SkyFile.WeatherSets.Insert(ind - 1, w);
                }
            },
                                             arg =>
            {
                return(SelectedWeatherFileIndex > 0 && SelectedWeatherFileIndex < SkyFile.WeatherSets.Count);
            }
                                             );
        }