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

Function Item_Multi_HandleKey

code/ui/ui_shared.cpp:10861–10946  ·  view source on GitHub ↗

================= Item_Multi_HandleKey ================= */

Source from the content-addressed store, hash-verified

10859=================
10860*/
10861qboolean Item_Multi_HandleKey(itemDef_t *item, int key)
10862{
10863 multiDef_t *multiPtr = (multiDef_t*)item->typeData;
10864 if (multiPtr)
10865 {
10866 if (Rect_ContainsPoint(&item->window.rect, DC->cursorx, DC->cursory) && item->window.flags & WINDOW_HASFOCUS)
10867 {
10868 //Raz: Scroll on multi buttons!
10869 if (key == A_MOUSE1 || key == A_ENTER || key == A_MOUSE2 || key == A_MOUSE3 || key == A_MWHEELDOWN || key == A_MWHEELUP)
10870 //if (key == A_MOUSE1 || key == A_ENTER || key == A_MOUSE2 || key == A_MOUSE3)
10871 {
10872 if (item->cvar)
10873 {
10874 int current = Item_Multi_FindCvarByValue(item);
10875 int max = Item_Multi_CountSettings(item);
10876
10877 if (key == A_MOUSE2 || key == A_MWHEELDOWN)
10878 {
10879 current--;
10880 if ( current < 0 )
10881 {
10882 current = max-1;
10883 }
10884 }
10885 else
10886 {
10887 current++;
10888 if ( current >= max )
10889 {
10890 current = 0;
10891 }
10892 }
10893
10894 if (multiPtr->strDef)
10895 {
10896 DC->setCVar(item->cvar, multiPtr->cvarStr[current]);
10897 }
10898 else
10899 {
10900 float value = multiPtr->cvarValue[current];
10901 if (((float)((int) value)) == value)
10902 {
10903 DC->setCVar(item->cvar, va("%i", (int) value ));
10904 }
10905 else
10906 {
10907 DC->setCVar(item->cvar, va("%f", value ));
10908 }
10909 }
10910 if (item->special)
10911 {//its a feeder?
10912 DC->feederSelection(item->special, current, item);
10913 }
10914 }
10915 else
10916 {
10917 int max = Item_Multi_CountSettings(item);
10918

Callers 1

Item_HandleKeyFunction · 0.70

Calls 4

Rect_ContainsPointFunction · 0.70
Item_Multi_CountSettingsFunction · 0.70
vaFunction · 0.50

Tested by

no test coverage detected