diff --git a/src/const.h b/src/const.h index 806b04f1..8f3417e2 100644 --- a/src/const.h +++ b/src/const.h @@ -2,6 +2,7 @@ */ /* Grafx2 - The Ultimate 256-color bitmap paint program + Copyright 2014 Sergii Pylypenko Copyright 2008 Yves Rizoud Copyright 2007 Adrien Destugues Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) @@ -28,6 +29,16 @@ #ifndef _CONST_H_ #define _CONST_H_ +#if defined(__GP2X__) || defined(__WIZ__) || defined(__CAANOO__) || defined(__amigaos__) + // These platforms don't seem to have PATH_MAX + #undef PATH_MAX + #define PATH_MAX 260 +#elif defined(__ANDROID__) + #include // for PATH_MAX +#else + #include // for PATH_MAX +#endif + #ifndef M_2PI #define M_2PI 6.28318530717958647692528676656 ///< Hmm, pie... #endif @@ -36,7 +47,7 @@ #define VERSION2 0 ///< Version number for gfx2.cfg (2/4) #define BETA1 98 ///< Version number for gfx2.cfg (3/4) #define BETA2 0 ///< Version number for gfx2.cfg (4/4) -#define MAX_VIDEO_MODES 100 ///< Maximum number of video modes Grafx2 can propose. +#define MAX_VIDEO_MODES 200 ///< Maximum number of video modes Grafx2 can propose. #define NB_ZOOM_FACTORS 15 ///< Number of zoom levels available in the magnifier. #define MENU_WIDTH 254 ///< Width of the menu (not counting the palette) #define MENU_HEIGHT 44 ///< Height of the menu. @@ -61,7 +72,7 @@ #define COMMENT_SIZE 32 ///< Max number of characters for a comment in PKM or PNG file. #define NB_MAX_PAGES_UNDO 99 ///< Max number of undo pages #define DEFAULT_ZOOM_FACTOR 4 ///< Initial zoom factor for the magnifier. -#define MAX_PATH_CHARACTERS 260 ///< Number of characters for a file+complete path. Adapt to your OS... +#define MAX_PATH_CHARACTERS PATH_MAX ///< Number of characters for a file+complete path. Adapt to your OS... #define NB_BOOKMARKS 4 ///< Number of bookmark buttons in Save/Load screen. // Character to show a right arrow, used when editing long strings. It's present in ::Gfx->System_font #define RIGHT_TRIANGLE_CHARACTER 16 diff --git a/src/filesel.c b/src/filesel.c index 96c6ccb0..d95fc6ec 100644 --- a/src/filesel.c +++ b/src/filesel.c @@ -2,6 +2,7 @@ */ /* Grafx2 - The Ultimate 256-color bitmap paint program + Copyright 2014 Sergii Pylypenko Copyright 2011 Pawel Góralski Copyright 2009 Franck Charlet Copyright 2008 Peter Gordon @@ -359,7 +360,8 @@ void Read_list_of_files(T_Fileselector *list, byte selected_format) struct dirent* entry; // Structure de lecture des éléments char * filter = "*"; // Extension demandée struct stat Infos_enreg; - char * current_path; + char * current_path = NULL; + char curdir[MAX_PATH_CHARACTERS]; #if defined (__MINT__) char path[1024]={0}; char path2[1024]={0}; @@ -389,7 +391,7 @@ void Read_list_of_files(T_Fileselector *list, byte selected_format) strcat(path2,PATH_SEPARATOR); current_directory=opendir(path2); #else - current_path=getcwd(NULL,0); + current_path=getcwd(curdir,MAX_PATH_CHARACTERS); current_directory=opendir(current_path); #endif while ((entry=readdir(current_directory))) @@ -1489,7 +1491,7 @@ byte Button_Load_or_Save(T_Selector_settings *settings, byte load, T_IO_Context #else { chdir(context->File_directory); - getcwd(Selector->Directory,256); + getcwd(Selector->Directory,MAX_PATH_CHARACTERS); } #endif @@ -2007,7 +2009,7 @@ byte Button_Load_or_Save(T_Selector_settings *settings, byte load, T_IO_Context Dgetpath(path,0); sprintf(Selector->Directory,"%c:\%s",currentDrive,path); #else - getcwd(Selector->Directory,256); + getcwd(Selector->Directory,MAX_PATH_CHARACTERS); #endif // On lit le nouveau répertoire Read_list_of_files(&Filelist, Selector->Format_filter); diff --git a/src/global.h b/src/global.h index a3beff6b..6e4cb53f 100644 --- a/src/global.h +++ b/src/global.h @@ -2,6 +2,7 @@ */ /* Grafx2 - The Ultimate 256-color bitmap paint program + Copyright 2014 Sergii Pylypenko Copyright 2009 Franck Charlet Copyright 2009 Yves Rizoud Copyright 2007 Adrien Destugues @@ -721,11 +722,11 @@ GFX2_GLOBAL byte Airbrush_multi_flow[256]; /// Boolean, set to true to exit the program. GFX2_GLOBAL byte Quitting; /// Name of the directory that was current when the program was run. -GFX2_GLOBAL char Initial_directory[256]; +GFX2_GLOBAL char Initial_directory[MAX_PATH_CHARACTERS]; /// Name of the directory that holds the program's (read-only) data: skins, icon, etc. -GFX2_GLOBAL char Data_directory[256]; +GFX2_GLOBAL char Data_directory[MAX_PATH_CHARACTERS]; /// Name of the directory where grafx2 reads and writes configuration (gfx2.ini, gfx2.cfg) -GFX2_GLOBAL char Config_directory[256]; +GFX2_GLOBAL char Config_directory[MAX_PATH_CHARACTERS]; /// Current foreground color for drawing. GFX2_GLOBAL byte Fore_color; /// Current background color for drawing. diff --git a/src/io.c b/src/io.c index 65859da0..0ee7b28c 100644 --- a/src/io.c +++ b/src/io.c @@ -455,7 +455,7 @@ int Lock_file_handle = -1; byte Create_lock_file(const char *file_directory) { - #if defined (__amigaos__)||(__AROS__) + #if defined (__amigaos__)||(__AROS__)||(__ANDROID__) #warning "Missing code for your platform, please check and correct!" #else char lock_filename[MAX_PATH_CHARACTERS]; diff --git a/src/main.c b/src/main.c index 921548a6..0626d771 100644 --- a/src/main.c +++ b/src/main.c @@ -461,7 +461,7 @@ int Init_program(int argc,char * argv[]) strcpy(Main_selector.Directory,program_directory); #else // On détermine le répertoire courant: - getcwd(Main_selector.Directory,256); + getcwd(Main_selector.Directory,MAX_PATH_CHARACTERS); #endif // On en profite pour le mémoriser dans le répertoire principal: diff --git a/src/mountlist.c b/src/mountlist.c index 96143a23..54a88dcb 100644 --- a/src/mountlist.c +++ b/src/mountlist.c @@ -41,7 +41,7 @@ #define MOUNTED_GETFSSTAT 1 #define HAVE_SYS_MOUNT_H 1 #include -#elif defined(__SKYOS__) +#elif defined(__SKYOS__)||defined(__ANDROID__) #warning "Your platform is missing some specific code here ! please check and fix :)" #else #define MOUNTED_GETMNTENT1 diff --git a/src/readline.c b/src/readline.c index b2bc92af..e61e6043 100644 --- a/src/readline.c +++ b/src/readline.c @@ -2,6 +2,7 @@ */ /* Grafx2 - The Ultimate 256-color bitmap paint program + Copyright 2014 Sergii Pylypenko Copyright 2008 Yves Rizoud Copyright 2007 Adrien Destugues Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) @@ -50,6 +51,9 @@ #include #include #endif +#if defined(__ANDROID__) +#include +#endif // Virtual keyboard is ON by default on these platforms: #if defined(__GP2X__) || defined(__WIZ__) || defined(__CAANOO__) @@ -400,6 +404,10 @@ byte Readline_ex(word x_pos,word y_pos,char * str,byte visible_size,byte max_siz // Nothing. The caller should have initialized a valid hexa number. } +#if defined(__ANDROID__) + SDL_ANDROID_GetScreenKeyboardTextInput(str, max_size); + input_key = SDLK_RETURN; +#else // Virtual keyboards if (Config.Use_virtual_keyboard==1 || (VIRT_KEY_DEFAULT_ON && Config.Use_virtual_keyboard==0)) @@ -757,7 +765,7 @@ affichage: Mouse_K=old_mouse_k; Input_sticky_control=0; } - +#endif // defined(__ANDROID__) // Effacement de la chaîne Block(window_x+(x_pos*Menu_factor_X),window_y+(y_pos*Menu_factor_Y), visible_size*(Menu_factor_X<<3),(Menu_factor_Y<<3),BACKGROUND_COLOR); diff --git a/src/sdlscreen.c b/src/sdlscreen.c index 7b479948..7142d963 100644 --- a/src/sdlscreen.c +++ b/src/sdlscreen.c @@ -2,6 +2,7 @@ */ /* Grafx2 - The Ultimate 256-color bitmap paint program + Copyright 2014 Sergii Pylypenko Copyright 2011 Pawel Góralski Copyright 2008 Yves Rizoud Copyright 2008 Franck Charlet @@ -54,6 +55,8 @@ #define UPDATE_METHOD UPDATE_METHOD_FULL_PAGE #elif defined(__MINT__) #define UPDATE_METHOD UPDATE_METHOD_CUMULATED + #elif defined(__ANDROID__) + #define UPDATE_METHOD UPDATE_METHOD_FULL_PAGE #else #define UPDATE_METHOD UPDATE_METHOD_CUMULATED #endif diff --git a/src/setup.c b/src/setup.c index af32838c..68426554 100644 --- a/src/setup.c +++ b/src/setup.c @@ -2,6 +2,7 @@ */ /* Grafx2 - The Ultimate 256-color bitmap paint program + Copyright 2014 Sergii Pylypenko Copyright 2011 Pawel Góralski Copyright 2008 Peter Gordon Copyright 2008 Yves Rizoud @@ -92,6 +93,9 @@ void Set_program_directory(const char * argv0,char * program_dir) sprintf(program_dir,"%c:\%s",currentDrive,path); // Append trailing slash strcat(program_dir,PATH_SEPARATOR); + #elif defined(__ANDROID__) + getcwd(program_dir, MAX_PATH_CHARACTERS); + strcat(program_dir, "/"); // Linux: argv[0] unreliable #elif defined(__linux__) if (argv0[0]!='/') @@ -122,7 +126,7 @@ void Set_data_directory(const char * program_dir, char * data_dir) #if defined(__macosx__) strcat(data_dir,"Contents/Resources/"); // On GP2X, executable is not in bin/ - #elif defined (__GP2X__) || defined (__gp2x__) || defined (__WIZ__) || defined (__CAANOO__) + #elif defined (__GP2X__) || defined (__gp2x__) || defined (__WIZ__) || defined (__CAANOO__) || defined(__ANDROID__) strcat(data_dir,"share/grafx2/"); //on tos the same directory #elif defined (__MINT__) diff --git a/src/struct.h b/src/struct.h index a58deed8..bce6fed7 100644 --- a/src/struct.h +++ b/src/struct.h @@ -2,6 +2,7 @@ */ /* Grafx2 - The Ultimate 256-color bitmap paint program + Copyright 2014 Sergii Pylypenko Copyright 2011 Pawel Góralski Copyright 2008 Yves Rizoud Copyright 2007 Adrien Destugues @@ -173,7 +174,7 @@ typedef struct T_Dropdown_button /// Data for one item (file, directory) in a fileselector. typedef struct T_Fileselector_item { - char Full_name[256]; ///< Filesystem value. + char Full_name[MAX_PATH_CHARACTERS]; ///< Filesystem value. byte Type; ///< Type of item: 0 = File, 1 = Directory, 2 = Drive byte Icon; ///< One of ::ICON_TYPES, ICON_NONE for none. @@ -545,7 +546,7 @@ typedef struct T_Selector_settings byte Format_filter; ///< 0 for "*.*", or a value of enum ::FILE_FORMATS short Position; ///< Index of the first file/entry to display in list short Offset; ///< Position of the "highlight" bar in the file list - char Directory[256]; ///< Directory currently browsed + char Directory[MAX_PATH_CHARACTERS]; ///< Directory currently browsed } T_Selector_settings; #endif diff --git a/src/text.c b/src/text.c index 1d8aeb4b..123085ce 100644 --- a/src/text.c +++ b/src/text.c @@ -2,6 +2,7 @@ */ /* Grafx2 - The Ultimate 256-color bitmap paint program + Copyright 2014 Sergii Pylypenko Copyright 2011 Pawel Góralski Copyright 2008 Yves Rizoud Copyright 2008 Franck Charlet @@ -418,10 +419,17 @@ byte *Render_text_TTF(const char *str, int font_number, int size, int antialias, bg_color.unused=fg_color.unused=255; // Text rendering: creates a 8bit surface with its dedicated palette + #ifdef __ANDROID__ + if (antialias) + text_surface=TTF_RenderUTF8_Shaded(font, str, fg_color, bg_color ); + else + text_surface=TTF_RenderUTF8_Solid(font, str, fg_color); + #else if (antialias) text_surface=TTF_RenderText_Shaded(font, str, fg_color, bg_color ); else text_surface=TTF_RenderText_Solid(font, str, fg_color); + #endif if (!text_surface) { TTF_CloseFont(font);