コード例 #1
0
ファイル: EditReps.cs プロジェクト: pratik07101999/FLHook
 private void buttonOK_Click(object sender, EventArgs e)
 {
     cfgFile.DeleteSection(itemNickName);
     foreach (UIDataSet.RepFixerItemFactionsRow faction in uIDataSet.RepFixerItemFactions.Rows)
     {
         string repStr = faction.Reputation;
         if (repStr == "-")
         {
             cfgFile.AddSetting(itemNickName, faction.ItemNickName, new object[] { });
         }
         else if (repStr.StartsWith("<"))
         {
             cfgFile.AddSetting(itemNickName, faction.ItemNickName, new object[] {
                 String.Format("{0:0.00}, {1}", Single.Parse(repStr.Substring(1)), MODE_REP_LESSTHAN)
             });
         }
         else if (repStr.StartsWith(">"))
         {
             cfgFile.AddSetting(itemNickName, faction.ItemNickName, new object[] {
                 String.Format("{0:0.00}, {1}", Single.Parse(repStr.Substring(1)), MODE_REP_GREATERTHAN)
             });
         }
         else if (repStr.StartsWith("="))
         {
             cfgFile.AddSetting(itemNickName, faction.ItemNickName, new object[] {
                 String.Format("{0:0.00}, {1}", Single.Parse(repStr.Substring(1)), MODE_REP_STATIC)
             });
         }
     }
     this.Close();
 }
