Exemple #1
0
void SimplePopup::Render()
{
    mClosed = false;
    float modX = (SCREEN_WIDTH_F / 2)-5;

    JRenderer *r = JRenderer::GetInstance();
    string detailedInformation = getDetailedInformation(mDeckInformation->getFilename());
#if !defined (PSP)
    
    JQuadPtr statsholder = WResourceManager::Instance()->RetrieveTempQuad("statsholder.png");//new graphics statsholder
    //const float textHeight = mTextFont->GetHeight() * mMaxLines;
    //r->FillRect(0,0,SCREEN_WIDTH_F,SCREEN_HEIGHT_F,ARGB(220,15,15,15));
    if(statsholder.get())
        r->RenderQuad(statsholder.get(),0,0,0,SCREEN_WIDTH_F/statsholder->mWidth,SCREEN_HEIGHT_F/statsholder->mHeight);
#endif
    r->FillRoundRect(mX+modX+3, mY + 7, 190.f, 148.f, 0, ARGB( 240, 15, 15, 15 ) );

    // currently causes a crash on the PSP when drawing the corners.
    // TODO: clean up the image ot make it loook cleaner. Find solution to load gfx to not crash PSP
#if 0
    r->DrawRoundRect(mX, mY + 2, mWidth + 11, textHeight - 12, 2.0f, ARGB( 255, 125, 255, 0) );
    drawBoundingBox( mX-3, mY, mWidth + 3, textHeight );
#endif
    mTextFont->DrawString(detailedInformation.c_str(), modX+mX + 9 , mY + 15);

}
Exemple #2
0
void PutInGraveyard::Render()
{
    WFont * mFont = observer->getResourceManager()->GetWFont(Fonts::MAIN_FONT);
    mFont->SetBase(0);
    mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
    if (!removeFromGame)
    {
        mFont->DrawString(_("goes to graveyard").c_str(), x + 30, y, JGETEXT_LEFT);
    }
    else
    {
        mFont->DrawString(_("is exiled").c_str(), x + 30, y, JGETEXT_LEFT);
    }
    JRenderer * renderer = JRenderer::GetInstance();
    JQuadPtr quad = observer->getResourceManager()->RetrieveCard(card, CACHE_THUMB);
    if (quad.get())
    {
        quad->SetColor(ARGB(255,255,255,255));
        float scale = 30 / quad->mHeight;
        renderer->RenderQuad(quad.get(), x, y, 0, scale, scale);
    }
    else
    {
        mFont->DrawString(_(card->name).c_str(), x, y - 15);
    }
}
JQuadPtr ResourceManagerImpl::RetrieveQuad(const string& filename, float offX, float offY, float width, float height, string resname,
        int style, int submode, int id)
{
    //Lookup managed resources, but only with a real resname.
    if (resname.size() && (style == RETRIEVE_MANAGE || style == RETRIEVE_RESOURCE))
    {
        JQuadPtr quad = GetQuad(resname);
        if (quad.get() || style == RETRIEVE_RESOURCE) return quad;
    }

    //Aliases.
    if (style == RETRIEVE_THUMB)
    {
        submode = submode | TEXTURE_SUB_THUMB;
        style = RETRIEVE_NORMAL;
    }

    //Resname defaults to filename.
    if (!resname.size()) resname = filename;

    //No quad, but we have a managed texture for this!
    WCachedTexture* jtex = textureWCache.Retrieve(id, filename, style, submode);

    lastError = textureWCache.mError;

    //Somehow, jtex wasn't promoted.
    if (style == RETRIEVE_MANAGE && jtex && !jtex->isPermanent()) return JQuadPtr();

    //Make this quad, overwriting any similarly resname'd quads.
    if (jtex)
    {
        JQuadPtr quad = jtex->GetQuad(offX, offY, width, height, resname);

        if (!quad.get())
            return quad;

        if (style == RETRIEVE_MANAGE && resname != "")
        {
            WManagedQuad mq;
            mq.resname = resname;
            mq.texture = jtex;
            AddQuadToManaged(mq);
        }

        if (style == RETRIEVE_LOCK)
            jtex->lock();
        else if (style == RETRIEVE_UNLOCK)
            jtex->unlock();
        else if (style == RETRIEVE_MANAGE) jtex->deadbolt();

        return quad;
    }

    //Texture doesn't exist, so no quad.
    return JQuadPtr();
}
Exemple #4
0
void Damage::Render()
{
    WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT);
    mFont->SetBase(0);
    mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
    char buffer[200];
    sprintf(buffer, _("Deals %i damage to").c_str(), damage);
    //mFont->DrawString(buffer, x + 20, y, JGETEXT_LEFT);
    mFont->DrawString(buffer, x + 32, y + GetVerticalTextOffset(), JGETEXT_LEFT);
    JRenderer * renderer = JRenderer::GetInstance();
    JQuadPtr quad = WResourceManager::Instance()->RetrieveCard(source, CACHE_THUMB);
    if (quad.get())
    {
        //float scale = 30 / quad->mHeight;
        //renderer->RenderQuad(quad.get(), x, y, 0, scale, scale);
        quad->SetColor(ARGB(255,255,255,255));
        float scale = mHeight / quad->mHeight;
        renderer->RenderQuad(quad.get(), x + (quad->mWidth * scale / 2), y + (quad->mHeight * scale / 2), 0, scale, scale);
    }
    else
    {
        //mFont->DrawString(_(source->getName()).c_str(), x, y - 15);
        mFont->DrawString(_(source->getName()).c_str(), x, y + GetVerticalTextOffset() - 15);
    }
    quad = target->getIcon();
    if (quad.get())
    {
        //float scale = 30 / quad->mHeight;
        //renderer->RenderQuad(quad.get(), x + 150, y, 0, scale, scale);
        float backupX = quad->mHotSpotX;
        float backupY = quad->mHotSpotY;
        quad->SetColor(ARGB(255,255,255,255));
        quad->SetHotSpot(quad->mWidth / 2, quad->mHeight / 2);
        float scale = mHeight / quad->mHeight;
        renderer->RenderQuad(quad.get(), x + 130, y - 0.5f + ((mHeight - quad->mHeight) / 2) + quad->mHotSpotY, 0, scale, scale);
        quad->SetHotSpot(backupX, backupY);
    }
    else
    {
        //if (target->type_as_damageable == Damageable::DAMAGEABLE_MTGCARDINSTANCE)
            //mFont->DrawString(_(((MTGCardInstance *) target)->getName()).c_str(), x + 120, y);
        if (target->type_as_damageable == Damageable::DAMAGEABLE_MTGCARDINSTANCE)
            mFont->DrawString(_(((MTGCardInstance *) target)->getName()).c_str(), x + 35, y+15 + GetVerticalTextOffset());
        else if(target->type_as_damageable == Damageable::DAMAGEABLE_PLAYER)
            mFont->DrawString(_(((Player *) target)->getDisplayName()).c_str(), x + 35, y+15 + GetVerticalTextOffset());
    }

}
int ResourceManagerImpl::CreateQuad(const string &quadName, const string &textureName, float x, float y, float width, float height)
{
    if (!quadName.size() || !textureName.size()) return INVALID_ID;

    if (GetQuad(quadName) != NULL)
    {
        assert(false);
        return ALREADY_EXISTS;
    }

    WCachedTexture * jtex = textureWCache.Retrieve(0, textureName, RETRIEVE_MANAGE);
    lastError = textureWCache.mError;
    int id = INVALID_ID;
    //Somehow, jtex wasn't promoted.
    if (RETRIEVE_MANAGE && jtex && !jtex->isPermanent()) return id;

    if (jtex)
    {
        JQuadPtr quad = jtex->GetQuad(x, y, width, height, quadName);

        if (quad.get())
        {
            jtex->deadbolt();

            WManagedQuad mq;
            mq.resname = quadName;
            mq.texture = jtex;
            id = AddQuadToManaged(mq);
        }
    }

    assert(id != INVALID_ID);
    return id;
}
Exemple #6
0
void StackAbility::Render()
{
    string action = ability->getMenuText();
    MTGCardInstance * source = ability->source;
    string alt1 = source->getName();

    Targetable * _target = ability->target;
    if (ability->getActionTc())
    {
        Targetable * t = ability->getActionTc()->getNextTarget();
        if (t)
            _target = t;
    }
    Damageable * target = NULL;
    if (_target != ability->source && (dynamic_cast<MTGCardInstance *>(_target) || dynamic_cast<Player *>(_target)))
    {
        target = (Damageable *) _target;
    }

    JQuadPtr quad;
    string alt2 = "";
    if (target)
    {
        quad = target->getIcon();
        if (target->type_as_damageable == Damageable::DAMAGEABLE_MTGCARDINSTANCE)
        {
            alt2 = ((MTGCardInstance *) target)->name;
        }
    }

    Interruptible::Render(source, quad.get(), alt1, alt2, action);
}
Exemple #7
0
void OptionProfile::Render()
{
    JRenderer * renderer = JRenderer::GetInstance();
    WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::OPTION_FONT);
    mFont->SetScale(1);
    int spacing = 2 + (int) mFont->GetHeight();

    float pX, pY;
    pX = x;
    pY = y;
    char buf[512];
    if (selections[value] == "Default")
        sprintf(buf, "player/avatar.jpg");
    else
        sprintf(buf, "profiles/%s/avatar.jpg", selections[value].c_str());
    string filename = buf;
    JQuadPtr avatar = WResourceManager::Instance()->RetrieveTempQuad(filename, TEXTURE_SUB_EXACT);

    if (avatar)
    {
        renderer->RenderQuad(avatar.get(), x, pY);
        pX += 40;
    }

    mFont->SetColor(getColor(WGuiColor::TEXT_HEADER));
    mFont->DrawString(selections[value].c_str(), pX, pY + 2, JGETEXT_LEFT);
    mFont->SetScale(0.8f);
    mFont->SetColor(getColor(WGuiColor::TEXT_BODY));
    mFont->DrawString(preview.c_str(), pX, pY + spacing + 2, JGETEXT_LEFT);
    mFont->SetScale(1.0f);

}
Exemple #8
0
JQuadPtr WCachedTexture::GetCard(float offX, float offY, float width, float height, const string& resname)
{
    JQuadPtr jq = GetQuad(offX, offY, width, height, resname);
    if (jq.get())
        jq->SetHotSpot(static_cast<float> (jq->mTex->mWidth / 2), static_cast<float> (jq->mTex->mHeight / 2));

    return jq;
}
Exemple #9
0
void GuiBackground::Render()
{
    JRenderer* renderer = JRenderer::GetInstance();
    JQuadPtr quad;
    if (observer && observer->mRules && observer->mRules->bg.size())
    {
        quad = WResourceManager::Instance()->RetrieveTempQuad(observer->mRules->bg);
    }
    if (!quad.get())
    {
        quad = WResourceManager::Instance()->RetrieveTempQuad(kBackdropFile);
    }
    if (quad.get())
    {
        renderer->RenderQuad(quad.get(), 0, 18);
    }
}
Exemple #10
0
void Interruptible::Render(MTGCardInstance * source, JQuad * targetQuad, string alt1, string alt2, string action,
    bool bigQuad)
{
    WFont * mFont = observer->getResourceManager()->GetWFont(Fonts::MAIN_FONT);
    mFont->SetColor(ARGB(255,255,255,255));
    mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);

    mFont->DrawString(_(action).c_str(), x + 35, y + GetVerticalTextOffset(), JGETEXT_LEFT);
    JRenderer * renderer = JRenderer::GetInstance();
    JQuadPtr quad = observer->getResourceManager()->RetrieveCard(source, CACHE_THUMB);
    if (!quad.get())
        quad = CardGui::AlternateThumbQuad(source);
    if (quad.get())
    {
        quad->SetColor(ARGB(255,255,255,255));
        float scale = mHeight / quad->mHeight;
        renderer->RenderQuad(quad.get(), x + (quad->mWidth * scale / 2), y + (quad->mHeight * scale / 2), 0, scale, scale);
    }
    else if (alt1.size())
    {
        mFont->DrawString(_(alt1).c_str(), x, y + GetVerticalTextOffset());
    }

    if (bigQuad)
    {
        Pos pos = Pos(CardGui::BigWidth / 2, CardGui::BigHeight / 2 - 10, 1.0, 0.0, 220);
        CardGui::DrawCard(source, pos, observer->getCardSelector()->GetDrawMode());
    }

    if (targetQuad)
    {
        float backupX = targetQuad->mHotSpotX;
        float backupY = targetQuad->mHotSpotY;
        targetQuad->SetColor(ARGB(255,255,255,255));
        targetQuad->SetHotSpot(targetQuad->mWidth / 2, targetQuad->mHeight / 2);
        float scale = mHeight / targetQuad->mHeight;
        renderer->RenderQuad(targetQuad, x + 150, y + ((mHeight - targetQuad->mHeight) / 2) + targetQuad->mHotSpotY, 0, scale, scale);
        targetQuad->SetHotSpot(backupX, backupY);
    }
    else if (alt2.size())
    {
        mFont->DrawString(_(alt2).c_str(), x + 120, y + GetVerticalTextOffset());
    }
}
Exemple #11
0
void DeckMenu::RenderBackground()
{
    ostringstream bgFilename;
    bgFilename << backgroundName << ".png";

    static bool loadBackground = true;
    if (loadBackground)
    {
        //Erwan 2010/07/11 the TEXTURE_SUB_5551 below is useless, JGE doesn't support it for png. I'm letting it here to avoid causing a bug, but it should be removed
        JQuadPtr background = WResourceManager::Instance()->RetrieveTempQuad(bgFilename.str(), TEXTURE_SUB_5551);
        if (background.get())
        {
            float scaleX = SCREEN_WIDTH_F / background.get()->mWidth;
            float scaleY = SCREEN_HEIGHT_F / background.get()->mHeight;
            JRenderer::GetInstance()->RenderQuad(background.get(), 0, 0,0,scaleX, scaleY);
        }
        else
            loadBackground = false;
    }
}
Exemple #12
0
// drawing routines
void SimplePopup::drawCorner(string imageName, bool flipX, bool flipY, float x, float y)
{
    LOG(" Drawing a Corner! ");
    JRenderer* r = JRenderer::GetInstance();
    JQuadPtr horizontalBarImage = WResourceManager::Instance()->RetrieveTempQuad( imageName, TEXTURE_SUB_5551);
    horizontalBarImage->SetHFlip(flipX);
    horizontalBarImage->SetVFlip(flipY);

    r->RenderQuad(horizontalBarImage.get(), x, y);
    LOG(" Done Drawing a Corner! ");
}
Exemple #13
0
void GuiGameZone::Render()
{
    //Texture
    JQuadPtr quad = WResourceManager::Instance()->GetQuad(kGenericCardThumbnailID);
    float scale = defaultHeight / quad->mHeight;
    quad->SetColor(ARGB((int)(actA),255,255,255));
    if(type == GUI_EXILE)
    {
        quad->SetColor(ARGB((int)(actA),255,240,255));
    }
    JRenderer::GetInstance()->RenderQuad(quad.get(), actX, actY, 0.0, scale * actZ, scale * actZ);

    float x0 = actX;
    if (x0 < SCREEN_WIDTH / 2)
    {
        x0 += 7;
    }

    if (mHasFocus)
        JRenderer::GetInstance()->FillRect(actX, actY, quad->mWidth * scale * actZ, quad->mHeight * scale * actZ,
                ARGB(abs(128 - wave),255,255,255));

    //Number of cards
    WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT);
    mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
    char buffer[11];
    int mAlpha = (int) (actA);
    /*if(type == GUI_GRAVEYARD)
        sprintf(buffer, "%i\ng", zone->nb_cards);
    else if(type == GUI_LIBRARY)
        sprintf(buffer, "%i\nl", zone->nb_cards);
    else if(type == GUI_OPPONENTHAND)
        sprintf(buffer, "%i\nh", zone->nb_cards);
    else if(type == GUI_EXILE)
        sprintf(buffer, "%i\ne", zone->nb_cards);
    else*/
        sprintf(buffer, "%i", zone->nb_cards);
    mFont->SetColor(ARGB(mAlpha,0,0,0));
    mFont->DrawString(buffer, x0 + 1, actY + 1);
    if (actA > 120)
        mAlpha = 255;
    mFont->SetColor(ARGB(mAlpha,255,255,255));
    mFont->DrawString(buffer, x0, actY);

    if (showCards)
        cd->Render();
    for (vector<CardView*>::iterator it = cards.begin(); it != cards.end(); ++it)
        (*it)->Render();
    PlayGuiObject::Render();
}
Exemple #14
0
void GameStateAwards::Render()
{
    JRenderer * r = JRenderer::GetInstance();
    r->ClearScreen(ARGB(0,0,0,0));

    JQuadPtr background = WResourceManager::Instance()->RetrieveTempQuad("awardback.jpg", TEXTURE_SUB_5551);
    if (background.get())
        r->RenderQuad(background.get(), 0, 0);

    switch (mState)
    {
    case STATE_LISTVIEW:
        if (listview)
            listview->Render();
        break;
    case STATE_DETAILS:
        if (detailview)
            detailview->Render();
        break;
    }

    if (showMenu && menu)
        menu->Render();
}
Exemple #15
0
void OptionTheme::Render()
{
    JRenderer * renderer = JRenderer::GetInstance();
    char buf[512];
    if (!bChecked)
    {
        author = "";
        bChecked = true;
        if (selections[value] == "Default")
            sprintf(buf, "%s", "graphics/themeinfo.txt");
        else
            sprintf(buf, "themes/%s/themeinfo.txt", selections[value].c_str());
        string contents;
        if (JFileSystem::GetInstance()->readIntoString(buf, contents))
        {
            std::stringstream stream(contents);
            string temp;
            std::getline(stream, temp);
            for (unsigned int x = 0; x < 17 && x < temp.size(); x++)
            {
                if (isprint(temp[x])) //Clear stuff that breaks mFont->DrawString, cuts to 16 chars.
                    author += temp[x];
            }
        }
    }
    sprintf(buf, _("Theme: %s").c_str(), selections[value].c_str());

    JQuadPtr q = getImage();
    if (q)
    {
        float scale = 128 / q->mHeight;
        renderer->RenderQuad(q.get(), x, y, 0, scale, scale);
    }

    WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::OPTION_FONT);
    mFont->SetColor(getColor(WGuiColor::TEXT_HEADER));
    mFont->DrawString(buf, x + 2, y + 2);
    if (bChecked && author.size())
    {
        mFont->SetColor(getColor(WGuiColor::TEXT_BODY));
        mFont->SetScale(0.8f);
        float hi = mFont->GetHeight();
        sprintf(buf, _("Artist: %s").c_str(), author.c_str());
        mFont->DrawString(buf, x + 2, y + getHeight() - hi);
        mFont->SetScale(1);
    }
}
Exemple #16
0
void SimplePopup::drawVertPole(string imageName, bool flipX = false, bool flipY = false, float x = 0, float y = 0, float height = SCREEN_HEIGHT_F)
{
    LOG(" Drawing a Vertical border! ");
    JRenderer* r = JRenderer::GetInstance();
    JQuadPtr verticalBarImage = WResourceManager::Instance()->RetrieveTempQuad( imageName, TEXTURE_SUB_5551);
    if ( verticalBarImage != NULL )
    {
        verticalBarImage->SetHFlip(flipX);
        verticalBarImage->SetVFlip(flipY);

        r->RenderQuad(verticalBarImage.get(), x, y, 0, 1.0f, height);
    }
    else
    {
        LOG ( "ERROR: Error trying to render vertical edge! ");
    }
    LOG(" DONE Drawing a horizontal border! ");
}
Exemple #17
0
void SimplePopup::drawHorzPole(string imageName, bool flipX = false, bool flipY = false, float x = 0, float y = 0, float width = SCREEN_WIDTH_F)
{
    LOG(" Drawing a horizontal border! ");
    JRenderer* r = JRenderer::GetInstance();
    JQuadPtr horizontalBarImage = WResourceManager::Instance()->RetrieveTempQuad( imageName, TEXTURE_SUB_5551);
    if ( horizontalBarImage != NULL )
    {
    horizontalBarImage->SetHFlip(flipX);
    horizontalBarImage->SetVFlip(flipY);

    r->RenderQuad(horizontalBarImage.get(), x, y, 0, width);
    }
    else
    {
        LOG ( "ERROR: Error trying to render horizontal edge! ");
    }
    LOG(" Done Drawing a horizontal border! ");
}
Exemple #18
0
void Spell::Render()
{
    string action = source->getName();
    string alt1 = "";

    string alt2 = "";
    Damageable * target = getNextDamageableTarget();
    JQuadPtr quad;
    if (target)
    {
        quad = target->getIcon();
        if (target->type_as_damageable == Damageable::DAMAGEABLE_MTGCARDINSTANCE)
        {
            alt2 = ((MTGCardInstance *) target)->name;
        }
    }
    Interruptible::Render(source, quad.get(), alt1, alt2, action, true);
}
Exemple #19
0
GuiPhaseBar::GuiPhaseBar(DuelLayers* duelLayers) :
    GuiLayer(duelLayers->getObserver()), PlayGuiObject(80, 0, 106, 0, false),
    displayedPhaseId(0), angle(0.0f), zoomFactor(zoom_small), angleEasing(angle),
    zoomFactorEasing(zoomFactor), mpDuelLayers(duelLayers)
{
    if(duelLayers->getObserver()->getResourceManager())
    {
        JQuadPtr quad = WResourceManager::Instance()->GetQuad("phasebar");
        if (quad.get() != NULL)
        {
            quad->mHeight = kHeight;
            quad->mWidth = kWidth;
        }
        else
            GameApp::systemError = "Error loading phasebar texture : " __FILE__;
    }

    mpDuelLayers->getCardSelector()->Add(this);
}
Exemple #20
0
void DeckMenu::Render()
{
    JRenderer * renderer = JRenderer::GetInstance();
    float height = mHeight;

    if (!menuInitialized)
    {
        initMenuItems();
        stars->Fire();
        timeOpen = 0;
        menuInitialized = true;
    }
    
    if (timeOpen < 1) height *= timeOpen > 0 ? timeOpen : -timeOpen;
    
    for (int i = startId; i < startId + maxItems; i++)
    {
        if (i > mCount - 1) break;        
        DeckMenuItem *currentMenuItem = static_cast<DeckMenuItem*> (mObjects[i]);
        if (currentMenuItem->getY() - DeckMenuConst::kLineHeight * startId < mY + height - DeckMenuConst::kLineHeight + 7)
        {
            // only load stats for visible items in the list
			DeckMetaData* metaData = currentMenuItem->getMetaData();
            if (metaData && !metaData->mStatsLoaded)
            {
                metaData->LoadStats();
			}

            if (currentMenuItem->hasFocus())
            {
                mSelectedDeck = metaData;
                WFont *descriptionFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT);

                // display the "more info" button if special condition is met
                if (showDetailsScreen())
                {                    
                    dismissButton->setIsSelectionValid(true);
                    dismissButton->Render();
                }
                else
                {
                    dismissButton->setIsSelectionValid(false);
                }
                // display the avatar image
                string currentAvatarImageName = currentMenuItem->getImageFilename();
                if (currentAvatarImageName.size() > 0)
                {
                    JQuadPtr quad = WResourceManager::Instance()->RetrieveTempQuad(currentAvatarImageName, TEXTURE_SUB_AVATAR);
                    if(quad.get())
                    {
                        quad->mWidth = 35.f;
                        quad->mHeight = 50.f;
                        if (currentMenuItem->getText() == "Evil Twin")
                        {
                            JQuad * evil = quad.get();
                            evil->SetHFlip(true);
                            renderer->RenderQuad(quad.get(), avatarX, avatarY);
                            evil = NULL;
                        }
                        else
                            renderer->RenderQuad(quad.get(), avatarX, avatarY);
                    }
                }
                
                // fill in the description part of the screen
				string text = wordWrap(_(currentMenuItem->getDescription()), descWidth, descriptionFont->mFontID );
                descriptionFont->SetColor(ARGB(255,255,255,255));
                descriptionFont->DrawString(text.c_str(), descX, descY);
                
                // fill in the statistical portion
                if (currentMenuItem->hasMetaData())
                {
                    ostringstream oss;
                    oss << _("Deck: ") << currentMenuItem->getDeckName() << endl;
                    oss << currentMenuItem->getDeckStatsSummary();
                    descriptionFont->SetColor(ARGB(255,255,255,255));
                    descriptionFont->DrawString(oss.str(), statsX, statsY);
                }
                
                // change the font color of the current menu item
                mFont->SetColor(ARGB(255,255,255,255));
            }
            else // reset the font color to be slightly muted
                mFont->SetColor(ARGB(150,255,255,255));
            currentMenuItem->RenderWithOffset(-DeckMenuConst::kLineHeight * startId);
        }
    }
    
	if (!title.empty())
    {
        mFont->SetColor(ARGB(255,255,255,255));
        mFont->DrawString(title.c_str(), titleX, titleY, JGETEXT_CENTER);
    }

    mScroller->Render();
	RenderBackground();
    RenderDeckManaColors();
    
    renderer->SetTexBlend(BLEND_SRC_ALPHA, BLEND_ONE);
	stars->Render();
	renderer->SetTexBlend(BLEND_SRC_ALPHA, BLEND_ONE_MINUS_SRC_ALPHA);

}
Exemple #21
0
void GameApp::Create()
{
    srand((unsigned int) time(0)); // initialize random
#if !defined(QT_CONFIG) && !defined(IOS)
#if defined (WIN32)
    _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
#elif defined (PSP)
    pspFpuSetEnable(0); //disable FPU Exceptions until we find where the FPU errors come from
    pspDebugScreenPrintf("Wagic:Loading resources...");
#endif
#endif //QT_CONFIG
    //_CrtSetBreakAlloc(368);
    LOG("starting Game");

    string systemFolder = "Res/";
    string foldersRoot = "";

    //Find the Res folder
    ifstream mfile("Res.txt");
    string resPath;
    if (mfile)
    {
        bool found = false;
        while (!found && std::getline(mfile, resPath))
        {
            if (resPath[resPath.size() - 1] == '\r')
                resPath.erase(resPath.size() - 1); //Handle DOS files
            string testfile = resPath + systemFolder;
            testfile.append("graphics/simon.dat");
            ifstream tempfile(testfile.c_str());
            if (tempfile)
            {
                found = true;
                tempfile.close();
                foldersRoot = resPath;
            }
        }
        mfile.close();
    }
    LOG("init Res Folder at " + foldersRoot);
    JFileSystem::init(foldersRoot + "User/", foldersRoot + systemFolder);

    
    // Create User Folders (for write access) if they don't exist
    {
        const char* folders[] = { "ai", "ai/baka", "ai/baka/stats", "campaigns", "graphics", "lang", "packs", "player", "player/stats", "profiles", "rules", "sets", "settings", "sound", "sound/sfx", "themes", "test"};

        for (size_t i = 0; i < sizeof(folders)/sizeof(folders[0]); ++i)
        {
            JFileSystem::GetInstance()->MakeDir(string(folders[i]));
        }
    }

    LOG("Loading Modrules");
    //Load Mod Rules before everything else
    gModRules.load("rules/modrules.xml");

    LOG("Loading Unlockables");
    //Load awards (needs to be loaded before any option are accessed)
    Unlockable::load();

    //Link this to our settings manager.
    options.theGame = this;

    //Ensure that options are partially loaded before loading files.
    LOG("options.reloadProfile()");
    options.reloadProfile();


    //Setup Cache before calling any gfx/sfx functions
	WResourceManager::Instance()->ResetCacheLimits();


    LOG("Checking for music files");
    //Test for Music files presence
    JFileSystem * jfs = JFileSystem::GetInstance();
    HasMusic = jfs->FileExists(WResourceManager::Instance()->musicFile("Track0.mp3")) && jfs->FileExists(WResourceManager::Instance()->musicFile("Track1.mp3"));
    
    LOG("Init Collection");
    MTGAllCards::getInstance();

    LOG("Loading rules");
    Rules::loadAllRules();


    LOG("Loading Textures");
    LOG("--Loading menuicons.png");
    WResourceManager::Instance()->RetrieveTexture("menuicons.png", RETRIEVE_MANAGE);
#if !defined (PSP)
    WResourceManager::Instance()->RetrieveTexture("miconslarge.png", RETRIEVE_MANAGE);
#endif
    LOG("---Gettings menuicons.png quads");
   
    //Load all icons from gModRules and save in manaIcons -> todo. Change the icons positions on menuicons.png to avoid use item->mColorId
    vector<ModRulesBackGroundCardGuiItem *>items = gModRules.cardgui.background;
    for(size_t i= 0; i < items.size(); i ++)
    {
        
        ModRulesBackGroundCardGuiItem * item = items[i];
        if (item->mMenuIcon == 1)
        {
            manaIcons.push_back(WResourceManager::Instance()->RetrieveQuad("menuicons.png", 2 + (float)item->mColorId * 36, 38, 32, 32, "c_" + item->MColorName, RETRIEVE_MANAGE));
            Constants::MTGColorStrings.push_back(item->MColorName.c_str());
        }
    }
    Constants::NB_Colors = (int)Constants::MTGColorStrings.size();
    
    items.erase(items.begin(),items.end());
    

    for (int i = manaIcons.size()-1; i >= 0; --i)
        if (manaIcons[i].get())
            manaIcons[i]->SetHotSpot(16, 16);

    LOG("--Loading back.jpg");
    WResourceManager::Instance()->RetrieveTexture("back.jpg", RETRIEVE_MANAGE);
    JQuadPtr jq = WResourceManager::Instance()->RetrieveQuad("back.jpg", 0, 0, 0, 0, kGenericCardID, RETRIEVE_MANAGE);
    if (jq.get())
        jq->SetHotSpot(jq->mWidth / 2, jq->mHeight / 2);

    WResourceManager::Instance()->RetrieveTexture("back_thumb.jpg", RETRIEVE_MANAGE);
    WResourceManager::Instance()->RetrieveQuad("back_thumb.jpg", 0, 0, MTG_MINIIMAGE_WIDTH, MTG_MINIIMAGE_HEIGHT, kGenericCardThumbnailID, RETRIEVE_MANAGE);

    LOG("--Loading particles.png");
    WResourceManager::Instance()->RetrieveTexture("particles.png", RETRIEVE_MANAGE);
    jq = WResourceManager::Instance()->RetrieveQuad("particles.png", 0, 0, 32, 32, "particles", RETRIEVE_MANAGE);
    if (jq)
        jq->SetHotSpot(16, 16);
    jq = WResourceManager::Instance()->RetrieveQuad("particles.png", 64, 0, 32, 32, "stars", RETRIEVE_MANAGE);
    if (jq)
        jq->SetHotSpot(16, 16);

    LOG("--Loading fonts");
    string lang = options[Options::LANG].str;
    std::transform(lang.begin(), lang.end(), lang.begin(), ::tolower);
    WResourceManager::Instance()->InitFonts(lang);
    Translator::GetInstance()->init();
    // The translator is ready now.

    LOG("--Loading various textures");
    // Load in this function only textures that are used frequently throughout the game. These textures will constantly stay in Ram, so be frugal
    WResourceManager::Instance()->RetrieveTexture("phasebar.png", RETRIEVE_MANAGE);
    WResourceManager::Instance()->RetrieveTexture("wood.png", RETRIEVE_MANAGE);
    WResourceManager::Instance()->RetrieveTexture("gold.png", RETRIEVE_MANAGE);
    WResourceManager::Instance()->RetrieveTexture("goldglow.png", RETRIEVE_MANAGE);
    WResourceManager::Instance()->RetrieveTexture("backdrop.jpg", RETRIEVE_MANAGE);
    WResourceManager::Instance()->RetrieveTexture("handback.png", RETRIEVE_MANAGE);
    WResourceManager::Instance()->RetrieveTexture("shadows.png", RETRIEVE_MANAGE);

    jq = WResourceManager::Instance()->RetrieveQuad("shadows.png", 2, 2, 16, 16, "white", RETRIEVE_MANAGE);
    if (jq)
        jq->SetHotSpot(8, 8);
    jq = WResourceManager::Instance()->RetrieveQuad("shadows.png", 20, 2, 16, 16, "shadow", RETRIEVE_MANAGE);
    if (jq)
        jq->SetHotSpot(8, 8);
    jq = WResourceManager::Instance()->RetrieveQuad("shadows.png", 38, 2, 16, 16, "extracostshadow", RETRIEVE_MANAGE);
    if (jq)
        jq->SetHotSpot(8, 8);

    jq = WResourceManager::Instance()->RetrieveQuad("phasebar.png", 0, 0, 0, 0, "phasebar", RETRIEVE_MANAGE);



    LOG("Creating Game States");
    mGameStates[GAME_STATE_DECK_VIEWER] = NEW GameStateDeckViewer(this);
    mGameStates[GAME_STATE_DECK_VIEWER]->Create();

    mGameStates[GAME_STATE_MENU] = NEW GameStateMenu(this);
    mGameStates[GAME_STATE_MENU]->Create();

    mGameStates[GAME_STATE_DUEL] = NEW GameStateDuel(this);
    mGameStates[GAME_STATE_DUEL]->Create();

    mGameStates[GAME_STATE_SHOP] = NEW GameStateShop(this);
    mGameStates[GAME_STATE_SHOP]->Create();

    mGameStates[GAME_STATE_OPTIONS] = NEW GameStateOptions(this);
    mGameStates[GAME_STATE_OPTIONS]->Create();

    mGameStates[GAME_STATE_AWARDS] = NEW GameStateAwards(this);
    mGameStates[GAME_STATE_AWARDS]->Create();

    mGameStates[GAME_STATE_STORY] = NEW GameStateStory(this);
    mGameStates[GAME_STATE_STORY]->Create();

    mGameStates[GAME_STATE_TRANSITION] = NULL;

    mCurrentState = NULL;
    mNextState = mGameStates[GAME_STATE_MENU];

    //Set Audio volume
    JSoundSystem::GetInstance()->SetSfxVolume(options[Options::SFXVOLUME].number);
    JSoundSystem::GetInstance()->SetMusicVolume(options[Options::MUSICVOLUME].number);

    DebugTrace("size of MTGCardInstance: " << sizeof(MTGCardInstance));
    DebugTrace("size of MTGCard: "<< sizeof(MTGCard));
    DebugTrace("size of CardPrimitive: "<< sizeof(CardPrimitive));
    DebugTrace("size of ExtraCost: " << sizeof(ExtraCost));
    DebugTrace("size of ManaCost: " << sizeof(ManaCost));

    LOG("Game Creation Done.");
}
Exemple #22
0
void GameStateShop::Render()
{
    //Erase
    WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT);
    JRenderer * r = JRenderer::GetInstance();
    r->ClearScreen(ARGB(0,0,0,0));
    if (mStage == STAGE_FADE_IN)
        return;

    JQuadPtr mBg = WResourceManager::Instance()->RetrieveTempQuad("shop.jpg", TEXTURE_SUB_5551);
    if (mBg.get())
        r->RenderQuad(mBg.get(), 0, 0);

    JQuadPtr quad = WResourceManager::Instance()->RetrieveTempQuad("shop_light.jpg", TEXTURE_SUB_5551);
    if (quad.get())
    {
        r->EnableTextureFilter(false);
        r->SetTexBlend(BLEND_SRC_ALPHA, BLEND_ONE);
        quad->SetColor(ARGB(lightAlpha,255,255,255));
        r->RenderQuad(quad.get(), 0, 0);
        r->SetTexBlend(BLEND_SRC_ALPHA, BLEND_ONE_MINUS_SRC_ALPHA);
        r->EnableTextureFilter(true);
    }

    if (shopMenu)
        shopMenu->Render();
    
    if (filterMenu && !filterMenu->isFinished())
        filterMenu->Render();
    else
    {
        if (boosterDisplay)
            boosterDisplay->Render();
        else if (bigDisplay)
        {
            if (bigDisplay->mOffset.getPos() >= 0)
                bigDisplay->setSource(srcCards);
            else
                bigDisplay->setSource(NULL);
            bigDisplay->Render();
            float elp = srcCards->getElapsed();
            //Render the card list overlay.
            if (bListCards || elp > LIST_FADEIN)
            {
                int alpha = 200;
                if (!bListCards && elp < LIST_FADEIN + .25)
                {
                    alpha = static_cast<int> (800 * (elp - LIST_FADEIN));
                }
                r->FillRoundRect(300, 10, 160, SHOP_SLOTS * 20 + 15, 5, ARGB(alpha,0,0,0));
                alpha += 55;
                for (int i = 0; i < SHOP_SLOTS; i++)
                {
                    if (i == shopMenu->getSelected())
                        mFont->SetColor(ARGB(alpha,255,255,0));
                    else
                        mFont->SetColor(ARGB(alpha,255,255,255));
                    char buffer[512];
                    string s = descPurchase(i, true);
                    sprintf(buffer, "%s", s.c_str());
                    float x = 310;
                    float y = static_cast<float> (25 + 20 * i);
                    mFont->DrawString(buffer, x, y);
                }
            }
        }
    }

    //Render the info bar
    r->FillRect(0, SCREEN_HEIGHT - 17, SCREEN_WIDTH, 17, ARGB(128,0,0,0));
    std::ostringstream stream;
    stream << kCreditsString << playerdata->credits;
    mFont->SetColor(ARGB(255,255,255,255));
    mFont->DrawString(stream.str(), 5, SCREEN_HEIGHT - 14);

