public void SetLevelDownloadState(Guid worldId, LevelMetadata.DownloadStates downloadState) { int queryCount = Query.Size(); for (int i = 0; i < queryCount; ++i) { if (Query[i].WorldId == worldId) { Query[i].DownloadState = downloadState; //make sure the local cache is updated with the correct genre for file location if (downloadState == LevelMetadata.DownloadStates.Complete) { Query[i].Genres |= BokuShared.Genres.Downloads; } return; } } }
} // end of HandleTouchInput() public override void Render(Camera camera) { if (rt != null && level != null && !dirty) { // We do this check here to ensure the download state icon's alpha is reset if needed before being rendered. // When this check is performed in Update, we see a fully opaque icon for one frame due to order of operations. if (Level != null) { if (Level.DownloadState != prevDownloadState) { DownloadStateChanged(); } prevDownloadState = Level.DownloadState; } try { SimpleTexturedQuad quad = SimpleTexturedQuad.GetInstance(); // Render thumbnail drop shadow. { float s = Scale; Matrix shadowMatrix = Matrix.CreateScale(3.8f + 0.25f * s * s) * Matrix.CreateTranslation(0, -0.2f * s, 0) * worldMatrix; quad.Render(camera, levelTileShadow, ref shadowMatrix, 0.6f); } // Render the favorite box if (0 != (level.Genres & BokuShared.Genres.Favorite)) { Matrix tileMatrix = Matrix.CreateScale(2.13f) * worldMatrix; quad.Render(camera, favoriteBox, ref tileMatrix, levelTileAlphaMap); } // Render the thumbnail. { Matrix tileMatrix = Matrix.CreateScale(2f) * worldMatrix; quad.Render(camera, rt, ref tileMatrix, levelTileAlphaMap); } if (Level != null) { const float kDownloadStatusX = 0.9f; const float kDownloadStatusY = 0.8f; if (Level.FlaggedByMe) { Matrix m = Matrix.CreateTranslation(kDownloadStatusX, kDownloadStatusY, 0) * worldMatrix; quad.Render(camera, reportAbuse, ref m, 1.0f); } else { switch (Level.DownloadState) { case LevelMetadata.DownloadStates.Queued: { Matrix s = Matrix.CreateTranslation(kDownloadStatusX, kDownloadStatusY - 0.1f, 0) * worldMatrix; quad.Render(camera, statusIconShadow, ref s, 0.75f * downloadStateIconAlpha); Matrix m = Matrix.CreateTranslation(kDownloadStatusX, kDownloadStatusY, 0) * worldMatrix; quad.Render(camera, downloadQueuedIcon, ref m, downloadQueuedAlphaMap, downloadStateIconAlpha); } break; case LevelMetadata.DownloadStates.InProgress: { Matrix s = Matrix.CreateTranslation(kDownloadStatusX, kDownloadStatusY - downloadInProgressAnimOffset - 0.1f, 0) * worldMatrix; quad.Render(camera, statusIconShadow, ref s, 0.75f * downloadStateIconAlpha); Matrix m = Matrix.CreateTranslation(kDownloadStatusX, kDownloadStatusY - downloadInProgressAnimOffset, 0) * worldMatrix; quad.Render(camera, downloadInProgressIcon, ref m, downloadInProgressAlphaMap, downloadStateIconAlpha); } break; case LevelMetadata.DownloadStates.Failed: { Matrix s = Matrix.CreateTranslation(kDownloadStatusX, kDownloadStatusY - 0.1f, 0) * worldMatrix; quad.Render(camera, statusIconShadow, ref s, 0.75f * downloadStateIconAlpha); Matrix m = Matrix.CreateTranslation(kDownloadStatusX, kDownloadStatusY, 0) * worldMatrix; quad.Render(camera, downloadFailedIcon, ref m, downloadFailedAlphaMap, downloadStateIconAlpha); } break; case LevelMetadata.DownloadStates.Complete: { Matrix s = Matrix.CreateTranslation(kDownloadStatusX, kDownloadStatusY - 0.1f, 0) * worldMatrix; quad.Render(camera, statusIconShadow, ref s, 0.75f * downloadStateIconAlpha); Matrix m = Matrix.CreateTranslation(kDownloadStatusX, kDownloadStatusY, 0) * worldMatrix; quad.Render(camera, downloadCompleteIcon, ref m, downloadCompleteAlphaMap, downloadStateIconAlpha); } break; } } } } catch { // This will end up here if the rt call above throws an exception // because it thinks that the rendertarget is still tied to the device. This // only occurs in some device-reset situations. If we do nothing here then // everything is ok next frame. } } } // end of UIGridLevelElement Render()