Exemple #1
0
        /// <summary>
        /// Loads camera.bin data
        /// </summary>
        private void _LoadReferenceCameras()
        {
            Cursor = Cursors.WaitCursor;

            // Parsing ref XML file and writing to reference
            VehicleSlotsHelper.InitReference(AppConstants.FOLDER_XML);

            // View selector dialog
            _CamViewSelectorDialog = new CamSelectorDialog(VehicleSlotsHelper.DefaultCameras);

            Cursor = Cursors.Default;
        }
        /// <summary>
        /// What the instruction should do
        /// </summary>
        protected void _CommonProcess()
        {
            // Common parameters
            string camId           = _GetParameter(PatchInstructionParameter.ParameterName.cameraIKIdentifier);
            string hoodView        = _GetParameter(PatchInstructionParameter.ParameterName.newHoodView);
            string hoodBackView    = _GetParameter(PatchInstructionParameter.ParameterName.newHoodBackView);
            string cockpitView     = _GetParameter(PatchInstructionParameter.ParameterName.newCockpitView);
            string cockpitBackView = _GetParameter(PatchInstructionParameter.ParameterName.newCockpitBackView);

            // Parameter validation
            string hoodCamId = hoodView.Split(Tools.SYMBOL_VALUE_SEPARATOR)[0];

            Cameras.ViewType hoodViewType  = _ValidateViewType(hoodView.Split(Tools.SYMBOL_VALUE_SEPARATOR)[1]);
            string           hoodBackCamId = hoodBackView.Split(Tools.SYMBOL_VALUE_SEPARATOR)[0];

            Cameras.ViewType hoodBackViewType = _ValidateViewType(hoodBackView.Split(Tools.SYMBOL_VALUE_SEPARATOR)[1]);
            string           cockpitCamId     = cockpitView.Split(Tools.SYMBOL_VALUE_SEPARATOR)[0];

            Cameras.ViewType cockpitViewType  = _ValidateViewType(cockpitView.Split(Tools.SYMBOL_VALUE_SEPARATOR)[1]);
            string           cockpitBackCamId = cockpitBackView.Split(Tools.SYMBOL_VALUE_SEPARATOR)[0];

            Cameras.ViewType cockpitBackViewType = _ValidateViewType(cockpitBackView.Split(Tools.SYMBOL_VALUE_SEPARATOR)[1]);

            // Loading current camera
            string  currentCamFile = LibraryConstants.GetSpecialFile(LibraryConstants.TduSpecialFile.CamerasBin);
            Cameras currentCameras = TduFile.GetFile(currentCamFile) as Cameras;

            if (currentCameras == null || !currentCameras.Exists)
            {
                throw new Exception("Unable to load current camera data: " + currentCamFile);
            }

            // Loading default camera
            Cameras defaultCameras = TduFile.GetFile(camReferenceFilename) as Cameras;

            if (defaultCameras == null || !defaultCameras.Exists)
            {
                throw new Exception("Unable to load new camera data: " + camReferenceFilename);
            }

            // Views
            VehicleSlotsHelper.InitReference(Tools.WorkingPath + LibraryConstants.FOLDER_XML);

            _Customize(currentCameras, defaultCameras, camId, Cameras.ViewType.Hood, hoodCamId, hoodViewType);
            _Customize(currentCameras, defaultCameras, camId, Cameras.ViewType.Hood_Back, hoodBackCamId, hoodBackViewType);
            _Customize(currentCameras, defaultCameras, camId, Cameras.ViewType.Cockpit, cockpitCamId, cockpitViewType);
            _Customize(currentCameras, defaultCameras, camId, Cameras.ViewType.Cockpit_Back, cockpitBackCamId, cockpitBackViewType);

            // Saving
            currentCameras.Save();
        }
Exemple #3
0
        /// <summary>
        /// Default constructor
        /// </summary>
        public VehicleManagerForm()
        {
            InitializeComponent();

            // Vehicle slots reference
            VehicleSlotsHelper.InitReference(AppConstants.FOLDER_XML);

            try
            {
                _LoadReferenceCameras();
            }
            catch (Exception ex)
            {
                MessageBoxes.ShowError(this, new Exception(_ERROR_LOADING_CAMERAS, ex));
            }

            _InitializeContents();

            try
            {
                _LoadDatabase();
            }
            catch (Exception ex)
            {
                MessageBoxes.ShowError(this, new Exception(_ERROR_LOADING_DATABASE, ex));
            }

            // Getting setting for list mod
            bool originalMode = bool.Parse(Program.ApplicationSettings.VehicleManagerOriginalDisplayMode);

            _IsShowOriginalNames = !originalMode;

            if (originalMode)
            {
                originalNamesRadioButton.Checked = true;
            }
            else
            {
                moddedNamesRadioButton.Checked = true;
            }
        }
