summaryrefslogtreecommitdiffstats
path: root/Examples/WhisperDesktop/WhisperDesktop.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Examples/WhisperDesktop/WhisperDesktop.cpp')
-rw-r--r--Examples/WhisperDesktop/WhisperDesktop.cpp63
1 files changed, 63 insertions, 0 deletions
diff --git a/Examples/WhisperDesktop/WhisperDesktop.cpp b/Examples/WhisperDesktop/WhisperDesktop.cpp
new file mode 100644
index 0000000..ddef5b6
--- /dev/null
+++ b/Examples/WhisperDesktop/WhisperDesktop.cpp
@@ -0,0 +1,63 @@
+#include "stdafx.h"
+#include "AppState.h"
+#include "Utils/miscUtils.h"
+#include "LoadModelDlg.h"
+#include "TranscribeDlg.h"
+#include "CaptureDlg.h"
+
+HRESULT dialogLoadModel( AppState& appState )
+{
+ LoadModelDlg loadDialog{ appState };
+ HRESULT hr = loadDialog.show();
+ if( FAILED( hr ) )
+ {
+ reportFatalError( "Error loading the model", hr );
+ return hr;
+ }
+ appState.automaticallyLoadModel = false;
+ return hr;
+}
+
+HRESULT dialogTranscribe( AppState& appState )
+{
+ TranscribeDlg dialog{ appState };
+ return dialog.show();
+}
+
+HRESULT dialogCapture( AppState& appState )
+{
+ CaptureDlg dialog{ appState };
+ return dialog.show();
+}
+
+using pfnDialog = HRESULT( * )( AppState& appState );
+static const std::array<pfnDialog, 4> s_dialogs =
+{
+ nullptr, // S_OK
+ &dialogLoadModel, // SCREEN_MODEL
+ &dialogTranscribe, // SCREEN_TRANSCRIBE
+ &dialogCapture, // SCREEN_CAPTURE
+};
+
+int __stdcall wWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow )
+{
+ AppState appState;
+ HRESULT hr = appState.startup();
+ if( FAILED( hr ) )
+ return hr;
+
+ appState.findModelSource();
+
+ hr = SCREEN_MODEL;
+ while( true )
+ {
+ pfnDialog pfn = s_dialogs[ hr ];
+ if( nullptr == pfn )
+ return S_OK;
+ hr = pfn( appState );
+ if( FAILED( hr ) )
+ return hr;
+ if( hr == SCREEN_MODEL )
+ appState.model = nullptr;
+ }
+} \ No newline at end of file