Add extra game info stuff (genre, players etc) for the menu

This commit is contained in:
simon.kagstrom 2010-03-28 15:59:56 +00:00
parent dab3082e48
commit 5964b5e783
6 changed files with 151 additions and 10 deletions

View File

@ -404,16 +404,36 @@ GameInfo *GameInfo::loadFromFile(const char *fileName)
return out;
}
void GameInfo::setAuthor(const char *author)
void GameInfo::setGeneric(const char **what, const char *who)
{
if (strlen(author) == 0)
author = " ";
free((void*)this->publisher);
this->publisher = xstrdup(author);
if (strcmp(author, " ") != 0)
if (strlen(who) == 0)
who = " ";
free((void*)*what);
*what = xstrdup(who);
if (strcmp(who, " ") != 0)
this->score++;
}
void GameInfo::setAuthor(const char *who)
{
this->setGeneric(&this->publisher, who);
}
void GameInfo::setCreator(const char *who)
{
this->setGeneric(&this->creator, who);
}
void GameInfo::setMusician(const char *who)
{
this->setGeneric(&this->musician, who);
}
void GameInfo::setGraphicsArtist(const char *who)
{
this->setGeneric(&this->graphics_artist, who);
}
void GameInfo::setYear(uint16_t year)
{
this->year = year;

View File

@ -13,6 +13,11 @@ enum
GENRE_ADVENTURE = 2,
GENRE_SIMULATION = 3,
GENRE_PUZZLE = 4,
GENRE_PLATFORM = 5,
GENRE_STRATEGY = 6,
GENRE_ROLE_PLAYING = 7,
GENRE_MAX
};
struct game_info;
@ -31,6 +36,12 @@ public:
~GameInfo();
void setGraphicsArtist(const char *who);
void setMusician(const char *who);
void setCreator(const char *who);
void setAuthor(const char *author);
void setName(const char *name);
@ -59,6 +70,8 @@ public:
uint16_t score;
private:
void setGeneric(const char **what, const char *who);
/** Fill in this game info object from a structure */
bool fromDump(struct game_info *data);

View File

@ -81,7 +81,14 @@ public:
{
snprintf(this->year, sizeof(this->year), "%d", this->gi->year);
this->gi_messages[0] = this->gi->name ? this->gi->name : " ";
this->gi_messages[3] = this->gi->publisher ? this->gi->publisher : " ";
this->gi_messages[1] = this->gi->publisher ? this->gi->publisher : " ";
this->gi_messages[2] = this->gi->creator ? this->gi->creator : " ";
this->gi_messages[3] = this->gi->musician ? this->gi->musician : " ";
this->gi_messages[4] = this->gi->graphics_artist ? this->gi->graphics_artist : " ";
if (this->gi->genre == GENRE_UNKNOWN || this->gi->genre >= GENRE_MAX)
this->gi_messages[5] = "Unknown";
else
this->gi_messages[5] = genre_dlg[this->gi->genre - 1];
}
this->gi_messages[6] = year;

View File

@ -8,6 +8,64 @@
class GameInfoView;
class MultiSelectionDialogue : public DialogueBox
{
public:
MultiSelectionDialogue(GameInfoBox *box, const char *msgs[]) : DialogueBox(msgs, true)
{
this->setSelectedBackground(Gui::gui->bg_left, Gui::gui->bg_middle,
Gui::gui->bg_right,
Gui::gui->bg_submenu_left, Gui::gui->bg_submenu_middle,
Gui::gui->bg_submenu_right);
this->cur_sel = 0;
this->box = box;
}
int selectNext(event_t ev)
{
return Menu::selectNext(ev);
}
protected:
GameInfoBox *box;
};
class GenreDialogue : public MultiSelectionDialogue
{
public:
GenreDialogue(GameInfoBox *box, const char *msgs[]) : MultiSelectionDialogue(box, msgs)
{
}
void selectCallback(int which)
{
Gui::gui->popDialogueBox();
box->gi->genre = which + 1;
box->updateMessages();
delete this;
}
};
class PlayersDialogue : public MultiSelectionDialogue
{
public:
PlayersDialogue(GameInfoBox *box, const char *msgs[]) : MultiSelectionDialogue(box, msgs)
{
}
void selectCallback(int which)
{
Gui::gui->popDialogueBox();
box->gi->players = which + 1;
box->updateMessages();
delete this;
}
};
class GameInfoMenu : public Menu, public KeyboardListener
{
friend class GameInfoView;
@ -30,6 +88,15 @@ public:
this->box->gi->setAuthor(str);
break;
case 4:
this->box->gi->setCreator(str);
break;
case 5:
this->box->gi->setMusician(str);
break;
case 6:
this->box->gi->setGraphicsArtist(str);
break;
case 7:
{
unsigned long v;
char *endp;
@ -65,9 +132,18 @@ public:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
VirtualKeyboard::kbd->activate();
VirtualKeyboard::kbd->registerListener(this);
break;
case 8:
Gui::gui->pushDialogueBox(new GenreDialogue(this->box, genre_dlg));
break;
case 9:
Gui::gui->pushDialogueBox(new PlayersDialogue(this->box, players_dlg));
break;
default:
panic("Impossible menu option\n");
break;

View File

@ -323,15 +323,38 @@ const char **network_menu_help[9] = {
};
const char *game_info_menu_messages[6] = {
const char *game_info_menu_messages[11] = {
/*00*/ "Capture game screenshot",
/*01*/ " ",
/*02*/ "Set game name",
/*03*/ "Set game author",
/*04*/ "Set publishing year",
/*03*/ "Set publisher",
/*04*/ "Set creator/programmer",
/*05*/ "Set musician",
/*06*/ "Set graphics artist",
/*07*/ "Set publishing year",
/*08*/ "Set genre",
/*09*/ "Set number of players",
NULL
};
const char *genre_dlg[8] = {
/*00*/ "Action",
/*01*/ "Adventure",
/*02*/ "Simulation",
/*03*/ "Puzzle",
/*04*/ "Platform",
/*05*/ "Strategy",
/*06*/ "Role playing",
NULL
};
const char *players_dlg[5] = {
/*00*/ "# 1",
/*01*/ "# 2",
/*02*/ "# 3",
/*03*/ "# 4",
NULL
};
const char *needs_help[9] = {
/*00*/ "c64-network.org needs",

View File

@ -23,6 +23,8 @@ extern const char *broken_theme_dlg[];
extern const char *select_analogue_dlg[];
extern const char *game_info_bad_year_dlg[];
extern const char *game_info_bad_number_dlg[];
extern const char *genre_dlg[];
extern const char *players_dlg[];
extern const char *save_state_done[];
#endif