├── .gitignore
├── LICENSE
├── README.md
├── WitcherScriptMerger.sln
└── WitcherScriptMerger
├── App.config
├── AppSettings.cs
├── Controls
├── ConflictTree.cs
├── MergeTree.cs
├── SMTree.cs
├── SMTreeSorter.cs
└── ToolStripRegion.cs
├── DeadCodeDetection.ruleset
├── Extensions.cs
├── FileIndex
├── ModFile.cs
├── ModFileCategory.cs
└── ModFileIndex.cs
├── Forms
├── DependencyForm.Designer.cs
├── DependencyForm.cs
├── DependencyForm.resx
├── MainForm.Designer.cs
├── MainForm.cs
├── MainForm.resx
├── MergeReportForm.Designer.cs
├── MergeReportForm.cs
├── MergeReportForm.resx
├── MessageBoxManager.cs
├── OptionsForm.Designer.cs
├── OptionsForm.cs
├── OptionsForm.resx
├── PackReportForm.Designer.cs
├── PackReportForm.cs
├── PackReportForm.resx
└── PriorityPrompt.cs
├── Inventory
├── FileHash.cs
├── FileMerger.cs
├── Merge.cs
├── MergeInventory.cs
└── MergeProgressInfo.cs
├── LoadOrder
├── CustomLoadOrder.cs
├── LoadOrderComparer.cs
├── LoadOrderValidator.cs
└── ModLoadSetting.cs
├── Paths.cs
├── Program.cs
├── Properties
├── AssemblyInfo.cs
├── Resources.Designer.cs
├── Resources.resx
├── Settings.Designer.cs
└── Settings.settings
├── SimLink.cs
├── TaskbarProgress.cs
├── Tools
├── KDiff3.cs
├── QuickBms.cs
├── WccLite.cs
└── xxHash.cs
├── WitcherScriptMerger.csproj
└── WolfMedallion.ico
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # Screenshots folder
5 | [Ss]creenshots/
6 |
7 | # User-specific files
8 | *.suo
9 | *.user
10 | *.userosscache
11 | *.sln.docstates
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 | # Build results
17 | [Dd]ebug/
18 | [Dd]ebugPublic/
19 | [Rr]elease/
20 | [Rr]eleases/
21 | x64/
22 | x86/
23 | build/
24 | bld/
25 | [Bb]in/
26 | [Oo]bj/
27 |
28 | # Visual Studo 2015 cache/options directory
29 | .vs/
30 |
31 | # MSTest test Results
32 | [Tt]est[Rr]esult*/
33 | [Bb]uild[Ll]og.*
34 |
35 | # NUNIT
36 | *.VisualState.xml
37 | TestResult.xml
38 |
39 | # Build Results of an ATL Project
40 | [Dd]ebugPS/
41 | [Rr]eleasePS/
42 | dlldata.c
43 |
44 | *_i.c
45 | *_p.c
46 | *_i.h
47 | *.ilk
48 | *.meta
49 | *.obj
50 | *.pch
51 | *.pdb
52 | *.pgc
53 | *.pgd
54 | *.rsp
55 | *.sbr
56 | *.tlb
57 | *.tli
58 | *.tlh
59 | *.tmp
60 | *.tmp_proj
61 | *.log
62 | *.vspscc
63 | *.vssscc
64 | .builds
65 | *.pidb
66 | *.svclog
67 | *.scc
68 |
69 | # Chutzpah Test files
70 | _Chutzpah*
71 |
72 | # Visual C++ cache files
73 | ipch/
74 | *.aps
75 | *.ncb
76 | *.opensdf
77 | *.sdf
78 | *.cachefile
79 |
80 | # Visual Studio profiler
81 | *.psess
82 | *.vsp
83 | *.vspx
84 |
85 | # TFS 2012 Local Workspace
86 | $tf/
87 |
88 | # Guidance Automation Toolkit
89 | *.gpState
90 |
91 | # ReSharper is a .NET coding add-in
92 | _ReSharper*/
93 | *.[Rr]e[Ss]harper
94 | *.DotSettings.user
95 |
96 | # JustCode is a .NET coding addin-in
97 | .JustCode
98 |
99 | # TeamCity is a build add-in
100 | _TeamCity*
101 |
102 | # DotCover is a Code Coverage Tool
103 | *.dotCover
104 |
105 | # NCrunch
106 | _NCrunch_*
107 | .*crunch*.local.xml
108 |
109 | # MightyMoose
110 | *.mm.*
111 | AutoTest.Net/
112 |
113 | # Web workbench (sass)
114 | .sass-cache/
115 |
116 | # Installshield output folder
117 | [Ee]xpress/
118 |
119 | # DocProject is a documentation generator add-in
120 | DocProject/buildhelp/
121 | DocProject/Help/*.HxT
122 | DocProject/Help/*.HxC
123 | DocProject/Help/*.hhc
124 | DocProject/Help/*.hhk
125 | DocProject/Help/*.hhp
126 | DocProject/Help/Html2
127 | DocProject/Help/html
128 |
129 | # Click-Once directory
130 | publish/
131 |
132 | # Publish Web Output
133 | *.[Pp]ublish.xml
134 | *.azurePubxml
135 | # TODO: Comment the next line if you want to checkin your web deploy settings
136 | # but database connection strings (with potential passwords) will be unencrypted
137 | *.pubxml
138 | *.publishproj
139 |
140 | # NuGet Packages
141 | *.nupkg
142 | # The packages folder can be ignored because of Package Restore
143 | **/packages/*
144 | # except build/, which is used as an MSBuild target.
145 | !**/packages/build/
146 | # Uncomment if necessary however generally it will be regenerated when needed
147 | #!**/packages/repositories.config
148 |
149 | # Windows Azure Build Output
150 | csx/
151 | *.build.csdef
152 |
153 | # Windows Store app package directory
154 | AppPackages/
155 |
156 | # Others
157 | *.[Cc]ache
158 | ClientBin/
159 | [Ss]tyle[Cc]op.*
160 | ~$*
161 | *~
162 | *.dbmdl
163 | *.dbproj.schemaview
164 | *.pfx
165 | *.publishsettings
166 | node_modules/
167 | bower_components/
168 |
169 | # RIA/Silverlight projects
170 | Generated_Code/
171 |
172 | # Backup & report files from converting an old project file
173 | # to a newer Visual Studio version. Backup files are not needed,
174 | # because we have git ;-)
175 | _UpgradeReport_Files/
176 | Backup*/
177 | UpgradeLog*.XML
178 | UpgradeLog*.htm
179 |
180 | # SQL Server files
181 | *.mdf
182 | *.ldf
183 |
184 | # Business Intelligence projects
185 | *.rdl.data
186 | *.bim.layout
187 | *.bim_*.settings
188 |
189 | # Microsoft Fakes
190 | FakesAssemblies/
191 |
192 | # Node.js Tools for Visual Studio
193 | .ntvs_analysis.dat
194 |
195 | # Visual Studio 6 build log
196 | *.plg
197 |
198 | # Visual Studio 6 workspace options file
199 | *.opt
200 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 2, June 1991
3 |
4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6 | Everyone is permitted to copy and distribute verbatim copies
7 | of this license document, but changing it is not allowed.
8 |
9 | Preamble
10 |
11 | The licenses for most software are designed to take away your
12 | freedom to share and change it. By contrast, the GNU General Public
13 | License is intended to guarantee your freedom to share and change free
14 | software--to make sure the software is free for all its users. This
15 | General Public License applies to most of the Free Software
16 | Foundation's software and to any other program whose authors commit to
17 | using it. (Some other Free Software Foundation software is covered by
18 | the GNU Lesser General Public License instead.) You can apply it to
19 | your programs, too.
20 |
21 | When we speak of free software, we are referring to freedom, not
22 | price. Our General Public Licenses are designed to make sure that you
23 | have the freedom to distribute copies of free software (and charge for
24 | this service if you wish), that you receive source code or can get it
25 | if you want it, that you can change the software or use pieces of it
26 | in new free programs; and that you know you can do these things.
27 |
28 | To protect your rights, we need to make restrictions that forbid
29 | anyone to deny you these rights or to ask you to surrender the rights.
30 | These restrictions translate to certain responsibilities for you if you
31 | distribute copies of the software, or if you modify it.
32 |
33 | For example, if you distribute copies of such a program, whether
34 | gratis or for a fee, you must give the recipients all the rights that
35 | you have. You must make sure that they, too, receive or can get the
36 | source code. And you must show them these terms so they know their
37 | rights.
38 |
39 | We protect your rights with two steps: (1) copyright the software, and
40 | (2) offer you this license which gives you legal permission to copy,
41 | distribute and/or modify the software.
42 |
43 | Also, for each author's protection and ours, we want to make certain
44 | that everyone understands that there is no warranty for this free
45 | software. If the software is modified by someone else and passed on, we
46 | want its recipients to know that what they have is not the original, so
47 | that any problems introduced by others will not reflect on the original
48 | authors' reputations.
49 |
50 | Finally, any free program is threatened constantly by software
51 | patents. We wish to avoid the danger that redistributors of a free
52 | program will individually obtain patent licenses, in effect making the
53 | program proprietary. To prevent this, we have made it clear that any
54 | patent must be licensed for everyone's free use or not licensed at all.
55 |
56 | The precise terms and conditions for copying, distribution and
57 | modification follow.
58 |
59 | GNU GENERAL PUBLIC LICENSE
60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61 |
62 | 0. This License applies to any program or other work which contains
63 | a notice placed by the copyright holder saying it may be distributed
64 | under the terms of this General Public License. The "Program", below,
65 | refers to any such program or work, and a "work based on the Program"
66 | means either the Program or any derivative work under copyright law:
67 | that is to say, a work containing the Program or a portion of it,
68 | either verbatim or with modifications and/or translated into another
69 | language. (Hereinafter, translation is included without limitation in
70 | the term "modification".) Each licensee is addressed as "you".
71 |
72 | Activities other than copying, distribution and modification are not
73 | covered by this License; they are outside its scope. The act of
74 | running the Program is not restricted, and the output from the Program
75 | is covered only if its contents constitute a work based on the
76 | Program (independent of having been made by running the Program).
77 | Whether that is true depends on what the Program does.
78 |
79 | 1. You may copy and distribute verbatim copies of the Program's
80 | source code as you receive it, in any medium, provided that you
81 | conspicuously and appropriately publish on each copy an appropriate
82 | copyright notice and disclaimer of warranty; keep intact all the
83 | notices that refer to this License and to the absence of any warranty;
84 | and give any other recipients of the Program a copy of this License
85 | along with the Program.
86 |
87 | You may charge a fee for the physical act of transferring a copy, and
88 | you may at your option offer warranty protection in exchange for a fee.
89 |
90 | 2. You may modify your copy or copies of the Program or any portion
91 | of it, thus forming a work based on the Program, and copy and
92 | distribute such modifications or work under the terms of Section 1
93 | above, provided that you also meet all of these conditions:
94 |
95 | a) You must cause the modified files to carry prominent notices
96 | stating that you changed the files and the date of any change.
97 |
98 | b) You must cause any work that you distribute or publish, that in
99 | whole or in part contains or is derived from the Program or any
100 | part thereof, to be licensed as a whole at no charge to all third
101 | parties under the terms of this License.
102 |
103 | c) If the modified program normally reads commands interactively
104 | when run, you must cause it, when started running for such
105 | interactive use in the most ordinary way, to print or display an
106 | announcement including an appropriate copyright notice and a
107 | notice that there is no warranty (or else, saying that you provide
108 | a warranty) and that users may redistribute the program under
109 | these conditions, and telling the user how to view a copy of this
110 | License. (Exception: if the Program itself is interactive but
111 | does not normally print such an announcement, your work based on
112 | the Program is not required to print an announcement.)
113 |
114 | These requirements apply to the modified work as a whole. If
115 | identifiable sections of that work are not derived from the Program,
116 | and can be reasonably considered independent and separate works in
117 | themselves, then this License, and its terms, do not apply to those
118 | sections when you distribute them as separate works. But when you
119 | distribute the same sections as part of a whole which is a work based
120 | on the Program, the distribution of the whole must be on the terms of
121 | this License, whose permissions for other licensees extend to the
122 | entire whole, and thus to each and every part regardless of who wrote it.
123 |
124 | Thus, it is not the intent of this section to claim rights or contest
125 | your rights to work written entirely by you; rather, the intent is to
126 | exercise the right to control the distribution of derivative or
127 | collective works based on the Program.
128 |
129 | In addition, mere aggregation of another work not based on the Program
130 | with the Program (or with a work based on the Program) on a volume of
131 | a storage or distribution medium does not bring the other work under
132 | the scope of this License.
133 |
134 | 3. You may copy and distribute the Program (or a work based on it,
135 | under Section 2) in object code or executable form under the terms of
136 | Sections 1 and 2 above provided that you also do one of the following:
137 |
138 | a) Accompany it with the complete corresponding machine-readable
139 | source code, which must be distributed under the terms of Sections
140 | 1 and 2 above on a medium customarily used for software interchange; or,
141 |
142 | b) Accompany it with a written offer, valid for at least three
143 | years, to give any third party, for a charge no more than your
144 | cost of physically performing source distribution, a complete
145 | machine-readable copy of the corresponding source code, to be
146 | distributed under the terms of Sections 1 and 2 above on a medium
147 | customarily used for software interchange; or,
148 |
149 | c) Accompany it with the information you received as to the offer
150 | to distribute corresponding source code. (This alternative is
151 | allowed only for noncommercial distribution and only if you
152 | received the program in object code or executable form with such
153 | an offer, in accord with Subsection b above.)
154 |
155 | The source code for a work means the preferred form of the work for
156 | making modifications to it. For an executable work, complete source
157 | code means all the source code for all modules it contains, plus any
158 | associated interface definition files, plus the scripts used to
159 | control compilation and installation of the executable. However, as a
160 | special exception, the source code distributed need not include
161 | anything that is normally distributed (in either source or binary
162 | form) with the major components (compiler, kernel, and so on) of the
163 | operating system on which the executable runs, unless that component
164 | itself accompanies the executable.
165 |
166 | If distribution of executable or object code is made by offering
167 | access to copy from a designated place, then offering equivalent
168 | access to copy the source code from the same place counts as
169 | distribution of the source code, even though third parties are not
170 | compelled to copy the source along with the object code.
171 |
172 | 4. You may not copy, modify, sublicense, or distribute the Program
173 | except as expressly provided under this License. Any attempt
174 | otherwise to copy, modify, sublicense or distribute the Program is
175 | void, and will automatically terminate your rights under this License.
176 | However, parties who have received copies, or rights, from you under
177 | this License will not have their licenses terminated so long as such
178 | parties remain in full compliance.
179 |
180 | 5. You are not required to accept this License, since you have not
181 | signed it. However, nothing else grants you permission to modify or
182 | distribute the Program or its derivative works. These actions are
183 | prohibited by law if you do not accept this License. Therefore, by
184 | modifying or distributing the Program (or any work based on the
185 | Program), you indicate your acceptance of this License to do so, and
186 | all its terms and conditions for copying, distributing or modifying
187 | the Program or works based on it.
188 |
189 | 6. Each time you redistribute the Program (or any work based on the
190 | Program), the recipient automatically receives a license from the
191 | original licensor to copy, distribute or modify the Program subject to
192 | these terms and conditions. You may not impose any further
193 | restrictions on the recipients' exercise of the rights granted herein.
194 | You are not responsible for enforcing compliance by third parties to
195 | this License.
196 |
197 | 7. If, as a consequence of a court judgment or allegation of patent
198 | infringement or for any other reason (not limited to patent issues),
199 | conditions are imposed on you (whether by court order, agreement or
200 | otherwise) that contradict the conditions of this License, they do not
201 | excuse you from the conditions of this License. If you cannot
202 | distribute so as to satisfy simultaneously your obligations under this
203 | License and any other pertinent obligations, then as a consequence you
204 | may not distribute the Program at all. For example, if a patent
205 | license would not permit royalty-free redistribution of the Program by
206 | all those who receive copies directly or indirectly through you, then
207 | the only way you could satisfy both it and this License would be to
208 | refrain entirely from distribution of the Program.
209 |
210 | If any portion of this section is held invalid or unenforceable under
211 | any particular circumstance, the balance of the section is intended to
212 | apply and the section as a whole is intended to apply in other
213 | circumstances.
214 |
215 | It is not the purpose of this section to induce you to infringe any
216 | patents or other property right claims or to contest validity of any
217 | such claims; this section has the sole purpose of protecting the
218 | integrity of the free software distribution system, which is
219 | implemented by public license practices. Many people have made
220 | generous contributions to the wide range of software distributed
221 | through that system in reliance on consistent application of that
222 | system; it is up to the author/donor to decide if he or she is willing
223 | to distribute software through any other system and a licensee cannot
224 | impose that choice.
225 |
226 | This section is intended to make thoroughly clear what is believed to
227 | be a consequence of the rest of this License.
228 |
229 | 8. If the distribution and/or use of the Program is restricted in
230 | certain countries either by patents or by copyrighted interfaces, the
231 | original copyright holder who places the Program under this License
232 | may add an explicit geographical distribution limitation excluding
233 | those countries, so that distribution is permitted only in or among
234 | countries not thus excluded. In such case, this License incorporates
235 | the limitation as if written in the body of this License.
236 |
237 | 9. The Free Software Foundation may publish revised and/or new versions
238 | of the General Public License from time to time. Such new versions will
239 | be similar in spirit to the present version, but may differ in detail to
240 | address new problems or concerns.
241 |
242 | Each version is given a distinguishing version number. If the Program
243 | specifies a version number of this License which applies to it and "any
244 | later version", you have the option of following the terms and conditions
245 | either of that version or of any later version published by the Free
246 | Software Foundation. If the Program does not specify a version number of
247 | this License, you may choose any version ever published by the Free Software
248 | Foundation.
249 |
250 | 10. If you wish to incorporate parts of the Program into other free
251 | programs whose distribution conditions are different, write to the author
252 | to ask for permission. For software which is copyrighted by the Free
253 | Software Foundation, write to the Free Software Foundation; we sometimes
254 | make exceptions for this. Our decision will be guided by the two goals
255 | of preserving the free status of all derivatives of our free software and
256 | of promoting the sharing and reuse of software generally.
257 |
258 | NO WARRANTY
259 |
260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268 | REPAIR OR CORRECTION.
269 |
270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278 | POSSIBILITY OF SUCH DAMAGES.
279 |
280 | END OF TERMS AND CONDITIONS
281 |
282 | How to Apply These Terms to Your New Programs
283 |
284 | If you develop a new program, and you want it to be of the greatest
285 | possible use to the public, the best way to achieve this is to make it
286 | free software which everyone can redistribute and change under these terms.
287 |
288 | To do so, attach the following notices to the program. It is safest
289 | to attach them to the start of each source file to most effectively
290 | convey the exclusion of warranty; and each file should have at least
291 | the "copyright" line and a pointer to where the full notice is found.
292 |
293 | {description}
294 | Copyright (C) {year} {fullname}
295 |
296 | This program is free software; you can redistribute it and/or modify
297 | it under the terms of the GNU General Public License as published by
298 | the Free Software Foundation; either version 2 of the License, or
299 | (at your option) any later version.
300 |
301 | This program is distributed in the hope that it will be useful,
302 | but WITHOUT ANY WARRANTY; without even the implied warranty of
303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304 | GNU General Public License for more details.
305 |
306 | You should have received a copy of the GNU General Public License along
307 | with this program; if not, write to the Free Software Foundation, Inc.,
308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309 |
310 | Also add information on how to contact you by electronic and paper mail.
311 |
312 | If the program is interactive, make it output a short notice like this
313 | when it starts in an interactive mode:
314 |
315 | Gnomovision version 69, Copyright (C) year name of author
316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317 | This is free software, and you are welcome to redistribute it
318 | under certain conditions; type `show c' for details.
319 |
320 | The hypothetical commands `show w' and `show c' should show the appropriate
321 | parts of the General Public License. Of course, the commands you use may
322 | be called something other than `show w' and `show c'; they could even be
323 | mouse-clicks or menu items--whatever suits your program.
324 |
325 | You should also get your employer (if you work as a programmer) or your
326 | school, if any, to sign a "copyright disclaimer" for the program, if
327 | necessary. Here is a sample; alter the names:
328 |
329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330 | `Gnomovision' (which makes passes at compilers) written by James Hacker.
331 |
332 | {signature of Ty Coon}, 1 April 1989
333 | Ty Coon, President of Vice
334 |
335 | This General Public License does not permit incorporating your program into
336 | proprietary programs. If your program is a subroutine library, you may
337 | consider it more useful to permit linking proprietary applications with the
338 | library. If this is what you want to do, use the GNU Lesser General
339 | Public License instead of this License.
340 |
341 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Script Merger for The Witcher 3
2 |
3 | I threw together this tool because I got tired of manually merging script files.
4 |
5 | - Checks your Mods folder for mod conflicts. Uses [QuickBMS](http://aluigi.altervista.org/quickbms.htm) to scan .bundle packages.
6 | - Merges .ws scripts or .xml files inside bundle packages using the powerful open-source merge tool [KDiff3](http://kdiff3.sourceforge.net/).
7 | - Packages new .bundle packages using the official mod tool [wcc_lite](http://www.nexusmods.com/witcher3/news/12625/?).
8 | - Detects updated merge source files using the [xxHash](https://github.com/Cyan4973/xxHash) algorithm by Yann Collet, [implemented in .NET](https://github.com/wilhelmliao/xxHash.NET) by Wilhelm Liao.
9 |
10 | **KDiff3 & other external binary dependencies aren't included in this source code.**
11 |
--------------------------------------------------------------------------------
/WitcherScriptMerger.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.25420.1
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WitcherScriptMerger", "WitcherScriptMerger\WitcherScriptMerger.csproj", "{B0417CBE-445D-47A0-8502-717BCFE63013}"
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 | {B0417CBE-445D-47A0-8502-717BCFE63013}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {B0417CBE-445D-47A0-8502-717BCFE63013}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {B0417CBE-445D-47A0-8502-717BCFE63013}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {B0417CBE-445D-47A0-8502-717BCFE63013}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | EndGlobal
23 |
--------------------------------------------------------------------------------
/WitcherScriptMerger/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
--------------------------------------------------------------------------------
/WitcherScriptMerger/AppSettings.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Configuration;
3 | using System.Reflection;
4 | using System.Windows.Forms;
5 |
6 | namespace WitcherScriptMerger
7 | {
8 | class AppSettings
9 | {
10 | string _assemblyPath;
11 |
12 | Configuration _cachedConfig;
13 | Configuration CachedConfig
14 | {
15 | get
16 | {
17 | if (_cachedConfig == null)
18 | _cachedConfig = ConfigurationManager.OpenExeConfiguration(_assemblyPath);
19 | return _cachedConfig;
20 | }
21 | }
22 |
23 | public bool HasConfigFile => CachedConfig.HasFile;
24 |
25 | public AppSettings()
26 | {
27 | _assemblyPath = Assembly.GetEntryAssembly().Location;
28 |
29 | if (!CachedConfig.HasFile)
30 | {
31 | MessageBox.Show(
32 | "Config file is missing.",
33 | "Script Merger Error",
34 | MessageBoxButtons.OK,
35 | MessageBoxIcon.Error);
36 | Environment.Exit(1);
37 | }
38 | }
39 |
40 | public void Set(string key, object value)
41 | {
42 | try
43 | {
44 | CachedConfig.AppSettings.Settings[key].Value = value.ToString();
45 | }
46 | catch
47 | {
48 | CachedConfig.AppSettings.Settings.Add(key, value.ToString());
49 | }
50 | }
51 |
52 | public T Get(string key)
53 | {
54 | try
55 | {
56 | if (CachedConfig.HasFile)
57 | {
58 | var valueString = CachedConfig.AppSettings.Settings[key].Value;
59 | var parseMethod = typeof(T).GetMethod("Parse", new Type[] { typeof(string) });
60 | var valueObject = parseMethod.Invoke(null, new object[] { valueString });
61 | return (T)valueObject;
62 | }
63 |
64 | Program.MainForm.ShowError($"Config file doesn't exist:\n\n{CachedConfig.FilePath}");
65 | return default(T);
66 | }
67 | catch
68 | {
69 | return default(T);
70 | }
71 | }
72 |
73 | public string Get(string key)
74 | {
75 | try
76 | {
77 | if (CachedConfig.HasFile)
78 | return CachedConfig.AppSettings.Settings[key].Value;
79 |
80 | Program.MainForm.ShowError($"Config file doesn't exist:\n\n{CachedConfig.FilePath}");
81 | return string.Empty;
82 | }
83 | catch
84 | {
85 | return string.Empty;
86 | }
87 | }
88 |
89 | public void Save()
90 | {
91 | try
92 | {
93 | CachedConfig.Save(ConfigurationSaveMode.Minimal);
94 | }
95 | catch (Exception ex)
96 | {
97 | Program.MainForm.ShowError($"Failed to save config due to error:\n\n{ex.Message}");
98 | }
99 | }
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/WitcherScriptMerger/Controls/ConflictTree.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Drawing;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Windows.Forms;
6 | using WitcherScriptMerger.FileIndex;
7 | using WitcherScriptMerger.Forms;
8 | using WitcherScriptMerger.LoadOrder;
9 |
10 | namespace WitcherScriptMerger.Controls
11 | {
12 | class ConflictTree : SMTree
13 | {
14 | #region Members
15 |
16 | public static readonly Color UnresolvedForeColor = Color.Red;
17 | public static readonly Color ResolvedForeColor = Color.Purple;
18 |
19 | public static readonly new Color FileNodeForeColor = UnresolvedForeColor;
20 |
21 | ToolStripSeparator _contextCustomLoadOrderSeparator = new ToolStripSeparator();
22 | ToolStripMenuItem _contextPrioritizeMod = new ToolStripMenuItem();
23 | ToolStripMenuItem _contextToggleMod = new ToolStripMenuItem();
24 | ToolStripMenuItem _contextRemoveFromCustomLoadOrder = new ToolStripMenuItem();
25 |
26 | #endregion
27 |
28 | public ConflictTree()
29 | {
30 | ContextNodeRegion.Items.AddRange(new ToolStripItem[]
31 | {
32 | _contextCustomLoadOrderSeparator,
33 | _contextPrioritizeMod,
34 | _contextToggleMod,
35 | _contextRemoveFromCustomLoadOrder
36 | });
37 | BuildContextMenu();
38 |
39 | // contextCustomLoadOrderSeparator
40 | _contextCustomLoadOrderSeparator.Name = "contextCustomLoadOrderSeparator";
41 | _contextCustomLoadOrderSeparator.Size = new Size(235, 6);
42 |
43 | // contextPrioritizeMod
44 | _contextPrioritizeMod.Name = "contextPrioritizeMod";
45 | _contextPrioritizeMod.Size = new Size(225, 22);
46 | _contextPrioritizeMod.Text = "Set Overall Mod Priority...";
47 | _contextPrioritizeMod.ToolTipText = "Lets you define the load order of your mods";
48 | _contextPrioritizeMod.Click += ContextPrioritizeMod;
49 |
50 | // contextToggleMod
51 | _contextToggleMod.Name = "contextToggleMod";
52 | _contextToggleMod.Size = new Size(225, 22);
53 | _contextToggleMod.ToolTipText = "Tells the game whether to load any of this mod's files";
54 | _contextToggleMod.Click += ContextToggleMod;
55 |
56 | // contextRemoveFromCustomLoadOrder
57 | _contextRemoveFromCustomLoadOrder.Name = "contextRemoveFromCustomLoadOrder";
58 | _contextRemoveFromCustomLoadOrder.Size = new Size(225, 22);
59 | _contextRemoveFromCustomLoadOrder.ToolTipText = "Removes this mod's custom load order settings";
60 | _contextRemoveFromCustomLoadOrder.Click += ContextRemoveFromCustomLoadOrder;
61 | }
62 |
63 | protected override void HandleCheckedChange()
64 | {
65 | if (IsCategoryNode(ClickedNode))
66 | {
67 | foreach (var fileNode in ClickedNode.GetTreeNodes())
68 | {
69 | fileNode.SetCheckedIfVisible(ClickedNode.Checked);
70 | foreach (var modNode in fileNode.GetTreeNodes())
71 | modNode.SetCheckedIfVisible(ClickedNode.Checked);
72 | }
73 | }
74 | else if (IsFileNode(ClickedNode))
75 | {
76 | foreach (var modNode in ClickedNode.GetTreeNodes())
77 | modNode.SetCheckedIfVisible(ClickedNode.Checked);
78 |
79 | var catNode = ClickedNode.Parent;
80 | catNode.Checked = catNode.AreAllVisibleCheckboxesChecked();
81 | }
82 | else if (IsModNode(ClickedNode))
83 | {
84 | var fileNode = ClickedNode.Parent;
85 | fileNode.Checked = fileNode.AreAllVisibleCheckboxesChecked();
86 |
87 | var catNode = fileNode.Parent;
88 | catNode.Checked = catNode.AreAllVisibleCheckboxesChecked();
89 | }
90 | Program.MainForm.EnableMergeIfValidSelection();
91 | }
92 |
93 | protected override void OnLeftMouseUp(MouseEventArgs e)
94 | {
95 | if (ClickedNode == null)
96 | return;
97 |
98 | TreeNode catNode;
99 | if (IsCategoryNode(ClickedNode))
100 | catNode = ClickedNode;
101 | else if (IsFileNode(ClickedNode))
102 | catNode = ClickedNode.Parent;
103 | else
104 | catNode = ClickedNode.Parent.Parent;
105 |
106 | var category = catNode.Tag as ModFileCategory;
107 | if (!category.IsSupported)
108 | {
109 | EndUpdate();
110 | IsUpdating = false;
111 | }
112 | else
113 | base.OnLeftMouseUp(e);
114 | }
115 |
116 | protected override void SetAllChecked(bool isChecked)
117 | {
118 | foreach (var catNode in CategoryNodes)
119 | {
120 | var category = catNode.Tag as ModFileCategory;
121 | if (!category.IsSupported)
122 | continue;
123 | catNode.Checked = isChecked;
124 | foreach (var fileNode in catNode.GetTreeNodes())
125 | {
126 | fileNode.Checked = isChecked;
127 | foreach (var modNode in fileNode.GetTreeNodes())
128 | modNode.SetCheckedIfVisible(isChecked);
129 | }
130 | }
131 | Program.MainForm.EnableMergeIfValidSelection();
132 | }
133 |
134 | protected override void SetContextItemAvailability()
135 | {
136 | base.SetContextItemAvailability();
137 |
138 | if (ClickedNode != null)
139 | {
140 | if (IsModNode(ClickedNode))
141 | {
142 | _contextCustomLoadOrderSeparator.Available = true;
143 | _contextPrioritizeMod.Available = true;
144 |
145 | foreach (var item in ContextNodeRegion.Items.Cast())
146 | {
147 | item.Enabled = Program.LoadOrder.IsValid;
148 | }
149 |
150 | var isDisabled = Program.LoadOrder.IsModDisabledByName(ClickedNode.Text);
151 |
152 | _contextToggleMod.Available = true;
153 | _contextToggleMod.Text =
154 | isDisabled
155 | ? "Enable Mod"
156 | : "Disable Mod";
157 |
158 | _contextRemoveFromCustomLoadOrder.Available = Program.LoadOrder.ContainsMod(ClickedNode.Text);
159 | _contextRemoveFromCustomLoadOrder.Text =
160 | isDisabled
161 | ? "Clear Priority && Disabled State"
162 | : "Clear Priority";
163 | }
164 | }
165 | else if (!this.IsEmpty())
166 | {
167 | ContextSelectAll.Available = CategoryNodes.Any(catNode => !catNode.Checked && (catNode.Tag as ModFileCategory).IsSupported);
168 |
169 | ContextDeselectAll.Available = ModNodes.Any(modNode => modNode.Checked);
170 | }
171 | }
172 |
173 | void ContextPrioritizeMod(object sender, EventArgs e)
174 | {
175 | RightClickedNode.BackColor = Color.Gainsboro;
176 |
177 | var modName = RightClickedNode.Text;
178 | int? inputVal;
179 |
180 | using (var prompt = new PriorityPrompt())
181 | {
182 | inputVal = prompt.ShowDialog(Program.LoadOrder.GetPriorityByName(modName));
183 | }
184 |
185 | RightClickedNode.BackColor = Color.Transparent;
186 |
187 | if (!inputVal.HasValue)
188 | return;
189 |
190 | Program.LoadOrder.Refresh();
191 | Program.LoadOrder.SetPriorityByName(modName, inputVal.Value);
192 | Program.LoadOrder.AddMergedModIfMissing();
193 | Program.LoadOrder.Save();
194 |
195 | SetStylesForCustomLoadOrder();
196 | }
197 |
198 | void ContextToggleMod(object sender, EventArgs e)
199 | {
200 | var modName = RightClickedNode.Text;
201 |
202 | Program.LoadOrder.Refresh();
203 | Program.LoadOrder.ToggleModByName(modName);
204 | Program.LoadOrder.AddMergedModIfMissing();
205 | Program.LoadOrder.Save();
206 |
207 | SetStylesForCustomLoadOrder();
208 |
209 | var fileNode = RightClickedNode.Parent;
210 |
211 | if ((fileNode.Parent.Tag as ModFileCategory).IsSupported)
212 | {
213 | fileNode.Checked = fileNode.GetTreeNodes()
214 | .Where(modNode => modNode.IsCheckBoxVisible())
215 | .All(modNode => modNode.Checked);
216 | }
217 |
218 | Program.MainForm.EnableMergeIfValidSelection();
219 | }
220 |
221 | void ContextRemoveFromCustomLoadOrder(object sender, EventArgs e)
222 | {
223 | Program.LoadOrder.Refresh();
224 |
225 | var modName = RightClickedNode.Text;
226 |
227 | var index = Program.LoadOrder.Mods.FindIndex(setting => setting.ModName.EqualsIgnoreCase(modName));
228 |
229 | if (index > -1)
230 | {
231 | Program.LoadOrder.Mods.RemoveAt(index);
232 | Program.LoadOrder.Save();
233 | }
234 |
235 | SetStylesForCustomLoadOrder();
236 | }
237 |
238 | internal void SetStylesForCustomLoadOrder()
239 | {
240 | foreach (var fileNode in FileNodes)
241 | {
242 | var modNames = fileNode.GetTreeNodes().Select(modNode => modNode.Text);
243 |
244 | var isResolved = Program.LoadOrder.HasResolvedConflict(modNames);
245 |
246 | var topPriorityMod =
247 | isResolved
248 | ? Program.LoadOrder.GetTopPriorityEnabledMod(modNames)
249 | : null;
250 |
251 | fileNode.ForeColor =
252 | isResolved
253 | ? ResolvedForeColor
254 | : UnresolvedForeColor;
255 |
256 | foreach (var modNode in fileNode.GetTreeNodes())
257 | {
258 | modNode.NodeFont = DefaultFont;
259 | modNode.ForeColor = DefaultForeColor;
260 | modNode.ToolTipText = "";
261 |
262 | var priority = Program.LoadOrder.GetPriorityByName(modNode.Text);
263 |
264 | modNode.ToolTipText =
265 | priority > -1
266 | ? $"Priority {priority}"
267 | : "No Priority";
268 |
269 | if (modNode.Text.EqualsIgnoreCase(topPriorityMod))
270 | {
271 | if (priority > -1)
272 | modNode.ToolTipText += " - Top priority in this conflict";
273 | }
274 | else if (isResolved)
275 | {
276 | modNode.ToolTipText += " - Overridden by a higher-priority mod";
277 | modNode.ForeColor = Color.Gray;
278 | }
279 |
280 | if (Program.LoadOrder.IsModDisabledByName(modNode.Text))
281 | {
282 | modNode.ToolTipText = "This mod is disabled in your custom load order";
283 | modNode.ForeColor = Color.Gray;
284 | modNode.SetFontStyle(FontStyle.Strikeout);
285 | modNode.Checked = false;
286 | modNode.SetIsCheckBoxVisible(false);
287 | }
288 | else if ((fileNode.Parent.Tag as ModFileCategory).IsSupported)
289 | modNode.SetIsCheckBoxVisible(true);
290 |
291 | var mergeFile = Program.Inventory
292 | ?.GetMergeByRelativePath(fileNode.Text)
293 | ?.GetHashByModName(modNode.Text);
294 | if (mergeFile != null && mergeFile.IsOutdated)
295 | {
296 | modNode.ToolTipText += " - CHANGED SINCE MERGE";
297 | modNode.SetFontStyle(FontStyle.Italic);
298 | }
299 | }
300 | }
301 | }
302 | }
303 | }
304 |
--------------------------------------------------------------------------------
/WitcherScriptMerger/Controls/MergeTree.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Drawing;
3 | using System.Linq;
4 | using System.Windows.Forms;
5 |
6 | namespace WitcherScriptMerger.Controls
7 | {
8 | class MergeTree : SMTree
9 | {
10 | #region Members
11 |
12 | public static readonly new Color FileNodeForeColor = Color.Blue;
13 |
14 | ToolStripMenuItem _contextOpenMergedFile = new ToolStripMenuItem();
15 | ToolStripMenuItem _contextOpenMergedFileDir = new ToolStripMenuItem();
16 | ToolStripMenuItem _contextDeleteAssociatedMerges = new ToolStripMenuItem();
17 | ToolStripMenuItem _contextDeleteMerge = new ToolStripMenuItem();
18 | ToolStripSeparator _contextDeleteSeparator = new ToolStripSeparator();
19 |
20 | #endregion
21 |
22 | public MergeTree()
23 | {
24 |
25 | ContextOpenRegion.Items.AddRange(new ToolStripItem[]
26 | {
27 | _contextOpenMergedFile,
28 | _contextOpenMergedFileDir
29 | });
30 | ContextNodeRegion.Items.AddRange(new ToolStripItem[]
31 | {
32 | _contextDeleteSeparator,
33 | _contextDeleteMerge,
34 | _contextDeleteAssociatedMerges
35 | });
36 | BuildContextMenu();
37 |
38 | // contextOpenMergedFile
39 | _contextOpenMergedFile.Name = "contextOpenMergedFile";
40 | _contextOpenMergedFile.Size = new Size(225, 22);
41 | _contextOpenMergedFile.Text = "Open Merged File";
42 | _contextOpenMergedFile.ToolTipText = "Opens the merged version of the file";
43 | _contextOpenMergedFile.Click += ContextOpenFile_Click;
44 |
45 | // contextOpenMergedFileDir
46 | _contextOpenMergedFileDir.Name = "contextOpenMergedFileDir";
47 | _contextOpenMergedFileDir.Size = new Size(225, 22);
48 | _contextOpenMergedFileDir.Text = "Open Merged File Directory";
49 | _contextOpenMergedFileDir.ToolTipText = "Opens the location of the merged version of the file";
50 | _contextOpenMergedFileDir.Click += ContextOpenDirectory_Click;
51 |
52 | // contextDeleteSeparator
53 | _contextDeleteSeparator.Name = "contextDeleteSeparator";
54 | _contextDeleteSeparator.Size = new Size(235, 6);
55 |
56 | // contextDeleteMerge
57 | _contextDeleteMerge.Name = "contextDeleteMerge";
58 | _contextDeleteMerge.Size = new Size(225, 22);
59 | _contextDeleteMerge.Text = "Delete This Merge";
60 | _contextDeleteMerge.ToolTipText = "Deletes the merged version of the file";
61 | _contextDeleteMerge.Click += ContextDeleteMerge_Click;
62 |
63 | // contextDeleteAssociatedMerges
64 | _contextDeleteAssociatedMerges.Name = "contextDeleteAssociatedMerges";
65 | _contextDeleteAssociatedMerges.Size = new Size(225, 22);
66 | _contextDeleteAssociatedMerges.Text = "Delete All {0} Merges";
67 | _contextDeleteAssociatedMerges.ToolTipText = "Deletes all merges that contain this mod's files";
68 | _contextDeleteAssociatedMerges.Click += ContextDeleteAssociatedMerges_Click;
69 | }
70 |
71 | protected override void HandleCheckedChange()
72 | {
73 | if (IsCategoryNode(ClickedNode))
74 | {
75 | foreach (var fileNode in ClickedNode.GetTreeNodes())
76 | fileNode.Checked = ClickedNode.Checked;
77 | }
78 | else if (IsFileNode(ClickedNode))
79 | {
80 | var catNode = ClickedNode.Parent;
81 | catNode.Checked = catNode.GetTreeNodes().All(node => node.Checked);
82 | }
83 | Program.MainForm.EnableUnmergeIfValidSelection();
84 | }
85 |
86 | protected override void OnLeftMouseUp(MouseEventArgs e)
87 | {
88 | if (ClickedNode != null && IsModNode(ClickedNode))
89 | ClickedNode = ClickedNode.Parent;
90 |
91 | base.OnLeftMouseUp(e);
92 | }
93 |
94 | protected override void SetAllChecked(bool isChecked)
95 | {
96 | foreach (var catNode in CategoryNodes)
97 | {
98 | catNode.Checked = isChecked;
99 | foreach (var fileNode in catNode.GetTreeNodes())
100 | fileNode.Checked = isChecked;
101 | }
102 | Program.MainForm.EnableUnmergeIfValidSelection();
103 | }
104 |
105 | void ContextDeleteMerge_Click(object sender, EventArgs e)
106 | {
107 | if (RightClickedNode == null)
108 | return;
109 |
110 | if (IsModNode(RightClickedNode))
111 | Program.MainForm.DeleteMerges(new TreeNode[] { RightClickedNode.Parent });
112 | else
113 | Program.MainForm.DeleteMerges(new TreeNode[] { RightClickedNode });
114 | }
115 |
116 | void ContextDeleteAssociatedMerges_Click(object sender, EventArgs e)
117 | {
118 | if (RightClickedNode == null || !IsModNode(RightClickedNode))
119 | return;
120 |
121 | // Find all file nodes that contain a node matching the clicked node
122 | var fileNodes = FileNodes.Where(node =>
123 | node.GetTreeNodes().Any(modNode =>
124 | modNode.Text == RightClickedNode.Text));
125 |
126 | Program.MainForm.DeleteMerges(fileNodes);
127 | }
128 |
129 | protected override void SetContextItemAvailability()
130 | {
131 | base.SetContextItemAvailability();
132 |
133 | if (ClickedNode != null)
134 | {
135 | if (ClickedNode.Tag != null && IsFileNode(ClickedNode))
136 | {
137 | _contextOpenMergedFile.Available = _contextOpenMergedFileDir.Available = true;
138 | }
139 |
140 | if (!IsCategoryNode(ClickedNode))
141 | {
142 | _contextDeleteMerge.Available = _contextDeleteSeparator.Available = true;
143 | if (IsModNode(ClickedNode))
144 | {
145 | _contextDeleteAssociatedMerges.Available = true;
146 | _contextDeleteAssociatedMerges.Text = $"Delete All {ClickedNode.Text} Merges";
147 | }
148 | }
149 | }
150 | else if (!this.IsEmpty())
151 | {
152 | ContextSelectAll.Available = CategoryNodes.Any(catNode => !catNode.Checked);
153 |
154 | ContextDeselectAll.Available = FileNodes.Any(fileNode => fileNode.Checked);
155 | }
156 | }
157 | }
158 | }
159 |
--------------------------------------------------------------------------------
/WitcherScriptMerger/Controls/SMTreeSorter.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 | using System.Windows.Forms;
3 | using WitcherScriptMerger.FileIndex;
4 | using WitcherScriptMerger.LoadOrder;
5 |
6 | namespace WitcherScriptMerger.Controls
7 | {
8 | class SMTreeSorter : IComparer
9 | {
10 | public int Compare(object x, object y)
11 | {
12 | var xNode = x as TreeNode;
13 | var yNode = y as TreeNode;
14 |
15 | switch (xNode.Level)
16 | {
17 | case (int)SMTree.LevelType.Categories:
18 | var xCat = (ModFileCategory)xNode.Tag;
19 | var yCat = (ModFileCategory)yNode.Tag;
20 | return xCat.OrderIndex.CompareTo(yCat.OrderIndex);
21 | case (int)SMTree.LevelType.Mods:
22 | return (new LoadOrderComparer()).Compare(xNode.Text, yNode.Text);
23 | default:
24 | return xNode.Text.CompareTo(yNode.Text);
25 | }
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/WitcherScriptMerger/Controls/ToolStripRegion.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 | using System.Windows.Forms;
3 |
4 | namespace WitcherScriptMerger.Controls
5 | {
6 | class ToolStripRegion
7 | {
8 | public ToolStripItemCollection Items;
9 |
10 | public bool Available => Items.Cast().Any(item => item.Available);
11 |
12 | public ToolStripRegion(ToolStrip owner, ToolStripItem[] value)
13 | {
14 | Items = new ToolStripItemCollection(owner, value);
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/WitcherScriptMerger/DeadCodeDetection.ruleset:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/WitcherScriptMerger/Extensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Drawing;
4 | using System.Linq;
5 | using System.Runtime.InteropServices;
6 | using System.Text.RegularExpressions;
7 | using System.Windows.Forms;
8 |
9 | namespace WitcherScriptMerger
10 | {
11 | using System.IO;
12 |
13 | static class Extensions
14 | {
15 | #region Strings
16 |
17 | public static string ReplaceIgnoreCase(this string s, string oldValue, string newValue)
18 | {
19 | return Regex.Replace(s, Regex.Escape(oldValue), newValue.Replace("$", "$$"), RegexOptions.IgnoreCase);
20 | }
21 |
22 | public static bool EqualsIgnoreCase(this string s, string otherString)
23 | {
24 | return s.Equals(otherString, StringComparison.InvariantCultureIgnoreCase);
25 | }
26 |
27 | public static int IndexOfIgnoreCase(this string s, string value, int startIndex = 0)
28 | {
29 | return s.IndexOf(value, startIndex, StringComparison.InvariantCultureIgnoreCase);
30 | }
31 |
32 | public static int LastIndexOfIgnoreCase(this string s, string value, int startIndex = -1)
33 | {
34 | if (startIndex == -1)
35 | startIndex = s.Length - 1;
36 | return s.LastIndexOf(value, startIndex, StringComparison.InvariantCultureIgnoreCase);
37 | }
38 |
39 | public static bool StartsWithIgnoreCase(this string s, string value)
40 | {
41 | return s.StartsWith(value, StringComparison.InvariantCultureIgnoreCase);
42 | }
43 |
44 | public static bool EndsWithIgnoreCase(this string s, string value)
45 | {
46 | return s.EndsWith(value, StringComparison.InvariantCultureIgnoreCase);
47 | }
48 |
49 | public static bool IsAlphaNumeric(this string s)
50 | {
51 | return new Regex("^[_a-zA-Z0-9]*$").IsMatch(s);
52 | }
53 |
54 | public static string GetPluralS(this int num)
55 | {
56 | return num == 1 ? "" : "s";
57 | }
58 |
59 | #endregion
60 |
61 | #region FileInfo
62 | public static string ResolveTargetFileFullName(this FileInfo fileInfo)
63 | {
64 | return fileInfo.Exists ? SimLink.GetSymbolicLinkTarget(fileInfo) : fileInfo.FullName;
65 | }
66 | #endregion
67 |
68 | #region Tree & Context Menu
69 |
70 | public static IEnumerable GetAvailableItems(this ContextMenuStrip menu)
71 | {
72 | return menu.Items.Cast().Where(item => item.Available);
73 | }
74 |
75 | public static void SetFontStyle(this TreeNode node, FontStyle style)
76 | {
77 | var currFont = node.NodeFont ?? Control.DefaultFont;
78 | node.NodeFont = new Font(currFont, style);
79 | }
80 |
81 | public static IEnumerable GetTreeNodes(this TreeNode node)
82 | {
83 | return node.Nodes.Cast();
84 | }
85 |
86 | public static Controls.SMTree.NodeMetadata GetMetadata(this TreeNode node)
87 | {
88 | return node.Tag as Controls.SMTree.NodeMetadata;
89 | }
90 |
91 | public static bool IsEmpty(this TreeView tree)
92 | {
93 | return (tree.Nodes.Count == 0);
94 | }
95 |
96 | #endregion
97 |
98 | #region Scrolling TreeView to Top
99 |
100 | const int WM_VSCROLL = 0x0115;
101 | const int SB_THUMBPOSITION = 0x0004;
102 |
103 | [DllImport("user32.dll", CharSet = CharSet.Auto)]
104 | static extern int SetScrollPos(IntPtr hWnd, int nBar, int nPos, bool bRedraw);
105 |
106 | [DllImport("User32.Dll", EntryPoint = "PostMessageA")]
107 | static extern bool PostMessage(IntPtr hWnd, uint msg, int wParam, int lParam);
108 |
109 | public static void ScrollToTop(this TreeView treeView)
110 | {
111 | if (SetScrollPos(treeView.Handle, WM_VSCROLL, 0, true) != -1)
112 | PostMessage(treeView.Handle, WM_VSCROLL, SB_THUMBPOSITION, 0);
113 | }
114 |
115 | #endregion
116 |
117 | #region TreeView Checkbox Visibility
118 |
119 | // From http://stackoverflow.com/a/22488652/1641069
120 |
121 | const int TVIF_STATE = 0x8;
122 | const int TVIS_STATEIMAGEMASK = 0xF000;
123 | const int TV_FIRST = 0x1100;
124 | const int TVM_GETITEM = TV_FIRST + 62;
125 | const int TVM_SETITEM = TV_FIRST + 63;
126 |
127 | [StructLayout(LayoutKind.Sequential, Pack = 8, CharSet = CharSet.Auto)]
128 | struct TVITEM
129 | {
130 | public int mask;
131 | public IntPtr hItem;
132 | public int state;
133 | public int stateMask;
134 | [MarshalAs(UnmanagedType.LPTStr)]
135 | public string lpszText;
136 | public int cchTextMax;
137 | public int iImage;
138 | public int iSelectedImage;
139 | public int cChildren;
140 | public IntPtr lParam;
141 | }
142 |
143 | [DllImport("user32.dll", CharSet = CharSet.Auto)]
144 | static extern IntPtr SendMessage(IntPtr hWnd, int Msg, IntPtr wParam, ref TVITEM lParam);
145 |
146 | ///
147 | /// Gets a value indicating if the checkbox is visible on the tree node.
148 | ///
149 | /// The tree node.
150 | /// true if the checkbox is visible on the tree node; otherwise false.
151 | public static bool IsCheckBoxVisible(this TreeNode node)
152 | {
153 | if (node == null)
154 | throw new ArgumentNullException("node");
155 | if (node.TreeView == null)
156 | throw new InvalidOperationException("The node does not belong to a tree.");
157 | var tvi = new TVITEM
158 | {
159 | hItem = node.Handle,
160 | mask = TVIF_STATE
161 | };
162 | var result = SendMessage(node.TreeView.Handle, TVM_GETITEM, node.Handle, ref tvi);
163 | if (result == IntPtr.Zero)
164 | throw new ApplicationException("Error getting TreeNode state.");
165 | var imageIndex = (tvi.state & TVIS_STATEIMAGEMASK) >> 12;
166 | return (imageIndex != 0);
167 | }
168 |
169 | ///
170 | /// Sets a value indicating if the checkbox is visible on the tree node.
171 | ///
172 | /// The tree node.
173 | /// true to make the checkbox visible on the tree node; otherwise false.
174 | public static void SetIsCheckBoxVisible(this TreeNode node, bool isVisible, bool applyToSubtree = false)
175 | {
176 | if (node.TreeView == null)
177 | throw new InvalidOperationException("The node does not belong to a tree.");
178 | var tvi = new TVITEM
179 | {
180 | hItem = node.Handle,
181 | mask = TVIF_STATE,
182 | stateMask = TVIS_STATEIMAGEMASK,
183 | state = (isVisible ? node.Checked ? 2 : 1 : 0) << 12
184 | };
185 | var result = SendMessage(node.TreeView.Handle, TVM_SETITEM, IntPtr.Zero, ref tvi);
186 | if (result == IntPtr.Zero)
187 | throw new ApplicationException("Error setting TreeNode state.");
188 |
189 | if (applyToSubtree)
190 | {
191 | foreach (var childNode in node.GetTreeNodes())
192 | {
193 | childNode.SetIsCheckBoxVisible(isVisible, applyToSubtree);
194 | }
195 | }
196 | }
197 |
198 | public static bool SetCheckedIfVisible(this TreeNode node, bool isChecked)
199 | {
200 | if (node.IsCheckBoxVisible())
201 | {
202 | node.Checked = isChecked;
203 | return true;
204 | }
205 | return false;
206 | }
207 |
208 | public static bool AreAllVisibleCheckboxesChecked(this TreeNode node)
209 | {
210 | return node.GetTreeNodes()
211 | .Where(child => child.IsCheckBoxVisible())
212 | .All(child => child.Checked);
213 | }
214 |
215 | #endregion
216 | }
217 | }
218 |
--------------------------------------------------------------------------------
/WitcherScriptMerger/FileIndex/ModFile.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Xml.Serialization;
6 | using WitcherScriptMerger.Inventory;
7 |
8 | namespace WitcherScriptMerger.FileIndex
9 | {
10 | public class ModFile
11 | {
12 | #region Members
13 |
14 | [XmlElement]
15 | public string RelativePath { get; set; }
16 |
17 | [XmlElement("IncludedMod")]
18 | public List Mods { get; private set; }
19 |
20 | [XmlElement]
21 | public string BundleName { get; set; }
22 |
23 | [XmlIgnore]
24 | public ModFileCategory Category
25 | {
26 | get
27 | {
28 | if (BundleName != null)
29 | {
30 | if (IsTextFile(RelativePath))
31 | return Categories.BundleText;
32 | else
33 | return Categories.BundleNotMergeable;
34 | }
35 | else if (IsScript(RelativePath))
36 | return Categories.Script;
37 | else if (IsXml(RelativePath))
38 | return Categories.Xml;
39 | else
40 | return Categories.FlatNotMergeable;
41 | }
42 | }
43 |
44 | [XmlIgnore]
45 | public bool IsBundleContent => (BundleName != null);
46 |
47 | [XmlIgnore]
48 | public bool HasConflict => (Mods.Count > 1);
49 |
50 | #endregion
51 |
52 | public ModFile(string relPath, string bundlePath = null)
53 | {
54 | RelativePath = relPath;
55 | Mods = new List();
56 | if (bundlePath != null)
57 | BundleName = Path.GetFileName(bundlePath);
58 | }
59 |
60 | public ModFile()
61 | {
62 | Mods = new List();
63 | }
64 |
65 | public bool ContainsMod(string modName)
66 | {
67 | return Mods.Any(mod => mod.Name.EqualsIgnoreCase(modName));
68 | }
69 |
70 | public string GetVanillaFile()
71 | {
72 | if (Category == Categories.Script)
73 | return Path.Combine(Paths.ScriptsDirectory, RelativePath);
74 | else if (Category == Categories.Xml)
75 | return Path.Combine(Paths.GameDirectory, RelativePath);
76 | else
77 | throw new Exception($"Can't get vanilla file for category '{Category.DisplayName}'.");
78 | }
79 |
80 | public string GetModFile(string modName)
81 | {
82 | if (Category == Categories.Script)
83 | return Path.Combine(Paths.ModsDirectory, modName, Paths.ModScriptBase, RelativePath);
84 | else if (Category == Categories.Xml)
85 | return Path.Combine(Paths.ModsDirectory, modName, RelativePath);
86 | else if (Category.IsBundled)
87 | return Path.Combine(Paths.ModsDirectory, modName, Paths.BundleBase, BundleName);
88 | else
89 | throw new NotImplementedException();
90 | }
91 |
92 | public static string GetModNameFromPath(string modFilePath)
93 | {
94 | if (!modFilePath.StartsWithIgnoreCase(Paths.ModsDirectory)) // Merged bundle content has internal path, not derived from mod folder
95 | return Paths.MergedBundleContent;
96 |
97 | var nameStart = Paths.ModsDirectory.Length + 1;
98 | var name = modFilePath.Substring(nameStart);
99 | return name.Substring(0, name.IndexOf('\\'));
100 | }
101 |
102 | public static bool IsScript(string path) => path.EndsWithIgnoreCase(".ws");
103 |
104 | public static bool IsXml(string path) => path.EndsWithIgnoreCase(".xml");
105 |
106 | public static bool IsFlatFile(string path) => (IsScript(path) || IsXml(path));
107 |
108 | public static bool IsBundle(string path) => path.EndsWithIgnoreCase(".bundle");
109 |
110 | public static bool IsTextFile(string path) => (path.EndsWithIgnoreCase(".ws") || path.EndsWithIgnoreCase(".xml") || path.EndsWithIgnoreCase(".txt") || path.EndsWithIgnoreCase(".csv"));
111 |
112 | public override string ToString()
113 | {
114 | return $"({Mods.Count} mod{Mods.Count.GetPluralS()}) {RelativePath}";
115 | }
116 | }
117 | }
--------------------------------------------------------------------------------
/WitcherScriptMerger/FileIndex/ModFileCategory.cs:
--------------------------------------------------------------------------------
1 | namespace WitcherScriptMerger.FileIndex
2 | {
3 | public class ModFileCategory
4 | {
5 | public ModFileCategory(int orderIndex, string displayName, string toolTipText, bool isSupported, bool isBundled)
6 | {
7 | OrderIndex = orderIndex;
8 | DisplayName = displayName;
9 | ToolTipText = toolTipText;
10 | IsSupported = isSupported;
11 | IsBundled = isBundled;
12 | }
13 |
14 | public int OrderIndex { get; private set; }
15 | public string DisplayName { get; private set; }
16 | public string ToolTipText { get; private set; }
17 | public bool IsSupported { get; private set; }
18 | public bool IsBundled { get; private set; }
19 |
20 | public override string ToString()
21 | {
22 | return DisplayName;
23 | }
24 | }
25 |
26 | static class Categories
27 | {
28 | public static ModFileCategory Script = new ModFileCategory(
29 | 1, "Scripts", "These plaintext .ws files can be merged", true, false);
30 |
31 | public static ModFileCategory Xml = new ModFileCategory(
32 | 2, "Non-Bundled XML", "These .xml text files can be merged", true, false);
33 |
34 | public static ModFileCategory BundleText = new ModFileCategory(
35 | 3, "Bundled Text", "These bundled text files can be merged", true, true);
36 |
37 | public static ModFileCategory BundleNotMergeable = new ModFileCategory(
38 | 4, "Bundled Non-text - Not Mergeable", "Right-click mods to define your load order instead of merging", false, true);
39 |
40 | public static ModFileCategory FlatNotMergeable = new ModFileCategory(
41 | 5, "Not Mergeable", "Script Merger doesn't know what these files are", false, false);
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/WitcherScriptMerger/FileIndex/ModFileIndex.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.IO;
5 | using System.Linq;
6 | using WitcherScriptMerger.Inventory;
7 | using WitcherScriptMerger.Tools;
8 |
9 | namespace WitcherScriptMerger.FileIndex
10 | {
11 | class ModFileIndex
12 | {
13 | public List Files;
14 |
15 | public IEnumerable Conflicts => Files.Where(f => f.HasConflict);
16 |
17 | public bool HasConflict => Files.Any(f => f.HasConflict);
18 |
19 | public int ModCount { get; private set; }
20 |
21 | public int ScriptCount { get; private set; }
22 |
23 | public int XmlCount { get; private set; }
24 |
25 | public int BundleCount { get; private set; }
26 |
27 | public ModFileIndex()
28 | {
29 | Files = new List();
30 | }
31 |
32 | public void BuildAsync(
33 | bool checkScripts, bool checkXml, bool checkBundles,
34 | ProgressChangedEventHandler progressHandler,
35 | RunWorkerCompletedEventHandler completedHandler)
36 | {
37 | var ignoredModNames = GetIgnoredModNames();
38 | var modDirPaths = Directory.GetDirectories(Paths.ModsDirectory, "mod*", SearchOption.TopDirectoryOnly)
39 | .Where(path => !ignoredModNames.Any(name => name.EqualsIgnoreCase(new DirectoryInfo(path).Name)))
40 | .ToList();
41 | ModCount = modDirPaths.Count;
42 | if (ModCount == 0)
43 | {
44 | Program.MainForm.ShowMessage("Can't find any mods in the Mods directory.");
45 | }
46 |
47 | var bgWorker = new BackgroundWorker
48 | {
49 | WorkerReportsProgress = true
50 | };
51 | bgWorker.DoWork += (sender, e) =>
52 | {
53 | var i = 0;
54 | ScriptCount = XmlCount = BundleCount = 0;
55 | foreach (var modDirPath in modDirPaths)
56 | {
57 | var modName = Path.GetFileName(modDirPath);
58 | var filePaths = Directory.GetFiles(modDirPath, "*", SearchOption.AllDirectories);
59 | var scriptPaths = filePaths.Where(path => ModFile.IsScript(path));
60 | var xmlPaths = filePaths.Where(path => ModFile.IsXml(path));
61 | var bundlePaths = filePaths.Where(path => ModFile.IsBundle(path));
62 |
63 | ScriptCount += scriptPaths.Count();
64 | XmlCount += xmlPaths.Count();
65 | BundleCount += bundlePaths.Count();
66 |
67 | if (checkScripts)
68 | {
69 | Files.AddRange(GetModFilesFromPaths(scriptPaths, Categories.Script, modName));
70 | }
71 | if (checkXml)
72 | {
73 | Files.AddRange(GetModFilesFromPaths(xmlPaths, Categories.Xml, modName));
74 | }
75 | if (checkBundles)
76 | {
77 | foreach (var bundlePath in bundlePaths)
78 | {
79 | var contentPaths = QuickBms.GetBundleContentPaths(bundlePath);
80 | Files.AddRange(GetModFilesFromPaths(contentPaths, Categories.BundleText, modName, bundlePath));
81 | }
82 | }
83 | var progressPct = (int)((float)++i / modDirPaths.Count * 100f);
84 | bgWorker.ReportProgress(progressPct, modName as object);
85 | }
86 | if (checkBundles)
87 | System.Threading.Thread.Sleep(500); // Wait for progress bar to fill completely
88 | };
89 | bgWorker.RunWorkerCompleted += completedHandler;
90 | bgWorker.ProgressChanged += progressHandler;
91 | bgWorker.RunWorkerAsync();
92 | }
93 |
94 | private List GetModFilesFromPaths(
95 | IEnumerable filePaths,
96 | ModFileCategory category,
97 | string modName, string bundlePath = null)
98 | {
99 | var fileList = new List();
100 | foreach (var filePath in filePaths)
101 | {
102 | string relPath = null;
103 | if (category == Categories.Script)
104 | relPath = Paths.GetRelativePath(filePath, Paths.ModScriptBase);
105 | else if (category == Categories.Xml)
106 | relPath = Paths.GetRelativePath(filePath, modName);
107 | else if (category == Categories.BundleText)
108 | relPath = filePath;
109 | else
110 | throw new NotImplementedException();
111 |
112 | var existingFile = Files.FirstOrDefault(file =>
113 | file.RelativePath.EqualsIgnoreCase(relPath));
114 | if (existingFile == null)
115 | {
116 | var newFile = (bundlePath != null
117 | ? new ModFile(relPath, bundlePath)
118 | : new ModFile(relPath));
119 | newFile.Mods.Add(new FileHash { Name = modName });
120 | fileList.Add(newFile);
121 | }
122 | else
123 | existingFile.Mods.Add(new FileHash { Name = modName });
124 | }
125 | return fileList;
126 | }
127 |
128 | private IEnumerable GetIgnoredModNames()
129 | {
130 | var ignoredNames = Program.Settings.Get("IgnoreModNames");
131 | return ignoredNames.Split(',')
132 | .Where(name => !string.IsNullOrWhiteSpace(name))
133 | .Select(name => name.Trim());
134 | }
135 | }
136 | }
137 |
--------------------------------------------------------------------------------
/WitcherScriptMerger/Forms/DependencyForm.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using System.Drawing;
4 | using System.IO;
5 | using System.Windows.Forms;
6 | using WitcherScriptMerger.Tools;
7 |
8 | namespace WitcherScriptMerger.Forms
9 | {
10 | partial class DependencyForm : Form
11 | {
12 | bool AreAnyPathsChanged
13 | {
14 | get
15 | {
16 | return (!txtKDiff3Path.Text.EqualsIgnoreCase(KDiff3.ExePath) ||
17 | !txtBmsPath.Text.EqualsIgnoreCase(QuickBms.ExePath) ||
18 | !txtBmsPluginPath.Text.EqualsIgnoreCase(QuickBms.PluginPath) ||
19 | !txtWccLitePath.Text.EqualsIgnoreCase(WccLite.ExePath));
20 | }
21 | }
22 |
23 | public DependencyForm()
24 | {
25 | InitializeComponent();
26 | }
27 |
28 | void DependencyForm_Load(object sender, EventArgs e)
29 | {
30 | txtKDiff3Path.Text = KDiff3.ExePath;
31 | txtBmsPath.Text = QuickBms.ExePath;
32 | txtBmsPluginPath.Text = QuickBms.PluginPath;
33 | txtWccLitePath.Text = WccLite.ExePath;
34 | btnOK.Select();
35 | }
36 |
37 | void btnOK_Click(object sender, EventArgs e)
38 | {
39 | var allValid =
40 | Color.LightGreen == txtKDiff3Path.BackColor &&
41 | Color.LightGreen == txtBmsPath.BackColor &&
42 | Color.LightGreen == txtBmsPluginPath.BackColor &&
43 | Color.LightGreen == txtWccLitePath.BackColor;
44 |
45 | if (!allValid &&
46 | DialogResult.No == MessageBox.Show(
47 | "Not all the files are located & valid. Save settings anyway?",
48 | "Missing Dependency",
49 | MessageBoxButtons.YesNo,
50 | MessageBoxIcon.Warning))
51 | {
52 | DialogResult = DialogResult.None;
53 | return;
54 | }
55 |
56 | if (AreAnyPathsChanged)
57 | {
58 | KDiff3.ExePath = UpdatePathSetting(KDiff3.ExePath, txtKDiff3Path.Text, "Kdiff3Path");
59 | QuickBms.ExePath = UpdatePathSetting(QuickBms.ExePath, txtBmsPath.Text, "QuickBmsPath");
60 | QuickBms.PluginPath = UpdatePathSetting(QuickBms.PluginPath, txtBmsPluginPath.Text, "QuickBmsPluginPath");
61 | WccLite.ExePath = UpdatePathSetting(WccLite.ExePath, txtWccLitePath.Text, "WccLitePath");
62 | Program.Settings.Save();
63 | }
64 |
65 | DialogResult = (allValid
66 | ? DialogResult.OK
67 | : DialogResult.Cancel);
68 | }
69 |
70 | string UpdatePathSetting(string oldPath, string newPath, string settingName)
71 | {
72 | if (oldPath.EqualsIgnoreCase(newPath))
73 | return oldPath;
74 | Program.Settings.Set(settingName, newPath);
75 | return newPath;
76 | }
77 |
78 | void btnCancel_Click(object sender, EventArgs e)
79 | {
80 | DialogResult = DialogResult.Cancel;
81 | }
82 |
83 | #region Selecting Files
84 |
85 | void btnKDiff3Path_Click(object sender, EventArgs e)
86 | {
87 | GetUserFileChoice(txtKDiff3Path, "Executables|*.exe");
88 | }
89 |
90 | void btnBmsPath_Click(object sender, EventArgs e)
91 | {
92 | GetUserFileChoice(txtBmsPath, "Executables|*.exe");
93 | }
94 |
95 | void btnBmsPluginPath_Click(object sender, EventArgs e)
96 | {
97 | GetUserFileChoice(txtBmsPluginPath, "QuickBMS Plugins|*.bms");
98 | }
99 |
100 | void btnWccLitePath_Click(object sender, EventArgs e)
101 | {
102 | GetUserFileChoice(txtWccLitePath, "Executables|*.exe");
103 | }
104 |
105 | void GetUserFileChoice(TextBox txt, string filter)
106 | {
107 | var dlgSelectFile = new OpenFileDialog();
108 | dlgSelectFile.Filter = filter;
109 | if (!string.IsNullOrWhiteSpace(txt.Text) && File.Exists(txt.Text))
110 | dlgSelectFile.FileName = txt.Text;
111 | if (DialogResult.OK == dlgSelectFile.ShowDialog())
112 | txt.Text = dlgSelectFile.FileName.Replace(Environment.CurrentDirectory + "\\", "");
113 | }
114 |
115 | #endregion
116 |
117 | #region Clicking Links
118 |
119 | void lnkKDiff3_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
120 | {
121 | Process.Start("http://kdiff3.sourceforge.net/");
122 | }
123 |
124 | void lnkBms_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
125 | {
126 | Process.Start("http://aluigi.altervista.org/quickbms.htm");
127 | }
128 |
129 | void lnkWccLite_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
130 | {
131 | Process.Start("http://www.nexusmods.com/witcher3/news/12625/?");
132 | }
133 |
134 | #endregion
135 |
136 | #region Validation
137 |
138 | void exe_TextChanged(object sender, EventArgs e)
139 | {
140 | ValidateTextBox(sender as TextBox, ".exe");
141 | }
142 |
143 | void bms_TextChanged(object sender, EventArgs e)
144 | {
145 | ValidateTextBox(sender as TextBox, ".bms");
146 | }
147 |
148 | void ValidateTextBox(TextBox txt, string validExtension)
149 | {
150 | var path = txt.Text;
151 | txt.BackColor = (path.EndsWithIgnoreCase(validExtension) && File.Exists(path)
152 | ? Color.LightGreen
153 | : Color.LightPink);
154 | }
155 |
156 | #endregion
157 | }
158 | }
--------------------------------------------------------------------------------
/WitcherScriptMerger/Forms/MergeReportForm.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace WitcherScriptMerger.Forms
2 | {
3 | partial class MergeReportForm
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 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MergeReportForm));
32 | this.txtFilePath1 = new System.Windows.Forms.TextBox();
33 | this.btnOpenFile1 = new System.Windows.Forms.Button();
34 | this.grpFile1 = new System.Windows.Forms.GroupBox();
35 | this.btnOpenDir1 = new System.Windows.Forms.Button();
36 | this.lblMergedFiles = new System.Windows.Forms.Label();
37 | this.grpMergedFile = new System.Windows.Forms.GroupBox();
38 | this.btnOpenMergedDir = new System.Windows.Forms.Button();
39 | this.btnOpenMergedFile = new System.Windows.Forms.Button();
40 | this.txtMergedPath = new System.Windows.Forms.TextBox();
41 | this.grpFile2 = new System.Windows.Forms.GroupBox();
42 | this.btnOpenDir2 = new System.Windows.Forms.Button();
43 | this.btnOpenFile2 = new System.Windows.Forms.Button();
44 | this.txtFilePath2 = new System.Windows.Forms.TextBox();
45 | this.btnOK = new System.Windows.Forms.Button();
46 | this.chkShowAfterMerge = new System.Windows.Forms.CheckBox();
47 | this.lblTempContentFiles = new System.Windows.Forms.Label();
48 | this.lblPlusAndArrow = new System.Windows.Forms.Label();
49 | this.grpFile1.SuspendLayout();
50 | this.grpMergedFile.SuspendLayout();
51 | this.grpFile2.SuspendLayout();
52 | this.SuspendLayout();
53 | //
54 | // txtFilePath1
55 | //
56 | this.txtFilePath1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
57 | | System.Windows.Forms.AnchorStyles.Right)));
58 | this.txtFilePath1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
59 | this.txtFilePath1.ForeColor = System.Drawing.SystemColors.ControlText;
60 | this.txtFilePath1.Location = new System.Drawing.Point(6, 19);
61 | this.txtFilePath1.Name = "txtFilePath1";
62 | this.txtFilePath1.ReadOnly = true;
63 | this.txtFilePath1.Size = new System.Drawing.Size(588, 20);
64 | this.txtFilePath1.TabIndex = 0;
65 | this.txtFilePath1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txt_KeyDown);
66 | //
67 | // btnOpenFile1
68 | //
69 | this.btnOpenFile1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
70 | this.btnOpenFile1.ForeColor = System.Drawing.SystemColors.ControlText;
71 | this.btnOpenFile1.Location = new System.Drawing.Point(7, 45);
72 | this.btnOpenFile1.Name = "btnOpenFile1";
73 | this.btnOpenFile1.Size = new System.Drawing.Size(290, 23);
74 | this.btnOpenFile1.TabIndex = 1;
75 | this.btnOpenFile1.Text = "Open File";
76 | this.btnOpenFile1.UseVisualStyleBackColor = true;
77 | this.btnOpenFile1.Click += new System.EventHandler(this.btnOpenFile1_Click);
78 | //
79 | // grpFile1
80 | //
81 | this.grpFile1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
82 | | System.Windows.Forms.AnchorStyles.Right)));
83 | this.grpFile1.Controls.Add(this.btnOpenDir1);
84 | this.grpFile1.Controls.Add(this.btnOpenFile1);
85 | this.grpFile1.Controls.Add(this.txtFilePath1);
86 | this.grpFile1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
87 | this.grpFile1.ForeColor = System.Drawing.Color.Red;
88 | this.grpFile1.Location = new System.Drawing.Point(12, 54);
89 | this.grpFile1.Name = "grpFile1";
90 | this.grpFile1.Size = new System.Drawing.Size(600, 79);
91 | this.grpFile1.TabIndex = 0;
92 | this.grpFile1.TabStop = false;
93 | this.grpFile1.Text = "Mod 1";
94 | //
95 | // btnOpenDir1
96 | //
97 | this.btnOpenDir1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
98 | this.btnOpenDir1.ForeColor = System.Drawing.SystemColors.ControlText;
99 | this.btnOpenDir1.Location = new System.Drawing.Point(303, 45);
100 | this.btnOpenDir1.Name = "btnOpenDir1";
101 | this.btnOpenDir1.Size = new System.Drawing.Size(291, 23);
102 | this.btnOpenDir1.TabIndex = 2;
103 | this.btnOpenDir1.Text = "Open Directory";
104 | this.btnOpenDir1.UseVisualStyleBackColor = true;
105 | this.btnOpenDir1.Click += new System.EventHandler(this.btnOpenDir1_Click);
106 | //
107 | // lblMergedFiles
108 | //
109 | this.lblMergedFiles.AutoSize = true;
110 | this.lblMergedFiles.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
111 | this.lblMergedFiles.Location = new System.Drawing.Point(12, 11);
112 | this.lblMergedFiles.Name = "lblMergedFiles";
113 | this.lblMergedFiles.Size = new System.Drawing.Size(185, 20);
114 | this.lblMergedFiles.TabIndex = 5;
115 | this.lblMergedFiles.Text = "Created new merged file!";
116 | //
117 | // grpMergedFile
118 | //
119 | this.grpMergedFile.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
120 | | System.Windows.Forms.AnchorStyles.Right)));
121 | this.grpMergedFile.Controls.Add(this.btnOpenMergedDir);
122 | this.grpMergedFile.Controls.Add(this.btnOpenMergedFile);
123 | this.grpMergedFile.Controls.Add(this.txtMergedPath);
124 | this.grpMergedFile.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
125 | this.grpMergedFile.ForeColor = System.Drawing.Color.Blue;
126 | this.grpMergedFile.Location = new System.Drawing.Point(12, 296);
127 | this.grpMergedFile.Name = "grpMergedFile";
128 | this.grpMergedFile.Size = new System.Drawing.Size(600, 77);
129 | this.grpMergedFile.TabIndex = 2;
130 | this.grpMergedFile.TabStop = false;
131 | this.grpMergedFile.Text = "Merged File";
132 | //
133 | // btnOpenMergedDir
134 | //
135 | this.btnOpenMergedDir.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
136 | this.btnOpenMergedDir.ForeColor = System.Drawing.SystemColors.ControlText;
137 | this.btnOpenMergedDir.Location = new System.Drawing.Point(303, 45);
138 | this.btnOpenMergedDir.Name = "btnOpenMergedDir";
139 | this.btnOpenMergedDir.Size = new System.Drawing.Size(291, 23);
140 | this.btnOpenMergedDir.TabIndex = 2;
141 | this.btnOpenMergedDir.Text = "Open Directory";
142 | this.btnOpenMergedDir.UseVisualStyleBackColor = true;
143 | this.btnOpenMergedDir.Click += new System.EventHandler(this.btnOpenOutputDir_Click);
144 | //
145 | // btnOpenMergedFile
146 | //
147 | this.btnOpenMergedFile.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
148 | this.btnOpenMergedFile.ForeColor = System.Drawing.SystemColors.ControlText;
149 | this.btnOpenMergedFile.Location = new System.Drawing.Point(7, 45);
150 | this.btnOpenMergedFile.Name = "btnOpenMergedFile";
151 | this.btnOpenMergedFile.Size = new System.Drawing.Size(290, 23);
152 | this.btnOpenMergedFile.TabIndex = 1;
153 | this.btnOpenMergedFile.Text = "Open File";
154 | this.btnOpenMergedFile.UseVisualStyleBackColor = true;
155 | this.btnOpenMergedFile.Click += new System.EventHandler(this.btnOpenOutputFile_Click);
156 | //
157 | // txtMergedPath
158 | //
159 | this.txtMergedPath.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
160 | | System.Windows.Forms.AnchorStyles.Right)));
161 | this.txtMergedPath.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
162 | this.txtMergedPath.ForeColor = System.Drawing.SystemColors.ControlText;
163 | this.txtMergedPath.Location = new System.Drawing.Point(6, 19);
164 | this.txtMergedPath.Name = "txtMergedPath";
165 | this.txtMergedPath.ReadOnly = true;
166 | this.txtMergedPath.Size = new System.Drawing.Size(588, 20);
167 | this.txtMergedPath.TabIndex = 0;
168 | this.txtMergedPath.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txt_KeyDown);
169 | //
170 | // grpFile2
171 | //
172 | this.grpFile2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
173 | | System.Windows.Forms.AnchorStyles.Right)));
174 | this.grpFile2.Controls.Add(this.btnOpenDir2);
175 | this.grpFile2.Controls.Add(this.btnOpenFile2);
176 | this.grpFile2.Controls.Add(this.txtFilePath2);
177 | this.grpFile2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
178 | this.grpFile2.ForeColor = System.Drawing.Color.Red;
179 | this.grpFile2.Location = new System.Drawing.Point(12, 161);
180 | this.grpFile2.Name = "grpFile2";
181 | this.grpFile2.Size = new System.Drawing.Size(600, 79);
182 | this.grpFile2.TabIndex = 1;
183 | this.grpFile2.TabStop = false;
184 | this.grpFile2.Text = "Mod 2";
185 | //
186 | // btnOpenDir2
187 | //
188 | this.btnOpenDir2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
189 | this.btnOpenDir2.ForeColor = System.Drawing.SystemColors.ControlText;
190 | this.btnOpenDir2.Location = new System.Drawing.Point(303, 45);
191 | this.btnOpenDir2.Name = "btnOpenDir2";
192 | this.btnOpenDir2.Size = new System.Drawing.Size(291, 23);
193 | this.btnOpenDir2.TabIndex = 2;
194 | this.btnOpenDir2.Text = "Open Directory";
195 | this.btnOpenDir2.UseVisualStyleBackColor = true;
196 | this.btnOpenDir2.Click += new System.EventHandler(this.btnOpenDir2_Click);
197 | //
198 | // btnOpenFile2
199 | //
200 | this.btnOpenFile2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
201 | this.btnOpenFile2.ForeColor = System.Drawing.SystemColors.ControlText;
202 | this.btnOpenFile2.Location = new System.Drawing.Point(7, 45);
203 | this.btnOpenFile2.Name = "btnOpenFile2";
204 | this.btnOpenFile2.Size = new System.Drawing.Size(290, 23);
205 | this.btnOpenFile2.TabIndex = 1;
206 | this.btnOpenFile2.Text = "Open File";
207 | this.btnOpenFile2.UseVisualStyleBackColor = true;
208 | this.btnOpenFile2.Click += new System.EventHandler(this.btnOpenFile2_Click);
209 | //
210 | // txtFilePath2
211 | //
212 | this.txtFilePath2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
213 | | System.Windows.Forms.AnchorStyles.Right)));
214 | this.txtFilePath2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
215 | this.txtFilePath2.ForeColor = System.Drawing.SystemColors.ControlText;
216 | this.txtFilePath2.Location = new System.Drawing.Point(6, 19);
217 | this.txtFilePath2.Name = "txtFilePath2";
218 | this.txtFilePath2.ReadOnly = true;
219 | this.txtFilePath2.Size = new System.Drawing.Size(588, 20);
220 | this.txtFilePath2.TabIndex = 0;
221 | this.txtFilePath2.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txt_KeyDown);
222 | //
223 | // btnOK
224 | //
225 | this.btnOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
226 | this.btnOK.DialogResult = System.Windows.Forms.DialogResult.Cancel;
227 | this.btnOK.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
228 | this.btnOK.Location = new System.Drawing.Point(504, 387);
229 | this.btnOK.Name = "btnOK";
230 | this.btnOK.Size = new System.Drawing.Size(107, 23);
231 | this.btnOK.TabIndex = 4;
232 | this.btnOK.Text = "OK";
233 | this.btnOK.UseVisualStyleBackColor = true;
234 | this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
235 | //
236 | // chkShowAfterMerge
237 | //
238 | this.chkShowAfterMerge.AutoSize = true;
239 | this.chkShowAfterMerge.Location = new System.Drawing.Point(16, 391);
240 | this.chkShowAfterMerge.Name = "chkShowAfterMerge";
241 | this.chkShowAfterMerge.Size = new System.Drawing.Size(185, 17);
242 | this.chkShowAfterMerge.TabIndex = 3;
243 | this.chkShowAfterMerge.Text = "&Show this report after each merge";
244 | this.chkShowAfterMerge.UseVisualStyleBackColor = true;
245 | //
246 | // lblTempContentFiles
247 | //
248 | this.lblTempContentFiles.AutoSize = true;
249 | this.lblTempContentFiles.Location = new System.Drawing.Point(233, 9);
250 | this.lblTempContentFiles.Name = "lblTempContentFiles";
251 | this.lblTempContentFiles.Size = new System.Drawing.Size(377, 26);
252 | this.lblTempContentFiles.TabIndex = 6;
253 | this.lblTempContentFiles.Text = "Note: The first 2 files listed below were temporarily unpacked from .bundle files" +
254 | ".\r\nThey will be deleted when all merges are finished.";
255 | //
256 | // lblPlusAndArrow
257 | //
258 | this.lblPlusAndArrow.AutoSize = true;
259 | this.lblPlusAndArrow.Font = new System.Drawing.Font("Microsoft Sans Serif", 20F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
260 | this.lblPlusAndArrow.Location = new System.Drawing.Point(297, 133);
261 | this.lblPlusAndArrow.Name = "lblPlusAndArrow";
262 | this.lblPlusAndArrow.Size = new System.Drawing.Size(31, 155);
263 | this.lblPlusAndArrow.TabIndex = 7;
264 | this.lblPlusAndArrow.Text = "+\r\n\r\n\r\n\r\n↓";
265 | this.lblPlusAndArrow.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
266 | //
267 | // MergeReportForm
268 | //
269 | this.AcceptButton = this.btnOK;
270 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
271 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
272 | this.CancelButton = this.btnOK;
273 | this.ClientSize = new System.Drawing.Size(624, 421);
274 | this.ControlBox = false;
275 | this.Controls.Add(this.lblTempContentFiles);
276 | this.Controls.Add(this.chkShowAfterMerge);
277 | this.Controls.Add(this.btnOK);
278 | this.Controls.Add(this.grpFile2);
279 | this.Controls.Add(this.grpMergedFile);
280 | this.Controls.Add(this.lblMergedFiles);
281 | this.Controls.Add(this.grpFile1);
282 | this.Controls.Add(this.lblPlusAndArrow);
283 | this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
284 | this.MaximumSize = new System.Drawing.Size(1920, 460);
285 | this.MinimumSize = new System.Drawing.Size(640, 455);
286 | this.Name = "MergeReportForm";
287 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
288 | this.Text = "Merge Finished";
289 | this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MergeReportForm_FormClosing);
290 | this.grpFile1.ResumeLayout(false);
291 | this.grpFile1.PerformLayout();
292 | this.grpMergedFile.ResumeLayout(false);
293 | this.grpMergedFile.PerformLayout();
294 | this.grpFile2.ResumeLayout(false);
295 | this.grpFile2.PerformLayout();
296 | this.ResumeLayout(false);
297 | this.PerformLayout();
298 |
299 | }
300 |
301 | #endregion
302 |
303 | private System.Windows.Forms.TextBox txtFilePath1;
304 | private System.Windows.Forms.Button btnOpenFile1;
305 | private System.Windows.Forms.GroupBox grpFile1;
306 | private System.Windows.Forms.Button btnOpenDir1;
307 | private System.Windows.Forms.Label lblMergedFiles;
308 | private System.Windows.Forms.GroupBox grpMergedFile;
309 | private System.Windows.Forms.Button btnOpenMergedDir;
310 | private System.Windows.Forms.Button btnOpenMergedFile;
311 | private System.Windows.Forms.TextBox txtMergedPath;
312 | private System.Windows.Forms.GroupBox grpFile2;
313 | private System.Windows.Forms.Button btnOpenDir2;
314 | private System.Windows.Forms.Button btnOpenFile2;
315 | private System.Windows.Forms.TextBox txtFilePath2;
316 | private System.Windows.Forms.Button btnOK;
317 | private System.Windows.Forms.CheckBox chkShowAfterMerge;
318 | private System.Windows.Forms.Label lblTempContentFiles;
319 | private System.Windows.Forms.Label lblPlusAndArrow;
320 | }
321 | }
--------------------------------------------------------------------------------
/WitcherScriptMerger/Forms/MergeReportForm.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Forms;
3 |
4 | namespace WitcherScriptMerger.Forms
5 | {
6 | partial class MergeReportForm : Form
7 | {
8 | #region Initialization
9 |
10 | public MergeReportForm(
11 | int mergeNum, int mergeTotal,
12 | string file1, string file2, string outputFile,
13 | string modName1, string modName2)
14 | {
15 | InitializeComponent();
16 |
17 | if (mergeTotal > 1)
18 | {
19 | Text += $" ({mergeNum} of {mergeTotal})"; // Window title
20 | if (mergeNum < mergeTotal)
21 | btnOK.Text = "Continue";
22 | }
23 |
24 | lblTempContentFiles.Visible = outputFile.StartsWithIgnoreCase(Paths.MergedBundleContent);
25 |
26 | grpFile1.Text = modName1;
27 | grpFile2.Text = modName2;
28 |
29 | txtFilePath1.Text = file1;
30 | txtFilePath2.Text = file2;
31 | txtMergedPath.Text = outputFile;
32 |
33 | chkShowAfterMerge.Checked = Program.Settings.Get("ReportAfterMerge");
34 |
35 | btnOK.Select();
36 |
37 | lblPlusAndArrow.Left = (ClientSize.Width / 2) - (lblPlusAndArrow.Width / 2);
38 | }
39 |
40 | void MergeReportForm_FormClosing(object sender, FormClosingEventArgs e)
41 | {
42 | Program.Settings.Set("ReportAfterMerge", chkShowAfterMerge.Checked);
43 | }
44 |
45 | #endregion
46 |
47 | #region Button Clicks
48 |
49 | void btnOpenFile1_Click(object sender, EventArgs e)
50 | {
51 | Program.TryOpenFile(txtFilePath1.Text);
52 | }
53 |
54 | void btnOpenFile2_Click(object sender, EventArgs e)
55 | {
56 | Program.TryOpenFile(txtFilePath2.Text);
57 | }
58 |
59 | void btnOpenOutputFile_Click(object sender, EventArgs e)
60 | {
61 | Program.TryOpenFile(txtMergedPath.Text);
62 | }
63 |
64 | void btnOpenDir1_Click(object sender, EventArgs e)
65 | {
66 | Program.TryOpenFileLocation(txtFilePath1.Text);
67 | }
68 |
69 | void btnOpenDir2_Click(object sender, EventArgs e)
70 | {
71 | Program.TryOpenFileLocation(txtFilePath2.Text);
72 | }
73 |
74 | void btnOpenOutputDir_Click(object sender, EventArgs e)
75 | {
76 | Program.TryOpenFileLocation(txtMergedPath.Text);
77 | }
78 |
79 | void btnOK_Click(object sender, EventArgs e)
80 | {
81 | DialogResult = DialogResult.OK;
82 | }
83 |
84 | #endregion
85 |
86 | void txt_KeyDown(object sender, KeyEventArgs e)
87 | {
88 | if (e.Control && e.KeyCode == Keys.A)
89 | (sender as TextBox).SelectAll();
90 | }
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/WitcherScriptMerger/Forms/MessageBoxManager.cs:
--------------------------------------------------------------------------------
1 | // From http://www.codeproject.com/Articles/18399/Localizing-System-MessageBox
2 |
3 | #pragma warning disable 0618
4 | using System.Text;
5 | using System.Runtime.InteropServices;
6 | using System.Security.Permissions;
7 |
8 | [assembly: SecurityPermission(SecurityAction.RequestMinimum, UnmanagedCode = true)]
9 | namespace System.Windows.Forms
10 | {
11 | class MessageBoxManager
12 | {
13 | private delegate IntPtr HookProc(int nCode, IntPtr wParam, IntPtr lParam);
14 | private delegate bool EnumChildProc(IntPtr hWnd, IntPtr lParam);
15 |
16 | private const int WH_CALLWNDPROCRET = 12;
17 | private const int WM_DESTROY = 0x0002;
18 | private const int WM_INITDIALOG = 0x0110;
19 | private const int WM_TIMER = 0x0113;
20 | private const int WM_USER = 0x400;
21 | private const int DM_GETDEFID = WM_USER + 0;
22 |
23 | private const int MBOK = 1;
24 | private const int MBCancel = 2;
25 | private const int MBAbort = 3;
26 | private const int MBRetry = 4;
27 | private const int MBIgnore = 5;
28 | private const int MBYes = 6;
29 | private const int MBNo = 7;
30 |
31 |
32 | [DllImport("user32.dll")]
33 | private static extern IntPtr SendMessage(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam);
34 |
35 | [DllImport("user32.dll")]
36 | private static extern IntPtr SetWindowsHookEx(int idHook, HookProc lpfn, IntPtr hInstance, int threadId);
37 |
38 | [DllImport("user32.dll")]
39 | private static extern int UnhookWindowsHookEx(IntPtr idHook);
40 |
41 | [DllImport("user32.dll")]
42 | private static extern IntPtr CallNextHookEx(IntPtr idHook, int nCode, IntPtr wParam, IntPtr lParam);
43 |
44 | [DllImport("user32.dll", EntryPoint = "GetWindowTextLengthW", CharSet = CharSet.Unicode)]
45 | private static extern int GetWindowTextLength(IntPtr hWnd);
46 |
47 | [DllImport("user32.dll", EntryPoint = "GetWindowTextW", CharSet = CharSet.Unicode)]
48 | private static extern int GetWindowText(IntPtr hWnd, StringBuilder text, int maxLength);
49 |
50 | [DllImport("user32.dll")]
51 | private static extern int EndDialog(IntPtr hDlg, IntPtr nResult);
52 |
53 | [DllImport("user32.dll")]
54 | private static extern bool EnumChildWindows(IntPtr hWndParent, EnumChildProc lpEnumFunc, IntPtr lParam);
55 |
56 | [DllImport("user32.dll", EntryPoint = "GetClassNameW", CharSet = CharSet.Unicode)]
57 | private static extern int GetClassName(IntPtr hWnd, StringBuilder lpClassName, int nMaxCount);
58 |
59 | [DllImport("user32.dll")]
60 | private static extern int GetDlgCtrlID(IntPtr hwndCtl);
61 |
62 | [DllImport("user32.dll")]
63 | private static extern IntPtr GetDlgItem(IntPtr hDlg, int nIDDlgItem);
64 |
65 | [DllImport("user32.dll", EntryPoint = "SetWindowTextW", CharSet = CharSet.Unicode)]
66 | private static extern bool SetWindowText(IntPtr hWnd, string lpString);
67 |
68 |
69 | [StructLayout(LayoutKind.Sequential)]
70 | public struct CWPRETSTRUCT
71 | {
72 | public IntPtr lResult;
73 | public IntPtr lParam;
74 | public IntPtr wParam;
75 | public uint message;
76 | public IntPtr hwnd;
77 | };
78 |
79 | private static HookProc hookProc;
80 | private static EnumChildProc enumProc;
81 | [ThreadStatic]
82 | private static IntPtr hHook;
83 | [ThreadStatic]
84 | private static int nButton;
85 |
86 | ///
87 | /// OK text
88 | ///
89 | public static string OK = "&OK";
90 | ///
91 | /// Cancel text
92 | ///
93 | public static string Cancel = "&Cancel";
94 | ///
95 | /// Abort text
96 | ///
97 | public static string Abort = "&Abort";
98 | ///
99 | /// Retry text
100 | ///
101 | public static string Retry = "&Retry";
102 | ///
103 | /// Ignore text
104 | ///
105 | public static string Ignore = "&Ignore";
106 | ///
107 | /// Yes text
108 | ///
109 | public static string Yes = "&Yes";
110 | ///
111 | /// No text
112 | ///
113 | public static string No = "&No";
114 |
115 | static MessageBoxManager()
116 | {
117 | hookProc = new HookProc(MessageBoxHookProc);
118 | enumProc = new EnumChildProc(MessageBoxEnumProc);
119 | hHook = IntPtr.Zero;
120 | }
121 |
122 | ///
123 | /// Enables MessageBoxManager functionality
124 | ///
125 | ///
126 | /// MessageBoxManager functionality is enabled on current thread only.
127 | /// Each thread that needs MessageBoxManager functionality has to call this method.
128 | ///
129 | public static void Register()
130 | {
131 | if (hHook != IntPtr.Zero)
132 | throw new NotSupportedException("One hook per thread allowed.");
133 | hHook = SetWindowsHookEx(WH_CALLWNDPROCRET, hookProc, IntPtr.Zero, AppDomain.GetCurrentThreadId());
134 | }
135 |
136 | ///
137 | /// Disables MessageBoxManager functionality
138 | ///
139 | ///
140 | /// Disables MessageBoxManager functionality on current thread only.
141 | ///
142 | public static void Unregister()
143 | {
144 | if (hHook != IntPtr.Zero)
145 | {
146 | UnhookWindowsHookEx(hHook);
147 | hHook = IntPtr.Zero;
148 | }
149 | }
150 |
151 | private static IntPtr MessageBoxHookProc(int nCode, IntPtr wParam, IntPtr lParam)
152 | {
153 | if (nCode < 0)
154 | return CallNextHookEx(hHook, nCode, wParam, lParam);
155 |
156 | CWPRETSTRUCT msg = (CWPRETSTRUCT)Marshal.PtrToStructure(lParam, typeof(CWPRETSTRUCT));
157 | IntPtr hook = hHook;
158 |
159 | if (msg.message == WM_INITDIALOG)
160 | {
161 | int nLength = GetWindowTextLength(msg.hwnd);
162 | StringBuilder className = new StringBuilder(10);
163 | GetClassName(msg.hwnd, className, className.Capacity);
164 | if (className.ToString() == "#32770")
165 | {
166 | nButton = 0;
167 | EnumChildWindows(msg.hwnd, enumProc, IntPtr.Zero);
168 | if (nButton == 1)
169 | {
170 | IntPtr hButton = GetDlgItem(msg.hwnd, MBCancel);
171 | if (hButton != IntPtr.Zero)
172 | SetWindowText(hButton, OK);
173 | }
174 | }
175 | }
176 |
177 | return CallNextHookEx(hook, nCode, wParam, lParam);
178 | }
179 |
180 | private static bool MessageBoxEnumProc(IntPtr hWnd, IntPtr lParam)
181 | {
182 | StringBuilder className = new StringBuilder(10);
183 | GetClassName(hWnd, className, className.Capacity);
184 | if (className.ToString() == "Button")
185 | {
186 | int ctlId = GetDlgCtrlID(hWnd);
187 | switch (ctlId)
188 | {
189 | case MBOK:
190 | SetWindowText(hWnd, OK);
191 | break;
192 | case MBCancel:
193 | SetWindowText(hWnd, Cancel);
194 | break;
195 | case MBAbort:
196 | SetWindowText(hWnd, Abort);
197 | break;
198 | case MBRetry:
199 | SetWindowText(hWnd, Retry);
200 | break;
201 | case MBIgnore:
202 | SetWindowText(hWnd, Ignore);
203 | break;
204 | case MBYes:
205 | SetWindowText(hWnd, Yes);
206 | break;
207 | case MBNo:
208 | SetWindowText(hWnd, No);
209 | break;
210 |
211 | }
212 | nButton++;
213 | }
214 |
215 | return true;
216 | }
217 | }
218 | }
219 |
--------------------------------------------------------------------------------
/WitcherScriptMerger/Forms/OptionsForm.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Forms;
3 |
4 | namespace WitcherScriptMerger.Forms
5 | {
6 | public partial class OptionsForm : Form
7 | {
8 | public OptionsForm()
9 | {
10 | InitializeComponent();
11 | }
12 |
13 | void Options_Load(object sender, EventArgs e)
14 | {
15 | chkCheckScripts.Checked = Program.Settings.Get("CheckScripts");
16 | chkCheckXmlFiles.Checked = Program.Settings.Get("CheckScripts");
17 | chkCheckBundleContents.Checked = Program.Settings.Get("CheckBundleContents");
18 |
19 | chkCollapseNotMergeable.Checked = Program.Settings.Get("CollapseNotMergeable");
20 | chkCollapseCustomLoadOrder.Checked = Program.Settings.Get("CollapseCustomLoadOrder");
21 |
22 | chkPromptOutdatedMerge.Checked = Program.Settings.Get("ValidateMergeSources");
23 | chkPromptPrioritize.Checked = Program.Settings.Get("ValidateCustomLoadOrder");
24 |
25 | chkReviewEachMerge.Checked = Program.Settings.Get("ReviewEachMerge");
26 | chkShowPathsInKDiff3.Checked = Program.Settings.Get("ShowPathsInKDiff3");
27 | chkCompletionSounds.Checked = Program.Settings.Get("PlayCompletionSounds");
28 | chkMergeReport.Checked = Program.Settings.Get("ReportAfterMerge");
29 | chkPackReport.Checked = Program.Settings.Get("ReportAfterPack");
30 |
31 | btnOK.Select();
32 | }
33 |
34 | void btnOK_Click(object sender, EventArgs e)
35 | {
36 | Save();
37 |
38 | DialogResult = DialogResult.OK;
39 | }
40 |
41 | void btnCancel_Click(object sender, EventArgs e)
42 | {
43 | DialogResult = DialogResult.Cancel;
44 | }
45 |
46 | void btnApply_Click(object sender, EventArgs e)
47 | {
48 | Save();
49 |
50 | DialogResult = DialogResult.None;
51 | }
52 |
53 | void Save()
54 | {
55 | Program.Settings.Set("CheckScripts", chkCheckScripts.Checked);
56 | Program.Settings.Set("CheckXmlFiles", chkCheckXmlFiles.Checked);
57 | Program.Settings.Set("CheckBundleContents", chkCheckBundleContents.Checked);
58 |
59 | Program.Settings.Set("CollapseNotMergeable", chkCollapseNotMergeable.Checked);
60 | Program.Settings.Set("CollapseCustomLoadOrder", chkCollapseCustomLoadOrder.Checked);
61 |
62 | Program.Settings.Set("ValidateMergeSources", chkPromptOutdatedMerge.Checked);
63 | Program.Settings.Set("ValidateCustomLoadOrder", chkPromptPrioritize.Checked);
64 |
65 | Program.Settings.Set("ReviewEachMerge", chkReviewEachMerge.Checked);
66 | Program.Settings.Set("ShowPathsInKDiff3", chkShowPathsInKDiff3.Checked);
67 | Program.Settings.Set("PlayCompletionSounds", chkCompletionSounds.Checked);
68 | Program.Settings.Set("ReportAfterMerge", chkMergeReport.Checked);
69 | Program.Settings.Set("ReportAfterPack", chkPackReport.Checked);
70 |
71 | Program.Settings.Save();
72 | }
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/WitcherScriptMerger/Forms/PackReportForm.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace WitcherScriptMerger.Forms
2 | {
3 | partial class PackReportForm
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 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(PackReportForm));
32 | this.txtBundlePath = new System.Windows.Forms.TextBox();
33 | this.btnOpenContentDir = new System.Windows.Forms.Button();
34 | this.lblContent = new System.Windows.Forms.Label();
35 | this.txtContent = new System.Windows.Forms.TextBox();
36 | this.btnOpenBundleDir = new System.Windows.Forms.Button();
37 | this.lblPackedBundle = new System.Windows.Forms.Label();
38 | this.btnOK = new System.Windows.Forms.Button();
39 | this.chkShowAfterPack = new System.Windows.Forms.CheckBox();
40 | this.label1 = new System.Windows.Forms.Label();
41 | this.SuspendLayout();
42 | //
43 | // txtBundlePath
44 | //
45 | this.txtBundlePath.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
46 | | System.Windows.Forms.AnchorStyles.Right)));
47 | this.txtBundlePath.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
48 | this.txtBundlePath.Location = new System.Drawing.Point(12, 77);
49 | this.txtBundlePath.Name = "txtBundlePath";
50 | this.txtBundlePath.ReadOnly = true;
51 | this.txtBundlePath.Size = new System.Drawing.Size(538, 20);
52 | this.txtBundlePath.TabIndex = 1;
53 | this.txtBundlePath.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txt_KeyDown);
54 | //
55 | // btnOpenContentDir
56 | //
57 | this.btnOpenContentDir.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
58 | this.btnOpenContentDir.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
59 | this.btnOpenContentDir.Location = new System.Drawing.Point(458, 114);
60 | this.btnOpenContentDir.Name = "btnOpenContentDir";
61 | this.btnOpenContentDir.Size = new System.Drawing.Size(92, 21);
62 | this.btnOpenContentDir.TabIndex = 2;
63 | this.btnOpenContentDir.Text = "Open Directory";
64 | this.btnOpenContentDir.UseVisualStyleBackColor = true;
65 | this.btnOpenContentDir.Click += new System.EventHandler(this.btnOpenContentDir_Click);
66 | //
67 | // lblContent
68 | //
69 | this.lblContent.AutoSize = true;
70 | this.lblContent.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
71 | this.lblContent.Location = new System.Drawing.Point(12, 118);
72 | this.lblContent.Name = "lblContent";
73 | this.lblContent.Size = new System.Drawing.Size(51, 13);
74 | this.lblContent.TabIndex = 12;
75 | this.lblContent.Text = "Content";
76 | //
77 | // txtContent
78 | //
79 | this.txtContent.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
80 | | System.Windows.Forms.AnchorStyles.Left)
81 | | System.Windows.Forms.AnchorStyles.Right)));
82 | this.txtContent.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
83 | this.txtContent.Location = new System.Drawing.Point(12, 139);
84 | this.txtContent.Multiline = true;
85 | this.txtContent.Name = "txtContent";
86 | this.txtContent.ReadOnly = true;
87 | this.txtContent.ScrollBars = System.Windows.Forms.ScrollBars.Both;
88 | this.txtContent.Size = new System.Drawing.Size(538, 190);
89 | this.txtContent.TabIndex = 3;
90 | this.txtContent.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txt_KeyDown);
91 | //
92 | // btnOpenBundleDir
93 | //
94 | this.btnOpenBundleDir.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
95 | this.btnOpenBundleDir.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
96 | this.btnOpenBundleDir.Location = new System.Drawing.Point(458, 52);
97 | this.btnOpenBundleDir.Name = "btnOpenBundleDir";
98 | this.btnOpenBundleDir.Size = new System.Drawing.Size(92, 21);
99 | this.btnOpenBundleDir.TabIndex = 0;
100 | this.btnOpenBundleDir.Text = "Open Directory";
101 | this.btnOpenBundleDir.UseVisualStyleBackColor = true;
102 | this.btnOpenBundleDir.Click += new System.EventHandler(this.btnOpenBundleDir_Click);
103 | //
104 | // lblPackedBundle
105 | //
106 | this.lblPackedBundle.AutoSize = true;
107 | this.lblPackedBundle.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
108 | this.lblPackedBundle.Location = new System.Drawing.Point(12, 11);
109 | this.lblPackedBundle.Name = "lblPackedBundle";
110 | this.lblPackedBundle.Size = new System.Drawing.Size(175, 20);
111 | this.lblPackedBundle.TabIndex = 8;
112 | this.lblPackedBundle.Text = "Packed new bundle file!";
113 | //
114 | // btnOK
115 | //
116 | this.btnOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
117 | this.btnOK.DialogResult = System.Windows.Forms.DialogResult.Cancel;
118 | this.btnOK.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
119 | this.btnOK.Location = new System.Drawing.Point(443, 335);
120 | this.btnOK.Name = "btnOK";
121 | this.btnOK.Size = new System.Drawing.Size(107, 23);
122 | this.btnOK.TabIndex = 5;
123 | this.btnOK.Text = "OK";
124 | this.btnOK.UseVisualStyleBackColor = true;
125 | this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
126 | //
127 | // chkShowAfterPack
128 | //
129 | this.chkShowAfterPack.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
130 | this.chkShowAfterPack.AutoSize = true;
131 | this.chkShowAfterPack.Location = new System.Drawing.Point(16, 337);
132 | this.chkShowAfterPack.Name = "chkShowAfterPack";
133 | this.chkShowAfterPack.Size = new System.Drawing.Size(202, 17);
134 | this.chkShowAfterPack.TabIndex = 4;
135 | this.chkShowAfterPack.Text = "&Show this report after packing bundle";
136 | this.chkShowAfterPack.UseVisualStyleBackColor = true;
137 | //
138 | // label1
139 | //
140 | this.label1.AutoSize = true;
141 | this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
142 | this.label1.Location = new System.Drawing.Point(12, 56);
143 | this.label1.Name = "label1";
144 | this.label1.Size = new System.Drawing.Size(116, 13);
145 | this.label1.TabIndex = 14;
146 | this.label1.Text = "Merged Bundle File";
147 | //
148 | // PackReportForm
149 | //
150 | this.AcceptButton = this.btnOK;
151 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
152 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
153 | this.CancelButton = this.btnOK;
154 | this.ClientSize = new System.Drawing.Size(562, 368);
155 | this.ControlBox = false;
156 | this.Controls.Add(this.label1);
157 | this.Controls.Add(this.txtBundlePath);
158 | this.Controls.Add(this.btnOpenContentDir);
159 | this.Controls.Add(this.btnOpenBundleDir);
160 | this.Controls.Add(this.lblContent);
161 | this.Controls.Add(this.chkShowAfterPack);
162 | this.Controls.Add(this.txtContent);
163 | this.Controls.Add(this.btnOK);
164 | this.Controls.Add(this.lblPackedBundle);
165 | this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
166 | this.MinimumSize = new System.Drawing.Size(360, 290);
167 | this.Name = "PackReportForm";
168 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
169 | this.Text = "Pack Finished";
170 | this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.PackReportForm_FormClosing);
171 | this.ResumeLayout(false);
172 | this.PerformLayout();
173 |
174 | }
175 |
176 | #endregion
177 |
178 | private System.Windows.Forms.TextBox txtBundlePath;
179 | private System.Windows.Forms.Button btnOpenBundleDir;
180 | private System.Windows.Forms.Label lblPackedBundle;
181 | private System.Windows.Forms.Button btnOK;
182 | private System.Windows.Forms.CheckBox chkShowAfterPack;
183 | private System.Windows.Forms.Label lblContent;
184 | private System.Windows.Forms.TextBox txtContent;
185 | private System.Windows.Forms.Button btnOpenContentDir;
186 | private System.Windows.Forms.Label label1;
187 | }
188 | }
--------------------------------------------------------------------------------
/WitcherScriptMerger/Forms/PackReportForm.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Windows.Forms;
4 |
5 | namespace WitcherScriptMerger.Forms
6 | {
7 | partial class PackReportForm : Form
8 | {
9 | #region Initialization
10 |
11 | public PackReportForm(string bundlePath)
12 | {
13 | InitializeComponent();
14 |
15 | txtBundlePath.Text = bundlePath;
16 |
17 | var contentPaths = Directory.GetFiles(Paths.MergedBundleContent, "*", SearchOption.AllDirectories);
18 | txtContent.Text = string.Join(Environment.NewLine, contentPaths);
19 |
20 | chkShowAfterPack.Checked = Program.Settings.Get("ReportAfterPack");
21 |
22 | btnOK.Select();
23 | }
24 |
25 | void PackReportForm_FormClosing(object sender, FormClosingEventArgs e)
26 | {
27 | Program.Settings.Set("ReportAfterPack", chkShowAfterPack.Checked);
28 | }
29 |
30 | #endregion
31 |
32 | #region Button Clicks
33 |
34 | void btnOpenBundleDir_Click(object sender, EventArgs e)
35 | {
36 | Program.TryOpenFileLocation(txtBundlePath.Text);
37 | }
38 |
39 | void btnOpenContentDir_Click(object sender, EventArgs e)
40 | {
41 | Program.TryOpenDirectory(Paths.MergedBundleContent);
42 | }
43 |
44 | void btnOK_Click(object sender, EventArgs e)
45 | {
46 | DialogResult = DialogResult.OK;
47 | }
48 |
49 | #endregion
50 |
51 | void txt_KeyDown(object sender, KeyEventArgs e)
52 | {
53 | if (e.Control && e.KeyCode == Keys.A)
54 | (sender as TextBox).SelectAll();
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/WitcherScriptMerger/Forms/PriorityPrompt.cs:
--------------------------------------------------------------------------------
1 | using System.Drawing;
2 | using System.Windows.Forms;
3 | using WitcherScriptMerger.LoadOrder;
4 |
5 | namespace WitcherScriptMerger.Forms
6 | {
7 | class PriorityPrompt : Form
8 | {
9 | const int Spacing = 5;
10 |
11 | NumericUpDown _inputField;
12 | TextBox _innerTextBox;
13 | Button _okButton;
14 |
15 | public int? ShowDialog(int value = 0)
16 | {
17 | _inputField = new NumericUpDown
18 | {
19 | Left = Spacing,
20 | Top = Spacing,
21 | Width = 50,
22 | Increment = 1,
23 | DecimalPlaces = 0,
24 | Minimum = CustomLoadOrder.TopPriority + 1,
25 | Maximum = CustomLoadOrder.BottomPriority,
26 | };
27 | _innerTextBox = (TextBox)_inputField.Controls[1];
28 | _innerTextBox.KeyDown += InputField_KeyDown;
29 | _innerTextBox.TextChanged += InputField_TextChanged;
30 |
31 | _okButton = new Button
32 | {
33 | Text = "&OK",
34 | Left = _inputField.Left + _inputField.Width + Spacing,
35 | Width = 50,
36 | DialogResult = DialogResult.OK
37 | };
38 | _okButton.Top = _inputField.Top - (System.Math.Abs(_okButton.Height - _inputField.Height) / 2);
39 |
40 | FormBorderStyle = FormBorderStyle.FixedToolWindow;
41 | Text = "Set Priority";
42 | ClientSize = new Size
43 | {
44 | Width = Spacing + _inputField.Width + Spacing + _okButton.Width + Spacing,
45 | Height = Spacing + _inputField.Height + Spacing
46 | };
47 | StartPosition = FormStartPosition.CenterParent;
48 | MinimizeBox = MaximizeBox = false;
49 | AcceptButton = _okButton;
50 | Icon = Program.MainForm.Icon;
51 | Controls.AddRange(
52 | new Control[]
53 | {
54 | _inputField,
55 | _okButton
56 | });
57 | KeyPreview = true;
58 | KeyDown += OnKeyDown;
59 |
60 | if (value >= _inputField.Minimum && value <= _inputField.Maximum)
61 | _inputField.Value = value;
62 |
63 | return
64 | base.ShowDialog() == DialogResult.OK
65 | ? (int?)System.Convert.ToInt32(_inputField.Value)
66 | : null;
67 | }
68 |
69 | private void InputField_TextChanged(object sender, System.EventArgs e)
70 | {
71 | _okButton.Enabled = !string.IsNullOrWhiteSpace((sender as TextBox).Text);
72 | }
73 |
74 | void InputField_KeyDown(object sender, KeyEventArgs e)
75 | {
76 | e.SuppressKeyPress =
77 | (e.KeyCode == Keys.Subtract) ||
78 | (IsCharacterCountMaxed() && !HasSelection() && IsNumeric(e.KeyCode)) ||
79 | (_innerTextBox.SelectionStart == 0 && (e.KeyCode == Keys.D0 || e.KeyCode == Keys.NumPad0));
80 | }
81 |
82 | bool IsCharacterCountMaxed()
83 | {
84 | return _innerTextBox.Text.Length == _inputField.Maximum.ToString().Length;
85 | }
86 |
87 | bool HasSelection()
88 | {
89 | return _innerTextBox.SelectionLength > 0;
90 | }
91 |
92 | bool IsNumeric(Keys keyCode)
93 | {
94 | return
95 | (keyCode >= Keys.D0 && keyCode <= Keys.D9) ||
96 | (keyCode >= Keys.NumPad0 && keyCode <= Keys.NumPad9);
97 | }
98 |
99 | void OnKeyDown(object sender, KeyEventArgs e)
100 | {
101 | if (e.KeyCode == Keys.Escape)
102 | Close();
103 | }
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/WitcherScriptMerger/Inventory/FileHash.cs:
--------------------------------------------------------------------------------
1 | using System.Xml.Serialization;
2 |
3 | namespace WitcherScriptMerger.Inventory
4 | {
5 | [XmlRoot]
6 | public class FileHash
7 | {
8 | [XmlAttribute]
9 | public string Hash { get; set; }
10 |
11 | [XmlText]
12 | public string Name { get; set; }
13 |
14 | [XmlIgnore]
15 | public bool IsOutdated { get; set; }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/WitcherScriptMerger/Inventory/Merge.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Linq;
4 | using System.Xml.Serialization;
5 | using WitcherScriptMerger.FileIndex;
6 |
7 | namespace WitcherScriptMerger.Inventory
8 | {
9 | [XmlRoot]
10 | public class Merge : ModFile
11 | {
12 | [XmlElement]
13 | public string MergedModName;
14 |
15 | public string GetMergedFile()
16 | {
17 | if (Category == Categories.Script)
18 | return Path.Combine(Paths.ModsDirectory, MergedModName, Paths.ModScriptBase, RelativePath);
19 | else if (Category == Categories.Xml)
20 | return Path.Combine(Paths.ModsDirectory, MergedModName, RelativePath);
21 | else if (Category == Categories.BundleText)
22 | return Path.Combine(Paths.MergedBundleContent, RelativePath);
23 | else
24 | throw new NotImplementedException();
25 | }
26 |
27 | public string GetMergedBundle()
28 | {
29 | if (Category != Categories.BundleText)
30 | throw new Exception($"Can't get bundle for file of category '{Category.DisplayName}'.");
31 |
32 | return Path.Combine(Paths.ModsDirectory, MergedModName, Paths.BundleBase, BundleName);
33 | }
34 |
35 | public FileHash GetHashByModName(string modName)
36 | {
37 | return Mods.FirstOrDefault(m => m.Name.EqualsIgnoreCase(modName));
38 | }
39 | }
40 | }
--------------------------------------------------------------------------------
/WitcherScriptMerger/Inventory/MergeInventory.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.ObjectModel;
2 | using System.IO;
3 | using System.Linq;
4 | using System.Xml.Serialization;
5 | using WitcherScriptMerger.FileIndex;
6 | using WitcherScriptMerger.LoadOrder;
7 |
8 | namespace WitcherScriptMerger.Inventory
9 | {
10 | [XmlRoot]
11 | public class MergeInventory
12 | {
13 | [XmlElement("Merge")]
14 | public ObservableCollection Merges { get; private set; }
15 |
16 | [XmlIgnore]
17 | public bool ScriptsChanged { get; private set; }
18 |
19 | [XmlIgnore]
20 | public bool XmlChanged { get; private set; }
21 |
22 | [XmlIgnore]
23 | public bool BundleChanged { get; private set; }
24 |
25 | [XmlIgnore]
26 | public bool HasChanged => (ScriptsChanged || XmlChanged || BundleChanged);
27 |
28 | static XmlSerializer _serializer = new XmlSerializer(typeof(MergeInventory));
29 |
30 | public MergeInventory()
31 | {
32 | Merges = new ObservableCollection();
33 | Merges.CollectionChanged += Merges_CollectionChanged;
34 | }
35 |
36 | public static MergeInventory Load(string path)
37 | {
38 | MergeInventory inventory;
39 | try
40 | {
41 | _serializer = new XmlSerializer(typeof(MergeInventory));
42 | using (var stream = File.OpenRead(path))
43 | {
44 | inventory = (MergeInventory)_serializer.Deserialize(stream);
45 | }
46 |
47 | AddMissingHashes(inventory);
48 | }
49 | catch
50 | {
51 | inventory = new MergeInventory();
52 | }
53 | inventory.ScriptsChanged = inventory.XmlChanged = inventory.BundleChanged = false;
54 | return inventory;
55 | }
56 |
57 | void Merges_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
58 | {
59 | if ((e.NewItems != null && e.NewItems.Cast().Any(merge => merge.Category == Categories.Script)) ||
60 | (e.OldItems != null && e.OldItems.Cast().Any(merge => merge.Category == Categories.Script)))
61 | ScriptsChanged = true;
62 | if ((e.NewItems != null && e.NewItems.Cast().Any(merge => merge.Category == Categories.Xml)) ||
63 | (e.OldItems != null && e.OldItems.Cast().Any(merge => merge.Category == Categories.Xml)))
64 | XmlChanged = true;
65 | if ((e.NewItems != null && e.NewItems.Cast().Any(merge => merge.IsBundleContent)) ||
66 | (e.OldItems != null && e.OldItems.Cast().Any(merge => merge.IsBundleContent)))
67 | BundleChanged = true;
68 | }
69 |
70 | public void AddModToMerge(FileMerger.MergeSource source, Merge m)
71 | {
72 | var modFilePath =
73 | m.IsBundleContent
74 | ? source.Bundle.FullName
75 | : source.TextFile.FullName;
76 |
77 | var existingMod = m.Mods.Find(mod => mod.Name.EqualsIgnoreCase(source.Name));
78 | if (existingMod != null)
79 | existingMod.Hash = Tools.Hasher.ComputeHash(modFilePath);
80 | else
81 | {
82 | m.Mods.Add(
83 | new FileHash
84 | {
85 | Hash = Tools.Hasher.ComputeHash(modFilePath),
86 | Name = source.Name
87 | });
88 | }
89 |
90 | if (m.Category == Categories.Script)
91 | ScriptsChanged = true;
92 | else if (m.Category == Categories.Xml)
93 | XmlChanged = true;
94 | else if (m.IsBundleContent)
95 | BundleChanged = true;
96 | }
97 |
98 | public void Save()
99 | {
100 | if (_serializer == null)
101 | return;
102 | using (var writer = new StreamWriter(Paths.Inventory))
103 | {
104 | _serializer.Serialize(writer, this);
105 | }
106 | }
107 |
108 | public bool HasResolvedConflict(ModFile conflict)
109 | {
110 | var merge = Merges.FirstOrDefault(mrg => mrg.RelativePath.EqualsIgnoreCase(conflict.RelativePath));
111 | if (merge == null)
112 | return false;
113 |
114 | if (conflict.Mods.Any(mod => !mod.Name.EqualsIgnoreCase(merge.MergedModName) && !merge.ContainsMod(mod.Name)))
115 | return false;
116 |
117 | if (merge.Mods.Any(mod => new LoadOrderComparer().Compare(merge.MergedModName, mod.Name) > 0))
118 | return false;
119 |
120 | return
121 | merge.Mods.All(mod => mod.Hash == Tools.Hasher.ComputeHash(merge.GetModFile(mod.Name)));
122 | }
123 |
124 | public Merge GetMergeByRelativePath(string relativePath)
125 | {
126 | return Merges.FirstOrDefault(m => m.RelativePath.EqualsIgnoreCase(relativePath));
127 | }
128 |
129 | // Adds file hashes to old inventories that don't have them
130 | static void AddMissingHashes(MergeInventory inventory)
131 | {
132 | var anyMissing = false;
133 |
134 | foreach (var merge in inventory.Merges)
135 | {
136 | foreach (var mod in merge.Mods)
137 | {
138 | if (mod.Hash == null)
139 | {
140 | anyMissing = true;
141 | mod.Hash = Tools.Hasher.ComputeHash(merge.GetModFile(mod.Name));
142 | }
143 | }
144 | }
145 |
146 | if (anyMissing)
147 | inventory.Save();
148 | }
149 | }
150 | }
151 |
--------------------------------------------------------------------------------
/WitcherScriptMerger/Inventory/MergeProgressInfo.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel;
2 |
3 | namespace WitcherScriptMerger.Inventory
4 | {
5 | public class MergeProgressInfo : INotifyPropertyChanged
6 | {
7 | string _currentAction;
8 | public string CurrentAction
9 | {
10 | get { return _currentAction; }
11 | set { Set(ref _currentAction, value); }
12 | }
13 |
14 | string _currentPhase;
15 | public string CurrentPhase
16 | {
17 | get { return _currentPhase; }
18 | set { Set(ref _currentPhase, value); }
19 | }
20 |
21 | int _currentMergeNum;
22 | public int CurrentMergeNum
23 | {
24 | get { return _currentMergeNum; }
25 | set
26 | {
27 | _currentMergeNum = value;
28 | UpdatePhase();
29 | }
30 | }
31 |
32 | int _totalMergeCount;
33 | public int TotalMergeCount
34 | {
35 | get { return _totalMergeCount; }
36 | set
37 | {
38 | _totalMergeCount = value;
39 | UpdatePhase();
40 | }
41 | }
42 |
43 | string _currentFileName;
44 | public string CurrentFileName
45 | {
46 | get { return _currentFileName; }
47 | set
48 | {
49 | _currentFileName = value;
50 | UpdatePhase();
51 | }
52 | }
53 |
54 | int _currentFileNum;
55 | public int CurrentFileNum
56 | {
57 | get { return _currentFileNum; }
58 | set
59 | {
60 | _currentFileNum = value;
61 | UpdatePhase();
62 | }
63 | }
64 |
65 | int _totalFileCount;
66 | public int TotalFileCount
67 | {
68 | get { return _totalFileCount; }
69 | set
70 | {
71 | _totalFileCount = value;
72 | UpdatePhase();
73 | }
74 | }
75 |
76 | public event PropertyChangedEventHandler PropertyChanged;
77 |
78 | protected virtual void OnPropertyChanged()
79 | {
80 | PropertyChanged?.Invoke(this, null);
81 | }
82 |
83 | void Set(ref T property, T value)
84 | {
85 | property = value;
86 | OnPropertyChanged();
87 | }
88 |
89 | void UpdatePhase()
90 | {
91 | CurrentPhase =
92 | "Resolving mod conflict" +
93 | (
94 | TotalMergeCount > 1
95 | ? $" {CurrentMergeNum} of {TotalMergeCount}" : ""
96 | ) +
97 | "\nFile" +
98 | (
99 | TotalFileCount > 1 && TotalFileCount != TotalMergeCount
100 | ? $" {CurrentFileNum} of {TotalFileCount}" : ""
101 | ) +
102 | $": {CurrentFileName}";
103 | }
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/WitcherScriptMerger/LoadOrder/CustomLoadOrder.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Text.RegularExpressions;
7 |
8 | namespace WitcherScriptMerger.LoadOrder
9 | {
10 | class CustomLoadOrder
11 | {
12 | public const int TopPriority = 0;
13 | public const int BottomPriority = 9999;
14 |
15 | public readonly string FilePath =
16 | Path.Combine(
17 | Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
18 | "The Witcher 3",
19 | "mods.settings");
20 |
21 | public List Mods { get; private set; }
22 |
23 | public bool IsValid { get; private set; }
24 |
25 | public CustomLoadOrder()
26 | {
27 | Refresh();
28 | }
29 |
30 | #region File Processing
31 |
32 | public void Refresh()
33 | {
34 | Mods = new List();
35 | IsValid = false;
36 |
37 | if (!File.Exists(FilePath))
38 | {
39 | IsValid = true;
40 | return;
41 | }
42 |
43 | var lines = File.ReadAllLines(FilePath);
44 |
45 | List mods = new List();
46 | ModLoadSetting currModSetting = null;
47 |
48 | for (int i = 0; i < lines.Length; ++i)
49 | {
50 | if (!ProcessLine(lines[i], i + 1, ref currModSetting))
51 | return;
52 |
53 | if (currModSetting != null
54 | && currModSetting.IsEnabled.HasValue
55 | && currModSetting.Priority.HasValue)
56 | {
57 | mods.Add(currModSetting);
58 | currModSetting = null;
59 | }
60 | }
61 |
62 | IsValid = true;
63 |
64 | Mods = mods
65 | .OrderBy(m => m.Priority)
66 | .ThenBy(m => m.ModName)
67 | .ToList();
68 | }
69 |
70 | bool ProcessLine(string line, int lineNum, ref ModLoadSetting setting)
71 | {
72 | line = line.Replace(" ", "").Replace("\t", "");
73 |
74 | if (line.StartsWith("[") && line.EndsWith("]"))
75 | {
76 | if (!ProcessModNameLine(line, ref setting))
77 | return false;
78 | }
79 | else if (line.StartsWith("Enabled="))
80 | {
81 | if (!ProcessIsEnabledLine(line, lineNum, setting))
82 | return false;
83 | }
84 | else if (line.StartsWith("Priority="))
85 | {
86 | if (!ProcessPriorityLine(line, lineNum, setting))
87 | return false;
88 | }
89 | else if (!string.IsNullOrWhiteSpace(line) && !line.StartsWith(";"))
90 | {
91 | ShowWarningForMalformedFile($"Unrecognized value on line {lineNum}:\n\n{line}");
92 | return false;
93 | }
94 | return true;
95 | }
96 |
97 | bool ProcessModNameLine(string line, ref ModLoadSetting setting)
98 | {
99 | if (setting != null)
100 | {
101 | ShowWarningForMalformedFile($"{setting.ModName} settings are incomplete. 'Enabled' and 'Priority' are both required.");
102 | return false;
103 | }
104 |
105 | var modName = line.Substring(1, line.Length - 2); // Trim brackets
106 | setting = new ModLoadSetting(modName);
107 | return true;
108 | }
109 |
110 | bool ProcessIsEnabledLine(string line, int lineNum, ModLoadSetting setting)
111 | {
112 | if (setting == null)
113 | {
114 | ShowWarningForMalformedFile($"The 'Enabled' setting on line {lineNum} doesn't have a corresponding mod name.");
115 | return false;
116 | }
117 | if (!new Regex("^Enabled=[0|1]$").IsMatch(line))
118 | {
119 | ShowWarningForMalformedFile($"The 'Enabled' setting on line {lineNum} isn't within the valid range of 0 or 1:\n\n{line}");
120 | return false;
121 | }
122 |
123 | setting.IsEnabled = line.EndsWith("1");
124 | return true;
125 | }
126 |
127 | bool ProcessPriorityLine(string line, int lineNum, ModLoadSetting setting)
128 | {
129 | if (setting == null)
130 | {
131 | ShowWarningForMalformedFile($"The 'Priority' setting on line {lineNum} doesn't have a corresponding mod name.");
132 | return false;
133 | }
134 |
135 | var priorityString = line.Substring(line.IndexOf('=') + 1);
136 | int parsedPriority;
137 |
138 | if (!int.TryParse(priorityString, out parsedPriority))
139 | {
140 | ShowWarningForMalformedFile($"Can't parse the priority on line {lineNum}:\n\n{line}");
141 | return false;
142 | }
143 | if (TopPriority > parsedPriority || parsedPriority > BottomPriority)
144 | {
145 | ShowWarningForMalformedFile($"The priority on line {lineNum} isn't within the valid range of {TopPriority} to {BottomPriority}:\n\n{line}");
146 | return false;
147 | }
148 |
149 | setting.Priority = parsedPriority;
150 | return true;
151 | }
152 |
153 | void ShowWarningForMalformedFile(string reason)
154 | {
155 | Program.MainForm.ShowMessage(
156 | "Your mods.settings file is invalid.\n\n" + reason,
157 | "Invalid Load Order File",
158 | System.Windows.Forms.MessageBoxButtons.OK,
159 | System.Windows.Forms.MessageBoxIcon.Warning);
160 | }
161 |
162 | public void Save()
163 | {
164 | var builder = new StringBuilder();
165 |
166 | foreach (var modSetting in Mods)
167 | {
168 | builder
169 | .Append("[").Append(modSetting.ModName).AppendLine("]")
170 | .Append("Enabled = ").AppendLine(Convert.ToInt32(modSetting.IsEnabled).ToString())
171 | .Append("Priority = ").AppendLine(modSetting.Priority.ToString());
172 |
173 | if (modSetting != Mods.Last())
174 | builder.AppendLine();
175 | }
176 |
177 | File.WriteAllText(FilePath, builder.ToString());
178 | }
179 |
180 | #endregion
181 |
182 | public void AddMergedModIfMissing()
183 | {
184 | var mergedModName = Paths.RetrieveMergedModName();
185 |
186 | if (!Mods.Any(setting => setting.ModName.EqualsIgnoreCase(mergedModName)))
187 | {
188 | Mods.Insert(0,
189 | new ModLoadSetting
190 | {
191 | ModName = mergedModName,
192 | IsEnabled = true,
193 | Priority = TopPriority
194 | });
195 | }
196 | }
197 |
198 | public bool HasResolvedConflict(IEnumerable modNames)
199 | {
200 | var loadSettings = modNames
201 | .Select(GetModLoadSettingByName)
202 | .Where(setting => setting != null);
203 |
204 | if (!loadSettings.Any())
205 | return false;
206 |
207 | if (loadSettings.Any(setting => setting.IsEnabled.Value))
208 | return true;
209 |
210 | var numSettings = loadSettings.Count();
211 | var numMods = modNames.Count();
212 |
213 | return (numSettings >= numMods - 1);
214 | }
215 |
216 | public bool ContainsMod(string modName)
217 | {
218 | return Mods.Any(setting => setting.ModName.EqualsIgnoreCase(modName));
219 | }
220 |
221 | public ModLoadSetting GetTopPriorityEnabledMod()
222 | {
223 | return Mods
224 | .OrderBy(setting => setting, new LoadOrderComparer())
225 | .FirstOrDefault();
226 | }
227 |
228 | public string GetTopPriorityEnabledMod(IEnumerable conflictMods)
229 | {
230 | var conflictModSettings = Mods.Where(setting => conflictMods.Any(modName => modName.EqualsIgnoreCase(setting.ModName)));
231 | var enabledModSettings = conflictModSettings.Where(setting => setting.IsEnabled.Value);
232 |
233 | if (!conflictModSettings.Any())
234 | return conflictMods
235 | .OrderBy(name => name, new LoadOrderComparer())
236 | .FirstOrDefault();
237 |
238 | if (!enabledModSettings.Any())
239 | return conflictMods
240 | .Except(conflictModSettings.Select(setting => setting.ModName))
241 | .OrderBy(name => name, new LoadOrderComparer())
242 | .FirstOrDefault();
243 |
244 | return enabledModSettings
245 | .OrderBy(setting => setting, new LoadOrderComparer())
246 | .ThenBy(setting => setting.ModName, new LoadOrderComparer())
247 | .FirstOrDefault()
248 | ?.ModName;
249 | }
250 |
251 | public ModLoadSetting GetModLoadSettingByName(string modName)
252 | {
253 | return Mods.FirstOrDefault(setting => setting.ModName.EqualsIgnoreCase(modName));
254 | }
255 |
256 | public bool IsModDisabledByName(string modName)
257 | {
258 | var mod = GetModLoadSettingByName(modName);
259 |
260 | return (mod != null && !mod.IsEnabled.Value);
261 | }
262 |
263 | public void ToggleModByName(string modName)
264 | {
265 | var mod = GetModLoadSettingByName(modName);
266 |
267 | if (mod != null)
268 | mod.IsEnabled = !mod.IsEnabled;
269 | else
270 | {
271 | Mods.Add(new ModLoadSetting
272 | {
273 | ModName = modName,
274 | IsEnabled = false,
275 | Priority = BottomPriority
276 | });
277 | }
278 | }
279 |
280 | public int GetPriorityByName(string modName)
281 | {
282 | var mod = GetModLoadSettingByName(modName);
283 |
284 | return
285 | mod != null
286 | ? mod.Priority.Value
287 | : -1;
288 | }
289 |
290 | public void SetPriorityByName(string modName, int priority)
291 | {
292 | var mod = GetModLoadSettingByName(modName);
293 |
294 | if (mod != null)
295 | {
296 | mod.Priority = priority;
297 | }
298 | else
299 | {
300 | Mods.Add(new ModLoadSetting
301 | {
302 | ModName = modName,
303 | IsEnabled = true,
304 | Priority = priority
305 | });
306 | }
307 | }
308 | }
309 | }
310 |
--------------------------------------------------------------------------------
/WitcherScriptMerger/LoadOrder/LoadOrderComparer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace WitcherScriptMerger.LoadOrder
5 | {
6 | class LoadOrderComparer : IComparer, IComparer
7 | {
8 | public int Compare(string x, string y)
9 | {
10 | // The game loads numbers first, then underscores, then letters (upper or lower).
11 | // ASCII (ordinal) order is numbers, then uppercase letters, then underscores, then lowercase.
12 | // To achieve the game's load order, we can convert uppercase letters to lowercase, then take ASCII order.
13 | return string.Compare(
14 | x.ToLowerInvariant(),
15 | y.ToLowerInvariant(),
16 | StringComparison.Ordinal);
17 | }
18 |
19 | public int Compare(ModLoadSetting x, ModLoadSetting y)
20 | {
21 | if (x.IsEnabled.Value)
22 | {
23 | if (y.IsEnabled.Value)
24 | return x.Priority.Value.CompareTo(y.Priority.Value);
25 | else
26 | return -1; // Only x is enabled
27 | }
28 | else if (y.IsEnabled.Value)
29 | return 1; // Only y is enabled
30 | else
31 | return Compare(x.ModName, y.ModName); // Neither is enabled
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/WitcherScriptMerger/LoadOrder/LoadOrderValidator.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 | using System.Windows.Forms;
3 |
4 | namespace WitcherScriptMerger.LoadOrder
5 | {
6 | static class LoadOrderValidator
7 | {
8 | public static void ValidateAndFix(CustomLoadOrder loadOrder)
9 | {
10 | if (!loadOrder.Mods.Any())
11 | return;
12 |
13 | var mergedModName = Paths.RetrieveMergedModName();
14 | var mergedMod = loadOrder.Mods.Find(m => m.ModName.EqualsIgnoreCase(mergedModName));
15 |
16 | if (mergedMod != null && mergedMod == loadOrder.GetTopPriorityEnabledMod())
17 | return;
18 |
19 | var choice = PromptToPrioritizeMergedMod(loadOrder.FilePath);
20 | if (choice == DialogResult.Yes)
21 | {
22 | PrioritizeMergedMod(loadOrder, mergedMod);
23 | }
24 | else if (choice == DialogResult.Cancel) // Never
25 | {
26 | Program.Settings.Set("ValidateCustomLoadOrder", false);
27 | Program.Settings.Save();
28 | }
29 | }
30 |
31 | static DialogResult PromptToPrioritizeMergedMod(string modsSettingsPath)
32 | {
33 | MessageBoxManager.Cancel = "Ne&ver";
34 | MessageBoxManager.Register();
35 |
36 | var choice = MessageBox.Show(
37 | $"{modsSettingsPath}\n\n" +
38 | "Detected custom load order in the file above, and merged files aren't configured to load first.\n\n" +
39 | "Would you like Script Merger to modify your custom load order so that your merged files have top priority?",
40 | "Custom Load Order Problem",
41 | MessageBoxButtons.YesNoCancel,
42 | MessageBoxIcon.Exclamation,
43 | MessageBoxDefaultButton.Button2);
44 |
45 | MessageBoxManager.Unregister();
46 | return choice;
47 | }
48 |
49 | static void PrioritizeMergedMod(CustomLoadOrder loadOrder, ModLoadSetting mergedModSetting)
50 | {
51 | // Priority of min - 1 will be incremented to min
52 | var priority = CustomLoadOrder.TopPriority - 1;
53 |
54 | if (mergedModSetting != null)
55 | {
56 | mergedModSetting.IsEnabled = true;
57 | mergedModSetting.Priority = priority;
58 | }
59 | else
60 | {
61 | loadOrder.Mods.Insert(0, new ModLoadSetting
62 | {
63 | ModName = Paths.RetrieveMergedModName(),
64 | IsEnabled = true,
65 | Priority = priority
66 | });
67 | }
68 |
69 | IncrementLeadingContiguousPriorities(loadOrder, priority);
70 |
71 | loadOrder.Save();
72 | }
73 |
74 | static void IncrementLeadingContiguousPriorities(CustomLoadOrder loadOrder, int startingPriority)
75 | {
76 | var nextPriority = startingPriority + 1;
77 | var modsToIncrement = loadOrder.Mods.Where(mod => mod.Priority == startingPriority).ToArray();
78 | var displacedMods = loadOrder.Mods.Where(mod => mod.Priority == nextPriority).ToArray();
79 |
80 | if (!modsToIncrement.Any())
81 | return;
82 |
83 | if (displacedMods.Any() &&
84 | nextPriority < CustomLoadOrder.BottomPriority)
85 | {
86 | IncrementLeadingContiguousPriorities(loadOrder, nextPriority);
87 | }
88 |
89 | foreach (var mod in modsToIncrement)
90 | ++mod.Priority;
91 | }
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/WitcherScriptMerger/LoadOrder/ModLoadSetting.cs:
--------------------------------------------------------------------------------
1 | namespace WitcherScriptMerger.LoadOrder
2 | {
3 | class ModLoadSetting
4 | {
5 | public string ModName { get; set; }
6 |
7 | public bool? IsEnabled { get; set; }
8 |
9 | public int? Priority { get; set; }
10 |
11 | public ModLoadSetting()
12 | { }
13 |
14 | public ModLoadSetting(string modName)
15 | {
16 | ModName = modName;
17 | }
18 |
19 | public override string ToString()
20 | {
21 | return $"{ModName}, priority {Priority}, {(!IsEnabled.HasValue || IsEnabled.Value ? "enabled" : "disabled")}";
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/WitcherScriptMerger/Paths.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Windows.Forms;
4 | using WitcherScriptMerger.Tools;
5 |
6 | namespace WitcherScriptMerger
7 | {
8 | static class Paths
9 | {
10 | public const string TempBundleContent = "tempbundlecontent";
11 | public static string MergedBundleContent = "Merged Bundle Content";
12 | public static string MergedBundleContentAbsolute = Path.Combine(Environment.CurrentDirectory, MergedBundleContent);
13 | public const string Inventory = "MergeInventory.xml";
14 | public static string ModScriptBase = Path.Combine("content", "scripts");
15 | public static string VanillaScriptBase = Path.Combine("content", "content0", "scripts");
16 | public static string BundleBase = "content";
17 |
18 | public static string GameDirectory => Program.MainForm.GameDirectorySetting;
19 |
20 | public static string GameExe => Path.Combine(GameDirectory, "bin", "x64", "witcher3.exe");
21 |
22 | public static string BundlesDirectory => Path.Combine(GameDirectory, BundleBase);
23 |
24 | public static string DlcDirectory => Path.Combine(GameDirectory, "DLC");
25 |
26 | static string _scriptsDirSetting = Program.Settings.Get("VanillaScriptsDirectory");
27 | public static string ScriptsDirectory
28 | {
29 | get
30 | {
31 | return (!string.IsNullOrWhiteSpace(_scriptsDirSetting)
32 | ? _scriptsDirSetting
33 | : Path.Combine(GameDirectory, VanillaScriptBase));
34 | }
35 | }
36 |
37 | static string _modsDirSetting = Program.Settings.Get("ModsDirectory");
38 | public static string ModsDirectory
39 | {
40 | get
41 | {
42 | return (!string.IsNullOrWhiteSpace(_modsDirSetting)
43 | ? _modsDirSetting
44 | : Path.Combine(GameDirectory, "Mods"));
45 | }
46 | }
47 |
48 | public static bool IsScriptsDirectoryDerived => string.IsNullOrWhiteSpace(_scriptsDirSetting);
49 |
50 | public static bool IsModsDirectoryDerived => string.IsNullOrWhiteSpace(_modsDirSetting);
51 |
52 | public static string GetRelativePath(string fullPath, string basePath)
53 | {
54 | var startIndex = fullPath.IndexOfIgnoreCase(basePath) + basePath.Length + 1;
55 | return fullPath.Substring(startIndex);
56 | }
57 |
58 | public static bool ValidateDependencyPaths()
59 | {
60 | return (File.Exists(KDiff3.ExePath) &&
61 | File.Exists(QuickBms.ExePath) &&
62 | File.Exists(QuickBms.PluginPath) &&
63 | File.Exists(WccLite.ExePath));
64 | }
65 |
66 | public static bool ValidateModsDirectory()
67 | {
68 | if (!Directory.Exists(ModsDirectory))
69 | {
70 | Program.MainForm.ShowMessage(
71 | (!IsModsDirectoryDerived
72 | ? "Can't find the Mods directory specified in the config file."
73 | : "Can't find Mods directory in the specified game directory."));
74 | return false;
75 | }
76 | return true;
77 | }
78 |
79 | public static bool ValidateScriptsDirectory()
80 | {
81 | if (!Directory.Exists(ScriptsDirectory))
82 | {
83 | Program.MainForm.ShowMessage(
84 | (!IsScriptsDirectoryDerived
85 | ? "Can't find the Scripts directory specified in the config file."
86 | : "Can't find \\content\\content0\\scripts directory in the specified game directory.") +
87 | "\n\nIt was added in patch 1.08.1 and should contain the game's vanilla scripts.");
88 | return false;
89 | }
90 | return true;
91 | }
92 |
93 | public static bool ValidateBundlesDirectory()
94 | {
95 | if (!Directory.Exists(BundlesDirectory))
96 | {
97 | Program.MainForm.ShowMessage("Can't find 'content' directory in the specified game directory.");
98 | return false;
99 | }
100 | return true;
101 | }
102 |
103 | public static string RetrieveMergedBundlePath()
104 | {
105 | var mergedModName = RetrieveMergedModName();
106 | if (mergedModName != null)
107 | return Path.Combine(ModsDirectory, mergedModName, BundleBase, "blob0.bundle");
108 | else
109 | return null;
110 | }
111 |
112 | public static string RetrieveMergedModName()
113 | {
114 | var mergedModName = Program.Settings.Get("MergedModName");
115 | if (string.IsNullOrWhiteSpace(mergedModName))
116 | {
117 | Program.MainForm.ShowMessage("The MergedModName setting isn't configured in the .config file.");
118 | return null;
119 | }
120 | if (mergedModName.Length > 64)
121 | mergedModName = mergedModName.Substring(0, 64);
122 | if (!mergedModName.IsAlphaNumeric() || !mergedModName.StartsWith("mod"))
123 | {
124 | if (!ConfirmInvalidModName(mergedModName))
125 | return null;
126 | }
127 | return mergedModName;
128 | }
129 |
130 | public static string RetrieveMergedModDir()
131 | {
132 | var modName = RetrieveMergedModName();
133 | return
134 | modName != null
135 | ? Path.Combine(ModsDirectory, modName)
136 | : null;
137 | }
138 |
139 | static bool ConfirmInvalidModName(string mergedModName)
140 | {
141 | return (DialogResult.Yes == Program.MainForm.ShowMessage(
142 | "The Witcher 3 won't load the merged file if the mod name isn't \"mod\" followed by numbers, letters, or underscores."
143 | + "\n\nUse this name anyway?\n" + mergedModName
144 | + "\n\nTo change the name: Click No, then edit \"MergedModName\" in the .config file.",
145 | "Warning",
146 | MessageBoxButtons.YesNo,
147 | MessageBoxIcon.Exclamation));
148 | }
149 | }
150 | }
--------------------------------------------------------------------------------
/WitcherScriptMerger/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using System.IO;
4 | using System.Windows.Forms;
5 | using WitcherScriptMerger.Forms;
6 | using WitcherScriptMerger.Inventory;
7 | using WitcherScriptMerger.LoadOrder;
8 |
9 | namespace WitcherScriptMerger
10 | {
11 | static class Program
12 | {
13 | public static AppSettings Settings = new AppSettings();
14 | public static CustomLoadOrder LoadOrder = null;
15 | public static MergeInventory Inventory = null;
16 | public static MainForm MainForm;
17 |
18 | ///
19 | /// The main entry point for the application.
20 | ///
21 | [STAThread]
22 | static void Main()
23 | {
24 | Application.EnableVisualStyles();
25 | Application.SetCompatibleTextRenderingDefault(false);
26 |
27 | if (!Settings.HasConfigFile)
28 | {
29 | ShowLaunchFailure("Config file is missing.");
30 | return;
31 | }
32 | if (!Paths.ValidateDependencyPaths())
33 | {
34 | using (var dependencyForm = new DependencyForm())
35 | {
36 | if (dependencyForm.ShowDialog() != DialogResult.OK)
37 | {
38 | ShowLaunchFailure("A dependency is missing.");
39 | return;
40 | }
41 | }
42 | }
43 |
44 | MainForm = new MainForm();
45 | Application.Run(MainForm);
46 | }
47 |
48 | static void ShowLaunchFailure(string message)
49 | {
50 | MessageBox.Show(
51 | $"Launch failure: {message}",
52 | "Script Merger Error",
53 | MessageBoxButtons.OK,
54 | MessageBoxIcon.Error);
55 | }
56 |
57 | public static bool TryOpenFile(string path)
58 | {
59 | if (!File.Exists(path))
60 | {
61 | MainForm.ShowMessage("Can't find file: " + path);
62 | return false;
63 | }
64 |
65 | if (path.EndsWithIgnoreCase(".exe")) // EXEs need working dir to be specified
66 | {
67 | var startInfo = new ProcessStartInfo
68 | {
69 | FileName = path,
70 | WorkingDirectory = Path.GetDirectoryName(path)
71 | };
72 | Process.Start(startInfo);
73 | }
74 | else
75 | try { Process.Start(path); }
76 | catch (Exception) { }
77 |
78 | return true;
79 | }
80 |
81 | public static bool TryOpenFileLocation(string filePath)
82 | {
83 | return TryOpenDirectory(Path.GetDirectoryName(filePath));
84 | }
85 |
86 | public static bool TryOpenDirectory(string dirPath)
87 | {
88 | if (!Directory.Exists(dirPath))
89 | {
90 | MainForm.ShowMessage("Can't find directory: " + dirPath);
91 | return false;
92 | }
93 | Process.Start(dirPath);
94 | return true;
95 | }
96 | }
97 | }
--------------------------------------------------------------------------------
/WitcherScriptMerger/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("WitcherScriptMerger")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("WitcherScriptMerger")]
13 | [assembly: AssemblyCopyright("Copyright © 2015")]
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("e00365ce-7ffa-45a7-b046-f3df9e279007")]
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("0.6.2.2")]
36 | [assembly: AssemblyFileVersion("0.6.2")]
37 |
--------------------------------------------------------------------------------
/WitcherScriptMerger/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.34209
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace WitcherScriptMerger.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.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 | /// Returns the cached ResourceManager instance used by this class.
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("WitcherScriptMerger.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// Overrides the current thread's CurrentUICulture property for all
51 | /// resource lookups using this strongly typed resource class.
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 |
--------------------------------------------------------------------------------
/WitcherScriptMerger/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 | text/microsoft-resx
107 |
108 |
109 | 2.0
110 |
111 |
112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
113 |
114 |
115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
--------------------------------------------------------------------------------
/WitcherScriptMerger/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.34209
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace WitcherScriptMerger.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.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 |
--------------------------------------------------------------------------------
/WitcherScriptMerger/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/WitcherScriptMerger/SimLink.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel;
3 | using System.IO;
4 | using System.Runtime.InteropServices;
5 | using System.Text;
6 | using Microsoft.Win32.SafeHandles;
7 |
8 | namespace WitcherScriptMerger
9 | {
10 | ///
11 | /// Provides access to NTFS junction points in .Net.
12 | ///
13 | public static class SimLink
14 | {
15 | private const int CREATION_DISPOSITION_OPEN_EXISTING = 3;
16 |
17 | private const int FILE_FLAG_BACKUP_SEMANTICS = 0x02000000;
18 |
19 | // http://msdn.microsoft.com/en-us/library/aa364962%28VS.85%29.aspx
20 | [DllImport("kernel32.dll", EntryPoint = "GetFinalPathNameByHandleW", CharSet = CharSet.Unicode,
21 | SetLastError = true)]
22 | public static extern int GetFinalPathNameByHandle(IntPtr handle,
23 | [In, Out] StringBuilder path,
24 | int bufLen,
25 | int flags);
26 |
27 | // http://msdn.microsoft.com/en-us/library/aa363858(VS.85).aspx
28 | [DllImport("kernel32.dll", EntryPoint = "CreateFileW", CharSet = CharSet.Unicode, SetLastError = true)]
29 | public static extern SafeFileHandle CreateFile(string lpFileName,
30 | int dwDesiredAccess,
31 | int dwShareMode,
32 | IntPtr SecurityAttributes,
33 | int dwCreationDisposition,
34 | int dwFlagsAndAttributes,
35 | IntPtr hTemplateFile);
36 |
37 | public static string GetSymbolicLinkTarget(FileInfo symlink)
38 | {
39 | var fileHandle = CreateFile(symlink.FullName, 0, 2, IntPtr.Zero, CREATION_DISPOSITION_OPEN_EXISTING,
40 | FILE_FLAG_BACKUP_SEMANTICS, IntPtr.Zero);
41 | if (fileHandle.IsInvalid)
42 | {
43 | throw new Win32Exception(Marshal.GetLastWin32Error());
44 | }
45 |
46 | var path = new StringBuilder(512);
47 | var size = GetFinalPathNameByHandle(fileHandle.DangerousGetHandle(), path, path.Capacity, 0);
48 | if (size < 0)
49 | {
50 | throw new Win32Exception(Marshal.GetLastWin32Error());
51 | }
52 | // The remarks section of GetFinalPathNameByHandle mentions the return being prefixed with "\\?\"
53 | // More information about "\\?\" here -> http://msdn.microsoft.com/en-us/library/aa365247(v=VS.85).aspx
54 | if (path[0] == '\\' && path[1] == '\\' && path[2] == '?' && path[3] == '\\')
55 | {
56 | return path.ToString().Substring(4);
57 | }
58 | return path.ToString();
59 | }
60 | }
61 | }
--------------------------------------------------------------------------------
/WitcherScriptMerger/TaskbarProgress.cs:
--------------------------------------------------------------------------------
1 | // From http://stackoverflow.com/a/24187171/1641069
2 |
3 | using System;
4 | using System.Runtime.InteropServices;
5 |
6 | static class TaskbarProgress
7 | {
8 | public enum TaskbarStates
9 | {
10 | NoProgress = 0,
11 | Indeterminate = 0x1,
12 | Normal = 0x2,
13 | Error = 0x4,
14 | Paused = 0x8
15 | }
16 |
17 | [ComImportAttribute()]
18 | [GuidAttribute("ea1afb91-9e28-4b86-90e9-9e9f8a5eefaf")]
19 | [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
20 | private interface ITaskbarList3
21 | {
22 | // ITaskbarList
23 | [PreserveSig]
24 | void HrInit();
25 | [PreserveSig]
26 | void AddTab(IntPtr hwnd);
27 | [PreserveSig]
28 | void DeleteTab(IntPtr hwnd);
29 | [PreserveSig]
30 | void ActivateTab(IntPtr hwnd);
31 | [PreserveSig]
32 | void SetActiveAlt(IntPtr hwnd);
33 |
34 | // ITaskbarList2
35 | [PreserveSig]
36 | void MarkFullscreenWindow(IntPtr hwnd, [MarshalAs(UnmanagedType.Bool)] bool fFullscreen);
37 |
38 | // ITaskbarList3
39 | [PreserveSig]
40 | void SetProgressValue(IntPtr hwnd, UInt64 ullCompleted, UInt64 ullTotal);
41 | [PreserveSig]
42 | void SetProgressState(IntPtr hwnd, TaskbarStates state);
43 | }
44 |
45 | [GuidAttribute("56FDF344-FD6D-11d0-958A-006097C9A090")]
46 | [ClassInterfaceAttribute(ClassInterfaceType.None)]
47 | [ComImportAttribute()]
48 | private class TaskbarInstance
49 | {
50 | }
51 |
52 | private static ITaskbarList3 taskbarInstance = (ITaskbarList3)new TaskbarInstance();
53 | private static bool taskbarSupported = Environment.OSVersion.Version >= new Version(6, 1);
54 |
55 | public static void SetState(IntPtr windowHandle, TaskbarStates taskbarState)
56 | {
57 | if (taskbarSupported)
58 | taskbarInstance.SetProgressState(windowHandle, taskbarState);
59 | }
60 |
61 | public static void SetValue(IntPtr windowHandle, double progressValue, double progressMax)
62 | {
63 | if (taskbarSupported)
64 | taskbarInstance.SetProgressValue(windowHandle, (ulong)progressValue, (ulong)progressMax);
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/WitcherScriptMerger/Tools/KDiff3.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using System.IO;
4 | using WitcherScriptMerger.Inventory;
5 |
6 | namespace WitcherScriptMerger.Tools
7 | {
8 | static class KDiff3
9 | {
10 | public static string ExePath = Program.Settings.Get("KDiff3Path");
11 |
12 | public static int Run(
13 | FileMerger.MergeSource source1,
14 | FileMerger.MergeSource source2,
15 | FileInfo vanillaFile,
16 | string outputPath, bool followFileLinks)
17 | {
18 | if (!File.Exists(ExePath))
19 | {
20 | Program.MainForm.ShowError("Can't find KDiff3 at this location:\n\n" + ExePath, "Missing KDiff3");
21 | return 1;
22 | }
23 |
24 | var outputDir = Path.GetDirectoryName(outputPath);
25 |
26 | if (!Directory.Exists(outputDir))
27 | Directory.CreateDirectory(outputDir);
28 |
29 | var hasVanillaVersion = (vanillaFile != null && vanillaFile.Exists);
30 |
31 | var args = (hasVanillaVersion
32 | ? "\"" + vanillaFile.FullName + "\" "
33 | : "");
34 |
35 | // resolve any simlinked files
36 | var source1FullName = followFileLinks ? source1.TextFile.ResolveTargetFileFullName() : source1.TextFile.FullName;
37 | var source2FullName = followFileLinks ? source2.TextFile.ResolveTargetFileFullName() : source2.TextFile.FullName;
38 |
39 | args +=
40 | $"\"{source1FullName}\" \"{source2FullName}\" " +
41 | $"-o \"{outputPath}\" " +
42 | "--cs \"WhiteSpace3FileMergeDefault=2\" " +
43 | "--cs \"CreateBakFiles=0\" " +
44 | "--cs \"LineEndStyle=1\" " +
45 | "--cs \"FollowFileLinks=1\" " +
46 | "--cs \"FollowDirLinks=1\"";
47 |
48 | if (!Program.Settings.Get("ShowPathsInKDiff3"))
49 | {
50 | if (hasVanillaVersion)
51 | args += $" --L1 Vanilla --L2 \"{source1.Name}\" --L3 \"{source2.Name}\"";
52 | else
53 | args += $" --L1 \"{source1.Name}\" --L2 \"{source2.Name}\"";
54 | }
55 |
56 | if (!Program.Settings.Get("ReviewEachMerge") && hasVanillaVersion)
57 | {
58 | if (source1FullName.EqualsIgnoreCase(outputPath)
59 | && source2.Hash != null && source2.Hash.IsOutdated)
60 | {
61 | Program.MainForm.ShowMessage(
62 | "You are merging an updated mod file into a merge created with a previous version of the file.\n\n" +
63 | "You should carefully inspect this merge, because KDiff3's auto-solving behavior KEEPS changes from the previous version of the mod file that have been REMOVED in the new version.",
64 | "Warning",
65 | System.Windows.Forms.MessageBoxButtons.OK,
66 | System.Windows.Forms.MessageBoxIcon.Warning);
67 | }
68 | else
69 | args += " --auto";
70 | }
71 |
72 | var kdiff3Path = (Path.IsPathRooted(ExePath)
73 | ? ExePath
74 | : Path.Combine(Environment.CurrentDirectory, ExePath));
75 |
76 | var kdiff3Proc = Process.Start(kdiff3Path, args);
77 | kdiff3Proc.WaitForExit();
78 |
79 | return kdiff3Proc.ExitCode;
80 | }
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/WitcherScriptMerger/Tools/QuickBms.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Diagnostics;
3 | using System.IO;
4 | using System.Linq;
5 |
6 | namespace WitcherScriptMerger.Tools
7 | {
8 | static class QuickBms
9 | {
10 | public static string ExePath = Program.Settings.Get("QuickBmsPath");
11 | public static string PluginPath = Program.Settings.Get("QuickBmsPluginPath");
12 |
13 | public static int UnpackFile(string bundlePath, string contentRelativePath, string outputDir)
14 | {
15 | if (!ValidateResources(bundlePath))
16 | return 1;
17 |
18 | if (!Directory.Exists(outputDir))
19 | Directory.CreateDirectory(outputDir);
20 |
21 | var startInfo = BuildStartInfo($"-Y -f \"{contentRelativePath}\" \"{PluginPath}\" \"{bundlePath}\" \"{outputDir}\"");
22 |
23 | using (var bmsProc = new Process { StartInfo = startInfo })
24 | {
25 | bmsProc.Start();
26 | var output = bmsProc.StandardError.ReadToEnd(); // QuickBMS prints results to std error, even if successful
27 |
28 | if (output.Contains("- 0 files found"))
29 | {
30 | var errorMsg = "Error unpacking bundle content file using QuickBMS.\nIts output is below.";
31 | var outputStart = output.IndexOf("- filter string");
32 | if (outputStart != -1)
33 | {
34 | output = output.Substring(outputStart);
35 | errorMsg += "\n\n" + output;
36 | }
37 | Program.MainForm.ShowError(errorMsg);
38 | return 1;
39 | }
40 |
41 | return 0;
42 | }
43 | }
44 |
45 | public static string[] GetBundleContentPaths(string bundlePath)
46 | {
47 | if (!ValidateResources(bundlePath))
48 | return null;
49 |
50 | var contentPaths = new List();
51 |
52 | var startInfo = BuildStartInfo($"-l \"{PluginPath}\" \"{bundlePath}\"");
53 |
54 | using (var bmsProc = new Process { StartInfo = startInfo })
55 | {
56 | bmsProc.Start();
57 | var output = bmsProc.StandardOutput.ReadToEnd() + "\n\n" + bmsProc.StandardError.ReadToEnd();
58 | var footerPos = output.LastIndexOf("QuickBMS generic");
59 | var outputLines = output.Substring(0, footerPos).Split('\n');
60 | var paths = outputLines
61 | .Where(line => line.Length > 5)
62 | .Select(line => line.Substring(line.LastIndexOf(' ')).Trim());
63 | contentPaths.AddRange(paths);
64 | }
65 | return contentPaths.ToArray();
66 | }
67 |
68 | static bool ValidateResources(string bundlePath)
69 | {
70 | if (!File.Exists(bundlePath))
71 | {
72 | Program.MainForm.ShowError("Can't find bundle file:\n\n" + bundlePath, "Missing Bundle");
73 | return false;
74 | }
75 | if (!File.Exists(ExePath))
76 | {
77 | Program.MainForm.ShowError("Can't find QuickBMS at this location:\n\n" + ExePath, "Missing QuickBMS");
78 | return false;
79 | }
80 | if (!File.Exists(PluginPath))
81 | {
82 | Program.MainForm.ShowError("Can't find QuickBMS plugin at this location:\n\n" + PluginPath, "Missing QuickBMS Plugin");
83 | return false;
84 | }
85 | return true;
86 | }
87 |
88 | static ProcessStartInfo BuildStartInfo(string arguments)
89 | {
90 | return new ProcessStartInfo
91 | {
92 | FileName = ExePath,
93 | Arguments = arguments,
94 | UseShellExecute = false,
95 | RedirectStandardOutput = true,
96 | RedirectStandardError = true,
97 | CreateNoWindow = true
98 | };
99 | }
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/WitcherScriptMerger/Tools/WccLite.cs:
--------------------------------------------------------------------------------
1 | using System.Diagnostics;
2 | using System.IO;
3 |
4 | namespace WitcherScriptMerger.Tools
5 | {
6 | static class WccLite
7 | {
8 | public static string ExePath = Program.Settings.Get("WccLitePath");
9 |
10 | public static int PackBundle(string sourceDir, string outputDir)
11 | {
12 | if (!Directory.Exists(sourceDir))
13 | {
14 | Program.MainForm.ShowError("Can't find content directory to pack into bundle:\n\n" + sourceDir, "Missing Directory");
15 | return 1;
16 | }
17 |
18 | return Run(
19 | $"pack -dir=\"{sourceDir}\" -outdir=\"{outputDir}\"",
20 | "Error packing merged content into a new bundle using wcc_lite.\nIts error output is below."
21 | );
22 | }
23 |
24 | public static int GenerateMetadata(string bundleDir)
25 | {
26 | return Run(
27 | $"metadatastore -path=\"{bundleDir}\"",
28 | "Error generating metadata.store for new merged bundle using wcc_lite.\nIts error output is below."
29 | );
30 | }
31 |
32 | public static int Run(string arguments, string failureMsg)
33 | {
34 | if (!File.Exists(ExePath))
35 | {
36 | Program.MainForm.ShowError("Can't find wcc_lite at this location:\n\n" + ExePath, "Missing wcc_lite");
37 | return 1;
38 | }
39 |
40 | var procInfo = new ProcessStartInfo
41 | {
42 | FileName = ExePath,
43 | Arguments = arguments,
44 | WorkingDirectory = Path.GetDirectoryName(ExePath),
45 | UseShellExecute = false,
46 | RedirectStandardOutput = true,
47 | RedirectStandardError = true,
48 | CreateNoWindow = true
49 | };
50 |
51 | using (var wccLiteProc = new Process { StartInfo = procInfo })
52 | {
53 | wccLiteProc.Start();
54 | var stdOutput = wccLiteProc.StandardOutput.ReadToEnd().Trim();
55 | var stdError = wccLiteProc.StandardError.ReadToEnd().Trim();
56 |
57 | string errorMsg = null;
58 | if (!string.IsNullOrWhiteSpace(stdError))
59 | errorMsg = stdError;
60 | else if (stdOutput.EndsWith("Wcc operation failed"))
61 | errorMsg = stdOutput;
62 | if (errorMsg != null)
63 | {
64 | Program.MainForm.ShowError(failureMsg + "\n\n" + errorMsg);
65 | return 1;
66 | }
67 | }
68 | return 0;
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/WitcherScriptMerger/Tools/xxHash.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Created by Wilhelm Liao on 2015-12-25.
3 | Copyright (c) 2015, Wilhelm Liao
4 | All rights reserved.
5 | Redistribution and use in source and binary forms, with or without
6 | modification, are permitted provided that the following conditions are met:
7 | * Redistributions of source code must retain the above copyright notice, this
8 | list of conditions and the following disclaimer.
9 | * Redistributions in binary form must reproduce the above copyright notice,
10 | this list of conditions and the following disclaimer in the documentation
11 | and/or other materials provided with the distribution.
12 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
13 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
14 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
15 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
16 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
17 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
18 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
19 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
20 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
21 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22 | - Original xxHash's License follows:
23 | """
24 | Copyright (C) 2012-2015, Yann Collet. (https://github.com/Cyan4973/xxHash)
25 | BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
26 | Redistribution and use in source and binary forms, with or without
27 | modification, are permitted provided that the following conditions are
28 | met:
29 | * Redistributions of source code must retain the above copyright
30 | notice, this list of conditions and the following disclaimer.
31 |
32 | * Redistributions in binary form must reproduce the above
33 | copyright notice, this list of conditions and the following disclaimer
34 | in the documentation and/or other materials provided with the
35 | distribution.
36 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
37 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
38 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
39 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
40 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
42 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
43 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
44 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
45 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
46 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
47 |
48 | You can contact the author at :
49 | - xxHash source repository : https://github.com/Cyan4973/xxHash
50 | """
51 | */
52 |
53 | using System.IO;
54 |
55 | namespace WitcherScriptMerger.Tools
56 | {
57 | static class Hasher
58 | {
59 | public static string ComputeHash(string filePath)
60 | {
61 | if (!File.Exists(filePath))
62 | throw new FileNotFoundException("Can't find file to hash: " + filePath);
63 |
64 | return new xxHash(filePath).ToString();
65 | }
66 | }
67 |
68 | class xxHash
69 | {
70 | const uint Seed = 0U,
71 | Prime1 = 2654435761U,
72 | Prime2 = 2246822519U,
73 | Prime3 = 3266489917U,
74 | Prime4 = 668265263U,
75 | Prime5 = 374761393U;
76 |
77 | const int TransformSize = sizeof(uint) * 4;
78 | uint _v1,
79 | _v2,
80 | _v3,
81 | _v4;
82 |
83 | string _hex;
84 |
85 | public override string ToString() => _hex;
86 |
87 | public xxHash(string filePath)
88 | {
89 | unchecked // Allow integer overflow
90 | {
91 | _v1 = Seed + Prime1 + Prime2;
92 | _v2 = Seed + Prime2;
93 | _v3 = Seed;
94 | _v4 = Seed - Prime1;
95 | }
96 |
97 | using (var reader = new BinaryReader(File.OpenRead(filePath)))
98 | {
99 | // Limit prevents trying to transform by
100 | // last chunk of input when it's too short
101 | long streamLength = reader.BaseStream.Length; // Cache this because it's IO-expensive
102 | long limit = streamLength - TransformSize;
103 | while (reader.BaseStream.Position <= limit)
104 | {
105 | TransformBy(reader);
106 | }
107 |
108 | _hex = string.Format("{0:X}", Finalize(reader, streamLength));
109 | }
110 | }
111 |
112 | void TransformBy(BinaryReader reader)
113 | {
114 | _v1 += reader.ReadUInt32() * Prime2;
115 | _v1 = XXH_rotl(_v1, 13);
116 | _v1 *= Prime1;
117 |
118 | _v2 += reader.ReadUInt32() * Prime2;
119 | _v2 = XXH_rotl(_v2, 13);
120 | _v2 *= Prime1;
121 |
122 | _v3 += reader.ReadUInt32() * Prime2;
123 | _v3 = XXH_rotl(_v3, 13);
124 | _v3 *= Prime1;
125 |
126 | _v4 += reader.ReadUInt32() * Prime2;
127 | _v4 = XXH_rotl(_v4, 13);
128 | _v4 *= Prime1;
129 | }
130 |
131 | uint Finalize(BinaryReader reader, long streamLength)
132 | {
133 | var stream = reader.BaseStream;
134 |
135 | uint hash =
136 | (streamLength >= 16)
137 | ? XXH_rotl(_v1, 1) + XXH_rotl(_v2, 7) + XXH_rotl(_v3, 12) + XXH_rotl(_v4, 18)
138 | : Seed + Prime5;
139 |
140 | hash += (uint)streamLength;
141 |
142 | // Transform hash by any leftover bytes at end of input
143 | if (stream.Position < streamLength)
144 | {
145 | while (stream.Position + sizeof(uint) <= streamLength)
146 | {
147 | hash += reader.ReadUInt32() * Prime3;
148 | hash = XXH_rotl(hash, 17) * Prime4;
149 | }
150 |
151 | while (stream.Position < streamLength)
152 | {
153 | hash += reader.ReadByte() * Prime5;
154 | hash = XXH_rotl(hash, 11) * Prime1;
155 | }
156 | }
157 |
158 | hash ^= hash >> 15;
159 | hash *= Prime2;
160 | hash ^= hash >> 13;
161 | hash *= Prime3;
162 | hash ^= hash >> 16;
163 |
164 | return hash;
165 | }
166 |
167 | // Rotates unsigned 32-bit integer "x" to the left by the number of bits "r"
168 | static uint XXH_rotl(uint x, int r)
169 | {
170 | return (x << r) | (x >> (32 - r));
171 | }
172 | }
173 | }
174 |
--------------------------------------------------------------------------------
/WitcherScriptMerger/WitcherScriptMerger.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {B0417CBE-445D-47A0-8502-717BCFE63013}
8 | WinExe
9 | Properties
10 | WitcherScriptMerger
11 | WitcherScriptMerger
12 | v4.5
13 | 512
14 |
15 |
16 | AnyCPU
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 | DeadCodeDetection.ruleset
25 |
26 |
27 | AnyCPU
28 | pdbonly
29 | true
30 | bin\Release\
31 | TRACE
32 | prompt
33 | 4
34 | DeadCodeDetection.ruleset
35 |
36 |
37 | WolfMedallion.ico
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 | Component
57 |
58 |
59 | Component
60 |
61 |
62 | Component
63 |
64 |
65 |
66 |
67 | Form
68 |
69 |
70 | OptionsForm.cs
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 | Form
80 |
81 |
82 | DependencyForm.cs
83 |
84 |
85 | Form
86 |
87 |
88 | PackReportForm.cs
89 |
90 |
91 | Form
92 |
93 |
94 | MergeReportForm.cs
95 |
96 |
97 |
98 | Form
99 |
100 |
101 | MainForm.cs
102 |
103 |
104 | Form
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 | DependencyForm.cs
124 |
125 |
126 | OptionsForm.cs
127 |
128 |
129 | PackReportForm.cs
130 |
131 |
132 | MergeReportForm.cs
133 |
134 |
135 | MainForm.cs
136 | Designer
137 |
138 |
139 | ResXFileCodeGenerator
140 | Resources.Designer.cs
141 | Designer
142 |
143 |
144 | True
145 | Resources.resx
146 | True
147 |
148 |
149 | SettingsSingleFileGenerator
150 | Settings.Designer.cs
151 |
152 |
153 | True
154 | Settings.settings
155 | True
156 |
157 |
158 |
159 |
160 |
161 | Designer
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 | if exist "$(TargetPath).locked" del "$(TargetPath).locked"
171 | if exist "$(TargetPath)" if not exist "$(TargetPath).locked" move "$(TargetPath)" "$(TargetPath).locked"
172 |
173 |
180 |
--------------------------------------------------------------------------------
/WitcherScriptMerger/WolfMedallion.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/woodbyte/WitcherScriptMerger/2a087bb839dacf2d85d0e1b30e511b647a65496a/WitcherScriptMerger/WolfMedallion.ico
--------------------------------------------------------------------------------