Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This file implements scrollbars that are used in info and shop pages.
- // note: compile qestscrn.acs ONLY
- bool QSB_Scrollbar = false;
- // this function returns changed position of scrollbar (if it's changed)
- function int QS_Scrollbar(int scr_x, int scr_y, int scr_w, int scr_h, int min, int max, int pos)
- {
- if (pos < min) pos = min;
- if (pos > max) pos = max;
- // draw scrollbar buttons.
- bool scrollup = QS_MouseInRect(scr_x+scr_w, scr_y, 16, 16);
- bool scrolldown = QS_MouseInRect(scr_x+scr_w, scr_y+scr_h-16, 16, 16);
- int scrollspacelocal = (scr_h-32-24);
- if (scrollspacelocal < 1) scrollspacelocal = 1;
- int scrollspaceglobal = (max-min);
- if (scrollspaceglobal < 1) scrollspaceglobal = 1;
- int scrollpos = scrollspacelocal * pos / scrollspaceglobal;
- //
- if (scrollup && QS_Mouse1)
- SetFont("graphics/QSScrollUpD.png");
- else if (scrollup)
- SetFont("graphics/QSScrollUpA.png");
- else SetFont("graphics/QSScrollUp.png");
- HudMessage(s:"A"; QS_HudMsgFlags, QS_HudMsgId--, CR_UNTRANSLATED, ((scr_x+scr_w)<<16)+0.1, (scr_y<<16)+0.1, 0.029, 1.0);
- //
- if (scrolldown && QS_Mouse1)
- SetFont("graphics/QSScrollDnD.png");
- else if (scrolldown)
- SetFont("graphics/QSScrollDnA.png");
- else SetFont("graphics/QSScrollDn.png");
- HudMessage(s:"A"; QS_HudMsgFlags, QS_HudMsgId--, CR_UNTRANSLATED, ((scr_x+scr_w)<<16)+0.1, ((scr_y+scr_h-16)<<16)+0.1, 0.029, 1.0);
- //
- bool scrollbar = QS_MouseInRect(scr_x+scr_w, scr_y+16+scrollpos, 16, 24);
- if ((scrollbar && QS_Mouse1) || QSB_Scrollbar)
- SetFont("graphics/QSScrollBarD.png");
- else if (scrollbar)
- SetFont("graphics/QSScrollBarA.png");
- else SetFont("graphics/QSScrollBar.png");
- HudMessage(s:"A"; QS_HudMsgFlags, QS_HudMsgId--, CR_UNTRANSLATED, ((scr_x+scr_w)<<16)+0.1, ((scr_y+16+scrollpos)<<16)+0.1, 0.029, 1.0);
- // handle clicks.
- if (QS_Mouse1Click)
- {
- if (scrollup)
- pos -= 16;
- if (scrolldown)
- pos += 16;
- if (pos < min) pos = min;
- if (pos > max) pos = max;
- if (scrollbar)
- QSB_Scrollbar = true;
- }
- if (!QS_Mouse1) QSB_Scrollbar = false;
- if (QSB_Scrollbar)
- {
- scrollpos = QS_MouseY-(scr_y+16+12);
- if (scrollpos < 0) scrollpos = 0;
- if (scrollpos > scrollspacelocal) scrollpos = scrollspacelocal;
- pos = scrollspaceglobal * scrollpos / scrollspacelocal;
- }
- return pos;
- }
Advertisement
Add Comment
Please, Sign In to add comment