-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsetupwin.cpp
142 lines (111 loc) · 3.56 KB
/
setupwin.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#include "RED2Launcher.h"
#include "ini.h"
#include "config_ini_writer.h"
#include "iso9660_dump.h"
void RunJPSXDec(const char* imageFilename)
{
#ifdef PLATFORM_WIN32
const char* indexesFile = "install\\idxfile.tmp";
system(Format("java -jar install\\jpsxdec.jar -f \"%s\" -x \"%s\"\n", imageFilename, indexesFile));
system(Format("java -jar install\\jpsxdec.jar -x \"%s\" -a video -quality psx -vf avi:mjpg -up Lanczos3", indexesFile));
system(Format("java -jar install\\jpsxdec.jar -x \"%s\" -a audio -quality psx -af wav", indexesFile));
#endif
#ifdef PLATFORM_LINUX
const char* indexesFile = "install/idxfile.tmp";
system(Format("java -jar install/jpsxdec.jar -f \"%s\" -x \"%s\"\n", imageFilename, indexesFile));
system(Format("java -jar install/jpsxdec.jar -x \"%s\" -a video -quality psx -vf avi:mjpg -up Lanczos3", indexesFile));
system(Format("java -jar install/jpsxdec.jar -x \"%s\" -a audio -quality psx -af wav", indexesFile));
#endif
}
SetupWizardWindow::SetupWizardWindow()
{
CtrlLayout(*this, "Setup wizard");
fs.ActiveDir(".");
fs.Type("Compatible ISO 9660 files (.bin, .iso, .ccd)", "*.bin *.iso *.ccd");
unpackFMV_XACheck.Set(1);
fullUnpackCheck.Set(1);
imageCD1ChooseBtn << [=] {
if(!fs.ExecuteOpen("Select ISO/BIN image"))
return;
imageCD1FilenameEdit = (~fs);
};
imageCD2ChooseBtn << [=] {
if(!fs.ExecuteOpen("Select ISO/BIN image"))
return;
imageCD2FilenameEdit = (~fs);
};
installBtn << [=] {
std::string cd1Filename = (~imageCD1FilenameEdit).ToStd();
std::string cd2Filename = (~imageCD2FilenameEdit).ToStd();
if(cd1Filename.length() < 2 && cd2Filename.length() < 2)
{
Exclamation("Please select CD1 or CD2 to continue!");
return;
}
bool dumped = false;
std::string cdImageFiles[2] = {
cd1Filename,
cd2Filename
};
if(cd1Filename.length() < 2 || cd2Filename.length() < 2)
{
if(!PromptYesNo("Not all CD images selected. You will still be able to run the game. Continue?"))
return;
}
for(int i = 0; i < 2; i++)
{
if(cdImageFiles[i].length() < 2)
continue;
const char* imageFilename = cdImageFiles[i].c_str();
if(CheckIsDriver2GameImage(imageFilename))
{
if(!dumped) // this will allow to dump any of CDs
{
bool dumpImage = fullUnpackCheck.Get();
if(dumpImage)
{
if(!DumpImageFile((char*)imageFilename))
{
Exclamation("Unable to unpack the game!");
return;
}
}
int languageId = DetectDriver2Language((char*)imageFilename);
if(languageId != -1)
{
PromptOK(String("Language detected: ") + LanguageList[languageId]);
}
else
Exclamation("Unable to detect language - custom CDs?");
// make default best game settings
config_data_t cfgData;
BestDefaultConfig(&cfgData);
cfgData.languageId = languageId;
cfgData.imageFilename = dumpImage ? NULL : (char*)imageFilename;
if(!SaveNewConfigFile(&cfgData))
Exclamation("Unable to save 'config.ini'!");
PromptOK(String("Detected game language: ") + LanguageList[languageId]);
dumped = true;
}
// also run FMV and XA conversion
if(unpackFMV_XACheck.Get())
{
RunJPSXDec(imageFilename);
}
}
else
{
Exclamation(Format("CD%d is not valid game CD image or it is corrupted!", i + 1));
}
}
if(!dumped)
{
Exclamation("Installation failed!");
}
else
{
PromptOK("Installation completed!");
}
Close();
};
}