mirror of
https://github.com/Oibaf66/frodo-wii.git
synced 2024-11-13 07:05:12 +01:00
Add year to the game info
This commit is contained in:
parent
0e441a5ea7
commit
450260dd59
@ -40,6 +40,7 @@ struct game_info_v1
|
||||
uint16_t screenshot_off; /* In PNG format */
|
||||
uint16_t filename_off;
|
||||
uint16_t score;
|
||||
uint16_t year;
|
||||
uint8_t data[]; /* 4-byte aligned */
|
||||
};
|
||||
|
||||
@ -64,6 +65,7 @@ static void demarshal_v1(struct game_info_v1 *src)
|
||||
src->filename_off = ntohs(src->filename_off);
|
||||
src->screenshot_off = ntohs(src->screenshot_off);
|
||||
src->score = ntohs(src->score);
|
||||
src->year = ntohs(src->year);
|
||||
src->flags = ntohs(src->flags);
|
||||
}
|
||||
|
||||
@ -79,6 +81,7 @@ static struct game_info *from_v0(struct game_info_v0 *src)
|
||||
dst->sz = src->sz + d;
|
||||
dst->version_magic = VERSION_MAGIC;
|
||||
dst->flags = 0;
|
||||
dst->year = 1982; /* Got to assume something, right :-) */
|
||||
dst->score = src->score;
|
||||
|
||||
dst->author_off = src->author_off;
|
||||
@ -114,6 +117,7 @@ GameInfo::GameInfo(const char *filename,
|
||||
this->author = xstrdup(author);
|
||||
this->screenshot = image;
|
||||
this->score = 0;
|
||||
this->year = 1982;
|
||||
}
|
||||
|
||||
GameInfo::GameInfo(GameInfo *gi)
|
||||
@ -128,6 +132,7 @@ GameInfo::GameInfo(GameInfo *gi)
|
||||
this->author = xstrdup(gi->author);
|
||||
this->filename = xstrdup(gi->filename);
|
||||
this->screenshot = NULL;
|
||||
this->year = gi->year;
|
||||
|
||||
if (gi->screenshot)
|
||||
this->screenshot = SDL_DisplayFormatAlpha(gi->screenshot);
|
||||
@ -181,6 +186,7 @@ struct game_info *GameInfo::dump()
|
||||
out = (struct game_info*)xmalloc(total_sz);
|
||||
out->sz = total_sz;
|
||||
out->score = this->score;
|
||||
out->year = this->year;
|
||||
out->version_magic = VERSION_MAGIC;
|
||||
|
||||
out->author_off = 0; /* Starts AFTER the header */
|
||||
@ -202,6 +208,7 @@ struct game_info *GameInfo::dump()
|
||||
out->filename_off = htons(out->filename_off);
|
||||
out->screenshot_off = htons(out->screenshot_off);
|
||||
out->score = htons(out->score);
|
||||
out->year = htons(out->year);
|
||||
|
||||
return out;
|
||||
}
|
||||
@ -230,6 +237,7 @@ bool GameInfo::fromDump(struct game_info *gi)
|
||||
this->name = xstrdup((char*)p->data + p->name_off);
|
||||
this->filename = xstrdup((char*)p->data + p->filename_off);
|
||||
this->score = p->score;
|
||||
this->year = p->year;
|
||||
|
||||
rw = SDL_RWFromMem(p->data + p->screenshot_off,
|
||||
p->sz - p->screenshot_off);
|
||||
@ -298,14 +306,25 @@ GameInfo *GameInfo::loadFromFile(const char *fileName)
|
||||
|
||||
void GameInfo::setAuthor(const char *author)
|
||||
{
|
||||
if (strlen(author) == 0)
|
||||
author = " ";
|
||||
free((void*)this->author);
|
||||
this->author = xstrdup(author);
|
||||
if (strcmp(author, " ") != 0)
|
||||
this->score++;
|
||||
}
|
||||
|
||||
void GameInfo::setYear(uint16_t year)
|
||||
{
|
||||
this->year = year;
|
||||
this->score++;
|
||||
}
|
||||
|
||||
void GameInfo::setName(const char *name)
|
||||
{
|
||||
if (strlen(name) == 0)
|
||||
name = " ";
|
||||
|
||||
free((void*)this->name);
|
||||
this->name = xstrdup(name);
|
||||
if (strcmp(name, " ") != 0)
|
||||
|
@ -18,6 +18,7 @@ struct game_info
|
||||
uint16_t screenshot_off; /* In PNG format */
|
||||
uint16_t filename_off;
|
||||
uint16_t score;
|
||||
uint16_t year;
|
||||
uint8_t data[]; /* 4-byte aligned */
|
||||
};
|
||||
|
||||
@ -36,6 +37,8 @@ public:
|
||||
|
||||
void setName(const char *name);
|
||||
|
||||
void setYear(uint16_t year);
|
||||
|
||||
void setScreenshot(SDL_Surface *scr);
|
||||
|
||||
void resetDefaults();
|
||||
@ -54,7 +57,8 @@ public:
|
||||
const char *filename;
|
||||
SDL_Surface *screenshot;
|
||||
|
||||
Uint16 score;
|
||||
uint16_t year;
|
||||
uint16_t score;
|
||||
};
|
||||
|
||||
#endif /*__GAME_INFO_HH__ */
|
||||
|
@ -77,16 +77,22 @@ public:
|
||||
this->gi_messages[1] = " ";
|
||||
this->gi_messages[2] = "Author:";
|
||||
this->gi_messages[3] = " ";
|
||||
this->gi_messages[4] = "Year:";
|
||||
this->gi_messages[5] = " ";
|
||||
|
||||
if (this->gi)
|
||||
{
|
||||
snprintf(this->year, sizeof(this->year), "%d", this->gi->year);
|
||||
this->gi_messages[1] = this->gi->name ? this->gi->name : " ";
|
||||
this->gi_messages[3] = this->gi->author ? this->gi->author : " ";
|
||||
this->gi_messages[5] = year;
|
||||
}
|
||||
|
||||
this->setText(this->gi_messages);
|
||||
}
|
||||
|
||||
const char *gi_messages[6];
|
||||
const char *gi_messages[8];
|
||||
char year[8];
|
||||
GameInfo *gi;
|
||||
};
|
||||
|
||||
|
@ -29,6 +29,22 @@ public:
|
||||
case 3:
|
||||
this->box->gi->setAuthor(str);
|
||||
break;
|
||||
case 4:
|
||||
{
|
||||
unsigned long v;
|
||||
char *endp;
|
||||
|
||||
v = strtoul(str, &endp, 0);
|
||||
if (str != endp)
|
||||
{
|
||||
if (v < 1976 || v > 2040)
|
||||
Gui::gui->pushDialogueBox(new DialogueBox(game_info_bad_year_dlg));
|
||||
else
|
||||
this->box->gi->setYear(v);
|
||||
}
|
||||
else
|
||||
Gui::gui->pushDialogueBox(new DialogueBox(game_info_bad_number_dlg));
|
||||
} break;
|
||||
default:
|
||||
panic("Cur sel is %d, not possible!\n", this->cur_sel);
|
||||
break;
|
||||
@ -45,6 +61,7 @@ public:
|
||||
break;
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
VirtualKeyboard::kbd->activate();
|
||||
VirtualKeyboard::kbd->registerListener(this);
|
||||
break;
|
||||
|
@ -46,6 +46,28 @@ const char **broken_theme_dlg = (const char*[]){
|
||||
NULL
|
||||
};
|
||||
|
||||
const char **game_info_bad_year_dlg = (const char*[]){
|
||||
/*00*/ "Impossible year selected,",
|
||||
/*01*/ "try starting with 1981!",
|
||||
/*02*/ "#", /* Empty line */
|
||||
/*03*/ "#",
|
||||
/*04*/ "#",
|
||||
/*05*/ "#",
|
||||
/*06*/ "^|OK",
|
||||
NULL
|
||||
};
|
||||
|
||||
const char **game_info_bad_number_dlg = (const char*[]){
|
||||
/*00*/ "Please enter a number!",
|
||||
/*01*/ "#",
|
||||
/*02*/ "#", /* Empty line */
|
||||
/*03*/ "#",
|
||||
/*04*/ "#",
|
||||
/*05*/ "#",
|
||||
/*06*/ "^|OK",
|
||||
NULL
|
||||
};
|
||||
|
||||
const char **select_analogue_dlg = (const char*[]){
|
||||
/*00*/ "Select axis of analogue",
|
||||
/*01*/ "joystick to bind.",
|
||||
@ -253,6 +275,7 @@ const char **game_info_menu_messages = (const char*[]){
|
||||
/*00*/ "Capture game screenshot",
|
||||
/*01*/ " ",
|
||||
/*02*/ "Set game name",
|
||||
/*02*/ "Set game author",
|
||||
/*03*/ "Set game author",
|
||||
/*04*/ "Set publishing year",
|
||||
NULL
|
||||
};
|
||||
|
@ -17,5 +17,7 @@ extern const char **network_port_dialogue_messages;
|
||||
extern const char **network_unset_name_dlg;
|
||||
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;
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user