@@ -35,7 +35,7 @@ use apiw::application_support_functions::SaveFileDialogFlags;
35
35
pub fn ui_alert ( msg : & str ) {
36
36
MessageBoxBuilder :: new ( )
37
37
. message ( msg)
38
- . invoke ( ) ;
38
+ . invoke ( ) . unwrap ( ) ;
39
39
}
40
40
41
41
pub struct Ui ;
@@ -55,7 +55,7 @@ impl Ui {
55
55
Self :: create_main_window ( ) ?;
56
56
57
57
THE_GAME . with ( |game| {
58
- let mut game = game. try_borrow_mut ( ) . or_else ( |_| apiw:: last_error ( ) ) ?;
58
+ let mut game = game. try_borrow_mut ( ) . or_else ( |_| apiw:: Error :: last ( ) ) ?;
59
59
let game = & mut * game;
60
60
game. mvc . process_input ( ControllerInput :: Initialize ) ;
61
61
Ok ( ( ) )
@@ -144,7 +144,7 @@ BOOL HandleMapFile(bool bSave, UINT nFilterResID, LPCTSTR lpszDefExt, LPTSTR lps
144
144
request
145
145
. route_create ( |window : & ForeignWindow , _| -> apiw:: Result < bool > {
146
146
THE_GAME . with ( |game| {
147
- let mut game = game. try_borrow_mut ( ) . or_else ( |_| apiw:: last_error ( ) ) ?;
147
+ let mut game = game. try_borrow_mut ( ) . or_else ( |_| apiw:: Error :: last ( ) ) ?;
148
148
let game = & mut * game;
149
149
game. mvc . redirect_output_target ( Some ( window. clone ( ) ) ) ;
150
150
window. invalidate ( ) ?;
@@ -156,7 +156,7 @@ BOOL HandleMapFile(bool bSave, UINT nFilterResID, LPCTSTR lpszDefExt, LPTSTR lps
156
156
let mut paint_dc = window. do_paint ( ) ?;
157
157
158
158
THE_GAME . with ( |game| {
159
- let game = game. try_borrow ( ) . or_else ( |_| apiw:: last_error ( ) ) ?;
159
+ let game = game. try_borrow ( ) . or_else ( |_| apiw:: Error :: last ( ) ) ?;
160
160
game. mvc . sync_output_with_parameter ( & mut paint_dc) ;
161
161
Ok ( ( ) )
162
162
} ) ?;
@@ -168,7 +168,7 @@ BOOL HandleMapFile(bool bSave, UINT nFilterResID, LPCTSTR lpszDefExt, LPTSTR lps
168
168
THE_GAME . with ( |game| {
169
169
use apiw:: windows_subsystem:: window:: MouseEventArgType ;
170
170
171
- let mut game = game. try_borrow_mut ( ) . or_else ( |_| apiw:: last_error ( ) ) ?;
171
+ let mut game = game. try_borrow_mut ( ) . or_else ( |_| apiw:: Error :: last ( ) ) ?;
172
172
let game = & mut * game;
173
173
174
174
let mut target = None ;
@@ -213,7 +213,7 @@ BOOL HandleMapFile(bool bSave, UINT nFilterResID, LPCTSTR lpszDefExt, LPTSTR lps
213
213
match args. id ( ) as isize {
214
214
resources:: IDM_FILE_NEW => {
215
215
THE_GAME . with ( |game| {
216
- let mut game = game. try_borrow_mut ( ) . or_else ( |_| apiw:: last_error ( ) ) ?;
216
+ let mut game = game. try_borrow_mut ( ) . or_else ( |_| apiw:: Error :: last ( ) ) ?;
217
217
let game = & mut * game;
218
218
game. mvc . process_input ( ControllerInput :: ModelCommand (
219
219
ModelCommand :: NewGame ) ) ;
@@ -222,7 +222,7 @@ BOOL HandleMapFile(bool bSave, UINT nFilterResID, LPCTSTR lpszDefExt, LPTSTR lps
222
222
}
223
223
resources:: IDM_FILE_GAME_EASY | resources:: IDM_FILE_GAME_MEDIUM | resources:: IDM_FILE_GAME_HARD => {
224
224
THE_GAME . with ( |game| {
225
- let mut game = game. try_borrow_mut ( ) . or_else ( |_| apiw:: last_error ( ) ) ?;
225
+ let mut game = game. try_borrow_mut ( ) . or_else ( |_| apiw:: Error :: last ( ) ) ?;
226
226
let game = & mut * game;
227
227
let boardsetting = match args. id ( ) as isize {
228
228
resources:: IDM_FILE_GAME_EASY => model_config:: BoardSetting :: EASY ,
@@ -237,21 +237,38 @@ BOOL HandleMapFile(bool bSave, UINT nFilterResID, LPCTSTR lpszDefExt, LPTSTR lps
237
237
}
238
238
resources:: IDM_FILE_MARK => {
239
239
THE_GAME . with ( |game| {
240
- let mut game = game. try_borrow_mut ( ) . or_else ( |_| apiw:: last_error ( ) ) ?;
240
+ let mut game = game. try_borrow_mut ( ) . or_else ( |_| apiw:: Error :: last ( ) ) ?;
241
241
let game = & mut * game;
242
242
243
243
game. mvc . process_input ( ControllerInput :: ModelCommand (
244
244
ModelCommand :: ToggleAllowMarks ) ) ;
245
245
Ok ( ( ) )
246
246
} ) ?;
247
- }
247
+ } ,
248
+ resources:: IDM_ADVANCED_ZOOM_1x | resources:: IDM_ADVANCED_ZOOM_2x | resources:: IDM_ADVANCED_ZOOM_3x => {
249
+ THE_GAME . with ( |game| {
250
+ let mut game = game. try_borrow_mut ( ) . or_else ( |_| apiw:: Error :: last ( ) ) ?;
251
+ let game = & mut * game;
252
+
253
+ game. mvc . process_input ( ControllerInput :: ModelCommand (
254
+ ModelCommand :: UpdateZoomRatio (
255
+ match args. id ( ) as isize {
256
+ resources:: IDM_ADVANCED_ZOOM_1x => model_config:: ZoomRatio :: Zoom1x ,
257
+ resources:: IDM_ADVANCED_ZOOM_2x => model_config:: ZoomRatio :: Zoom2x ,
258
+ resources:: IDM_ADVANCED_ZOOM_3x => model_config:: ZoomRatio :: Zoom3x ,
259
+ _ => unreachable ! ( ) ,
260
+ }
261
+ ) ) ) ;
262
+ Ok ( ( ) )
263
+ } ) ?;
264
+ } ,
248
265
resources:: IDM_FILE_EXIT => {
249
266
window. destroy ( ) ?;
250
267
} ,
251
268
resources:: IDM_ADVANCED_LOADMAP => {
252
269
if let Some ( path) = Ui :: call_open_file_dialog ( window, 0 , "cmm" ) {
253
270
THE_GAME . with ( |game| {
254
- let mut game = game. try_borrow_mut ( ) . or_else ( |_| apiw:: last_error ( ) ) ?;
271
+ let mut game = game. try_borrow_mut ( ) . or_else ( |_| apiw:: Error :: last ( ) ) ?;
255
272
let game = & mut * game;
256
273
257
274
game. mvc . process_input ( ControllerInput :: ModelCommand (
@@ -263,7 +280,7 @@ BOOL HandleMapFile(bool bSave, UINT nFilterResID, LPCTSTR lpszDefExt, LPTSTR lps
263
280
resources:: IDM_ADVANCED_SAVEMAP => {
264
281
if let Some ( path) = Ui :: call_save_file_dialog ( window, 0 , "cmm" ) {
265
282
THE_GAME . with ( |game| {
266
- let mut game = game. try_borrow_mut ( ) . or_else ( |_| apiw:: last_error ( ) ) ?;
283
+ let mut game = game. try_borrow_mut ( ) . or_else ( |_| apiw:: Error :: last ( ) ) ?;
267
284
let game = & mut * game;
268
285
269
286
game. mvc . process_input ( ControllerInput :: ModelCommand (
@@ -274,7 +291,7 @@ BOOL HandleMapFile(bool bSave, UINT nFilterResID, LPCTSTR lpszDefExt, LPTSTR lps
274
291
} ,
275
292
resources:: IDM_ADVANCED_RESTART => {
276
293
THE_GAME . with ( |game| {
277
- let mut game = game. try_borrow_mut ( ) . or_else ( |_| apiw:: last_error ( ) ) ?;
294
+ let mut game = game. try_borrow_mut ( ) . or_else ( |_| apiw:: Error :: last ( ) ) ?;
278
295
let game = & mut * game;
279
296
280
297
game. mvc . process_input ( ControllerInput :: ModelCommand (
0 commit comments