[Tux4kids-commits] r1314 - branches/commonification/tux4kids-common/trunk/src
Bolesław Kulbabiński
bolekk-guest at alioth.debian.org
Fri Jul 31 21:33:03 UTC 2009
Author: bolekk-guest
Date: 2009-07-31 21:33:03 +0000 (Fri, 31 Jul 2009)
New Revision: 1314
Modified:
branches/commonification/tux4kids-common/trunk/src/t4k-globals.h
branches/commonification/tux4kids-common/trunk/src/t4k-loaders.c
branches/commonification/tux4kids-common/trunk/src/t4k-main.c
branches/commonification/tux4kids-common/trunk/src/t4k-menu.c
branches/commonification/tux4kids-common/trunk/src/tux4kids-common.h
Log:
removed DATA_PREFIX from loaders in tux4kids-common
Modified: branches/commonification/tux4kids-common/trunk/src/t4k-globals.h
===================================================================
--- branches/commonification/tux4kids-common/trunk/src/t4k-globals.h 2009-07-31 20:49:25 UTC (rev 1313)
+++ branches/commonification/tux4kids-common/trunk/src/t4k-globals.h 2009-07-31 21:33:03 UTC (rev 1314)
@@ -12,8 +12,6 @@
#include "SDL.h"
-typedef enum { false, true } bool;
-
#define REG_RGBA 16,16,96,96
#define SEL_RGBA 16,16,128,128
@@ -31,8 +29,6 @@
extern const int dbg_sdl;
extern const int dbg_all;
-extern char* data_prefix;
-
extern SDL_Color red, yellow, white, black;
/* debug macros */
#define DEBUGCODE(mask) if((mask) & dbg_status)
Modified: branches/commonification/tux4kids-common/trunk/src/t4k-loaders.c
===================================================================
--- branches/commonification/tux4kids-common/trunk/src/t4k-loaders.c 2009-07-31 20:49:25 UTC (rev 1313)
+++ branches/commonification/tux4kids-common/trunk/src/t4k-loaders.c 2009-07-31 21:33:03 UTC (rev 1314)
@@ -279,7 +279,7 @@
/* run loader depending on file extension */
/* add path prefix */
- snprintf(fn, PATH_MAX, "%s/images/%s", data_prefix, file_name);
+ snprintf(fn, PATH_MAX, "%s", file_name);
fn_len = strlen(fn);
if(strcmp(fn + fn_len - 4, ".svg"))
@@ -470,7 +470,7 @@
#ifdef HAVE_RSVG
/* check if SVG sprite file is present */
- sprintf(fn, "%s/images/%s.svg", data_prefix, name);
+ sprintf(fn, "%s.svg", name);
if(1 == check_file(fn))
{
if(proportional)
@@ -589,8 +589,7 @@
Mix_Chunk* tempChunk = NULL;
char fn[PATH_MAX];
-// sprintf(fn , "%s/sounds/%s", realPath[i], datafile);
- sprintf(fn , "%s/sounds/%s", data_prefix, datafile);
+ sprintf(fn , "%s", datafile);
tempChunk = Mix_LoadWAV(fn);
if (!tempChunk)
{
@@ -605,7 +604,7 @@
char fn[PATH_MAX];
Mix_Music* tempMusic = NULL;
- sprintf( fn , "%s/sounds/%s", data_prefix, datafile );
+ sprintf(fn, "%s", datafile);
if (1 != check_file(fn))
{
fprintf(stderr, "LoadMusic(): %s not found\n\n", fn);
Modified: branches/commonification/tux4kids-common/trunk/src/t4k-main.c
===================================================================
--- branches/commonification/tux4kids-common/trunk/src/t4k-main.c 2009-07-31 20:49:25 UTC (rev 1313)
+++ branches/commonification/tux4kids-common/trunk/src/t4k-main.c 2009-07-31 21:33:03 UTC (rev 1314)
@@ -23,16 +23,13 @@
const int dbg_sdl = 1 << 10;
const int dbg_all = ~0;
-char* data_prefix;
-
SDL_Color red, yellow, white, black;
/* set global variables */
-void InitT4KCommon(int debug_flags, char* data_pref)
+void InitT4KCommon(int debug_flags)
{
dbg_status = debug_flags;
- data_prefix = data_pref;
black.r = 0x00; black.g = 0x00; black.b = 0x00;
red.r = 0xff; red.g = 0x00; red.b = 0x00;
Modified: branches/commonification/tux4kids-common/trunk/src/t4k-menu.c
===================================================================
--- branches/commonification/tux4kids-common/trunk/src/t4k-menu.c 2009-07-31 20:49:25 UTC (rev 1313)
+++ branches/commonification/tux4kids-common/trunk/src/t4k-menu.c 2009-07-31 21:33:03 UTC (rev 1314)
@@ -54,6 +54,7 @@
int n_of_activities;
char** activities;
+char* data_prefix;
Mix_Chunk* snd_click;
Mix_Chunk* snd_hover;
@@ -82,11 +83,11 @@
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};
const float next_pos[4] = {0.94, 0.93, 0.06, 0.06};
-const char* stop_path = "status/stop.svg";
-const char* prev_path = "status/left.svg";
-const char* next_path = "status/right.svg";
-const char* prev_gray_path = "status/left_gray.svg";
-const char* next_gray_path = "status/right_gray.svg";
+const char* stop_path = "/images/status/stop.svg";
+const char* prev_path = "/images/status/left.svg";
+const char* next_path = "/images/status/right.svg";
+const char* prev_gray_path = "/images/status/left_gray.svg";
+const char* next_gray_path = "/images/status/right_gray.svg";
const float button_gap = 0.2, text_h_gap = 0.4, text_w_gap = 0.5, button_radius = 0.27;
const int min_font_size = 8, default_font_size = 20, max_font_size = 40;
@@ -99,9 +100,7 @@
void read_attributes(FILE* xml_file, MenuNode* node);
MenuNode* load_menu_from_file(FILE* xml_file, MenuNode* parent);
void free_menu(MenuNode* menu);
-MenuNode* CreateOneLevelMenu(int items, char** item_names, char* title, char* trailer);
-int RunMenu(MenuNode* root, bool return_choice, void (*draw_background)(), int (*handle_event)(SDL_Event*), void (*handle_animations)(), int (*handle_activity)(int, int));
SDL_Surface** render_buttons(MenuNode* menu, bool selected);
void prerender_menu(MenuNode* menu);
char* find_longest_text(MenuNode* menu, int* length);
@@ -123,6 +122,11 @@
menu_music = music;
}
+void SetImagePathPrefix(char* pref)
+{
+ data_prefix = pref;
+}
+
/*
functions responsible for parsing menu files
and creating menu trees
@@ -271,7 +275,7 @@
/* create a simple one-level menu without sprites.
all given strings are copied */
-MenuNode* CreateOneLevelMenu(int items, char** item_names, char* title, char* trailer)
+void CreateOneLevelMenu(int index, int items, char** item_names, char* title, char* trailer)
{
MenuNode* menu = create_empty_node();
int i;
@@ -297,7 +301,7 @@
menu->submenu[items]->activity = items;
}
- return menu;
+ menus[index] = menu;
}
@@ -306,13 +310,13 @@
if return_choice = true then return chosen value instead of
running handle_activity()
this function is a modified copy of choose_menu_item() */
-int RunMenu(MenuNode* root, bool return_choice, void (*draw_background)(), int (*handle_event)(SDL_Event*), void (*handle_animations)(), int (*handle_activity)(int, int))
+int RunMenu(int index, bool return_choice, void (*draw_background)(), int (*handle_event)(SDL_Event*), void (*handle_animations)(), int (*handle_activity)(int, int))
{
SDL_Surface** menu_item_unselected = NULL;
SDL_Surface** menu_item_selected = NULL;
SDL_Surface* title_surf;
SDL_Event event;
- MenuNode* menu = root;
+ MenuNode* menu = menus[index];
MenuNode* tmp_node;
SDL_Rect tmp_rect;
@@ -666,7 +670,7 @@
if(tmp_node->activity == RUN_MAIN_MENU)
{
/* go back to the root of this menu */
- menu = root;
+ menu = menus[index];
}
else
{
@@ -861,7 +865,7 @@
if(curr_node->icon_name)
{
- sprintf(filename, "sprites/%s", curr_node->icon_name);
+ sprintf(filename, "%s/images/sprites/%s", data_prefix, curr_node->icon_name);
DEBUGMSG(dbg_menu, "prerender_menu(): loading sprite %s for item #%d.\n", filename, i);
curr_node->icon = LoadSpriteOfBoundingBox(filename, IMG_ALPHA, button_h, button_h);
}
@@ -946,33 +950,39 @@
void PrerenderAll()
{
int i;
+ char fn[PATH_MAX];
SetRect(&menu_rect, menu_pos);
SetRect(&stop_rect, stop_pos);
if(stop_button)
SDL_FreeSurface(stop_button);
- stop_button = LoadImageOfBoundingBox(stop_path, IMG_ALPHA, stop_rect.w, stop_rect.h);
+ sprintf("%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;
SetRect(&prev_rect, prev_pos);
if(prev_arrow)
SDL_FreeSurface(prev_arrow);
- prev_arrow = LoadImageOfBoundingBox(prev_path, IMG_ALPHA, prev_rect.w, prev_rect.h);
+ sprintf("%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);
- prev_gray = LoadImageOfBoundingBox(prev_gray_path, IMG_ALPHA, prev_rect.w, prev_rect.h);
+ sprintf("%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;
SetRect(&next_rect, next_pos);
if(next_arrow)
SDL_FreeSurface(next_arrow);
- next_arrow = LoadImageOfBoundingBox(next_path, IMG_ALPHA, next_rect.w, next_rect.h);
+ sprintf("%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);
- next_gray = LoadImageOfBoundingBox(next_gray_path, IMG_ALPHA, next_rect.w, next_rect.h);
+ sprintf("%s%s", data_prefix, next_gray_path);
+ next_gray = LoadImageOfBoundingBox(fn, IMG_ALPHA, next_rect.w, next_rect.h);
set_font_size();
Modified: branches/commonification/tux4kids-common/trunk/src/tux4kids-common.h
===================================================================
--- branches/commonification/tux4kids-common/trunk/src/tux4kids-common.h 2009-07-31 20:49:25 UTC (rev 1313)
+++ branches/commonification/tux4kids-common/trunk/src/tux4kids-common.h 2009-07-31 21:33:03 UTC (rev 1314)
@@ -13,7 +13,6 @@
#define TUX4KIDS_COMMON_H
#include "SDL.h"
-#include "SDL_image.h"
#include "SDL_mixer.h"
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
@@ -28,6 +27,8 @@
#define amask 0xff000000
#endif
+typedef enum { false, true } bool;
+
#define MAX_SPRITE_FRAMES 10
typedef struct {
@@ -37,19 +38,24 @@
int cur;
} sprite;
-/* functions from t4k-main.c */
-void SetDebugMode(int dbg_flags);
+/* from t4k-main.c */
+void InitT4KCommon(int debug_flags);
-/* functions from tk4-menu.c */
-void LoadMenus(void);
-int RunLoginMenu(void);
-void RunMainMenu(void);
-void UnloadMenus(void);
-
+/* from tk4-menu.c */
extern SDL_Rect menu_rect, stop_rect, prev_rect, next_rect;
extern SDL_Surface *stop_button, *prev_arrow, *next_arrow, *prev_gray, *next_gray;
-/* functions from tk4-sdl.c */
+void SetActivitiesList(int num, char** acts);
+void SetMenuSounds(Mix_Music* music, Mix_Chunk* click, Mix_Chunk* hover);
+void SetImagePathPrefix(char* pref);
+
+void CreateOneLevelMenu(int index, int items, char** item_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 PrerenderAll();
+void LoadMenu(int index, const char* file_name);
+void UnloadMenus(void);
+
+/* from tk4-sdl.c */
SDL_Surface* GetScreen();
void DrawButton(SDL_Rect* target_rect, int radius, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
void DrawButtonOn(SDL_Surface* target, SDL_Rect* target_rect, int radius, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
@@ -79,7 +85,7 @@
SDL_Surface* SimpleTextWithOffset(const char *t, int size, SDL_Color* col, int *glyph_offset);
-/* functions from tk4-loaders.c */
+/* from tk4-loaders.c */
#define IMG_REGULAR 0x01
#define IMG_COLORKEY 0x02
#define IMG_ALPHA 0x04
@@ -89,21 +95,21 @@
#define IMG_NO_PNG_FALLBACK 0x20
-SDL_Surface* LoadImage(const char* file_name, int mode);
-SDL_Surface* LoadScaledImage(const char* file_name, int mode, int width, int height);
-SDL_Surface* LoadImageOfBoundingBox(const char* file_name, int mode, int max_width, int max_height);
+SDL_Surface* LoadImage(const char* file_name, int mode);
+SDL_Surface* LoadScaledImage(const char* file_name, int mode, int width, int height);
+SDL_Surface* LoadImageOfBoundingBox(const char* file_name, int mode, int max_width, int max_height);
-SDL_Surface* LoadBkgd(const char* file_name, int width, int height);
+SDL_Surface* LoadBkgd(const char* file_name, int width, int height);
-sprite* LoadSprite(const char* name, int mode);
-sprite* LoadScaledSprite(const char* name, int mode, int width, int height);
-sprite* LoadSpriteOfBoundingBox(const char* name, int mode, int max_width, int max_height);
-sprite* FlipSprite(sprite* in, int X, int Y);
-void FreeSprite(sprite* gfx);
-void NextFrame(sprite* s);
+sprite* LoadSprite(const char* name, int mode);
+sprite* LoadScaledSprite(const char* name, int mode, int width, int height);
+sprite* LoadSpriteOfBoundingBox(const char* name, int mode, int max_width, int max_height);
+sprite* FlipSprite(sprite* in, int X, int Y);
+void FreeSprite(sprite* gfx);
+void NextFrame(sprite* s);
-Mix_Chunk* LoadSound(char* datafile);
-Mix_Music* LoadMusic(char *datafile);
+Mix_Chunk* LoadSound(char* datafile);
+Mix_Music* LoadMusic(char *datafile);
#endif
More information about the Tux4kids-commits
mailing list