MCPcopy Create free account
hub / github.com/JACoders/OpenJK / Item_Bind_Paint

Function Item_Bind_Paint

code/ui/ui_shared.cpp:6921–6991  ·  view source on GitHub ↗

================= Item_Bind_Paint ================= */

Source from the content-addressed store, hash-verified

6919=================
6920*/
6921void Item_Bind_Paint(itemDef_t *item)
6922{
6923 vec4_t newColor, lowLight;
6924 float value,textScale,textWidth;
6925 int maxChars = 0, textHeight,yAdj,startingXPos;
6926
6927 menuDef_t *parent = (menuDef_t*)item->parent;
6928 editFieldDef_t *editPtr = (editFieldDef_t*)item->typeData;
6929
6930 if (editPtr)
6931 {
6932 maxChars = editPtr->maxPaintChars;
6933 }
6934
6935 value = (item->cvar) ? DC->getCVarValue(item->cvar) : 0;
6936
6937 if (item->window.flags & WINDOW_HASFOCUS)
6938 {
6939 if (g_bindItem == item)
6940 {
6941 lowLight[0] = 0.8f * 1.0f;
6942 lowLight[1] = 0.8f * 0.0f;
6943 lowLight[2] = 0.8f * 0.0f;
6944 lowLight[3] = 0.8f * 1.0f;
6945 }
6946 else
6947 {
6948 lowLight[0] = 0.8f * parent->focusColor[0];
6949 lowLight[1] = 0.8f * parent->focusColor[1];
6950 lowLight[2] = 0.8f * parent->focusColor[2];
6951 lowLight[3] = 0.8f * parent->focusColor[3];
6952 }
6953 LerpColor(parent->focusColor,lowLight,newColor,0.5+0.5*sin((float)(DC->realTime / PULSE_DIVISOR)));
6954 }
6955 else
6956 {
6957 Item_TextColor( item,&newColor);
6958 }
6959
6960 if (item->text)
6961 {
6962 Item_Text_Paint(item);
6963 BindingFromName(item->cvar);
6964
6965 // If the text runs past the limit bring the scale down until it fits.
6966 textScale = item->textscale;
6967 textWidth = DC->textWidth(g_nameBind,(float) textScale, uiInfo.uiDC.Assets.qhMediumFont);
6968
6969 startingXPos = (item->textRect.x + item->textRect.w + 8);
6970
6971 while ((startingXPos + textWidth) >= SCREEN_WIDTH)
6972 {
6973 textScale -= .05f;
6974 textWidth = DC->textWidth(g_nameBind,(float) textScale, uiInfo.uiDC.Assets.qhMediumFont);
6975 }
6976
6977 // Try to adjust it's y placement if the scale has changed.
6978 yAdj = 0;

Callers 1

Item_PaintFunction · 0.70

Calls 4

LerpColorFunction · 0.70
Item_TextColorFunction · 0.70
Item_Text_PaintFunction · 0.70
BindingFromNameFunction · 0.70

Tested by

no test coverage detected