Пример #1
0
void TaskList::Start()
{
    vPos = -SCREEN_HEIGHT; //Offscreen
    mElapsed = 0;
    mState = TASKS_IN;
    if (!mBgTex)
    {
        mBgTex = WResourceManager::Instance()->RetrieveTexture("taskboard.png", RETRIEVE_LOCK);
        float unitH = static_cast<float> (mBgTex->mHeight / 4);
        float unitW = static_cast<float> (mBgTex->mWidth / 4);
        if (unitH == 0 || unitW == 0) return;

        for (int i = 0; i < 9; i++)
            SAFE_DELETE(mBg[i]);
        if (mBgTex)
        {
            mBg[0] = NEW JQuad(mBgTex, 0, 0, unitW, unitH);
            mBg[1] = NEW JQuad(mBgTex, unitW, 0, unitW * 2, unitH);
            mBg[2] = NEW JQuad(mBgTex, unitW * 3, 0, unitW, unitH);
            mBg[3] = NEW JQuad(mBgTex, 0, unitH, unitW, unitH * 2);
            mBg[4] = NEW JQuad(mBgTex, unitW, unitH, unitW * 2, unitH * 2);
            mBg[5] = NEW JQuad(mBgTex, unitW * 3, unitH, unitW, unitH * 2);
            mBg[6] = NEW JQuad(mBgTex, 0, unitH * 3, unitW, unitH);
            mBg[7] = NEW JQuad(mBgTex, unitW, unitH * 3, unitW * 2, unitH);
            mBg[8] = NEW JQuad(mBgTex, unitW * 3, unitH * 3, unitW, unitH);
        }

        sH = 64 / unitH;
        sW = 64 / unitW;
    }
}
Пример #2
0
JQuadPtr WCachedTexture::GetQuad(float offX, float offY, float width, float height, const string& resname)
{
    if (!texture) return JQuadPtr();

    if (width == 0.0f || width > static_cast<float> (texture->mWidth)) width = static_cast<float> (texture->mWidth);
    if (height == 0.0f || height > static_cast<float> (texture->mHeight)) height = static_cast<float> (texture->mHeight);

    // If we're fetching a card resource, but it's not available yet, we'll be attempting to get the Quad from the temporary back image.
    // If that's the case, don't stash a separate tracked quad entry for each card name in the the Back/BackThumbnail's resource
    string resource(resname);
    if (mFilename == kGenericCard || mFilename == kGenericThumbCard)
    {
        // if we're the back or thumb_back file, but we've been asked for a card ID, then assign it
        // a placeholder ID.  Reason being, hotspots on quads are different (ie centered) for card images, so we'll store a separate quad for cards 
        if (resname != kGenericCardID && resname != kGenericCardThumbnailID)
            resource = kPlaceholderID;
    }

	std::map<string, JQuadPtr>::iterator iter = mTrackedQuads.find(resource);
	if (iter != mTrackedQuads.end())
		return iter->second;

	JQuadPtr quad(NEW JQuad(texture, offX, offY, width, height));

    //Update JQ's values to what we called this with.
    quad->SetTextureRect(offX, offY, width, height);
	mTrackedQuads.insert(std::pair<string, JQuadPtr>(resource, quad));
    return quad;

}
Пример #3
0
int JResourceManager::CreateQuad(const string &quadName, const string &textureName, float x, float y, float width, float height)
{
	map<string, int>::iterator itr = mQuadMap.find(quadName);

	if (itr == mQuadMap.end())
	{
		JTexture *tex = GetTexture(textureName);
		if (tex == NULL)
		{
			int texId = CreateTexture(textureName);		// load texture if necessary
			tex = GetTexture(texId);
		}

		if (tex == NULL)								// no texture, no quad...
			return INVALID_ID;

		printf("creating quad:%s\n", quadName.c_str());

		int id = mQuadList.size();
		mQuadList.push_back(NEW JQuad(tex, x, y, width, height));

		mQuadMap[quadName] = id;

		return id;

	}
	else
		return itr->second;
}
Пример #4
0
SimpleMenu::SimpleMenu(JGE* jge, WResourceManager* resourceManager, int id, JGuiListener* listener, int fontId, float x, float y, const char * _title, int _maxItems, bool centerHorizontal, bool centerVertical)
    : JGuiController(jge, id, listener), fontId(fontId), mCenterHorizontal(centerHorizontal), mCenterVertical(centerVertical), stars(0)
{
    autoTranslate = true;
    isMultipleChoice = false;
    mHeight = 2 * SimpleMenuConst::kVerticalMargin;
    mWidth = 0;
    mX = x;
    mY = y;
    title = _(_title);
    startId = 0;
    maxItems = _maxItems;
    selectionT = 0;
    timeOpen = 0;
    mClosed = false;
    selectionTargetY = selectionY = y + SimpleMenuConst::kVerticalMargin;

    if(resourceManager)
    {
        JRenderer* renderer = JRenderer::GetInstance();

        if (!spadeLTex) spadeLTex = resourceManager->RetrieveTexture("spade_ul.png", RETRIEVE_MANAGE);
        if (!spadeRTex) spadeRTex = resourceManager->RetrieveTexture("spade_ur.png", RETRIEVE_MANAGE);
        if (!jewelTex) jewelTex = renderer->CreateTexture(5, 5, TEX_TYPE_USE_VRAM);
        if (!sideTex) sideTex = resourceManager->RetrieveTexture("menuside.png", RETRIEVE_MANAGE);
        spadeL = resourceManager->RetrieveQuad("spade_ul.png", 0, 0, 0, 0, "spade_ul", RETRIEVE_MANAGE);
        spadeR = resourceManager->RetrieveQuad("spade_ur.png", 0, 0, 0, 0, "spade_ur", RETRIEVE_MANAGE);
        jewel.reset(NEW JQuad(jewelTex, 1, 1, 3, 3));
        side = resourceManager->RetrieveQuad("menuside.png", 1, 1, 1, SimpleMenuConst::kPoleWidth, "menuside", RETRIEVE_MANAGE);

        stars = NEW hgeParticleSystem(resourceManager->RetrievePSI("stars.psi", resourceManager->GetQuad("stars").get()));

        stars->FireAt(mX, mY);
    }
}