summaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
Diffstat (limited to 'src/client')
-rw-r--r--src/client/chat.c2
-rwxr-xr-xsrc/client/font.c1
-rwxr-xr-xsrc/client/image.c39
-rwxr-xr-xsrc/client/image.h13
-rwxr-xr-xsrc/client/layer.c2
-rwxr-xr-xsrc/client/layer.h5
-rw-r--r--src/client/panel.c8
-rw-r--r--src/client/radar.c2
8 files changed, 48 insertions, 24 deletions
diff --git a/src/client/chat.c b/src/client/chat.c
index bad3826..a50af88 100644
--- a/src/client/chat.c
+++ b/src/client/chat.c
@@ -14,7 +14,7 @@
#include "chat.h"
#include "font.h"
-static SDL_Surface *g_chat;
+static image_t *g_chat;
static list_t *listText;
diff --git a/src/client/font.c b/src/client/font.c
index 0e67921..b81c398 100755
--- a/src/client/font.c
+++ b/src/client/font.c
@@ -1,4 +1,3 @@
-
#include "main.h"
#include "interface.h"
#include "font.h"
diff --git a/src/client/image.c b/src/client/image.c
index 3c3b40f..e76e1cf 100755
--- a/src/client/image.c
+++ b/src/client/image.c
@@ -60,10 +60,25 @@ static SDL_Surface *loadImage(const char *filename, int alpha)
return ret;
}
-static void destroySDLSurface(void *p)
+image_t* newImage(SDL_Surface *surface)
+{
+ image_t *new;
+
+ assert( surface != NULL );
+
+ new = malloc( sizeof(image_t) );
+ new->image = surface;
+ new->w = surface->w;
+ new->h = surface->h;
+
+ return new;
+}
+
+static void destroyImage(image_t *p)
{
assert( p != NULL );
- SDL_FreeSurface((SDL_Surface *)p);
+ SDL_FreeSurface((SDL_Surface *)p->image);
+ free(p);
}
/*
@@ -72,15 +87,17 @@ static void destroySDLSurface(void *p)
* *name - nazov obrazku ( pouzije sa ako vyhadavaci retazec v zazanem )
* alpha - 0 - nema alpha kanal | 1 - ma alpha kanal
*/
-SDL_Surface* addImageData(char *file, int alpha, char *name, char *group)
+image_t* addImageData(char *file, int alpha, char *name, char *group)
{
- SDL_Surface *new;
+ SDL_Surface *surface;
+ image_t *new;
assert( file != NULL );
assert( name != NULL );
assert( group != NULL );
- new = loadImage(file, alpha);
+ surface = loadImage(file, alpha);
+ new = newImage(surface);
addItemToStorage(listStorage, group, name, new );
@@ -93,7 +110,7 @@ SDL_Surface* addImageData(char *file, int alpha, char *name, char *group)
* Vrati odkaz na image_data v globalnom zozname obrazkov
* a nazvom *s
*/
-SDL_Surface* getImage(char *group, char *name)
+image_t* getImage(char *group, char *name)
{
assert( group != NULL );
assert( name != NULL );
@@ -106,17 +123,17 @@ void delImage(char *group, char *name)
assert( group != NULL );
assert( name != NULL );
- delItemFromStorage(listStorage, group, name, destroySDLSurface);
+ delItemFromStorage(listStorage, group, name, destroyImage);
}
void delAllImageInGroup(char *group)
{
assert( group != NULL );
- delAllItemFromStorage(listStorage, group, destroySDLSurface);
+ delAllItemFromStorage(listStorage, group, destroyImage);
}
-void drawImage(SDL_Surface *p, int x,int y, int px, int py, int w, int h)
+void drawImage(image_t *p, int x,int y, int px, int py, int w, int h)
{
static SDL_Surface *screen = NULL;
SDL_Rect dst_rect, src_rect;
@@ -134,7 +151,7 @@ void drawImage(SDL_Surface *p, int x,int y, int px, int py, int w, int h)
src_rect.w = w;
src_rect.h = h;
- SDL_BlitSurface(p, &src_rect, screen, &dst_rect);
+ SDL_BlitSurface(p->image, &src_rect, screen, &dst_rect);
}
/*
@@ -143,7 +160,7 @@ void drawImage(SDL_Surface *p, int x,int y, int px, int py, int w, int h)
void quitImageData()
{
printf("quit image database..\n");
- destroyStorage(listStorage, destroySDLSurface);
+ destroyStorage(listStorage, destroyImage);
isImageDataInit = FALSE;
}
diff --git a/src/client/image.h b/src/client/image.h
index e80efb5..c154ff0 100755
--- a/src/client/image.h
+++ b/src/client/image.h
@@ -23,13 +23,20 @@ typedef struct image_struct
} image_data_t;
*/
+typedef struct image_struct
+{
+ int w;
+ int h;
+ SDL_Surface *image;
+} image_t;
+
extern bool_t isImageInicialized();
extern void initImageData();
-extern SDL_Surface* addImageData(char *file, int alpha, char *name, char *group);
-extern SDL_Surface* getImage(char *group, char *name);
+extern image_t* addImageData(char *file, int alpha, char *name, char *group);
+extern image_t* getImage(char *group, char *name);
extern void delImage(char *group, char *name);
extern void delAllImageInGroup(char *group);
-extern void drawImage(SDL_Surface *p, int x,int y, int px, int py, int w, int h);
+extern void drawImage(image_t *p, int x,int y, int px, int py, int w, int h);
extern void quitImageData();
#endif
diff --git a/src/client/layer.c b/src/client/layer.c
index 102af1c..efac264 100755
--- a/src/client/layer.c
+++ b/src/client/layer.c
@@ -37,7 +37,7 @@ void initLayer()
* px py pw ph - suradnica casti obrazka *img ktora sa ma zobrazit
* layer - vrstva na ktorej sa zobrazi obrazok
*/
-void addLayer(SDL_Surface *img,
+void addLayer(image_t *img,
int x,int y, int px,int py,
int w,int h, int player)
{
diff --git a/src/client/layer.h b/src/client/layer.h
index 04a4617..f61a162 100755
--- a/src/client/layer.h
+++ b/src/client/layer.h
@@ -4,6 +4,7 @@
#define MY_LAYER_H
#include "main.h"
+#include "image.h"
typedef struct layer_str
{
@@ -21,7 +22,7 @@ typedef struct layer_str
int layer;
- SDL_Surface *image; //dane surfrace
+ image_t *image; //dane surfrace
} layer_t;
extern bool_t isLayerInicialized();
@@ -38,7 +39,7 @@ extern void initLayer();
* (0 - pod tuxancami | 1 - na tej istej ako tuxanci | 2 - nad tuxancami)
*/
-extern void addLayer(SDL_Surface *img,
+extern void addLayer(image_t *img,
int x,int y, int px,int py,
int w,int h, int player);
diff --git a/src/client/panel.c b/src/client/panel.c
index 7a5b3e2..f63e481 100644
--- a/src/client/panel.c
+++ b/src/client/panel.c
@@ -12,10 +12,10 @@
#include "font.h"
#include "chat.h"
-static SDL_Surface *g_panel;
-static SDL_Surface *g_shot;
-static SDL_Surface *g_icon[ITEM_COUNT];
-static SDL_Surface *g_bonus;
+static image_t *g_panel;
+static image_t *g_shot;
+static image_t *g_icon[ITEM_COUNT];
+static image_t *g_bonus;
static bool_t isPanelInit = FALSE;
diff --git a/src/client/radar.c b/src/client/radar.c
index 49c72de..afa48d4 100644
--- a/src/client/radar.c
+++ b/src/client/radar.c
@@ -12,7 +12,7 @@
#include "image.h"
#include "radar.h"
-static SDL_Surface *g_radar;
+static image_t *g_radar;
static list_t *listRadar;
typedef struct radar_item_struct