MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / SetCurrentIndex

Method SetCurrentIndex

Descent3/newui_core.cpp:2974–3015  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2972}
2973
2974void newuiListBox::SetCurrentIndex(int index) {
2975 if (m_NumItems == 0)
2976 return;
2977
2978 if (index >= 0 && index < m_NumItems) {
2979 int real_index = m_Virt2Real[index], old_index = m_SelectedIndex;
2980 int i = 0, y;
2981
2982 ASSERT(real_index >= 0 && real_index < m_NumItems);
2983 m_SelectedIndex = real_index;
2984
2985 // determine how many items fit in a listbox the long way.
2986 for (i = 0, y = m_boffs; i < m_NumItems; i++) {
2987 UITextItem item(m_ItemList[i]);
2988 item.set_font(MONITOR9_NEWUI_FONT);
2989
2990 y += item.height();
2991 if (y > (m_H - m_boffs - item.height())) {
2992 i++;
2993 break;
2994 }
2995 }
2996
2997 if (m_SelectedIndex < m_Index) {
2998 m_Index = m_SelectedIndex;
2999 }
3000 if (m_SelectedIndex >= (m_Index + i)) {
3001 m_Index = m_SelectedIndex - i + 1;
3002 }
3003 if (m_Index < 0) {
3004 m_Index = 0;
3005 }
3006
3007 // call callbacks if selection really changed.
3008 if (old_index != m_SelectedIndex) {
3009 if (selectchange_fn)
3010 (*selectchange_fn)(index);
3011 if (selectchange_id_fn)
3012 (*selectchange_id_fn)(GetID(), m_callbackptr);
3013 }
3014 }
3015}
3016
3017void newuiListBox::SetInternalCurrentIndex(int index) {}
3018

Callers 6

PilotChooseFunction · 0.45
NewPltUpdateFunction · 0.45
UpdateGraphicsListboxFunction · 0.45
UpdateAudioTauntBoxesFunction · 0.45
PltSelectShipFunction · 0.45

Calls 2

set_fontMethod · 0.45
heightMethod · 0.45

Tested by

no test coverage detected