inputname.c: consistent indentation

This commit is contained in:
wdlkmpx 2021-01-14 21:50:35 +08:00
parent 9cf177147d
commit 2a361fec55

View File

@ -21,7 +21,8 @@ static GtkWidget *_dialog = NULL;
static gchar _last_player_name[15] = ""; static gchar _last_player_name[15] = "";
static gint _saved_score = 0; static gint _saved_score = 0;
void read_entry(GtkWidget *widget, gpointer data) { void read_entry(GtkWidget *widget, gpointer data)
{
struct score_board current_entry; struct score_board current_entry;
time_t current_time; time_t current_time;
struct tm *timeptr; struct tm *timeptr;
@ -37,16 +38,17 @@ void read_entry(GtkWidget *widget, gpointer data) {
current_entry.score = _saved_score; current_entry.score = _saved_score;
current_time = time(NULL); current_time = time(NULL);
timeptr = localtime(&current_time); timeptr = localtime(&current_time);
if(!timeptr) {
if (!timeptr) {
ut_simple_message_box(_("Unable to determine current date.\n")); ut_simple_message_box(_("Unable to determine current date.\n"));
strncpy(current_entry.date, _("Unknown"), sizeof(current_entry.date)); strncpy(current_entry.date, _("Unknown"), sizeof(current_entry.date));
} else { } else {
if(!strftime(current_entry.date, sizeof(current_entry.date), _("%a %b %d %H:%M %Y"), timeptr)) { if (!strftime(current_entry.date, sizeof(current_entry.date), _("%a %b %d %H:%M %Y"), timeptr)) {
ut_simple_message_box(_("Unable to determine current date.\n")); ut_simple_message_box(_("Unable to determine current date.\n"));
strncpy(current_entry.date, _("Unknown"), sizeof(current_entry.date)); strncpy(current_entry.date, _("Unknown"), sizeof(current_entry.date));
} else { } else {
tstr = g_locale_to_utf8(current_entry.date, -1, &br, &bw, NULL); tstr = g_locale_to_utf8(current_entry.date, -1, &br, &bw, NULL);
if(!tstr) { if (!tstr) {
strncpy(current_entry.date, _("Unknown"), sizeof(current_entry.date)); strncpy(current_entry.date, _("Unknown"), sizeof(current_entry.date));
} else { } else {
strncpy(current_entry.date, tstr, sizeof(current_entry.date)); strncpy(current_entry.date, tstr, sizeof(current_entry.date));
@ -55,16 +57,16 @@ void read_entry(GtkWidget *widget, gpointer data) {
} }
} }
if(!read_score(b, &bf, &fbn)) { if (!read_score(b, &bf, &fbn)) {
ut_simple_message_box (_("Unable to read score.\n")); ut_simple_message_box (_("Unable to read score.\n"));
} else { } else {
pos = insert_entry_in_score_board(b, current_entry); pos = insert_entry_in_score_board(b, current_entry);
if(!write_score(b, bf, fbn)) { if (!write_score(b, bf, fbn)) {
ut_simple_message_box(_("Unable to save score.\n")); ut_simple_message_box(_("Unable to save score.\n"));
} }
/*FIXME: free bf here */ /*FIXME: free bf here */
free_score_board_full(bf, fbn); free_score_board_full(bf, fbn);
if(pos != -1) { if (pos != -1) {
pos++; pos++;
show_hall_of_fame(NULL, (gpointer)pos, b); show_hall_of_fame(NULL, (gpointer)pos, b);
} }
@ -74,11 +76,13 @@ void read_entry(GtkWidget *widget, gpointer data) {
/* show scores to let user see if (s)he's on top ;) */ /* show scores to let user see if (s)he's on top ;) */
} }
void input_name_dialog(void) {
GtkWidget *prompt_label, * vbox; void input_name_dialog(void)
GtkWidget *name; {
GtkWidget *button; GtkWidget * prompt_label, * vbox;
gchar *s; GtkWidget * name;
GtkWidget * button;
gchar * s;
/* we have to save score, because they will be set to 0 in new_game() */ /* we have to save score, because they will be set to 0 in new_game() */
_saved_score = game_get_score(); _saved_score = game_get_score();
@ -97,8 +101,8 @@ void input_name_dialog(void) {
g_signal_connect(G_OBJECT(name), "activate", G_CALLBACK(read_entry), name); g_signal_connect(G_OBJECT(name), "activate", G_CALLBACK(read_entry), name);
/* restore the last player's name */ /* restore the last player's name */
if(!(*_last_player_name)) { if (!(*_last_player_name)) {
if((s = getenv("USER"))) { if ((s = getenv("USER"))) {
strncpy(_last_player_name, s, sizeof(_last_player_name)); strncpy(_last_player_name, s, sizeof(_last_player_name));
} }
} }