@@ -179,6 +179,23 @@ protected override void OnUpdateFrame(FrameEventArgs e)
179179 Camera . position . Y -= delta * 6f ;
180180 }
181181
182+ if ( GUI . Scene == 1 && wantToSave ) {
183+ GUI . SetScene ( 2 ) ;
184+ UnlockMouse ( ) ;
185+ Thread saveThread = new Thread ( ( ) =>
186+ {
187+ System . Windows . Forms . DialogResult res = System . Windows . Forms . MessageBox . Show ( "Are you sure you want to save" , "Confirm save" ,
188+ System . Windows . Forms . MessageBoxButtons . YesNo , System . Windows . Forms . MessageBoxIcon . Question ,
189+ System . Windows . Forms . MessageBoxDefaultButton . Button1 ) ;
190+ if ( res == System . Windows . Forms . DialogResult . Yes )
191+ World . Save ( ) ;
192+
193+ wantToSave = false ;
194+ GUI . SetScene ( 1 ) ;
195+ } ) ;
196+ saveThread . Start ( ) ;
197+ }
198+
182199 Console . Title = Camera . position . ToString ( ) ;
183200
184201 // Other keyboard
@@ -190,7 +207,7 @@ protected override void OnUpdateFrame(FrameEventArgs e)
190207 GUI . Update ( delta ) ;
191208
192209 float FPS = 1f / delta ;
193- Title = $ "BuildPlate_Editor FPS: { SystemPlus . MathPlus . Round ( FPS , 2 ) } ";
210+ Title = $ "BuildPlate_Editor FPS: { MathPlus . Round ( FPS , 2 ) } ";
194211 }
195212
196213 protected override void OnRenderFrame ( FrameEventArgs e )
@@ -202,21 +219,21 @@ protected override void OnRenderFrame(FrameEventArgs e)
202219 Camera . UpdateView ( Width , Height ) ;
203220 shader . UploadMat4 ( "uProjection" , ref Camera . projMatrix ) ;
204221 shader . UploadMat4 ( "uView" , ref Camera . viewMatrix ) ;
205- if ( GUI . Scene == 1 )
222+ if ( GUI . Scene > 0 )
206223 World . Render ( shader ) ;
207224
208225 colShader . Bind ( ) ;
209226 colShader . UploadMat4 ( "uProjection" , ref Camera . projMatrix ) ;
210227 colShader . UploadMat4 ( "uView" , ref Camera . viewMatrix ) ;
211- if ( GUI . Scene == 1 )
228+ if ( GUI . Scene > 0 )
212229 outline . Render ( colShader ) ;
213230
214231 skyboxShader . Bind ( ) ;
215232 skyboxShader . UploadMat4 ( "uProjection" , ref Camera . projMatrix ) ;
216233 skyboxShader . UploadMat4 ( "uView" , ref Camera . viewMatrix ) ;
217234 GL . Disable ( EnableCap . CullFace ) ;
218235 SkyBox . pos = Camera . position ;
219- if ( GUI . Scene == 1 )
236+ if ( GUI . Scene > 0 )
220237 SkyBox . Render ( skyboxShader ) ;
221238 GL . Enable ( EnableCap . CullFace ) ;
222239
@@ -227,10 +244,9 @@ protected override void OnRenderFrame(FrameEventArgs e)
227244 SwapBuffers ( ) ;
228245 }
229246
247+ bool wantToSave = false ;
230248 protected override void OnKeyDown ( KeyboardKeyEventArgs e )
231249 {
232- keyboardState = e . Keyboard ;
233-
234250 if ( e . Key == Key . P ) {
235251 Vector3i pos = ( Vector3i ) outline . Position ;
236252 World . GetBlockIndex ( pos , out int sbi , out int bi ) ;
@@ -250,7 +266,12 @@ protected override void OnKeyDown(KeyboardKeyEventArgs e)
250266 else
251267 World . BlockToPlace = input ;
252268 }
269+ } else if ( e . Key == Key . S && ( e . Modifiers & KeyModifiers . Control ) == KeyModifiers . Control ) // save
270+ {
271+ wantToSave = true ;
253272 }
273+ else
274+ keyboardState = e . Keyboard ;
254275
255276 GUI . OnKeyDown ( e . Key , e . Modifiers ) ;
256277 }
0 commit comments