├── .gitattributes ├── .gitignore ├── App.config ├── Def.cs ├── DefSearcher.cs ├── Form1.Designer.cs ├── Form1.cs ├── Form1.resx ├── Mod.cs ├── Patch.cs ├── Preview ├── rimdev_prev1.png ├── rimdev_prev2.png └── rimdev_prev3.png ├── Program.cs ├── Properties ├── AssemblyInfo.cs ├── Resources.Designer.cs ├── Resources.resx ├── Settings.Designer.cs └── Settings.settings ├── RecipeDef.cs ├── Resources └── nopic.gif ├── RimDef.csproj ├── RimDef.sln ├── SearchCore.cs ├── ThingDef.cs └── XMLReader.cs /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | [Xx]64/ 19 | [Xx]86/ 20 | [Bb]uild/ 21 | bld/ 22 | [Bb]in/ 23 | [Oo]bj/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | # Uncomment if you have tasks that create the project's static files in wwwroot 28 | #wwwroot/ 29 | 30 | # MSTest test Results 31 | [Tt]est[Rr]esult*/ 32 | [Bb]uild[Ll]og.* 33 | 34 | # NUNIT 35 | *.VisualState.xml 36 | TestResult.xml 37 | 38 | # Build Results of an ATL Project 39 | [Dd]ebugPS/ 40 | [Rr]eleasePS/ 41 | dlldata.c 42 | 43 | # DNX 44 | project.lock.json 45 | artifacts/ 46 | 47 | *_i.c 48 | *_p.c 49 | *_i.h 50 | *.ilk 51 | *.meta 52 | *.obj 53 | *.pch 54 | *.pdb 55 | *.pgc 56 | *.pgd 57 | *.rsp 58 | *.sbr 59 | *.tlb 60 | *.tli 61 | *.tlh 62 | *.tmp 63 | *.tmp_proj 64 | *.log 65 | *.vspscc 66 | *.vssscc 67 | .builds 68 | *.pidb 69 | *.svclog 70 | *.scc 71 | 72 | # Chutzpah Test files 73 | _Chutzpah* 74 | 75 | # Visual C++ cache files 76 | ipch/ 77 | *.aps 78 | *.ncb 79 | *.opendb 80 | *.opensdf 81 | *.sdf 82 | *.cachefile 83 | *.VC.db 84 | 85 | # Visual Studio profiler 86 | *.psess 87 | *.vsp 88 | *.vspx 89 | *.sap 90 | 91 | # TFS 2012 Local Workspace 92 | $tf/ 93 | 94 | # Guidance Automation Toolkit 95 | *.gpState 96 | 97 | # ReSharper is a .NET coding add-in 98 | _ReSharper*/ 99 | *.[Rr]e[Ss]harper 100 | *.DotSettings.user 101 | 102 | # JustCode is a .NET coding add-in 103 | .JustCode 104 | 105 | # TeamCity is a build add-in 106 | _TeamCity* 107 | 108 | # DotCover is a Code Coverage Tool 109 | *.dotCover 110 | 111 | # NCrunch 112 | _NCrunch_* 113 | .*crunch*.local.xml 114 | nCrunchTemp_* 115 | 116 | # MightyMoose 117 | *.mm.* 118 | AutoTest.Net/ 119 | 120 | # Web workbench (sass) 121 | .sass-cache/ 122 | 123 | # Installshield output folder 124 | [Ee]xpress/ 125 | 126 | # DocProject is a documentation generator add-in 127 | DocProject/buildhelp/ 128 | DocProject/Help/*.HxT 129 | DocProject/Help/*.HxC 130 | DocProject/Help/*.hhc 131 | DocProject/Help/*.hhk 132 | DocProject/Help/*.hhp 133 | DocProject/Help/Html2 134 | DocProject/Help/html 135 | 136 | # Click-Once directory 137 | publish/ 138 | 139 | # Publish Web Output 140 | *.[Pp]ublish.xml 141 | *.azurePubxml 142 | 143 | # TODO: Un-comment the next line if you do not want to checkin 144 | # your web deploy settings because they may include unencrypted 145 | # passwords 146 | #*.pubxml 147 | *.publishproj 148 | 149 | # NuGet Packages 150 | *.nupkg 151 | # The packages folder can be ignored because of Package Restore 152 | **/packages/* 153 | # except build/, which is used as an MSBuild target. 154 | !**/packages/build/ 155 | # Uncomment if necessary however generally it will be regenerated when needed 156 | #!**/packages/repositories.config 157 | # NuGet v3's project.json files produces more ignoreable files 158 | *.nuget.props 159 | *.nuget.targets 160 | 161 | # Microsoft Azure Build Output 162 | csx/ 163 | *.build.csdef 164 | 165 | # Microsoft Azure Emulator 166 | ecf/ 167 | rcf/ 168 | 169 | # Windows Store app package directory 170 | AppPackages/ 171 | BundleArtifacts/ 172 | 173 | # Visual Studio cache files 174 | # files ending in .cache can be ignored 175 | *.[Cc]ache 176 | # but keep track of directories ending in .cache 177 | !*.[Cc]ache/ 178 | 179 | # Others 180 | ClientBin/ 181 | [Ss]tyle[Cc]op.* 182 | ~$* 183 | *~ 184 | *.dbmdl 185 | *.dbproj.schemaview 186 | *.pfx 187 | *.publishsettings 188 | node_modules/ 189 | orleans.codegen.cs 190 | 191 | # RIA/Silverlight projects 192 | Generated_Code/ 193 | 194 | # Backup & report files from converting an old project file 195 | # to a newer Visual Studio version. Backup files are not needed, 196 | # because we have git ;-) 197 | _UpgradeReport_Files/ 198 | Backup*/ 199 | UpgradeLog*.XML 200 | UpgradeLog*.htm 201 | 202 | # SQL Server files 203 | *.mdf 204 | *.ldf 205 | 206 | # Business Intelligence projects 207 | *.rdl.data 208 | *.bim.layout 209 | *.bim_*.settings 210 | 211 | # Microsoft Fakes 212 | FakesAssemblies/ 213 | 214 | # GhostDoc plugin setting file 215 | *.GhostDoc.xml 216 | 217 | # Node.js Tools for Visual Studio 218 | .ntvs_analysis.dat 219 | 220 | # Visual Studio 6 build log 221 | *.plg 222 | 223 | # Visual Studio 6 workspace options file 224 | *.opt 225 | 226 | # Visual Studio LightSwitch build output 227 | **/*.HTMLClient/GeneratedArtifacts 228 | **/*.DesktopClient/GeneratedArtifacts 229 | **/*.DesktopClient/ModelManifest.xml 230 | **/*.Server/GeneratedArtifacts 231 | **/*.Server/ModelManifest.xml 232 | _Pvt_Extensions 233 | 234 | # LightSwitch generated files 235 | GeneratedArtifacts/ 236 | ModelManifest.xml 237 | 238 | # Paket dependency manager 239 | .paket/paket.exe 240 | 241 | # FAKE - F# Make 242 | .fake/ 243 | -------------------------------------------------------------------------------- /App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Def.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace RimDef 4 | { 5 | public class Def 6 | { 7 | public Mod mod; 8 | 9 | public string defType; 10 | public string defName; 11 | public string label; 12 | public string description; 13 | public string texture; 14 | public string xml; 15 | public string file; 16 | public bool enabled; 17 | 18 | public List details = new List(); 19 | } 20 | } -------------------------------------------------------------------------------- /DefSearcher.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using SimpleSearch; 7 | 8 | namespace RimDef 9 | { 10 | class DefSearcher : Searcher 11 | { 12 | private List Defs { get; set; } 13 | 14 | public DefSearcher(List defs) 15 | { 16 | //Dummy up some data here... 17 | //Defs = new List(); 18 | this.Defs = defs; 19 | } 20 | 21 | public override IEnumerable Search(string searchTerm) 22 | { 23 | var result = Defs.Where(p => p.label.ToLower().Contains( 24 | searchTerm.ToLower()) /*|| p.description.ToLower().Contains(searchTerm.ToLower())*/) 25 | .Select(p => new SearchResult 26 | { 27 | //Mod = p.modName, 28 | //Label = p.label, 29 | //Description = p.description 30 | Definition = p 31 | 32 | }).ToList(); 33 | 34 | return result; 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Form1.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace RimDef 2 | { 3 | partial class Form1 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.lbMods = new System.Windows.Forms.ListBox(); 32 | this.lbDefTypes = new System.Windows.Forms.ListBox(); 33 | this.lwDefs = new System.Windows.Forms.ListView(); 34 | this.lwRecipe = new System.Windows.Forms.ListView(); 35 | this.pictureBox1 = new System.Windows.Forms.PictureBox(); 36 | this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog(); 37 | this.btnGameDir = new System.Windows.Forms.Button(); 38 | this.txtRimDir = new System.Windows.Forms.TextBox(); 39 | this.btnLoad = new System.Windows.Forms.Button(); 40 | this.txtSearch = new System.Windows.Forms.TextBox(); 41 | this.btnSearch = new System.Windows.Forms.Button(); 42 | this.thingDesc = new System.Windows.Forms.TextBox(); 43 | this.xmlView = new System.Windows.Forms.TextBox(); 44 | this.label1 = new System.Windows.Forms.Label(); 45 | this.label2 = new System.Windows.Forms.Label(); 46 | this.label3 = new System.Windows.Forms.Label(); 47 | this.label5 = new System.Windows.Forms.Label(); 48 | this.gbDesc = new System.Windows.Forms.GroupBox(); 49 | this.gbRecipe = new System.Windows.Forms.GroupBox(); 50 | this.cbOnlyActiveMods = new System.Windows.Forms.CheckBox(); 51 | this.label6 = new System.Windows.Forms.Label(); 52 | this.lbPatches = new System.Windows.Forms.ListBox(); 53 | this.cbVersion = new System.Windows.Forms.ComboBox(); 54 | this.btnDisable = new System.Windows.Forms.Button(); 55 | this.btnEnable = new System.Windows.Forms.Button(); 56 | this.lblXmlPath = new System.Windows.Forms.Label(); 57 | this.lblPatchMods = new System.Windows.Forms.Label(); 58 | this.lblXPath = new System.Windows.Forms.Label(); 59 | this.txtModDir = new System.Windows.Forms.TextBox(); 60 | this.btnModsDir = new System.Windows.Forms.Button(); 61 | ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); 62 | this.gbDesc.SuspendLayout(); 63 | this.gbRecipe.SuspendLayout(); 64 | this.SuspendLayout(); 65 | // 66 | // lbMods 67 | // 68 | this.lbMods.FormattingEnabled = true; 69 | this.lbMods.ItemHeight = 16; 70 | this.lbMods.Location = new System.Drawing.Point(25, 123); 71 | this.lbMods.Margin = new System.Windows.Forms.Padding(4); 72 | this.lbMods.Name = "lbMods"; 73 | this.lbMods.Size = new System.Drawing.Size(220, 660); 74 | this.lbMods.TabIndex = 0; 75 | this.lbMods.SelectedIndexChanged += new System.EventHandler(this.lbMods_SelectedIndexChanged); 76 | // 77 | // lbDefTypes 78 | // 79 | this.lbDefTypes.FormattingEnabled = true; 80 | this.lbDefTypes.ItemHeight = 16; 81 | this.lbDefTypes.Location = new System.Drawing.Point(265, 123); 82 | this.lbDefTypes.Margin = new System.Windows.Forms.Padding(4); 83 | this.lbDefTypes.Name = "lbDefTypes"; 84 | this.lbDefTypes.Size = new System.Drawing.Size(200, 228); 85 | this.lbDefTypes.TabIndex = 1; 86 | this.lbDefTypes.SelectedIndexChanged += new System.EventHandler(this.lbDefTypes_SelectedIndexChanged); 87 | // 88 | // lwDefs 89 | // 90 | this.lwDefs.FullRowSelect = true; 91 | this.lwDefs.GridLines = true; 92 | this.lwDefs.HideSelection = false; 93 | this.lwDefs.Location = new System.Drawing.Point(760, 123); 94 | this.lwDefs.Margin = new System.Windows.Forms.Padding(4); 95 | this.lwDefs.Name = "lwDefs"; 96 | this.lwDefs.Size = new System.Drawing.Size(530, 228); 97 | this.lwDefs.TabIndex = 2; 98 | this.lwDefs.UseCompatibleStateImageBehavior = false; 99 | this.lwDefs.View = System.Windows.Forms.View.Details; 100 | this.lwDefs.SelectedIndexChanged += new System.EventHandler(this.lwDefs_SelectedIndexChanged); 101 | // 102 | // lwRecipe 103 | // 104 | this.lwRecipe.GridLines = true; 105 | this.lwRecipe.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; 106 | this.lwRecipe.HideSelection = false; 107 | this.lwRecipe.Location = new System.Drawing.Point(0, 25); 108 | this.lwRecipe.Margin = new System.Windows.Forms.Padding(4); 109 | this.lwRecipe.Name = "lwRecipe"; 110 | this.lwRecipe.Size = new System.Drawing.Size(470, 98); 111 | this.lwRecipe.TabIndex = 3; 112 | this.lwRecipe.UseCompatibleStateImageBehavior = false; 113 | this.lwRecipe.View = System.Windows.Forms.View.Details; 114 | // 115 | // pictureBox1 116 | // 117 | this.pictureBox1.Location = new System.Drawing.Point(602, 430); 118 | this.pictureBox1.Margin = new System.Windows.Forms.Padding(4); 119 | this.pictureBox1.Name = "pictureBox1"; 120 | this.pictureBox1.Size = new System.Drawing.Size(133, 123); 121 | this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; 122 | this.pictureBox1.TabIndex = 4; 123 | this.pictureBox1.TabStop = false; 124 | this.pictureBox1.Visible = false; 125 | // 126 | // btnGameDir 127 | // 128 | this.btnGameDir.Location = new System.Drawing.Point(388, 38); 129 | this.btnGameDir.Margin = new System.Windows.Forms.Padding(4); 130 | this.btnGameDir.Name = "btnGameDir"; 131 | this.btnGameDir.Size = new System.Drawing.Size(33, 28); 132 | this.btnGameDir.TabIndex = 5; 133 | this.btnGameDir.Text = "..."; 134 | this.btnGameDir.UseVisualStyleBackColor = true; 135 | this.btnGameDir.Click += new System.EventHandler(this.btnGameDir_Click); 136 | // 137 | // txtRimDir 138 | // 139 | this.txtRimDir.Location = new System.Drawing.Point(80, 40); 140 | this.txtRimDir.Margin = new System.Windows.Forms.Padding(4); 141 | this.txtRimDir.Name = "txtRimDir"; 142 | this.txtRimDir.Size = new System.Drawing.Size(300, 22); 143 | this.txtRimDir.TabIndex = 6; 144 | // 145 | // btnLoad 146 | // 147 | this.btnLoad.Location = new System.Drawing.Point(429, 40); 148 | this.btnLoad.Margin = new System.Windows.Forms.Padding(4); 149 | this.btnLoad.Name = "btnLoad"; 150 | this.btnLoad.Size = new System.Drawing.Size(67, 28); 151 | this.btnLoad.TabIndex = 7; 152 | this.btnLoad.Text = "Load"; 153 | this.btnLoad.UseVisualStyleBackColor = true; 154 | this.btnLoad.Click += new System.EventHandler(this.btnLoad_Click); 155 | // 156 | // txtSearch 157 | // 158 | this.txtSearch.Location = new System.Drawing.Point(1057, 89); 159 | this.txtSearch.Margin = new System.Windows.Forms.Padding(4); 160 | this.txtSearch.Name = "txtSearch"; 161 | this.txtSearch.Size = new System.Drawing.Size(159, 22); 162 | this.txtSearch.TabIndex = 8; 163 | this.txtSearch.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtSearch_KeyDown); 164 | // 165 | // btnSearch 166 | // 167 | this.btnSearch.Location = new System.Drawing.Point(1225, 87); 168 | this.btnSearch.Margin = new System.Windows.Forms.Padding(4); 169 | this.btnSearch.Name = "btnSearch"; 170 | this.btnSearch.Size = new System.Drawing.Size(67, 28); 171 | this.btnSearch.TabIndex = 9; 172 | this.btnSearch.Text = "Search"; 173 | this.btnSearch.UseVisualStyleBackColor = true; 174 | this.btnSearch.Click += new System.EventHandler(this.btnSearch_Click); 175 | // 176 | // thingDesc 177 | // 178 | this.thingDesc.Location = new System.Drawing.Point(0, 20); 179 | this.thingDesc.Margin = new System.Windows.Forms.Padding(4); 180 | this.thingDesc.Multiline = true; 181 | this.thingDesc.Name = "thingDesc"; 182 | this.thingDesc.ReadOnly = true; 183 | this.thingDesc.Size = new System.Drawing.Size(317, 124); 184 | this.thingDesc.TabIndex = 10; 185 | // 186 | // xmlView 187 | // 188 | this.xmlView.Location = new System.Drawing.Point(760, 430); 189 | this.xmlView.Margin = new System.Windows.Forms.Padding(4); 190 | this.xmlView.Multiline = true; 191 | this.xmlView.Name = "xmlView"; 192 | this.xmlView.ReadOnly = true; 193 | this.xmlView.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; 194 | this.xmlView.Size = new System.Drawing.Size(630, 353); 195 | this.xmlView.TabIndex = 11; 196 | // 197 | // label1 198 | // 199 | this.label1.AutoSize = true; 200 | this.label1.Location = new System.Drawing.Point(22, 73); 201 | this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); 202 | this.label1.Name = "label1"; 203 | this.label1.Size = new System.Drawing.Size(41, 16); 204 | this.label1.TabIndex = 12; 205 | this.label1.Text = "Mods"; 206 | // 207 | // label2 208 | // 209 | this.label2.AutoSize = true; 210 | this.label2.Location = new System.Drawing.Point(262, 103); 211 | this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); 212 | this.label2.Name = "label2"; 213 | this.label2.Size = new System.Drawing.Size(35, 16); 214 | this.label2.TabIndex = 13; 215 | this.label2.Text = "Defs"; 216 | // 217 | // label3 218 | // 219 | this.label3.AutoSize = true; 220 | this.label3.Location = new System.Drawing.Point(22, 42); 221 | this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); 222 | this.label3.Name = "label3"; 223 | this.label3.Size = new System.Drawing.Size(44, 16); 224 | this.label3.TabIndex = 14; 225 | this.label3.Text = "Game"; 226 | // 227 | // label5 228 | // 229 | this.label5.AutoSize = true; 230 | this.label5.Location = new System.Drawing.Point(757, 103); 231 | this.label5.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); 232 | this.label5.Name = "label5"; 233 | this.label5.Size = new System.Drawing.Size(52, 16); 234 | this.label5.TabIndex = 16; 235 | this.label5.Text = "Content"; 236 | // 237 | // gbDesc 238 | // 239 | this.gbDesc.Controls.Add(this.thingDesc); 240 | this.gbDesc.Location = new System.Drawing.Point(265, 410); 241 | this.gbDesc.Margin = new System.Windows.Forms.Padding(4); 242 | this.gbDesc.Name = "gbDesc"; 243 | this.gbDesc.Padding = new System.Windows.Forms.Padding(4); 244 | this.gbDesc.Size = new System.Drawing.Size(317, 143); 245 | this.gbDesc.TabIndex = 19; 246 | this.gbDesc.TabStop = false; 247 | this.gbDesc.Text = "Description"; 248 | this.gbDesc.Visible = false; 249 | // 250 | // gbRecipe 251 | // 252 | this.gbRecipe.Controls.Add(this.lwRecipe); 253 | this.gbRecipe.Location = new System.Drawing.Point(265, 660); 254 | this.gbRecipe.Margin = new System.Windows.Forms.Padding(4); 255 | this.gbRecipe.Name = "gbRecipe"; 256 | this.gbRecipe.Padding = new System.Windows.Forms.Padding(4); 257 | this.gbRecipe.Size = new System.Drawing.Size(470, 123); 258 | this.gbRecipe.TabIndex = 20; 259 | this.gbRecipe.TabStop = false; 260 | this.gbRecipe.Text = "Ingredients"; 261 | this.gbRecipe.Visible = false; 262 | // 263 | // cbOnlyActiveMods 264 | // 265 | this.cbOnlyActiveMods.AutoSize = true; 266 | this.cbOnlyActiveMods.Location = new System.Drawing.Point(502, 70); 267 | this.cbOnlyActiveMods.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); 268 | this.cbOnlyActiveMods.Name = "cbOnlyActiveMods"; 269 | this.cbOnlyActiveMods.Size = new System.Drawing.Size(93, 20); 270 | this.cbOnlyActiveMods.TabIndex = 21; 271 | this.cbOnlyActiveMods.Text = "only active"; 272 | this.cbOnlyActiveMods.UseVisualStyleBackColor = true; 273 | // 274 | // label6 275 | // 276 | this.label6.AutoSize = true; 277 | this.label6.Location = new System.Drawing.Point(498, 103); 278 | this.label6.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); 279 | this.label6.Name = "label6"; 280 | this.label6.Size = new System.Drawing.Size(56, 16); 281 | this.label6.TabIndex = 26; 282 | this.label6.Text = "Patches"; 283 | // 284 | // lbPatches 285 | // 286 | this.lbPatches.FormattingEnabled = true; 287 | this.lbPatches.ItemHeight = 16; 288 | this.lbPatches.Location = new System.Drawing.Point(501, 123); 289 | this.lbPatches.Margin = new System.Windows.Forms.Padding(4); 290 | this.lbPatches.Name = "lbPatches"; 291 | this.lbPatches.Size = new System.Drawing.Size(220, 228); 292 | this.lbPatches.TabIndex = 25; 293 | this.lbPatches.SelectedIndexChanged += new System.EventHandler(this.lbPatches_SelectedIndexChanged); 294 | // 295 | // cbVersion 296 | // 297 | this.cbVersion.FormattingEnabled = true; 298 | this.cbVersion.Location = new System.Drawing.Point(429, 68); 299 | this.cbVersion.Name = "cbVersion"; 300 | this.cbVersion.Size = new System.Drawing.Size(67, 24); 301 | this.cbVersion.TabIndex = 27; 302 | this.cbVersion.SelectedIndexChanged += new System.EventHandler(this.cbVersion_SelectedIndexChanged); 303 | // 304 | // btnDisable 305 | // 306 | this.btnDisable.Enabled = false; 307 | this.btnDisable.Location = new System.Drawing.Point(1215, 358); 308 | this.btnDisable.Name = "btnDisable"; 309 | this.btnDisable.Size = new System.Drawing.Size(75, 23); 310 | this.btnDisable.TabIndex = 28; 311 | this.btnDisable.Text = "Disable"; 312 | this.btnDisable.UseVisualStyleBackColor = true; 313 | this.btnDisable.Click += new System.EventHandler(this.btnDisable_Click); 314 | // 315 | // btnEnable 316 | // 317 | this.btnEnable.Enabled = false; 318 | this.btnEnable.Location = new System.Drawing.Point(1141, 358); 319 | this.btnEnable.Name = "btnEnable"; 320 | this.btnEnable.Size = new System.Drawing.Size(75, 23); 321 | this.btnEnable.TabIndex = 29; 322 | this.btnEnable.Text = "Enable"; 323 | this.btnEnable.UseVisualStyleBackColor = true; 324 | this.btnEnable.Click += new System.EventHandler(this.btnEnable_Click); 325 | // 326 | // lblXmlPath 327 | // 328 | this.lblXmlPath.AutoSize = true; 329 | this.lblXmlPath.Location = new System.Drawing.Point(760, 390); 330 | this.lblXmlPath.Name = "lblXmlPath"; 331 | this.lblXmlPath.Size = new System.Drawing.Size(32, 16); 332 | this.lblXmlPath.TabIndex = 30; 333 | this.lblXmlPath.Text = "File:"; 334 | // 335 | // lblPatchMods 336 | // 337 | this.lblPatchMods.AutoSize = true; 338 | this.lblPatchMods.Location = new System.Drawing.Point(482, 358); 339 | this.lblPatchMods.Name = "lblPatchMods"; 340 | this.lblPatchMods.Size = new System.Drawing.Size(0, 16); 341 | this.lblPatchMods.TabIndex = 31; 342 | // 343 | // lblXPath 344 | // 345 | this.lblXPath.AutoSize = true; 346 | this.lblXPath.Location = new System.Drawing.Point(760, 410); 347 | this.lblXPath.Name = "lblXPath"; 348 | this.lblXPath.Size = new System.Drawing.Size(45, 16); 349 | this.lblXPath.TabIndex = 32; 350 | this.lblXPath.Text = "XPath:"; 351 | // 352 | // txtModDir 353 | // 354 | this.txtModDir.Location = new System.Drawing.Point(80, 70); 355 | this.txtModDir.Margin = new System.Windows.Forms.Padding(4); 356 | this.txtModDir.Name = "txtModDir"; 357 | this.txtModDir.Size = new System.Drawing.Size(300, 22); 358 | this.txtModDir.TabIndex = 33; 359 | // 360 | // btnModsDir 361 | // 362 | this.btnModsDir.Location = new System.Drawing.Point(388, 64); 363 | this.btnModsDir.Margin = new System.Windows.Forms.Padding(4); 364 | this.btnModsDir.Name = "btnModsDir"; 365 | this.btnModsDir.Size = new System.Drawing.Size(33, 28); 366 | this.btnModsDir.TabIndex = 34; 367 | this.btnModsDir.Text = "..."; 368 | this.btnModsDir.UseVisualStyleBackColor = true; 369 | this.btnModsDir.Click += new System.EventHandler(this.btnModsDir_Click); 370 | // 371 | // Form1 372 | // 373 | this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); 374 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 375 | this.ClientSize = new System.Drawing.Size(1422, 853); 376 | this.Controls.Add(this.btnModsDir); 377 | this.Controls.Add(this.txtModDir); 378 | this.Controls.Add(this.lblXPath); 379 | this.Controls.Add(this.lblPatchMods); 380 | this.Controls.Add(this.lblXmlPath); 381 | this.Controls.Add(this.btnEnable); 382 | this.Controls.Add(this.btnDisable); 383 | this.Controls.Add(this.cbVersion); 384 | this.Controls.Add(this.label6); 385 | this.Controls.Add(this.lbPatches); 386 | this.Controls.Add(this.cbOnlyActiveMods); 387 | this.Controls.Add(this.gbRecipe); 388 | this.Controls.Add(this.gbDesc); 389 | this.Controls.Add(this.label5); 390 | this.Controls.Add(this.label3); 391 | this.Controls.Add(this.label2); 392 | this.Controls.Add(this.label1); 393 | this.Controls.Add(this.xmlView); 394 | this.Controls.Add(this.btnSearch); 395 | this.Controls.Add(this.txtSearch); 396 | this.Controls.Add(this.btnLoad); 397 | this.Controls.Add(this.txtRimDir); 398 | this.Controls.Add(this.btnGameDir); 399 | this.Controls.Add(this.pictureBox1); 400 | this.Controls.Add(this.lwDefs); 401 | this.Controls.Add(this.lbDefTypes); 402 | this.Controls.Add(this.lbMods); 403 | this.Margin = new System.Windows.Forms.Padding(4); 404 | this.Name = "Form1"; 405 | this.Text = "RimDef"; 406 | this.Load += new System.EventHandler(this.Form1_Load); 407 | ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); 408 | this.gbDesc.ResumeLayout(false); 409 | this.gbDesc.PerformLayout(); 410 | this.gbRecipe.ResumeLayout(false); 411 | this.ResumeLayout(false); 412 | this.PerformLayout(); 413 | 414 | } 415 | 416 | #endregion 417 | 418 | private System.Windows.Forms.ListBox lbMods; 419 | private System.Windows.Forms.ListBox lbDefTypes; 420 | private System.Windows.Forms.ListView lwDefs; 421 | private System.Windows.Forms.ListView lwRecipe; 422 | private System.Windows.Forms.PictureBox pictureBox1; 423 | private System.Windows.Forms.FolderBrowserDialog folderBrowserDialog1; 424 | private System.Windows.Forms.Button btnGameDir; 425 | private System.Windows.Forms.TextBox txtRimDir; 426 | private System.Windows.Forms.Button btnLoad; 427 | private System.Windows.Forms.TextBox txtSearch; 428 | private System.Windows.Forms.Button btnSearch; 429 | private System.Windows.Forms.TextBox thingDesc; 430 | private System.Windows.Forms.TextBox xmlView; 431 | private System.Windows.Forms.Label label1; 432 | private System.Windows.Forms.Label label2; 433 | private System.Windows.Forms.Label label3; 434 | private System.Windows.Forms.Label label5; 435 | private System.Windows.Forms.GroupBox gbDesc; 436 | private System.Windows.Forms.GroupBox gbRecipe; 437 | private System.Windows.Forms.CheckBox cbOnlyActiveMods; 438 | //private System.Windows.Forms.Label lblPath; 439 | private System.Windows.Forms.Label label6; 440 | private System.Windows.Forms.ListBox lbPatches; 441 | private System.Windows.Forms.ComboBox cbVersion; 442 | private System.Windows.Forms.Button btnDisable; 443 | private System.Windows.Forms.Button btnEnable; 444 | private System.Windows.Forms.Label lblXmlPath; 445 | private System.Windows.Forms.Label lblPatchMods; 446 | private System.Windows.Forms.Label lblXPath; 447 | private System.Windows.Forms.TextBox txtModDir; 448 | private System.Windows.Forms.Button btnModsDir; 449 | } 450 | } 451 | 452 | -------------------------------------------------------------------------------- /Form1.cs: -------------------------------------------------------------------------------- 1 | using SimpleSearch; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Drawing; 5 | using System.IO; 6 | using System.Security.Cryptography; 7 | using System.Windows.Forms; 8 | 9 | namespace RimDef 10 | { 11 | public partial class Form1 : Form 12 | { 13 | XMLReader xmlReader = new XMLReader(); 14 | 15 | List defs = new List(); 16 | List defsView = new List(); 17 | 18 | private List patches = new List(); 19 | private List patchesView = new List(); 20 | 21 | private ListView lwDetails = new ListView(); 22 | 23 | string[] versions = { "1.0", "1.1", "1.2", "1.3", "1.4", "1.5" }; 24 | string[] vanilla = { "Core", "Royalty", "Ideology", "Anomaly", "Biotech" }; 25 | 26 | public Form1() 27 | { 28 | InitializeComponent(); 29 | 30 | txtRimDir.Text = @"C:\Games\Rimworld.v1.5.4184"; 31 | txtModDir.Text = @"C:\Games\Rimworld.v1.5.4184/Mods"; 32 | 33 | cbVersion.DataSource = versions; 34 | cbVersion.SelectedIndex = versions.Length - 1; 35 | 36 | lwRecipe.Columns.Add("amount", 50); 37 | lwRecipe.Columns.Add("ingredient", 200); 38 | lwRecipe.Columns.Add("products", 100); 39 | 40 | lwDetails.GridLines = true; 41 | lwDetails.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None; 42 | lwDetails.HideSelection = false; 43 | lwDetails.Size = new System.Drawing.Size(360, 110); 44 | lwDetails.Location = new System.Drawing.Point(200, 450); 45 | lwDetails.Name = "lwDetail"; 46 | lwDetails.Scrollable = true; 47 | lwDetails.TabIndex = 4; 48 | lwDetails.UseCompatibleStateImageBehavior = false; 49 | lwDetails.View = System.Windows.Forms.View.Details; 50 | lwDetails.Visible = false; 51 | 52 | lwDetails.Columns.Add("key", 150); 53 | lwDetails.Columns.Add("value", 150); 54 | 55 | Controls.Add(this.lwDetails); 56 | } 57 | 58 | private void Form1_Load(object sender, EventArgs e) 59 | { } 60 | 61 | private void loadModList(string rimDir, string modDir) 62 | { 63 | defs.Clear(); 64 | lbMods.Items.Clear(); 65 | lbDefTypes.DataSource = null; 66 | lbPatches.DataSource = null; 67 | lwDefs.Items.Clear(); 68 | xmlView.Clear(); 69 | gbDesc.Visible = false; 70 | gbRecipe.Visible = false; 71 | pictureBox1.Visible = false; 72 | 73 | List activeMods = xmlReader.readModConfig(); 74 | 75 | // vanilla content 76 | foreach (string content in vanilla) 77 | { 78 | Mod dlc = new Mod(content); 79 | dlc.dir = rimDir + @"\Data\" + content + @"\"; 80 | dlc.defPath = rimDir + @"\Data\" + content + @"\Defs\"; 81 | dlc.patchPath = rimDir + @"\Data\" + content + @"\Patches\"; 82 | lbMods.Items.Add(dlc); 83 | } 84 | 85 | // mod content 86 | foreach (string dir in Directory.GetDirectories(modDir)) 87 | { 88 | try 89 | { 90 | string packageId = xmlReader.readPackageId(dir + @"\About\About.xml"); 91 | if (cbOnlyActiveMods.Checked) 92 | { 93 | if (!activeMods.Contains(packageId)) continue; 94 | } 95 | 96 | string modName = xmlReader.readModName(dir + @"\About\About.xml"); 97 | Mod mod = new Mod(modName); 98 | mod.packageId = packageId; 99 | mod.dir = dir; 100 | 101 | // Defs dir 102 | string ver = versions[cbVersion.SelectedIndex]; 103 | string path = dir + @"\" + ver + @"\Defs\"; 104 | if (Directory.Exists(path)) 105 | { 106 | mod.defPath = path; 107 | mod.name = modName; 108 | mod.version = ver; 109 | } 110 | else 111 | { 112 | path = dir + @"\Defs\"; 113 | if (Directory.Exists(path)) 114 | { 115 | mod.defPath = path; 116 | } 117 | } 118 | 119 | // Patch dir 120 | path = dir + @"\" + ver + @"\Patches\"; 121 | if (Directory.Exists(path)) 122 | { 123 | mod.patchPath = path; 124 | } 125 | else 126 | { 127 | path = dir + @"\Patches\"; 128 | if (Directory.Exists(path)) 129 | { 130 | mod.patchPath = path; 131 | } 132 | } 133 | 134 | lbMods.Items.Add(mod); 135 | } 136 | catch (Exception e) { Console.WriteLine(e); } 137 | } 138 | } 139 | 140 | private void lbMods_SelectedIndexChanged(object sender, EventArgs e) 141 | { 142 | // read def types 143 | Mod mod = (Mod)lbMods.SelectedItem; 144 | defs = defsView = xmlReader.loadAllDefs(mod); 145 | //xmlReader.defTypes.Sort(); 146 | lbDefTypes.DataSource = null; 147 | lbDefTypes.DataSource = xmlReader.defTypes; 148 | 149 | // read patches 150 | patches = xmlReader.loadAllPatches(mod); 151 | patchesView = new List(); 152 | foreach (Def def in patches) { 153 | patchesView.Add(def.defName); 154 | } 155 | lbPatches.DataSource = null; 156 | lbPatches.DataSource = patchesView; 157 | if (lbPatches.Items.Count > 0) 158 | lbPatches.SetSelected(0, false); 159 | 160 | // reset form 161 | lwDefs.Items.Clear(); 162 | lwDefs.Columns.Clear(); 163 | lwDefs.Columns.Add("Name", 150); 164 | lwDefs.Columns.Add("Label", 300); 165 | lwDetails.Items.Clear(); 166 | lwRecipe.Items.Clear(); 167 | xmlView.Clear(); 168 | gbDesc.Visible = false; 169 | gbRecipe.Visible = false; 170 | pictureBox1.Visible = false; 171 | } 172 | 173 | private void lbPatches_SelectedIndexChanged(object sender, EventArgs e) 174 | { 175 | if (lbPatches.SelectedIndices.Count > 0) 176 | { 177 | string selectedName = patchesView[lbPatches.SelectedIndices[0]]; 178 | foreach (Patch patch in patches) 179 | { 180 | if (patch.defName == selectedName) 181 | { 182 | xmlView.Text = patch.xml; 183 | 184 | // trim path 185 | string path = patch.file; 186 | int i = path.IndexOf(@"\Patches"); 187 | if (i > -1) path = patch.file.Substring(i); 188 | 189 | lblXmlPath.Text = "File: " + path; 190 | lblXPath.Text = "XPath: " + patch.xpath; 191 | 192 | } 193 | } 194 | } 195 | } 196 | 197 | // Filter defs from loaded mod ListBox 198 | private void lbDefTypes_SelectedIndexChanged(object sender, EventArgs e) 199 | { 200 | if (lbDefTypes.SelectedIndices.Count > 0) 201 | { 202 | string selectedType = xmlReader.defTypes[lbDefTypes.SelectedIndices[0]]; 203 | lwDefs.Items.Clear(); 204 | 205 | defsView = new List(); 206 | foreach (Def def in defs) 207 | { 208 | if (def.defType == selectedType) 209 | { 210 | defsView.Add(def); 211 | string[] items = { def.defName, def.label }; 212 | var listViewItem = new ListViewItem(items); 213 | lwDefs.Items.Add(listViewItem); 214 | } 215 | } 216 | xmlView.Clear(); 217 | } 218 | } 219 | 220 | private void lwDefs_SelectedIndexChanged(object sender, EventArgs e) 221 | { 222 | if (lwDefs.SelectedIndices.Count > 0) 223 | { 224 | Def def = defsView[lwDefs.SelectedIndices[0]]; 225 | 226 | gbRecipe.Visible = false; 227 | gbDesc.Visible = false; 228 | pictureBox1.Visible = false; 229 | lwDetails.Visible = false; 230 | 231 | btnDisable.Enabled = def.enabled; 232 | btnEnable.Enabled = !btnDisable.Enabled; 233 | 234 | // trim path 235 | string path = def.file; 236 | int i = path.IndexOf(@"\1."); 237 | if (i > -1) path = def.file.Substring(i); 238 | lblXmlPath.Text = "File: " + path; 239 | 240 | xmlView.Text = def.xml; 241 | 242 | if (def.defType.ToLower() == "recipedef") 243 | { 244 | RecipeDef recipe = (RecipeDef)def; 245 | 246 | lwRecipe.Items.Clear(); 247 | 248 | foreach (string[] li in recipe.ingredients) 249 | { 250 | lwRecipe.Items.Add(new ListViewItem(li)); 251 | } 252 | 253 | lwDetails.Items.Clear(); 254 | lwDetails.Items.Add(new ListViewItem(new string[] { "Work amount", recipe.work })); 255 | lwDetails.Items.Add(new ListViewItem(new string[] { "Skill requirements", recipe.skill })); 256 | lwDetails.Items.Add(new ListViewItem(new string[] { "Research prerequisite", recipe.research })); 257 | 258 | lwDetails.Size = new System.Drawing.Size(360, 60); 259 | lwDetails.Visible = true; 260 | gbRecipe.Visible = true; 261 | } 262 | 263 | if (def.defType.ToLower() == "thingdef") 264 | { 265 | // Details 266 | lwDetails.Items.Clear(); 267 | foreach (string[] row in def.details) 268 | { 269 | lwDetails.Items.Add(new ListViewItem(row)); 270 | } 271 | if (lwDetails.Items.Count > 0) 272 | { 273 | lwDetails.Size = new System.Drawing.Size(360, 110); 274 | lwDetails.Visible = true; 275 | } 276 | 277 | // Textures 278 | Console.WriteLine("texture path = " + def.texture); 279 | Bitmap image = new Bitmap(RimDef.Properties.Resources.nopic); 280 | if (File.Exists(def.texture)) 281 | { 282 | try 283 | { 284 | image = new Bitmap(def.texture); 285 | } 286 | catch (Exception ex) { Console.WriteLine(ex); } 287 | } 288 | pictureBox1.Image = (Image)image; 289 | pictureBox1.Visible = true; 290 | pictureBox1.Refresh(); 291 | } 292 | 293 | // Description 294 | if (def.description != "") 295 | { 296 | thingDesc.Text = def.description; 297 | gbDesc.Visible = true; 298 | } 299 | } 300 | } 301 | 302 | private void btnGameDir_Click(object sender, EventArgs e) 303 | { 304 | DialogResult result = folderBrowserDialog1.ShowDialog(); 305 | if (result == DialogResult.OK) 306 | { 307 | txtRimDir.Text = folderBrowserDialog1.SelectedPath; 308 | } 309 | } 310 | 311 | private void btnModsDir_Click(object sender, EventArgs e) 312 | { 313 | DialogResult result = folderBrowserDialog1.ShowDialog(); 314 | if (result == DialogResult.OK) 315 | { 316 | txtModDir.Text = folderBrowserDialog1.SelectedPath; 317 | } 318 | } 319 | 320 | private void cbVersion_SelectedIndexChanged(object sender, EventArgs e) 321 | { 322 | loadModList(txtRimDir.Text, txtModDir.Text); 323 | } 324 | 325 | private void btnLoad_Click(object sender, EventArgs e) 326 | { 327 | loadModList(txtRimDir.Text, txtModDir.Text); 328 | } 329 | 330 | private SearchCore SearchCore { get; set; } 331 | 332 | private void txtSearch_KeyDown(object sender, KeyEventArgs e) 333 | { 334 | if (e.KeyCode == Keys.Enter) 335 | { 336 | btnSearch_Click(sender, e); 337 | } 338 | } 339 | 340 | private void btnSearch_Click(object sender, EventArgs e) 341 | { 342 | var searchers = new List { new DefSearcher(defs) }; 343 | SearchCore = new SearchCore(searchers); 344 | 345 | lwDefs.Items.Clear(); 346 | lwDefs.Columns.Clear(); 347 | lwDefs.Columns.Add("Mod", 150); 348 | lwDefs.Columns.Add("Type", 150); 349 | lwDefs.Columns.Add("Name", 150); 350 | lwDefs.Columns.Add("Label", 150); 351 | 352 | string searchText = txtSearch.Text; 353 | Console.WriteLine(searchText); 354 | 355 | var search = new SearchResponse(); 356 | var time = new System.Diagnostics.Stopwatch(); 357 | time.Start(); 358 | search.Results = SearchCore.Search(searchText); 359 | time.Stop(); 360 | search.TimeTaken = time.Elapsed; 361 | 362 | defsView.Clear(); 363 | 364 | foreach (SearchResult result in search.Results) 365 | { 366 | Def def = result.Definition; 367 | string[] items = { def.mod.name, def.defType, def.defName, def.label }; 368 | var listViewItem = new ListViewItem(items); 369 | lwDefs.Items.Add(listViewItem); 370 | defsView.Add(def); 371 | } 372 | } 373 | 374 | private void btnDisable_Click(object sender, EventArgs e) 375 | { 376 | if (lwDefs.SelectedIndices.Count > 0) 377 | { 378 | Def def = defsView[lwDefs.SelectedIndices[0]]; 379 | if (!def.enabled) 380 | { 381 | var confirm = MessageBox.Show("Are you sure to disable this item ??", "Confirm!", MessageBoxButtons.YesNo); 382 | if (confirm == DialogResult.Yes) 383 | { 384 | xmlReader.disableNode(def); 385 | def.enabled = false; 386 | btnDisable.Enabled = false; 387 | btnEnable.Enabled = !btnDisable.Enabled; 388 | } 389 | } 390 | } 391 | } 392 | 393 | private void btnEnable_Click(object sender, EventArgs e) 394 | { 395 | if (lwDefs.SelectedIndices.Count > 0) 396 | { 397 | Def def = defsView[lwDefs.SelectedIndices[0]]; 398 | if (def.enabled) 399 | { 400 | var confirm = MessageBox.Show("Are you sure to enable this item ??", "Confirm!", MessageBoxButtons.YesNo); 401 | if (confirm == DialogResult.Yes) 402 | { 403 | xmlReader.enableNode(def); 404 | def.enabled = true; 405 | btnDisable.Enabled = true; 406 | btnEnable.Enabled = !btnDisable.Enabled; 407 | } 408 | } 409 | } 410 | } 411 | 412 | } 413 | } 414 | -------------------------------------------------------------------------------- /Form1.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 17, 17 122 | 123 | 124 | 64 125 | 126 | -------------------------------------------------------------------------------- /Mod.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace RimDef 8 | { 9 | public class Mod 10 | { 11 | public string name; 12 | public string packageId; 13 | public string version; 14 | public string dir; 15 | public string defPath; 16 | public string patchPath; 17 | 18 | public Mod(string name) 19 | { 20 | this.name = name; 21 | } 22 | 23 | public override string ToString() 24 | { 25 | return this.name; 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /Patch.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace RimDef 8 | { 9 | public class Patch : Def 10 | { 11 | public List mods = new List(); 12 | public string patchType = "-unset-"; 13 | public string xpath = "-unset-"; 14 | public string value = "-unset-"; 15 | public string success = "-unset-"; 16 | public string container = "-unset-"; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Preview/rimdev_prev1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m1st4x/RimDef/b1392acbb4aab7b9ef532276b194d12b92ad7a7c/Preview/rimdev_prev1.png -------------------------------------------------------------------------------- /Preview/rimdev_prev2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m1st4x/RimDef/b1392acbb4aab7b9ef532276b194d12b92ad7a7c/Preview/rimdev_prev2.png -------------------------------------------------------------------------------- /Preview/rimdev_prev3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m1st4x/RimDef/b1392acbb4aab7b9ef532276b194d12b92ad7a7c/Preview/rimdev_prev3.png -------------------------------------------------------------------------------- /Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using System.Windows.Forms; 6 | 7 | namespace RimDef 8 | { 9 | static class Program 10 | { 11 | /// 12 | /// The main entry point for the application. 13 | /// 14 | [STAThread] 15 | static void Main() 16 | { 17 | Application.EnableVisualStyles(); 18 | Application.SetCompatibleTextRenderingDefault(false); 19 | Application.Run(new Form1()); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("RimDef")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("RimDef")] 13 | [assembly: AssemblyCopyright("Copyright © 2020")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("f82a4488-000f-4be9-8f9c-e18464f2a5ec")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Dieser Code wurde von einem Tool generiert. 4 | // Laufzeitversion:4.0.30319.42000 5 | // 6 | // Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn 7 | // der Code erneut generiert wird. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace RimDef.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw. 17 | /// 18 | // Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert 19 | // -Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert. 20 | // Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen 21 | // mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("RimDef.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle 51 | /// Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | 63 | /// 64 | /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. 65 | /// 66 | internal static System.Drawing.Bitmap nopic { 67 | get { 68 | object obj = ResourceManager.GetObject("nopic", resourceCulture); 69 | return ((System.Drawing.Bitmap)(obj)); 70 | } 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /Properties/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 122 | ..\Resources\nopic.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 123 | 124 | -------------------------------------------------------------------------------- /Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Dieser Code wurde von einem Tool generiert. 4 | // Laufzeitversion:4.0.30319.42000 5 | // 6 | // Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn 7 | // der Code erneut generiert wird. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace RimDef.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.10.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /RecipeDef.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace RimDef 4 | { 5 | class RecipeDef : Def 6 | { 7 | public List ingredients = new List(); 8 | 9 | public void addIngredients(string[] row) 10 | { 11 | this.ingredients.Add(row); 12 | } 13 | 14 | public string research; 15 | public string skill; 16 | public string work; 17 | } 18 | } -------------------------------------------------------------------------------- /Resources/nopic.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m1st4x/RimDef/b1392acbb4aab7b9ef532276b194d12b92ad7a7c/Resources/nopic.gif -------------------------------------------------------------------------------- /RimDef.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {F82A4488-000F-4BE9-8F9C-E18464F2A5EC} 8 | WinExe 9 | Properties 10 | RimDef 11 | RimDef 12 | v4.8 13 | 512 14 | true 15 | 16 | 17 | 18 | AnyCPU 19 | true 20 | full 21 | false 22 | bin\Debug\ 23 | DEBUG;TRACE 24 | prompt 25 | 4 26 | 27 | 28 | AnyCPU 29 | pdbonly 30 | true 31 | bin\Release\ 32 | TRACE 33 | prompt 34 | 4 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | Form 54 | 55 | 56 | Form1.cs 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | Form1.cs 68 | 69 | 70 | ResXFileCodeGenerator 71 | Resources.Designer.cs 72 | Designer 73 | 74 | 75 | True 76 | Resources.resx 77 | True 78 | 79 | 80 | SettingsSingleFileGenerator 81 | Settings.Designer.cs 82 | 83 | 84 | True 85 | Settings.settings 86 | True 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 108 | -------------------------------------------------------------------------------- /RimDef.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30517.126 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RimDef", "RimDef.csproj", "{F82A4488-000F-4BE9-8F9C-E18464F2A5EC}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {F82A4488-000F-4BE9-8F9C-E18464F2A5EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {F82A4488-000F-4BE9-8F9C-E18464F2A5EC}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {F82A4488-000F-4BE9-8F9C-E18464F2A5EC}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {F82A4488-000F-4BE9-8F9C-E18464F2A5EC}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | VisualSVNWorkingCopyRoot = . 24 | SolutionGuid = {B5E0E712-F8CC-405F-9397-763ECF341C71} 25 | EndGlobalSection 26 | EndGlobal 27 | -------------------------------------------------------------------------------- /SearchCore.cs: -------------------------------------------------------------------------------- 1 | using RimDef; 2 | using System; 3 | using System.Collections.Generic; 4 | 5 | namespace SimpleSearch 6 | { 7 | public class SearchCore 8 | { 9 | private List Searchers { get; set; } 10 | 11 | public SearchCore(List searchers) 12 | { 13 | //Add passed in searchers to the list of searchers to use. 14 | Searchers = searchers; 15 | } 16 | 17 | public IEnumerable Search(string searchTerm) 18 | { 19 | var result = new List(); 20 | 21 | //Iterate over the collection of Searchers, calling their search method 22 | //and adding the result to the results to be returned. 23 | foreach (Searcher searcher in Searchers) 24 | { 25 | result.AddRange(searcher.Search(searchTerm)); 26 | } 27 | return result; 28 | } 29 | 30 | } 31 | 32 | public abstract class Searcher 33 | { 34 | public abstract IEnumerable Search(string searchTerm); 35 | } 36 | 37 | public class SearchResponse 38 | { 39 | public IEnumerable Results { get; set; } 40 | public string OriginalSearchTerm { get; set; } 41 | public TimeSpan TimeTaken { get; set; } 42 | } 43 | 44 | public class SearchResult 45 | { 46 | //public string Label { get; set; } 47 | //public string Mod { get; set; } 48 | //public string Description { get; set; } 49 | public Def Definition { get; set; } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /ThingDef.cs: -------------------------------------------------------------------------------- 1 | namespace RimDef 2 | { 3 | class ThingDef : Def 4 | { 5 | 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /XMLReader.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Security.Cryptography; 5 | using System.Text.RegularExpressions; 6 | using System.Xml; 7 | using System.Xml.Linq; 8 | 9 | namespace RimDef 10 | { 11 | class XMLReader 12 | { 13 | public string appdataPath = "%USERPROFILE%\\Appdata\\LocalLow\\Ludeon Studios\\RimWorld by Ludeon Studios\\Config\\ModsConfig.xml"; 14 | 15 | public List defTypes; 16 | 17 | public List loadAllPatches(Mod mod) 18 | { 19 | List patches = new List(); 20 | if (Directory.Exists(mod.patchPath)) 21 | { 22 | foreach (string file in Directory.GetFiles(mod.patchPath, "*.xml", SearchOption.AllDirectories)) 23 | { 24 | try 25 | { 26 | Console.WriteLine("reading " + file); 27 | var doc = new XmlDocument(); 28 | doc.Load(file); 29 | 30 | // 0) 36 | { 37 | opClass = opNode.Attributes[0].Value; 38 | Console.WriteLine("opClass=" + opClass); 39 | 40 | if (opClass == "PatchOperationAdd" || 41 | opClass == "PatchOperationInsert" || 42 | opClass == "PatchOperationRemove" || 43 | opClass == "PatchOperationReplace" || 44 | opClass == "PatchOperationAttributeAdd") 45 | { 46 | Patch patch = new Patch(); 47 | patch.defType = "Patch"; 48 | 49 | patch.defName = opClass; 50 | patch.patchType = opClass; 51 | 52 | patch.mod = mod; 53 | patch.file = file; 54 | patch.xml = System.Xml.Linq.XDocument.Parse(opNode.OuterXml).ToString(); 55 | patch.enabled = true; 56 | 57 | foreach (XmlNode child in opNode.ChildNodes) 58 | { 59 | if (child.Name == "xpath") patch.xpath = child.InnerText; 60 | if (child.Name == "value") patch.value = child.InnerText; 61 | if (child.Name == "success") patch.success = child.InnerText; 62 | } 63 | patches.Add(patch); 64 | Console.WriteLine("-----------------------"); 65 | } 66 | 67 | else if (opClass == "PatchOperationFindMod") 68 | { 69 | // mods 70 | List patchMods = new List(); 71 | XmlNodeList nodeList = doc.DocumentElement.SelectNodes("/Patch/Operation/mods/li"); 72 | foreach (XmlNode li in nodeList) 73 | { 74 | patchMods = new List(); 75 | foreach (XmlNode node in nodeList) 76 | { 77 | patchMods.Add(node.InnerText); 78 | Console.WriteLine($"mods={node.InnerText}"); 79 | } 80 | } 81 | 82 | // match 83 | XmlNode match = doc.DocumentElement.SelectSingleNode("/Patch/Operation/match"); 84 | if (match != null) 85 | { 86 | string matchClass = "unset"; 87 | if (match.Attributes != null && match.Attributes.Count > 0) 88 | { 89 | matchClass = match.Attributes["Class"].Value; 90 | Console.WriteLine("Class=" + matchClass); 91 | } 92 | 93 | if (matchClass == "PatchOperationAdd" || 94 | matchClass == "PatchOperationInsert" || 95 | matchClass == "PatchOperationRemove" || 96 | matchClass == "PatchOperationReplace") 97 | //... 98 | { 99 | //TODO? 100 | } 101 | 102 | if (matchClass == "PatchOperationSequence") 103 | { 104 | // sequence 105 | foreach (XmlNode li in match.SelectNodes("operations/li")) 106 | { 107 | // type 108 | string liClass = "unset"; 109 | if (li.Attributes != null && li.Attributes.Count > 0) 110 | { 111 | liClass = li.Attributes["Class"].Value; 112 | Console.WriteLine("liClass=" + liClass); 113 | } 114 | 115 | string xpath = "unset"; 116 | string value = "unset"; 117 | foreach (XmlNode child in li.ChildNodes) 118 | { 119 | if (child.Name == "xpath") xpath = child.InnerText; 120 | if (child.Name == "value") value = child.InnerText; 121 | } 122 | Console.WriteLine("xpath=" + xpath); 123 | Console.WriteLine("value=" + value); 124 | 125 | // name 126 | string name = "unset"; 127 | try 128 | { 129 | int start = xpath.IndexOf("\""); 130 | int end = xpath.LastIndexOf("\""); 131 | name = xpath.Substring(start + 1, end - start - 1); 132 | Console.WriteLine("target=" + name); 133 | } 134 | catch (Exception ex) { Console.WriteLine(ex.Message); } 135 | // 136 | name = opClass + " (sequence)"; 137 | // 138 | Patch patch = new Patch(); 139 | patch.defType = matchClass; 140 | patch.defName = name; 141 | patch.mod = mod; 142 | patch.mods = patchMods; 143 | patch.file = file; 144 | patch.enabled = true; 145 | patch.xml = System.Xml.Linq.XDocument.Parse(match.OuterXml).ToString(); 146 | 147 | patch.patchType = liClass; 148 | patch.xpath = xpath; 149 | patch.value = value; 150 | 151 | patches.Add(patch); 152 | 153 | Console.WriteLine("-----------------------"); 154 | } 155 | } 156 | } 157 | } 158 | 159 | else if (opClass == "PatchOperationConditional") 160 | { 161 | Patch patch = new Patch(); 162 | patch.defType = "Patch"; 163 | 164 | patch.defName = opClass; 165 | patch.patchType = opClass; 166 | 167 | foreach (XmlNode child in opNode.ChildNodes) 168 | { 169 | if (child.Name == "xpath") patch.xpath = child.InnerText; 170 | if (child.Name == "value") patch.value = child.InnerText; 171 | 172 | //TODO 173 | if (child.Name == "match") 174 | { 175 | if (child.Attributes != null && child.Attributes.Count > 0) 176 | { 177 | string matchClass = child.Attributes[0].Value; 178 | } 179 | } 180 | if (child.Name == "nomatch") 181 | { 182 | if (child.Attributes != null && child.Attributes.Count > 0) 183 | { 184 | string nomatchClass = child.Attributes[0].Value; 185 | } 186 | } 187 | } 188 | 189 | patch.mod = mod; 190 | patch.file = file; 191 | patch.enabled = true; 192 | patch.xml = System.Xml.Linq.XDocument.Parse(opNode.OuterXml).ToString(); 193 | patches.Add(patch); 194 | 195 | Console.WriteLine("-----------------------"); 196 | } 197 | else 198 | { 199 | Patch patch = new Patch(); 200 | patch.defType = "Patch"; 201 | 202 | patch.defName = opClass + " (custom)"; 203 | patch.patchType = opClass; 204 | 205 | patch.mod = mod; 206 | patch.file = file; 207 | patch.xml = System.Xml.Linq.XDocument.Parse(opNode.OuterXml).ToString(); 208 | patch.enabled = true; 209 | 210 | foreach (XmlNode child in opNode.ChildNodes) 211 | { 212 | if (child.Name == "xpath") patch.xpath = child.InnerText; 213 | if (child.Name == "value") patch.value = child.InnerText; 214 | if (child.Name == "container") patch.container = child.InnerText; 215 | } 216 | patches.Add(patch); 217 | Console.WriteLine("-----------------------"); 218 | } 219 | } 220 | } 221 | } 222 | catch (Exception e) { Console.WriteLine(e); } 223 | } 224 | } 225 | 226 | return patches; 227 | } 228 | 229 | public List loadAllDefs(Mod mod) 230 | { 231 | Console.WriteLine("loading mod: " + mod.name); 232 | 233 | defTypes = new List(); 234 | 235 | List defs = new List(); 236 | 237 | // NOTE: The contents of a Def folder don't follow a clear naming convention, 238 | // but the folder names are generally the same in every mod. 239 | // see https://rimworldwiki.com/wiki/Modding_Tutorials/Mod_folder_structure 240 | try 241 | { 242 | string path = mod.dir + "\\" + mod.version; 243 | string[] files = Directory.GetFiles(path, "*.xml", SearchOption.AllDirectories); 244 | foreach (string file in files) 245 | { 246 | Console.WriteLine("reading " + file); 247 | defs.AddRange(readXML(mod, file)); 248 | } 249 | } 250 | catch (Exception ex) { Console.WriteLine(ex); } 251 | 252 | return defs; 253 | } 254 | 255 | public List readModConfig() 256 | { 257 | List activeMods = new List(); 258 | try 259 | { 260 | string path = Environment.ExpandEnvironmentVariables(appdataPath); 261 | var doc = new XmlDocument(); 262 | doc.Load(path); 263 | foreach (XmlNode node in doc.DocumentElement.SelectNodes("/ModsConfigData/activeMods/li")) 264 | activeMods.Add(node.InnerText); 265 | } 266 | catch (Exception e) { Console.WriteLine(e); } 267 | 268 | return activeMods; 269 | } 270 | 271 | public string readPackageId(string file) 272 | { 273 | string packageId = "-undef-"; 274 | try 275 | { 276 | var doc = new XmlDocument(); 277 | doc.Load(file); 278 | XmlNode node = doc.DocumentElement.SelectSingleNode("/ModMetaData/packageId"); 279 | if (node != null) 280 | packageId = node.InnerText.ToLower(); 281 | } 282 | catch (Exception e) { Console.WriteLine(e); } 283 | 284 | return packageId; 285 | } 286 | 287 | public string readModName(string file) 288 | { 289 | string modName = "-undef-"; 290 | try 291 | { 292 | var doc = new XmlDocument(); 293 | doc.Load(file); 294 | XmlNode node = doc.DocumentElement.SelectSingleNode("/ModMetaData/name"); 295 | if (node != null) 296 | modName = node.InnerText.ToLower(); 297 | } 298 | catch (Exception e) { Console.WriteLine(e); } 299 | 300 | return modName; 301 | } 302 | 303 | private List readXML(Mod mod, string file) 304 | { 305 | List xmlDefs = new List(); 306 | string[] orientations = { "_north", "_south", "_west", "_east" }; 307 | 308 | var doc = new XmlDocument(); 309 | try 310 | { 311 | doc.Load(file); 312 | foreach (XmlNode node in doc.DocumentElement.SelectNodes("/Defs")) 313 | { 314 | foreach (XmlNode child in node.ChildNodes) 315 | { 316 | string type = child.Name; 317 | int idx = type.IndexOf("Def"); 318 | if (idx > 0) 319 | { 320 | if (!defTypes.Contains(type)) 321 | { 322 | defTypes.Add(type); 323 | } 324 | 325 | string defType = type.Substring(0, idx).ToLower(); 326 | 327 | string defName = ""; 328 | string label = ""; 329 | string description = ""; 330 | string texture = ""; 331 | 332 | for (int i = 0; i < child.ChildNodes.Count; i++) 333 | { 334 | string name = child.ChildNodes[i].Name; 335 | if (name == "defName") 336 | { 337 | defName = child.ChildNodes[i].InnerText; 338 | } 339 | if (name == "label") 340 | { 341 | label = child.ChildNodes[i].InnerText; 342 | } 343 | if (name == "description") 344 | { 345 | description = child.ChildNodes[i].InnerText; 346 | } 347 | 348 | if (name == "reportString") // Jobs 349 | { 350 | description = child.ChildNodes[i].InnerText; 351 | } 352 | if (name == "baseDesc") // Backstories 353 | { 354 | description = child.ChildNodes[i].InnerText; 355 | } 356 | if (name == "degreeDatas") // Traits 357 | { 358 | XmlNode traitNode = child.SelectSingleNode("degreeDatas/li/description"); 359 | if (traitNode != null) 360 | { 361 | description = traitNode.InnerText; 362 | } 363 | } 364 | if (name == "stages") // Thoughts 365 | { 366 | XmlNodeList thoughtDefs = child.SelectNodes("stages/li/description"); 367 | foreach (XmlNode thoughtNode in thoughtDefs) 368 | { 369 | description += thoughtNode.InnerText + "\n\n"; 370 | } 371 | } 372 | } 373 | if (description == "") description = "No additional information available"; 374 | 375 | 376 | // Textures 377 | XmlNode texNode = child.SelectSingleNode("graphicData/texPath"); 378 | if (texNode != null) 379 | { 380 | // core textures 381 | // https://ludeon.com/forums/index.php?topic=2325 382 | 383 | string texPath = mod.dir + @"\\Textures\\" + texNode.InnerText; 384 | if (Directory.Exists(texPath)) 385 | { 386 | string[] files = Directory.GetFiles(texPath, "*.*", SearchOption.AllDirectories); 387 | texture = files[0]; 388 | } 389 | else 390 | { 391 | texture = mod.dir + @"\\Textures\\" + texNode.InnerText + ".png"; 392 | if (!File.Exists(texture)) 393 | { 394 | //Console.WriteLine(texture + " does not exist"); 395 | foreach (string ori in orientations) 396 | { 397 | string textureOri = mod.dir + @"\\Textures\\" + texNode.InnerText + ori + ".png"; 398 | if (File.Exists(textureOri)) 399 | { 400 | texture = textureOri; 401 | //Console.WriteLine(texture + " added"); 402 | break; 403 | } 404 | } 405 | } 406 | } 407 | } 408 | 409 | Def def = new Def(); 410 | 411 | if (defType == "thing") 412 | { 413 | ThingDef thing = new ThingDef(); 414 | 415 | // 416 | XmlNode statsNode = child.SelectSingleNode("statBases"); 417 | if (statsNode != null) 418 | { 419 | foreach (XmlNode stat in statsNode.ChildNodes) 420 | { 421 | thing.details.Add(new string[] { stat.Name, stat.InnerText }); 422 | } 423 | } 424 | def = thing; 425 | } 426 | 427 | if (defType == "recipe") 428 | { 429 | RecipeDef recipe = new RecipeDef(); 430 | 431 | // 432 | string products = ""; 433 | XmlNodeList productNodes = child.SelectNodes("products"); 434 | foreach (XmlNode n in productNodes) 435 | { 436 | foreach (XmlNode p in n.ChildNodes) 437 | { 438 | products += p.InnerXml + "x " + p.Name; 439 | } 440 | } 441 | 442 | // 443 | string research = "-"; 444 | XmlNode researchNode = child.SelectSingleNode("researchPrerequisite"); 445 | if (researchNode != null) 446 | { 447 | research = researchNode.InnerText; 448 | } 449 | recipe.research = research; 450 | 451 | // 452 | string skill = "-"; 453 | XmlNode skillNode = child.SelectSingleNode("skillRequirements"); 454 | if (skillNode != null) 455 | { 456 | skill = skillNode.InnerText; 457 | } 458 | recipe.skill = skill; 459 | 460 | // 461 | string work = "-"; 462 | XmlNode workNode = child.SelectSingleNode("workAmount"); 463 | if (workNode != null) 464 | { 465 | work = workNode.InnerText; 466 | } 467 | recipe.work = work; 468 | 469 | // 470 | foreach (XmlNode n in child.SelectNodes("ingredients/li")) 471 | { 472 | string ingredients = ""; 473 | foreach (XmlNode xml in n.SelectNodes("filter/thingDefs/li")) 474 | { 475 | ingredients += xml.InnerText + ", "; 476 | } 477 | foreach (XmlNode xml in n.SelectNodes("filter/categories/li")) 478 | { 479 | ingredients += xml.InnerText + ", "; 480 | } 481 | ingredients = ingredients.Substring(0, ingredients.Length - 2); 482 | 483 | string amount = n.LastChild.InnerText; 484 | 485 | recipe.addIngredients(new string[] { amount, ingredients, products }); 486 | } 487 | def = recipe; 488 | } 489 | 490 | def.mod = mod; 491 | def.defType = type; 492 | def.defName = defName; 493 | def.label = label; 494 | def.description = description; 495 | def.texture = texture; 496 | def.file = file; 497 | def.enabled = true; 498 | 499 | // XML view 500 | string xmlOut = System.Xml.Linq.XDocument.Parse(child.OuterXml).ToString(); 501 | def.xml = xmlOut; 502 | 503 | if (defName != "") 504 | { 505 | xmlDefs.Add(def); 506 | } 507 | } 508 | } 509 | } 510 | } 511 | catch (Exception ex) { Console.WriteLine(ex); } 512 | 513 | try 514 | { 515 | // read defs disabled by comment 516 | foreach (XmlNode comment in doc.SelectNodes("//comment()")) 517 | { 518 | Console.WriteLine("\ncomment: " + comment.InnerText + "\n"); 519 | string xml = comment.InnerText; 520 | if (!xml.StartsWith("<")) xml = "<" + xml + ">"; 521 | XmlReader nodeReader = XmlReader.Create(new StringReader(xml)); 522 | XmlNode newNode = doc.ReadNode(nodeReader); 523 | 524 | XmlNode defName = newNode.SelectSingleNode("defName"); 525 | if (defName != null) 526 | { 527 | Def disabledDef = new Def(); 528 | disabledDef.mod = mod; 529 | disabledDef.defType = newNode.Name; 530 | disabledDef.defName = defName.InnerText; 531 | disabledDef.label = "(Disabled) "; 532 | XmlNode labelNode = newNode.SelectSingleNode("label"); 533 | if (labelNode != null) disabledDef.label += labelNode.InnerText; 534 | disabledDef.file = file; 535 | disabledDef.enabled = false; 536 | xmlDefs.Add(disabledDef); 537 | Console.WriteLine("Disabled definition added."); 538 | } 539 | } 540 | } 541 | catch (Exception e) { Console.WriteLine("XMLReader: " + e.StackTrace); } 542 | 543 | return xmlDefs; 544 | } 545 | 546 | public void disableNode(Def def) 547 | { 548 | try 549 | { 550 | // backup file 551 | string backup = def.file + ".ori"; 552 | if (!File.Exists(backup)) 553 | File.Copy(def.file, backup); 554 | } 555 | catch (Exception ex) { Console.WriteLine(ex); } 556 | 557 | try 558 | { 559 | // comment out xml 560 | var doc = new XmlDocument(); 561 | doc.Load(def.file); 562 | XmlNode node = doc.DocumentElement.SelectSingleNode("ThingDef[defName='" + def.defName + "']"); 563 | if (node != null) 564 | { 565 | XmlComment comment = doc.CreateComment(node.OuterXml); 566 | XmlNode parent = node.ParentNode; 567 | parent.ReplaceChild(comment, node); 568 | doc.Save(def.file); 569 | def.enabled = false; 570 | Console.WriteLine("'" + def.defName + "' disabled."); 571 | } 572 | else 573 | { 574 | Console.WriteLine("'" + def.defName + "' not found."); 575 | } 576 | } 577 | catch (Exception ex) { Console.WriteLine(ex); } 578 | } 579 | 580 | public void enableNode(Def def) 581 | { 582 | var doc = new XmlDocument(); 583 | doc.Load(def.file); 584 | foreach (XmlNode comment in doc.SelectNodes("//comment()")) 585 | { 586 | string xml = comment.InnerText; 587 | if (!xml.StartsWith("<")) xml = "<" + xml + ">"; 588 | XmlReader nodeReader = XmlReader.Create(new StringReader(xml)); 589 | XmlNode newNode = doc.ReadNode(nodeReader); 590 | Console.WriteLine("enable: " + newNode.OuterXml); 591 | 592 | XmlNode defName = newNode.SelectSingleNode("defName"); 593 | if (defName != null && defName.InnerText == def.defName) 594 | { 595 | XmlNode parent = comment.ParentNode; 596 | parent.ReplaceChild(newNode, comment); 597 | doc.Save(def.file); 598 | def.enabled = true; 599 | Console.WriteLine("'" + def.defName + "' enabled."); 600 | break; 601 | } 602 | } 603 | } 604 | 605 | } 606 | } 607 | --------------------------------------------------------------------------------