|
1 | | -#-----------------------------------------------------------------------------# |
2 | | -# Program: DTC GUI # |
3 | | -# File: DTC-GUI.dsc # |
4 | | -# Author: 007revad # |
5 | | -# Contact: https://github.com/007revad # |
6 | | -# Copyright: 2024, 007revad # |
7 | | -#-----------------------------------------------------------------------------# |
8 | | - |
9 | | - title DTC GUI |
10 | | - |
11 | | - %%inifile = @path(%0)DTC-GUI.ini |
12 | | - inifile open, %%inifile |
13 | | - if @not(@ok()) |
14 | | - warn Failed to open DTC-GUI.ini |
15 | | - goto Close |
16 | | - end |
17 | | - |
18 | | -REM DIALOG CREATE,DTC GUI,-1,0,560,156 |
19 | | - DIALOG CREATE,DTC GUI,-1,0,560,156,ONTOP |
20 | | -REM *** Modified by Dialog Designer on Tue 20 08 2024 - 12:30 *** |
21 | | - DIALOG ADD,STYLE,STYLE1,,,B,,RED |
22 | | - DIALOG ADD,STYLE,STYLE2,,,BC,,00C400 |
23 | | - DIALOG ADD,STYLE,STYLE3,,,BC,,RED |
24 | | - DIALOG ADD,TEXT,TEXT1,20,18,45,18,In File |
25 | | - DIALOG ADD,TEXT,TEXT2,50,18,45,18,Out File |
26 | | - DIALOG ADD,EDIT,EDIT1,18,70,390,18,,,READONLY |
27 | | - DIALOG ADD,EDIT,EDIT2,48,70,390,18 |
28 | | - DIALOG ADD,BUTTON,Select,15,468,70,24,Select File |
29 | | - DIALOG ADD,TEXT,TEXT3,50,470,70,18,,,STYLE1 |
30 | | - DIALOG ADD,BUTTON,Compile,80,195,74,24,Compile |
31 | | - DIALOG ADD,BUTTON,Decompile,80,285,74,24,Decompile |
32 | | - DIALOG ADD,TEXT,TEXT4,120,20,518,18,,,FITTEXT,STYLE2 |
33 | | - DIALOG ADD,TEXT,TEXT5,120,20,518,18,,,FITTEXT,STYLE3 |
34 | | - dialog disable, Compile |
35 | | - dialog disable, Decompile |
36 | | - dialog hide, TEXT5 |
37 | | - DIALOG SHOW |
38 | | - |
39 | | - |
40 | | -:EvLoop |
41 | | - wait event, 0.5 |
42 | | - goto @event() |
43 | | - |
44 | | - |
45 | | -:TIMER |
46 | | - %%file_out = @dlgtext(EDIT2) |
47 | | - %%ext_out = @ext(%%file_out) |
48 | | - if @both(@equal(%%ext_in,%%ext_out),@both(%%ext_in,%%ext_out)) |
49 | | - dialog set, TEXT3, Same Type! |
50 | | - elsif @file(%%file_out) |
51 | | - dialog set, TEXT3, File Exists! |
52 | | - else |
53 | | - dialog set, TEXT3, |
54 | | - end |
55 | | - if @both(@equal(%%ext_in,dtb),@equal(%%ext_out,dts)) |
56 | | - dialog disable, Compile |
57 | | - dialog enable, Decompile |
58 | | - elsif @both(@equal(%%ext_in,dts),@equal(%%ext_out,dtb)) |
59 | | - dialog enable, Compile |
60 | | - dialog disable, Decompile |
61 | | - else |
62 | | - dialog disable, Compile |
63 | | - dialog disable, Decompile |
64 | | - end |
65 | | - goto EvLoop |
66 | | - |
67 | | - |
68 | | -:Close |
69 | | - inifile close, %%inifile |
70 | | - stop |
71 | | - |
72 | | - |
73 | | -:SelectBUTTON |
74 | | - %%file_in = @filedlg("dtc files (*.dts,*dtb)|*.dt?",Open file) |
75 | | - if @ok() |
76 | | - %%ext_in = @ext(%%file_in) |
77 | | - %%name = @name(%%file_in) |
78 | | - %%path = @path(%%file_in) |
79 | | - |
80 | | - if @equal(%%ext_in,dtb) |
81 | | - %%ext_out = dts |
82 | | - elsif @equal(%%ext_in,dts) |
83 | | - %%ext_out = dtb |
84 | | - end |
85 | | - |
86 | | - %%file_out = %%path%%name.%%ext_out |
87 | | - |
88 | | - dialog set, EDIT1, %%file_in |
89 | | - dialog set, EDIT2, %%file_out |
90 | | - |
91 | | - dialog set, TEXT4, |
92 | | - dialog hide, TEXT5 |
93 | | - end |
94 | | - goto Timer |
95 | | - |
96 | | - |
97 | | -:SaveBUTTON |
98 | | - directory change, %%last_save_path |
99 | | - %%file_out = @filedlg("dtc files (*.dts,*dtb)|*.dt?",Save file) |
100 | | - |
101 | | - %%ext_out = @ext(%%file_out) |
102 | | - %%name = @name(%%file_out) |
103 | | - %%path_out = @path(%%file_out) |
104 | | - |
105 | | - if @equal(%%ext_in,dtb) |
106 | | - %%ext_out = dts |
107 | | - elsif @equal(%%ext_in,dts) |
108 | | - %%ext_out = dtb |
109 | | - end |
110 | | - |
111 | | - %%file_out = %%path_out%%name.%%ext_out |
112 | | - |
113 | | - dialog set, EDIT2, %%file_out |
114 | | - goto Timer |
115 | | - |
116 | | - |
117 | | -:CompileBUTTON |
118 | | -:DecompileBUTTON |
119 | | - # Check if dtc.exe exists |
120 | | - %%dtcpath = @iniread(main, dtc_path) |
121 | | - %%dtcexe = %%dtcpath\dtc.exe |
122 | | - if @null(%%dtcpath) |
123 | | - warn dtc_path not set in DTC-GUI.ini |
124 | | - goto EvLoop |
125 | | - elsif @not(@file(%%dtcpath,D)) |
126 | | - warn dtc_path does not exist! %%dtcpath |
127 | | - goto EvLoop |
128 | | - elsif @not(@file(%%dtcexe)) |
129 | | - warn dtc.exe does not exist! %%dtcexe |
130 | | - goto EvLoop |
131 | | - end |
132 | | - |
133 | | - directory change, %%dtcpath |
134 | | - |
135 | | - # Debug --------------------------------------------------------------------- |
136 | | - # dtc.exe -q -I dtb -O dts -o "$dts_file" "$dtb_file" |
137 | | -# dialog set, TEXT3, dtc.exe -q -I %%ext_in -O %%ext_out -o %%name.%%ext_out %%name.%%ext_in |
138 | | - #---------------------------------------------------------------------------- |
139 | | - |
140 | | - # cmd.exe strips a \ from \\<network-path> so we add an extra \ |
141 | | - if @equal(@substr(%%file_in,1,2),\\) |
142 | | - %%in_file = \%%file_in |
143 | | - else |
144 | | - %%in_file = %%file_in |
145 | | - end |
146 | | - if @equal(@substr(%%file_out,1,2),\\) |
147 | | - %%out_file = \%%file_out |
148 | | - else |
149 | | - %%out_file = %%file_out |
150 | | - end |
151 | | - |
152 | | - # Debug --------------------------------------------------------------------- |
153 | | - #clipboard set,@chr(34)%%dtcexe@chr(34) -q -I %%ext_in -O %%ext_out -o @chr(34)%%out_file@chr(34) @chr(34)%%in_file@chr(34) |
154 | | - #---------------------------------------------------------------------------- |
155 | | - |
156 | | - runh cmd /C @chr(34)@chr(34)%%dtcexe@chr(34) -q -I %%ext_in -O %%ext_out -o @chr(34)%%out_file@chr(34) @chr(34)%%in_file@chr(34)@chr(34) ,wait 5 ,pipe |
157 | | - %%pipe = @pipe() |
158 | | - |
159 | | - if @null(%%pipe) |
160 | | - dialog set, TEXT4, Finished |
161 | | - else |
162 | | - dialog set, TEXT5, Finished with errors! |
163 | | - dialog show, TEXT5 |
164 | | - info %%pipe , |
165 | | - end |
166 | | - |
167 | | - wait event |
168 | | - goto @event() |
169 | | - |
170 | | - |
| 1 | +#-----------------------------------------------------------------------------# |
| 2 | +# Program: DTC GUI # |
| 3 | +# File: DTC-GUI.dsc # |
| 4 | +# Author: 007revad # |
| 5 | +# Contact: https://github.com/007revad # |
| 6 | +# Copyright: 2024, 007revad # |
| 7 | +#-----------------------------------------------------------------------------# |
| 8 | + |
| 9 | + title DTC GUI |
| 10 | + |
| 11 | + %%inifile = @path(%0)DTC-GUI.ini |
| 12 | + inifile open, %%inifile |
| 13 | + if @not(@ok()) |
| 14 | + warn Failed to open DTC-GUI.ini |
| 15 | + goto Close |
| 16 | + end |
| 17 | + |
| 18 | + |
| 19 | +REM DIALOG CREATE,DTC GUI,-1,0,560,156 |
| 20 | + DIALOG CREATE,DTC GUI,-1,0,560,156,ONTOP,DRAGDROP |
| 21 | +REM *** Modified by Dialog Designer on Thu 3 10 2024 - 13:14 *** |
| 22 | + DIALOG ADD,STYLE,STYLE1,,,B,,RED |
| 23 | + DIALOG ADD,STYLE,STYLE2,,,BC,,00C400 |
| 24 | + DIALOG ADD,STYLE,STYLE3,,,BC,,RED |
| 25 | + DIALOG ADD,TEXT,TEXT1,20,18,45,18,In File |
| 26 | + DIALOG ADD,TEXT,TEXT2,50,18,45,18,Out File |
| 27 | + DIALOG ADD,EDIT,EDIT1,18,70,390,18,,,READONLY |
| 28 | + DIALOG ADD,EDIT,EDIT2,48,70,390,18 |
| 29 | + DIALOG ADD,BUTTON,Select,15,468,70,24,Select File |
| 30 | + DIALOG ADD,TEXT,TEXT3,50,470,70,18,,,STYLE1 |
| 31 | + DIALOG ADD,BUTTON,Compile,80,195,74,24,Compile |
| 32 | + DIALOG ADD,BUTTON,Decompile,80,285,74,24,Decompile |
| 33 | + DIALOG ADD,TEXT,TEXT4,120,20,518,18,,,FITTEXT,STYLE2 |
| 34 | + DIALOG ADD,TEXT,TEXT5,120,20,518,18,,,FITTEXT,STYLE3 |
| 35 | + dialog disable, Compile |
| 36 | + dialog disable, Decompile |
| 37 | + dialog hide, TEXT5 |
| 38 | + DIALOG HIDE |
| 39 | + if @not(@null(%1)) |
| 40 | + %%file_in = %1 |
| 41 | + gosub VerifyFile |
| 42 | + end |
| 43 | + DIALOG SHOW |
| 44 | + |
| 45 | +:EvLoop |
| 46 | + wait event, 0.5 |
| 47 | + goto @event() |
| 48 | + |
| 49 | + |
| 50 | +:TIMER |
| 51 | + %%file_out = @dlgtext(EDIT2) |
| 52 | + %%ext_out = @ext(%%file_out) |
| 53 | + if @both(@equal(%%ext_in,%%ext_out),@both(%%ext_in,%%ext_out)) |
| 54 | + dialog set, TEXT3, Same Type! |
| 55 | + elsif @file(%%file_out) |
| 56 | + dialog set, TEXT3, File Exists! |
| 57 | + else |
| 58 | + dialog set, TEXT3, |
| 59 | + end |
| 60 | + if @both(@equal(%%ext_in,dtb),@equal(%%ext_out,dts)) |
| 61 | + dialog disable, Compile |
| 62 | + dialog enable, Decompile |
| 63 | + elsif @both(@equal(%%ext_in,dts),@equal(%%ext_out,dtb)) |
| 64 | + dialog enable, Compile |
| 65 | + dialog disable, Decompile |
| 66 | + else |
| 67 | + dialog disable, Compile |
| 68 | + dialog disable, Decompile |
| 69 | + end |
| 70 | + goto EvLoop |
| 71 | + |
| 72 | + |
| 73 | +:Close |
| 74 | + inifile close, %%inifile |
| 75 | + stop |
| 76 | + |
| 77 | +:VerifyFile |
| 78 | + %%ext_in = @ext(%%file_in) |
| 79 | + %%name = @name(%%file_in) |
| 80 | + %%path = @path(%%file_in) |
| 81 | + |
| 82 | + if @equal(%%ext_in,dtb) |
| 83 | + %%ext_out = dts |
| 84 | + elsif @equal(%%ext_in,dts) |
| 85 | + %%ext_out = dtb |
| 86 | + else |
| 87 | + warn "Not a dtb or dts file!" |
| 88 | + exit |
| 89 | + end |
| 90 | + |
| 91 | + %%file_out = %%path%%name.%%ext_out |
| 92 | + |
| 93 | + dialog set, EDIT1, %%file_in |
| 94 | + dialog set, EDIT2, %%file_out |
| 95 | + |
| 96 | + dialog set, TEXT4, |
| 97 | + dialog hide, TEXT5 |
| 98 | + exit |
| 99 | + |
| 100 | +:DRAGDROP |
| 101 | + list create,1 |
| 102 | + list dropfiles,1 |
| 103 | + %%file_in = @item(1) |
| 104 | + if @ok() |
| 105 | + gosub VerifyFile |
| 106 | + end |
| 107 | + list close,1 |
| 108 | + goto Timer |
| 109 | + |
| 110 | +:SelectBUTTON |
| 111 | + %%file_in = @filedlg("dtc files (*.dts,*dtb)|*.dt?",Open file) |
| 112 | + if @ok() |
| 113 | + gosub VerifyFile |
| 114 | + end |
| 115 | + goto Timer |
| 116 | + |
| 117 | + |
| 118 | +:SaveBUTTON |
| 119 | + directory change, %%last_save_path |
| 120 | + %%file_out = @filedlg("dtc files (*.dts,*dtb)|*.dt?",Save file) |
| 121 | + |
| 122 | + %%ext_out = @ext(%%file_out) |
| 123 | + %%name = @name(%%file_out) |
| 124 | + %%path_out = @path(%%file_out) |
| 125 | + |
| 126 | + if @equal(%%ext_in,dtb) |
| 127 | + %%ext_out = dts |
| 128 | + elsif @equal(%%ext_in,dts) |
| 129 | + %%ext_out = dtb |
| 130 | + end |
| 131 | + |
| 132 | + %%file_out = %%path_out%%name.%%ext_out |
| 133 | + |
| 134 | + dialog set, EDIT2, %%file_out |
| 135 | + goto Timer |
| 136 | + |
| 137 | + |
| 138 | +:CompileBUTTON |
| 139 | +:DecompileBUTTON |
| 140 | + # Check if dtc.exe exists |
| 141 | + %%dtcpath = @iniread(main, dtc_path) |
| 142 | + %%dtcexe = %%dtcpath\dtc.exe |
| 143 | + if @null(%%dtcpath) |
| 144 | + warn dtc_path not set in DTC-GUI.ini |
| 145 | + goto EvLoop |
| 146 | + elsif @not(@file(%%dtcpath,D)) |
| 147 | + warn dtc_path does not exist! %%dtcpath |
| 148 | + goto EvLoop |
| 149 | + elsif @not(@file(%%dtcexe)) |
| 150 | + warn dtc.exe does not exist! %%dtcexe |
| 151 | + goto EvLoop |
| 152 | + end |
| 153 | + |
| 154 | + directory change, %%dtcpath |
| 155 | + |
| 156 | + # Debug --------------------------------------------------------------------- |
| 157 | + # dtc.exe -q -I dtb -O dts -o "$dts_file" "$dtb_file" |
| 158 | +# dialog set, TEXT3, dtc.exe -q -I %%ext_in -O %%ext_out -o %%name.%%ext_out %%name.%%ext_in |
| 159 | + #---------------------------------------------------------------------------- |
| 160 | + |
| 161 | + # cmd.exe strips a \ from \\<network-path> so we add an extra \ |
| 162 | + if @equal(@substr(%%file_in,1,2),\\) |
| 163 | + %%in_file = \%%file_in |
| 164 | + else |
| 165 | + %%in_file = %%file_in |
| 166 | + end |
| 167 | + if @equal(@substr(%%file_out,1,2),\\) |
| 168 | + %%out_file = \%%file_out |
| 169 | + else |
| 170 | + %%out_file = %%file_out |
| 171 | + end |
| 172 | + |
| 173 | + # Debug --------------------------------------------------------------------- |
| 174 | + #clipboard set,@chr(34)%%dtcexe@chr(34) -q -I %%ext_in -O %%ext_out -o @chr(34)%%out_file@chr(34) @chr(34)%%in_file@chr(34) |
| 175 | + #---------------------------------------------------------------------------- |
| 176 | + |
| 177 | + runh cmd /C @chr(34)@chr(34)%%dtcexe@chr(34) -q -I %%ext_in -O %%ext_out -o @chr(34)%%out_file@chr(34) @chr(34)%%in_file@chr(34)@chr(34) ,wait 5 ,pipe |
| 178 | + %%pipe = @pipe() |
| 179 | + |
| 180 | + if @null(%%pipe) |
| 181 | + dialog set, TEXT4, Finished |
| 182 | + else |
| 183 | + dialog set, TEXT5, Finished with errors! |
| 184 | + dialog show, TEXT5 |
| 185 | + info %%pipe , |
| 186 | + end |
| 187 | + |
| 188 | + wait event |
| 189 | + goto @event() |
| 190 | + |
| 191 | + |
0 commit comments