Ejemplo n.º 1
0
        private bool CommitNewUCSEntry()
        {
            // check if index is still available
            var index = (uint)m_nupIndex.Value;

            if (UCSManager.HasString(index))
            {
                UIHelper.ShowError("The selected index already exists! Choose another one!");
                return(false);
            }

            // merge text into one line
            string text = m_rtbUCSText.Text;

            if (m_rtbUCSText.Lines.Length > 1)
            {
                text = m_rtbUCSText.Lines.Aggregate(string.Empty, (current, s) => current + " " + s);
            }

            UCSManager.AddString(text, index);
            if (m_chkbxCopyToClipboard.Checked)
            {
                Clipboard.SetText(index.ToString());
            }
            return(true);
        }
Ejemplo n.º 2
0
        public static void TestMod()
        {
            UCSManager.SaveUCS();
            if (Properties.Settings.Default.sSteamExecutable == null || !File.Exists(Properties.Settings.Default.sSteamExecutable))
            {
                UIHelper.ShowError("The selected path for the Steam-Executable is not valid! Set it to a valid path in the options menu!");
                return;
            }

            string modName = ModManager.ModName;

            if (modName == null)
            {
                UIHelper.ShowError("Can't acquire mod name, please ensure that there is a mod loaded.");
                return;
            }
            string param = "-applaunch ";

            param += Properties.Settings.Default.sSteamAppID;
            if (Properties.Settings.Default.sSteamAppID == string.Empty)
            {
                param += GameConstants.DOW2_APP_ID;
            }
            param += " -dev -modname " + modName;
            if (Properties.Settings.Default.bTestDebugWin)
            {
                param += " -debugwindow";
            }
            if (Properties.Settings.Default.bTestNoMovies)
            {
                param += " -nomovies";
            }
            if (Properties.Settings.Default.bTestWindowed)
            {
                param += " -window";
            }
            if (Properties.Settings.Default.sTestParams != string.Empty)
            {
                param += " " + Properties.Settings.Default.sTestParams;
            }

            bool advDebug = false;

            if (User.IsCurrentUserAdministrator())
            {
                advDebug = Properties.Settings.Default.bUseAdvancedDebug;
            }
            else
            {
                LoggingManager.SendMessage("DebugManager - Current user has insufficient rights to use advanced debugging.");
            }
            Process.Start(Properties.Settings.Default.sSteamExecutable, param);
            if (advDebug)
            {
                Thread.Sleep(2000);
                DebugManager.StartDebugging();
            }
        }
Ejemplo n.º 3
0
        private void DgvStringsCellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex <= 0 || e.RowIndex < 0)
            {
                return;
            }
            DataGridViewRow row   = m_dgvStrings.Rows[e.RowIndex];
            uint            index = (uint)row.Cells[0].Value;
            string          text  = (string)row.Cells[1].Value;

            UCSManager.ModifyString(text, index);
        }
Ejemplo n.º 4
0
        private void TrvTablesAfterSelect(object sender, TreeViewEventArgs e)
        {
            if (e.Node.Tag == null)
            {
                return;
            }
            var current = e.Node.Tag as AttributeValue;

            UpdateDataGrid(current);
            if (current.DataType == AttributeDataType.Integer)
            {
                var value = (uint)(int)current.Data;
                m_rtbCurrentUCS.Text = UCSManager.HasString(value) ? UCSManager.GetString(value) : string.Empty;
            }
        }
Ejemplo n.º 5
0
        private void LoadEntries()
        {
            var entries = UCSManager.GetStrings();

            if (entries == null)
            {
                return;
            }
            m_dgvStrings.AllowUserToAddRows = true;
            foreach (var kvp in entries)
            {
                AddRow(kvp.Key, kvp.Value);
            }
            m_dgvStrings.AllowUserToAddRows = false;
        }
Ejemplo n.º 6
0
 private void DgvStringsKeyDown(object sender, KeyEventArgs e)
 {
     if ((e.KeyCode & Keys.Delete) == Keys.Delete)
     {
         if (m_dgvStrings.SelectedCells.Count > 0)
         {
             var cell = m_dgvStrings.SelectedCells[0];
             if (cell.ColumnIndex != 0)
             {
                 return;
             }
             uint index = (uint)cell.Value;
             m_dgvStrings.Rows.RemoveAt(cell.RowIndex);
             UCSManager.RemoveString(index);
         }
     }
 }
