-
Notifications
You must be signed in to change notification settings - Fork 0
/
CWorkerThread.cpp
122 lines (99 loc) · 2.85 KB
/
CWorkerThread.cpp
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/*
Proteus Controller - A Preset editor for E-mu Proteus compatible
sound modules
Copyright (C) 2004 John McCann
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
http://www.gnu.org/copyleft/gpl.html
*/
#include "CWorkerThread.h"
#include "CProteusController.h"
#include "Events.h"
#include "wx/string.h"
CWorkerThread::CWorkerThread(CProteusControllerApp* app, CProteus* proteus) : wxThread()
{
mApp = app;
Proteus = proteus;
mROM = 0;
mPresetID = 0;
}
void* CWorkerThread::Entry()
{
switch(mOperation)
{
case eLoadPreset:
{
long err = Proteus->LoadPreset(mROM, mPresetID, this);
if(err) return NULL;
wxCommandEvent event( wxEVT_COMMAND_MENU_SELECTED, eLoadPresetComplete );
wxPostEvent( mApp, event );
}
break;
case eDownloadPresets:
{
wxString fileName;
mApp->GetAppPath(fileName);
if(mROM == 0)
{
fileName.append("\\UserPresets.txt");
mApp->Proteus.DownloadUserPresetNames(this);
mApp->Proteus.SaveUserPresetNames(fileName.GetData());
}
else
{
fileName.append(wxString::Format("\\ROMPresets_%i_.txt", mROM));
mApp->Proteus.DownloadROMPresetNames(mROM, this);
mApp->Proteus.SaveROMPresetNames(fileName, mROM);
}
wxCommandEvent event( wxEVT_COMMAND_MENU_SELECTED, eDownloadPresetsComplete );
wxPostEvent( mApp, event );
}
break;
case eDownloadInstruments:
{
wxString fileName;
mApp->GetAppPath(fileName);
fileName.append("\\InstrumentNames.txt");
mApp->Proteus.DownloadInstrumentNames(this);
mApp->Proteus.SaveInstrumentNames(fileName.GetData());
wxCommandEvent event( wxEVT_COMMAND_MENU_SELECTED, eDownloadInstrumentsComplete );
wxPostEvent( mApp, event );
}
break;
}
return NULL;
}
void CWorkerThread::Set(int operation, short ROM, short presetID)
{
mOperation = operation;
if(ROM == -1)
mROM = 0;
else
mROM = ROM;
mPresetID = presetID;
}
void CWorkerThread::SetTotalSteps(int steps)
{
wxCommandEvent event(wxEVT_COMMAND_MENU_SELECTED, eSetStepsEvent);
event.SetInt(steps);
wxPostEvent( mApp, event );
}
void CWorkerThread::Step()
{
wxCommandEvent event( wxEVT_COMMAND_MENU_SELECTED, eStepEvent );
wxPostEvent( mApp, event );
}
bool CWorkerThread::IsCancelled()
{
if(TestDestroy())
return true;
if(mApp->mProgressDlg)
return mApp->mProgressDlg->mCancelled;
return false;
}