================= Item_Slider_HandleKey ================= */
| 10951 | ================= |
| 10952 | */ |
| 10953 | qboolean Item_Slider_HandleKey(itemDef_t *item, int key, qboolean down) |
| 10954 | { |
| 10955 | //DC->Print("slider handle key\n"); |
| 10956 | //JLF MPMOVED |
| 10957 | |
| 10958 | float x, value, width, work; |
| 10959 | |
| 10960 | if (item->window.flags & WINDOW_HASFOCUS && item->cvar && Rect_ContainsPoint(&item->window.rect, DC->cursorx, DC->cursory)) |
| 10961 | { |
| 10962 | |
| 10963 | if (key == A_MOUSE1 || key == A_ENTER || key == A_MOUSE2 || key == A_MOUSE3) |
| 10964 | { |
| 10965 | editFieldDef_t *editDef = (editFieldDef_s *) item->typeData; |
| 10966 | if (editDef) |
| 10967 | { |
| 10968 | rectDef_t testRect; |
| 10969 | width = SLIDER_WIDTH; |
| 10970 | if (item->text) |
| 10971 | { |
| 10972 | x = item->textRect.x + item->textRect.w + 8; |
| 10973 | } |
| 10974 | else |
| 10975 | { |
| 10976 | x = item->window.rect.x; |
| 10977 | } |
| 10978 | |
| 10979 | testRect = item->window.rect; |
| 10980 | testRect.x = x; |
| 10981 | value = (float)SLIDER_THUMB_WIDTH / 2; |
| 10982 | testRect.x -= value; |
| 10983 | //DC->Print("slider x: %f\n", testRect.x); |
| 10984 | testRect.w = (SLIDER_WIDTH + (float)SLIDER_THUMB_WIDTH / 2); |
| 10985 | //DC->Print("slider w: %f\n", testRect.w); |
| 10986 | if (Rect_ContainsPoint(&testRect, DC->cursorx, DC->cursory)) |
| 10987 | { |
| 10988 | work = DC->cursorx - x; |
| 10989 | value = work / width; |
| 10990 | value *= (editDef->maxVal - editDef->minVal); |
| 10991 | // vm fuckage |
| 10992 | // value = (((float)(DC->cursorx - x)/ SLIDER_WIDTH) * (editDef->maxVal - editDef->minVal)); |
| 10993 | value += editDef->minVal; |
| 10994 | DC->setCVar(item->cvar, va("%f", value)); |
| 10995 | return qtrue; |
| 10996 | } |
| 10997 | } |
| 10998 | } |
| 10999 | } |
| 11000 | |
| 11001 | //DC->Print("slider handle key exit\n"); |
| 11002 | return qfalse; |
| 11003 | } |
| 11004 | |
| 11005 | /* |
| 11006 | ================= |
no test coverage detected