static void DisplayAt(int x, int y, const char *s, int hilite) { if (hilite) CDogsTextStringWithTableAt(x, y, s, &tableFlamed); else CDogsTextStringAt(x, y, s); }
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; }
void DisplayMenuItem(int x, int y, const char *s, int selected) { if (selected) { CDogsTextStringWithTableAt(x, y, s, &tableFlamed); } else { CDogsTextStringAt(x, y, s); } }
void DisplayPlayer(int x, const char *name, Character *c, int editingName) { Vec2i pos = Vec2iNew(x, gGraphicsDevice.cachedConfig.Res.y / 10); Vec2i playerPos = Vec2iAdd(pos, Vec2iNew(20, 36)); if (editingName) { char s[22]; sprintf(s, "%c%s%c", '\020', name, '\021'); CDogsTextStringAt(pos.x, pos.y, s); } else { CDogsTextStringAt(pos.x, pos.y, name); } DrawCharacterSimple( c, playerPos, DIRECTION_DOWN, STATE_IDLE, -1, GUNSTATE_READY, &c->table); }
static void ShowPlayerControls(int x, KeyConfig *config) { char s[256]; int y = gGraphicsDevice.cachedConfig.ResolutionHeight - (gGraphicsDevice.cachedConfig.ResolutionHeight / 6); if (config->Device == INPUT_DEVICE_KEYBOARD) { sprintf(s, "(%s, %s, %s, %s, %s and %s)", SDL_GetKeyName(config->Keys.left), SDL_GetKeyName(config->Keys.right), SDL_GetKeyName(config->Keys.up), SDL_GetKeyName(config->Keys.down), SDL_GetKeyName(config->Keys.button1), SDL_GetKeyName(config->Keys.button2)); if (CDogsTextWidth(s) < 125) { CDogsTextStringAt(x, y, s); } else { sprintf(s, "(%s, %s, %s,", SDL_GetKeyName(config->Keys.left), SDL_GetKeyName(config->Keys.right), SDL_GetKeyName(config->Keys.up)); CDogsTextStringAt(x, y - 10, s); sprintf(s, "%s, %s and %s)", SDL_GetKeyName(config->Keys.down), SDL_GetKeyName(config->Keys.button1), SDL_GetKeyName(config->Keys.button2)); CDogsTextStringAt(x, y, s); } } else { sprintf(s, "(%s)", InputDeviceStr(config->Device)); CDogsTextStringAt(x, y, s); } }
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); } } }
void DisplayPlayer(int x, struct PlayerData *data, int character, int editingName) { struct CharacterDescription *cd; TOffsetPic body, head; char s[22]; int y; y = gGraphicsDevice.cachedConfig.ResolutionHeight / 10; cd = &characterDesc[character]; if (editingName) { sprintf(s, "%c%s%c", '\020', data->name, '\021'); CDogsTextStringAt(x, y, s); } else CDogsTextStringAt(x, y, data->name); body.dx = cBodyOffset[cd->unarmedBodyPic][DIRECTION_DOWN].dx; body.dy = cBodyOffset[cd->unarmedBodyPic][DIRECTION_DOWN].dy; body.picIndex = cBodyPic[cd->unarmedBodyPic][DIRECTION_DOWN][STATE_IDLE]; head.dx = cNeckOffset[cd->unarmedBodyPic][DIRECTION_DOWN].dx + cHeadOffset[cd->facePic][DIRECTION_DOWN].dx; head.dy = cNeckOffset[cd->unarmedBodyPic][DIRECTION_DOWN].dy + cHeadOffset[cd->facePic][DIRECTION_DOWN].dy; head.picIndex = cHeadPic[cd->facePic][DIRECTION_DOWN][STATE_IDLE]; DrawTTPic(x + 20 + body.dx, y + 36 + body.dy, gPics[body.picIndex], cd->table, gRLEPics[body.picIndex]); DrawTTPic(x + 20 + head.dx, y + 36 + head.dy, gPics[head.picIndex], cd->table, gRLEPics[head.picIndex]); }
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; }
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(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); }