[Tux4kids-commits] r1332 - branches/commonification/tux4kids-common/trunk/src

Bolesław Kulbabiński bolekk-guest at alioth.debian.org
Mon Aug 3 00:34:33 UTC 2009


Author: bolekk-guest
Date: 2009-08-03 00:34:32 +0000 (Mon, 03 Aug 2009)
New Revision: 1332

Modified:
   branches/commonification/tux4kids-common/trunk/src/t4k-audio.c
   branches/commonification/tux4kids-common/trunk/src/t4k-menu.c
   branches/commonification/tux4kids-common/trunk/src/t4k-sdl.c
   branches/commonification/tux4kids-common/trunk/src/tux4kids-common.h
Log:
small changes to t4k-common

Modified: branches/commonification/tux4kids-common/trunk/src/t4k-audio.c
===================================================================
--- branches/commonification/tux4kids-common/trunk/src/t4k-audio.c	2009-08-02 23:49:28 UTC (rev 1331)
+++ branches/commonification/tux4kids-common/trunk/src/t4k-audio.c	2009-08-03 00:34:32 UTC (rev 1332)
@@ -34,10 +34,10 @@
 /* audioMusicLoad attempts to load and play the music file
  * Note: loops == -1 means forever
  */
-void AudioMusicLoad(Mix_Music* music, int loops)
+void AudioMusicLoad(char* music_path, int loops)
 {
   audioMusicUnload(); // make sure defaultMusic is clear
-  default_music = music;
+  default_music = LoadMusic(music_path);
   Mix_PlayMusic(default_music, loops);
 }
 

Modified: branches/commonification/tux4kids-common/trunk/src/t4k-menu.c
===================================================================
--- branches/commonification/tux4kids-common/trunk/src/t4k-menu.c	2009-08-02 23:49:28 UTC (rev 1331)
+++ branches/commonification/tux4kids-common/trunk/src/t4k-menu.c	2009-08-03 00:34:32 UTC (rev 1332)
@@ -59,7 +59,7 @@
 
 Mix_Chunk* snd_click;
 Mix_Chunk* snd_hover;
-Mix_Music* menu_music;
+char* music_path;
 
 #define N_OF_MENUS 10
 MenuNode* menus[N_OF_MENUS];
@@ -68,7 +68,7 @@
 int curr_font_size;
 
 /* buffer size used when reading attributes or names */
-const int buf_size = 128;
+const int buf_size = 512;
 
 /* actions available while viewing the menu */
 enum { NONE, CLICK, PAGEUP, PAGEDOWN, STOP_ESC, RESIZED };
@@ -79,7 +79,7 @@
 SDL_Surface *stop_button, *prev_arrow, *next_arrow, *prev_gray, *next_gray;
 
 /*TODO: move these constants into a config file (maybe together with
-  titleGetScreen() paths and rects ? ) */
+  titlescreen paths and rects ? ) */
 const float menu_pos[4] = {0.38, 0.23, 0.55, 0.72};
 const float stop_pos[4] = {0.94, 0.0, 0.06, 0.06};
 const float prev_pos[4] = {0.87, 0.93, 0.06, 0.06};
@@ -103,9 +103,9 @@
 void            free_menu(MenuNode* menu);
 
 SDL_Surface**   render_buttons(MenuNode* menu, bool selected);
-void            prerender_menu(MenuNode* menu);
 char*           find_longest_text(MenuNode* menu, int* length);
 void            set_font_size();
+void            prerender_menu(MenuNode* menu);
 
 
 /* initialization of menu module */
@@ -115,11 +115,11 @@
   activities = acts;
 }
 
-void SetMenuSounds(Mix_Music* music, Mix_Chunk* click, Mix_Chunk* hover)
+void SetMenuSounds(char* mus_path, Mix_Chunk* click, Mix_Chunk* hover)
 {
   snd_click = click;
   snd_hover = hover;
-  menu_music = music;
+  music_path = mus_path;
 }
 
 void SetImagePathPrefix(char* pref)
@@ -273,9 +273,9 @@
   }
 }
 
-/* create a simple one-level menu without sprites.
-   all given strings are copied */
-void CreateOneLevelMenu(int index, int items, char** item_names, char* title, char* trailer)
+/* create a simple one-level menu.
+   All given strings are copied */
+void CreateOneLevelMenu(int index, int items, char** item_names, char** sprite_names, char* title, char* trailer)
 {
   MenuNode* menu = create_empty_node();
   int i;
@@ -291,6 +291,8 @@
   {
     menu->submenu[i] = create_empty_node();
     menu->submenu[i]->title = strdup(item_names[i]);
+    if(sprite_names && sprite_names[i])
+      menu->submenu[i]->icon_name = strdup(sprite_names[i]);
     menu->submenu[i]->activity = i;
   }
 
@@ -594,9 +596,9 @@
                 {
                   AudioMusicUnload();
                 }
-                else if(menu_music)
+                else if(music_path)
                 {
-                  AudioMusicLoad(menu_music, -1);
+                  AudioMusicLoad(music_path, -1);
                 }
                 break;
               }
@@ -874,6 +876,11 @@
   }
 }
 
