Skip to content

Commit

Permalink
WIP menu refactor - implement display campaigns; add dogfights dir
Browse files Browse the repository at this point in the history
  • Loading branch information
cxong committed Feb 27, 2013
1 parent 69b4a3c commit 729368e
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 2 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
45 changes: 43 additions & 2 deletions src/mainmenu.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ int SelectCampaign(int dogFight, int cmd)
static int dogfightIndex = 0;
int count, y, i, j;
struct FileEntry *list = dogFight ? dogfightList : campaignList;
char *prefix = dogFight ? "dogfights/" : "missions/";
const char *prefix = dogFight ? CDOGS_DOGFIGHT_DIR : CDOGS_CAMPAIGN_DIR;
int *index = dogFight ? &dogfightIndex : &campaignIndex;
struct FileEntry *f;

Expand Down Expand Up @@ -1534,11 +1534,52 @@ void MenuDisplaySubmenus(menu_t *menu, int isCentered)
}
}

#define ARROW_UP "\036"
#define ARROW_DOWN "\037"

// Display menu items for options
switch (menu->u.normal.optionType)
{
case MENU_OPTION_TYPE_CAMPAIGNS:
assert(0);
{
int count = 0, y, j;
struct FileEntry *list = campaignList;
struct FileEntry *f = list;
i = 0;
while (f != NULL && i <= menu->u.normal.index - 12)
{
count++;
i++;
f = f->next;
}

y = CenterY(12 * CDogsTextHeight());

if (i != 0)
{
DisplayMenuItem(CenterX(CDogsTextWidth(ARROW_UP)), y - 2 - CDogsTextHeight(), ARROW_UP, 0);
}

for (j = 0; f != NULL && j < 12; f = f->next, i++, j++)
{
int isSelected = i == menu->u.normal.index;
DisplayMenuItem(CenterX(CDogsTextWidth(f->info)), y, f->info, isSelected);

if (isSelected)
{
char s[255];
sprintf(s, "( %s )", strlen(f->name) == 0 ? "Internal" : f->name);
CDogsTextStringSpecial(s, TEXT_XCENTER | TEXT_BOTTOM, 0, SCREEN_WIDTH / 12);
}

y += CDogsTextHeight();
}

if (f != NULL)
{
DisplayMenuItem(CenterX(CDogsTextWidth(ARROW_DOWN)), y + 2, ARROW_DOWN, 0);
}
}
break;
case MENU_OPTION_TYPE_DOGFIGHTS:
assert(0);
Expand Down
3 changes: 3 additions & 0 deletions src/sys_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
#define CDOGS_GAME_MUSIC_DIR CDOGS_MUSIC_DIR "game/"
#define CDOGS_MENU_MUSIC_DIR CDOGS_MUSIC_DIR "menu/"

#define CDOGS_CAMPAIGN_DIR "missions/"
#define CDOGS_DOGFIGHT_DIR "dogfights/"

#define CDOGS_TEMP_DIR "/tmp/cdogs/"

#endif
3 changes: 3 additions & 0 deletions src/sys_config.h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
#define CDOGS_GAME_MUSIC_DIR CDOGS_MUSIC_DIR "game/"
#define CDOGS_MENU_MUSIC_DIR CDOGS_MUSIC_DIR "menu/"

#define CDOGS_CAMPAIGN_DIR "missions/"
#define CDOGS_DOGFIGHT_DIR "dogfights/"

#define CDOGS_TEMP_DIR "@CDOGS_TEMP_DIR@"

#endif

0 comments on commit 729368e

Please sign in to comment.