MCPcopy Create free account
hub / github.com/OpenDUNE/OpenDUNE / GUI_Widget_SpriteTextButton_Draw

Function GUI_Widget_SpriteTextButton_Draw

src/gui/widget_draw.c:136–289  ·  view source on GitHub ↗

* Draw a sprite/text button widget to the display, relative to 0,0. * * @param w The widget (which is a button) to draw. */

Source from the content-addressed store, hash-verified

134 * @param w The widget (which is a button) to draw.
135 */
136void GUI_Widget_SpriteTextButton_Draw(Widget *w)
137{
138 Screen oldScreenID;
139 Structure *s;
140 uint16 positionX, positionY;
141 uint16 width, height;
142 uint16 spriteID;
143 uint16 percentDone;
144 bool buttonDown;
145
146 if (w == NULL) return;
147
148 spriteID = 0;
149 percentDone = 0;
150
151 s = Structure_Get_ByPackedTile(g_selectionPosition);
152 if (s == NULL) return;
153
154 GUI_UpdateProductionStringID();
155
156 oldScreenID = SCREEN_ACTIVE;
157 if (GFX_Screen_IsActive(SCREEN_0)) {
158 oldScreenID = GFX_Screen_SetActive(SCREEN_1);
159 }
160
161 buttonDown = w->state.hover2;
162
163 positionX = w->offsetX;
164 positionY = w->offsetY;
165 width = w->width;
166 height = w->height;
167
168 GUI_DrawWiredRectangle(positionX - 1, positionY - 1, positionX + width, positionY + height, 12);
169 GUI_DrawBorder(positionX, positionY, width, height, buttonDown ? 0 : 1, true);
170
171 switch (g_productionStringID) {
172 case STR_LAUNCH:
173 spriteID = 0x1E;
174 break;
175
176 case STR_FREMEN:
177 spriteID = 0x5E;
178 break;
179
180 case STR_SABOTEUR:
181 spriteID = 0x60;
182 break;
183
184 case STR_UPGRADINGD_DONE:
185 default:
186 spriteID = 0x0;
187 break;
188
189 case STR_PLACE_IT:
190 case STR_COMPLETED:
191 case STR_ON_HOLD:
192 case STR_BUILD_IT:
193 case STR_D_DONE:

Callers

nothing calls this directly

Calls 15

GFX_Screen_IsActiveFunction · 0.85
GFX_Screen_SetActiveFunction · 0.85
GUI_DrawWiredRectangleFunction · 0.85
GUI_DrawBorderFunction · 0.85
GUI_DrawSpriteFunction · 0.85
Sprite_GetWidthFunction · 0.85
Unit_Get_ByIndexFunction · 0.85
GUI_DrawText_WrapperFunction · 0.85
String_Get_ByIndexFunction · 0.85
GUI_Widget_GetShortcutFunction · 0.85

Tested by

no test coverage detected