#ifndef TOUCH_ENABLED
    float len = 4 + mFont->GetStringWidth(kOtherCardsString.c_str());
	r->RenderQuad(pspIcons[6].get(), SCREEN_WIDTH - len - 0.5 - 10, SCREEN_HEIGHT - 8, 0, kPspIconScaleFactor, kPspIconScaleFactor);
    mFont->DrawString(kOtherCardsString, SCREEN_WIDTH - len, SCREEN_HEIGHT - 14);
#else
    enableButtons();
#endif
    
    mFont->SetColor(ARGB(255,255,255,0));
    mFont->DrawString(descPurchase(bigSync.getPos()).c_str(), SCREEN_WIDTH / 2, SCREEN_HEIGHT - 14, JGETEXT_CENTER);
    mFont->SetColor(ARGB(255,255,255,255));

    if (mStage == STAGE_SHOP_TASKS && taskList)
    {
        taskList->Render();
    }
    if (menu)
        menu->Render();
    
    if (!filterMenu || (filterMenu && filterMenu->isFinished()))
        renderButtons();
}
Exemple #23
0
void Interruptible::Render(MTGCardInstance * source, JQuad * targetQuad, string alt1, string alt2, string action,
                           bool bigQuad)
{
    WFont * mFont = observer->getResourceManager()->GetWFont(Fonts::MAIN_FONT);
    mFont->SetColor(ARGB(255,255,255,255));
    mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
    JRenderer * renderer = JRenderer::GetInstance();

    if (!targetQuad)
    {
        /*if(source->controller()->isHuman() && source->controller()->opponent()->isAI() && !alt2.size() && _(action).c_str() == source->name)
            mFont->DrawString("You play ", x + 35, y-15 + GetVerticalTextOffset(), JGETEXT_LEFT);
        else if(source->controller()->isAI() && source->controller()->opponent()->isHuman() && !alt2.size() && _(action).c_str() == source->name)
            mFont->DrawString("Opponent plays ", x + 35, y-15 + GetVerticalTextOffset(), JGETEXT_LEFT);*/
        mFont->DrawString(_(action).c_str(), x + 35, y + GetVerticalTextOffset(), JGETEXT_LEFT);
    }
    else
    {
        renderer->FillRect(x-2,y-16 + GetVerticalTextOffset(), 73, 43, ARGB(235,10,10,10));
        /*if(source->controller()->isHuman() && source->controller()->opponent()->isAI())
            renderer->DrawRect(x-2,y-16 + GetVerticalTextOffset(), 73, 43, ARGB(245,0,255,0));
        else
            renderer->DrawRect(x-2,y-16 + GetVerticalTextOffset(), 73, 43, ARGB(245,255,0,0));*/
        mFont->DrawString(">", x + 32, y + GetVerticalTextOffset(), JGETEXT_LEFT);
        mFont->DrawString(_(action).c_str(), x + 75, y + GetVerticalTextOffset(), JGETEXT_LEFT);
    }

    JQuadPtr quad = observer->getResourceManager()->RetrieveCard(source, CACHE_THUMB);
    if (!quad.get())
        quad = CardGui::AlternateThumbQuad(source);
    if (quad.get())
    {
        quad->SetColor(ARGB(255,255,255,255));
        float scale = mHeight / quad->mHeight;
        renderer->RenderQuad(quad.get(), x + (quad->mWidth * scale / 2), y + (quad->mHeight * scale / 2), 0, scale, scale);
    }
    else if (alt1.size())
    {
        mFont->DrawString(_(alt1).c_str(), x, y + GetVerticalTextOffset());
    }

    if (bigQuad)
    {
        //Pos pos = Pos(CardGui::BigWidth / 2, CardGui::BigHeight / 2 - 10, 1.0, 0.0, 220);
        Pos npos = Pos(CardGui::BigWidth / 2 + 8.f, CardGui::BigHeight / 2 - 2.f, 1.0f - (1.0f/10), 0.0, 220);
        //border
        if(observer->getCardSelector()->GetDrawMode() < 2)
        {
            string cardsetname = setlist[source->setId].c_str();
            if(cardsetname == "2ED"||cardsetname == "RV"||cardsetname == "4ED"||cardsetname == "5ED"||cardsetname == "6ED"||cardsetname == "7ED"||cardsetname == "8ED"||cardsetname == "9ED"||cardsetname == "CHR"||cardsetname == "DM")
            {
                JRenderer::GetInstance()->FillRoundRect((npos.actX - (npos.actZ * 84.f))-11.5f,(npos.actY - (npos.actZ * 119.7f))-14.f,npos.actZ * 168.f + 6.5f,npos.actZ * 239.4f + 12.f,8.f,ARGB(255,248,248,255));
                JRenderer::GetInstance()->DrawRoundRect((npos.actX - (npos.actZ * 84.f))-11.5f,(npos.actY - (npos.actZ * 119.7f))-14.f,npos.actZ * 168.f + 6.5f,npos.actZ * 239.4f + 12.f,8.f,ARGB(150,20,20,20));
            }
            else
            {
                JRenderer::GetInstance()->FillRoundRect((npos.actX - (npos.actZ * 84.f))-11.5f,(npos.actY - (npos.actZ * 119.7f))-14.f,npos.actZ * 168.f + 6.5f,npos.actZ * 239.4f + 12.f,8.f,ARGB(255,5,5,5));
                JRenderer::GetInstance()->DrawRoundRect((npos.actX - (npos.actZ * 84.f))-11.5f,(npos.actY - (npos.actZ * 119.7f))-14.f,npos.actZ * 168.f + 6.5f,npos.actZ * 239.4f + 12.f,8.f,ARGB(50,240,240,240));
            }
        }
        //render card
        CardGui::DrawCard(source, npos, observer->getCardSelector()->GetDrawMode(),false,true);
    }

    if (targetQuad)
    {
        float backupX = targetQuad->mHotSpotX;
        float backupY = targetQuad->mHotSpotY;
        targetQuad->SetColor(ARGB(255,255,255,255));
        targetQuad->SetHotSpot(targetQuad->mWidth / 2, targetQuad->mHeight / 2);
        float scale = mHeight / targetQuad->mHeight;
        renderer->RenderQuad(targetQuad, x + 55, y + ((mHeight - targetQuad->mHeight) / 2) + targetQuad->mHotSpotY, 0, scale, scale);
        targetQuad->SetHotSpot(backupX, backupY);
    }
    else if (alt2.size())
    {
        mFont->DrawString(_(alt2).c_str(), x + 35, y+15 + GetVerticalTextOffset());
    }
}
Exemple #24
0
void GuiPhaseBar::Render()
{
    JQuadPtr quad = WResourceManager::Instance()->GetQuad("phasebar");
    JQuadPtr phaseinfo = WResourceManager::Instance()->RetrieveTempQuad("fakebar.png"); //new fakebar graphics
    //uncomment to draw a hideous line across hires screens.
    // JRenderer::GetInstance()->DrawLine(0, CENTER, SCREEN_WIDTH, CENTER, ARGB(255, 255, 255, 255));

    const float radius  = 25 * zoomFactor;

    for(int i = 0; i < 6; ++i)
    {
        //the position of the glyphe in the circle
        const float circPos = (i - 2) * step + angle;
        const float glyphY = this->y + this->mHeight / 2 + sin(circPos) * radius;

        //the scale is computed so that the glyphes touch each other
        //hint: sin(circPos + PI/2) = cos(circPos)
        const float glyphScale = float(zoomFactor * cosf(circPos) * 0.5f);

        if (observer->currentPlayer && observer->currentPlayer->isAI() && !observer->currentPlayer->opponent()->isAI())
            DrawGlyph(quad.get(), (displayedPhaseId - 2 + i + kPhases) % kPhases, 0, glyphY, glyphScale, 29);
        else
            DrawGlyph(quad.get(), (displayedPhaseId - 2 + i + kPhases) % kPhases, 0, glyphY, glyphScale, 0);
    }

    //print phase name
    WFont * font = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT);
    string currentP = _("your turn");
    string interrupt = "";
    if (observer->currentPlayer == mpDuelLayers->getRenderedPlayerOpponent())
    {
        currentP = _("opponent's turn");
    }
    font->SetColor(ARGB(255, 255, 255, 255));
    if (observer->currentlyActing() && observer->currentlyActing()->isAI())
    {
        font->SetColor(ARGB(255, 128, 128, 128));
    }
    if (observer->currentlyActing() != observer->currentPlayer)
    {
        if (observer->currentPlayer == mpDuelLayers->getRenderedPlayer())
        {
            interrupt = _(" - ") + _("opponent plays");
        }
        else
        {
            interrupt = _(" - ") + _("you play");
        }
    }

    char buf[200];
    //running this string through translate returns gibberish even though we defined the variables in the lang.txt
    //the conversion from phase bar phases to mtg phases is x%kPhases + 1
    //todo: just to this when the displayedPhaseId updates
    string phaseNameToTranslate = observer->phaseRing->phaseName(displayedPhaseId%kPhases + 1);
    phaseNameToTranslate = _(phaseNameToTranslate);
    sprintf(buf, _("(%s%s) %s").c_str(), currentP.c_str(), interrupt.c_str(),phaseNameToTranslate.c_str());