Exemple #4
0
        private void browseSlotsButton_Click(object sender, EventArgs e)
        {
            // Click on '...' button for slots
            try
            {
                Cursor = Cursors.WaitCursor;

                // Preparing slot list
                SortedStringCollection      sortedSlotList = new SortedStringCollection();
                Dictionary <string, string> index          = new Dictionary <string, string>();

                // Misc slot
                sortedSlotList.Add(Tools.NAME_MISC_SLOT);
                index.Add(Tools.NAME_MISC_SLOT, Tools.KEY_MISC_SLOT);

                // Vehicle slots
                VehicleSlotsHelper.InitReference(Tools.WorkingPath + LibraryConstants.FOLDER_XML);

                foreach (KeyValuePair <string, string> pair in VehicleSlotsHelper.SlotReference)
                {
                    sortedSlotList.Add(pair.Key);
                    index.Add(pair.Key, pair.Value);
                }

                Cursor = Cursors.Default;

                // Displaying browse dialog
                TableBrowsingDialog dialog = new TableBrowsingDialog(_MESSAGE_BROWSE_SLOTS, sortedSlotList, index);
                DialogResult        dr     = dialog.ShowDialog();

                if (dr == DialogResult.OK && dialog.SelectedIndex != null)
                {
                    slotRefTextBox.Text = dialog.SelectedIndex;
                }
            }
            catch (Exception ex)
            {
                MessageBoxes.ShowError(this, ex);
            }
        }
