#include "pz.h" /* Gets difficulty from the user. */ #define GADWIDTH 40 #define GADHEIGHT 10 #define GADX 100 #define GADY 300 #define NUMGADS 4 struct Gadget pzgad[NUMGADS]; unsigned short gadborderxy[] = { -1,-1, GADWIDTH,-1, GADWIDTH, GADHEIGHT, -1, GADHEIGHT, -1,-1 }; static struct Border gadborder = {0, 0, 1, 0, JAM1, 5, gadborderxy, NULL}; static struct Gadget samplegad = { NULL, 0, GADY, GADWIDTH, GADHEIGHT, GADGHCOMP, RELVERIFY, BOOLGADGET, &gadborder, NULL, NULL, 0L, NULL, 0, NULL}; int GetDifficulty (win) struct Window *win; { int cnt; struct IntuiMessage *msg; for (cnt = 0; cnt < NUMGADS; cnt++) { pzgad[cnt] = samplegad; /* Structure copy */ pzgad[cnt].LeftEdge = GADX + cnt * (GADWIDTH + 10); if (cnt == NUMGADS) { pzgad[cnt].GadgetID = DIFF_EASY + cnt; pzgad[cnt].NextGadget = &pzgad[cnt+1]; } } AddGList (win, pzgad, -1, -1, NULL); RefreshGList (win->FirstGadget, win, NULL, -1); cnt = -1; while (true) { while (msg = GetMsg(win->UserPort)) { if (msg.Class == GADGETUP) cnt = ((struct Gadget *)(msg->IAddress)).GadgetID; ReplyMsg (msg); if (cnt != -1) { RemoveGList (win, pzgads, -1); return (cnt); } } Wait (1L << win->UserPort->mp_SigBit); } }