");
26 | return;
27 | }
28 | else if (File.Exists(args[1]) == false)
29 | {
30 | ConsoleEx.WriteError("File not found: " + args[1]);
31 | return;
32 | }
33 |
34 | if (args[0].ToLower() == "compile")
35 | {
36 | string path = args[1];
37 |
38 | ConsoleEx.WriteInfo("Parsing file...");
39 |
40 | string duixml = File.ReadAllText(path);
41 | XmlDocument doc = new XmlDocument();
42 | doc.LoadXml(duixml);
43 |
44 | if (doc.ChildNodes.Count != 1 || doc.ChildNodes[0]?.Name != "duixml")
45 | {
46 | ConsoleEx.WriteError("Invalid duixml file");
47 | return;
48 | }
49 |
50 | ConsoleEx.WriteInfo("Compiling file...");
51 |
52 | DuibFileWriter writer = new DuibFileWriter(doc);
53 |
54 | if (path.EndsWith(".xml", StringComparison.OrdinalIgnoreCase))
55 | path = path.Replace(".xml", ".duib", StringComparison.OrdinalIgnoreCase);
56 | else if (path.EndsWith(".duixml", StringComparison.OrdinalIgnoreCase))
57 | path = path.Replace(".duixml", ".duib", StringComparison.OrdinalIgnoreCase);
58 | else if (path.EndsWith(".txt", StringComparison.OrdinalIgnoreCase))
59 | path = path.Replace(".txt", ".duib", StringComparison.OrdinalIgnoreCase);
60 | else
61 | path += ".duib";
62 |
63 | writer.Write(path);
64 |
65 | ConsoleEx.WriteSuccess($"File saved successfully at {path}");
66 | }
67 | else
68 | {
69 | string path = args[1];
70 |
71 | ConsoleEx.WriteInfo("Decompiling file...");
72 |
73 | DuibFileReader reader = new DuibFileReader(path);
74 |
75 | if (path.EndsWith(".duib", StringComparison.OrdinalIgnoreCase))
76 | path = path.Replace(".duib", ".duixml", StringComparison.OrdinalIgnoreCase);
77 | else if (path.EndsWith(".bin", StringComparison.OrdinalIgnoreCase))
78 | path = path.Replace(".bin", ".duixml", StringComparison.OrdinalIgnoreCase);
79 | else if (path.EndsWith(".uib", StringComparison.OrdinalIgnoreCase))
80 | path = path.Replace(".uib", ".duixml", StringComparison.OrdinalIgnoreCase);
81 | else
82 | path += ".duixml";
83 |
84 | ConsoleEx.WriteInfo("Saving file...");
85 |
86 | reader.Save(path);
87 |
88 | ConsoleEx.WriteSuccess($"File saved successfully at {path}");
89 | }
90 | }
91 |
92 | private static void OnUnhandledException(object sender, UnhandledExceptionEventArgs e)
93 | {
94 | Exception exception = (Exception)e.ExceptionObject;
95 |
96 | if (exception is XmlException xmlException)
97 | ConsoleEx.WriteError($"Error while parsing duixml: {xmlException}");
98 | else
99 | ConsoleEx.WriteError($"Unknown error happened: {exception}");
100 |
101 | Environment.Exit(exception.HResult);
102 | }
103 | }
104 | }
105 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) [year] [fullname]
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | DuiTool
6 | The ultimate DirectUI tool
7 | Source Code |
8 | Downloads |
9 | Contact |
10 | Donate
11 |
12 | 
13 |
14 |
15 | ## Usage
16 |
17 | #### Decompiling a DUIB file:
18 | ```bash
19 | DuiTool.exe decompile myDuibFile.duib
20 | ```
21 |
22 | #### Compiling a DuiXml file:
23 | ```bash
24 | DuiTool.exe compile myXmlFile.duixml
25 | ```
26 |
27 | #### Example of input DuiXml file:
28 | ```xml
29 |
30 |
31 |
32 |
33 |
34 | ```
35 |
36 | ## Progress
37 |
38 | - [x] DUIB Decompiler
39 | - [x] DUIB Compiler
40 | - [ ] DirectUI Color Helper
41 | - [ ] DuiXml Previewer
42 | - [ ] DuiXml Designer
43 |
44 | ## Crediting
45 | We kindly ask users of the tool to provide (totally optional) attribution/credit if they utilize any files generated by the tool.
46 |
47 | Attribution helps acknowledge the efforts put into creating and maintaining the tool and encourages its continued development.
48 |
--------------------------------------------------------------------------------