Index: proj/include/scoreboards.h
===================================================================
--- proj/include/scoreboards.h	(nonexistent)
+++ proj/include/scoreboards.h	(revision 348)
@@ -0,0 +1,58 @@
+#ifndef SCOREBOARD_H_INCLUDED
+#define SCOREBOARD_H_INCLUDED
+
+/**
+ * @defgroup proj_structures proj_structures
+ * @brief Project structures.
+ *
+ * @{
+ */
+
+#include <stdint.h>
+#include "font.h"
+
+/**
+ * @brief Score.
+ */
+typedef struct  score_info score_info_t;
+
+/**
+ * @brief Table of highscores.
+ */
+typedef struct highscores highscores_t;
+/**
+ * @brief Construct score.
+ * @param   score           Game score.
+ * @param   time_played     Time elapsed on game.
+ * @return      Pointer to constructed score, or NULL if failed.
+ */
+score_info_t* (score_ctor)(int score, int time_played);
+
+/**
+ * @brief Destruct score.
+ * @param   p   Pointer to score to destruct
+ */
+void (score_dtor)(score_info_t *p);
+
+/**
+ * @brief Construct highscores.
+ * @param   fnt     Font to use when rendering highscores text
+ * @param   path    Path to file to be read with highscores values.
+ * @return      Pointer to constructed highscores, or NULL if failed.
+ */
+highscores_t* (highscores_ctor)(const font_t *fnt, const char *path);
+/**
+ * @brief Save highscore into file.
+ * @param f     Path to file to be written
+ */
+void (highscores_save)(const highscores_t *p, const char *path);
+/**
+ * @brief Destruct menu.
+ * @param   p   Pointer to menu to destruct
+ */
+void (highscores_dtor)(highscores_t *p);
+
+
+
+
+#endif /* end of include guard: SCOREBOARD_H_INCLUDED */

Property changes on: proj/include/scoreboards.h
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: proj/src/scoreboards.c
===================================================================
--- proj/src/scoreboards.c	(nonexistent)
+++ proj/src/scoreboards.c	(revision 348)
@@ -0,0 +1,103 @@
+#include <lcom/lcf.h>
+
+#include "scoreboards.h"
+
+#include "graph.h"
+#include "rectangle.h"
+#include "proj_func.h"
+#include "proj_macros.h"
+#include "rtc.h"
+#include "errors.h"
+
+#include <stdio.h>
+
+#define MAX_HIGHSCORES   3 /** @brief Number of scores saved */
+
+struct  score_info {
+    int day;
+    int month;
+    int year;
+    int hour;
+    int min;
+    int sec;
+    int score;
+    int time_played;
+};
+
+struct highscores {
+    score_info_t *highscores[MAX_HIGHSCORES];
+
+    const font_t *fnt;
+    rectangle_t *r[(MAX_HIGHSCORES+1)*3 + 1];
+    text_t      *t[(MAX_HIGHSCORES+1)*3 + 1];
+    rectangle_t *frame;
+};
+
+score_info_t* (score_ctor)(int score, int time_played){
+    score_info_t *ret = (score_info_t*)malloc(sizeof(score_info_t));
+    if (ret == NULL) return NULL;
+    uint8_t score_date[4];
+    if (rtc_read_date(score_date)) return NULL;
+    ret->sec = score_date[0];
+    ret->min = score_date[1];
+    ret->hour = score_date[2];
+
+    if (rtc_read_time(score_date)) return NULL;
+
+    ret->day = score_date[1];
+    ret->month = score_date[2];
+    ret->year = score_date[3];
+
+    ret->score = score;
+    ret->time_played = time_played;
+
+    return ret;
+}
+
+void (score_dtor)(score_info_t *p){
+    if (p != NULL) free(p);
+}
+
+highscores_t* (highscores_ctor)(const font_t *fnt, const char *path) {
+    if(fnt == NULL || path == NULL) return NULL;
+
+    FILE *f = fopen(path, "r");
+    if (f == NULL) return NULL;
+    highscores_t *ret = (highscores_t*)malloc(sizeof(highscores_t));
+    if (ret == NULL) return NULL;
+    char line[30];
+    for (int i = 0; i < MAX_HIGHSCORES; i++) {
+        fgets(line, 30, f);
+        score_info_t *score = (score_info_t*)malloc(sizeof(score_info_t));
+
+        sscanf(line, "%d/%d/%d %d:%d:%d - %d - %d\n",
+                    &(score->day), &(score->month), &(score->year),
+                    &(score->hour), &(score->month), &(score->sec),
+                    &(score->score), &(score->time_played));
+        ret->highscores[i] = score;
+    }
+    fclose(f);
+
+    return ret;
+}
+
+void (highscores_save)(const highscores_t *p, const char *path) {
+    if(p == NULL || path == NULL) return;
+
+    FILE *f = fopen(path, "w");
+    if (f == NULL) return;
+    for (int i = 0; i < MAX_HIGHSCORES; i++) {
+        score_info_t *score = p->highscores[i];
+        fprintf(f, "%d/%d/%d %d:%d:%d - %d - %d\n",
+                    (score->day), (score->month), (score->year),
+                    (score->hour), (score->month), (score->sec),
+                    (score->score), (score->time_played));
+    }
+    fclose(f);
+}
+
+void (highscores_dtor)(highscores_t *p) {
+    for (int i = 0; i < MAX_HIGHSCORES; i++) {
+        score_dtor(p->highscores[i]);
+    }
+}

Property changes on: proj/src/scoreboards.c
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: proj/Makefile
===================================================================
--- proj/Makefile	(revision 347)
+++ proj/Makefile	(revision 348)
@@ -9,10 +9,10 @@
 .PATH: ${.CURDIR}/libs/classes/src
 .PATH: ${.CURDIR}/libs/utils/src
 
-SRCS= list.c queue.c graph.c kbc.c keyboard.c mouse.c utils.c timer.c interrupts_func.c fast_math.c xpm_utils.c rtc.c uart.c makecode_map.c menu.c proj_func.c rectangle.c font.c ent.c proj.c hltp.c zombies.c campaign.c singleplayer.c chat.c
+SRCS= list.c queue.c graph.c kbc.c keyboard.c mouse.c utils.c timer.c interrupts_func.c fast_math.c xpm_utils.c rtc.c uart.c makecode_map.c menu.c proj_func.c rectangle.c font.c ent.c proj.c hltp.c zombies.c campaign.c singleplayer.c chat.c scoreboards.c
 IPATHS=-I./include -I./libs/graph/include -I./libs/kbc/include -I./libs/rtc/include -I./libs/timer/include -I./libs/uart/include -I./libs/classes/include -I./libs/utils/include -I./maps -I./media/xpm
 
-CPPFLAGS += -pedantic ${IPATHS} -D LCOM_MACRO #-D __LCOM_OPTIMIZED__ -Wall -Wextra -Wshadow -Wunreachable-code #-Weverything -Wno-padded -Wno-unused-macros
+CPPFLAGS += -pedantic ${IPATHS} -D LCOM_MACRO -D __LCOM_OPTIMIZED__ -Wall -Wextra -Wshadow -Wunreachable-code #-Weverything -Wno-padded -Wno-unused-macros
 
 DPADD += ${LIBLCF}
 LDADD += -llcf
