_MEMBER_FUNCTION_IMPL(Audio, constructor) { bool sqbIsOnlineStream; script_getbool(pVM, -3, &sqbIsOnlineStream); bool bIsOnlineStream = (sqbIsOnlineStream != 0); bool sqbReplay; script_getbool(pVM, -2, &sqbReplay); bool bReplay = (sqbReplay != 0); const char * szSoundName; script_getstring(pVM, -1, &szSoundName); CAudio * pAudio = new CAudio(szSoundName, bReplay, bIsOnlineStream); ///SQ metatable = null if(!pAudio || !pAudio->Load() || script_setinstance(pVM, pAudio, &_CLASS_DECL(Audio)) != 0) { CLogFile::Printf("Failed to load audio from file %s",szSoundName); SAFE_DELETE(pAudio); script_pushnull(pVM); return 1; } g_pClient->GetAudioManager()->Add(pAudio); //script_pushbool(pVM, true); return 1; }
LRESULT APIENTRY WndProc_Hook(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { bool bFocused = (GetForegroundWindow() == hWnd); // Update HWND state.. if(bFocused != g_pCore->GetGame()->IsFocused()) g_pCore->GetGame()->SetFocused(bFocused); // Are we focused? if(bFocused) { if (g_pCore->GetGraphics()->GetGUI()) g_pCore->GetGraphics()->GetGUI()->HandleUserInput(uMsg, wParam); if(uMsg == WM_KILLFOCUS || (uMsg == WM_ACTIVATE && LOWORD(wParam) == WA_INACTIVE)) { return true; } if(uMsg == WM_KEYUP) { switch(wParam) { case VK_F7: { const char *szSoundName = "test.mp3"; szSoundName = SharedUtility::GetAbsolutePath("resources\\%s", szSoundName); CAudio *pAudio = new CAudio(szSoundName, false, false); if (pAudio && pAudio->Load()) { g_pCore->GetAudioManager()->Add(pAudio); pAudio->Play(); } break; } case VK_ESCAPE: // Our own main menu { g_pCore->GetGraphics()->GetMainMenu()->SetVisible(!g_pCore->GetGraphics()->GetMainMenu()->IsMainMenuVisible()); if (g_pCore->GetGraphics()->GetMainMenu()->IsMainMenuVisible()) { g_pCore->GetGame()->GetLocalPlayer()->SetPlayerControlAdvanced(false, false); } else { g_pCore->GetGame()->GetLocalPlayer()->SetPlayerControlAdvanced(true, true); } break; } case VK_F8: { // Take a screen shot if(!CSnapShot::Take()) { g_pCore->GetGraphics()->GetChat()->Print(CString("Screen shot capture failed (%s).", CSnapShot::GetError().Get())); CSnapShot::Reset(); } break; } } } if(g_pCore->GetGraphics()->GetChat()) g_pCore->GetGraphics()->GetChat()->HandleUserInput(uMsg, wParam); } return CallWindowProc(m_wWndProc, hWnd, uMsg, wParam, lParam); }