Exemple #5
0
        /// <summary>
        /// What the instruction should do
        /// </summary>
        protected override void _Process()
        {
            // Parameters
            string vehicleName = _GetParameter(PatchInstructionParameter.ParameterName.slotFullName);
            string cameraId    = _GetParameter(PatchInstructionParameter.ParameterName.cameraIKIdentifier);

            // Loading reference
            VehicleSlotsHelper.InitReference(PatchHelper.CurrentPath);

            // Checking validity
            if (!VehicleSlotsHelper.SlotReference.ContainsKey(vehicleName))
            {
                throw new Exception("Specified vehicle name is not supported: " + vehicleName);
            }

            if (!VehicleSlotsHelper.CamReference.ContainsKey(cameraId))
            {
                throw new Exception("Specified camera identifier is not supported: " + cameraId);
            }

            // Edit task
            EditHelper.Task task = new EditHelper.Task();

            try
            {
                try
                {
                    string bnkFileName = string.Concat(LibraryConstants.GetSpecialFolder(LibraryConstants.TduSpecialFolder.Database), DB.GetBNKFileName(DB.Culture.Global));
                    BNK    dbBnkFile   = TduFile.GetFile(bnkFileName) as BNK;

                    if (dbBnkFile != null)
                    {
                        string dbFilePath =
                            dbBnkFile.GetPackedFilesPaths(DB.GetFileName(DB.Culture.Global, DB.Topic.CarPhysicsData))[0];

                        task =
                            EditHelper.Instance.AddTask(dbBnkFile, dbFilePath, true);
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception("Unable to get TDU database contents in DB.BNK.", ex);
                }

                // Opens packed file
                DB physicsDB = TduFile.GetFile(task.extractedFile) as DB;

                if (physicsDB == null)
                {
                    throw new Exception("Unable to get CarPhysicsData information.");
                }

                // Changes camera
                try
                {
                    string vehicleRef = VehicleSlotsHelper.SlotReference[vehicleName];

                    VehicleSlotsHelper.ChangeCameraById(vehicleRef, cameraId, physicsDB);
                }
                catch (Exception ex)
                {
                    throw new Exception("Unable to use new camera set: " + cameraId + " for " + vehicleName, ex);
                }

                // Saving
                try
                {
                    physicsDB.Save();
                    EditHelper.Instance.ApplyChanges(task);
                    EditHelper.Instance.RemoveTask(task);
                }
                catch (Exception ex)
                {
                    throw new Exception("Unable to save and replace file in BNK.", ex);
                }
            }
            finally
            {
                EditHelper.Instance.RemoveTask(task);
            }
        }
Exemple #6
0
        /// <summary>
        /// Manages component install/uninstall
        /// </summary>
        /// <param name="isInstall">true if install / false if uninstall</param>
        private void _Process(bool isInstall)
        {
            // Current culture
            //string selectedCulture = gameCultureComboBox.Text.Substring(0, 2);
            //DB.Culture currentCulture = (DB.Culture) Enum.Parse(typeof (DB.Culture), selectedCulture);
            // EVO_147
            const DB.Culture currentCulture = DB.Culture.US;

            // Selects right patch according to install/uninstall case
            PCH currentPatch = (isInstall ? _CurrentInstallPatch : _CurrentUninstallPatch);

            // TDU folder (override)
            Tools.TduPath = tduPathTextbox.Text;

            // Authorization checks
            // If specified ref matches a car pack vehicle, TDU version must be '1.66+megapack'
            if (Tools.InstalledTduVersion != Tools.TduVersion.V1_66_Megapack)
            {
                // Loading reference
                try
                {
                    VehicleSlotsHelper.InitReference(Application.StartupPath + LibraryConstants.FOLDER_XML);

                    // Getting vehicle information...
                    if (!Tools.KEY_MISC_SLOT.Equals(_CurrentInstallPatch.SlotRef) &&
                        VehicleSlotsHelper.VehicleInformation.ContainsKey(currentPatch.SlotRef))
                    {
                        VehicleSlotsHelper.VehicleInfo info =
                            VehicleSlotsHelper.VehicleInformation[currentPatch.SlotRef];

                        if (info.isAddon)
                        {
                            MessageBoxes.ShowWarning(this, _ERROR_MOD_NOT_ALLOWED);
                            return;
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBoxes.ShowError(this, ex);
                    return;
                }
            }

            // If another mod is installed on current slot...
            // Exception for Patch 1.67d
            if (isInstall &&
                InstallHelper.IsAnotherModInstalled(currentPatch.SlotRef, currentPatch.Name) &&
                !AppConstants.SLOT_COMMUNITY_PATCH.Equals(currentPatch.SlotRef))
            {
                MessageBoxes.ShowWarning(this, string.Format(_ERROR_ANOTHER_MOD_INSTALLED, InstallHelper.GetInstalledModName(currentPatch.SlotRef)));
                return;
            }

            // EVO_134 Group handling, if necessary
            List <string> chosenInstallGroups = new List <string> {
                PCH.REQUIRED_GROUP_NAME
            };

            if (isInstall && currentPatch.Groups.Count > 1)
            {
                GroupsDialog dlg = new GroupsDialog(_CurrentInstallPatch);
                DialogResult dr  = dlg.ShowDialog(this);

                if (dr == DialogResult.OK)
                {
                    chosenInstallGroups = dlg.ChosenGroups;
                }
                else
                {
                    return;
                }
            }

            // Patch logger init
            string logFile  = Application.StartupPath + LibraryConstants.FILE_LOG_PATCH;
            Log    patchLog = new Log(logFile);

            patchLog.Appenders.Add(new ConsoleAppender());

            // EVO_100: progress bar init
            progressPanel.Visible = true;
            infoLabel.Visible     = false;

            mainProgressBar.Minimum = 0;
            mainProgressBar.Maximum = currentPatch.PatchInstructions.Count;
            mainProgressBar.Step    = 1;
            mainProgressBar.Value   = 0;
            PatchHelper.ProgressBar = mainProgressBar;

            // Using new helper
            try
            {
                InstallHelper.RunAll(currentPatch, patchLog, currentCulture, isInstall, chosenInstallGroups);
                Application.DoEvents();

                // Showing gui messages
                foreach (string message in PatchHelper.Messages)
                {
                    MessageBoxes.ShowWarning(this, message);
                }

                // OK
                MessageBoxes.ShowInfo(this, isInstall ? _MESSAGE_PATCH_SUCCESS : _MESSAGE_PATCH_UNINSTALL_SUCCESS);

                // Refreshing window contents
                //_LoadData(_CurrentInstallPatch.FileName, (_CurrentUninstallPatch == null) ? null : _CurrentUninstallPatch.FileName);

                // Contextual information has to be updated
                _UpdateContextualControls();
            }
            catch (Exception ex)
            {
                // Showing messages first
                foreach (string message in PatchHelper.Messages)
                {
                    MessageBoxes.ShowWarning(this, message);
                }

                if (PatchHelper.Messages.Count == 0)
                {
                    MessageBoxes.ShowError(this, ex);
                }
            }
            finally
            {
                // Hiding progress bar
                progressPanel.Visible = false;
            }
        }