Ejemplo n.º 1
0
/// ---------------------------------------------------------------------------
/// Shows a cross platfrom information message dialog
/// ---------------------------------------------------------------------------
void prAlertShowInformation(const char *title, const char *message, prWindow *pWindow)
{
    PRASSERT(title && *title);
    PRASSERT(message && *message);

    char buffer[512];

#if defined(PLATFORM_PC)

    prTrace(LogError, "=======================================================\n");
    prTrace(LogError, "ALERT\n");
    prTrace(LogError, prStringSnprintf(buffer, sizeof(buffer), "Title  : %s\n", title));
    prTrace(LogError, prStringSnprintf(buffer, sizeof(buffer), "Message: %s\n", message));
    prTrace(LogError, "=======================================================\n");

    // Get windows handle
    HWND hwnd = (pWindow == 0) ? HWND_DESKTOP : static_cast<prWindow_PC*>(pWindow)->GetWindowHandle();

    // Create error dialog
    MessageBoxA(hwnd, message, title, MB_OK | MB_ICONEXCLAMATION | MB_TASKMODAL);

#else

    prTrace(LogError, "=======================================================\n");
    prTrace(LogError, "ALERT\n");
    prTrace(LogError, prStringSnprintf(buffer, sizeof(buffer), "Title  : %s\n", title));
    prTrace(LogError, prStringSnprintf(buffer, sizeof(buffer), "Message: %s\n", message));
    prTrace(LogError, "=======================================================\n");

#endif
}
Ejemplo n.º 2
0
/// ---------------------------------------------------------------------------
/// Registers a song list, so we can use play by index.
/// ---------------------------------------------------------------------------
void prSoundManager::LoadSongs(const char **filenames, int count)
{
    PRASSERT(filenames);
    PRASSERT(count > 0);
    pMusicTracks = filenames;
    numTracks    = count;
}
Ejemplo n.º 3
0
/// ---------------------------------------------------------------------------
/// Ctor
/// ---------------------------------------------------------------------------
prBackgroundLayer::prBackgroundLayer(s32 width, s32 height, s32 tileWidth, s32 tileHeight, prTexture *pTexture)
{
    PRASSERT(width > 0);
    PRASSERT(height > 0);
    PRASSERT(tileWidth > 0);
    PRASSERT(tileHeight > 0);
    PRASSERT(pTexture);

    mLayerWidth         = width;
    mLayerHeight        = height;
    mTileWidth          = tileWidth;
    mTileHeight         = tileHeight;
    mMapData            = new s32[width * height];
    mpTexture           = pTexture;
    mWrap               = FALSE;
    mPixelWidth         = 1.0f / pTexture->GetWidth();
    mPixelHeight        = 1.0f / pTexture->GetHeight();
    mTileWidthInPixels  = mPixelWidth * tileWidth;
    mTileHeightInPixels = mPixelHeight * tileHeight;
    
//    m_framesAcross = pTexture->GetWidth()  / frameWidth;
//    m_framesDown   = pTexture->GetHeight() / frameHeight;

    mTilesAcross        = pTexture->GetWidth()  / tileWidth;
    mTilesDown          = pTexture->GetHeight()  / tileWidth;

    prTrace(prLogLevel::LogError, "prBackgroundLayer: Map:(%i, %i), Tile:(%i, %i), Tile count:(%i, %i)\n", width, height, tileWidth, tileHeight, mTilesAcross, mTilesDown);
    prTrace(prLogLevel::LogError, "Map size         : %i\n", sizeof(s32) * (width * height));

    memset(mMapData, -1, sizeof(s32) * (width * height));
}
Ejemplo n.º 4
0
/// ---------------------------------------------------------------------------
/// Attribute parser - Used to get information from the file like the version
///                    number.
/// ---------------------------------------------------------------------------
void prScene::ParseAttribs_File(TiXmlElement* pElement)
{
    PRASSERT(pElement);
    if (pElement)
    {
        PRASSERT(pElement->Attribute("version"));
    }

    // Indicate correct file type.
    //m_correctFileType = true;
}
Ejemplo n.º 5
0
/// ---------------------------------------------------------------------------
/// 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
}
Ejemplo n.º 6
0
/// ---------------------------------------------------------------------------
/// Sets the window to draw to.
/// ---------------------------------------------------------------------------
void prRenderer::SetWindow(prWindow* window)
{
    PRASSERT(window);
    if (window)
    {
        m_pWindow = window;
    }
}
Ejemplo n.º 7
0
    /// ---------------------------------------------------------------------------
    /// Draws the widget
    /// ---------------------------------------------------------------------------
    void prPane::Draw()
    {
        prRenderer *pRenderer = static_cast<prRenderer *>(prCoreGetComponent(PRSYSTEM_RENDERER));
        if (pRenderer)
        {
            // Get the screens details
            prRegistry *pReg = static_cast<prRegistry *>(prCoreGetComponent(PRSYSTEM_REGISTRY));
            PRASSERT(pReg);
            s32 scrnHeight = atoi(pReg->GetValue("ScreenHeight"));

#if defined(PLATFORM_PC)
            glScissor(mXpos, scrnHeight - (mYpos + mHeight), mWidth, mHeight);
            glEnable(GL_SCISSOR_TEST);
#endif

            // Draw pane
            pRenderer->TexturesEnabled(false);
            pRenderer->SetColour(prColour::LiteGray);
            pRenderer->DrawFilledRect((f32)mXpos, (f32)mYpos, (f32)(mXpos + mWidth), (f32)(mYpos + mHeight));
            pRenderer->SetColour(prColour(.85f, .85f, .85f));
            pRenderer->DrawFilledRect((f32)mXpos, (f32)mYpos, (f32)(mXpos + mWidth), (f32)(mYpos + 18));
            pRenderer->TexturesEnabled(true);

			// Draw pane icon if we have one
			s32 xpos = mXpos + 2;				// + 2 == edge gap
			s32 ypos = mYpos + 2;				// + 2 == edge gap

			if (mpPaneIcon)
			{
				mpPaneIcon->pos.x = (f32)xpos;
				mpPaneIcon->pos.y = (f32)ypos;
				mpPaneIcon->Draw();
				xpos += mpPaneIcon->GetFrameWidth();
			}

            // Draw pane title text
			if (m_pBmpfont)
			{
				pRenderer->SetColour(prColour::Black);
				m_pBmpfont->Draw((f32)xpos, (f32)mYpos, mName.Text());
			}

			// Draw default pane icons
			if (mpOptionsIcon)
			{
				mpOptionsIcon->pos.x = (f32)((mXpos + mWidth) - mpOptionsIcon->GetFrameWidth());
				mpOptionsIcon->pos.y = (f32)ypos;
				mpOptionsIcon->Draw();
			}

#if defined(PLATFORM_PC)
            glDisable(GL_SCISSOR_TEST);
#endif
        }
    }