+void PrerenderMenu(int index)
+{
+  prerender_menu(menus[index]);
+}
+
 char* find_longest_text(MenuNode* menu, int* length)
 {
   SDL_Surface* text = NULL;
@@ -955,7 +962,7 @@
   SetRect(&stop_rect, stop_pos);
   if(stop_button)
     SDL_FreeSurface(stop_button);
-  sprintf("%s%s", data_prefix, stop_path);
+  sprintf(fn, "%s%s", data_prefix, stop_path);
   stop_button = LoadImageOfBoundingBox(fn, IMG_ALPHA, stop_rect.w, stop_rect.h);
   /* move button to the right */
   stop_rect.x = GetScreen()->w - stop_button->w;
@@ -963,11 +970,11 @@
   SetRect(&prev_rect, prev_pos);
   if(prev_arrow)
     SDL_FreeSurface(prev_arrow);
-  sprintf("%s%s", data_prefix, prev_path);
+  sprintf(fn, "%s%s", data_prefix, prev_path);
   prev_arrow = LoadImageOfBoundingBox(fn, IMG_ALPHA, prev_rect.w, prev_rect.h);
   if(prev_gray)
     SDL_FreeSurface(prev_gray);
-  sprintf("%s%s", data_prefix, prev_gray_path);
+  sprintf(fn, "%s%s", data_prefix, prev_gray_path);
   prev_gray = LoadImageOfBoundingBox(fn, IMG_ALPHA, prev_rect.w, prev_rect.h);
   /* move button to the right */
   prev_rect.x += prev_rect.w - prev_arrow->w;
@@ -975,24 +982,23 @@
   SetRect(&next_rect, next_pos);
   if(next_arrow)
     SDL_FreeSurface(next_arrow);
-  sprintf("%s%s", data_prefix, next_path);
+  sprintf(fn, "%s%s", data_prefix, next_path);
   next_arrow = LoadImageOfBoundingBox(fn, IMG_ALPHA, next_rect.w, next_rect.h);
   if(next_gray)
     SDL_FreeSurface(next_gray);
-  sprintf("%s%s", data_prefix, next_gray_path);
+  sprintf(fn, "%s%s", data_prefix, next_gray_path);
   next_gray = LoadImageOfBoundingBox(fn, IMG_ALPHA, next_rect.w, next_rect.h);
 
   set_font_size();
 
   for(i = 0; i < N_OF_MENUS; i++)
     if(menus[i])
-      prerender_menu(menus[i]);
+      PrerenderMenu(i);
 }
 
 void LoadMenu(int index, const char* file_name)
 {
   FILE* menu_file = NULL;
-  int i;
 
   if(menus[index])
   {

Modified: branches/commonification/tux4kids-common/trunk/src/t4k-sdl.c
===================================================================
--- branches/commonification/tux4kids-common/trunk/src/t4k-sdl.c	2009-08-02 23:49:28 UTC (rev 1331)
+++ branches/commonification/tux4kids-common/trunk/src/t4k-sdl.c	2009-08-03 00:34:32 UTC (rev 1332)
@@ -39,7 +39,7 @@
 */
 SDL_Surface* GetScreen()
 {
-#ifdef TUXMATH_DEBUG
+  DEBUGCODE(debug_sdl)
   {
     if (screen != SDL_GetVideoSurface() )
     {
@@ -47,7 +47,6 @@
       screen = SDL_GetVideoSurface();
     }
   }
-#endif
   return screen;
 }
 
@@ -709,8 +708,8 @@
 /* We cache fonts here once loaded to improve performance: */
 TTF_Font* font_list[MAX_FONT_SIZE + 1] = {NULL};
 static void free_font_list(void);
-//static TTF_Font* get_font(int size);
-//static TTF_Font* load_font(const char* font_name, int font_size);
+static TTF_Font* get_font(int size);
+static TTF_Font* load_font(const char* font_name, int font_size);
 #endif
 
 

Modified: branches/commonification/tux4kids-common/trunk/src/tux4kids-common.h
===================================================================
--- branches/commonification/tux4kids-common/trunk/src/tux4kids-common.h	2009-08-02 23:49:28 UTC (rev 1331)
+++ branches/commonification/tux4kids-common/trunk/src/tux4kids-common.h	2009-08-03 00:34:32 UTC (rev 1332)
@@ -55,11 +55,12 @@
 extern SDL_Surface *stop_button, *prev_arrow, *next_arrow, *prev_gray, *next_gray;
 
 void            SetActivitiesList(int num, char** acts);
-void            SetMenuSounds(Mix_Music* music, Mix_Chunk* click, Mix_Chunk* hover);
+void            SetMenuSounds(char* mus_path, Mix_Chunk* click, Mix_Chunk* hover);
 void            SetImagePathPrefix(char* pref);
 
-void            CreateOneLevelMenu(int index, int items, char** item_names, char* title, char* trailer);
+void            CreateOneLevelMenu(int index, int items, char** item_names, char** sprite_names, char* title, char* trailer);
 int             RunMenu(int index, bool return_choice, void (*draw_background)(), int (*handle_event)(SDL_Event*), void (*handle_animations)(), int (*handle_activity)(int, int));
+void            PrerenderMenu(int index);
 void            PrerenderAll();
 void            LoadMenu(int index, const char* file_name);
 void            UnloadMenus(void);
@@ -80,8 +81,8 @@
 void            UpdateRect(SDL_Surface* surf, SDL_Rect* rect);
 
 void            DarkenScreen(Uint8 bits);
-//void            ChangeWindowSize(int new_res_x, int new_res_y);
-//void            SwitchScreenMode(void);
+void            ChangeWindowSize(int new_res_x, int new_res_y);
+void            SwitchScreenMode(void);
 
 SDL_EventType   WaitForEvent(SDL_EventMask events);
 SDL_Surface*    zoom(SDL_Surface* src, int new_w, int new_h);
@@ -123,7 +124,7 @@
 /* from tk4-loaders.c */
 
 void            PlaySound(Mix_Chunk* sound);
-void            AudioMusicLoad(Mix_Music* music, int loops);
+void            AudioMusicLoad(char* music_path, int loops);
 void            AudioMusicUnload();
 bool            IsPlayingMusic();
 void            AudioMusicPlay(Mix_Music *musicData, int loops);




More information about the Tux4kids-commits mailing list