static void EditCampaign(void) { int done = 0; int c = 0; int mission = 0; int xc = 0, yc = 0; int xcOld, ycOld; struct Mission scrap; struct EditorInfo edInfo; int x, y, buttons, tag; GetEditorInfo(&edInfo); memset(&scrap, 0, sizeof(scrap)); SetMouseRects(localClicks); gCampaign.setting = &campaign; gCampaign.seed = 0; Setup(mission, 1); while (!done) { Display(mission, xc, yc, c); do { GetEvent(&c, &x, &y, &buttons); if (buttons) { if (GetMouseRectTag(x, y, &tag)) { xcOld = xc; ycOld = yc; if ((tag & LEAVE_YC) == 0) { yc = (tag & 0xFF); AdjustYC(&yc); } if ((tag & LEAVE_XC) == 0) { xc = ((tag >> 8) & 0xFF); AdjustXC(yc, &xc); } if ((tag & SELECT_ONLY) != 0) c = DUMMY; else if ((tag & SELECT_ONLY_FIRST) == 0 || (xc == xcOld && yc == ycOld)) c = (buttons == 1 ? PAGEUP : PAGEDOWN); else c = DUMMY; } } }
void EditCharacters(TCampaignSetting * setting) { int done = 0; int c = 0; int index = 0; int xc = 0, yc = 0; TBadGuy scrap; int x, y, buttons, tag; memset(&scrap, 0, sizeof(scrap)); SetMouseRects(localClicks); while (!done) { Display(setting, index, xc, yc); do { GetEvent(&c, &x, &y, &buttons); if (buttons) { if (XYToCharacterIndex(x, y, &tag)) { if (tag >= 0 && tag < setting->characterCount) index = tag; c = DUMMY; } else if (GetMouseRectTag(x, y, &tag)) { xc = (tag >> 8); yc = (tag & 0xFF); AdjustYC(&yc); AdjustXC(yc, &xc); c = (buttons == 1 ? PAGEUP : PAGEDOWN); } } } while (!c); switch (c) { case HOME: if (index > 0) index--; break; case END: if (index < setting->characterCount - 1) index++; break; case INSERT: InsertCharacter(setting, index, NULL); fileChanged = 1; break; case ALT_X: scrap = setting->characters[index]; case DELETE: DeleteCharacter(setting, &index); fileChanged = 1; break; case ALT_C: scrap = setting->characters[index]; break; case ALT_V: InsertCharacter(setting, index, &scrap); fileChanged = 1; break; case ALT_N: InsertCharacter(setting, setting->characterCount, NULL); index = setting->characterCount - 1; fileChanged = 1; break; case ARROW_UP: yc--; AdjustYC(&yc); AdjustXC(yc, &xc); break; case ARROW_DOWN: yc++; AdjustYC(&yc); AdjustXC(yc, &xc); break; case ARROW_LEFT: xc--; AdjustXC(yc, &xc); break; case ARROW_RIGHT: xc++; AdjustXC(yc, &xc); break; case PAGEUP: Change(setting, index, yc, xc, 1); fileChanged = 1; break; case PAGEDOWN: Change(setting, index, yc, xc, -1); fileChanged = 1; break; case ESCAPE: done = 1; break; } } }