[Tux4kids-commits] r1402 - in branches/commonification: tux4kids-common/trunk/src tuxmath/trunk/src tuxtype/trunk/src
Bolesław Kulbabiński
bolekk-guest at alioth.debian.org
Sat Aug 8 22:30:05 UTC 2009
Author: bolekk-guest
Date: 2009-08-08 22:30:05 +0000 (Sat, 08 Aug 2009)
New Revision: 1402
Modified:
branches/commonification/tux4kids-common/trunk/src/
branches/commonification/tux4kids-common/trunk/src/t4k-audio.c
branches/commonification/tux4kids-common/trunk/src/t4k-loaders.c
branches/commonification/tux4kids-common/trunk/src/t4k-menu.c
branches/commonification/tux4kids-common/trunk/src/tux4kids-common.h
branches/commonification/tuxmath/trunk/src/loaders.c
branches/commonification/tuxmath/trunk/src/menu.c
branches/commonification/tuxmath/trunk/src/menu.h
branches/commonification/tuxmath/trunk/src/tuxmath.h
branches/commonification/tuxtype/trunk/src/SDL_extras.h
branches/commonification/tuxtype/trunk/src/loaders.c
branches/commonification/tuxtype/trunk/src/menu.c
branches/commonification/tuxtype/trunk/src/menu.h
Log:
fixed bug in sprite loader
Property changes on: branches/commonification/tux4kids-common/trunk/src
___________________________________________________________________
Modified: svn:ignore
- CMakeFiles
cmake_install.cmake
Makefile
+ CMakeFiles
CMakeCache.txt
cmake_install.cmake
Makefile
Modified: branches/commonification/tux4kids-common/trunk/src/t4k-audio.c
===================================================================
--- branches/commonification/tux4kids-common/trunk/src/t4k-audio.c 2009-08-08 21:25:04 UTC (rev 1401)
+++ branches/commonification/tux4kids-common/trunk/src/t4k-audio.c 2009-08-08 22:30:05 UTC (rev 1402)
@@ -24,7 +24,7 @@
#include "tux4kids-common.h"
#include "t4k-globals.h"
-Mix_Music *default_music;
+static Mix_Music *default_music = NULL;
void PlaySound(Mix_Chunk* sound)
{
Modified: branches/commonification/tux4kids-common/trunk/src/t4k-loaders.c
===================================================================
--- branches/commonification/tux4kids-common/trunk/src/t4k-loaders.c 2009-08-08 21:25:04 UTC (rev 1401)
+++ branches/commonification/tux4kids-common/trunk/src/t4k-loaders.c 2009-08-08 22:30:05 UTC (rev 1402)
@@ -500,7 +500,7 @@
if(!new_sprite)
{
/* SVG sprite was not loaded, try to load it frame by frame from PNG files */
- new_sprite = malloc(sizeof(sprite));
+ new_sprite = (sprite*) malloc(sizeof(sprite));
sprintf(fn, "%sd.png", name); // The 'd' means the default image
if(proportional)
@@ -511,6 +511,7 @@
if(!new_sprite->default_img)
DEBUGMSG(debug_loaders, "load_sprite(): failed to load default image for %s\n", name);
+ new_sprite->cur = 0;
for(i = 0; i < MAX_SPRITE_FRAMES; i++)
{
sprintf(fn, "%s%d.png", name, i);
@@ -521,12 +522,13 @@
if(new_sprite->frame[i] == NULL)
{
- new_sprite->cur = 0;
- new_sprite->num_frames = i;
break;
}
else
+ {
DEBUGMSG(debug_loaders, "load_sprite(): loaded frame %d of %s\n", i, name);
+ new_sprite->num_frames = i + 1;
+ }
}
}
Modified: branches/commonification/tux4kids-common/trunk/src/t4k-menu.c
===================================================================
--- branches/commonification/tux4kids-common/trunk/src/t4k-menu.c 2009-08-08 21:25:04 UTC (rev 1401)
+++ branches/commonification/tux4kids-common/trunk/src/t4k-menu.c 2009-08-08 22:30:05 UTC (rev 1402)
@@ -53,7 +53,7 @@
#define RUN_MAIN_MENU -3
int n_of_activities;
-char** activities;
+static char** activities;
char* data_prefix;
@@ -645,7 +645,6 @@
switch(action)
{
case RESIZED:
- RenderTitleScreen();
menu->first_entry = 0;
PrerenderAll();
stop = true;
@@ -817,6 +816,7 @@
bool found_icons = false;
char filename[buf_size];
+ DEBUGMSG(debug_menu, "Entering prerender_menu()\n");
if(NULL == menu)
{
DEBUGMSG(debug_menu, "prerender_menu(): NULL pointer, exiting !\n");
@@ -867,7 +867,10 @@
curr_node->text_rect.w = max_text_w;
if(curr_node->icon)
+ {
FreeSprite(curr_node->icon);
+ curr_node->icon = NULL;
+ }
if(curr_node->icon_name)
{
@@ -880,6 +883,7 @@
prerender_menu(menu->submenu[i]);
}
+ DEBUGMSG(debug_menu, "Leaving prerender_menu()\n");
}
void PrerenderMenu(int index)
@@ -893,6 +897,7 @@
char *ret = NULL, *temp = NULL;
int i;
+ DEBUGMSG(debug_menu, "Entering find_longest_text()\n");
if(menu->submenu_size == 0)
{
text = SimpleText(_(menu->title), curr_font_size, &black);
@@ -912,6 +917,7 @@
ret = temp;
}
}
+ DEBUGMSG(debug_menu, "Leaving find_longest_text()\n");
return ret;
}
Modified: branches/commonification/tux4kids-common/trunk/src/tux4kids-common.h
===================================================================
--- branches/commonification/tux4kids-common/trunk/src/tux4kids-common.h 2009-08-08 21:25:04 UTC (rev 1401)
+++ branches/commonification/tux4kids-common/trunk/src/tux4kids-common.h 2009-08-08 22:30:05 UTC (rev 1402)
@@ -40,7 +40,7 @@
extern SDL_Surface* screen;
-#define MAX_SPRITE_FRAMES 10
+#define MAX_SPRITE_FRAMES 15
typedef struct {
SDL_Surface *frame[MAX_SPRITE_FRAMES];
Modified: branches/commonification/tuxmath/trunk/src/loaders.c
===================================================================
--- branches/commonification/tuxmath/trunk/src/loaders.c 2009-08-08 21:25:04 UTC (rev 1401)
+++ branches/commonification/tuxmath/trunk/src/loaders.c 2009-08-08 22:30:05 UTC (rev 1402)
@@ -49,27 +49,27 @@
-int check_file(const char* file)
+int CheckFile(const char* file)
{
FILE* fp = NULL;
if (!file)
{
- DEBUGMSG(debug_loaders, "check_file(): invalid char* argument!\n");
+ DEBUGMSG(debug_loaders, "CheckFile(): invalid char* argument!\n");
return 0;
}
- DEBUGMSG(debug_loaders, "check_file(): checking: %s\n", file);
+ DEBUGMSG(debug_loaders, "CheckFile(): checking: %s\n", file);
fp = fopen(file, "r");
if (fp)
{
- DEBUGMSG(debug_loaders, "check_file(): Opened successfully as FILE\n");
+ DEBUGMSG(debug_loaders, "CheckFile(): Opened successfully as FILE\n");
fclose(fp);
return 1;
}
- DEBUGMSG(debug_loaders, "check_file(): Unable to open '%s' as either FILE or DIR\n", file);
+ DEBUGMSG(debug_loaders, "CheckFile(): Unable to open '%s' as either FILE or DIR\n", file);
return 0;
}
@@ -362,7 +362,6 @@
width = w;
height = h;
}
- DEBUGMSG(debug_loaders, "load_image(): Resizing %s to %d x %d\n", file_name, width, height);
final_pic = zoom(loaded_pic, width, height);
SDL_FreeSurface(loaded_pic);
loaded_pic = final_pic;
@@ -475,7 +474,7 @@
#ifdef HAVE_RSVG
/* check if SVG sprite file is present */
sprintf(fn, "%s.svg", name);
- if(1 == check_file(fn))
+ if(1 == CheckFile(fn))
{
if(proportional)
{
@@ -504,7 +503,7 @@
if(!new_sprite)
{
/* SVG sprite was not loaded, try to load it frame by frame from PNG files */
- new_sprite = malloc(sizeof(sprite));
+ new_sprite = (sprite*) malloc(sizeof(sprite));
sprintf(fn, "%sd.png", name); // The 'd' means the default image
if(proportional)
@@ -515,6 +514,7 @@
if(!new_sprite->default_img)
DEBUGMSG(debug_loaders, "load_sprite(): failed to load default image for %s\n", name);
+ new_sprite->cur = 0;
for(i = 0; i < MAX_SPRITE_FRAMES; i++)
{
sprintf(fn, "%s%d.png", name, i);
@@ -525,12 +525,13 @@
if(new_sprite->frame[i] == NULL)
{
- new_sprite->cur = 0;
- new_sprite->num_frames = i;
break;
}
else
+ {
DEBUGMSG(debug_loaders, "load_sprite(): loaded frame %d of %s\n", i, name);
+ new_sprite->num_frames = i + 1;
+ }
}
}
@@ -609,7 +610,7 @@
Mix_Music* tempMusic = NULL;
sprintf(fn, "%s", datafile);
- if (1 != check_file(fn))
+ if (1 != CheckFile(fn))
{
fprintf(stderr, "LoadMusic(): %s not found\n\n", fn);
return NULL;
@@ -625,4 +626,5 @@
return tempMusic;
}
+
#endif //HAVE_LIBT4KCOMMON
Modified: branches/commonification/tuxmath/trunk/src/menu.c
===================================================================
--- branches/commonification/tuxmath/trunk/src/menu.c 2009-08-08 21:25:04 UTC (rev 1401)
+++ branches/commonification/tuxmath/trunk/src/menu.c 2009-08-08 22:30:05 UTC (rev 1402)
@@ -52,18 +52,12 @@
typedef struct mNode MenuNode;
-/* titlescreen & menu frame rate */
-#define MAX_FPS 30
-/* number of "real" frames per one sprite frame */
-#define SPRITE_FRAME_DELAY 6
-
-
#define QUIT -2
#define STOP -1
#define RUN_MAIN_MENU -3
int n_of_activities;
-char** activities;
+static char** activities;
char* data_prefix;
@@ -655,7 +649,6 @@
switch(action)
{
case RESIZED:
- RenderTitleScreen();
menu->first_entry = 0;
PrerenderAll();
stop = true;
@@ -827,6 +820,7 @@
bool found_icons = false;
char filename[buf_size];
+ DEBUGMSG(debug_menu, "Entering prerender_menu()\n");
if(NULL == menu)
{
DEBUGMSG(debug_menu, "prerender_menu(): NULL pointer, exiting !\n");
@@ -877,7 +871,10 @@
curr_node->text_rect.w = max_text_w;
if(curr_node->icon)
+ {
FreeSprite(curr_node->icon);
+ curr_node->icon = NULL;
+ }
if(curr_node->icon_name)
{
@@ -890,6 +887,7 @@
prerender_menu(menu->submenu[i]);
}
+ DEBUGMSG(debug_menu, "Leaving prerender_menu()\n");
}
void PrerenderMenu(int index)
@@ -903,6 +901,7 @@
char *ret = NULL, *temp = NULL;
int i;
+ DEBUGMSG(debug_menu, "Entering find_longest_text()\n");
if(menu->submenu_size == 0)
{
text = SimpleText(_(menu->title), curr_font_size, &black);
@@ -922,6 +921,7 @@
ret = temp;
}
}
+ DEBUGMSG(debug_menu, "Leaving find_longest_text()\n");
return ret;
}
Modified: branches/commonification/tuxmath/trunk/src/menu.h
===================================================================
--- branches/commonification/tuxmath/trunk/src/menu.h 2009-08-08 21:25:04 UTC (rev 1401)
+++ branches/commonification/tuxmath/trunk/src/menu.h 2009-08-08 22:30:05 UTC (rev 1402)
@@ -18,6 +18,9 @@
#include "tuxmath.h"
#ifndef HAVE_LIBT4KCOMMON
+
+#define MAX_FPS 30
+
extern SDL_Rect menu_rect, stop_rect, prev_rect, next_rect;
extern SDL_Surface *stop_button, *prev_arrow, *next_arrow, *prev_gray, *next_gray;
Modified: branches/commonification/tuxmath/trunk/src/tuxmath.h
===================================================================
--- branches/commonification/tuxmath/trunk/src/tuxmath.h 2009-08-08 21:25:04 UTC (rev 1401)
+++ branches/commonification/tuxmath/trunk/src/tuxmath.h 2009-08-08 22:30:05 UTC (rev 1402)
@@ -10,7 +10,7 @@
Part of "Tux4Kids" Project
http://www.tux4kids.org/
-
+
Added March 2, 2006
Copyright: See COPYING file that comes with this distribution
@@ -48,7 +48,7 @@
#include "globals.h"
#ifndef HAVE_LIBT4KCOMMON
-#define MAX_SPRITE_FRAMES 30
+#define MAX_SPRITE_FRAMES 15
typedef struct {
SDL_Surface *frame[MAX_SPRITE_FRAMES];
Modified: branches/commonification/tuxtype/trunk/src/SDL_extras.h
===================================================================
--- branches/commonification/tuxtype/trunk/src/SDL_extras.h 2009-08-08 21:25:04 UTC (rev 1401)
+++ branches/commonification/tuxtype/trunk/src/SDL_extras.h 2009-08-08 22:30:05 UTC (rev 1402)
@@ -37,7 +37,7 @@
//extra bkgd border around "erased" images.
#define ERASE_MARGIN 5
#define PIXEL_BITS 32
-#define MAX_SPRITE_FRAMES 30
+#define MAX_SPRITE_FRAMES 15
enum
{
Modified: branches/commonification/tuxtype/trunk/src/loaders.c
===================================================================
--- branches/commonification/tuxtype/trunk/src/loaders.c 2009-08-08 21:25:04 UTC (rev 1401)
+++ branches/commonification/tuxtype/trunk/src/loaders.c 2009-08-08 22:30:05 UTC (rev 1402)
@@ -1,22 +1,27 @@
-/***************************************************************************
- - file: loaders.c
- - description: Functions to load multimedia for Tux Typing
- -------------------
- begin : Thu May 4 2000
- copyright : (C) 2000 by Sam Hart
- : (C) 2003 by Jesse Andrews
- email : tuxtype-dev at tux4kids.net
- ***************************************************************************/
+/*
+ loaders.c
-/***************************************************************************
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- ***************************************************************************/
+ Functions responsible for loading multimedia.
+ begin : Thu May 4 2000
+ copyright : (C) 2000 by Sam Hart
+ : (C) 2003 by Jesse Andrews
+ email : tuxtype-dev at tux4kids.net
+
+ Modified for use in tuxmath by David Bruce - 2006.
+ email : <dbruce at tampabay.rr.com>
+ <tuxmath-devel at lists.sourceforge.net>
+
+ Modified to support SVG by Boleslaw Kulbabinski - 2009
+ email : <bkulbabinski at gmail.com>
+
+ Part of "Tux4Kids" Project
+ http://www.tux4kids.com/
+
+ Copyright: See COPYING file that comes with this distribution.
+*/
+
+
#include "globals.h"
#include "funcs.h"
#include "compiler.h"
@@ -272,21 +277,21 @@
if (!file)
{
- DEBUGMSG(debug_loaders, "check_file(): invalid char* argument!\n");
+ DEBUGMSG(debug_loaders, "CheckFile(): invalid char* argument!\n");
return 0;
}
- DEBUGMSG(debug_loaders, "check_file(): checking: %s\n", file);
+ DEBUGMSG(debug_loaders, "CheckFile(): checking: %s\n", file);
fp = fopen(file, "r");
if (fp)
{
- DEBUGMSG(debug_loaders, "check_file(): Opened successfully as FILE\n");
+ DEBUGMSG(debug_loaders, "CheckFile(): Opened successfully as FILE\n");
fclose(fp);
return 1;
}
- DEBUGMSG(debug_loaders, "check_file(): Unable to open '%s' as either FILE or DIR\n", file);
+ DEBUGMSG(debug_loaders, "CheckFile(): Unable to open '%s' as either FILE or DIR\n", file);
return 0;
}
@@ -720,7 +725,7 @@
if(!new_sprite)
{
/* SVG sprite was not loaded, try to load it frame by frame from PNG files */
- new_sprite = malloc(sizeof(sprite));
+ new_sprite = (sprite*) malloc(sizeof(sprite));
sprintf(fn, "%sd.png", name); // The 'd' means the default image
if(proportional)
@@ -731,6 +736,7 @@
if(!new_sprite->default_img)
DEBUGMSG(debug_loaders, "load_sprite(): failed to load default image for %s\n", name);
+ new_sprite->cur = 0;
for(i = 0; i < MAX_SPRITE_FRAMES; i++)
{
sprintf(fn, "%s%d.png", name, i);
@@ -741,12 +747,13 @@
if(new_sprite->frame[i] == NULL)
{
- new_sprite->cur = 0;
- new_sprite->num_frames = i;
break;
}
else
+ {
DEBUGMSG(debug_loaders, "load_sprite(): loaded frame %d of %s\n", i, name);
+ new_sprite->num_frames = i + 1;
+ }
}
}
@@ -801,6 +808,8 @@
s->cur = (s->cur + 1) % s->num_frames;
}
+
+
/* LoadSound : Load a sound/music patch from a file. */
Mix_Chunk* LoadSound( char *datafile )
{
@@ -839,4 +848,5 @@
return tempMusic;
}
+
#endif //HAVE_LIBT4KCOMMON
Modified: branches/commonification/tuxtype/trunk/src/menu.c
===================================================================
--- branches/commonification/tuxtype/trunk/src/menu.c 2009-08-08 21:25:04 UTC (rev 1401)
+++ branches/commonification/tuxtype/trunk/src/menu.c 2009-08-08 22:30:05 UTC (rev 1402)
@@ -51,12 +51,6 @@
typedef struct mNode MenuNode;
-/* titlescreen & menu frame rate */
-#define MAX_FPS 30
-/* number of "real" frames per one sprite frame */
-#define SPRITE_FRAME_DELAY 6
-
-
#define QUIT -2
#define STOP -1
#define RUN_MAIN_MENU -3
@@ -654,7 +648,6 @@
switch(action)
{
case RESIZED:
- RenderTitleScreen();
menu->first_entry = 0;
PrerenderAll();
stop = true;
@@ -826,6 +819,7 @@
bool found_icons = false;
char filename[buf_size];
+ DEBUGMSG(debug_menu, "Entering prerender_menu()\n");
if(NULL == menu)
{
DEBUGMSG(debug_menu, "prerender_menu(): NULL pointer, exiting !\n");
@@ -876,7 +870,10 @@
curr_node->text_rect.w = max_text_w;
if(curr_node->icon)
+ {
FreeSprite(curr_node->icon);
+ curr_node->icon = NULL;
+ }
if(curr_node->icon_name)
{
@@ -889,6 +886,7 @@
prerender_menu(menu->submenu[i]);
}
+ DEBUGMSG(debug_menu, "Leaving prerender_menu()\n");
}
void PrerenderMenu(int index)
@@ -902,6 +900,7 @@
char *ret = NULL, *temp = NULL;
int i;
+ DEBUGMSG(debug_menu, "Entering find_longest_text()\n");
if(menu->submenu_size == 0)
{
text = SimpleText(_(menu->title), curr_font_size, &black);
@@ -921,6 +920,7 @@
ret = temp;
}
}
+ DEBUGMSG(debug_menu, "Leaving find_longest_text()\n");
return ret;
}
Modified: branches/commonification/tuxtype/trunk/src/menu.h
===================================================================
--- branches/commonification/tuxtype/trunk/src/menu.h 2009-08-08 21:25:04 UTC (rev 1401)
+++ branches/commonification/tuxtype/trunk/src/menu.h 2009-08-08 22:30:05 UTC (rev 1402)
@@ -18,6 +18,9 @@
#include "globals.h"
#ifndef HAVE_LIBT4KCOMMON
+
+#define MAX_FPS 30
+
extern SDL_Rect menu_rect, stop_rect, prev_rect, next_rect;
extern SDL_Surface *stop_button, *prev_arrow, *next_arrow, *prev_gray, *next_gray;
More information about the Tux4kids-commits
mailing list