@@ -76,119 +76,127 @@ public Form1()
76
76
77
77
UAGUtils . InitializeInvoke ( this ) ;
78
78
79
- UAGConfig . Load ( ) ;
79
+ try
80
+ {
81
+ UAGConfig . Load ( ) ;
80
82
81
- Assembly assembly = Assembly . GetExecutingAssembly ( ) ;
82
- UAGUtils . _displayVersion = assembly . GetCustomAttribute < AssemblyInformationalVersionAttribute > ( ) . InformationalVersion ;
83
+ Assembly assembly = Assembly . GetExecutingAssembly ( ) ;
84
+ UAGUtils . _displayVersion = assembly . GetCustomAttribute < AssemblyInformationalVersionAttribute > ( ) . InformationalVersion ;
83
85
84
- string gitVersionGUI = string . Empty ;
85
- using ( Stream stream = assembly . GetManifestResourceStream ( "UAssetGUI.git_commit.txt" ) )
86
- {
87
- if ( stream != null )
86
+ string gitVersionGUI = string . Empty ;
87
+ using ( Stream stream = assembly . GetManifestResourceStream ( "UAssetGUI.git_commit.txt" ) )
88
88
{
89
- using ( StreamReader reader = new StreamReader ( stream ) )
89
+ if ( stream != null )
90
90
{
91
- if ( reader != null ) gitVersionGUI = reader . ReadToEnd ( ) . Trim ( ) ;
91
+ using ( StreamReader reader = new StreamReader ( stream ) )
92
+ {
93
+ if ( reader != null ) gitVersionGUI = reader . ReadToEnd ( ) . Trim ( ) ;
94
+ }
92
95
}
93
96
}
94
- }
95
97
96
- if ( ! gitVersionGUI . All ( "0123456789abcdef" . Contains ) ) gitVersionGUI = string . Empty ;
98
+ if ( ! gitVersionGUI . All ( "0123456789abcdef" . Contains ) ) gitVersionGUI = string . Empty ;
97
99
98
- string gitVersionAPI = string . Empty ;
99
- using ( Stream stream = typeof ( PropertyData ) . Assembly . GetManifestResourceStream ( "UAssetAPI.git_commit.txt" ) )
100
- {
101
- if ( stream != null )
100
+ string gitVersionAPI = string . Empty ;
101
+ using ( Stream stream = typeof ( PropertyData ) . Assembly . GetManifestResourceStream ( "UAssetAPI.git_commit.txt" ) )
102
102
{
103
- using ( StreamReader reader = new StreamReader ( stream ) )
103
+ if ( stream != null )
104
104
{
105
- if ( reader != null ) gitVersionAPI = reader . ReadToEnd ( ) . Trim ( ) ;
105
+ using ( StreamReader reader = new StreamReader ( stream ) )
106
+ {
107
+ if ( reader != null ) gitVersionAPI = reader . ReadToEnd ( ) . Trim ( ) ;
108
+ }
106
109
}
107
110
}
108
- }
109
111
110
- if ( ! gitVersionAPI . All ( "0123456789abcdef" . Contains ) ) gitVersionAPI = string . Empty ;
112
+ if ( ! gitVersionAPI . All ( "0123456789abcdef" . Contains ) ) gitVersionAPI = string . Empty ;
111
113
112
- if ( ! string . IsNullOrEmpty ( gitVersionGUI ) )
113
- {
114
- UAGUtils . _displayVersion += " (" + gitVersionGUI ;
115
- if ( ! string . IsNullOrEmpty ( gitVersionAPI ) )
114
+ if ( ! string . IsNullOrEmpty ( gitVersionGUI ) )
116
115
{
117
- UAGUtils . _displayVersion += " - " + gitVersionAPI ;
116
+ UAGUtils . _displayVersion += " (" + gitVersionGUI ;
117
+ if ( ! string . IsNullOrEmpty ( gitVersionAPI ) )
118
+ {
119
+ UAGUtils . _displayVersion += " - " + gitVersionAPI ;
120
+ }
121
+ UAGUtils . _displayVersion += ")" ;
118
122
}
119
- UAGUtils . _displayVersion += ")" ;
120
- }
121
123
122
- this . Text = DisplayVersion ;
123
- this . AllowDrop = true ;
124
- dataGridView1 . Visible = true ;
124
+ this . Text = DisplayVersion ;
125
+ this . AllowDrop = true ;
126
+ dataGridView1 . Visible = true ;
125
127
126
- // Extra data viewer
127
- byteView1 = new ByteViewer
128
- {
129
- Dock = DockStyle . Fill ,
130
- AutoScroll = true ,
131
- AutoSize = true ,
132
- Visible = false
133
- } ;
134
- splitContainer1 . Panel2 . Controls . Add ( byteView1 ) ;
128
+ // Extra data viewer
129
+ byteView1 = new ByteViewer
130
+ {
131
+ Dock = DockStyle . Fill ,
132
+ AutoScroll = true ,
133
+ AutoSize = true ,
134
+ Visible = false
135
+ } ;
136
+ splitContainer1 . Panel2 . Controls . Add ( byteView1 ) ;
135
137
136
- jsonView = new TextBox
137
- {
138
- Dock = DockStyle . Fill ,
139
- Visible = false ,
140
- AutoSize = true ,
141
- Multiline = true ,
142
- ReadOnly = true ,
143
- MaxLength = int . MaxValue ,
144
- ScrollBars = ScrollBars . Both ,
145
- } ;
146
- splitContainer1 . Panel2 . Controls . Add ( jsonView ) ;
138
+ jsonView = new TextBox
139
+ {
140
+ Dock = DockStyle . Fill ,
141
+ Visible = false ,
142
+ AutoSize = true ,
143
+ Multiline = true ,
144
+ ReadOnly = true ,
145
+ MaxLength = int . MaxValue ,
146
+ ScrollBars = ScrollBars . Both ,
147
+ } ;
148
+ splitContainer1 . Panel2 . Controls . Add ( jsonView ) ;
147
149
148
- jsonView . TextChanged += ( object sender , EventArgs e ) => { if ( tableEditor == null ) return ; tableEditor . dirtySinceLastLoad = true ; SetUnsavedChanges ( true ) ; } ;
150
+ jsonView . TextChanged += ( object sender , EventArgs e ) => { if ( tableEditor == null ) return ; tableEditor . dirtySinceLastLoad = true ; SetUnsavedChanges ( true ) ; } ;
149
151
150
- importBinaryData . Visible = false ;
151
- exportBinaryData . Visible = false ;
152
- setBinaryData . Visible = false ;
152
+ importBinaryData . Visible = false ;
153
+ exportBinaryData . Visible = false ;
154
+ setBinaryData . Visible = false ;
153
155
154
- // Enable double buffering to look nicer
155
- if ( ! SystemInformation . TerminalServerSession )
156
- {
157
- Type ourGridType = dataGridView1 . GetType ( ) ;
158
- PropertyInfo pi = ourGridType . GetProperty ( "DoubleBuffered" , BindingFlags . Instance | BindingFlags . NonPublic ) ;
159
- pi . SetValue ( dataGridView1 , true , null ) ;
160
- }
156
+ // Enable double buffering to look nicer
157
+ if ( ! SystemInformation . TerminalServerSession )
158
+ {
159
+ Type ourGridType = dataGridView1 . GetType ( ) ;
160
+ PropertyInfo pi = ourGridType . GetProperty ( "DoubleBuffered" , BindingFlags . Instance | BindingFlags . NonPublic ) ;
161
+ pi . SetValue ( dataGridView1 , true , null ) ;
162
+ }
161
163
162
- // Auto resizing
163
- SizeChanged += frm_sizeChanged ;
164
- FormClosing += frm_closing ;
164
+ // Auto resizing
165
+ SizeChanged += frm_sizeChanged ;
166
+ FormClosing += frm_closing ;
165
167
166
- // position of ByteViewer buttons depends on splitter location so resize if splitter moves
167
- splitContainer1 . SplitterMoved += ( sender , e ) => { ForceResize ( ) ; } ;
168
+ // position of ByteViewer buttons depends on splitter location so resize if splitter moves
169
+ splitContainer1 . SplitterMoved += ( sender , e ) => { ForceResize ( ) ; } ;
168
170
169
- // Drag-and-drop support
170
- DragEnter += new DragEventHandler ( frm_DragEnter ) ;
171
- DragDrop += new DragEventHandler ( frm_DragDrop ) ;
171
+ // Drag-and-drop support
172
+ DragEnter += new DragEventHandler ( frm_DragEnter ) ;
173
+ DragDrop += new DragEventHandler ( frm_DragDrop ) ;
172
174
173
- dataGridView1 . MouseWheel += dataGridView1_MouseWheel ;
174
- //dataGridView1.EditMode = UAGConfig.Data.DoubleClickToEdit ? DataGridViewEditMode.EditProgrammatically : DataGridViewEditMode.EditOnEnter;
175
+ dataGridView1 . MouseWheel += dataGridView1_MouseWheel ;
176
+ //dataGridView1.EditMode = UAGConfig.Data.DoubleClickToEdit ? DataGridViewEditMode.EditProgrammatically : DataGridViewEditMode.EditOnEnter;
175
177
176
- menuStrip1 . Renderer = new UAGMenuStripRenderer ( ) ;
177
- foreach ( ToolStripMenuItem entry in menuStrip1 . Items )
178
- {
179
- entry . DropDownOpened += ( sender , args ) =>
180
- {
181
- isDropDownOpened [ entry ] = true ;
182
- } ;
183
- entry . DropDownClosed += ( sender , args ) =>
178
+ menuStrip1 . Renderer = new UAGMenuStripRenderer ( ) ;
179
+ foreach ( ToolStripMenuItem entry in menuStrip1 . Items )
184
180
{
185
- isDropDownOpened [ entry ] = false ;
186
- } ;
187
- }
181
+ entry . DropDownOpened += ( sender , args ) =>
182
+ {
183
+ isDropDownOpened [ entry ] = true ;
184
+ } ;
185
+ entry . DropDownClosed += ( sender , args ) =>
186
+ {
187
+ isDropDownOpened [ entry ] = false ;
188
+ } ;
189
+ }
188
190
189
- ac7decrypt = new AC7Decrypt ( ) ;
191
+ ac7decrypt = new AC7Decrypt ( ) ;
190
192
191
- UpdateRPC ( ) ;
193
+ UpdateRPC ( ) ;
194
+ }
195
+ catch ( Exception ex )
196
+ {
197
+ MessageBox . Show ( "An error occured while initializing!\n " + ex . GetType ( ) + ": " + ex . Message + "\n \n UAssetGUI will now close." , "UAssetGUI" ) ;
198
+ Environment . Exit ( 1 ) ; // kill the process
199
+ }
192
200
}
193
201
194
202
private static Dictionary < ToolStripItem , bool > isDropDownOpened = new Dictionary < ToolStripItem , bool > ( ) ;
0 commit comments