コード例 #1
0
	BOOL handleMessages( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
	{
		int index = 0;
		std::string mod;

		int modIndex = modSelector.getActiveIndex();
		int menuId = game::SimpleOptions::getInt(DH_OPT_I_MENU_LANGUAGE);
		int speechId = game::SimpleOptions::getInt(DH_OPT_I_SPEECH_LANGUAGE);
		int subtitleId = game::SimpleOptions::getInt(DH_OPT_I_SUBTITLE_LANGUAGE);
		std::string modDir;
		std::string parameters;

		switch( msg )
		{
		case WM_INITDIALOG:
			SetFocus( GetDlgItem( hwnd, IDOK ) );
			break; 

		case WM_COMMAND:
		{	
			int command = LOWORD(wParam);
						
			switch( command )
			{
			case IDOK:
				applyOptions( hwnd );
				GameOptionManager::getInstance()->save();
				PostQuitMessage( 0 );

				modSelector.restoreDir();

				//int modIndex = modSelector.getActiveIndex();
				if(modIndex >= 0)
				{
					//int menuId = game::SimpleOptions::getInt(DH_OPT_I_MENU_LANGUAGE);
					//int speechId = game::SimpleOptions::getInt(DH_OPT_I_SPEECH_LANGUAGE);
					//int subtitleId = game::SimpleOptions::getInt(DH_OPT_I_SUBTITLE_LANGUAGE);
					modDir = modSelector.getModDir(modIndex);

					parameters += "-mod=" + modDir;
					parameters += " -menu_language=" + boost::lexical_cast<std::string> (menuId);
					parameters += " -speech_language=" + boost::lexical_cast<std::string> (speechId);
					parameters += " -subtitle_language=" + boost::lexical_cast<std::string> (subtitleId);

					//MessageBox(0, command.c_str(), "Shit happens", MB_OK);
					ShellExecute( 0, 0, "claw_proto.exe", parameters.c_str(), 0, SW_NORMAL );
				}
				else
				{
					ShellExecute( 0, 0, "claw_proto.exe", 0, 0, SW_NORMAL );
				}

				// manager.save();
				break;

			case IDCHECKUPDATES:
				//applyOptions( hwnd );
				//GameOptionManager::getInstance()->save();
				//ShellExecute( 0, 0, "Updater.exe", 0, 0, SW_NORMAL );
				//system("start Updater.exe");
				modSelector.restoreDir();
				hiddencommand("Updater\\start_updater.bat", false);
				PostQuitMessage( 0 );
				// manager.save();
				break;

			case IDC_ACTIVATEMOD:
				index = SendMessage( GetDlgItem( hwnd, IDC_COMBOMODSELECTION ), CB_GETCURSEL, 0, 0);
				modSelector.saveActiveModFile(index - 1);

				modSelector.restoreDir();

				if(fileExists("Shadowgrounds Launcher.exe"))
					ShellExecute( 0, 0, "Shadowgrounds Launcher.exe", 0, 0, SW_NORMAL );
				else
					ShellExecute( 0, 0, "ShadowgroundsLauncher.exe", 0, 0, SW_NORMAL );

				PostQuitMessage( 0 );
				break;

			case IDC_EDITOR_MANUAL:
				modSelector.restoreDir();

				if(fileExists("Editor Manual.rtf"))
					ShellExecute( 0, 0, "Editor Manual.rtf", 0, 0, SW_NORMAL );
				else
					ShellExecute( 0, 0, "EditorManual.rtf", 0, 0, SW_NORMAL );


				modSelector.changeDir();
				break;

			case IDC_EDITOR_LAUNCH:
				modSelector.restoreDir();
#ifdef STEAM_HAX
				ShellExecute( 0, 0, "steam://run/2505", 0, 0, SW_NORMAL );
#else
				if(fileExists("Shadowgrounds Editor.exe"))
					ShellExecute( 0, 0, "Shadowgrounds Editor.exe", 0, 0, SW_NORMAL );
				else
					ShellExecute( 0, 0, "ShadowgroundsEditor.exe", 0, 0, SW_NORMAL );
#endif
				PostQuitMessage( 0 );
				break;

			case IDCANCEL:
				PostQuitMessage( 0 );
				break;

			case IDC_BUTTONADVANCED:
				applyOptions( hwnd );
				lwindow->openAdvanced();

				break;
			}

			break;
		}

		case WM_SHOWWINDOW:
			manager.load();
			initDialog( hwnd );	
			break;

		};


		return 0;
	}