Пример #1
0
        private bool RemapString(string source, ref string targetFile)
        {
            string remapName;

            source = source.ToLower();

            // Default remap
            targetFile = source.Replace(mSourcePath, mSyncRoot);

            // Check for special rules for this asset in the ReMap section
            if (mPlatformSync.SectionExist("ReMap"))
            {
                for (int x = 0; x < mPlatformSync.CountKeys("ReMap"); x++)
                {
                    remapName = FormatString(mPlatformSync.GetKeyNameByIndex("ReMap", x).ToLower());

                    //Strip the files of their roots
                    //string remapNameNoRoot = remapName.Replace(mSourcePath, "");
                    //string sourceNoRoot = source.Replace(mSourcePath, "");

                    //if (StringUtils.StringCompare(remapNameNoRoot, sourceNoRoot))
                    if (StringUtils.StringCompare(remapName, source))
                    {
                        string wildString = "";

                        // Check for wildcards
                        if (remapName.IndexOf("*") != -1)
                        {
                            // Make sure we only have one *
                            if (remapName.IndexOf("*", remapName.IndexOf("*") + 1) != -1)
                            {
                                // Error!
                                MOG_REPORT.ShowMessageBox(mPlatformSync.GetFilename(), string.Concat("There are more than one '*' in string(", remapName, ")!  This is not allowed!"), MessageBoxButtons.OK);
                                return(false);
                            }
                            else
                            {
                                // If we have a wildcard, replace all target * with the text from the source *
                                wildString = FindWildcardString(source, remapName);
                            }
                        }

                        targetFile = mPlatformSync.GetKeyByIndex("Remap", x).ToLower();
                        targetFile = FormatString(targetFile);

                        // replace * if we had a wildCard
                        if (wildString.Length != 0)
                        {
                            targetFile = targetFile.Replace("*", wildString);
                        }

                        break;
                    }
                }
            }

            return(true);
        }
Пример #2
0
        /// <summary>
        /// Load our RadioButtons, given a section and a MOG_Ini
        /// </summary>
        /// <param name="section"></param>
        /// <param name="ini"></param>
        /// <returns></returns>
        private static SortedList LoadRadioButtons(string section, MOG_Ini ini)
        {
            ini.Load(ini.GetFilename());
            int        count        = ini.CountKeys(section);
            SortedList radioButtons = new SortedList();

            for (int i = 0; i < count; ++i)
            {
                radioButtons.Add(ini.GetKeyNameByIndexSLOW(section, i), ini.GetKeyByIndexSLOW(section, i));
            }
            return(radioButtons);
        }
Пример #3
0
        private bool InitializeFileMap()
        {
            mPlatformSync = new MOG_Ini();

            // Get the platformSinc.info file
            string platformSyncFile = mMog.GetProject().GetProjectToolsPath() + "\\" + mProjectSyncFile;

            if (DosUtils.Exist(platformSyncFile))
            {
                // Open the global sinc file to determine what to sinc
                mPlatformSync.Open(platformSyncFile, FileShare.Read);
                mPlatformSync.SetFilename(mMog.GetUser().GetUserToolsPath() + "\\platformSinc." + mMog.GetActivePlatform().mPlatformName + ".Merge.info", false);
            }

            // Check if the user has a custom sync file
            string userSyncFile = mMog.GetUser().GetUserToolsPath() + "\\" + mUserSyncFile;

            if (DosUtils.FileExist(userSyncFile))
            {
                // Should we force ourselves to use only the user sync file?
                if (string.Compare(mProjectSyncFile, "none", true) == 0)
                {
                    mPlatformSync.CloseNoSave();
                    mPlatformSync.Open(userSyncFile, FileShare.Read);
                }
                else
                {
                    // Lets merge the two then
                    mPlatformSync.PutFile(userSyncFile);
                }
            }

            // Make sure we got 'a' Map file loaded
            if (mPlatformSync.GetFilename().Length > 0)
            {
                // Is this a local sync
                if (Path.IsPathRooted(mTargetConsole))
                {
                    string root = "";
                    // Get our local directory root path
                    // Get our console root path
                    if (mUseDefaultUser)
                    {
                        root = FormatString(mPlatformSync.GetString(mMog.GetActivePlatform().mPlatformName, "SpecialRoot").ToLower());
                    }
                    else
                    {
                        root = FormatString(mPlatformSync.GetString(mMog.GetActivePlatform().mPlatformName, "Root").ToLower());
                    }

                    // Fix up the pc console name
                    mSyncRoot    = mTargetConsole + "\\" + Path.GetFileNameWithoutExtension(root);
                    mConsoleCopy = false;
                }
                else
                {
                    // Get our console root path
                    if (mUseDefaultUser)
                    {
                        mSyncRoot = FormatString(mPlatformSync.GetString(mMog.GetActivePlatform().mPlatformName, "SpecialRoot").ToLower());
                    }
                    else
                    {
                        mSyncRoot = FormatString(mPlatformSync.GetString(mMog.GetActivePlatform().mPlatformName, "Root").ToLower());
                    }
                }
            }
            else
            {
                throw(new Exception("Valid platform sync file never properly loaded!"));
            }

            return(true);
        }
