Skip to content

Commit

Permalink
#15 Windows reading level and soundtrack name from command line
Browse files Browse the repository at this point in the history
  • Loading branch information
XProger committed Dec 30, 2016
1 parent d52b478 commit c7f1226
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 14 deletions.
Binary file added bin/008.ogg
Binary file not shown.
Binary file added bin/CUT1.PHD
Binary file not shown.
Binary file modified bin/OpenLara.exe
Binary file not shown.
16 changes: 9 additions & 7 deletions src/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,32 @@
namespace Game {
Level *level;

void startLevel(Stream &stream, bool demo, bool home) {
void startLevel(Stream &stream, const char *sndName, bool demo, bool home) {
delete level;
level = new Level(stream, demo, home);

#ifndef __EMSCRIPTEN__
//Sound::play(Sound::openWAD("05_Lara's_Themes.wav"), 1, 1, 0);
Sound::play(new Stream("05.ogg"), vec3(0.0f), 1, 1, Sound::Flags::LOOP);
Sound::play(new Stream(sndName), vec3(0.0f), 1, 1, Sound::Flags::LOOP);
//Sound::play(new Stream("03.mp3"), 1, 1, 0);
#endif
}

void startLevel(const char *name, bool demo, bool home) {
Stream stream(name);
startLevel(stream, demo, home);
void startLevel(const char *lvlName, const char *sndName, bool demo, bool home) {
Stream stream(lvlName);
startLevel(stream, sndName, demo, home);
}

void init() {
void init(char *lvlName = NULL, char *sndName = NULL) {
Core::init();
level = NULL;

if (!lvlName) lvlName = "LEVEL2.PSX";
if (!sndName) sndName = "05.ogg";
//lstartLevel("LEVEL2_DEMO.PHD", true, false);
//lstartLevel("GYM.PSX", false, true);
//lstartLevel("LEVEL3A.PHD", false, false);
startLevel("CUT1.PHD", false, false);
startLevel(lvlName, sndName, false, false);
}

void free() {
Expand Down
4 changes: 2 additions & 2 deletions src/platform/win/OpenLara.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@
<WholeProgramOptimization>true</WholeProgramOptimization>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>false</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>wcrt.lib;opengl32.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
Expand Down
15 changes: 10 additions & 5 deletions src/platform/win/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,15 +272,16 @@ void freeGL(HGLRC hRC) {
}

#ifdef _DEBUG
int main() {
int main(int argc, char** argv) {
_CrtMemState _ms;
_CrtMemCheckpoint(&_ms);
_CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
_CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDOUT);
#elif PROFILE
int main() {
//#elif PROFILE
#else
int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
int main(int argc, char** argv) {
//#else
//int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
#endif
RECT r = { 0, 0, 1280, 720 };
AdjustWindowRect(&r, WS_OVERLAPPEDWINDOW, false);
Expand All @@ -292,7 +293,11 @@ int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi

joyInit();
sndInit(hWnd);
Game::init();

char *lvlName = argc > 1 ? argv[1] : NULL;
char *sndName = argc > 2 ? argv[2] : NULL;

Game::init(lvlName, sndName);

SetWindowLong(hWnd, GWL_WNDPROC, (LONG)&WndProc);
ShowWindow(hWnd, SW_SHOWDEFAULT);
Expand Down

0 comments on commit c7f1226

Please sign in to comment.