66 3DMM SDL Dialog support
77
88***************************************************************************/
9+ #include < cstdio>
910#include " frame.h"
1011ASSERTNAME
1112
13+ #include " utestres.h"
14+
1215bool DLG::_FInit (void )
1316{
14- return fFalse ;
17+ bool fRet = fFalse ;
18+ const int32_t kcdit = 2 ;
19+
20+ // We only support certain dialog boxes
21+ if (_rid != dlidAbnormalExit && _rid != dlidInitFailed && _rid != dlidInitFailedOOM && _rid != dlidGenericErrorBox)
22+ goto LFail;
23+
24+ // Allocate some dialog items to allow setting text in error messages
25+ if (!FEnsureSpace (kcdit, SIZEOF (int32_t ), fgrpNil))
26+ goto LFail;
27+
28+ DIT dit;
29+ ClearPb (&dit, SIZEOF (dit));
30+ dit.ditk = ditkEditText;
31+
32+ for (int32_t idit = 0 ; idit < kcdit; idit++)
33+ {
34+ if (!FInsert (idit, 0 , pvNil, &dit))
35+ goto LFail;
36+ }
37+
38+ fRet = fTrue ;
39+
40+ LFail:
41+ return fRet ;
1542}
1643
1744/* **************************************************************************
@@ -20,8 +47,51 @@ bool DLG::_FInit(void)
2047***************************************************************************/
2148int32_t DLG::IditDo (int32_t iditFocus)
2249{
23- RawRtn ();
24- return ivNil;
50+ STN stnMessage;
51+ STN stnT;
52+ U8SZ u8szTitle;
53+ U8SZ u8szMessage;
54+
55+ switch (_rid)
56+ {
57+ case dlidAbnormalExit:
58+ stnMessage = PszLit (" 3D Movie Maker ended unexpectedly. Attempting to clean up." );
59+ break ;
60+
61+ case dlidInitFailed:
62+ stnMessage = PszLit (" 3D Movie Maker could not start." );
63+ break ;
64+
65+ case dlidInitFailedOOM:
66+ stnMessage = PszLit (" 3D Movie Maker could not start because there is not enough memory available." );
67+ break ;
68+
69+ case dlidGenericErrorBox:
70+ stnT = PszLit (" (unknown)" );
71+ GetStn (1 , &stnT);
72+ stnMessage.FFormatSz (PszLit (" 3D Movie Maker could not start because the following function failed: %s" ), &stnT);
73+ break ;
74+
75+ default :
76+ Bug (" Unimplemented dialog box type" );
77+ stnMessage.FFormatSz (PszLit (" Unimplemented dialog box type: %d" ), _rid);
78+ break ;
79+ }
80+
81+ vpappb->GetStnAppName (&stnT);
82+ stnT.GetUtf8Sz (u8szTitle);
83+
84+ stnMessage.GetUtf8Sz (u8szMessage);
85+ if (SDL_ShowSimpleMessageBox (SDL_MESSAGEBOX_ERROR, u8szTitle, u8szMessage, pvNil) != 0 )
86+ {
87+ Bug (SDL_GetError ());
88+ // Cannot show a message box, so we will print to stderr instead.
89+ fprintf (stderr, " %s\n " , u8szMessage);
90+ }
91+
92+ // This should return the ID of the dialog box item that dismissed the dialog.
93+ // However, we don't have any dialog box item IDs, so we will just return non-zero to indicate success.
94+ return 1 ;
2595}
2696
2797/* **************************************************************************
0 commit comments