MCPcopy Create free account
hub / github.com/atraczyk/2d-engine / R_drawSelectedMenuItem

Function R_drawSelectedMenuItem

engine/src/game.cpp:2095–2135  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2093}
2094
2095void R_drawSelectedMenuItem(MenuItem item, float tx, float ty, float tw,
2096 float th)
2097{
2098 if (item.isSlider)
2099 {
2100 glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
2101 ScreenRect srcRect = ScreenRect(0, 0, 0.166f, 1);
2102 ScreenRect dstRect = ScreenRect(tx + item.x, ty + item.y, 12.0f, th);
2103 DrawQuad(game.renderTargets.menuPanel, game.textures.slider, &srcRect,
2104 &dstRect, NULL);
2105 // middle
2106 srcRect = ScreenRect(0.166f, 0, 0.166f, 1);
2107 dstRect = ScreenRect(tx + item.x + 12.0f, ty + item.y, 232.0f, th);
2108 DrawQuad(game.renderTargets.menuPanel, game.textures.slider, &srcRect,
2109 &dstRect, NULL);
2110 // end
2111 srcRect = ScreenRect(0.333f, 0, 0.166f, 1);
2112 dstRect = ScreenRect(tx + item.x + 244.0f, ty + item.y, 12.0f, th);
2113 DrawQuad(game.renderTargets.menuPanel, game.textures.slider, &srcRect,
2114 &dstRect, NULL);
2115 // handle
2116 srcRect = ScreenRect(0.5f, 0, 0.5f, 1);
2117 dstRect = ScreenRect(tx + item.x + *item.floatValue * 225.0f,
2118 ty + item.y, tw, th);
2119 DrawQuad(game.renderTargets.menuPanel, game.textures.slider, &srcRect,
2120 &dstRect, NULL);
2121
2122 char buffer[8];
2123 sprintf(buffer, "%d", (int)(*item.floatValue * 100.0f + 0.5f));
2124 font.displayText(tx + item.x + 260.0f, ty + item.y, tw, th, 1.0f, 1.0f,
2125 1.0f, buffer);
2126 }
2127 else
2128 {
2129 font.displayText(tx + item.x - 4.0f, ty + item.y, tw, th, 1.0f, 1.0f,
2130 1.0f, item.name);
2131 if (item.boolValue != NULL)
2132 font.displayText(tx + item.x + 256.0f, ty + item.y, tw, th, 1.0f,
2133 1.0f, 1.0f, BOOLTOSTRING(*item.boolValue));
2134 }
2135}
2136
2137void R_resize(int w, int h)
2138{

Callers 1

R_drawMenusFunction · 0.85

Calls 3

ScreenRectClass · 0.85
DrawQuadFunction · 0.85
displayTextMethod · 0.80

Tested by

no test coverage detected