*POSSIBLY DESTABLIZING CHANGE, PLS PING ME IF YOU SEE ISSUES*
Turned on the threaded card fetching code for win/linux. PSP runs unthreaded. There's an easy toggle for switching which mode the app runs in: check out WResourceManager's constructor. To fully appreciate the difference, try going into the deck editor without these changes, and use the arrow keys to navigate around (esp. up/down, as it loads 7 cards at a time). Then try again with these mods, you'll see the cards flicker briefly to the back card image and then load as they scroll onto the screen.
This commit is contained in:
@@ -21,8 +21,7 @@
|
||||
#include "SimpleMenu.h"
|
||||
#include "utils.h"
|
||||
|
||||
// This is pending a change by Wil regarding graphics threads
|
||||
#define GRAPHICS_NO_THREADING
|
||||
|
||||
|
||||
//!! helper function; this is probably handled somewhere in the code already.
|
||||
// If not, should be placed in general library
|
||||
@@ -1314,63 +1313,64 @@ void GameStateDeckViewer::renderCard(int id, float rotation)
|
||||
int alpha = (int) (255 * (scale + 1.0 - max_scale));
|
||||
|
||||
if (!card) return;
|
||||
|
||||
#ifdef GRAPHICS_NO_THREADING
|
||||
|
||||
JQuadPtr backQuad = WResourceManager::Instance()->GetQuad("back");
|
||||
JQuadPtr quad;
|
||||
|
||||
int cacheError = CACHE_ERROR_NONE;
|
||||
|
||||
if (!options[Options::DISABLECARDS].number)
|
||||
|
||||
if (!WResourceManager::Instance()->IsThreaded())
|
||||
{
|
||||
quad = WResourceManager::Instance()->RetrieveCard(card, RETRIEVE_EXISTING);
|
||||
cacheError = WResourceManager::Instance()->RetrieveError();
|
||||
if (!quad.get() && cacheError != CACHE_ERROR_404)
|
||||
JQuadPtr backQuad = WResourceManager::Instance()->GetQuad("back");
|
||||
JQuadPtr quad;
|
||||
|
||||
int cacheError = CACHE_ERROR_NONE;
|
||||
|
||||
if (!options[Options::DISABLECARDS].number)
|
||||
{
|
||||
if (last_user_activity > (abs(2 - id) + 1) * NO_USER_ACTIVITY_SHOWCARD_DELAY)
|
||||
quad = WResourceManager::Instance()->RetrieveCard(card);
|
||||
else
|
||||
quad = WResourceManager::Instance()->RetrieveCard(card, RETRIEVE_EXISTING);
|
||||
cacheError = WResourceManager::Instance()->RetrieveError();
|
||||
if (!quad.get() && cacheError != CACHE_ERROR_404)
|
||||
{
|
||||
quad = backQuad;
|
||||
if (last_user_activity > (abs(2 - id) + 1) * NO_USER_ACTIVITY_SHOWCARD_DELAY)
|
||||
quad = WResourceManager::Instance()->RetrieveCard(card);
|
||||
else
|
||||
{
|
||||
quad = backQuad;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (quad.get())
|
||||
{
|
||||
if (quad == backQuad)
|
||||
if (quad.get())
|
||||
{
|
||||
quad->SetColor(ARGB(255,255,255,255));
|
||||
float _scale = scale * (285 / quad->mHeight);
|
||||
JRenderer::GetInstance()->RenderQuad(quad.get(), x, y, 0.0f, _scale, _scale);
|
||||
if (quad == backQuad)
|
||||
{
|
||||
quad->SetColor(ARGB(255,255,255,255));
|
||||
float _scale = scale * (285 / quad->mHeight);
|
||||
JRenderer::GetInstance()->RenderQuad(quad.get(), x, y, 0.0f, _scale, _scale);
|
||||
}
|
||||
else
|
||||
{
|
||||
Pos pos = Pos(x, y, scale * 285 / 250, 0.0, 255);
|
||||
CardGui::DrawCard(card, pos);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Pos pos = Pos(x, y, scale * 285 / 250, 0.0, 255);
|
||||
CardGui::DrawCard(card, pos);
|
||||
CardGui::DrawCard(card, pos, DrawMode::kText);
|
||||
if (!options[Options::DISABLECARDS].number) quad = WResourceManager::Instance()->RetrieveCard(card, CACHE_THUMB);
|
||||
if (quad.get())
|
||||
{
|
||||
float _scale = 285 * scale / quad->mHeight;
|
||||
quad->SetColor(ARGB(40,255,255,255));
|
||||
JRenderer::GetInstance()->RenderQuad(quad.get(), x, y, 0, _scale, _scale);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int mode = !options[Options::DISABLECARDS].number ? DrawMode::kNormal : DrawMode::kText;
|
||||
|
||||
Pos pos = Pos(x, y, scale * 285 / 250, 0.0, 255);
|
||||
CardGui::DrawCard(card, pos, DrawMode::kText);
|
||||
if (!options[Options::DISABLECARDS].number) quad = WResourceManager::Instance()->RetrieveCard(card, CACHE_THUMB);
|
||||
if (quad.get())
|
||||
{
|
||||
float _scale = 285 * scale / quad->mHeight;
|
||||
quad->SetColor(ARGB(40,255,255,255));
|
||||
JRenderer::GetInstance()->RenderQuad(quad.get(), x, y, 0, _scale, _scale);
|
||||
}
|
||||
CardGui::DrawCard(card, pos, mode);
|
||||
}
|
||||
|
||||
#else
|
||||
int mode = !options[Options::DISABLECARDS].number ? DrawMode::kNormal : DrawMode::kText;
|
||||
|
||||
Pos pos = Pos(x, y, scale * 285 / 250, 0.0, 255);
|
||||
CardGui::DrawCard(card, pos, mode);
|
||||
#endif
|
||||
|
||||
int quadAlpha = alpha;
|
||||
if (!displayed_deck->count(card)) quadAlpha /= 2;
|
||||
quadAlpha = 255 - quadAlpha;
|
||||
@@ -1421,6 +1421,19 @@ void GameStateDeckViewer::Render()
|
||||
order[2] = 1;
|
||||
}
|
||||
|
||||
// even though we want to draw the cards in a particular z order for layering, we want to prefetch them
|
||||
// in a different order, ie the center card should appear first, then the adjacent ones
|
||||
if (WResourceManager::Instance()->IsThreaded())
|
||||
{
|
||||
WResourceManager::Instance()->RetrieveCard(cardIndex[0]);
|
||||
WResourceManager::Instance()->RetrieveCard(cardIndex[3]);
|
||||
WResourceManager::Instance()->RetrieveCard(cardIndex[4]);
|
||||
WResourceManager::Instance()->RetrieveCard(cardIndex[2]);
|
||||
WResourceManager::Instance()->RetrieveCard(cardIndex[5]);
|
||||
WResourceManager::Instance()->RetrieveCard(cardIndex[1]);
|
||||
WResourceManager::Instance()->RetrieveCard(cardIndex[6]);
|
||||
}
|
||||
|
||||
renderCard(6, mRotation);
|
||||
renderCard(5, mRotation);
|
||||
renderCard(4, mRotation);
|
||||
|
||||
Reference in New Issue
Block a user