#if !defined (PSP)
    if(phaseinfo.get())
    {
        
        phaseinfo->mWidth = font->GetStringWidth(buf)+12.f;
        phaseinfo->SetHotSpot(phaseinfo->mWidth -4, 0);
        //phaseinfo->mHeight = font->GetHeight()+5.f;
        JRenderer::GetInstance()->RenderQuad(phaseinfo.get(),SCREEN_WIDTH_F,0,0,2.2f, SCREEN_HEIGHT_F / phaseinfo->mHeight);
    }
#endif
    font->DrawString(buf, SCREEN_WIDTH - 5, 2, JGETEXT_RIGHT);
}
Exemple #25
0
void DeckView::renderCard(int index, int alpha, bool asThumbnail, bool addWHborder)
{
    WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT);

    const CardRep& cardPosition = mCards[index];

    if (!cardPosition.card) return;

    if (!WResourceManager::Instance()->IsThreaded())
    {
        JQuadPtr backQuad = WResourceManager::Instance()->GetQuad(kGenericCardID);
        JQuadPtr quad;

        int cacheError = CACHE_ERROR_NONE;

        if (!options[Options::DISABLECARDS].number)
        {
            quad = WResourceManager::Instance()->RetrieveCard(cardPosition.card, RETRIEVE_EXISTING);
            cacheError = WResourceManager::Instance()->RetrieveError();
            if (!quad.get() && cacheError != CACHE_ERROR_404)
            {
                if (last_user_activity > (abs(2 - index) + 1) * no_user_activity_show_card_delay)
                    quad = WResourceManager::Instance()->RetrieveCard(cardPosition.card);
                else
                {
                    quad = backQuad;
                }
            }
        }

        if (quad.get())
        {
            if (quad == backQuad)
            {
                quad->SetColor(ARGB(255,255,255,255));
                float _scale = cardPosition.scale * (285 / quad->mHeight);
                JRenderer::GetInstance()->RenderQuad(quad.get(), cardPosition.x, cardPosition.y, 0.0f, _scale, _scale);
            }
            else
            {
                Pos pos = Pos(cardPosition.x, cardPosition.y, cardPosition.scale * 285 / 250, 0.0, 255);
                CardGui::DrawCard(cardPosition.card, pos, asThumbnail, true);
            }
        }
        else
        {
            Pos pos = Pos(cardPosition.x, cardPosition.y, cardPosition.scale * 285 / 250, 0.0, 255);
            CardGui::DrawCard(cardPosition.card, pos, DrawMode::kText, asThumbnail, true);
        }
    }
    else
    {//NORMAL VIEW WITH IMAGES
        int mode = !options[Options::DISABLECARDS].number ? DrawMode::kNormal : DrawMode::kText;
        float modx = addWHborder ? 2.0f:0.0f;
        //border for editor && others???
        string cardsetname = setlist[cardPosition.card->setId].c_str();
        if(cardsetname == "2ED"||cardsetname == "RV"||cardsetname == "4ED"||cardsetname == "5ED"||cardsetname == "6ED"||cardsetname == "7ED"||cardsetname == "8ED"||cardsetname == "9ED"||cardsetname == "CHR"||cardsetname == "DM")
        {
            JRenderer::GetInstance()->FillRoundRect((cardPosition.x - cardPosition.scale * 100.0f)-(5.f+modx),(cardPosition.y - cardPosition.scale * 142.5f)-(5.f+modx),cardPosition.scale * 200.0f,cardPosition.scale * 285.0f,5.f+modx,ARGB(255,248,248,255));
            JRenderer::GetInstance()->DrawRoundRect((cardPosition.x - cardPosition.scale * 100.0f)-(5.f+modx),(cardPosition.y - cardPosition.scale * 142.5f)-(5.f+modx),cardPosition.scale * 200.0f,cardPosition.scale * 285.0f,5.f+modx,ARGB(150,20,20,20));
        }
        else
        {
            JRenderer::GetInstance()->FillRoundRect((cardPosition.x - cardPosition.scale * 100.0f)-(5.f+modx),(cardPosition.y - cardPosition.scale * 142.5f)-(5.f+modx),cardPosition.scale * 200.0f,cardPosition.scale * 285.0f,5.f+modx,ARGB(255,10,10,10));
            JRenderer::GetInstance()->DrawRoundRect((cardPosition.x - cardPosition.scale * 100.0f)-(5.f+modx),(cardPosition.y - cardPosition.scale * 142.5f)-(5.f+modx),cardPosition.scale * 200.0f,cardPosition.scale * 285.0f,5.f+modx,ARGB(50,240,240,240));
        }
        Pos pos = Pos(cardPosition.x, cardPosition.y, cardPosition.scale * 285 / 250, 0.0, 255);
        CardGui::DrawCard(cardPosition.card, pos, mode, asThumbnail, true);
    }
    int quadAlpha = alpha;
    if (!deck()->count(cardPosition.card)) quadAlpha /= 2;
    quadAlpha = 255 - quadAlpha;
    if (quadAlpha > 0)
    {
        JRenderer::GetInstance()->FillRect(cardPosition.x - cardPosition.scale * 100.0f, cardPosition.y - cardPosition.scale * 142.5f, cardPosition.scale * 200.0f, cardPosition.scale * 285.0f,
                                           ARGB(quadAlpha,0,0,0));
    }
    if (last_user_activity < 3)
    {
        int fontAlpha = alpha;
        float qtY = cardPosition.y - 135 * cardPosition.scale;
        float qtX = cardPosition.x + 40 * cardPosition.scale;
        char buffer[4096];
        sprintf(buffer, "x%i", deck()->count(cardPosition.card));
        WFont * font = mFont;
        font->SetScale(1.4f);
        font->SetColor(ARGB(fontAlpha/2,0,0,0));
        JRenderer::GetInstance()->FillRect(qtX, qtY, font->GetStringWidth(buffer) + 6, 18, ARGB(fontAlpha/2,0,0,0));
        JRenderer::GetInstance()->DrawRect(qtX, qtY, font->GetStringWidth(buffer) + 6, 18, ARGB(fontAlpha/2,240,240,240));
        font->DrawString(buffer, qtX + 5, qtY + 3);
        font->SetColor(ARGB(fontAlpha,255,255,255));
        font->DrawString(buffer, qtX + 4, qtY + 2);
        font->SetColor(ARGB(255,255,255,255));
        font->SetScale(1.0f);
    }
}
Exemple #26
0
void Interruptible::Render(MTGCardInstance * source, JQuad * targetQuad, string alt1, string alt2, string action,
    bool bigQuad)
{
    WFont * mFont = observer->getResourceManager()->GetWFont(Fonts::MAIN_FONT);
    mFont->SetColor(ARGB(255,255,255,255));
    mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
    JRenderer * renderer = JRenderer::GetInstance();
    
    if (!targetQuad)
    {
        /*if(source->controller()->isHuman() && source->controller()->opponent()->isAI() && !alt2.size() && _(action).c_str() == source->name)
            mFont->DrawString("You play ", x + 35, y-15 + GetVerticalTextOffset(), JGETEXT_LEFT);
        else if(source->controller()->isAI() && source->controller()->opponent()->isHuman() && !alt2.size() && _(action).c_str() == source->name)
            mFont->DrawString("Opponent plays ", x + 35, y-15 + GetVerticalTextOffset(), JGETEXT_LEFT);*/
        mFont->DrawString(_(action).c_str(), x + 35, y + GetVerticalTextOffset(), JGETEXT_LEFT);
    }
    else
    {
        renderer->FillRect(x-2,y-16 + GetVerticalTextOffset(), 73, 43, ARGB(235,10,10,10));
        /*if(source->controller()->isHuman() && source->controller()->opponent()->isAI())
            renderer->DrawRect(x-2,y-16 + GetVerticalTextOffset(), 73, 43, ARGB(245,0,255,0));
        else
            renderer->DrawRect(x-2,y-16 + GetVerticalTextOffset(), 73, 43, ARGB(245,255,0,0));*/
        mFont->DrawString(">", x + 32, y + GetVerticalTextOffset(), JGETEXT_LEFT);
        mFont->DrawString(_(action).c_str(), x + 75, y + GetVerticalTextOffset(), JGETEXT_LEFT);
    }

    JQuadPtr quad = observer->getResourceManager()->RetrieveCard(source, CACHE_THUMB);
    if (!quad.get())
        quad = CardGui::AlternateThumbQuad(source);
    if (quad.get())
    {
        quad->SetColor(ARGB(255,255,255,255));
        float scale = mHeight / quad->mHeight;
        renderer->RenderQuad(quad.get(), x + (quad->mWidth * scale / 2), y + (quad->mHeight * scale / 2), 0, scale, scale);
    }
    else if (alt1.size())
    {
        mFont->DrawString(_(alt1).c_str(), x, y + GetVerticalTextOffset());
    }

    if (bigQuad)
    {
        /*Pos pos = Pos(CardGui::BigWidth / 2, CardGui::BigHeight / 2 - 10, 1.0, 0.0, 220);
        CardGui::DrawCard(source, pos, observer->getCardSelector()->GetDrawMode());*/
        Pos pos = Pos(CardGui::BigWidth / 2, CardGui::BigHeight / 2 - 10, 0.80f, 0.0, 220);
        pos.actY = 142;//adjust y a little bit
        CardGui::DrawCard(source, pos, observer->getCardSelector()->GetDrawMode());
    }

    if (targetQuad)
    {
        float backupX = targetQuad->mHotSpotX;
        float backupY = targetQuad->mHotSpotY;
        targetQuad->SetColor(ARGB(255,255,255,255));
        targetQuad->SetHotSpot(targetQuad->mWidth / 2, targetQuad->mHeight / 2);
        float scale = mHeight / targetQuad->mHeight;
        renderer->RenderQuad(targetQuad, x + 55, y + ((mHeight - targetQuad->mHeight) / 2) + targetQuad->mHotSpotY, 0, scale, scale);
        targetQuad->SetHotSpot(backupX, backupY);
    }
    else if (alt2.size())
    {
        mFont->DrawString(_(alt2).c_str(), x + 35, y+15 + GetVerticalTextOffset());
    }
}
Exemple #27
0
void GuiCombat::Render()
{
    if (NONE == cursor_pos)
        return;
    JRenderer* renderer = JRenderer::GetInstance();
    renderer->FillRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, ARGB(200,0,0,0));

    for (inner_iterator it = attackers.begin(); it != attackers.end(); ++it)
        if ((*it)->show)
            (*it)->Render(step);
    if (activeAtk)
    {
        float setH = 0;
        float setW = 0;
        signed damage = activeAtk->card->stepPower(step);
        for (vector<DefenserDamaged*>::iterator q = activeAtk->blockers.begin(); q != activeAtk->blockers.end(); ++q)
        {
            (*q)->Render(step);
            damage -= (*q)->sumDamages();
            setH = (*q)->Height;
            setW = (*q)->Width;
        }
        if (damage < 0)
            damage = 0;
        if (activeAtk->card->has(Constants::TRAMPLE))
        {
            if(activeAtk->card->isAttacking && activeAtk->card->isAttacking != observer->opponent())
            {
                JQuadPtr enemy = WResourceManager::Instance()->RetrieveCard((MTGCardInstance*)activeAtk->card->isAttacking, CACHE_THUMB);
                float oldH = enemy->mHeight;
                float oldW = enemy->mWidth;
                enemy->mHeight = setH;
                enemy->mWidth = setW;
                enemy->SetHotSpot(18, 25);
                enemy_avatar.Render(enemy.get());
                enemy->mHeight = oldH;
                enemy->mWidth = oldW;
            }
            else
            {
                observer->opponent()->getIcon()->SetHotSpot(18, 25);
                enemy_avatar.Render(observer->opponent()->getIcon().get());
            }
            WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT);
            mFont->SetColor(ARGB(255, 255, 64, 0));
            {
                char buf[10];
                sprintf(buf, "%i", damage);
                mFont->DrawString(buf, enemy_avatar.actX - 25, enemy_avatar.actY - 40);
            }

        }
    }
    if (ok_tex)
    {
        JQuadPtr ok_quad = WResourceManager::Instance()->RetrieveTempQuad("Ok.png");
        ok_quad->SetHotSpot(28, 22);
        ok.Render(ok_quad.get());
    }
    renderer->DrawLine(0, SCREEN_HEIGHT / 2 + 10, SCREEN_WIDTH, SCREEN_HEIGHT / 2 + 10, ARGB(255, 255, 64, 0));
    if (FIRST_STRIKE == step)
    {
        WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT);
        mFont->SetColor(ARGB(255, 64, 255, 64));
        mFont->DrawString("First strike damage", 370, 2);
    }
}