| 27 | static TFE_Settings_Graphics* s_settings; |
| 28 | |
| 29 | bool reticle_init() |
| 30 | { |
| 31 | s_settings = TFE_Settings::getGraphicsSettings(); |
| 32 | |
| 33 | char imagePath[TFE_MAX_PATH]; |
| 34 | sprintf(imagePath, "UI_Images/ReticleAtlas.png"); |
| 35 | if (!TFE_Paths::mapSystemPath(imagePath)) { |
| 36 | TFE_Paths::appendPath(TFE_PathType::PATH_PROGRAM, "UI_Images/ReticleAtlas.png", imagePath, TFE_MAX_PATH); |
| 37 | } |
| 38 | |
| 39 | SDL_Surface* image = TFE_Image::get(imagePath); |
| 40 | if (!image) |
| 41 | { |
| 42 | TFE_System::logWrite(LOG_ERROR, "Reticle", "Cannot load reticle atlas: '%s'.", imagePath); |
| 43 | return false; |
| 44 | } |
| 45 | |
| 46 | s_reticleImage.texture = TFE_RenderBackend::createTexture(image->w, image->h, (u32*)image->pixels); |
| 47 | s_reticleImage.overlayX = 0; |
| 48 | s_reticleImage.overlayY = 0; |
| 49 | s_reticleImage.overlayWidth = 32; |
| 50 | s_reticleImage.overlayHeight = 32; |
| 51 | s_reticleId = TFE_PostProcess::addOverlayTexture(&s_reticleImage, nullptr, 0.5f, 0.5f); |
| 52 | TFE_PostProcess::enableOverlay(s_reticleId, false); |
| 53 | |
| 54 | s_enabled = false; |
| 55 | s_reticleLoaded = true; |
| 56 | |
| 57 | // Values from settings. |
| 58 | reticle_setShape((u32)s_settings->reticleIndex); |
| 59 | reticle_setScale(s_settings->reticleScale); |
| 60 | reticle_setColor(&s_settings->reticleRed); |
| 61 | |
| 62 | return true; |
| 63 | } |
| 64 | |
| 65 | void reticle_destroy() |
| 66 | { |
no test coverage detected