Ejemplo n.º 8
0
/// ---------------------------------------------------------------------------
/// 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;
}
Ejemplo n.º 9
0
/// ---------------------------------------------------------------------------
/// Begins a purchase
/// ---------------------------------------------------------------------------
void prJNI_BeginPurchase(const char *item)
{
    if (item && *item)
    {
        JavaVM *pJavaVM = prJNI_GetVM();
        PRASSERT(pJavaVM);
        if (pJavaVM)
        {
            bool    isAttached  = false;
            JNIEnv *env         = NULL;

            // Get environment.
            if (!prJNI_GetEnv(&env, isAttached))
                return;

            // Find class
            jclass cls = prJNI_GetTheClass(env, "InAppPurchase", isAttached);
            if (!cls)
                return;
        
            // Find the callBack method ID
            jmethodID method = env->GetStaticMethodID(cls, "beginPurchase", "(Ljava/lang/String;)V");
            if (!method)
            {
                __android_log_print(ANDROID_LOG_ERROR, "Proteus", "Failed to get method ID %s", "beginPurchase");
                if (isAttached)
                {
                    pJavaVM->DetachCurrentThread();
                }
                return;
            }

            // Construct a Java string.
            jstring js = env->NewStringUTF(item);
            env->CallStaticVoidMethod(cls, method, js);

            // And done
            if (isAttached)
            {
                pJavaVM->DetachCurrentThread();
            }
        }
    }
}
Ejemplo n.º 10
0
/// ---------------------------------------------------------------------------
/// Plays a song.
/// ---------------------------------------------------------------------------
void prJNI_SongPlay(const char *filename)
{
    JavaVM *pJavaVM = prJNI_GetVM();
    PRASSERT(pJavaVM);
    if (pJavaVM)
    {
        bool    isAttached  = false;
        JNIEnv *env         = NULL;

        // Get environment.
        if (!prJNI_GetEnv(&env, isAttached))
            return;

        // Find class
        jclass cls = prJNI_GetAudioClass(env, "Music", isAttached);
        if (!cls)
            return;
        
        // Find the callBack method ID
        jmethodID method = env->GetStaticMethodID(cls, "songPlay", "(Ljava/lang/String;)V");
        if (!method)
        {
            prTrace(LogError, "Failed to get method ID %s", "songPlay");
            if (isAttached)
            {
                pJavaVM->DetachCurrentThread();
            }
            return;
        }

        // Construct a Java string.
        jstring js = env->NewStringUTF(filename);
        env->CallStaticVoidMethod(cls, method, js);

        // And done
        if (isAttached)
        {
            pJavaVM->DetachCurrentThread();
        }
    }
}
Ejemplo n.º 11
0
/// ---------------------------------------------------------------------------
/// Opens a facebook session
/// ---------------------------------------------------------------------------
void prJNI_FacebookOpenSession()
{
    JavaVM *pJavaVM = prJNI_GetVM();
    PRASSERT(pJavaVM);
    if (pJavaVM)
    {
        bool    isAttached  = false;
        JNIEnv *env         = NULL;

        // Get environment.
        if (!prJNI_GetEnv(&env, isAttached))
            return;

        // Find class
        jclass cls = prJNI_GetFacebookClass(env, "Facebook", isAttached);
        if (!cls)
            return;
        
        // Find the callBack method ID
        jmethodID method = env->GetStaticMethodID(cls, "openSession", "()V");
        if (!method)
        {
            __android_log_print(ANDROID_LOG_ERROR, "Proteus", "Failed to get method ID %s", "openSession");
            if (isAttached)
            {
                pJavaVM->DetachCurrentThread();
            }
            return;
        }

        // Call.
        env->CallStaticVoidMethod(cls, method);

        // And done
        if (isAttached)
        {
            pJavaVM->DetachCurrentThread();
        }
    }
}
Ejemplo n.º 12
0
/// ---------------------------------------------------------------------------
/// Resumes playing the current song.
/// ---------------------------------------------------------------------------
void prJNI_SongResume()
{
    JavaVM *pJavaVM = prJNI_GetVM();
    PRASSERT(pJavaVM);
    if (pJavaVM)
    {
        bool    isAttached  = false;
        JNIEnv *env         = NULL;

        // Get environment.
        if (!prJNI_GetEnv(&env, isAttached))
            return;

        // Find class
        jclass cls = prJNI_GetAudioClass(env, "Music", isAttached);
        if (!cls)
            return;
        
        // Find the callBack method ID
        jmethodID method = env->GetStaticMethodID(cls, "songResume", "()V");
        if (!method)
        {
            prTrace(LogError, "Failed to get method ID %s", "songResume");
            if (isAttached)
            {
                pJavaVM->DetachCurrentThread();
            }
            return;
        }

        // Call.
        env->CallStaticVoidMethod(cls, method);

        // And done
        if (isAttached)
        {
            pJavaVM->DetachCurrentThread();
        }
    }
}
Ejemplo n.º 13
0
/// ---------------------------------------------------------------------------
/// Constructor.
/// ---------------------------------------------------------------------------
prConsoleWindow::prConsoleWindow(const char *name, int width, int height)
{
    PRASSERT(name && *name);

    scrbuf  = INVALID_HANDLE_VALUE;
    fstdin  = 0;
    fstderr = 0;
    fstdout = 0;


    // Allocate
    if (AllocConsole() == 0)
    {
        prDebugShowLastError(PRFILE_LINE);
        return;
    }

    if (SetConsoleCtrlHandler((PHANDLER_ROUTINE)HandlerRoutine, true) == 0)
    {
        prDebugShowLastError(PRFILE_LINE);
        return;
    }


    // Create
    SetConsoleTitleA(name);

    scrbuf = CreateConsoleScreenBuffer
    (
        GENERIC_READ | GENERIC_WRITE,
        FILE_SHARE_READ | FILE_SHARE_WRITE,
        NULL,
        CONSOLE_TEXTMODE_BUFFER,
        NULL
    );

    if (scrbuf == INVALID_HANDLE_VALUE)
    {
        prDebugShowLastError(PRFILE_LINE);
        FreeConsole();
        return;
    }


    // Set active
    if (SetConsoleActiveScreenBuffer(scrbuf) == 0)
    {
        prDebugShowLastError(PRFILE_LINE);
        FreeConsole();
        return;
    }


    // Set console size.
    if (width < GetSystemMetrics(SM_CXMIN))
    {
        width = GetSystemMetrics(SM_CXMIN);
    }

    if (height < GetSystemMetrics(SM_CYMIN))
    {
        height = GetSystemMetrics(SM_CYMIN);
    }

    mConsoleWidth   = width;
    mConsoleHeight  = height;

    COORD coord;
    coord.X = (SHORT)width;
    coord.Y = (SHORT)height;

    if (SetConsoleScreenBufferSize(scrbuf, coord) == 0)
    {
        prDebugShowLastError(PRFILE_LINE);
        FreeConsole();
        return;
    }


    // Redirect input/output.
    fstdin  = freopen("CONIN$",  "rt", stdin);
    fstderr = freopen("CONOUT$", "wt", stderr);
    fstdout = freopen("CONOUT$", "wt", stdout);
}
Ejemplo n.º 14
0
// ----------------------------------------------------------------------------
// Operator [] - Array access.
// ----------------------------------------------------------------------------
char& prString::operator [] (unsigned int index)
{
    PRASSERT(index < (unsigned int)m_length);
    return m_buffer[index];
}