summaryrefslogtreecommitdiff
path: root/src/screen/screen_table.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/screen/screen_table.c')
-rw-r--r--src/screen/screen_table.c343
1 files changed, 170 insertions, 173 deletions
diff --git a/src/screen/screen_table.c b/src/screen/screen_table.c
index 31c0baf..f4c981c 100644
--- a/src/screen/screen_table.c
+++ b/src/screen/screen_table.c
@@ -31,211 +31,208 @@ static list_t *listWidgetLabelScore;
static textFile_t *textFile;
-void
-startScreenTable()
+void startScreenTable()
{
#ifndef NO_SOUND
- playMusic("menu", MUSIC_GROUP_BASE);
+ playMusic("menu", MUSIC_GROUP_BASE);
#endif
}
-void
-drawScreenTable()
+void drawScreenTable()
{
- int i;
-
- drawWidgetImage(image_backgorund);
-
- drawWidgetButton(button_back);
-
- for (i = 0; i < listWidgetLabelNumer->count; i++) {
- widget_t *this;
- this = (widget_t *) listWidgetLabelNumer->list[i];
- drawWidgetLabel(this);
- }
-
- for (i = 0; i < listWidgetLabelName->count; i++) {
- widget_t *this;
- this = (widget_t *) listWidgetLabelName->list[i];
- drawWidgetLabel(this);
- }
-
- for (i = 0; i < listWidgetLabelScore->count; i++) {
- widget_t *this;
- this = (widget_t *) listWidgetLabelScore->list[i];
- drawWidgetLabel(this);
- }
+ int i;
+
+ drawWidgetImage(image_backgorund);
+
+ drawWidgetButton(button_back);
+
+ for( i = 0 ; i < listWidgetLabelNumer->count ; i++ )
+ {
+ widget_t *this;
+ this = (widget_t *)listWidgetLabelNumer->list[i];
+ drawWidgetLabel(this);
+ }
+
+ for( i = 0 ; i < listWidgetLabelName->count ; i++ )
+ {
+ widget_t *this;
+ this = (widget_t *)listWidgetLabelName->list[i];
+ drawWidgetLabel(this);
+ }
+
+ for( i = 0 ; i < listWidgetLabelScore->count ; i++ )
+ {
+ widget_t *this;
+ this = (widget_t *)listWidgetLabelScore->list[i];
+ drawWidgetLabel(this);
+ }
}
-void
-eventScreenTable()
+void eventScreenTable()
{
- eventWidgetButton(button_back);
+ eventWidgetButton(button_back);
}
-void
-stopScreenTable()
+void stopScreenTable()
{
}
-static void
-eventWidget(void *p)
+static void eventWidget(void *p)
{
- widget_t *button;
-
- button = (widget_t *) (p);
-
- if (button == button_back) {
- setScreen("mainMenu");
- }
+ widget_t *button;
+
+ button = (widget_t *)(p);
+
+ if( button == button_back )
+ {
+ setScreen("mainMenu");
+ }
}
-static void
-setWidgetLabel()
+static void setWidgetLabel()
{
- int i;
-
- if (textFile == NULL) {
- fprintf(stderr, _("Highscore file: \"%s\" was not loaded!"),
- SCREEN_TABLE_FILE_HIGHSCORE_NAME);
-
- return;
- }
-
- if (listWidgetLabelNumer != NULL ||
- listWidgetLabelName != NULL || listWidgetLabelScore != NULL) {
- destroyListItem(listWidgetLabelNumer, destroyWidgetLabel);
- destroyListItem(listWidgetLabelName, destroyWidgetLabel);
- destroyListItem(listWidgetLabelScore, destroyWidgetLabel);
- }
-
- listWidgetLabelNumer = newList();
- listWidgetLabelName = newList();
- listWidgetLabelScore = newList();
-
- for (i = 0; i < SCREEN_TABLE_MAX_PLAYERS; i++) {
- widget_t *label;
- char name[STR_NAME_SIZE];
- char score[STR_NUM_SIZE];
- char num[STR_NUM_SIZE];
- char *line;
-
- line = (char *) textFile->text->list[i];
-
- sscanf(line, "%s %s", name, score);
- sprintf(num, "%2d)", i + 1);
-
- label =
- newWidgetLabel(num, WINDOW_SIZE_X / 2 - 100, 200 + i * 20,
- WIDGET_LABEL_LEFT);
- addList(listWidgetLabelNumer, label);
-
- label =
- newWidgetLabel(name, WINDOW_SIZE_X / 2, 200 + i * 20,
- WIDGET_LABEL_CENTER);
- addList(listWidgetLabelName, label);
-
- label =
- newWidgetLabel(score, WINDOW_SIZE_X / 2 + 80, 200 + i * 20,
- WIDGET_LABEL_LEFT);
- addList(listWidgetLabelScore, label);
- }
+ int i;
+
+ if( textFile == NULL )
+ {
+ fprintf(stderr, _("Highscore file: \"%s\" was not loaded!"),
+ SCREEN_TABLE_FILE_HIGHSCORE_NAME);
+
+ return;
+ }
+
+ if( listWidgetLabelNumer != NULL ||
+ listWidgetLabelName != NULL ||
+ listWidgetLabelScore != NULL )
+ {
+ destroyListItem(listWidgetLabelNumer, destroyWidgetLabel);
+ destroyListItem(listWidgetLabelName, destroyWidgetLabel);
+ destroyListItem(listWidgetLabelScore, destroyWidgetLabel);
+ }
+
+ listWidgetLabelNumer = newList();
+ listWidgetLabelName = newList();
+ listWidgetLabelScore = newList();
+
+ for( i = 0 ; i < SCREEN_TABLE_MAX_PLAYERS ; i++ )
+ {
+ widget_t *label;
+ char name[STR_NAME_SIZE];
+ char score[STR_NUM_SIZE];
+ char num[STR_NUM_SIZE];
+ char *line;
+
+ line = (char *) textFile->text->list[i];
+
+ sscanf(line, "%s %s", name, score);
+ sprintf(num, "%2d)", i+1);
+
+ label = newWidgetLabel(num, WINDOW_SIZE_X/2 - 100, 200 + i * 20, WIDGET_LABEL_LEFT);
+ addList(listWidgetLabelNumer, label);
+
+ label = newWidgetLabel(name, WINDOW_SIZE_X/2, 200 + i * 20, WIDGET_LABEL_CENTER);
+ addList(listWidgetLabelName, label);
+
+ label = newWidgetLabel(score, WINDOW_SIZE_X/2 + 80, 200 + i * 20, WIDGET_LABEL_LEFT);
+ addList(listWidgetLabelScore, label);
+ }
}
-static void
-loadHighscoreFile()
+static void loadHighscoreFile()
{
- char path[STR_PATH_SIZE];
- int i;
-
- sprintf(path, "%s/" SCREEN_TABLE_FILE_HIGHSCORE_NAME, getHomeDirector());
- textFile = loadTextFile(path);
-
- if (textFile == NULL) {
- fprintf(stderr, _("I am unable to load: \"%s\" !\n"), path);
- fprintf(stderr, _("Creating: \"%s\"\n"), path);
- textFile = newTextFile(path);
- }
- else {
- return;
- }
-
- if (textFile == NULL) {
- fprintf(stderr, _("I was unable to create: \"%s\" !\n"), path);
- return;
- }
-
- for (i = 0; i < SCREEN_TABLE_MAX_PLAYERS; i++) {
- addList(textFile->text, strdup("no_name 0"));
- }
-
- saveTextFile(textFile);
+ char path[STR_PATH_SIZE];
+ int i;
+
+ sprintf(path, "%s/" SCREEN_TABLE_FILE_HIGHSCORE_NAME , getHomeDirector());
+ textFile = loadTextFile(path);
+
+ if( textFile == NULL )
+ {
+ fprintf(stderr, _("I am unable to load: \"%s\" !\n"), path);
+ fprintf(stderr, _("Creating: \"%s\"\n"), path);
+ textFile = newTextFile(path);
+ }
+ else
+ {
+ return;
+ }
+
+ if( textFile == NULL )
+ {
+ fprintf(stderr, _("I was unable to create: \"%s\" !\n"), path);
+ return;
+ }
+
+ for( i = 0 ; i < SCREEN_TABLE_MAX_PLAYERS ; i++ )
+ {
+ addList(textFile->text, strdup("no_name 0") );
+ }
+
+ saveTextFile(textFile);
}
-int
-addPlayerInHighScore(char *name, int score)
+int addPlayerInHighScore(char *name, int score)
{
- int i;
-
- for (i = 0; i < SCREEN_TABLE_MAX_PLAYERS; i++) {
- char *line;
- char thisName[STR_NAME_SIZE];
- int thisCore;
-
- line = (char *) textFile->text->list[i];
- sscanf(line, "%s %d", thisName, &thisCore);
-
- if (score >= thisCore) {
- char new[STR_SIZE];
-
- sprintf(new, "%s %d", name, score);
- insList(textFile->text, i, strdup(new));
- delListItem(textFile->text, SCREEN_TABLE_MAX_PLAYERS, free);
- setWidgetLabel();
-
- return 0;
- }
- }
-
- return -1;
+ int i;
+
+ for( i = 0 ; i < SCREEN_TABLE_MAX_PLAYERS ; i++ )
+ {
+ char *line;
+ char thisName[STR_NAME_SIZE];
+ int thisCore;
+
+ line = (char *) textFile->text->list[i];
+ sscanf(line, "%s %d", thisName, &thisCore);
+
+ if( score >= thisCore )
+ {
+ char new[STR_SIZE];
+
+ sprintf(new, "%s %d", name, score);
+ insList(textFile->text, i, strdup(new) );
+ delListItem(textFile->text, SCREEN_TABLE_MAX_PLAYERS, free);
+ setWidgetLabel();
+
+ return 0;
+ }
+ }
+
+ return -1;
}
-void
-initScreenTable()
+void initScreenTable()
{
- image_t *image;
+ image_t *image;
- image =
- addImageData("screen_table.png", IMAGE_NO_ALPHA, "screen_table",
- IMAGE_GROUP_BASE);
- image_backgorund = newWidgetImage(0, 0, image);
+ image = addImageData("screen_table.png", IMAGE_NO_ALPHA, "screen_table", IMAGE_GROUP_BASE);
+ image_backgorund = newWidgetImage(0, 0, image);
- button_back =
- newWidgetButton(_("back"), WINDOW_SIZE_X / 2 - WIDGET_BUTTON_WIDTH / 2,
- WINDOW_SIZE_Y - 100, eventWidget);
+ button_back = newWidgetButton(_("back"), WINDOW_SIZE_X/2 -WIDGET_BUTTON_WIDTH/2,
+ WINDOW_SIZE_Y-100, eventWidget);
- loadHighscoreFile();
- listWidgetLabelNumer = NULL;
- listWidgetLabelName = NULL;
- listWidgetLabelScore = NULL;
- setWidgetLabel();
+ loadHighscoreFile();
+ listWidgetLabelNumer = NULL;
+ listWidgetLabelName = NULL;
+ listWidgetLabelScore = NULL;
+ setWidgetLabel();
- registerScreen(newScreen("table", startScreenTable, eventScreenTable,
- drawScreenTable, stopScreenTable));
+ registerScreen( newScreen("table", startScreenTable, eventScreenTable,
+ drawScreenTable, stopScreenTable) );
}
-void
-quitScreenTable()
+void quitScreenTable()
{
- destroyWidgetImage(image_backgorund);
-
- destroyWidgetButton(button_back);
- destroyListItem(listWidgetLabelNumer, destroyWidgetLabel);
- destroyListItem(listWidgetLabelName, destroyWidgetLabel);
- destroyListItem(listWidgetLabelScore, destroyWidgetLabel);
-
- if (textFile != NULL) {
- saveTextFile(textFile);
- destroyTextFile(textFile);
- }
+ destroyWidgetImage(image_backgorund);
+
+ destroyWidgetButton(button_back);
+ destroyListItem(listWidgetLabelNumer, destroyWidgetLabel);
+ destroyListItem(listWidgetLabelName, destroyWidgetLabel);
+ destroyListItem(listWidgetLabelScore, destroyWidgetLabel);
+
+ if( textFile != NULL )
+ {
+ saveTextFile(textFile);
+ destroyTextFile(textFile);
+ }
}
+