summaryrefslogtreecommitdiffstats
path: root/Examples/WhisperDesktop/WhisperDesktop.cpp
blob: ddef5b6bdd8f05ae231dadcfb1f611f1cbbef115 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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;
	}
}