Ejemplo n.º 7
0
        private void DgvValuesSelectionChanged(object sender, EventArgs e)
        {
            if (m_dgvValues.SelectedRows.Count <= 0)
            {
                return;
            }
            DataGridViewRow row = m_dgvValues.SelectedRows[0];

            if ((row.Cells[2].Value as string) == "int")
            {
                var value = (uint)int.Parse(row.Cells[1].Value.ToString());
                m_rtbCurrentUCS.Text = UCSManager.HasString(value) ? UCSManager.GetString(value) : string.Empty;
            }
            else
            {
                m_rtbCurrentUCS.Text = string.Empty;
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Commits the changes made to the current UCS string.
        /// </summary>
        /// <returns></returns>
        private void CommitUCSEntry()
        {
            // check if index is still available
            var index = (uint)m_nupIndex.Value;

            string text = m_rtbUCSText.Text;

            if (m_rtbUCSText.Lines.Length > 1)
            {
                text = m_rtbUCSText.Lines.Aggregate(string.Empty, (current, s) => current + " " + s);
            }

            UCSManager.ModifyOrAddString(text, index);
            if (m_chkbxCopyToClipboard.Checked)
            {
                Clipboard.SetText(index.ToString());
            }
        }
Ejemplo n.º 9
0
        static void Main(string[] args)
        {
            if (!SetUpLoggingSystem())
            {
                UIHelper.ShowError("Could not set up logging system!");
            }
            if (!ConfigManager.SetupConfigSystem(Application.StartupPath + "\\plugins.config"))
            {
                UIHelper.ShowError("Could not set up config system! Make sure '" + Application.StartupPath + "\\plugins.config' exists.");
            }

            LoggingManager.SendMessage("Tool starting...");
            if (args.Length > 0)
            {
                var arguments = new StringBuilder();
                foreach (string arg in args)
                {
                    arguments.Append(' ');
                    arguments.Append(arg);
                }
                LoggingManager.SendMessage("Arguments: " + arguments);
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            AppDomain.CurrentDomain.UnhandledException += LogException;
            Application.ApplicationExit         += OnApplicationExit;
            ModManager.ApplicationExitRequested += ModManagerApplicationExitRequested;

            // determine last used directory
            string lastPath  = Properties.Settings.Default.sLastPath;
            string steamPath = null;

            if (string.IsNullOrEmpty(lastPath))
            {
                LoggingManager.SendMessage("Could not determine last used path, setting it to default path.");
                steamPath = MainManager.GetSteamPath();
                if (steamPath == null)
                {
                    AppEnd("User failed to provide a valid Steam path.");
                    return;
                }
                if (Directory.Exists(steamPath + GameConstants.RETRIBUTION_PATH_FROM_STEAM))
                {
                    lastPath = steamPath + GameConstants.RETRIBUTION_PATH_FROM_STEAM;
                }
                else if (Directory.Exists(steamPath + GameConstants.DOW2_PATH_FROM_STEAM))
                {
                    lastPath = steamPath + GameConstants.DOW2_PATH_FROM_STEAM;
                }
                else
                {
                    LoggingManager.SendWarning("Could neither find Retribution nor DoW2 directory; searched for " +
                                               steamPath + GameConstants.RETRIBUTION_PATH_FROM_STEAM + " and " +
                                               steamPath + GameConstants.DOW2_PATH_FROM_STEAM);
                    //AppEnd("Could neither find DoW2 nor Retribution");
                    lastPath = steamPath;
                }
            }
            ModManager.GameDirectory = lastPath;

            // get path to steam executable
            if (string.IsNullOrEmpty(Properties.Settings.Default.sSteamExecutable))
            {
                if (steamPath == null)
                {
                    steamPath = MainManager.GetSteamPath();
                    if (steamPath == null)
                    {
                        AppEnd("User failed to provide a valid Steam path.");
                        return;
                    }
                }
                Properties.Settings.Default.sSteamExecutable = steamPath + "\\steam.exe";
            }

            MainManager.SetAllowOpeningFilesTwice(Properties.Settings.Default.bAppAllowOpeningTwice);
            // create FrontEnd
            var mainDialog = new MainDialog();

            // load plugins
            // IMPORTANT: Create the FrontEnd BEFORE loading the plugins
            PluginManager.Path = Application.StartupPath + "\\plugins\\";
            PluginManager.LoadPlugins();
            PluginManager.LoadFileTypeSettings(Properties.Settings.Default.sFileTypes);

            if (string.IsNullOrEmpty(Properties.Settings.Default.sLanguage))
            {
                LoggingManager.SendMessage("No DoW2 language found, setting it to default (English)");
                MainManager.SetModLanguage("English");
            }
            else
            {
                MainManager.SetModLanguage(Properties.Settings.Default.sLanguage);
            }
            UCSManager.Init();

            mainDialog.HandleArgs(args);
            Application.Run(mainDialog);
        }