Skip to content

Instantly share code, notes, and snippets.

@marrub--
Created March 16, 2017 12:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marrub--/35ef6af49e6edf9e455a6024609025db to your computer and use it in GitHub Desktop.
Save marrub--/35ef6af49e6edf9e455a6024609025db to your computer and use it in GitHub Desktop.
// ZScript
override bool InputProcess(InputEvent e)
{
if (e.type == InputEvent.Type_Mouse)
return CallACS("P_CL_Mouse", consoleplayer, e.mousex, -e.mousey);
else if (e.type == InputEvent.Type_KeyDown)
return CallACS("P_CL_KeyPress", consoleplayer, e.keyscan, true);
else if (e.type == InputEvent.Type_KeyUp)
return CallACS("P_CL_KeyPress", consoleplayer, e.keyscan, false);
else
return false;
}
// C
void G_Mouse(gui_state_t *g, int relx, int rely)
{
g->cx += relx * 0.5;
g->cy += rely * 1.8;
g->cx = M_MinMax(g->cx, 0, g->w);
g->cy = M_MinMax(g->cy, 0, g->h);
}
script_extern bool P_CL_Mouse(int pid, int relx, int rely)
{
player_t *p = &Player[pid];
if (p->gui.focus)
{
G_Mouse(&p->gui, relx, rely);
return true;
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment