MCPcopy Create free account
hub / github.com/TheForceEngine/TheForceEngine / reticle_init

Function reticle_init

TheForceEngine/TFE_Game/reticle.cpp:29–63  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27static TFE_Settings_Graphics* s_settings;
28
29bool 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
65void reticle_destroy()
66{

Callers 1

mainFunction · 0.85

Calls 11

getGraphicsSettingsFunction · 0.85
logWriteFunction · 0.85
addOverlayTextureFunction · 0.85
enableOverlayFunction · 0.85
reticle_setShapeFunction · 0.85
reticle_setScaleFunction · 0.85
reticle_setColorFunction · 0.85
mapSystemPathFunction · 0.50
appendPathFunction · 0.50
getFunction · 0.50
createTextureFunction · 0.50

Tested by

no test coverage detected