MCPcopy Create free account
hub / github.com/diasurgical/devilution / DoSpeedBook

Function DoSpeedBook

Source/control.cpp:834–885  ·  view source on GitHub ↗

* Draws the "Speed Book": the rows of known spells for quick-setting a spell that * show up when you click the spell slot at the control panel. */

Source from the content-addressed store, hash-verified

832 * show up when you click the spell slot at the control panel.
833 */
834void DoSpeedBook()
835{
836 unsigned __int64 spells, spell;
837 int xo, yo, X, Y, i, j;
838
839 spselflag = TRUE;
840 xo = PANEL_X + 12 + 56 * 10;
841 yo = PANEL_Y - 17;
842 X = PANEL_LEFT + 12 + 56 * 10 + 56 / 2;
843 Y = PANEL_TOP - 17 - 56 / 2;
844 if (plr[myplr]._pRSpell != SPL_INVALID) {
845 for (i = 0; i < 4; i++) {
846 switch (i) {
847 case RSPLTYPE_SKILL:
848 spells = plr[myplr]._pAblSpells;
849 break;
850 case RSPLTYPE_SPELL:
851 spells = plr[myplr]._pMemSpells;
852 break;
853 case RSPLTYPE_SCROLL:
854 spells = plr[myplr]._pScrlSpells;
855 break;
856 case RSPLTYPE_CHARGES:
857 spells = plr[myplr]._pISpells;
858 break;
859 }
860 spell = (__int64)1;
861 for (j = 1; j < MAX_SPELLS; j++) {
862 if (spell & spells) {
863 if (j == plr[myplr]._pRSpell && i == plr[myplr]._pRSplType) {
864 X = xo - (BORDER_LEFT - 56 / 2);
865 Y = yo - (BORDER_TOP + 56 / 2);
866 }
867 xo -= 56;
868 if (xo == PANEL_X + 12 - 56) {
869 xo = PANEL_X + 12 + 56 * 10;
870 yo -= 56;
871 }
872 }
873 spell <<= (__int64)1;
874 }
875 if (spells && xo != PANEL_X + 12 + 56 * 10)
876 xo -= 56;
877 if (xo == PANEL_X + 12 - 56) {
878 xo = PANEL_X + 12 + 56 * 10;
879 yo -= 56;
880 }
881 }
882 }
883
884 SetCursorPos(X, Y);
885}
886
887/**
888 * Checks if the mouse cursor is within any of the panel buttons and flag it if so.

Callers 3

PeekMessageAFunction · 0.85
PressCharFunction · 0.85
DoPanBtnFunction · 0.85

Calls 1

SetCursorPosFunction · 0.85

Tested by

no test coverage detected