_MEMBER_FUNCTION_IMPL(Audio, play) { CAudio * pAudio = script_getinstance<CAudio *>(pVM); script_pushbool(pVM, pAudio->Play()); 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); }