Пример #4
0
        private void SyncSaveButton_Click(object sender, System.EventArgs e)
        {
            SyncSaveFileDialog.InitialDirectory = MOG_ControllerProject.GetUser().GetUserToolsPath();

            // Save this custom sync file
            if (SyncSaveFileDialog.ShowDialog() == DialogResult.OK)
            {
                string  syncFilename = SyncSaveFileDialog.FileName;
                MOG_Ini syncFile     = new MOG_Ini(syncFilename);

                foreach (TreeNode sectionNode in XboxSincTreeView.Nodes)
                {
                    string section = sectionNode.Text;

                    foreach (TreeNode keyNode in sectionNode.Nodes)
                    {
                        string key = keyNode.Text;

                        if (keyNode.Nodes.Count > 0)
                        {
                            foreach (TreeNode valNode in keyNode.Nodes)
                            {
                                string val = valNode.Text;

                                syncFile.PutString(section, key, val);
                            }
                        }
                        else
                        {
                            syncFile.PutSectionString(section, key);
                        }
                    }
                }

                // Verify that the newly created sync file has the correct number amount of sections
                if (syncFile.SectionExist("Filemap"))
                {
                    if (syncFile.CountKeys("Filemap") > 0 && string.Compare(SyncProjectMapComboBox.Text, "None") == 0)
                    {
                        MOG_Prompt.PromptMessage("Missing syncfile data", "The required 'FILEMAP' section was not found in this custom sync file.  Aborting...");
                        syncFile.CloseNoSave();
                        return;
                    }
                }
                else
                {
                    MOG_Prompt.PromptMessage("Missing syncfile data", "The required 'FILEMAP' section was not found in this custom sync file.  Aborting...");
                    syncFile.CloseNoSave();
                    return;
                }

                // Make sure we have a valid root definition
                if (syncFile.SectionExist(MOG_ControllerProject.GetCurrentSyncDataController().GetPlatformName()))
                {
                    if (syncFile.CountKeys(MOG_ControllerProject.GetCurrentSyncDataController().GetPlatformName()) > 0 && string.Compare(SyncProjectMapComboBox.Text, "None") == 0)
                    {
                        MOG_Prompt.PromptMessage("Missing syncfile data", "The required '" + MOG_ControllerProject.GetCurrentSyncDataController().GetPlatformName() + "' section was not found in this custom sync file.  Aborting...");
                        syncFile.CloseNoSave();
                        return;
                    }
                }
                else
                {
                    MOG_Prompt.PromptMessage("Missing syncfile data", "The required '" + MOG_ControllerProject.GetCurrentSyncDataController().GetPlatformName() + "' section was not found in this custom sync file.  Aborting...");
                    syncFile.CloseNoSave();
                    return;
                }

                // Save out our new syncFile
                syncFile.Save();
                SyncSaveButton.Enabled = false;

                mUserMap = syncFile.GetFilename();
            }
        }