コード例 #2
0
ファイル: Form1.cs プロジェクト: Friendly0Fire/FLHook
        private void ButtonSave_Click(object sender, EventArgs e)
        {
            cfgFile.AddSetting("Settings", "dllname", new object[] { "playercntl.dll" });
            cfgFile.AddSetting("Settings", "name", new object[] { "Player Control v1.0 by Cannon" });
            cfgFile.AddSetting("Settings", "shortname", new object[] { "playercntl" });
            cfgFile.AddSetting("Settings", "maypause", new object[] { "false" });
            cfgFile.AddSetting("Settings", "mayunload", new object[] { "true" });

            cfgFile.DeleteSection("Hooks");
            cfgFile.AddSettingNotUnique("Hooks", "hook", new object[] { "LoadSettings, 3" });
            cfgFile.AddSettingNotUnique("Hooks", "hook", new object[] { "ClearClientInfo, 3" });
            cfgFile.AddSettingNotUnique("Hooks", "hook", new object[] { "HkTimerCheckKick, 3" });
            cfgFile.AddSettingNotUnique("Hooks", "hook", new object[] { "SendDeathMsg, 3" });
            cfgFile.AddSettingNotUnique("Hooks", "hook", new object[] { "HkIServerImpl::PlayerLaunch, 3" });
            cfgFile.AddSettingNotUnique("Hooks", "hook", new object[] { "HkIServerImpl::BaseEnter, 3" });
            cfgFile.AddSettingNotUnique("Hooks", "hook", new object[] { "HkIServerImpl::LocationEnter, 3" });
            cfgFile.AddSettingNotUnique("Hooks", "hook", new object[] { "HkIServerImpl::DisConnect, 3" });
            cfgFile.AddSettingNotUnique("Hooks", "hook", new object[] { "HkIServerImpl::CharacterSelect, 3" });
            cfgFile.AddSettingNotUnique("Hooks", "hook", new object[] { "HkIServerImpl::JumpInComplete, 3" });
            cfgFile.AddSettingNotUnique("Hooks", "hook", new object[] { "HkIServerImpl::SystemSwitchOutComplete, 3" });
            cfgFile.AddSettingNotUnique("Hooks", "hook", new object[] { "HkIServerImpl::SPObjCollision, 3" });
            cfgFile.AddSettingNotUnique("Hooks", "hook", new object[] { "HkIServerImpl::GFGoodBuy, 3" });
            cfgFile.AddSettingNotUnique("Hooks", "hook", new object[] { "HkIServerImpl::ReqAddItem, 3" });
            cfgFile.AddSettingNotUnique("Hooks", "hook", new object[] { "HkIServerImpl::ReqChangeCash, 3" });
            cfgFile.AddSettingNotUnique("Hooks", "hook", new object[] { "HkIServerImpl::ReqSetCash, 3" });
            cfgFile.AddSettingNotUnique("Hooks", "hook", new object[] { "HkIServerImpl::ReqEquipment, 3" });
            cfgFile.AddSettingNotUnique("Hooks", "hook", new object[] { "HkIServerImpl::ReqHullStatus, 3" });
            cfgFile.AddSettingNotUnique("Hooks", "hook", new object[] { "HkIServerImpl::ReqShipArch, 3" });
            cfgFile.AddSettingNotUnique("Hooks", "hook", new object[] { "HkIServerImpl::TractorObjects, 3" });
            cfgFile.AddSettingNotUnique("Hooks", "hook", new object[] { "HkIServerImpl::SetTarget, 3" });
            cfgFile.AddSettingNotUnique("Hooks", "hook", new object[] { "HkIServerImpl::CharacterInfoReq, 3" });
            cfgFile.AddSettingNotUnique("Hooks", "hook", new object[] { "HkIServerImpl::SubmitChat, 3" });
            cfgFile.AddSettingNotUnique("Hooks", "hook", new object[] { "HkIServerImpl::GoTradelane, 3" });
            cfgFile.AddSettingNotUnique("Hooks", "hook", new object[] { "HkIServerImpl::StopTradelane, 3" });
            cfgFile.AddSettingNotUnique("Hooks", "hook", new object[] { "HkIEngine::Dock_Call, 3" });
            cfgFile.AddSettingNotUnique("Hooks", "hook", new object[] { "HkCb_AddDmgEntry, 3" });
            cfgFile.AddSettingNotUnique("Hooks", "hook", new object[] { "HkCb_SendChat, 3" });
            cfgFile.AddSettingNotUnique("Hooks", "hook", new object[] { "UserCmd_Process, 3" });
            cfgFile.AddSettingNotUnique("Hooks", "hook", new object[] { "UserCmd_Help, 3" });
            cfgFile.AddSettingNotUnique("Hooks", "hook", new object[] { "ExecuteCommandString_Callback, 3" });

            cfgFile.AddSetting("General", "EnableMoveChar", new object[] { checkBoxEnableMoveChar.Checked });
            cfgFile.AddSetting("General", "EnableRenameMe", new object[] { checkBoxEnableRenameMe.Checked });
            cfgFile.AddSetting("General", "EnablePimpShip", new object[] { checkBoxEnablePimpShip.Checked });
            cfgFile.AddSetting("General", "EnableRestart", new object[] { checkBoxEnableRestart.Checked });
            cfgFile.AddSetting("General", "EnableGiveCash", new object[] { checkBoxEnableGiveCash.Checked });
            cfgFile.AddSetting("General", "EnableDropRepAndMisc", new object[] { checkBoxEnableDropRepAndMisc.Checked });
            cfgFile.AddSetting("General", "EnableLoginSound", new object[] { checkBoxEnableLoginSound.Checked });
            cfgFile.AddSetting("General", "EnableWardrobe", new object[] { checkBoxEnableWardrobe.Checked });
            cfgFile.AddSetting("General", "EnableRestartCost", new object[] { checkBoxEnableRestartCost.Checked });
            cfgFile.AddSetting("General", "EnableMe", new object[] { checkBoxEnableMe.Checked });
            cfgFile.AddSetting("General", "EnableDo", new object[] { checkBoxEnableDo.Checked });

            cfgFile.AddSetting("General", "RepDropCost", new object[] { textBoxDropRepCost.Text });
            cfgFile.AddSetting("General", "StuckMsg", new object[] { textBoxStuckMsg.Text });
            cfgFile.AddSetting("General", "DiceMsg", new object[] { textBoxDiceMsg.Text });
            cfgFile.AddSetting("General", "CoinMsg", new object[] { textBoxCoinMsg.Text });
            cfgFile.AddSetting("General", "SmiteMusic", new object[] { textBoxSmiteMusic.Text });

            cfgFile.AddSetting("General", "DisconnectingPlayersRange", new object[] { textBoxDisconnectingPlayersRange.Text });
            cfgFile.AddSetting("General", "ReportDisconnectingPlayers", new object[] { checkBoxReportDisconnectingPlayers.Checked });
            cfgFile.AddSetting("General", "KillDisconnectingPlayers", new object[] { checkBoxKillDisconnectingPlayers.Checked });
            cfgFile.AddSetting("General", "LootDisconnectingPlayers", new object[] { checkBoxLootDisconnectingPlayers.Checked });
            cfgFile.AddSetting("General", "ReportDisconnectingPlayers", new object[] { checkBoxReportDisconnectingPlayers.Checked });
            cfgFile.AddSetting("General", "HullDropFactor", new object[] { textBoxHullDropFactor.Text });
            cfgFile.AddSetting("General", "CargoDropContainer", new object[] { textBoxCargoDropContainer.Text });
            cfgFile.AddSetting("General", "HullDrop1NickName", new object[] { textBoxHullDrop1NickName.Text });
            cfgFile.AddSetting("General", "HullDrop2NickName", new object[] { textBoxHullDrop2NickName.Text });
            cfgFile.AddSetting("General", "DisconnectMsg", new object[] { textBoxDisconnectMsg.Text });

            cfgFile.AddSetting("General", "SpinProtectionMass", new object[] { textBoxSpinProtectMass.Text });
            cfgFile.AddSetting("General", "SpinProtectionMultiplier", new object[] { textBoxSpinImpulseMultiplier.Text });

            cfgFile.AddSetting("General", "EnableEscort", new object[] { checkBoxEnableEscort.Checked });
            cfgFile.AddSetting("General", "EscortedShipMinimumMass", new object[] { textBoxEscortedShipMinimumMass.Text });
            cfgFile.AddSetting("General", "EscortedShipDamageFactor", new object[] { textBoxEscortedShipDamageFactor.Text });

            cfgFile.AddSetting("Rename", "RenameCost", new object[] { textBoxRenameCost.Text });
            cfgFile.AddSetting("Rename", "RenameTimeLimit", new object[] { textBoxRenameTimeLimit.Text });
            cfgFile.AddSetting("Rename", "MoveCost", new object[] { textBoxMoveCost.Text });
            cfgFile.AddSetting("Rename", "CharnameTag", new object[] { checkBoxCharnameTag.Checked });
            cfgFile.AddSetting("Rename", "MakeTagCost", new object[] { textBoxCharnameTagCost.Text });
            cfgFile.AddSetting("Rename", "AsciiCharnameOnly", new object[] { checkBoxAsciiCharnameOnly.Checked });

            cfgFile.AddSetting("GiveCash", "MinTransfer", new object[] { textBoxMinTransfer.Text });
            cfgFile.AddSetting("GiveCash", "MinTime", new object[] { textBoxMinTime.Text });
            cfgFile.AddSetting("GiveCash", "BlockedSystem", new object[] { textBoxBlockedSystem.Text });

            cfgFile.DeleteSection("ShipPimper");
            cfgFile.AddSettingNotUnique("ShipPimper", "cost", new object[] { textBoxPimpShipCost.Text });
            foreach (UIDataSet.ShipPimperItemListRow row in uIDataSet.ShipPimperItemList.Rows)
            {
                cfgFile.AddSettingNotUnique("ShipPimper", "equip", new object[] { row.ItemNickName });
            }
            foreach (UIDataSet.ShipPimperBaseListRow row in uIDataSet.ShipPimperBaseList.Rows)
            {
                cfgFile.AddSettingNotUnique("ShipPimper", "room", new object[] { row.ItemNickName });
            }

            cfgFile.AddSetting("RepFixer", "EnableRepFixUpdates", new object[] { checkBoxEnableRepFixUpdates.Checked });
            cfgFile.AddSetting("RepFixer", "LogRepFixUpdates", new object[] { checkBoxLogRepFixUpdates.Checked });
            cfgFile.AddSetting("RepFixer", "ItemMustBeMounted", new object[] { checkBoxItemMustBeMounted.Checked });
            cfgFile.DeleteSection("RepFixerItems");
            foreach (UIDataSet.RepFixerItemListRow row in uIDataSet.RepFixerItemList.Rows)
            {
                cfgFile.AddSetting("RepFixerItems", row.ItemNickName, new object[] { });
            }


            cfgFile.AddSetting("PurchaseRestrictions", "CheckIDRestrictions", new object[] { checkBoxCheckIDRestrictions.Checked });
            cfgFile.AddSetting("PurchaseRestrictions", "EnforceIDRestrictions", new object[] { checkBoxEnforceIDRestrictions.Checked });
            cfgFile.DeleteSection("ShipItemRestrictions");
            foreach (UIDataSet.ShipPurchaseRestrictionItemsRow row in uIDataSet.ShipPurchaseRestrictionItems.Rows)
            {
                if (row.ControlItemNickName.Length > 0)
                {
                    cfgFile.AddSettingNotUnique("ShipItemRestrictions", row.ItemNickName, new object[] { row.ControlItemNickName });
                }
            }

            cfgFile.DeleteSection("GoodItemRestrictions");
            foreach (UIDataSet.EquipPurchaseRestrictionItemsRow row in uIDataSet.EquipPurchaseRestrictionItems.Rows)
            {
                if (row.ControlItemNickName.Length > 0)
                {
                    cfgFile.AddSettingNotUnique("GoodItemRestrictions", row.ItemNickName, new object[] { row.ControlItemNickName });
                }
            }

            cfgFile.DeleteSection("NoBuy");
            foreach (UIDataSet.BaseGoodNoBuyListRow row in uIDataSet.BaseGoodNoBuyList.Rows)
            {
                if (row.GoodNickName.Length > 0)
                {
                    cfgFile.AddSettingNotUnique("NoBuy", row.BaseNickName, new object[] { row.GoodNickName });
                }
            }

            cfgFile.DeleteSection("SystemSensor");
            foreach (UIDataSet.SysSensorListRow row in uIDataSet.SysSensorList.Rows)
            {
                if (row.EquipNickName.Length > 0)
                {
                    cfgFile.AddSettingNotUnique("SystemSensor", row.SystemNickName, new object[] { row.EquipNickName, row.NetworkID });
                }
            }

            cfgFile.AddSetting("Message", "CustomHelp", new object[] { checkBoxCustomHelp.Checked });
            cfgFile.AddSetting("Message", "CmdEcho", new object[] { checkBoxCmdEcho.Checked });
            cfgFile.AddSetting("Message", "CmdHide", new object[] { checkBoxCmdHide.Checked });
            cfgFile.AddSetting("Message", "CmdEchoStyle", new object[] { textBoxCmdEchoStyle.Text });

            cfgFile.AddSetting("Message", "SpecialBannerDelay", new object[] { textBoxSpecialBannerDelay.Text });
            cfgFile.AddSetting("Message", "StandardBannerDelay", new object[] { textBoxStandardBannerDelay.Text });

            cfgFile.DeleteSection("Help");
            foreach (string line in richTextBoxHelpLines.Lines)
            {
                if (line.Length > 0)
                {
                    cfgFile.AddSettingNotUnique("Help", line, new object[] { });
                }
            }

            cfgFile.DeleteSection("SwearWords");
            foreach (string line in richTextBoxSwearWords.Lines)
            {
                if (line.Length > 0)
                {
                    cfgFile.AddSettingNotUnique("SwearWords", "Text", new object[] { line });
                }
            }

            cfgFile.DeleteSection("GreetingBanner");
            foreach (string line in richTextBoxGreetingBannerLines.Lines)
            {
                if (line.Length > 0)
                {
                    cfgFile.AddSettingNotUnique("GreetingBanner", "Text", new object[] { line });
                }
            }

            cfgFile.DeleteSection("SpecialBanner");
            foreach (string line in richTextBoxSpecialBannerLines.Lines)
            {
                if (line.Length > 0)
                {
                    cfgFile.AddSettingNotUnique("SpecialBanner", "Text", new object[] { line });
                }
            }

            while (cfgFile.DeleteSection("StandardBanner"))
            {
                ;
            }
            foreach (UIDataSet.StandardBannerListRow row in uIDataSet.StandardBannerList.Rows)
            {
                var sect = new FLDataFile.Section()
                {
                    sectionName = "StandardBanner"
                };
                foreach (string line in row.BannerText.Split(new char[] { '\r', '\n' }))
                {
                    if (line.Length > 0)
                    {
                        sect.settings.Add(new FLDataFile.Setting("StandardBanner", "Text", "", new object[] { line }));
                    }
                }
                cfgFile.sections.Add(sect);
            }

            cfgFile.DeleteSection("Sounds");
            foreach (string line in richTextBoxSounds.Lines)
            {
                if (line.Length > 0)
                {
                    cfgFile.AddSettingNotUnique("Sounds", "sound", new object[] { line });
                }
            }

            cfgFile.DeleteSection("Wardrobe");
            foreach (string line in richTextBoxHeads.Lines)
            {
                if (line.Length > 0)
                {
                    cfgFile.AddSettingNotUnique("Wardrobe", "head", new object[] { line });
                }
            }
            foreach (string line in richTextBoxBodies.Lines)
            {
                if (line.Length > 0)
                {
                    cfgFile.AddSettingNotUnique("Wardrobe", "body", new object[] { line });
                }
            }

            cfgFile.DeleteSection("Restart");
            cfgFile.AddSetting("Restart", "MaxRank", new object[] { textBoxRestartMaxRank.Text });
            cfgFile.AddSetting("Restart", "MaxCash", new object[] { textBoxRestartMaxCash.Text });
            foreach (string line in richTextBoxRestarts.Lines)
            {
                if (line.Length > 0)
                {
                    cfgFile.AddSettingNotUnique("Restart", "restart", new object[] { line });
                }
            }

            try
            {
                cfgFile.SaveSettings(cfgFilePath, false);
                MessageBox.Show("File saved to " + cfgFilePath, "File saved");
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error " + ex.Message, "Unable to save ini file");
            }
        }