static int TemplateSelection(int loadFlag, int x, int index, struct PlayerData *data, int cmd) { int i; int y; static int selection[2] = { 0, 0 }; if (cmd & CMD_BUTTON1) { if (loadFlag) { UseTemplate(index, data, &templates[selection[index]]); } else { SaveTemplate(data, &templates[selection[index]]); } SoundPlay(&gSoundDevice, rand() % SND_COUNT); return 0; } else if (cmd & CMD_BUTTON2) { SoundPlay(&gSoundDevice, rand() % SND_COUNT); return 0; } else if (cmd & (CMD_LEFT | CMD_UP)) { if (selection[index] > 0) { selection[index]--; SoundPlay(&gSoundDevice, SND_SWITCH); } else if (selection[index] == 0) { selection[index] = MAX_TEMPLATE - 1; SoundPlay(&gSoundDevice, SND_SWITCH); } } else if (cmd & (CMD_RIGHT | CMD_DOWN)) { if (selection[index] < MAX_TEMPLATE - 1) { selection[index]++; SoundPlay(&gSoundDevice, SND_SWITCH); } else if (selection[index] == MAX_TEMPLATE - 1) { selection[index] = 0; SoundPlay(&gSoundDevice, SND_SWITCH); } } y = CenterY((CDogsTextHeight() * MAX_TEMPLATE)); if (!loadFlag) { CDogsTextStringAt(x, y - 4 - CDogsTextHeight(), "Save "); CDogsTextString(data->name); CDogsTextString("..."); } for (i = 0; i < MAX_TEMPLATE; i++) DisplayMenuItem(x, y + i * CDogsTextHeight(), templates[i].name, i == selection[index]); return 1; }
static int AppearanceSelection(const char **menu, int menuCount, int x, int index, struct PlayerData *data, int *property, int cmd, int *selection) { int y; int i; debug(D_NORMAL, "\n"); if (cmd & (CMD_BUTTON1 | CMD_BUTTON2)) { SoundPlay(&gSoundDevice, SND_MACHINEGUN); return 0; } else if (cmd & (CMD_LEFT | CMD_UP)) { if (selection[index] > 0) { selection[index]--; *property = selection[index]; SoundPlay(&gSoundDevice, SND_SWITCH); } else if (selection[index] == 0) { selection[index] = menuCount - 1; *property = selection[index]; SoundPlay(&gSoundDevice, SND_SWITCH); } } else if (cmd & (CMD_RIGHT | CMD_DOWN)) { if (selection[index] < menuCount - 1) { selection[index]++; *property = selection[index]; SoundPlay(&gSoundDevice, SND_SWITCH); } else if (selection[index] == menuCount - 1) { selection[index] = 0; *property = selection[index]; SoundPlay(&gSoundDevice, SND_SWITCH); } } SetPlayer(index, data); y = CenterY((menuCount * CDogsTextHeight())); for (i = 0; i < menuCount; i++) DisplayMenuItem(x, y + i * CDogsTextHeight(), menu[i], i == selection[index]); return 1; }
static int BodyPartSelection(int x, int index, struct PlayerData *data, int cmd, int *property, int *selection) { int i; int y; if (cmd & (CMD_BUTTON1 | CMD_BUTTON2)) { SoundPlay(&gSoundDevice, SND_POWERGUN); return 0; } else if (cmd & (CMD_LEFT | CMD_UP)) { if (*selection > 0) { (*selection)--; *property = IndexToShade(*selection); SoundPlay(&gSoundDevice, SND_SWITCH); } else if (*selection == 0) { (*selection) = PLAYER_BODY_COUNT - 1; *property = IndexToShade(*selection); SoundPlay(&gSoundDevice, SND_SWITCH); } } else if (cmd & (CMD_RIGHT | CMD_DOWN)) { if (*selection < PLAYER_BODY_COUNT - 1) { (*selection)++; *property = IndexToShade(*selection); SoundPlay(&gSoundDevice, SND_SWITCH); } else if (*selection == PLAYER_BODY_COUNT - 1) { (*selection) = 0; *property = IndexToShade(*selection); SoundPlay(&gSoundDevice, SND_SWITCH); } } y = CenterY((PLAYER_BODY_COUNT * CDogsTextHeight())); SetPlayer(index, data); for (i = 0; i < PLAYER_BODY_COUNT; i++) DisplayMenuItem(x, y + i * CDogsTextHeight(), shadeNames[i], i == *selection); return 1; }
bool ConfirmScreen(const char *info, const char *msg) { int w = gGraphicsDevice.cachedConfig.Res.x; int h = gGraphicsDevice.cachedConfig.Res.y; ClearScreen(&gGraphicsDevice); TextString(&gTextManager, info, &gGraphicsDevice, Vec2iNew((w - TextGetStringWidth(info)) / 2, (h - CDogsTextHeight()) / 2)); TextString(&gTextManager, msg, &gGraphicsDevice, Vec2iNew((w - TextGetStringWidth(msg)) / 2, (h + CDogsTextHeight()) / 2)); BlitFlip(&gGraphicsDevice, &gConfig.Graphics); int c = GetKey(&gEventHandlers); return (c == 'Y' || c == 'y'); }
static int MainMenu(int x, int index, int cmd) { int i; int y; static int selection[2] = { MODE_DONE, MODE_DONE }; if (cmd & (CMD_BUTTON1 | CMD_BUTTON2)) { SoundPlay(&gSoundDevice, SND_BANG); return selection[index]; } else if (cmd & (CMD_LEFT | CMD_UP)) { if (selection[index] > MODE_SELECTNAME) { selection[index]--; SoundPlay(&gSoundDevice, SND_SWITCH); } else if (selection[index] == MODE_SELECTNAME) { selection[index] = MODE_DONE; SoundPlay(&gSoundDevice, SND_SWITCH); } } else if (cmd & (CMD_RIGHT | CMD_DOWN)) { if (selection[index] < MODE_DONE) { selection[index]++; SoundPlay(&gSoundDevice, SND_SWITCH); } else if (selection[index] == MODE_DONE) { selection[index] = MODE_SELECTNAME; SoundPlay(&gSoundDevice, SND_SWITCH); } } y = CenterY((CDogsTextHeight() * MENU_COUNT)); for (i = 1; i < MENU_COUNT; i++) DisplayMenuItem(x, y + i * CDogsTextHeight(), mainMenu[i], selection[index] == i); return MODE_MAIN; }
static void DrawNameMenu( menu_t *menu, GraphicsDevice *g, Vec2i pos, Vec2i size, void *data) { int i; PlayerSelectMenuData *d = data; #define ENTRY_COLS 8 #define ENTRY_SPACING 7 int x = pos.x; int y = CENTER_Y( pos, size, CDogsTextHeight() * ((strlen(letters) - 1) / ENTRY_COLS)); UNUSED(menu); for (i = 0; i < (int)strlen(letters); i++) { Vec2i menuPos = Vec2iNew( x + (i % ENTRY_COLS) * ENTRY_SPACING, y + (i / ENTRY_COLS) * CDogsTextHeight()); if (i == d->nameMenuSelection) { TextCharMasked(&gTextManager, letters[i], g, menuPos, colorRed); } else { TextCharMasked(&gTextManager, letters[i], g, menuPos, colorWhite); } } DisplayMenuItem( Vec2iNew( x + (i % ENTRY_COLS) * ENTRY_SPACING, y + (i / ENTRY_COLS) * CDogsTextHeight()), "(End)", i == d->nameMenuSelection, 0, colorBlack); }
static int DisplayPage(const char *title, int index, struct Entry *e, int hilite1, int hilite2) { int x = 80; int y = 5; CDogsTextStringAt(5, 5, title); while (index < MAX_ENTRY && e[index].score > 0 && x < 300) { y += DisplayEntry(x, y, index, &e[index], index == hilite1 || index == hilite2); if (y > 198 - CDogsTextHeight()) { y = 20; x += 100; } index++; } CopyToScreen(); return index; }
static void ShowSelection(int x, struct PlayerData *data, int character) { DisplayPlayer(x, data, character, 0); if (data->weaponCount == 0) { CDogsTextStringAt( x + 40, (gGraphicsDevice.cachedConfig.ResolutionHeight / 10) + 20, "None selected..."); } else { int i; for (i = 0; i < data->weaponCount; i++) { CDogsTextStringAt( x + 40, (gGraphicsDevice.cachedConfig.ResolutionHeight / 10) + 20 + i * CDogsTextHeight(), gGunDescriptions[data->weapons[i]].gunName); } } }
static int DisplayEntry(int x, int y, int index, struct Entry *e, int hilite) { char s[10]; #define INDEX_OFFSET 15 #define SCORE_OFFSET 40 #define MISSIONS_OFFSET 60 #define MISSION_OFFSET 80 #define NAME_OFFSET 85 sprintf(s, "%d.", index + 1); DisplayAt(x + INDEX_OFFSET - CDogsTextWidth(s), y, s, hilite); sprintf(s, "%d", e->score); DisplayAt(x + SCORE_OFFSET - CDogsTextWidth(s), y, s, hilite); sprintf(s, "%d", e->missions); DisplayAt(x + MISSIONS_OFFSET - CDogsTextWidth(s), y, s, hilite); sprintf(s, "(%d)", e->lastMission + 1); DisplayAt(x + MISSION_OFFSET - CDogsTextWidth(s), y, s, hilite); DisplayAt(x + NAME_OFFSET, y, e->name, hilite); return 1 + CDogsTextHeight(); }
static int WeaponSelection(int x, int index, struct PlayerData *data, int cmd, int done) { int i; int y; static int selection[2] = { 0, 0 }; debug(D_VERBOSE, "\n"); if (selection[index] > gMission.weaponCount) selection[index] = gMission.weaponCount; if (cmd & CMD_BUTTON1) { if (selection[index] == gMission.weaponCount) { SoundPlay(&gSoundDevice, SND_KILL2); return data->weaponCount > 0 ? 0 : 1; } if (data->weaponCount < MAX_WEAPONS) { for (i = 0; i < data->weaponCount; i++) if (data->weapons[i] == gMission.availableWeapons[selection[index]]) return 1; data->weapons[data->weaponCount] = gMission.availableWeapons[selection[index]]; data->weaponCount++; SoundPlay(&gSoundDevice, SND_SHOTGUN); } else { SoundPlay(&gSoundDevice, SND_KILL); } } else if (cmd & CMD_BUTTON2) { if (data->weaponCount) { data->weaponCount--; SoundPlay(&gSoundDevice, SND_PICKUP); done = 0; } } else if (cmd & (CMD_LEFT | CMD_UP)) { if (selection[index] > 0) { selection[index]--; SoundPlay(&gSoundDevice, SND_SWITCH); } else if (selection[index] == 0) { selection[index] = gMission.weaponCount; SoundPlay(&gSoundDevice, SND_SWITCH); } done = 0; } else if (cmd & (CMD_RIGHT | CMD_DOWN)) { if (selection[index] < gMission.weaponCount) { selection[index]++; SoundPlay(&gSoundDevice, SND_SWITCH); } else if (selection[index] == gMission.weaponCount) { selection[index] = 0; SoundPlay(&gSoundDevice, SND_SWITCH); } done = 0; } if (!done) { y = CenterY((CDogsTextHeight() * gMission.weaponCount)); for (i = 0; i < gMission.weaponCount; i++) { DisplayMenuItem( x, y + i * CDogsTextHeight(), gGunDescriptions[gMission.availableWeapons[i]].gunName, i == selection[index]); } DisplayMenuItem(x, y + i * CDogsTextHeight(), endChoice, i == selection[index]); } return !done; }
static int NameSelection(int x, int index, struct PlayerData *data, int cmd) { int i; int y; //char s[2]; static char letters[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ !#?:.-0123456789"; static char smallLetters[] = "abcdefghijklmnopqrstuvwxyz !#?:.-0123456789"; static int selection[2] = { -1, -1 }; // Kludge since Watcom won't let me initialize selection with a strlen() if (selection[0] < 0) selection[0] = selection[1] = strlen(letters); if (cmd & CMD_BUTTON1) { if (selection[index] == (int)strlen(letters)) { SoundPlay(&gSoundDevice, SND_LAUNCH); return 0; } if (strlen(data->name) < sizeof(data->name) - 1) { int l = strlen(data->name); data->name[l + 1] = 0; if (l > 0 && data->name[l - 1] != ' ') data->name[l] = smallLetters[selection[index]]; else data->name[l] = letters[selection[index]]; SoundPlay(&gSoundDevice, SND_MACHINEGUN); } else { SoundPlay(&gSoundDevice, SND_KILL); } } else if (cmd & CMD_BUTTON2) { if (data->name[0]) { data->name[strlen(data->name) - 1] = 0; SoundPlay(&gSoundDevice, SND_BANG); } else { SoundPlay(&gSoundDevice, SND_KILL); } } else if (cmd & CMD_LEFT) { if (selection[index] > 0) { selection[index]--; SoundPlay(&gSoundDevice, SND_DOOR); } } else if (cmd & CMD_RIGHT) { if (selection[index] < (int)strlen(letters)) { selection[index]++; SoundPlay(&gSoundDevice, SND_DOOR); } } else if (cmd & CMD_UP) { if (selection[index] > 9) { selection[index] -= 10; SoundPlay(&gSoundDevice, SND_DOOR); } } else if (cmd & CMD_DOWN) { if (selection[index] < (int)strlen(letters) - 9) { selection[index] += 10; SoundPlay(&gSoundDevice, SND_DOOR); } else if (selection[index] < (int)strlen(letters)) { selection[index] = strlen(letters); SoundPlay(&gSoundDevice, SND_DOOR); } } #define ENTRY_COLS 10 #define ENTRY_SPACING 12 y = CenterY(((CDogsTextHeight() * ((strlen(letters) - 1) / ENTRY_COLS) ))); if (gOptions.twoPlayers && index == CHARACTER_PLAYER1) { x = CenterOf( 0, gGraphicsDevice.cachedConfig.ResolutionWidth / 2 , (ENTRY_SPACING * (ENTRY_COLS - 1)) + CDogsTextCharWidth('a')); } else if (gOptions.twoPlayers && index == CHARACTER_PLAYER2) { x = CenterOf( gGraphicsDevice.cachedConfig.ResolutionWidth / 2, gGraphicsDevice.cachedConfig.ResolutionWidth, (ENTRY_SPACING * (ENTRY_COLS - 1)) + CDogsTextCharWidth('a')); } else { x = CenterX((ENTRY_SPACING * (ENTRY_COLS - 1)) + CDogsTextCharWidth('a')); } // Draw selection //s[1] = 0; for (i = 0; i < (int)strlen(letters); i++) { //s[0] = letters[i]; CDogsTextGoto(x + (i % ENTRY_COLS) * ENTRY_SPACING, y + (i / ENTRY_COLS) * CDogsTextHeight()); if (i == selection[index]) CDogsTextCharWithTable(letters[i], &tableFlamed); else CDogsTextChar(letters[i]); /* DisplayMenuItem(x + (i % 10) * 12, 80 + (i / 10) * CDogsTextHeight(), s, i == selection[index]); */ } DisplayMenuItem(x + (i % ENTRY_COLS) * ENTRY_SPACING, y + (i / ENTRY_COLS) * CDogsTextHeight(), endChoice, i == selection[index]); return 1; }
void MenuDisplaySubmenus(menu_t *menu) { int i; int x = 0, yStart = 0; int maxWidth = 0; switch (menu->type) { // TODO: refactor the three menu types (normal, options, campaign) into one case MENU_TYPE_NORMAL: case MENU_TYPE_OPTIONS: { int isCentered = menu->type == MENU_TYPE_NORMAL; int xOptions; for (i = 0; i < menu->u.normal.numSubMenus; i++) { int width = CDogsTextWidth(menu->u.normal.subMenus[i].name); if (width > maxWidth) { maxWidth = width; } } x = CenterX(maxWidth); if (!isCentered) { x -= 20; } yStart = CenterY(menu->u.normal.numSubMenus * CDogsTextHeight()); xOptions = x + maxWidth + 10; // Display normal menu items for (i = 0; i < menu->u.normal.numSubMenus; i++) { int y = yStart + i * CDogsTextHeight(); menu_t *subMenu = &menu->u.normal.subMenus[i]; // Display menu item const char *name = subMenu->name; if (i == menu->u.normal.index) { CDogsTextStringWithTableAt(x, y, name, &tableFlamed); } else { CDogsTextStringAt(x, y, name); } // display option value if (subMenu->type == MENU_TYPE_SET_OPTION_TOGGLE || subMenu->type == MENU_TYPE_SET_OPTION_RANGE || subMenu->type == MENU_TYPE_SET_OPTION_SEED || subMenu->type == MENU_TYPE_SET_OPTION_UP_DOWN_VOID_FUNC_VOID || subMenu->type == MENU_TYPE_SET_OPTION_RANGE_GET_SET || subMenu->type == MENU_TYPE_SET_OPTION_CHANGE_CONTROL || subMenu->type == MENU_TYPE_VOID_FUNC_VOID) { int optionInt = MenuOptionGetIntValue(subMenu); switch (subMenu->u.option.displayStyle) { case MENU_OPTION_DISPLAY_STYLE_INT: CDogsTextIntAt(xOptions, y, optionInt); break; case MENU_OPTION_DISPLAY_STYLE_YES_NO: CDogsTextStringAt(xOptions, y, optionInt ? "Yes" : "No"); break; case MENU_OPTION_DISPLAY_STYLE_ON_OFF: CDogsTextStringAt(xOptions, y, optionInt ? "On" : "Off"); break; case MENU_OPTION_DISPLAY_STYLE_STR_FUNC: CDogsTextStringAt(xOptions, y, subMenu->u.option.uFunc.str()); break; case MENU_OPTION_DISPLAY_STYLE_INT_TO_STR_FUNC: CDogsTextStringAt(xOptions, y, subMenu->u.option.uFunc.intToStr(optionInt)); break; default: break; } } } } break; case MENU_TYPE_CAMPAIGNS: { int y = CenterY(12 * CDogsTextHeight()); #define ARROW_UP "\036" #define ARROW_DOWN "\037" if (menu->u.normal.scroll != 0) { DisplayMenuItem( CenterX(CDogsTextWidth(ARROW_UP)), y - 2 - CDogsTextHeight(), ARROW_UP, 0); } for (i = menu->u.normal.scroll; i < MIN(menu->u.normal.scroll + 12, menu->u.normal.numSubMenus); i++) { int isSelected = i == menu->u.normal.index; menu_t *subMenu = &menu->u.normal.subMenus[i]; const char *name = subMenu->name; // TODO: display subfolders DisplayMenuItem( CenterX(CDogsTextWidth(name)), y, name, isSelected); if (isSelected) { char s[255]; const char *filename = subMenu->u.campaign.filename; int isBuiltin = subMenu->u.campaign.isBuiltin; sprintf(s, "( %s )", isBuiltin ? "Internal" : filename); CDogsTextStringSpecial( s, TEXT_XCENTER | TEXT_BOTTOM, 0, gGraphicsDevice.cachedConfig.ResolutionWidth / 12); } y += CDogsTextHeight(); } if (i < menu->u.normal.numSubMenus - 1) { DisplayMenuItem( CenterX(CDogsTextWidth(ARROW_DOWN)), y + 2, ARROW_DOWN, 0); } } break; case MENU_TYPE_KEYS: { int xKeys; x = CenterX((CDogsTextCharWidth('a') * 10)) / 2; xKeys = x * 3; yStart = (gGraphicsDevice.cachedConfig.ResolutionHeight / 2) - (CDogsTextHeight() * 10); for (i = 0; i < menu->u.normal.numSubMenus; i++) { int y = yStart + i * CDogsTextHeight(); int isSelected = i == menu->u.normal.index; menu_t *subMenu = &menu->u.normal.subMenus[i]; const char *name = subMenu->name; if (isSelected && subMenu->type != MENU_TYPE_SET_OPTION_CHANGE_KEY) { CDogsTextStringWithTableAt(x, y, name, &tableFlamed); } else { CDogsTextStringAt(x, y, name); } if (subMenu->type == MENU_TYPE_SET_OPTION_CHANGE_KEY) { const char *keyName; if (menu->u.normal.changeKeyMenu == subMenu) { keyName = "Press a key"; } else if (subMenu->u.changeKey.code == KEY_CODE_MAP) { keyName = SDL_GetKeyName(gConfig.Input.PlayerKeys[0].Keys.map); } else { keyName = SDL_GetKeyName(InputGetKey( subMenu->u.changeKey.keys, subMenu->u.changeKey.code)); } DisplayMenuItem(xKeys, y, keyName, isSelected); } } } break; default: assert(0); break; } }
static void Save(void) { char filename[CDOGS_PATH_MAX]; strcpy(filename, lastFile); bool doSave = false; bool done = false; while (!done) { ClearScreen(&gGraphicsDevice); CDogsTextStringAt(125, 50, "Save as:"); CDogsTextGoto(125, 50 + CDogsTextHeight()); CDogsTextChar('\020'); CDogsTextString(filename); CDogsTextChar('\021'); BlitFlip(&gGraphicsDevice, &gConfig.Graphics); int c = GetKey(&gEventHandlers); switch (c) { case SDLK_RETURN: case SDLK_KP_ENTER: if (!filename[0]) { break; } doSave = true; done = true; break; case SDLK_ESCAPE: break; case SDLK_BACKSPACE: if (filename[0]) filename[strlen(filename) - 1] = 0; break; default: if (strlen(filename) == sizeof(filename) - 1) { break; } c = KeyGetTyped(&gEventHandlers.keyboard); if (c && c != '*' && (strlen(filename) > 1 || c != '-') && c != ':' && c != '<' && c != '>' && c != '?' && c != '|') { size_t si = strlen(filename); filename[si + 1] = 0; filename[si] = (char)c; } } SDL_Delay(10); } if (doSave) { ClearScreen(&gGraphicsDevice); DrawTextStringSpecial( "Saving...", TEXT_XCENTER | TEXT_YCENTER, Vec2iZero(), gGraphicsDevice.cachedConfig.Res, Vec2iZero()); BlitFlip(&gGraphicsDevice, &gConfig.Graphics); MapNewSave(filename, &gCampaign.Setting); fileChanged = 0; strcpy(lastFile, filename); sAutosaveIndex = 0; } }
static void Display(GraphicsDevice *g, int yc, HandleInputResult result) { char s[128]; int y = 5; int i; int w = g->cachedConfig.Res.x; int h = g->cachedConfig.Res.y; Mission *mission = CampaignGetCurrentMission(&gCampaign); if (mission) { // Re-make the background if the resolution has changed if (gEventHandlers.HasResolutionChanged) { MakeBackground(g, 0); } if (result.RemakeBg || brush.IsGuideImageNew) { // Clear background first for (i = 0; i < GraphicsGetScreenSize(&g->cachedConfig); i++) { g->buf[i] = PixelFromColor(g, colorBlack); } brush.IsGuideImageNew = false; GrafxDrawExtra extra; extra.guideImage = brush.GuideImageSurface; extra.guideImageAlpha = brush.GuideImageAlpha; GrafxDrawBackground(g, &sDrawBuffer, tintNone, camera, &extra); } GraphicsBlitBkg(g); // Draw brush highlight tiles if (brush.IsActive && IsBrushPosValid(brush.Pos, mission)) { EditorBrushSetHighlightedTiles(&brush); } for (i = 0; i < (int)brush.HighlightedTiles.size; i++) { Vec2i *pos = CArrayGet(&brush.HighlightedTiles, i); Vec2i screenPos = GetScreenPos(*pos); if (screenPos.x >= 0 && screenPos.x < w && screenPos.y >= 0 && screenPos.y < h) { DrawRectangle( g, screenPos, Vec2iNew(TILE_WIDTH, TILE_HEIGHT), colorWhite, DRAW_FLAG_LINE); } } sprintf( s, "Mission %d/%d", gCampaign.MissionIndex + 1, (int)gCampaign.Setting.Missions.size); TextStringMasked(&gTextManager, s, g, Vec2iNew(270, y), yc == YC_MISSIONINDEX ? colorRed : colorWhite); if (brush.LastPos.x) { sprintf(s, "(%d, %d)", brush.Pos.x, brush.Pos.y); TextString(&gTextManager, s, g, Vec2iNew(w - 40, h - 16)); } } else { ClearScreen(g); if (gCampaign.Setting.Missions.size) { sprintf(s, "End/%d", (int)gCampaign.Setting.Missions.size); TextStringMasked(&gTextManager, s, g, Vec2iNew(270, y), yc == YC_MISSIONINDEX ? colorRed : colorWhite); } } if (fileChanged) { DrawTPic(10, y, PicManagerGetOldPic(&gPicManager, 221)); } TextString(&gTextManager, "Press F1 for help", g, Vec2iNew(20, h - 20 - CDogsTextHeight())); y = 150; UIObjectDraw( sObjs, g, Vec2iZero(), gEventHandlers.mouse.currentPos, &sDrawObjs); if (result.WillDisplayAutomap && mission) { AutomapDraw(AUTOMAP_FLAGS_SHOWALL, true); } else { if (sTooltipObj && sTooltipObj->Tooltip) { UITooltipDraw( g, gEventHandlers.mouse.currentPos, sTooltipObj->Tooltip); } MouseDraw(&gEventHandlers.mouse); } BlitFlip(g, &gConfig.Graphics); }
static void Display(CampaignSettingNew *setting, int idx, int xc, int yc) { int x, y = 10; char s[50]; const Character *b; int i; int tag; for (i = 0; i < GraphicsGetScreenSize(&gGraphicsDevice.cachedConfig); i++) { gGraphicsDevice.buf[i] = LookupPalette(74); } sprintf(s, "%d", setting->characters.otherCount); CDogsTextStringAt(10, 190, s); if (idx >= 0 && idx < setting->characters.otherCount) { b = &setting->characters.others[idx]; DisplayCDogsText(30, y, "Face", yc == YC_APPEARANCE && xc == XC_FACE); DisplayCDogsText(60, y, "Skin", yc == YC_APPEARANCE && xc == XC_SKIN); DisplayCDogsText(90, y, "Hair", yc == YC_APPEARANCE && xc == XC_HAIR); DisplayCDogsText(120, y, "Body", yc == YC_APPEARANCE && xc == XC_BODY); DisplayCDogsText(150, y, "Arms", yc == YC_APPEARANCE && xc == XC_ARMS); DisplayCDogsText(180, y, "Legs", yc == YC_APPEARANCE && xc == XC_LEGS); y += CDogsTextHeight(); sprintf(s, "Speed: %d%%", (100 * b->speed) / 256); DisplayCDogsText(20, y, s, yc == YC_ATTRIBUTES && xc == XC_SPEED); sprintf(s, "Hp: %d", b->maxHealth); DisplayCDogsText(70, y, s, yc == YC_ATTRIBUTES && xc == XC_HEALTH); sprintf(s, "Move: %d%%", b->bot.probabilityToMove); DisplayCDogsText(120, y, s, yc == YC_ATTRIBUTES && xc == XC_MOVE); sprintf(s, "Track: %d%%", b->bot.probabilityToTrack); DisplayCDogsText(170, y, s, yc == YC_ATTRIBUTES && xc == XC_TRACK); sprintf(s, "Shoot: %d%%", b->bot.probabilityToShoot); DisplayCDogsText(220, y, s, yc == YC_ATTRIBUTES && xc == XC_SHOOT); sprintf(s, "Delay: %d", b->bot.actionDelay); DisplayCDogsText(270, y, s, yc == YC_ATTRIBUTES && xc == XC_DELAY); y += CDogsTextHeight(); DisplayFlag(5, y, "Asbestos", (b->flags & FLAGS_ASBESTOS) != 0, yc == YC_FLAGS && xc == XC_ASBESTOS); DisplayFlag(50, y, "Immunity", (b->flags & FLAGS_IMMUNITY) != 0, yc == YC_FLAGS && xc == XC_IMMUNITY); DisplayFlag(95, y, "C-thru", (b->flags & FLAGS_SEETHROUGH) != 0, yc == YC_FLAGS && xc == XC_SEETHROUGH); DisplayFlag(140, y, "Run-away", (b->flags & FLAGS_RUNS_AWAY) != 0, yc == YC_FLAGS && xc == XC_RUNS_AWAY); DisplayFlag(185, y, "Sneaky", (b->flags & FLAGS_SNEAKY) != 0, yc == YC_FLAGS && xc == XC_SNEAKY); DisplayFlag(230, y, "Good guy", (b->flags & FLAGS_GOOD_GUY) != 0, yc == YC_FLAGS && xc == XC_GOOD_GUY); DisplayFlag(275, y, "Asleep", (b->flags & FLAGS_SLEEPALWAYS) != 0, yc == YC_FLAGS && xc == XC_SLEEPING); y += CDogsTextHeight(); DisplayFlag(5, y, "Prisoner", (b->flags & FLAGS_PRISONER) != 0, yc == YC_FLAGS2 && xc == XC_PRISONER); DisplayFlag(50, y, "Invuln.", (b->flags & FLAGS_INVULNERABLE) != 0, yc == YC_FLAGS2 && xc == XC_INVULNERABLE); DisplayFlag(95, y, "Follower", (b->flags & FLAGS_FOLLOWER) != 0, yc == YC_FLAGS2 && xc == XC_FOLLOWER); DisplayFlag(140, y, "Penalty", (b->flags & FLAGS_PENALTY) != 0, yc == YC_FLAGS2 && xc == XC_PENALTY); DisplayFlag(185, y, "Victim", (b->flags & FLAGS_VICTIM) != 0, yc == YC_FLAGS2 && xc == XC_VICTIM); DisplayFlag(230, y, "Awake", (b->flags & FLAGS_AWAKEALWAYS) != 0, yc == YC_FLAGS2 && xc == XC_AWAKE); y += CDogsTextHeight(); DisplayCDogsText(50, y, GunGetName(b->gun), yc == YC_WEAPON); y += CDogsTextHeight() + 5; x = 10; for (i = 0; i < setting->characters.otherCount; i++) { DisplayCharacter( x, y + 20, &setting->characters.others[i], idx == i, 0); x += 20; if (x > gGraphicsDevice.cachedConfig.ResolutionWidth) { x = 10; y += 30; } } } if (MouseTryGetRectTag(&gInputDevices.mouse, &tag)) { int mouseYc = tag & 0xFF; int mouseXc = (tag & 0xFF00) >> 8; Vec2i tooltipPos = Vec2iAdd( gInputDevices.mouse.currentPos, Vec2iNew(10, 10)); DrawTooltips(&gGraphicsDevice, tooltipPos, yc, xc, mouseYc, mouseXc); }
UIObject *CreateStaticMapObjs( Vec2i pos, CampaignOptions *co, EditorBrush *brush) { int x = pos.x; int th = CDogsTextHeight(); UIObject *c = UIObjectCreate(UITYPE_NONE, 0, Vec2iZero(), Vec2iZero()); UIObject *o2; // Check whether the map type matches, and set visibility c->CheckVisible = MissionCheckTypeStatic; c->Data = co; UIObject *o = UIObjectCreate(UITYPE_BUTTON, 0, Vec2iZero(), Vec2iZero()); o->Data = brush; o->OnFocusFunc = ActivateBrush; o->OnUnfocusFunc = DeactivateBrush; o->ChangesData = false; o2 = UIObjectCopy(o); UIButtonSetPic(o2, PicManagerGetPic(&gPicManager, "editor/pencil")); o2->u.Button.IsDownFunc = BrushIsBrushTypePoint; o2->ChangeFunc = BrushSetBrushTypePoint; CSTRDUP(o2->Tooltip, "Point"); o2->Pos = pos; UIObjectAddChild(c, o2); pos.x += o2->Size.x; o2 = UIObjectCopy(o); UIButtonSetPic(o2, PicManagerGetPic(&gPicManager, "editor/line")); o2->u.Button.IsDownFunc = BrushIsBrushTypeLine; o2->ChangeFunc = BrushSetBrushTypeLine; CSTRDUP(o2->Tooltip, "Line"); o2->Pos = pos; UIObjectAddChild(c, o2); pos.x += o2->Size.x; o2 = UIObjectCopy(o); UIButtonSetPic(o2, PicManagerGetPic(&gPicManager, "editor/box")); o2->u.Button.IsDownFunc = BrushIsBrushTypeBox; o2->ChangeFunc = BrushSetBrushTypeBox; CSTRDUP(o2->Tooltip, "Box"); o2->Pos = pos; UIObjectAddChild(c, o2); pos.x += o2->Size.x; o2 = UIObjectCopy(o); UIButtonSetPic(o2, PicManagerGetPic(&gPicManager, "editor/box_filled")); o2->u.Button.IsDownFunc = BrushIsBrushTypeBoxFilled; o2->ChangeFunc = BrushSetBrushTypeBoxFilled; CSTRDUP(o2->Tooltip, "Box filled"); o2->Pos = pos; UIObjectAddChild(c, o2); pos.x += o2->Size.x; o2 = UIObjectCopy(o); UIButtonSetPic(o2, PicManagerGetPic(&gPicManager, "editor/room")); o2->u.Button.IsDownFunc = BrushIsBrushTypeRoom; o2->ChangeFunc = BrushSetBrushTypeRoom; CSTRDUP(o2->Tooltip, "Room"); o2->Pos = pos; UIObjectAddChild(c, o2); pos.x += o2->Size.x; o2 = UIObjectCopy(o); UIButtonSetPic(o2, PicManagerGetPic(&gPicManager, "editor/select")); o2->u.Button.IsDownFunc = BrushIsBrushTypeSelect; o2->ChangeFunc = BrushSetBrushTypeSelect; CSTRDUP(o2->Tooltip, "Select and move"); o2->Pos = pos; UIObjectAddChild(c, o2); pos.x += o2->Size.x; o2 = UIObjectCopy(o); UIButtonSetPic(o2, PicManagerGetPic(&gPicManager, "editor/bucket")); o2->u.Button.IsDownFunc = BrushIsBrushTypeFill; o2->ChangeFunc = BrushSetBrushTypeFill; o2->Pos = pos; UIObjectAddChild(c, o2); pos.x += o2->Size.x; o2 = UIObjectCopy(o); UIButtonSetPic(o2, PicManagerGetPic(&gPicManager, "editor/add")); o2->u.Button.IsDownFunc = BrushIsBrushTypeAddItem; CSTRDUP(o2->Tooltip, "Add items\nRight click to remove"); o2->Pos = pos; UIObjectAddChild(o2, CreateAddItemObjs(o2->Size, brush, co)); UIObjectAddChild(c, o2); pos.x += o2->Size.x; o2 = UIObjectCopy(o); UIButtonSetPic(o2, PicManagerGetPic(&gPicManager, "editor/set_key")); o2->u.Button.IsDownFunc = BrushIsBrushTypeSetKey; CSTRDUP(o2->Tooltip, "Set key required for door"); o2->Pos = pos; UIObjectAddChild(o2, CreateSetKeyObjs(o2->Size, brush)); UIObjectAddChild(c, o2); pos.x += o2->Size.x; o2 = UIObjectCopy(o); UIButtonSetPic(o2, PicManagerGetPic(&gPicManager, "editor/set_exit")); o2->u.Button.IsDownFunc = BrushIsBrushTypeSetExit; o2->ChangeFunc = BrushSetBrushTypeSetExit; CSTRDUP(o2->Tooltip, "Set exit area (box drag)"); o2->Pos = pos; UIObjectAddChild(c, o2); UIObjectDestroy(o); o = UIObjectCreate( UITYPE_LABEL, 0, Vec2iZero(), Vec2iNew(60, th)); pos.x = x; pos.y += o2->Size.y; o2 = UIObjectCopy(o); o2->u.LabelFunc = BrushGetMainTypeStr; o2->Data = brush; o2->ChangeFunc = BrushChangeMainType; o2->OnFocusFunc = ActivateBrush; o2->OnUnfocusFunc = DeactivateBrush; CSTRDUP(o2->Tooltip, "Left click to paint the map with this tile type"); o2->Pos = pos; UIObjectAddChild(c, o2); pos.x += o2->Size.x; o2 = UIObjectCopy(o); o2->u.LabelFunc = BrushGetSecondaryTypeStr; o2->Data = brush; o2->ChangeFunc = BrushChangeSecondaryType; o2->OnFocusFunc = ActivateBrush; o2->OnUnfocusFunc = DeactivateBrush; CSTRDUP(o2->Tooltip, "Right click to paint the map with this tile type"); o2->Pos = pos; UIObjectAddChild(c, o2); pos.x = x; pos.y += th; o2 = UIObjectCopy(o); o2->u.LabelFunc = BrushGetSizeStr; o2->Data = brush; o2->ChangeFunc = BrushChangeSize; o2->OnFocusFunc = ActivateBrush; o2->OnUnfocusFunc = DeactivateBrush; o2->Pos = pos; UIObjectAddChild(c, o2); UIObjectDestroy(o); o = UIObjectCreate(UITYPE_TEXTBOX, 0, Vec2iZero(), Vec2iNew(100, th)); pos.x = x; pos.y += th; o2 = UIObjectCopy(o); o2->u.Textbox.TextLinkFunc = BrushGetGuideImageStr; o2->Data = brush; o2->ChangesData = 0; o2->ChangeFunc = BrushLoadGuideImage; CSTRDUP(o2->u.Textbox.Hint, "(Tracing guide image)"); o2->Pos = pos; UIObjectAddChild(c, o2); UIObjectDestroy(o); o = UIObjectCreate(UITYPE_LABEL, 0, Vec2iZero(), Vec2iNew(100, th)); pos.x = x; pos.y += th; o2 = UIObjectCopy(o); o2->u.LabelFunc = BrushGetGuideImageAlphaStr; o2->Data = brush; o2->ChangeFunc = BrushChangeGuideImageAlpha; o2->Pos = pos; UIObjectAddChild(c, o2); UIObjectDestroy(o); return c; }