summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomas Chvatal <scarabeus@gentoo.org>2009-03-23 18:33:33 +0100
committerTomas Chvatal <scarabeus@gentoo.org>2009-03-23 18:33:33 +0100
commit6763baff401bb712bc883dc1597e54e926607221 (patch)
tree875deaeac4d1f117f87afb646c5a6f92cd77856f
parent06bcd715e763387b5f7eade29d582f42156cc3a9 (diff)
remove old layer code. We dont need to keep it. scm takes care for that.
-rw-r--r--src/client/layer.c73
-rw-r--r--src/idget_image.h widget_picture.h89
2 files changed, 89 insertions, 73 deletions
diff --git a/src/client/layer.c b/src/client/layer.c
index d796603..2bf8cde 100644
--- a/src/client/layer.c
+++ b/src/client/layer.c
@@ -30,79 +30,6 @@ void initLayer()
isLayerInit = TRUE;
}
-#if 0
-/*
- * Add image to queue for rendering
- * *img - image to be rendered
- * x,y - coordinates where to draw the image
- * w,h - width and height of rendered part of image
- * px,py - coordinates of upper left corner of rendered part of image
- * layer - on which layer to draw
- * (0 - under tuxanci | 1 - same as tuxanci | 2 - over tuxancami)
- */
-void addLayer(image_t * img, int x, int y, int px, int py, int w, int h, int player)
-{
- layer_t *new;
- layer_t *actual;
- int i;
-
- assert(img != NULL);
-
- new = malloc(sizeof(layer_t));
- new->x = x;
- new->y = y;
- new->w = w;
- new->h = h;
- new->px = px;
- new->py = py;
- new->layer = player;
- new->image = img;
-
- // first, we check if we should insert our image at the begining of the queue
- if (listLayer->count == 0) {
- addList(listLayer, new);
- return;
- };
-
- if (((layer_t *) listLayer->list[0])->layer > new->layer) {
- insList(listLayer, 0, new);
- return;
- };
-
- // here we are sure, that we want to insert it somewhere else than the begining
- for (i = 0; i < listLayer->count; i++) {
- actual = getList(listLayer, i);
- // if we are at the same layer, we apply insert sort in (y+h)
- while ((actual->layer == new->layer)) {
- if ((new->y + new->h) < (actual->y + actual->h)) {
- insList(listLayer, i, new);
- return;
- };
-
- i++;
- if (i >= listLayer->count)
- break;
- actual = getList(listLayer, i);
-
- if (actual->layer > new->layer) {
- insList(listLayer, i, new);
- return;
- };
- };
-
- if (i >= listLayer->count)
- break;
-
- // we check if we are on layer, that is not present yet
- if (actual->layer > new->layer) {
- insList(listLayer, i, new);
- return;
- };
- };
- addList(listLayer, new);
-}
-#endif
-
/*
* Add image to queue for rendering
* *img - image to be rendered
diff --git a/src/idget_image.h widget_picture.h b/src/idget_image.h widget_picture.h
new file mode 100644
index 0000000..89476ff
--- /dev/null
+++ b/src/idget_image.h widget_picture.h
@@ -0,0 +1,89 @@
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+
+#include "main.h"
+#include "list.h"
+#include "textFile.h"
+#include "highScore.h"
+
+static textFile_t *textFile;
+
+void initHighScore(char *file)
+{
+ int i;
+
+ textFile = loadTextFile(file);
+
+ if (textFile == NULL) {
+ fprintf(stderr, _("I am unable to load: \"%s\"!\n"), file);
+ fprintf(stderr, _("Creating: \"%s\"\n"), file);
+ textFile = newTextFile(file);
+ } else {
+
+ DEBUG_MSG(_("Scorefile: \"%s\"\n"), file);
+ return;
+ }
+
+ if (textFile == NULL) {
+ fprintf(stderr, _("I was unable to create: \"%s\"!\n"), file);
+ return;
+ }
+
+ for (i = 0; i < HIGHSCORE_MAX_PLAYERS; i++) {
+ addList(textFile->text, strdup("no_name 0"));
+ }
+
+ saveTextFile(textFile);
+}
+
+int addPlayerInHighScore(char *name, int score)
+{
+ int i;
+
+ if (score <= 0) {
+ return -1; // Ha ha ha
+ }
+
+ for (i = 0; i < HIGHSCORE_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, HIGHSCORE_MAX_PLAYERS, free);
+ //printTextFile(textFile);
+ saveTextFile(textFile);
+
+ return 0;
+ }
+ }
+
+ return -1;
+}
+
+char *getTableItem(int index)
+{
+ if (textFile != NULL && index >= 0 && index < textFile->text->count) {
+ return (char *) textFile->text->list[index];
+ }
+
+ return NULL;
+}
+
+void quitHighScore()
+{
+ if (textFile != NULL) {
+ saveTextFile(textFile);
+ destroyTextFile(textFile);
+ }
+}