/// --------------------------------------------------------------------------- /// Receives mouse data messages from the window message handler. /// --------------------------------------------------------------------------- void prMouse::SetMouseData(s32 x, s32 y, u32 flags, bool state) { #if defined(PLATFORM_LINUX) m_xPos = x; m_yPos = y; switch(flags) { case MOUSE_BUTTON_LEFT: case MOUSE_BUTTON_RIGHT: case MOUSE_BUTTON_MIDDLE: m_flags = state ? PRSET_FLAG(m_flags, flags) : PRCLEAR_FLAG(m_flags, flags); break; } #else PRUNUSED(state); if (m_reset) { m_reset = false; m_flags = 0; } m_xPos = x; m_yPos = y; m_flags |= flags; #endif }
/// --------------------------------------------------------------------------- /// Mute/unmute all sound /// --------------------------------------------------------------------------- void prSoundManager::Mute(bool state) { #ifdef SOUND_ALLOW if (state) { if (!mIsMuted) { masterMusVolumeBackup = masterMusVolume; masterSfxVolumeBackup = masterSfxVolume; masterMusVolume = 0.0f; masterSfxVolume = 0.0f; mIsMuted = true; } } else { if (mIsMuted) { masterMusVolume = masterMusVolumeBackup; masterSfxVolume = masterSfxVolumeBackup; masterMusVolumeBackup = 0.0f; masterSfxVolumeBackup = 0.0f; mIsMuted = false; } } #else PRUNUSED(state); #endif }
/// --------------------------------------------------------------------------- /// Sets the master volume. /// --------------------------------------------------------------------------- void prSoundManager::SongSetMasterVolume(f32 volume) { #ifdef SOUND_ALLOW masterMusVolume = PRCLAMP(volume, AUDIO_MUS_MIN_VOLUME, AUDIO_MUS_MAX_VOLUME); SongSetVolume(songVolume); #else PRUNUSED(volume); #endif }
/// --------------------------------------------------------------------------- /// Displays the last windows error message. /// --------------------------------------------------------------------------- void prDebugShowLastError(const char *msg) { #if defined(PLATFORM_PC) DWORD dw = GetLastError(); if (dw != 0) { LPVOID lpMsgBuf = NULL; FormatMessageW ( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, dw, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&lpMsgBuf, 0, NULL ); prTrace(LogError, "============================================================\n"); prTrace(LogError, "Message : %s\n", (msg && *msg) ? msg : "None"); prTrace(LogError, "Last error: %ls\n", lpMsgBuf); prTrace(LogError, "============================================================\n"); if (lpMsgBuf) { LocalFree(lpMsgBuf); } } PRUNUSED(msg); #else PRUNUSED(msg); #endif }
/// --------------------------------------------------------------------------- /// Starts playing a song. /// --------------------------------------------------------------------------- void prSoundManager::SongPlay(s32 index) { #ifdef SOUND_ALLOW PRASSERT(index >= 0); PRASSERT(index < numTracks); SongPlayByName(pMusicTracks[index]); #else PRUNUSED(index); #endif }
/// --------------------------------------------------------------------------- /// Plays a sound effect. /// --------------------------------------------------------------------------- s32 prSoundManager::SFXPlay(const char *name, f32 volume, bool loop) { s32 handle = -1; #ifdef SOUND_ALLOW PRASSERT(initialised && name && *name); PRASSERT(pLoadedWaves); if (numEffects > 0) { u32 hash = prStringHash(name); for (s32 index = 0 ; index < numEffects; index++) { if (hash == pLoadedWaves[index].hash) { handle = SFXPlay(index, volume, loop); break; } } } if (handle == -1) { prTrace(prLogLevel::LogWarning, "Failed to play effect '%s'\n", name); } #else PRUNUSED(loop); PRUNUSED(volume); PRUNUSED(name); #endif return handle; }
// ---------------------------------------------------------------------------- // Console handler - stops a whole bunch of leaks if the user uses the console // window to close the app. // ---------------------------------------------------------------------------- BOOL HandlerRoutine(DWORD dwCtrlType) { PRUNUSED(dwCtrlType); return TRUE; }
/// --------------------------------------------------------------------------- /// Outputs a string of text to the platforms debug output window. /// --------------------------------------------------------------------------- void prOutputString(prLogLevel level, const char *text) { if (text && *text) { #if defined(PLATFORM_PC) switch(level) { case LogVerbose: if (pConsole) { pConsole->SetConsoleColours(prConsoleWindow::ConsoleColourLightCyan, prConsoleWindow::ConsoleColourBlack); } fprintf(stderr, "%s", text); break; case LogDebug: if (pConsole) { pConsole->SetConsoleColours(prConsoleWindow::ConsoleColourLightWhite, prConsoleWindow::ConsoleColourBlack); } fprintf(stderr, "%s", text); break; case LogInformation: if (pConsole) { pConsole->SetConsoleColours(prConsoleWindow::ConsoleColourLightGreen, prConsoleWindow::ConsoleColourBlack); } fprintf(stderr, "%s", text); break; case LogWarning: if (pConsole) { pConsole->SetConsoleColours(prConsoleWindow::ConsoleColourLightYellow, prConsoleWindow::ConsoleColourBlack); } fprintf(stderr, "%s", text); break; case LogError: if (pConsole) { pConsole->SetConsoleColours(prConsoleWindow::ConsoleColourLightRed, prConsoleWindow::ConsoleColourBlack); } fprintf(stderr, "%s", text); break; } OutputDebugStringA(text); #elif defined(PLATFORM_IOS) PRUNUSED(level); printf("%s", text); #elif defined(PLATFORM_MAC) PRUNUSED(level); printf("%s", text); #elif defined(PLATFORM_LINUX) PRUNUSED(level); printf("%s", text); #elif defined(PLATFORM_ANDROID) switch(level) { case LogVerbose: __android_log_print(ANDROID_LOG_VERBOSE, "Proteus", "%s", text); break; case LogDebug: __android_log_print(ANDROID_LOG_DEBUG, "Proteus", "%s", text); break; case LogInformation: __android_log_print(ANDROID_LOG_INFO, "Proteus", "%s", text); break; case LogWarning: __android_log_print(ANDROID_LOG_WARN, "Proteus", "%s", text); break; case LogError: __android_log_print(ANDROID_LOG_ERROR, "Proteus", "%s", text); break; } #else #error Unsupported platform. #endif } }
/// --------------------------------------------------------------------------- /// Purchase an item. /// --------------------------------------------------------------------------- void prStore_pc::BeginPurchase(const char *id) { PRUNUSED(id); }