Ran source code through "indent -nbfda -npcs -npsl -bli0".
This commit is contained in:
parent
51355bce43
commit
7716a05281
38 changed files with 10816 additions and 10710 deletions
|
|
@ -9,7 +9,7 @@ http://www.newbreedsoftware.com/tuxpaint/
|
|||
$Id$
|
||||
|
||||
|
||||
2006.August.26 (0.9.16)
|
||||
2006.August.27 (0.9.16)
|
||||
* Interface improvements:
|
||||
-----------------------
|
||||
* Modified "Text" tool so that it correctly handles the 16-bit unicode
|
||||
|
|
@ -143,6 +143,8 @@ $Id$
|
|||
|
||||
* Compiling, porting and packaging updates:
|
||||
-----------------------------------------
|
||||
* Ran source code through "indent -nbfda -npcs -npsl -bli0".
|
||||
|
||||
* "DESTDIR" patch is no longer needed.
|
||||
TOYAMA Shin-ichi <shin1@wmail.plala.or.jp>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
/* BeOS_print.h */
|
||||
|
||||
/* printing support for Tux Paint */
|
||||
/* Marcin 'Shard' Konicki <shard@beosjournal.org> */
|
||||
|
||||
/* BeOS_print.h */
|
||||
|
||||
/* printing support for Tux Paint */
|
||||
/* Marcin 'Shard' Konicki <shard@beosjournal.org> */
|
||||
|
||||
/*
|
||||
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
|
||||
|
|
@ -18,26 +18,26 @@
|
|||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
(See COPYING.txt)
|
||||
*/
|
||||
|
||||
/* Jan. 17, 2003 */
|
||||
/* $Id$ */
|
||||
|
||||
|
||||
*/
|
||||
|
||||
/* Jan. 17, 2003 */
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef __BEOS_PRINT_H__
|
||||
#define __BEOS_PRINT_H__
|
||||
|
||||
|
||||
#include "SDL.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern int SurfacePrint( SDL_Surface *surf );
|
||||
extern int IsPrinterAvailable();
|
||||
|
||||
extern "C"
|
||||
{
|
||||
|
||||
#endif /*
*/
|
||||
extern int SurfacePrint(SDL_Surface * surf);
|
||||
extern int IsPrinterAvailable();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
}
|
||||
#endif /*
*/
|
||||
|
||||
#endif /*
*/
|
||||
|
|
|
|||
39
src/colors.h
39
src/colors.h
|
|
@ -31,7 +31,8 @@
|
|||
|
||||
/* What colors are available: */
|
||||
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
COLOR_BLACK,
|
||||
COLOR_DARKGREY,
|
||||
COLOR_LIGHTGREY,
|
||||
|
|
@ -56,29 +57,29 @@ enum {
|
|||
/* Hex codes: */
|
||||
|
||||
const int color_hexes[NUM_COLORS][3] = {
|
||||
{0, 0, 0}, /* Black */
|
||||
{128, 128, 128}, /* Dark grey */
|
||||
{192, 192, 192}, /* Light grey */
|
||||
{255, 255, 255}, /* White */
|
||||
{255, 0, 0}, /* Red */
|
||||
{255, 128, 0}, /* Orange */
|
||||
{255, 255, 0}, /* Yellow */
|
||||
{160, 228, 128}, /* Light green */
|
||||
{ 33, 148, 70}, /* Dark green */
|
||||
{138, 168, 205}, /* Sky blue */
|
||||
{ 50, 100, 255}, /* Blue */
|
||||
{186, 157, 255}, /* Lavender */
|
||||
{128, 0, 128}, /* Purple */
|
||||
{255, 165, 211}, /* Pink */
|
||||
{128, 80, 0}, /* Brown */
|
||||
{226, 189, 166}, /* Tan */
|
||||
{247, 228, 219} /* Beige */
|
||||
{0, 0, 0}, /* Black */
|
||||
{128, 128, 128}, /* Dark grey */
|
||||
{192, 192, 192}, /* Light grey */
|
||||
{255, 255, 255}, /* White */
|
||||
{255, 0, 0}, /* Red */
|
||||
{255, 128, 0}, /* Orange */
|
||||
{255, 255, 0}, /* Yellow */
|
||||
{160, 228, 128}, /* Light green */
|
||||
{33, 148, 70}, /* Dark green */
|
||||
{138, 168, 205}, /* Sky blue */
|
||||
{50, 100, 255}, /* Blue */
|
||||
{186, 157, 255}, /* Lavender */
|
||||
{128, 0, 128}, /* Purple */
|
||||
{255, 165, 211}, /* Pink */
|
||||
{128, 80, 0}, /* Brown */
|
||||
{226, 189, 166}, /* Tan */
|
||||
{247, 228, 219} /* Beige */
|
||||
};
|
||||
|
||||
|
||||
/* Color names: */
|
||||
|
||||
const char * const color_names[NUM_COLORS] = {
|
||||
const char *const color_names[NUM_COLORS] = {
|
||||
gettext_noop("Black!"),
|
||||
gettext_noop("Dark grey! Some people spell it “dark gray”."),
|
||||
gettext_noop("Light grey! Some people spell it “light gray”."),
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@
|
|||
// since gcc-2.5
|
||||
#ifdef __GNUC__
|
||||
#define NORETURN __attribute__((__noreturn__))
|
||||
#define FUNCTION __attribute__((__const__)) // no access to global mem, even via ptr, and no side effect
|
||||
#define FUNCTION __attribute__((__const__)) // no access to global mem, even via ptr, and no side effect
|
||||
#else
|
||||
#define NORETURN
|
||||
#define FUNCTION
|
||||
|
|
@ -150,4 +150,3 @@
|
|||
#undef CLOCK_ASM
|
||||
#define CLOCK_ASM(x) x=42
|
||||
#endif
|
||||
|
||||
|
|
|
|||
16
src/cursor.c
16
src/cursor.c
|
|
@ -30,11 +30,11 @@
|
|||
#include "cursor.h"
|
||||
#include "debug.h"
|
||||
|
||||
#define UNUSED(arg) ((void)(arg))
|
||||
#define UNUSED(arg) ((void)(arg))
|
||||
|
||||
SDL_Cursor * cursor_hand, * cursor_arrow, * cursor_watch,
|
||||
* cursor_up, * cursor_down, * cursor_tiny, * cursor_crosshair,
|
||||
* cursor_brush, * cursor_wand, * cursor_insertion, * cursor_rotate;
|
||||
SDL_Cursor *cursor_hand, *cursor_arrow, *cursor_watch,
|
||||
*cursor_up, *cursor_down, *cursor_tiny, *cursor_crosshair,
|
||||
*cursor_brush, *cursor_wand, *cursor_insertion, *cursor_rotate;
|
||||
|
||||
int no_fancy_cursors;
|
||||
|
||||
|
|
@ -73,8 +73,8 @@ void do_setcursor(SDL_Cursor * c)
|
|||
void free_cursor(SDL_Cursor ** cursor)
|
||||
{
|
||||
if (*cursor)
|
||||
{
|
||||
SDL_FreeCursor(*cursor);
|
||||
*cursor = NULL;
|
||||
}
|
||||
{
|
||||
SDL_FreeCursor(*cursor);
|
||||
*cursor = NULL;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,9 +65,9 @@
|
|||
#include "arrow.xbm"
|
||||
#include "arrow-mask.xbm"
|
||||
|
||||
extern SDL_Cursor * cursor_hand, * cursor_arrow, * cursor_watch,
|
||||
* cursor_up, * cursor_down, * cursor_tiny, * cursor_crosshair,
|
||||
* cursor_brush, * cursor_wand, * cursor_insertion, * cursor_rotate;
|
||||
extern SDL_Cursor *cursor_hand, *cursor_arrow, *cursor_watch,
|
||||
*cursor_up, *cursor_down, *cursor_tiny, *cursor_crosshair,
|
||||
*cursor_brush, *cursor_wand, *cursor_insertion, *cursor_rotate;
|
||||
|
||||
extern int no_fancy_cursors;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,2 +1 @@
|
|||
#define DEBUG
|
||||
|
||||
//#define DEBUG
|
||||
|
|
|
|||
412
src/dirwalk.c
412
src/dirwalk.c
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#define __USE_GNU /* for strcasestr() */
|
||||
#define __USE_GNU /* for strcasestr() */
|
||||
#include <string.h>
|
||||
#include <locale.h>
|
||||
#include <libintl.h>
|
||||
|
|
@ -25,123 +25,123 @@
|
|||
|
||||
///////////////// directory walking callers and callbacks //////////////////
|
||||
|
||||
void loadfont_callback(SDL_Surface * screen, const char *restrict const dir, unsigned dirlen, tp_ftw_str *files, unsigned i)
|
||||
void loadfont_callback(SDL_Surface * screen, const char *restrict const dir,
|
||||
unsigned dirlen, tp_ftw_str * files, unsigned i)
|
||||
{
|
||||
dirlen = dirlen;
|
||||
|
||||
while(i--)
|
||||
while (i--)
|
||||
{
|
||||
int loadable = 0;
|
||||
const char *restrict const cp = strchr(files[i].str, '.');
|
||||
show_progress_bar(screen);
|
||||
if (cp)
|
||||
{
|
||||
int loadable = 0;
|
||||
const char *restrict const cp = strchr(files[i].str, '.');
|
||||
show_progress_bar(screen);
|
||||
if(cp)
|
||||
{
|
||||
// need gcc 3.4 for the restrict in this location
|
||||
const char * /*restrict*/ const suffixes[] = {"ttc", "dfont", "pfa", "pfb", "otf", "ttf",};
|
||||
int j = sizeof suffixes / sizeof suffixes[0];
|
||||
while(j--)
|
||||
{
|
||||
// only check part, because of potential .gz or .bz2 suffix
|
||||
if(!strncasecmp(cp+1,suffixes[j],strlen(suffixes[j])))
|
||||
{
|
||||
loadable = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!loadable)
|
||||
{
|
||||
if(strcasestr(files[i].str, "/rsrc"))
|
||||
loadable = 1;
|
||||
}
|
||||
// Loadable: TrueType (.ttf), OpenType (.otf), Type1 (.pfa and .pfb),
|
||||
// and various useless bitmap fonts. Compressed files (with .gz or .bz2)
|
||||
// should also work. A *.dfont is pretty much a Mac resource fork in a normal
|
||||
// file, and may load with some library versions.
|
||||
if (loadable)
|
||||
{
|
||||
char fname[512];
|
||||
TTF_Font *font;
|
||||
snprintf(fname, sizeof fname, "%s/%s", dir, files[i].str);
|
||||
// need gcc 3.4 for the restrict in this location
|
||||
const char * /*restrict */ const suffixes[] =
|
||||
{ "ttc", "dfont", "pfa", "pfb", "otf", "ttf", };
|
||||
int j = sizeof suffixes / sizeof suffixes[0];
|
||||
while (j--)
|
||||
{
|
||||
// only check part, because of potential .gz or .bz2 suffix
|
||||
if (!strncasecmp(cp + 1, suffixes[j], strlen(suffixes[j])))
|
||||
{
|
||||
loadable = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!loadable)
|
||||
{
|
||||
if (strcasestr(files[i].str, "/rsrc"))
|
||||
loadable = 1;
|
||||
}
|
||||
// Loadable: TrueType (.ttf), OpenType (.otf), Type1 (.pfa and .pfb),
|
||||
// and various useless bitmap fonts. Compressed files (with .gz or .bz2)
|
||||
// should also work. A *.dfont is pretty much a Mac resource fork in a normal
|
||||
// file, and may load with some library versions.
|
||||
if (loadable)
|
||||
{
|
||||
char fname[512];
|
||||
TTF_Font *font;
|
||||
snprintf(fname, sizeof fname, "%s/%s", dir, files[i].str);
|
||||
//printf("Loading font: %s\n", fname);
|
||||
font = TTF_OpenFont(fname, text_sizes[text_size]);
|
||||
if(font)
|
||||
{
|
||||
const char *restrict const family = TTF_FontFaceFamilyName(font);
|
||||
const char *restrict const style = TTF_FontFaceStyleName(font);
|
||||
font = TTF_OpenFont(fname, text_sizes[text_size]);
|
||||
if (font)
|
||||
{
|
||||
const char *restrict const family = TTF_FontFaceFamilyName(font);
|
||||
const char *restrict const style = TTF_FontFaceStyleName(font);
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
int numfaces = TTF_FontFaces(font);
|
||||
if (numfaces != 1)
|
||||
printf("Found %d faces in %s, %s, %s\n", numfaces, files[i].str, family, style);
|
||||
int numfaces = TTF_FontFaces(font);
|
||||
if (numfaces != 1)
|
||||
printf("Found %d faces in %s, %s, %s\n", numfaces, files[i].str,
|
||||
family, style);
|
||||
#endif
|
||||
|
||||
// First, the blacklist. We list font families that can crash Tux Paint
|
||||
// via bugs in the SDL_ttf library. We also test fonts to be sure that
|
||||
// they have both uppercase and lowercase letters. Note that we do not
|
||||
// test for "Aa", because it is OK if uppercase and lowercase are the
|
||||
// same. (but not nice -- such fonts get a low score later)
|
||||
//
|
||||
// We test the alphabet twice, to help with translation. If the users
|
||||
// will be unable to type ASCII letters, then both lines should be
|
||||
// translated. Otherwise, only Line X should be translated and the
|
||||
// ASCII-only fonts should be given bad scores in the scoring code below.
|
||||
// (the best scores going to fonts that support both)
|
||||
if
|
||||
(
|
||||
strcmp("Zapfino",family) && strcmp("Elvish Ring NFI",family)
|
||||
&&
|
||||
(
|
||||
(charset_works(font, gettext("qx")) && charset_works(font, gettext("QX"))) // Line X
|
||||
||
|
||||
(charset_works(font, gettext("qy")) && charset_works(font, gettext("QY"))) // Line Y
|
||||
)
|
||||
)
|
||||
{
|
||||
if (num_font_styles==num_font_styles_max)
|
||||
{
|
||||
num_font_styles_max = num_font_styles_max * 5 / 4 + 30;
|
||||
user_font_styles = realloc(user_font_styles, num_font_styles_max * sizeof *user_font_styles);
|
||||
}
|
||||
user_font_styles[num_font_styles] = malloc(sizeof *user_font_styles[num_font_styles]);
|
||||
user_font_styles[num_font_styles]->directory = strdup(dir);
|
||||
user_font_styles[num_font_styles]->filename = files[i].str; // steal it (mark NULL below)
|
||||
user_font_styles[num_font_styles]->family = strdup(family);
|
||||
user_font_styles[num_font_styles]->style = strdup(style);
|
||||
// Now we score fonts to ensure that the best ones will be placed at
|
||||
// the top of the list. The user will see them first. This sorting is
|
||||
// especially important for users who have scroll buttons disabled.
|
||||
// Translators should do whatever is needed to put crummy fonts last.
|
||||
user_font_styles[num_font_styles]->score = charset_works(font, gettext("oO")); // distinct uppercase and lowercase
|
||||
user_font_styles[num_font_styles]->score += charset_works(font, gettext("`\%_@$~#{}<>^&*")); // uncommon punctuation
|
||||
user_font_styles[num_font_styles]->score += charset_works(font, gettext(",.?!")); // common punctuation
|
||||
user_font_styles[num_font_styles]->score += charset_works(font, gettext("017")); // digits
|
||||
user_font_styles[num_font_styles]->score += charset_works(font, gettext("O0")); // distinct circle-like characters
|
||||
user_font_styles[num_font_styles]->score += charset_works(font, gettext("1Il|")); // distinct line-like characters
|
||||
num_font_styles++;
|
||||
// First, the blacklist. We list font families that can crash Tux Paint
|
||||
// via bugs in the SDL_ttf library. We also test fonts to be sure that
|
||||
// they have both uppercase and lowercase letters. Note that we do not
|
||||
// test for "Aa", because it is OK if uppercase and lowercase are the
|
||||
// same. (but not nice -- such fonts get a low score later)
|
||||
//
|
||||
// We test the alphabet twice, to help with translation. If the users
|
||||
// will be unable to type ASCII letters, then both lines should be
|
||||
// translated. Otherwise, only Line X should be translated and the
|
||||
// ASCII-only fonts should be given bad scores in the scoring code below.
|
||||
// (the best scores going to fonts that support both)
|
||||
if (strcmp("Zapfino", family) && strcmp("Elvish Ring NFI", family) && ((charset_works(font, gettext("qx")) && charset_works(font, gettext("QX"))) // Line X
|
||||
|| (charset_works(font, gettext("qy")) && charset_works(font, gettext("QY"))) // Line Y
|
||||
))
|
||||
{
|
||||
if (num_font_styles == num_font_styles_max)
|
||||
{
|
||||
num_font_styles_max = num_font_styles_max * 5 / 4 + 30;
|
||||
user_font_styles =
|
||||
realloc(user_font_styles,
|
||||
num_font_styles_max * sizeof *user_font_styles);
|
||||
}
|
||||
user_font_styles[num_font_styles] =
|
||||
malloc(sizeof *user_font_styles[num_font_styles]);
|
||||
user_font_styles[num_font_styles]->directory = strdup(dir);
|
||||
user_font_styles[num_font_styles]->filename = files[i].str; // steal it (mark NULL below)
|
||||
user_font_styles[num_font_styles]->family = strdup(family);
|
||||
user_font_styles[num_font_styles]->style = strdup(style);
|
||||
// Now we score fonts to ensure that the best ones will be placed at
|
||||
// the top of the list. The user will see them first. This sorting is
|
||||
// especially important for users who have scroll buttons disabled.
|
||||
// Translators should do whatever is needed to put crummy fonts last.
|
||||
user_font_styles[num_font_styles]->score = charset_works(font, gettext("oO")); // distinct uppercase and lowercase
|
||||
user_font_styles[num_font_styles]->score += charset_works(font, gettext("`\%_@$~#{}<>^&*")); // uncommon punctuation
|
||||
user_font_styles[num_font_styles]->score += charset_works(font, gettext(",.?!")); // common punctuation
|
||||
user_font_styles[num_font_styles]->score += charset_works(font, gettext("017")); // digits
|
||||
user_font_styles[num_font_styles]->score += charset_works(font, gettext("O0")); // distinct circle-like characters
|
||||
user_font_styles[num_font_styles]->score += charset_works(font, gettext("1Il|")); // distinct line-like characters
|
||||
num_font_styles++;
|
||||
//printf("Accepted: %s, %s, %s, score(%d)\n", files[i].str, family, style, user_font_styles[num_font_styles]->score);
|
||||
files[i].str = NULL; // so free() won't crash -- we stole the memory
|
||||
}
|
||||
else
|
||||
{
|
||||
files[i].str = NULL; // so free() won't crash -- we stole the memory
|
||||
}
|
||||
else
|
||||
{
|
||||
#if 0
|
||||
// THREADED_FONTS
|
||||
printf("Font is too defective: %s, %s, %s\n", files[i].str, family, style);
|
||||
printf("Font is too defective: %s, %s, %s\n", files[i].str, family,
|
||||
style);
|
||||
#endif
|
||||
}
|
||||
TTF_CloseFont(font);
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
TTF_CloseFont(font);
|
||||
}
|
||||
else
|
||||
{
|
||||
#if 0
|
||||
// THREADED_FONTS
|
||||
printf("could not open %s\n", files[i].str);
|
||||
printf("could not open %s\n", files[i].str);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
free(files[i].str);
|
||||
}
|
||||
}
|
||||
free(files[i].str);
|
||||
}
|
||||
free(files);
|
||||
}
|
||||
|
||||
|
|
@ -149,14 +149,16 @@ void loadfont_callback(SDL_Surface * screen, const char *restrict const dir, uns
|
|||
// For qsort()
|
||||
int compare_ftw_str(const void *v1, const void *v2)
|
||||
{
|
||||
const char *restrict const s1 = ((tp_ftw_str*)v1)->str;
|
||||
const char *restrict const s2 = ((tp_ftw_str*)v2)->str;
|
||||
const char *restrict const s1 = ((tp_ftw_str *) v1)->str;
|
||||
const char *restrict const s2 = ((tp_ftw_str *) v2)->str;
|
||||
return -strcmp(s1, s2);
|
||||
}
|
||||
|
||||
void tp_ftw(SDL_Surface * screen, char *restrict const dir, unsigned dirlen, int rsrc,
|
||||
void (*fn)(SDL_Surface * screen, const char *restrict const dir, unsigned dirlen, tp_ftw_str *files, unsigned count)
|
||||
)
|
||||
void tp_ftw(SDL_Surface * screen, char *restrict const dir, unsigned dirlen,
|
||||
int rsrc, void (*fn) (SDL_Surface * screen,
|
||||
const char *restrict const dir,
|
||||
unsigned dirlen, tp_ftw_str * files,
|
||||
unsigned count))
|
||||
{
|
||||
DIR *d;
|
||||
unsigned num_file_names = 0;
|
||||
|
|
@ -176,124 +178,124 @@ void tp_ftw(SDL_Surface * screen, char *restrict const dir, unsigned dirlen, int
|
|||
if (!d)
|
||||
return;
|
||||
|
||||
for(;;)
|
||||
{
|
||||
struct dirent * f = readdir(d);
|
||||
int filetype = TP_FTW_UNKNOWN;
|
||||
for (;;)
|
||||
{
|
||||
struct dirent *f = readdir(d);
|
||||
int filetype = TP_FTW_UNKNOWN;
|
||||
|
||||
if(!f)
|
||||
break;
|
||||
if(f->d_name[0]=='.')
|
||||
continue;
|
||||
if (!f)
|
||||
break;
|
||||
if (f->d_name[0] == '.')
|
||||
continue;
|
||||
// Linux and BSD can often provide file type info w/o the stat() call
|
||||
#ifdef DT_UNKNOWN
|
||||
switch(f->d_type)
|
||||
{
|
||||
default:
|
||||
continue;
|
||||
case DT_REG:
|
||||
if(!rsrc) // if maybe opening resource files, need st_size
|
||||
filetype = TP_FTW_NORMAL;
|
||||
break;
|
||||
case DT_DIR:
|
||||
filetype = TP_FTW_DIRECTORY;
|
||||
break;
|
||||
case DT_UNKNOWN:
|
||||
case DT_LNK:
|
||||
;
|
||||
}
|
||||
switch (f->d_type)
|
||||
{
|
||||
default:
|
||||
continue;
|
||||
case DT_REG:
|
||||
if (!rsrc) // if maybe opening resource files, need st_size
|
||||
filetype = TP_FTW_NORMAL;
|
||||
break;
|
||||
case DT_DIR:
|
||||
filetype = TP_FTW_DIRECTORY;
|
||||
break;
|
||||
case DT_UNKNOWN:
|
||||
case DT_LNK:
|
||||
;
|
||||
}
|
||||
#else
|
||||
#warning Failed to see DT_UNKNOWN
|
||||
#endif
|
||||
|
||||
#if defined(_DIRENT_HAVE_D_NAMLEN) || defined(__APPLE__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__)
|
||||
d_namlen = f->d_namlen;
|
||||
d_namlen = f->d_namlen;
|
||||
#else
|
||||
d_namlen = strlen(f->d_name);
|
||||
d_namlen = strlen(f->d_name);
|
||||
#endif
|
||||
add_rsrc = 0;
|
||||
add_rsrc = 0;
|
||||
|
||||
if(filetype == TP_FTW_UNKNOWN)
|
||||
{
|
||||
struct stat sbuf;
|
||||
memcpy(dir+dirlen, f->d_name, d_namlen+1);
|
||||
if(stat(dir, &sbuf))
|
||||
continue; // oh well... try the next one
|
||||
if(S_ISDIR(sbuf.st_mode))
|
||||
filetype = TP_FTW_DIRECTORY;
|
||||
else if(S_ISREG(sbuf.st_mode))
|
||||
{
|
||||
filetype = TP_FTW_NORMAL;
|
||||
if(rsrc && !sbuf.st_size)
|
||||
add_rsrc = 5; // 5 is length of "/rsrc"
|
||||
}
|
||||
else
|
||||
continue; // was a device file or somesuch
|
||||
}
|
||||
if(filetype==TP_FTW_NORMAL)
|
||||
{
|
||||
char *cp;
|
||||
|
||||
if(num_file_names==max_file_names)
|
||||
{
|
||||
max_file_names = max_file_names * 5 / 4 + 30;
|
||||
file_names = realloc(file_names, max_file_names * sizeof *file_names);
|
||||
}
|
||||
cp = malloc(d_namlen + add_rsrc + 1);
|
||||
memcpy(cp, f->d_name, d_namlen);
|
||||
if(add_rsrc)
|
||||
memcpy(cp+d_namlen, "/rsrc", 6);
|
||||
else
|
||||
cp[d_namlen] = '\0';
|
||||
file_names[num_file_names].str = cp;
|
||||
file_names[num_file_names].len = d_namlen;
|
||||
num_file_names++;
|
||||
}
|
||||
if(filetype==TP_FTW_DIRECTORY)
|
||||
{
|
||||
char * cp;
|
||||
if(num_dir_names==max_dir_names)
|
||||
{
|
||||
max_dir_names = max_dir_names * 5 / 4 + 3;
|
||||
dir_names = realloc(dir_names, max_dir_names * sizeof *dir_names);
|
||||
}
|
||||
cp = malloc(d_namlen + 1);
|
||||
memcpy(cp, f->d_name, d_namlen + 1);
|
||||
dir_names[num_dir_names].str = cp;
|
||||
dir_names[num_dir_names].len = d_namlen;
|
||||
num_dir_names++;
|
||||
}
|
||||
if (filetype == TP_FTW_UNKNOWN)
|
||||
{
|
||||
struct stat sbuf;
|
||||
memcpy(dir + dirlen, f->d_name, d_namlen + 1);
|
||||
if (stat(dir, &sbuf))
|
||||
continue; // oh well... try the next one
|
||||
if (S_ISDIR(sbuf.st_mode))
|
||||
filetype = TP_FTW_DIRECTORY;
|
||||
else if (S_ISREG(sbuf.st_mode))
|
||||
{
|
||||
filetype = TP_FTW_NORMAL;
|
||||
if (rsrc && !sbuf.st_size)
|
||||
add_rsrc = 5; // 5 is length of "/rsrc"
|
||||
}
|
||||
else
|
||||
continue; // was a device file or somesuch
|
||||
}
|
||||
if (filetype == TP_FTW_NORMAL)
|
||||
{
|
||||
char *cp;
|
||||
|
||||
if (num_file_names == max_file_names)
|
||||
{
|
||||
max_file_names = max_file_names * 5 / 4 + 30;
|
||||
file_names = realloc(file_names, max_file_names * sizeof *file_names);
|
||||
}
|
||||
cp = malloc(d_namlen + add_rsrc + 1);
|
||||
memcpy(cp, f->d_name, d_namlen);
|
||||
if (add_rsrc)
|
||||
memcpy(cp + d_namlen, "/rsrc", 6);
|
||||
else
|
||||
cp[d_namlen] = '\0';
|
||||
file_names[num_file_names].str = cp;
|
||||
file_names[num_file_names].len = d_namlen;
|
||||
num_file_names++;
|
||||
}
|
||||
if (filetype == TP_FTW_DIRECTORY)
|
||||
{
|
||||
char *cp;
|
||||
if (num_dir_names == max_dir_names)
|
||||
{
|
||||
max_dir_names = max_dir_names * 5 / 4 + 3;
|
||||
dir_names = realloc(dir_names, max_dir_names * sizeof *dir_names);
|
||||
}
|
||||
cp = malloc(d_namlen + 1);
|
||||
memcpy(cp, f->d_name, d_namlen + 1);
|
||||
dir_names[num_dir_names].str = cp;
|
||||
dir_names[num_dir_names].len = d_namlen;
|
||||
num_dir_names++;
|
||||
}
|
||||
}
|
||||
|
||||
closedir(d);
|
||||
show_progress_bar(screen);
|
||||
dir[dirlen] = '\0'; // repair it (clobbered for stat() call above)
|
||||
dir[dirlen] = '\0'; // repair it (clobbered for stat() call above)
|
||||
|
||||
if(file_names)
|
||||
{
|
||||
if (file_names)
|
||||
{
|
||||
// let callee sort and keep the string
|
||||
#if 0
|
||||
qsort(file_names, num_file_names, sizeof *file_names, compare_ftw_str);
|
||||
while(num_file_names--)
|
||||
{
|
||||
free(file_names[num_file_names].str);
|
||||
}
|
||||
free(file_names);
|
||||
#else
|
||||
fn(screen, dir, dirlen, file_names, num_file_names);
|
||||
#endif
|
||||
}
|
||||
|
||||
if(dir_names)
|
||||
qsort(file_names, num_file_names, sizeof *file_names, compare_ftw_str);
|
||||
while (num_file_names--)
|
||||
{
|
||||
qsort(dir_names, num_dir_names, sizeof *dir_names, compare_ftw_str);
|
||||
while(num_dir_names--)
|
||||
{
|
||||
memcpy(dir+dirlen, dir_names[num_dir_names].str, dir_names[num_dir_names].len+1);
|
||||
tp_ftw(screen, dir, dirlen+dir_names[num_dir_names].len, rsrc, fn);
|
||||
free(dir_names[num_dir_names].str);
|
||||
}
|
||||
free(dir_names);
|
||||
free(file_names[num_file_names].str);
|
||||
}
|
||||
}
|
||||
free(file_names);
|
||||
#else
|
||||
fn(screen, dir, dirlen, file_names, num_file_names);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (dir_names)
|
||||
{
|
||||
qsort(dir_names, num_dir_names, sizeof *dir_names, compare_ftw_str);
|
||||
while (num_dir_names--)
|
||||
{
|
||||
memcpy(dir + dirlen, dir_names[num_dir_names].str,
|
||||
dir_names[num_dir_names].len + 1);
|
||||
tp_ftw(screen, dir, dirlen + dir_names[num_dir_names].len, rsrc, fn);
|
||||
free(dir_names[num_dir_names].str);
|
||||
}
|
||||
free(dir_names);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,17 +17,21 @@
|
|||
|
||||
#define TP_FTW_PATHSIZE 400
|
||||
|
||||
typedef struct tp_ftw_str {
|
||||
typedef struct tp_ftw_str
|
||||
{
|
||||
char *str;
|
||||
unsigned char len;
|
||||
// unsigned char is_rsrc;
|
||||
} tp_ftw_str;
|
||||
|
||||
|
||||
void loadfont_callback(SDL_Surface * screen, const char *restrict const dir, unsigned dirlen, tp_ftw_str *files, unsigned i);
|
||||
void loadfont_callback(SDL_Surface * screen, const char *restrict const dir,
|
||||
unsigned dirlen, tp_ftw_str * files, unsigned i);
|
||||
int compare_ftw_str(const void *v1, const void *v2);
|
||||
void tp_ftw(SDL_Surface * screen, char *restrict const dir, unsigned dirlen, int rsrc,
|
||||
void (*fn)(SDL_Surface * screen, const char *restrict const dir, unsigned dirlen, tp_ftw_str *files, unsigned count));
|
||||
void tp_ftw(SDL_Surface * screen, char *restrict const dir, unsigned dirlen,
|
||||
int rsrc, void (*fn) (SDL_Surface * screen,
|
||||
const char *restrict const dir,
|
||||
unsigned dirlen, tp_ftw_str * files,
|
||||
unsigned count));
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
107
src/floodfill.c
107
src/floodfill.c
|
|
@ -45,51 +45,52 @@ static int colors_close(SDL_Surface * canvas, Uint32 c1, Uint32 c2)
|
|||
#ifdef LOW_QUALITY_FLOOD_FILL
|
||||
return (c1 == c2);
|
||||
#else
|
||||
Uint8 r1, g1, b1,
|
||||
r2, g2, b2;
|
||||
Uint8 r1, g1, b1, r2, g2, b2;
|
||||
|
||||
if (c1 == c2)
|
||||
{
|
||||
/* Get it over with quick, if possible! */
|
||||
{
|
||||
/* Get it over with quick, if possible! */
|
||||
|
||||
return 1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
double r, g, b;
|
||||
SDL_GetRGB(c1, canvas->format, &r1, &g1, &b1);
|
||||
SDL_GetRGB(c2, canvas->format, &r2, &g2, &b2);
|
||||
{
|
||||
double r, g, b;
|
||||
SDL_GetRGB(c1, canvas->format, &r1, &g1, &b1);
|
||||
SDL_GetRGB(c2, canvas->format, &r2, &g2, &b2);
|
||||
|
||||
// use distance in linear RGB space
|
||||
r = sRGB_to_linear_table[r1] - sRGB_to_linear_table[r2];
|
||||
r *= r;
|
||||
g = sRGB_to_linear_table[g1] - sRGB_to_linear_table[g2];
|
||||
g *= g;
|
||||
b = sRGB_to_linear_table[b1] - sRGB_to_linear_table[b2];
|
||||
b *= b;
|
||||
// use distance in linear RGB space
|
||||
r = sRGB_to_linear_table[r1] - sRGB_to_linear_table[r2];
|
||||
r *= r;
|
||||
g = sRGB_to_linear_table[g1] - sRGB_to_linear_table[g2];
|
||||
g *= g;
|
||||
b = sRGB_to_linear_table[b1] - sRGB_to_linear_table[b2];
|
||||
b *= b;
|
||||
|
||||
// easy to confuse:
|
||||
// dark grey, brown, purple
|
||||
// light grey, tan
|
||||
// red, orange
|
||||
return r+g+b < 0.04;
|
||||
}
|
||||
// easy to confuse:
|
||||
// dark grey, brown, purple
|
||||
// light grey, tan
|
||||
// red, orange
|
||||
return r + g + b < 0.04;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/* Flood fill! */
|
||||
|
||||
void do_flood_fill(SDL_Surface * screen, SDL_Surface * canvas, int x, int y, Uint32 cur_colr, Uint32 old_colr)
|
||||
void do_flood_fill(SDL_Surface * screen, SDL_Surface * canvas, int x, int y,
|
||||
Uint32 cur_colr, Uint32 old_colr)
|
||||
{
|
||||
int fillL, fillR, i, in_line;
|
||||
static unsigned char prog_anim;
|
||||
Uint32 (*getpixel)(SDL_Surface *, int, int) = getpixels[canvas->format->BytesPerPixel];
|
||||
void (*putpixel)(SDL_Surface *, int, int, Uint32) = putpixels[canvas->format->BytesPerPixel];
|
||||
Uint32(*getpixel) (SDL_Surface *, int, int) =
|
||||
getpixels[canvas->format->BytesPerPixel];
|
||||
void (*putpixel) (SDL_Surface *, int, int, Uint32) =
|
||||
putpixels[canvas->format->BytesPerPixel];
|
||||
|
||||
|
||||
if (cur_colr == old_colr ||
|
||||
colors_close(canvas, cur_colr, old_colr))
|
||||
if (cur_colr == old_colr || colors_close(canvas, cur_colr, old_colr))
|
||||
return;
|
||||
|
||||
|
||||
|
|
@ -98,10 +99,10 @@ void do_flood_fill(SDL_Surface * screen, SDL_Surface * canvas, int x, int y, Uin
|
|||
|
||||
prog_anim++;
|
||||
if ((prog_anim % 4) == 0)
|
||||
{
|
||||
show_progress_bar(screen);
|
||||
playsound(screen, 0, SND_BUBBLE, 0, x, SNDDIST_NEAR);
|
||||
}
|
||||
{
|
||||
show_progress_bar(screen);
|
||||
playsound(screen, 0, SND_BUBBLE, 0, x, SNDDIST_NEAR);
|
||||
}
|
||||
|
||||
|
||||
/* Find left side, filling along the way */
|
||||
|
|
@ -109,13 +110,14 @@ void do_flood_fill(SDL_Surface * screen, SDL_Surface * canvas, int x, int y, Uin
|
|||
in_line = 1;
|
||||
|
||||
while (in_line)
|
||||
{
|
||||
putpixel(canvas, fillL, y, cur_colr);
|
||||
fillL--;
|
||||
{
|
||||
putpixel(canvas, fillL, y, cur_colr);
|
||||
fillL--;
|
||||
|
||||
in_line = (fillL < 0) ? 0 : colors_close(canvas, getpixel(canvas, fillL, y),
|
||||
old_colr);
|
||||
}
|
||||
in_line =
|
||||
(fillL < 0) ? 0 : colors_close(canvas, getpixel(canvas, fillL, y),
|
||||
old_colr);
|
||||
}
|
||||
|
||||
fillL++;
|
||||
|
||||
|
|
@ -124,14 +126,15 @@ void do_flood_fill(SDL_Surface * screen, SDL_Surface * canvas, int x, int y, Uin
|
|||
|
||||
in_line = 1;
|
||||
while (in_line)
|
||||
{
|
||||
putpixel(canvas, fillR, y, cur_colr);
|
||||
fillR++;
|
||||
{
|
||||
putpixel(canvas, fillR, y, cur_colr);
|
||||
fillR++;
|
||||
|
||||
in_line = (fillR >= canvas->w) ? 0 : colors_close(canvas, getpixel(canvas,
|
||||
fillR, y),
|
||||
old_colr);
|
||||
}
|
||||
in_line = (fillR >= canvas->w) ? 0 : colors_close(canvas, getpixel(canvas,
|
||||
fillR,
|
||||
y),
|
||||
old_colr);
|
||||
}
|
||||
|
||||
fillR--;
|
||||
|
||||
|
|
@ -139,12 +142,12 @@ void do_flood_fill(SDL_Surface * screen, SDL_Surface * canvas, int x, int y, Uin
|
|||
/* Search top and bottom */
|
||||
|
||||
for (i = fillL; i <= fillR; i++)
|
||||
{
|
||||
if (y > 0 && colors_close(canvas, getpixel(canvas, i, y - 1), old_colr))
|
||||
do_flood_fill(screen, canvas, i, y - 1, cur_colr, old_colr);
|
||||
{
|
||||
if (y > 0 && colors_close(canvas, getpixel(canvas, i, y - 1), old_colr))
|
||||
do_flood_fill(screen, canvas, i, y - 1, cur_colr, old_colr);
|
||||
|
||||
if (y < canvas->h && colors_close(canvas, getpixel(canvas, i, y + 1), old_colr))
|
||||
do_flood_fill(screen, canvas, i, y + 1, cur_colr, old_colr);
|
||||
}
|
||||
if (y < canvas->h
|
||||
&& colors_close(canvas, getpixel(canvas, i, y + 1), old_colr))
|
||||
do_flood_fill(screen, canvas, i, y + 1, cur_colr, old_colr);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@
|
|||
|
||||
#include "SDL.h"
|
||||
|
||||
void do_flood_fill(SDL_Surface * screen, SDL_Surface * canvas, int x, int y, Uint32 cur_colr, Uint32 old_colr);
|
||||
void do_flood_fill(SDL_Surface * screen, SDL_Surface * canvas, int x, int y,
|
||||
Uint32 cur_colr, Uint32 old_colr);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
1273
src/fonts.c
1273
src/fonts.c
File diff suppressed because it is too large
Load diff
45
src/fonts.h
45
src/fonts.h
|
|
@ -31,10 +31,10 @@
|
|||
#define SDL_WaitThread(tid,rcp) do{(void)tid;(void)rcp;}while(0)
|
||||
#define SDL_Thread int
|
||||
#define SDL_mutex int
|
||||
#define SDL_CreateMutex() 0 // creates in released state
|
||||
#define SDL_CreateMutex() 0 // creates in released state
|
||||
#define SDL_DestroyMutex(lock)
|
||||
#define SDL_mutexP(lock) // take lock
|
||||
#define SDL_mutexV(lock) // release lock
|
||||
#define SDL_mutexP(lock) // take lock
|
||||
#define SDL_mutexV(lock) // release lock
|
||||
#endif
|
||||
|
||||
extern SDL_Thread *font_thread;
|
||||
|
|
@ -48,11 +48,11 @@ extern int no_system_fonts;
|
|||
extern int was_bad_font;
|
||||
|
||||
|
||||
TTF_Font *BUGFIX_TTF_OpenFont206(const char * const file, int ptsize);
|
||||
TTF_Font *BUGFIX_TTF_OpenFont206(const char *const file, int ptsize);
|
||||
#define TTF_OpenFont BUGFIX_TTF_OpenFont206
|
||||
|
||||
TTF_Font *try_alternate_font(int size);
|
||||
TTF_Font *load_locale_font(TTF_Font *fallback, int size);
|
||||
TTF_Font *load_locale_font(TTF_Font * fallback, int size);
|
||||
int load_user_fonts(SDL_Surface * screen, void *vp);
|
||||
|
||||
#ifdef FORKED_FONTS
|
||||
|
|
@ -78,25 +78,29 @@ extern unsigned text_size;
|
|||
// nice progression (alternating 33% and 25%) 9 12 18 24 36 48 72 96 144 192
|
||||
// commonly hinted sizes seem to be: 9, 10, 12, 14, 18, 20 (less so), 24
|
||||
// reasonable: 9,12,18... and 10,14,18...
|
||||
static int text_sizes[] = {9, 12, 18, 24, 36, 48,
|
||||
56, 64, 96, 112, 128, 160}; // point sizes
|
||||
static int text_sizes[] = { 9, 12, 18, 24, 36, 48,
|
||||
56, 64, 96, 112, 128, 160
|
||||
}; // point sizes
|
||||
|
||||
#define MIN_TEXT_SIZE 0u
|
||||
#define MAX_TEXT_SIZE (sizeof text_sizes / sizeof text_sizes[0] - 1)
|
||||
|
||||
// for sorting through the font files at startup
|
||||
typedef struct style_info {
|
||||
typedef struct style_info
|
||||
{
|
||||
char *filename;
|
||||
char *directory;
|
||||
char *family; // name like "FooCorp Thunderstruck"
|
||||
char *style; // junk like "Oblique Demi-Bold"
|
||||
char *family; // name like "FooCorp Thunderstruck"
|
||||
char *style; // junk like "Oblique Demi-Bold"
|
||||
int italic;
|
||||
int boldness;
|
||||
int score;
|
||||
int truetype; // Is it? (TrueType gets priority)
|
||||
int truetype; // Is it? (TrueType gets priority)
|
||||
} style_info;
|
||||
|
||||
// user's notion of a font
|
||||
typedef struct family_info {
|
||||
typedef struct family_info
|
||||
{
|
||||
char *directory;
|
||||
char *family;
|
||||
char *filename[4];
|
||||
|
|
@ -104,7 +108,7 @@ typedef struct family_info {
|
|||
int score;
|
||||
} family_info;
|
||||
|
||||
extern TTF_Font * medium_font, * small_font, * large_font, * locale_font;
|
||||
extern TTF_Font *medium_font, *small_font, *large_font, *locale_font;
|
||||
|
||||
extern family_info **user_font_families;
|
||||
extern int num_font_families;
|
||||
|
|
@ -118,17 +122,16 @@ extern int num_font_styles_max;
|
|||
int compar_fontgroup(const void *v1, const void *v2);
|
||||
int compar_fontkiller(const void *v1, const void *v2);
|
||||
int compar_fontscore(const void *v1, const void *v2);
|
||||
void parse_font_style(style_info *si);
|
||||
void groupfonts_range(style_info **base, int count);
|
||||
void dupe_markdown_range(family_info **base, int count);
|
||||
void parse_font_style(style_info * si);
|
||||
void groupfonts_range(style_info ** base, int count);
|
||||
void dupe_markdown_range(family_info ** base, int count);
|
||||
void groupfonts(void);
|
||||
TTF_Font *getfonthandle(int desire);
|
||||
void loadfonts(SDL_Surface * screen, const char * const dir);
|
||||
void loadfonts(SDL_Surface * screen, const char *const dir);
|
||||
|
||||
int do_surfcmp(const SDL_Surface *const *const v1, const SDL_Surface *const *const v2);
|
||||
int do_surfcmp(const SDL_Surface * const *const v1,
|
||||
const SDL_Surface * const *const v2);
|
||||
int surfcmp(const void *s1, const void *s2);
|
||||
int charset_works(TTF_Font *font, const char *s);
|
||||
int charset_works(TTF_Font * font, const char *s);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -9,15 +9,15 @@
|
|||
#include "get_fname.h"
|
||||
#include "debug.h"
|
||||
|
||||
char * savedir;
|
||||
char *savedir;
|
||||
|
||||
|
||||
/* The filename for the current image: */
|
||||
|
||||
char * get_fname(const char * const name)
|
||||
char *get_fname(const char *const name)
|
||||
{
|
||||
char f[512];
|
||||
const char * tux_settings_dir;
|
||||
const char *tux_settings_dir;
|
||||
|
||||
|
||||
/* Where is the user's data directory?
|
||||
|
|
@ -54,46 +54,45 @@ char * get_fname(const char * const name)
|
|||
/* Put together home directory path + settings directory + filename... */
|
||||
|
||||
if (savedir == NULL)
|
||||
{
|
||||
/* Save directory not overridden: */
|
||||
|
||||
if (getenv("HOME") != NULL)
|
||||
{
|
||||
/* Save directory not overridden: */
|
||||
if (*name == '\0')
|
||||
{
|
||||
/* (Some mkdir()'s don't like trailing slashes) */
|
||||
|
||||
if (getenv("HOME") != NULL)
|
||||
{
|
||||
if (*name == '\0')
|
||||
{
|
||||
/* (Some mkdir()'s don't like trailing slashes) */
|
||||
|
||||
snprintf(f, sizeof(f), "%s/%s", getenv("HOME"), tux_settings_dir);
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf(f, sizeof(f), "%s/%s/%s",
|
||||
getenv("HOME"), tux_settings_dir, name);
|
||||
}
|
||||
}
|
||||
snprintf(f, sizeof(f), "%s/%s", getenv("HOME"), tux_settings_dir);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* WOAH! Don't know where HOME directory is! Last resort, use '.'! */
|
||||
|
||||
strcpy(f, name);
|
||||
}
|
||||
{
|
||||
snprintf(f, sizeof(f), "%s/%s/%s",
|
||||
getenv("HOME"), tux_settings_dir, name);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* WOAH! Don't know where HOME directory is! Last resort, use '.'! */
|
||||
|
||||
strcpy(f, name);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* User had overridden save directory with "--savedir" option: */
|
||||
|
||||
if (*name != '\0')
|
||||
{
|
||||
/* User had overridden save directory with "--savedir" option: */
|
||||
/* (Some mkdir()'s don't like trailing slashes) */
|
||||
|
||||
if (*name != '\0')
|
||||
{
|
||||
/* (Some mkdir()'s don't like trailing slashes) */
|
||||
|
||||
snprintf(f, sizeof(f), "%s/%s", savedir, name);
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf(f, sizeof(f), "%s", savedir);
|
||||
}
|
||||
snprintf(f, sizeof(f), "%s/%s", savedir, name);
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf(f, sizeof(f), "%s", savedir);
|
||||
}
|
||||
}
|
||||
|
||||
return strdup(f);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,10 +5,9 @@
|
|||
#ifndef GET_FNAME_H
|
||||
#define GET_FNAME_H
|
||||
|
||||
extern char * savedir;
|
||||
extern char *savedir;
|
||||
|
||||
char * get_fname(const char * const name);
|
||||
char *get_fname(const char *const name);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@
|
|||
#define GREAT_H
|
||||
|
||||
|
||||
const char * const great_strs[] = {
|
||||
const char *const great_strs[] = {
|
||||
gettext_noop("Great!"),
|
||||
gettext_noop("Cool!"),
|
||||
gettext_noop("Keep it up!"),
|
||||
|
|
|
|||
662
src/i18n.c
662
src/i18n.c
|
|
@ -41,7 +41,7 @@
|
|||
|
||||
/* Globals: */
|
||||
|
||||
const char * lang_prefixes[NUM_LANGS] = {
|
||||
const char *lang_prefixes[NUM_LANGS] = {
|
||||
"af",
|
||||
"ar",
|
||||
"be",
|
||||
|
|
@ -132,117 +132,117 @@ int lang_use_right_to_left[] = {
|
|||
};
|
||||
|
||||
|
||||
char * langstr;
|
||||
char *langstr;
|
||||
int need_own_font;
|
||||
int need_right_to_left;
|
||||
const char * lang_prefix;
|
||||
const char *lang_prefix;
|
||||
|
||||
const language_to_locale_struct language_to_locale_array[] = {
|
||||
{"english", "C"},
|
||||
{"american-english", "C"},
|
||||
{"arabic", "ar_SA.UTF-8"},
|
||||
{"croatian", "hr_HR.UTF-8"},
|
||||
{"hrvatski", "hr_HR.UTF-8"},
|
||||
{"catalan", "ca_ES.UTF-8"},
|
||||
{"catala", "ca_ES.UTF-8"},
|
||||
{"belarusian", "be_BY.UTF-8"},
|
||||
{"bielaruskaja", "be_BY.UTF-8"},
|
||||
{"czech", "cs_CZ.UTF-8"},
|
||||
{"cesky", "cs_CZ.UTF-8"},
|
||||
{"danish", "da_DK.UTF-8"},
|
||||
{"dansk", "da_DK.UTF-8"},
|
||||
{"german", "de_DE.UTF-8"},
|
||||
{"deutsch", "de_DE.UTF-8"},
|
||||
{"estonian", "et_EE.UTF-8"},
|
||||
{"greek", "el_GR.UTF-8"},
|
||||
{"gronings", "gos_NL.UTF-8"},
|
||||
{"zudelk-veenkelonioals","gos_NL.UTF-8"},
|
||||
{"gujarati", "gu_IN.UTF-8"},
|
||||
{"british-english", "en_GB.UTF-8"},
|
||||
{"british", "en_GB.UTF-8"},
|
||||
{"spanish", "es_ES.UTF-8"},
|
||||
{"mexican", "es_MX.UTF-8"},
|
||||
{"mexican-spanish", "es_MX.UTF-8"},
|
||||
{"espanol-mejicano", "es_MX.UTF-8"},
|
||||
{"espanol", "es_ES.UTF-8"},
|
||||
{"finnish", "fi_FI.UTF-8"},
|
||||
{"suomi", "fi_FI.UTF-8"},
|
||||
{"faroese", "fo_FO.UTF-8"},
|
||||
{"french", "fr_FR.UTF-8"},
|
||||
{"francais", "fr_FR.UTF-8"},
|
||||
{"gaelic", "ga_IE.UTF-8"},
|
||||
{"irish-gaelic", "ga_IE.UTF-8"},
|
||||
{"gaidhlig", "ga_IE.UTF-8"},
|
||||
{"scottish", "gd_GB.UTF-8"},
|
||||
{"ghaidhlig", "gd_GB.UTF-8"},
|
||||
{"scottish-gaelic", "gd_GB.UTF-8"},
|
||||
{"galician", "gl_ES.UTF-8"},
|
||||
{"galego", "gl_ES.UTF-8"},
|
||||
{"hebrew", "he_IL.UTF-8"},
|
||||
{"hindi", "hi_IN.UTF-8"},
|
||||
{"hungarian", "hu_HU.UTF-8"},
|
||||
{"magyar", "hu_HU.UTF-8"},
|
||||
{"indonesian", "id_ID.UTF-8"},
|
||||
{"bahasa-indonesia", "id_ID.UTF-8"},
|
||||
{"icelandic", "is_IS.UTF-8"},
|
||||
{"islenska", "is_IS.UTF-8"},
|
||||
{"italian", "it_IT.UTF-8"},
|
||||
{"italiano", "it_IT.UTF-8"},
|
||||
{"japanese", "ja_JP.UTF-8"},
|
||||
{"vietnamese", "vi_VN.UTF-8"},
|
||||
{"afrikaans", "af_ZA.UTF-8"},
|
||||
{"albanian", "sq_AL.UTF-8"},
|
||||
{"breton", "br_FR.UTF-8"},
|
||||
{"brezhoneg", "br_FR.UTF-8"},
|
||||
{"bulgarian", "bg_BG.UTF-8"},
|
||||
{"welsh", "cy_GB.UTF-8"},
|
||||
{"cymraeg", "cy_GB.UTF-8"},
|
||||
{"bokmal", "nb_NO.UTF-8"},
|
||||
{"basque", "eu_ES.UTF-8"},
|
||||
{"euskara", "eu_ES.UTF-8"},
|
||||
{"georgian", "ka_GE"},
|
||||
{"kinyarwanda", "rw_RW.UTF-8"},
|
||||
{"klingon", "tlh.UTF-8"},
|
||||
{"tlhIngan", "tlh.UTF-8"},
|
||||
{"tlhingan", "tlh.UTF-8"},
|
||||
{"korean", "ko_KR.UTF-8"},
|
||||
{"kurdish", "ku_TR.UTF-8"},
|
||||
{"tamil", "ta_IN.UTF-8"},
|
||||
{"lithuanian", "lt_LT.UTF-8"},
|
||||
{"lietuviu", "lt_LT.UTF-8"},
|
||||
{"malay", "ms_MY.UTF-8"},
|
||||
{"dutch", "nl_NL.UTF-8"},
|
||||
{"nederlands", "nl_NL.UTF-8"},
|
||||
{"norwegian", "nn_NO.UTF-8"},
|
||||
{"nynorsk", "nn_NO.UTF-8"},
|
||||
{"norsk", "nn_NO.UTF-8"},
|
||||
{"polish", "pl_PL.UTF-8"},
|
||||
{"polski", "pl_PL.UTF-8"},
|
||||
{"brazilian-portuguese", "pt_BR.UTF-8"},
|
||||
{"portugues-brazilian", "pt_BR.UTF-8"},
|
||||
{"brazilian", "pt_BR.UTF-8"},
|
||||
{"portuguese", "pt_PT.UTF-8"},
|
||||
{"portugues", "pt_PT.UTF-8"},
|
||||
{"romanian", "ro_RO.UTF-8"},
|
||||
{"russian", "ru_RU.UTF-8"},
|
||||
{"russkiy", "ru_RU.UTF-8"},
|
||||
{"slovak", "sk_SK.UTF-8"},
|
||||
{"slovenian", "sl_SI.UTF-8"},
|
||||
{"slovensko", "sl_SI.UTF-8"},
|
||||
{"serbian", "sr_YU.UTF-8"},
|
||||
{"swedish", "sv_SE.UTF-8"},
|
||||
{"svenska", "sv_SE.UTF-8"},
|
||||
{"swahili", "sw_TZ.UTF-8"},
|
||||
{"tagalog", "tl_PH.UTF-8"},
|
||||
{"thai", "th_TH.UTF-8"},
|
||||
{"tibetan", "bo_CN.UTF-8"}, /* Based on: http://texinfo.org/pipermail/texinfo-pretest/2005-April/000334.html */
|
||||
{"turkish", "tr_TR.UTF-8"},
|
||||
{"ukrainian", "uk_UA.UTF-8"},
|
||||
{"walloon", "wa_BE.UTF-8"},
|
||||
{"walon", "wa_BE.UTF-8"},
|
||||
{"chinese", "zh_CN.UTF-8"},
|
||||
{"simplified-chinese", "zh_CN.UTF-8"},
|
||||
{"traditional-chinese", "zh_TW.UTF-8"},
|
||||
{"english", "C"},
|
||||
{"american-english", "C"},
|
||||
{"arabic", "ar_SA.UTF-8"},
|
||||
{"croatian", "hr_HR.UTF-8"},
|
||||
{"hrvatski", "hr_HR.UTF-8"},
|
||||
{"catalan", "ca_ES.UTF-8"},
|
||||
{"catala", "ca_ES.UTF-8"},
|
||||
{"belarusian", "be_BY.UTF-8"},
|
||||
{"bielaruskaja", "be_BY.UTF-8"},
|
||||
{"czech", "cs_CZ.UTF-8"},
|
||||
{"cesky", "cs_CZ.UTF-8"},
|
||||
{"danish", "da_DK.UTF-8"},
|
||||
{"dansk", "da_DK.UTF-8"},
|
||||
{"german", "de_DE.UTF-8"},
|
||||
{"deutsch", "de_DE.UTF-8"},
|
||||
{"estonian", "et_EE.UTF-8"},
|
||||
{"greek", "el_GR.UTF-8"},
|
||||
{"gronings", "gos_NL.UTF-8"},
|
||||
{"zudelk-veenkelonioals", "gos_NL.UTF-8"},
|
||||
{"gujarati", "gu_IN.UTF-8"},
|
||||
{"british-english", "en_GB.UTF-8"},
|
||||
{"british", "en_GB.UTF-8"},
|
||||
{"spanish", "es_ES.UTF-8"},
|
||||
{"mexican", "es_MX.UTF-8"},
|
||||
{"mexican-spanish", "es_MX.UTF-8"},
|
||||
{"espanol-mejicano", "es_MX.UTF-8"},
|
||||
{"espanol", "es_ES.UTF-8"},
|
||||
{"finnish", "fi_FI.UTF-8"},
|
||||
{"suomi", "fi_FI.UTF-8"},
|
||||
{"faroese", "fo_FO.UTF-8"},
|
||||
{"french", "fr_FR.UTF-8"},
|
||||
{"francais", "fr_FR.UTF-8"},
|
||||
{"gaelic", "ga_IE.UTF-8"},
|
||||
{"irish-gaelic", "ga_IE.UTF-8"},
|
||||
{"gaidhlig", "ga_IE.UTF-8"},
|
||||
{"scottish", "gd_GB.UTF-8"},
|
||||
{"ghaidhlig", "gd_GB.UTF-8"},
|
||||
{"scottish-gaelic", "gd_GB.UTF-8"},
|
||||
{"galician", "gl_ES.UTF-8"},
|
||||
{"galego", "gl_ES.UTF-8"},
|
||||
{"hebrew", "he_IL.UTF-8"},
|
||||
{"hindi", "hi_IN.UTF-8"},
|
||||
{"hungarian", "hu_HU.UTF-8"},
|
||||
{"magyar", "hu_HU.UTF-8"},
|
||||
{"indonesian", "id_ID.UTF-8"},
|
||||
{"bahasa-indonesia", "id_ID.UTF-8"},
|
||||
{"icelandic", "is_IS.UTF-8"},
|
||||
{"islenska", "is_IS.UTF-8"},
|
||||
{"italian", "it_IT.UTF-8"},
|
||||
{"italiano", "it_IT.UTF-8"},
|
||||
{"japanese", "ja_JP.UTF-8"},
|
||||
{"vietnamese", "vi_VN.UTF-8"},
|
||||
{"afrikaans", "af_ZA.UTF-8"},
|
||||
{"albanian", "sq_AL.UTF-8"},
|
||||
{"breton", "br_FR.UTF-8"},
|
||||
{"brezhoneg", "br_FR.UTF-8"},
|
||||
{"bulgarian", "bg_BG.UTF-8"},
|
||||
{"welsh", "cy_GB.UTF-8"},
|
||||
{"cymraeg", "cy_GB.UTF-8"},
|
||||
{"bokmal", "nb_NO.UTF-8"},
|
||||
{"basque", "eu_ES.UTF-8"},
|
||||
{"euskara", "eu_ES.UTF-8"},
|
||||
{"georgian", "ka_GE"},
|
||||
{"kinyarwanda", "rw_RW.UTF-8"},
|
||||
{"klingon", "tlh.UTF-8"},
|
||||
{"tlhIngan", "tlh.UTF-8"},
|
||||
{"tlhingan", "tlh.UTF-8"},
|
||||
{"korean", "ko_KR.UTF-8"},
|
||||
{"kurdish", "ku_TR.UTF-8"},
|
||||
{"tamil", "ta_IN.UTF-8"},
|
||||
{"lithuanian", "lt_LT.UTF-8"},
|
||||
{"lietuviu", "lt_LT.UTF-8"},
|
||||
{"malay", "ms_MY.UTF-8"},
|
||||
{"dutch", "nl_NL.UTF-8"},
|
||||
{"nederlands", "nl_NL.UTF-8"},
|
||||
{"norwegian", "nn_NO.UTF-8"},
|
||||
{"nynorsk", "nn_NO.UTF-8"},
|
||||
{"norsk", "nn_NO.UTF-8"},
|
||||
{"polish", "pl_PL.UTF-8"},
|
||||
{"polski", "pl_PL.UTF-8"},
|
||||
{"brazilian-portuguese", "pt_BR.UTF-8"},
|
||||
{"portugues-brazilian", "pt_BR.UTF-8"},
|
||||
{"brazilian", "pt_BR.UTF-8"},
|
||||
{"portuguese", "pt_PT.UTF-8"},
|
||||
{"portugues", "pt_PT.UTF-8"},
|
||||
{"romanian", "ro_RO.UTF-8"},
|
||||
{"russian", "ru_RU.UTF-8"},
|
||||
{"russkiy", "ru_RU.UTF-8"},
|
||||
{"slovak", "sk_SK.UTF-8"},
|
||||
{"slovenian", "sl_SI.UTF-8"},
|
||||
{"slovensko", "sl_SI.UTF-8"},
|
||||
{"serbian", "sr_YU.UTF-8"},
|
||||
{"swedish", "sv_SE.UTF-8"},
|
||||
{"svenska", "sv_SE.UTF-8"},
|
||||
{"swahili", "sw_TZ.UTF-8"},
|
||||
{"tagalog", "tl_PH.UTF-8"},
|
||||
{"thai", "th_TH.UTF-8"},
|
||||
{"tibetan", "bo_CN.UTF-8"}, /* Based on: http://texinfo.org/pipermail/texinfo-pretest/2005-April/000334.html */
|
||||
{"turkish", "tr_TR.UTF-8"},
|
||||
{"ukrainian", "uk_UA.UTF-8"},
|
||||
{"walloon", "wa_BE.UTF-8"},
|
||||
{"walon", "wa_BE.UTF-8"},
|
||||
{"chinese", "zh_CN.UTF-8"},
|
||||
{"simplified-chinese", "zh_CN.UTF-8"},
|
||||
{"traditional-chinese", "zh_TW.UTF-8"},
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -251,10 +251,10 @@ static int search_int_array(int l, int *array)
|
|||
int i;
|
||||
|
||||
for (i = 0; array[i] != -1; i++)
|
||||
{
|
||||
if (array[i] == l)
|
||||
return 1;
|
||||
}
|
||||
{
|
||||
if (array[i] == l)
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -270,7 +270,7 @@ void set_langstr(const char *s)
|
|||
|
||||
void set_current_language(void)
|
||||
{
|
||||
char * loc;
|
||||
char *loc;
|
||||
int lang, i, found;
|
||||
|
||||
bindtextdomain("tuxpaint", LOCALEDIR);
|
||||
|
|
@ -288,53 +288,53 @@ void set_current_language(void)
|
|||
#ifndef WIN32
|
||||
loc = setlocale(LC_MESSAGES, NULL);
|
||||
if (loc != NULL)
|
||||
{
|
||||
if (strstr(loc, "LC_MESSAGES") != NULL)
|
||||
loc = getenv("LANG");
|
||||
}
|
||||
{
|
||||
if (strstr(loc, "LC_MESSAGES") != NULL)
|
||||
loc = getenv("LANG");
|
||||
}
|
||||
#else
|
||||
bind_textdomain_codeset("tuxpaint", "UTF-8");
|
||||
loc = getenv("LANGUAGE");
|
||||
if (!loc)
|
||||
{
|
||||
loc = _nl_locale_name(LC_MESSAGES, "");
|
||||
if (loc)
|
||||
{
|
||||
loc = _nl_locale_name(LC_MESSAGES, "");
|
||||
if (loc)
|
||||
{
|
||||
char *s;
|
||||
int len;
|
||||
len = strlen("LANGUAGE=")+strlen(loc)+1;
|
||||
s = malloc(len);
|
||||
snprintf(s, len, "LANGUAGE=%s", loc);
|
||||
putenv(s);
|
||||
}
|
||||
char *s;
|
||||
int len;
|
||||
len = strlen("LANGUAGE=") + strlen(loc) + 1;
|
||||
s = malloc(len);
|
||||
snprintf(s, len, "LANGUAGE=%s", loc);
|
||||
putenv(s);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
//debug(loc);
|
||||
|
||||
if (loc != NULL)
|
||||
{
|
||||
/* Which, if any, of the locales is it? */
|
||||
|
||||
found = 0;
|
||||
|
||||
for (i = 0; i < NUM_LANGS && found == 0; i++)
|
||||
{
|
||||
/* Which, if any, of the locales is it? */
|
||||
|
||||
found = 0;
|
||||
|
||||
for (i = 0; i < NUM_LANGS && found == 0; i++)
|
||||
{
|
||||
// Case-insensitive (both "pt_BR" and "pt_br" work, etc.)
|
||||
if (strncasecmp(loc, lang_prefixes[i], strlen(lang_prefixes[i])) == 0)
|
||||
{
|
||||
lang = i;
|
||||
found = 1;
|
||||
}
|
||||
}
|
||||
// Case-insensitive (both "pt_BR" and "pt_br" work, etc.)
|
||||
if (strncasecmp(loc, lang_prefixes[i], strlen(lang_prefixes[i])) == 0)
|
||||
{
|
||||
lang = i;
|
||||
found = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lang_prefix = lang_prefixes[lang];
|
||||
need_own_font = search_int_array(lang,lang_use_own_font);
|
||||
need_right_to_left = search_int_array(lang,lang_use_right_to_left);
|
||||
need_own_font = search_int_array(lang, lang_use_own_font);
|
||||
need_right_to_left = search_int_array(lang, lang_use_right_to_left);
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,"DEBUG: Language is %s (%d)\n", lang_prefix, lang);
|
||||
fprintf(stderr, "DEBUG: Language is %s (%d)\n", lang_prefix, lang);
|
||||
fflush(stderr);
|
||||
#endif
|
||||
|
||||
|
|
@ -343,228 +343,226 @@ void set_current_language(void)
|
|||
|
||||
/* FIXME: All this should REALLY be array-based!!! */
|
||||
/* Show available languages: */
|
||||
void show_lang_usage(FILE * f, const char * const prg)
|
||||
void show_lang_usage(FILE * f, const char *const prg)
|
||||
{
|
||||
fprintf(f,
|
||||
"\n"
|
||||
"Usage: %s [--lang LANGUAGE]\n"
|
||||
"\n"
|
||||
"LANGUAGE may be one of:\n"
|
||||
/* C */ " english american-english\n"
|
||||
/* af */ " afrikaans\n"
|
||||
/* sq */ " albanian\n"
|
||||
/* ar */ " arabic\n"
|
||||
/* eu */ " basque euskara\n"
|
||||
/* be */ " belarusian bielaruskaja\n"
|
||||
/* nb */ " bokmal\n"
|
||||
/* pt_BR */ " brazilian brazilian-portuguese portugues-brazilian\n"
|
||||
/* br */ " breton brezhoneg\n"
|
||||
/* en_GB */ " british british-english\n"
|
||||
/* bg_BG */ " bulgarian\n"
|
||||
/* ca */ " catalan catala\n"
|
||||
/* zh_CN */ " chinese simplified-chinese\n"
|
||||
/* zh_TW */ " traditional-chinese\n"
|
||||
/* hr */ " croatian hrvatski\n"
|
||||
/* cs */ " czech cesky\n"
|
||||
/* da */ " danish dansk\n"
|
||||
/* nl */ " dutch nederlands\n"
|
||||
/* et */ " estonian\n"
|
||||
/* fo */ " faroese\n"
|
||||
/* fi */ " finnish suomi\n"
|
||||
/* fr */ " french francais\n"
|
||||
/* ga */ " gaelic irish-gaelic gaidhlig\n"
|
||||
/* gl */ " galician galego\n"
|
||||
/* ka */ " georgian\n"
|
||||
/* de */ " german deutsch\n"
|
||||
/* el */ " greek\n"
|
||||
/* gos */ " gronings zudelk-veenkelonioals\n"
|
||||
/* gu */ " gujarati\n"
|
||||
/* he */ " hebrew\n"
|
||||
/* hi */ " hindi\n"
|
||||
/* hu */ " hungarian magyar\n"
|
||||
/* is */ " icelandic islenska\n"
|
||||
/* id */ " indonesian bahasa-indonesia\n"
|
||||
/* it */ " italian italiano\n"
|
||||
/* ja */ " japanese\n"
|
||||
/* rw */ " kinyarwanda\n"
|
||||
/* tlh */ " klingon tlhIngan\n"
|
||||
/* ko */ " korean\n"
|
||||
/* ku */ " kurdish\n"
|
||||
/* lt */ " lithuanian lietuviu\n"
|
||||
/* ms */ " malay\n"
|
||||
/* es_MX */ " mexican mexican-spanish espanol-mejicano\n"
|
||||
/* nn */ " norwegian nynorsk norsk\n"
|
||||
/* pl */ " polish polski\n"
|
||||
/* pt_PT */ " portuguese portugues\n"
|
||||
/* ro */ " romanian\n"
|
||||
/* ru */ " russian russkiy\n"
|
||||
/* gd */ " scottish scottish-gaelic ghaidhlig\n"
|
||||
/* sr */ " serbian\n"
|
||||
/* sk */ " slovak\n"
|
||||
/* sl */ " slovenian slovensko\n"
|
||||
/* es */ " spanish espanol\n"
|
||||
/* sw */ " swahili\n"
|
||||
/* sv */ " swedish svenska\n"
|
||||
/* tl */ " tagalog\n"
|
||||
/* ta */ " tamil\n"
|
||||
/* bo */ " tibetan\n"
|
||||
/* th */ " thai\n"
|
||||
/* tr */ " turkish\n"
|
||||
/* uk */ " ukrainian\n"
|
||||
/* vi */ " vietnamese\n"
|
||||
/* wa */ " walloon walon\n"
|
||||
/* cy */ " welsh cymraeg\n"
|
||||
"\n",
|
||||
prg);
|
||||
"\n"
|
||||
"Usage: %s [--lang LANGUAGE]\n" "\n" "LANGUAGE may be one of:\n"
|
||||
/* C */ " english american-english\n"
|
||||
/* af */ " afrikaans\n"
|
||||
/* sq */ " albanian\n"
|
||||
/* ar */ " arabic\n"
|
||||
/* eu */ " basque euskara\n"
|
||||
/* be */ " belarusian bielaruskaja\n"
|
||||
/* nb */ " bokmal\n"
|
||||
/* pt_BR */
|
||||
" brazilian brazilian-portuguese portugues-brazilian\n"
|
||||
/* br */ " breton brezhoneg\n"
|
||||
/* en_GB */ " british british-english\n"
|
||||
/* bg_BG */ " bulgarian\n"
|
||||
/* ca */ " catalan catala\n"
|
||||
/* zh_CN */ " chinese simplified-chinese\n"
|
||||
/* zh_TW */ " traditional-chinese\n"
|
||||
/* hr */ " croatian hrvatski\n"
|
||||
/* cs */ " czech cesky\n"
|
||||
/* da */ " danish dansk\n"
|
||||
/* nl */ " dutch nederlands\n"
|
||||
/* et */ " estonian\n"
|
||||
/* fo */ " faroese\n"
|
||||
/* fi */ " finnish suomi\n"
|
||||
/* fr */ " french francais\n"
|
||||
/* ga */ " gaelic irish-gaelic gaidhlig\n"
|
||||
/* gl */ " galician galego\n"
|
||||
/* ka */ " georgian\n"
|
||||
/* de */ " german deutsch\n"
|
||||
/* el */ " greek\n"
|
||||
/* gos */ " gronings zudelk-veenkelonioals\n"
|
||||
/* gu */ " gujarati\n"
|
||||
/* he */ " hebrew\n"
|
||||
/* hi */ " hindi\n"
|
||||
/* hu */ " hungarian magyar\n"
|
||||
/* is */ " icelandic islenska\n"
|
||||
/* id */ " indonesian bahasa-indonesia\n"
|
||||
/* it */ " italian italiano\n"
|
||||
/* ja */ " japanese\n"
|
||||
/* rw */ " kinyarwanda\n"
|
||||
/* tlh */ " klingon tlhIngan\n"
|
||||
/* ko */ " korean\n"
|
||||
/* ku */ " kurdish\n"
|
||||
/* lt */ " lithuanian lietuviu\n"
|
||||
/* ms */ " malay\n"
|
||||
/* es_MX */
|
||||
" mexican mexican-spanish espanol-mejicano\n"
|
||||
/* nn */ " norwegian nynorsk norsk\n"
|
||||
/* pl */ " polish polski\n"
|
||||
/* pt_PT */ " portuguese portugues\n"
|
||||
/* ro */ " romanian\n"
|
||||
/* ru */ " russian russkiy\n"
|
||||
/* gd */ " scottish scottish-gaelic ghaidhlig\n"
|
||||
/* sr */ " serbian\n"
|
||||
/* sk */ " slovak\n"
|
||||
/* sl */ " slovenian slovensko\n"
|
||||
/* es */ " spanish espanol\n"
|
||||
/* sw */ " swahili\n"
|
||||
/* sv */ " swedish svenska\n"
|
||||
/* tl */ " tagalog\n"
|
||||
/* ta */ " tamil\n"
|
||||
/* bo */ " tibetan\n"
|
||||
/* th */ " thai\n"
|
||||
/* tr */ " turkish\n"
|
||||
/* uk */ " ukrainian\n"
|
||||
/* vi */ " vietnamese\n"
|
||||
/* wa */ " walloon walon\n"
|
||||
/* cy */ " welsh cymraeg\n"
|
||||
"\n", prg);
|
||||
}
|
||||
|
||||
|
||||
/* FIXME: Add accented characters to the descriptions */
|
||||
/* Show available locales: */
|
||||
void show_locale_usage(FILE * f, const char * const prg)
|
||||
void show_locale_usage(FILE * f, const char *const prg)
|
||||
{
|
||||
fprintf(f,
|
||||
"\n"
|
||||
"Usage: %s [--locale LOCALE]\n"
|
||||
"\n"
|
||||
"LOCALE may be one of:\n"
|
||||
" C (English American English)\n"
|
||||
" af_ZA (Afrikaans)\n"
|
||||
"\n"
|
||||
"Usage: %s [--locale LOCALE]\n"
|
||||
"\n"
|
||||
"LOCALE may be one of:\n"
|
||||
" C (English American English)\n"
|
||||
" af_ZA (Afrikaans)\n"
|
||||
" ar_SA (Arabic)\n"
|
||||
" eu_ES (Baque Euskara)\n"
|
||||
" be_BY (Belarusian Bielaruskaja)\n"
|
||||
" nb_NO (Bokmal)\n"
|
||||
" pt_BR (Brazilian Brazilian Portuguese Portugues Brazilian)\n"
|
||||
" br_FR (Breton Brezhoneg)\n"
|
||||
" en_GB (British British English)\n"
|
||||
" bg_BG (Bulgarian)\n"
|
||||
" ca_ES (Catalan Catala)\n"
|
||||
" zh_CN (Chinese-Simplified)\n"
|
||||
" zh_TW (Chinese-Traditional)\n"
|
||||
" cs_CZ (Czech Cesky)\n"
|
||||
" da_DK (Danish Dansk)\n"
|
||||
" nl_NL (Dutch)\n"
|
||||
" fi_FI (Finnish Suomi)\n"
|
||||
" eu_ES (Baque Euskara)\n"
|
||||
" be_BY (Belarusian Bielaruskaja)\n"
|
||||
" nb_NO (Bokmal)\n"
|
||||
" pt_BR (Brazilian Brazilian Portuguese Portugues Brazilian)\n"
|
||||
" br_FR (Breton Brezhoneg)\n"
|
||||
" en_GB (British British English)\n"
|
||||
" bg_BG (Bulgarian)\n"
|
||||
" ca_ES (Catalan Catala)\n"
|
||||
" zh_CN (Chinese-Simplified)\n"
|
||||
" zh_TW (Chinese-Traditional)\n"
|
||||
" cs_CZ (Czech Cesky)\n"
|
||||
" da_DK (Danish Dansk)\n"
|
||||
" nl_NL (Dutch)\n"
|
||||
" fi_FI (Finnish Suomi)\n"
|
||||
" fo_FO (Faroese)\n"
|
||||
" fr_FR (French Francais)\n"
|
||||
" ga_IE (Irish Gaelic Gaidhlig)\n"
|
||||
" gd_GB (Scottish Gaelic Ghaidhlig)\n"
|
||||
" gl_ES (Galician Galego)\n"
|
||||
" gos_NL (Gronings Zudelk Veenkelonioals)\n"
|
||||
" fr_FR (French Francais)\n"
|
||||
" ga_IE (Irish Gaelic Gaidhlig)\n"
|
||||
" gd_GB (Scottish Gaelic Ghaidhlig)\n"
|
||||
" gl_ES (Galician Galego)\n"
|
||||
" gos_NL (Gronings Zudelk Veenkelonioals)\n"
|
||||
" gu_IN (Gujarati)\n"
|
||||
" de_DE (German Deutsch)\n"
|
||||
" et_EE (Estonian)\n"
|
||||
" el_GR (Greek)\n"
|
||||
" he_IL (Hebrew)\n"
|
||||
" hi_IN (Hindi)\n"
|
||||
" hr_HR (Croatian Hrvatski)\n"
|
||||
" hu_HU (Hungarian Magyar)\n"
|
||||
" tlh (Klingon tlhIngan)\n"
|
||||
" is_IS (Icelandic Islenska)\n"
|
||||
" id_ID (Indonesian Bahasa Indonesia)\n"
|
||||
" it_IT (Italian Italiano)\n"
|
||||
" ja_JP (Japanese)\n"
|
||||
" ka_GE (Georgian)\n"
|
||||
" ko_KR (Korean)\n"
|
||||
" de_DE (German Deutsch)\n"
|
||||
" et_EE (Estonian)\n"
|
||||
" el_GR (Greek)\n"
|
||||
" he_IL (Hebrew)\n"
|
||||
" hi_IN (Hindi)\n"
|
||||
" hr_HR (Croatian Hrvatski)\n"
|
||||
" hu_HU (Hungarian Magyar)\n"
|
||||
" tlh (Klingon tlhIngan)\n"
|
||||
" is_IS (Icelandic Islenska)\n"
|
||||
" id_ID (Indonesian Bahasa Indonesia)\n"
|
||||
" it_IT (Italian Italiano)\n"
|
||||
" ja_JP (Japanese)\n"
|
||||
" ka_GE (Georgian)\n"
|
||||
" ko_KR (Korean)\n"
|
||||
" ku_TR (Kurdish)\n"
|
||||
" ms_MY (Malay)\n"
|
||||
" lt_LT (Lithuanian Lietuviu)\n"
|
||||
" nn_NO (Norwegian Nynorsk Norsk)\n"
|
||||
" pl_PL (Polish Polski)\n"
|
||||
" pt_PT (Portuguese Portugues)\n"
|
||||
" ro_RO (Romanian)\n"
|
||||
" ru_RU (Russian Russkiy)\n"
|
||||
" rw_RW (Kinyarwanda)\n"
|
||||
" sk_SK (Slovak)\n"
|
||||
" sl_SI (Slovenian)\n"
|
||||
" sq_AL (Albanian)\n"
|
||||
" sr_YU (Serbian)\n"
|
||||
" es_ES (Spanish Espanol)\n"
|
||||
" es_MX (Mexican Mexican Spanish Espanol Mejicano)\n"
|
||||
" sw_TZ (Swahili)\n"
|
||||
" sv_SE (Swedish Svenska)\n"
|
||||
" ms_MY (Malay)\n"
|
||||
" lt_LT (Lithuanian Lietuviu)\n"
|
||||
" nn_NO (Norwegian Nynorsk Norsk)\n"
|
||||
" pl_PL (Polish Polski)\n"
|
||||
" pt_PT (Portuguese Portugues)\n"
|
||||
" ro_RO (Romanian)\n"
|
||||
" ru_RU (Russian Russkiy)\n"
|
||||
" rw_RW (Kinyarwanda)\n"
|
||||
" sk_SK (Slovak)\n"
|
||||
" sl_SI (Slovenian)\n"
|
||||
" sq_AL (Albanian)\n"
|
||||
" sr_YU (Serbian)\n"
|
||||
" es_ES (Spanish Espanol)\n"
|
||||
" es_MX (Mexican Mexican Spanish Espanol Mejicano)\n"
|
||||
" sw_TZ (Swahili)\n"
|
||||
" sv_SE (Swedish Svenska)\n"
|
||||
" tl_PH (Tagalog)\n"
|
||||
" bo_CN (Tibetan)\n"
|
||||
" th_TH (Thai)\n"
|
||||
" tr_TR (Turkish)\n"
|
||||
" uk_UA (Ukrainian)\n"
|
||||
" vi_VN (Vietnamese)\n"
|
||||
" wa_BE (Walloon)\n"
|
||||
" cy_GB (Welsh Cymraeg)\n"
|
||||
"\n",
|
||||
prg);
|
||||
" th_TH (Thai)\n"
|
||||
" tr_TR (Turkish)\n"
|
||||
" uk_UA (Ukrainian)\n"
|
||||
" vi_VN (Vietnamese)\n"
|
||||
" wa_BE (Walloon)\n"
|
||||
" cy_GB (Welsh Cymraeg)\n" "\n", prg);
|
||||
}
|
||||
|
||||
void setup_language(const char * const prg)
|
||||
void setup_language(const char *const prg)
|
||||
{
|
||||
|
||||
// Justify this or delete it. It seems to make Tux Paint
|
||||
// violate the behavior documented by "man 7 locale".
|
||||
#if 0
|
||||
if (langstr == NULL && getenv("LANG"))
|
||||
{
|
||||
if(!strncasecmp(getenv("LANG"), "lt_LT", 5))
|
||||
set_langstr("lithuanian");
|
||||
if(!strncasecmp(getenv("LANG"), "pl_PL", 5))
|
||||
set_langstr("polish");
|
||||
}
|
||||
{
|
||||
if (!strncasecmp(getenv("LANG"), "lt_LT", 5))
|
||||
set_langstr("lithuanian");
|
||||
if (!strncasecmp(getenv("LANG"), "pl_PL", 5))
|
||||
set_langstr("polish");
|
||||
}
|
||||
#endif
|
||||
|
||||
if (langstr != NULL)
|
||||
{
|
||||
int i =
|
||||
sizeof language_to_locale_array / sizeof language_to_locale_array[0];
|
||||
const char *locale = NULL;
|
||||
|
||||
while (i--)
|
||||
{
|
||||
int i = sizeof language_to_locale_array / sizeof language_to_locale_array[0];
|
||||
const char *locale = NULL;
|
||||
|
||||
while(i--)
|
||||
{
|
||||
if (strcmp(langstr, language_to_locale_array[i].language))
|
||||
continue;
|
||||
locale = language_to_locale_array[i].locale;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!locale)
|
||||
{
|
||||
if (strcmp(langstr, "help") == 0 || strcmp(langstr, "list") == 0)
|
||||
{
|
||||
show_lang_usage(stdout, prg);
|
||||
//free(langstr); // pointless
|
||||
exit(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "%s is an invalid language\n", langstr);
|
||||
show_lang_usage(stderr, prg);
|
||||
//free(langstr); // pointless
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
char *s;
|
||||
ssize_t len;
|
||||
|
||||
len = strlen("LANGUAGE=")+strlen(locale)+1;
|
||||
s = malloc(len);
|
||||
snprintf(s, len, "LANGUAGE=%s", locale);
|
||||
putenv(s);
|
||||
|
||||
len = strlen("LC_ALL=")+strlen(locale)+1;
|
||||
s = malloc(len);
|
||||
snprintf(s, len, "LC_ALL=%s", locale);
|
||||
putenv(s);
|
||||
}
|
||||
|
||||
setlocale(LC_ALL, "");
|
||||
free(langstr);
|
||||
if (strcmp(langstr, language_to_locale_array[i].language))
|
||||
continue;
|
||||
locale = language_to_locale_array[i].locale;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!locale)
|
||||
{
|
||||
if (strcmp(langstr, "help") == 0 || strcmp(langstr, "list") == 0)
|
||||
{
|
||||
show_lang_usage(stdout, prg);
|
||||
//free(langstr); // pointless
|
||||
exit(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "%s is an invalid language\n", langstr);
|
||||
show_lang_usage(stderr, prg);
|
||||
//free(langstr); // pointless
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
char *s;
|
||||
ssize_t len;
|
||||
|
||||
len = strlen("LANGUAGE=") + strlen(locale) + 1;
|
||||
s = malloc(len);
|
||||
snprintf(s, len, "LANGUAGE=%s", locale);
|
||||
putenv(s);
|
||||
|
||||
len = strlen("LC_ALL=") + strlen(locale) + 1;
|
||||
s = malloc(len);
|
||||
snprintf(s, len, "LC_ALL=%s", locale);
|
||||
putenv(s);
|
||||
}
|
||||
|
||||
setlocale(LC_ALL, "");
|
||||
free(langstr);
|
||||
}
|
||||
|
||||
set_current_language();
|
||||
}
|
||||
|
||||
|
||||
// handle --locale arg
|
||||
void do_locale_option(const char * const arg)
|
||||
void do_locale_option(const char *const arg)
|
||||
{
|
||||
int len = strlen(arg) + 6;
|
||||
char *str = malloc(len);
|
||||
|
|
@ -573,5 +571,5 @@ void do_locale_option(const char * const arg)
|
|||
// We leak "str" because it can not be freed. It is now part
|
||||
// of the environment. If it were local, the environment would
|
||||
// get corrupted.
|
||||
setlocale(LC_ALL, ""); /* use arg ? */
|
||||
setlocale(LC_ALL, ""); /* use arg ? */
|
||||
}
|
||||
|
|
|
|||
149
src/i18n.h
149
src/i18n.h
|
|
@ -18,78 +18,80 @@
|
|||
|
||||
/* Possible languages: */
|
||||
|
||||
enum {
|
||||
LANG_AF, /* Afrikaans */
|
||||
LANG_AR, /* Arabic */
|
||||
LANG_BE, /* Belarusian */
|
||||
LANG_BG, /* Bulgarian */
|
||||
LANG_BO, /* Tibetan */
|
||||
LANG_BR, /* Breton */
|
||||
LANG_CA, /* Catalan */
|
||||
LANG_CS, /* Czech */
|
||||
LANG_CY, /* Welsh */
|
||||
LANG_DA, /* Danish */
|
||||
LANG_DE, /* German */
|
||||
LANG_EL, /* Greek */
|
||||
LANG_EN, /* English (American) (DEFAULT) */
|
||||
LANG_EN_GB, /* English (British) */
|
||||
LANG_ES, /* Spanish */
|
||||
LANG_ES_MX, /* Spanish (Mexican) */
|
||||
LANG_ET, /* Estonian */
|
||||
LANG_EU, /* Basque */
|
||||
LANG_FI, /* Finnish */
|
||||
LANG_FO, /* Faroese */
|
||||
LANG_FR, /* French */
|
||||
LANG_GA, /* Irish Gaelic */
|
||||
LANG_GD, /* Scottish Gaelic */
|
||||
LANG_GL, /* Galician */
|
||||
LANG_GR, /* Gronings */
|
||||
LANG_GU, /* Gujarati */
|
||||
LANG_HE, /* Hebrew */
|
||||
LANG_HI, /* Hindi */
|
||||
LANG_HR, /* Croatian */
|
||||
LANG_HU, /* Hungarian */
|
||||
LANG_I_KLINGON_ROMANIZED, /* Klingon (Romanized) */
|
||||
LANG_ID, /* Indonesian */
|
||||
LANG_IS, /* Icelandic */
|
||||
LANG_IT, /* Italian */
|
||||
LANG_JA, /* Japanese */
|
||||
LANG_KA, /* Georgian */
|
||||
LANG_KO, /* Korean */
|
||||
LANG_KU, /* Kurdish */
|
||||
LANG_LT, /* Lithuanian */
|
||||
LANG_MS, /* Malay */
|
||||
LANG_NB, /* Norwegian Bokmal */
|
||||
LANG_NL, /* Dutch */
|
||||
LANG_NN, /* Norwegian Nynorsk */
|
||||
LANG_PL, /* Polish */
|
||||
LANG_PT_BR, /* Portuguese (Brazilian) */
|
||||
LANG_PT_PT, /* Portuguese (Portugal) */
|
||||
LANG_RO, /* Romanian */
|
||||
LANG_RU, /* Russian */
|
||||
LANG_RW, /* Kinyarwanda */
|
||||
LANG_SK, /* Slovak */
|
||||
LANG_SL, /* Slovenian */
|
||||
LANG_SQ, /* Albanian */
|
||||
LANG_SR, /* Serbian */
|
||||
LANG_SV, /* Swedish */
|
||||
LANG_SW, /* Swahili */
|
||||
LANG_TA, /* Tamil */
|
||||
LANG_TH, /* Thai */
|
||||
LANG_TL, /* Tagalog */
|
||||
LANG_TR, /* Turkish */
|
||||
LANG_UK, /* Ukrainian */
|
||||
LANG_VI, /* Vietnamese */
|
||||
LANG_WA, /* Walloon */
|
||||
LANG_ZH_CN, /* Chinese (Simplified) */
|
||||
LANG_ZH_TW, /* Chinese (Traditional) */
|
||||
enum
|
||||
{
|
||||
LANG_AF, /* Afrikaans */
|
||||
LANG_AR, /* Arabic */
|
||||
LANG_BE, /* Belarusian */
|
||||
LANG_BG, /* Bulgarian */
|
||||
LANG_BO, /* Tibetan */
|
||||
LANG_BR, /* Breton */
|
||||
LANG_CA, /* Catalan */
|
||||
LANG_CS, /* Czech */
|
||||
LANG_CY, /* Welsh */
|
||||
LANG_DA, /* Danish */
|
||||
LANG_DE, /* German */
|
||||
LANG_EL, /* Greek */
|
||||
LANG_EN, /* English (American) (DEFAULT) */
|
||||
LANG_EN_GB, /* English (British) */
|
||||
LANG_ES, /* Spanish */
|
||||
LANG_ES_MX, /* Spanish (Mexican) */
|
||||
LANG_ET, /* Estonian */
|
||||
LANG_EU, /* Basque */
|
||||
LANG_FI, /* Finnish */
|
||||
LANG_FO, /* Faroese */
|
||||
LANG_FR, /* French */
|
||||
LANG_GA, /* Irish Gaelic */
|
||||
LANG_GD, /* Scottish Gaelic */
|
||||
LANG_GL, /* Galician */
|
||||
LANG_GR, /* Gronings */
|
||||
LANG_GU, /* Gujarati */
|
||||
LANG_HE, /* Hebrew */
|
||||
LANG_HI, /* Hindi */
|
||||
LANG_HR, /* Croatian */
|
||||
LANG_HU, /* Hungarian */
|
||||
LANG_I_KLINGON_ROMANIZED, /* Klingon (Romanized) */
|
||||
LANG_ID, /* Indonesian */
|
||||
LANG_IS, /* Icelandic */
|
||||
LANG_IT, /* Italian */
|
||||
LANG_JA, /* Japanese */
|
||||
LANG_KA, /* Georgian */
|
||||
LANG_KO, /* Korean */
|
||||
LANG_KU, /* Kurdish */
|
||||
LANG_LT, /* Lithuanian */
|
||||
LANG_MS, /* Malay */
|
||||
LANG_NB, /* Norwegian Bokmal */
|
||||
LANG_NL, /* Dutch */
|
||||
LANG_NN, /* Norwegian Nynorsk */
|
||||
LANG_PL, /* Polish */
|
||||
LANG_PT_BR, /* Portuguese (Brazilian) */
|
||||
LANG_PT_PT, /* Portuguese (Portugal) */
|
||||
LANG_RO, /* Romanian */
|
||||
LANG_RU, /* Russian */
|
||||
LANG_RW, /* Kinyarwanda */
|
||||
LANG_SK, /* Slovak */
|
||||
LANG_SL, /* Slovenian */
|
||||
LANG_SQ, /* Albanian */
|
||||
LANG_SR, /* Serbian */
|
||||
LANG_SV, /* Swedish */
|
||||
LANG_SW, /* Swahili */
|
||||
LANG_TA, /* Tamil */
|
||||
LANG_TH, /* Thai */
|
||||
LANG_TL, /* Tagalog */
|
||||
LANG_TR, /* Turkish */
|
||||
LANG_UK, /* Ukrainian */
|
||||
LANG_VI, /* Vietnamese */
|
||||
LANG_WA, /* Walloon */
|
||||
LANG_ZH_CN, /* Chinese (Simplified) */
|
||||
LANG_ZH_TW, /* Chinese (Traditional) */
|
||||
NUM_LANGS
|
||||
};
|
||||
|
||||
|
||||
/* Types: */
|
||||
|
||||
typedef struct language_to_locale_struct {
|
||||
typedef struct language_to_locale_struct
|
||||
{
|
||||
const char *language;
|
||||
const char *locale;
|
||||
} language_to_locale_struct;
|
||||
|
|
@ -97,13 +99,13 @@ typedef struct language_to_locale_struct {
|
|||
|
||||
/* Globals: */
|
||||
|
||||
extern const char * lang_prefixes[NUM_LANGS];
|
||||
extern const char *lang_prefixes[NUM_LANGS];
|
||||
extern int lang_use_own_font[];
|
||||
extern int lang_use_right_to_left[];
|
||||
extern char * langstr;
|
||||
extern char *langstr;
|
||||
extern int need_own_font;
|
||||
extern int need_right_to_left;
|
||||
extern const char * lang_prefix;
|
||||
extern const char *lang_prefix;
|
||||
extern const language_to_locale_struct language_to_locale_array[];
|
||||
|
||||
|
||||
|
|
@ -112,11 +114,10 @@ extern const language_to_locale_struct language_to_locale_array[];
|
|||
|
||||
void set_langstr(const char *s);
|
||||
void set_current_language(void);
|
||||
void show_lang_usage(FILE * f, const char * const prg);
|
||||
void show_locale_usage(FILE * f, const char * const prg);
|
||||
void setup_language(const char * const prg);
|
||||
void do_locale_option(const char * const arg);
|
||||
void show_lang_usage(FILE * f, const char *const prg);
|
||||
void show_locale_usage(FILE * f, const char *const prg);
|
||||
void setup_language(const char *const prg);
|
||||
void do_locale_option(const char *const arg);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,4 @@
|
|||
|
||||
#include "SDL.h"
|
||||
|
||||
const char* SurfacePrint (SDL_Surface *surface, int showDialog);
|
||||
|
||||
|
||||
const char *SurfacePrint(SDL_Surface * surface, int showDialog);
|
||||
|
|
|
|||
61
src/magic.h
61
src/magic.h
|
|
@ -30,25 +30,26 @@
|
|||
|
||||
/* What tools are available: */
|
||||
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
MAGIC_FILL,
|
||||
MAGIC_GRASS,
|
||||
|
||||
|
||||
MAGIC_LARGEBRICK,
|
||||
MAGIC_SMALLBRICK,
|
||||
|
||||
|
||||
MAGIC_RAINBOW,
|
||||
MAGIC_SPARKLES,
|
||||
|
||||
|
||||
MAGIC_BLUR,
|
||||
MAGIC_SMUDGE,
|
||||
|
||||
|
||||
MAGIC_FADE,
|
||||
MAGIC_DARKEN,
|
||||
|
||||
|
||||
MAGIC_CHALK,
|
||||
MAGIC_BLOCKS,
|
||||
|
||||
|
||||
MAGIC_NEGATIVE,
|
||||
MAGIC_TINT,
|
||||
|
||||
|
|
@ -65,14 +66,14 @@ enum {
|
|||
/* Need for the color selector: */
|
||||
|
||||
const int magic_colors[] = {
|
||||
COLORSEL_ENABLE, // fill
|
||||
COLORSEL_ENABLE, // grass
|
||||
COLORSEL_ENABLE, // fill
|
||||
COLORSEL_ENABLE, // grass
|
||||
|
||||
COLORSEL_ENABLE, // large bricks
|
||||
COLORSEL_ENABLE, // small bricks
|
||||
COLORSEL_ENABLE, // large bricks
|
||||
COLORSEL_ENABLE, // small bricks
|
||||
|
||||
COLORSEL_DISABLE,
|
||||
COLORSEL_ENABLE, // sparkles
|
||||
COLORSEL_ENABLE, // sparkles
|
||||
|
||||
COLORSEL_DISABLE,
|
||||
COLORSEL_DISABLE,
|
||||
|
|
@ -84,7 +85,7 @@ const int magic_colors[] = {
|
|||
COLORSEL_DISABLE,
|
||||
|
||||
COLORSEL_DISABLE,
|
||||
COLORSEL_ENABLE, // tint
|
||||
COLORSEL_ENABLE, // tint
|
||||
|
||||
COLORSEL_DISABLE,
|
||||
COLORSEL_DISABLE,
|
||||
|
|
@ -95,7 +96,7 @@ const int magic_colors[] = {
|
|||
|
||||
/* Magic tool names: */
|
||||
|
||||
const char * const magic_names[NUM_MAGICS] = {
|
||||
const char *const magic_names[NUM_MAGICS] = {
|
||||
gettext_noop("Fill"),
|
||||
gettext_noop("Grass"),
|
||||
|
||||
|
|
@ -127,30 +128,33 @@ const char * const magic_names[NUM_MAGICS] = {
|
|||
|
||||
/* Some text to write when each tool is selected: */
|
||||
|
||||
const char * const magic_tips[NUM_MAGICS] = {
|
||||
const char *const magic_tips[NUM_MAGICS] = {
|
||||
gettext_noop("Click in the picture to fill that area with color."),
|
||||
gettext_noop("Click and move to draw grass. Don’t forget the dirt!"),
|
||||
|
||||
|
||||
gettext_noop("Click and move to draw large bricks."),
|
||||
gettext_noop("Click and move to draw small bricks."),
|
||||
|
||||
|
||||
gettext_noop("You can draw in rainbow colors!"),
|
||||
gettext_noop("Click and move to draw sparkles."),
|
||||
|
||||
|
||||
gettext_noop("Click and move the mouse around to blur the picture."),
|
||||
gettext_noop("Click and move the mouse around to smudge the picture."),
|
||||
|
||||
gettext_noop("Click and move to fade the colors."),
|
||||
gettext_noop("Click and move to darken the colors."),
|
||||
|
||||
gettext_noop("Click and move the mouse around to turn the picture into a chalk drawing."),
|
||||
gettext_noop
|
||||
("Click and move the mouse around to turn the picture into a chalk drawing."),
|
||||
gettext_noop("Click and move the mouse around to make the picture blocky."),
|
||||
|
||||
|
||||
gettext_noop("Click and move the mouse around to draw a negative."),
|
||||
gettext_noop("Click and move the mouse around to change the picture’s color."),
|
||||
gettext_noop
|
||||
("Click and move the mouse around to change the picture’s color."),
|
||||
|
||||
gettext_noop("Click and move the mouse around to make the picture drip."),
|
||||
gettext_noop("Click and move the mouse around to turn the picture into a cartoon."),
|
||||
gettext_noop
|
||||
("Click and move the mouse around to turn the picture into a cartoon."),
|
||||
|
||||
gettext_noop("Click to make a mirror image."),
|
||||
gettext_noop("Click to flip the picture upside-down."),
|
||||
|
|
@ -159,16 +163,16 @@ const char * const magic_tips[NUM_MAGICS] = {
|
|||
|
||||
/* Tool icon filenames: */
|
||||
|
||||
const char * const magic_img_fnames[NUM_MAGICS] = {
|
||||
const char *const magic_img_fnames[NUM_MAGICS] = {
|
||||
DATA_PREFIX "images/magic/fill.png",
|
||||
DATA_PREFIX "images/magic/grass.png",
|
||||
|
||||
|
||||
DATA_PREFIX "images/magic/largebrick.png",
|
||||
DATA_PREFIX "images/magic/smallbrick.png",
|
||||
|
||||
|
||||
DATA_PREFIX "images/magic/rainbow.png",
|
||||
DATA_PREFIX "images/magic/sparkles.png",
|
||||
|
||||
|
||||
DATA_PREFIX "images/magic/blur.png",
|
||||
DATA_PREFIX "images/magic/smudge.png",
|
||||
|
||||
|
|
@ -177,10 +181,10 @@ const char * const magic_img_fnames[NUM_MAGICS] = {
|
|||
|
||||
DATA_PREFIX "images/magic/chalk.png",
|
||||
DATA_PREFIX "images/magic/blocks.png",
|
||||
|
||||
|
||||
DATA_PREFIX "images/magic/negative.png",
|
||||
DATA_PREFIX "images/magic/tint.png",
|
||||
|
||||
|
||||
DATA_PREFIX "images/magic/drip.png",
|
||||
DATA_PREFIX "images/magic/cartoon.png",
|
||||
|
||||
|
|
@ -222,4 +226,3 @@ const int rainbow_hexes[NUM_RAINBOW_COLORS][3] = {
|
|||
{255, 0, 128},
|
||||
{255, 0, 64}
|
||||
};
|
||||
|
||||
|
|
|
|||
203
src/pixels.c
203
src/pixels.c
|
|
@ -34,169 +34,177 @@
|
|||
/* Draw a single pixel into the surface: */
|
||||
void putpixel8(SDL_Surface * surface, int x, int y, Uint32 pixel)
|
||||
{
|
||||
Uint8 * p;
|
||||
Uint8 *p;
|
||||
|
||||
/* Assuming the X/Y values are within the bounds of this surface... */
|
||||
if (likely( likely((unsigned)x<(unsigned)surface->w) && likely((unsigned)y<(unsigned)surface->h) ))
|
||||
{
|
||||
// Set a pointer to the exact location in memory of the pixel
|
||||
p = (Uint8 *) (((Uint8 *)surface->pixels) + /* Start: beginning of RAM */
|
||||
(y * surface->pitch) + /* Go down Y lines */
|
||||
x); /* Go in X pixels */
|
||||
if (likely
|
||||
(likely((unsigned) x < (unsigned) surface->w)
|
||||
&& likely((unsigned) y < (unsigned) surface->h)))
|
||||
{
|
||||
// Set a pointer to the exact location in memory of the pixel
|
||||
p = (Uint8 *) (((Uint8 *) surface->pixels) + /* Start: beginning of RAM */
|
||||
(y * surface->pitch) + /* Go down Y lines */
|
||||
x); /* Go in X pixels */
|
||||
|
||||
|
||||
/* Set the (correctly-sized) piece of data in the surface's RAM
|
||||
* to the pixel value sent in: */
|
||||
/* Set the (correctly-sized) piece of data in the surface's RAM
|
||||
* to the pixel value sent in: */
|
||||
|
||||
*p = pixel;
|
||||
}
|
||||
*p = pixel;
|
||||
}
|
||||
}
|
||||
|
||||
/* Draw a single pixel into the surface: */
|
||||
void putpixel16(SDL_Surface * surface, int x, int y, Uint32 pixel)
|
||||
{
|
||||
Uint8 * p;
|
||||
Uint8 *p;
|
||||
|
||||
/* Assuming the X/Y values are within the bounds of this surface... */
|
||||
if (likely( likely((unsigned)x<(unsigned)surface->w) && likely((unsigned)y<(unsigned)surface->h) ))
|
||||
{
|
||||
// Set a pointer to the exact location in memory of the pixel
|
||||
p = (Uint8 *) (((Uint8 *)surface->pixels) + /* Start: beginning of RAM */
|
||||
(y * surface->pitch) + /* Go down Y lines */
|
||||
(x * 2)); /* Go in X pixels */
|
||||
if (likely
|
||||
(likely((unsigned) x < (unsigned) surface->w)
|
||||
&& likely((unsigned) y < (unsigned) surface->h)))
|
||||
{
|
||||
// Set a pointer to the exact location in memory of the pixel
|
||||
p = (Uint8 *) (((Uint8 *) surface->pixels) + /* Start: beginning of RAM */
|
||||
(y * surface->pitch) + /* Go down Y lines */
|
||||
(x * 2)); /* Go in X pixels */
|
||||
|
||||
|
||||
/* Set the (correctly-sized) piece of data in the surface's RAM
|
||||
* to the pixel value sent in: */
|
||||
/* Set the (correctly-sized) piece of data in the surface's RAM
|
||||
* to the pixel value sent in: */
|
||||
|
||||
*(Uint16 *)p = pixel;
|
||||
}
|
||||
*(Uint16 *) p = pixel;
|
||||
}
|
||||
}
|
||||
|
||||
/* Draw a single pixel into the surface: */
|
||||
void putpixel24(SDL_Surface * surface, int x, int y, Uint32 pixel)
|
||||
{
|
||||
Uint8 * p;
|
||||
Uint8 *p;
|
||||
|
||||
/* Assuming the X/Y values are within the bounds of this surface... */
|
||||
if (likely( likely((unsigned)x<(unsigned)surface->w) && likely((unsigned)y<(unsigned)surface->h) ))
|
||||
if (likely
|
||||
(likely((unsigned) x < (unsigned) surface->w)
|
||||
&& likely((unsigned) y < (unsigned) surface->h)))
|
||||
{
|
||||
// Set a pointer to the exact location in memory of the pixel
|
||||
p = (Uint8 *) (((Uint8 *) surface->pixels) + /* Start: beginning of RAM */
|
||||
(y * surface->pitch) + /* Go down Y lines */
|
||||
(x * 3)); /* Go in X pixels */
|
||||
|
||||
|
||||
/* Set the (correctly-sized) piece of data in the surface's RAM
|
||||
* to the pixel value sent in: */
|
||||
|
||||
if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
|
||||
{
|
||||
// Set a pointer to the exact location in memory of the pixel
|
||||
p = (Uint8 *) (((Uint8 *)surface->pixels) + /* Start: beginning of RAM */
|
||||
(y * surface->pitch) + /* Go down Y lines */
|
||||
(x * 3)); /* Go in X pixels */
|
||||
|
||||
|
||||
/* Set the (correctly-sized) piece of data in the surface's RAM
|
||||
* to the pixel value sent in: */
|
||||
|
||||
if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
|
||||
{
|
||||
p[0] = (pixel >> 16) & 0xff;
|
||||
p[1] = (pixel >> 8) & 0xff;
|
||||
p[2] = pixel & 0xff;
|
||||
}
|
||||
else
|
||||
{
|
||||
p[0] = pixel & 0xff;
|
||||
p[1] = (pixel >> 8) & 0xff;
|
||||
p[2] = (pixel >> 16) & 0xff;
|
||||
}
|
||||
|
||||
p[0] = (pixel >> 16) & 0xff;
|
||||
p[1] = (pixel >> 8) & 0xff;
|
||||
p[2] = pixel & 0xff;
|
||||
}
|
||||
else
|
||||
{
|
||||
p[0] = pixel & 0xff;
|
||||
p[1] = (pixel >> 8) & 0xff;
|
||||
p[2] = (pixel >> 16) & 0xff;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/* Draw a single pixel into the surface: */
|
||||
void putpixel32(SDL_Surface * surface, int x, int y, Uint32 pixel)
|
||||
{
|
||||
Uint8 * p;
|
||||
Uint8 *p;
|
||||
|
||||
/* Assuming the X/Y values are within the bounds of this surface... */
|
||||
if (likely( likely((unsigned)x<(unsigned)surface->w) && likely((unsigned)y<(unsigned)surface->h) ))
|
||||
{
|
||||
// Set a pointer to the exact location in memory of the pixel
|
||||
p = (Uint8 *) (((Uint8 *)surface->pixels) + /* Start: beginning of RAM */
|
||||
(y * surface->pitch) + /* Go down Y lines */
|
||||
(x * 4)); /* Go in X pixels */
|
||||
if (likely
|
||||
(likely((unsigned) x < (unsigned) surface->w)
|
||||
&& likely((unsigned) y < (unsigned) surface->h)))
|
||||
{
|
||||
// Set a pointer to the exact location in memory of the pixel
|
||||
p = (Uint8 *) (((Uint8 *) surface->pixels) + /* Start: beginning of RAM */
|
||||
(y * surface->pitch) + /* Go down Y lines */
|
||||
(x * 4)); /* Go in X pixels */
|
||||
|
||||
|
||||
/* Set the (correctly-sized) piece of data in the surface's RAM
|
||||
* to the pixel value sent in: */
|
||||
/* Set the (correctly-sized) piece of data in the surface's RAM
|
||||
* to the pixel value sent in: */
|
||||
|
||||
*(Uint32 *)p = pixel; // 32-bit display
|
||||
}
|
||||
*(Uint32 *) p = pixel; // 32-bit display
|
||||
}
|
||||
}
|
||||
|
||||
/* Get a pixel: */
|
||||
Uint32 getpixel8(SDL_Surface * surface, int x, int y)
|
||||
{
|
||||
Uint8 * p;
|
||||
Uint8 *p;
|
||||
|
||||
/* get the X/Y values within the bounds of this surface */
|
||||
if (unlikely( (unsigned)x > (unsigned)surface->w - 1u ))
|
||||
x = (x<0) ? 0 : surface->w - 1;
|
||||
if (unlikely( (unsigned)y > (unsigned)surface->h - 1u ))
|
||||
y = (y<0) ? 0 : surface->h - 1;
|
||||
if (unlikely((unsigned) x > (unsigned) surface->w - 1u))
|
||||
x = (x < 0) ? 0 : surface->w - 1;
|
||||
if (unlikely((unsigned) y > (unsigned) surface->h - 1u))
|
||||
y = (y < 0) ? 0 : surface->h - 1;
|
||||
|
||||
/* Set a pointer to the exact location in memory of the pixel
|
||||
in question: */
|
||||
|
||||
p = (Uint8 *) (((Uint8 *)surface->pixels) + /* Start at top of RAM */
|
||||
(y * surface->pitch) + /* Go down Y lines */
|
||||
x); /* Go in X pixels */
|
||||
p = (Uint8 *) (((Uint8 *) surface->pixels) + /* Start at top of RAM */
|
||||
(y * surface->pitch) + /* Go down Y lines */
|
||||
x); /* Go in X pixels */
|
||||
|
||||
|
||||
/* Return the correctly-sized piece of data containing the
|
||||
* pixel's value (an 8-bit palette value, or a 16-, 24- or 32-bit
|
||||
* RGB value) */
|
||||
|
||||
return(*p);
|
||||
return (*p);
|
||||
}
|
||||
|
||||
/* Get a pixel: */
|
||||
Uint32 getpixel16(SDL_Surface * surface, int x, int y)
|
||||
{
|
||||
Uint8 * p;
|
||||
Uint8 *p;
|
||||
|
||||
/* get the X/Y values within the bounds of this surface */
|
||||
if (unlikely( (unsigned)x > (unsigned)surface->w - 1u ))
|
||||
x = (x<0) ? 0 : surface->w - 1;
|
||||
if (unlikely( (unsigned)y > (unsigned)surface->h - 1u ))
|
||||
y = (y<0) ? 0 : surface->h - 1;
|
||||
if (unlikely((unsigned) x > (unsigned) surface->w - 1u))
|
||||
x = (x < 0) ? 0 : surface->w - 1;
|
||||
if (unlikely((unsigned) y > (unsigned) surface->h - 1u))
|
||||
y = (y < 0) ? 0 : surface->h - 1;
|
||||
|
||||
/* Set a pointer to the exact location in memory of the pixel
|
||||
in question: */
|
||||
|
||||
p = (Uint8 *) (((Uint8 *)surface->pixels) + /* Start at top of RAM */
|
||||
(y * surface->pitch) + /* Go down Y lines */
|
||||
(x * 2)); /* Go in X pixels */
|
||||
p = (Uint8 *) (((Uint8 *) surface->pixels) + /* Start at top of RAM */
|
||||
(y * surface->pitch) + /* Go down Y lines */
|
||||
(x * 2)); /* Go in X pixels */
|
||||
|
||||
|
||||
/* Return the correctly-sized piece of data containing the
|
||||
* pixel's value (an 8-bit palette value, or a 16-, 24- or 32-bit
|
||||
* RGB value) */
|
||||
|
||||
return(*(Uint16 *)p);
|
||||
return (*(Uint16 *) p);
|
||||
}
|
||||
|
||||
/* Get a pixel: */
|
||||
Uint32 getpixel24(SDL_Surface * surface, int x, int y)
|
||||
{
|
||||
Uint8 * p;
|
||||
Uint8 *p;
|
||||
Uint32 pixel;
|
||||
|
||||
/* get the X/Y values within the bounds of this surface */
|
||||
if (unlikely( (unsigned)x > (unsigned)surface->w - 1u ))
|
||||
x = (x<0) ? 0 : surface->w - 1;
|
||||
if (unlikely( (unsigned)y > (unsigned)surface->h - 1u ))
|
||||
y = (y<0) ? 0 : surface->h - 1;
|
||||
if (unlikely((unsigned) x > (unsigned) surface->w - 1u))
|
||||
x = (x < 0) ? 0 : surface->w - 1;
|
||||
if (unlikely((unsigned) y > (unsigned) surface->h - 1u))
|
||||
y = (y < 0) ? 0 : surface->h - 1;
|
||||
|
||||
/* Set a pointer to the exact location in memory of the pixel
|
||||
in question: */
|
||||
|
||||
p = (Uint8 *) (((Uint8 *)surface->pixels) + /* Start at top of RAM */
|
||||
(y * surface->pitch) + /* Go down Y lines */
|
||||
(x * 3)); /* Go in X pixels */
|
||||
p = (Uint8 *) (((Uint8 *) surface->pixels) + /* Start at top of RAM */
|
||||
(y * surface->pitch) + /* Go down Y lines */
|
||||
(x * 3)); /* Go in X pixels */
|
||||
|
||||
|
||||
/* Return the correctly-sized piece of data containing the
|
||||
|
|
@ -216,33 +224,34 @@ Uint32 getpixel24(SDL_Surface * surface, int x, int y)
|
|||
/* Get a pixel: */
|
||||
Uint32 getpixel32(SDL_Surface * surface, int x, int y)
|
||||
{
|
||||
Uint8 * p;
|
||||
Uint8 *p;
|
||||
|
||||
/* get the X/Y values within the bounds of this surface */
|
||||
if (unlikely( (unsigned)x > (unsigned)surface->w - 1u ))
|
||||
x = (x<0) ? 0 : surface->w - 1;
|
||||
if (unlikely( (unsigned)y > (unsigned)surface->h - 1u ))
|
||||
y = (y<0) ? 0 : surface->h - 1;
|
||||
if (unlikely((unsigned) x > (unsigned) surface->w - 1u))
|
||||
x = (x < 0) ? 0 : surface->w - 1;
|
||||
if (unlikely((unsigned) y > (unsigned) surface->h - 1u))
|
||||
y = (y < 0) ? 0 : surface->h - 1;
|
||||
|
||||
/* Set a pointer to the exact location in memory of the pixel
|
||||
in question: */
|
||||
|
||||
p = (Uint8 *) (((Uint8 *)surface->pixels) + /* Start at top of RAM */
|
||||
(y * surface->pitch) + /* Go down Y lines */
|
||||
(x * 4)); /* Go in X pixels */
|
||||
p = (Uint8 *) (((Uint8 *) surface->pixels) + /* Start at top of RAM */
|
||||
(y * surface->pitch) + /* Go down Y lines */
|
||||
(x * 4)); /* Go in X pixels */
|
||||
|
||||
|
||||
/* Return the correctly-sized piece of data containing the
|
||||
* pixel's value (an 8-bit palette value, or a 16-, 24- or 32-bit
|
||||
* RGB value) */
|
||||
|
||||
return *(Uint32 *)p; // 32-bit display
|
||||
return *(Uint32 *) p; // 32-bit display
|
||||
}
|
||||
|
||||
void (*putpixels[])(SDL_Surface *, int, int, Uint32) = {
|
||||
putpixel8, putpixel8, putpixel16, putpixel24, putpixel32 };
|
||||
void (*putpixels[]) (SDL_Surface *, int, int, Uint32) =
|
||||
{
|
||||
putpixel8, putpixel8, putpixel16, putpixel24, putpixel32};
|
||||
|
||||
|
||||
Uint32 (*getpixels[])(SDL_Surface *, int, int) = {
|
||||
getpixel8, getpixel8, getpixel16, getpixel24, getpixel32 };
|
||||
|
||||
Uint32(*getpixels[])(SDL_Surface *, int, int) =
|
||||
{
|
||||
getpixel8, getpixel8, getpixel16, getpixel24, getpixel32};
|
||||
|
|
|
|||
|
|
@ -37,14 +37,13 @@ void putpixel16(SDL_Surface * surface, int x, int y, Uint32 pixel);
|
|||
void putpixel24(SDL_Surface * surface, int x, int y, Uint32 pixel);
|
||||
void putpixel32(SDL_Surface * surface, int x, int y, Uint32 pixel);
|
||||
|
||||
extern void (*putpixels[])(SDL_Surface *, int, int, Uint32);
|
||||
extern void (*putpixels[]) (SDL_Surface *, int, int, Uint32);
|
||||
|
||||
Uint32 getpixel8(SDL_Surface * surface, int x, int y);
|
||||
Uint32 getpixel16(SDL_Surface * surface, int x, int y);
|
||||
Uint32 getpixel24(SDL_Surface * surface, int x, int y);
|
||||
Uint32 getpixel32(SDL_Surface * surface, int x, int y);
|
||||
|
||||
extern Uint32 (*getpixels[])(SDL_Surface *, int, int);
|
||||
extern Uint32(*getpixels[]) (SDL_Surface *, int, int);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -2,61 +2,61 @@
|
|||
#include "debug.h"
|
||||
|
||||
#ifndef NOSOUND
|
||||
Mix_Chunk * sounds[NUM_SOUNDS];
|
||||
Mix_Chunk *sounds[NUM_SOUNDS];
|
||||
#endif
|
||||
|
||||
int mute, use_sound;
|
||||
int old_sound[4] = {-1, -1, -1, -1};
|
||||
int old_sound[4] = { -1, -1, -1, -1 };
|
||||
|
||||
void playsound(SDL_Surface * screen, int chan, int s, int override, int x, int y)
|
||||
void playsound(SDL_Surface * screen, int chan, int s, int override, int x,
|
||||
int y)
|
||||
{
|
||||
#ifndef NOSOUND
|
||||
int left, dist;
|
||||
|
||||
if (!mute && use_sound && s != SND_NONE)
|
||||
{
|
||||
if (override || !Mix_Playing(chan))
|
||||
{
|
||||
if (override || !Mix_Playing(chan))
|
||||
{
|
||||
Mix_PlayChannel(chan, sounds[s], 0);
|
||||
Mix_PlayChannel(chan, sounds[s], 0);
|
||||
|
||||
old_sound[chan] = s;
|
||||
}
|
||||
|
||||
if (old_sound[chan] == s)
|
||||
{
|
||||
if (y == SNDDIST_NEAR)
|
||||
dist = 0;
|
||||
else
|
||||
{
|
||||
if (y < 0)
|
||||
y = 0;
|
||||
else if (y >= screen->h - 1)
|
||||
y = screen->h - 1;
|
||||
|
||||
dist = (255 * ((screen->h - 1) - y)) / (screen->h - 1);
|
||||
}
|
||||
|
||||
if (x == SNDPOS_LEFT)
|
||||
left = 255 - dist;
|
||||
else if (x == SNDPOS_CENTER)
|
||||
left = (255 - dist) / 2;
|
||||
else if (x == SNDPOS_RIGHT)
|
||||
left = 0;
|
||||
else
|
||||
{
|
||||
if (x < 0)
|
||||
x = 0;
|
||||
else if (x >= screen->w)
|
||||
x = screen->w - 1;
|
||||
|
||||
left = ((255 - dist) * ((screen->w - 1) - x)) / (screen->w - 1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Mix_SetPanning(chan, left, (255 - dist) - left);
|
||||
}
|
||||
old_sound[chan] = s;
|
||||
}
|
||||
|
||||
if (old_sound[chan] == s)
|
||||
{
|
||||
if (y == SNDDIST_NEAR)
|
||||
dist = 0;
|
||||
else
|
||||
{
|
||||
if (y < 0)
|
||||
y = 0;
|
||||
else if (y >= screen->h - 1)
|
||||
y = screen->h - 1;
|
||||
|
||||
dist = (255 * ((screen->h - 1) - y)) / (screen->h - 1);
|
||||
}
|
||||
|
||||
if (x == SNDPOS_LEFT)
|
||||
left = 255 - dist;
|
||||
else if (x == SNDPOS_CENTER)
|
||||
left = (255 - dist) / 2;
|
||||
else if (x == SNDPOS_RIGHT)
|
||||
left = 0;
|
||||
else
|
||||
{
|
||||
if (x < 0)
|
||||
x = 0;
|
||||
else if (x >= screen->w)
|
||||
x = screen->w - 1;
|
||||
|
||||
left = ((255 - dist) * ((screen->w - 1) - x)) / (screen->w - 1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Mix_SetPanning(chan, left, (255 - dist) - left);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,10 +11,10 @@
|
|||
|
||||
#define SNDDIST_NEAR -999
|
||||
|
||||
extern Mix_Chunk * sounds[NUM_SOUNDS];
|
||||
extern Mix_Chunk *sounds[NUM_SOUNDS];
|
||||
extern int mute, use_sound;
|
||||
|
||||
void playsound(SDL_Surface * screen, int chan, int s, int override, int x, int y);
|
||||
void playsound(SDL_Surface * screen, int chan, int s, int override, int x,
|
||||
int y);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@
|
|||
#include "progressbar.h"
|
||||
#include "debug.h"
|
||||
|
||||
SDL_Surface * img_progress;
|
||||
SDL_Surface *img_progress;
|
||||
int progress_bar_disabled, prog_bar_ctr;
|
||||
|
||||
void show_progress_bar(SDL_Surface * screen)
|
||||
|
|
@ -41,33 +41,32 @@ void show_progress_bar(SDL_Surface * screen)
|
|||
static Uint32 oldtime;
|
||||
Uint32 newtime;
|
||||
|
||||
if(progress_bar_disabled)
|
||||
if (progress_bar_disabled)
|
||||
return;
|
||||
|
||||
newtime = SDL_GetTicks();
|
||||
if(newtime > oldtime+15) // trying not to eat some serious CPU time!
|
||||
if (newtime > oldtime + 15) // trying not to eat some serious CPU time!
|
||||
{
|
||||
for (x = 0; x < screen->w; x = x + 65)
|
||||
{
|
||||
for (x = 0; x < screen->w; x = x + 65)
|
||||
{
|
||||
src.x = 65 - (prog_bar_ctr % 65);
|
||||
src.y = 0;
|
||||
src.w = 65;
|
||||
src.h = 24;
|
||||
src.x = 65 - (prog_bar_ctr % 65);
|
||||
src.y = 0;
|
||||
src.w = 65;
|
||||
src.h = 24;
|
||||
|
||||
dest.x = x;
|
||||
dest.y = screen->h - 24;
|
||||
dest.x = x;
|
||||
dest.y = screen->h - 24;
|
||||
|
||||
SDL_BlitSurface(img_progress, &src, screen, &dest);
|
||||
}
|
||||
|
||||
prog_bar_ctr++;
|
||||
|
||||
SDL_UpdateRect(screen, 0, screen->h - 24, screen->w, 24);
|
||||
SDL_BlitSurface(img_progress, &src, screen, &dest);
|
||||
}
|
||||
|
||||
prog_bar_ctr++;
|
||||
|
||||
SDL_UpdateRect(screen, 0, screen->h - 24, screen->w, 24);
|
||||
}
|
||||
oldtime = newtime;
|
||||
|
||||
|
||||
/* FIXME: RESURRECT THIS (bjk 2006.02.18) */
|
||||
//eat_sdl_events();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,10 +33,9 @@
|
|||
|
||||
#include "SDL.h"
|
||||
|
||||
extern SDL_Surface * img_progress;
|
||||
extern SDL_Surface *img_progress;
|
||||
extern int progress_bar_disabled, prog_bar_ctr;
|
||||
|
||||
void show_progress_bar(SDL_Surface * screen);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -30,18 +30,16 @@
|
|||
#include "rgblinear.h"
|
||||
#include "debug.h"
|
||||
|
||||
unsigned char linear_to_sRGB (float linear)
|
||||
unsigned char linear_to_sRGB(float linear)
|
||||
{
|
||||
unsigned slot;
|
||||
slot = linear*4096.0 + 0.5;
|
||||
if(slot>4095)
|
||||
{
|
||||
if(linear>0.5)
|
||||
slot = 4095;
|
||||
else
|
||||
slot = 0;
|
||||
}
|
||||
slot = linear * 4096.0 + 0.5;
|
||||
if (slot > 4095)
|
||||
{
|
||||
if (linear > 0.5)
|
||||
slot = 4095;
|
||||
else
|
||||
slot = 0;
|
||||
}
|
||||
return linear_to_sRGB_table[slot];
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -306,10 +306,8 @@ static const unsigned char linear_to_sRGB_table[4096] =
|
|||
"\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe"
|
||||
"\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe"
|
||||
"\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff"
|
||||
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
|
||||
;
|
||||
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff";
|
||||
|
||||
unsigned char linear_to_sRGB (float linear) FUNCTION;
|
||||
unsigned char linear_to_sRGB(float linear) FUNCTION;
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
162
src/shapes.h
162
src/shapes.h
|
|
@ -31,7 +31,8 @@
|
|||
|
||||
/* What shapes are available: */
|
||||
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
SHAPE_SQUARE,
|
||||
SHAPE_SQUARE_FILL,
|
||||
SHAPE_RECTANGLE,
|
||||
|
|
@ -53,60 +54,60 @@ enum {
|
|||
/* How many sides do they have? */
|
||||
|
||||
const int shape_sides[NUM_SHAPES] = {
|
||||
4, /* Square */
|
||||
4, /* Square */
|
||||
4, /* Rectangle */
|
||||
4, /* Rectangle */
|
||||
72, /* Circle */
|
||||
72, /* Circle */
|
||||
72, /* Ellipse */
|
||||
72, /* Ellipse */
|
||||
3, /* Triangle */
|
||||
3, /* Triangle */
|
||||
5, /* Pentagon */
|
||||
5, /* Pentagon */
|
||||
4, /* Rhombus */
|
||||
4 /* Rhombus */
|
||||
4, /* Square */
|
||||
4, /* Square */
|
||||
4, /* Rectangle */
|
||||
4, /* Rectangle */
|
||||
72, /* Circle */
|
||||
72, /* Circle */
|
||||
72, /* Ellipse */
|
||||
72, /* Ellipse */
|
||||
3, /* Triangle */
|
||||
3, /* Triangle */
|
||||
5, /* Pentagon */
|
||||
5, /* Pentagon */
|
||||
4, /* Rhombus */
|
||||
4 /* Rhombus */
|
||||
};
|
||||
|
||||
|
||||
/* Which shapes are 1:1 aspect? */
|
||||
|
||||
const int shape_locked[NUM_SHAPES] = {
|
||||
1, /* Square */
|
||||
1, /* Square */
|
||||
0, /* Rectangle */
|
||||
0, /* Rectangle */
|
||||
1, /* Circle */
|
||||
1, /* Circle */
|
||||
0, /* Ellipse */
|
||||
0, /* Ellipse */
|
||||
0, /* Triangle */
|
||||
0, /* Triangle */
|
||||
0, /* Pentagon */
|
||||
0, /* Pentagon */
|
||||
0, /* Rhombus */
|
||||
0 /* Rhombus */
|
||||
1, /* Square */
|
||||
1, /* Square */
|
||||
0, /* Rectangle */
|
||||
0, /* Rectangle */
|
||||
1, /* Circle */
|
||||
1, /* Circle */
|
||||
0, /* Ellipse */
|
||||
0, /* Ellipse */
|
||||
0, /* Triangle */
|
||||
0, /* Triangle */
|
||||
0, /* Pentagon */
|
||||
0, /* Pentagon */
|
||||
0, /* Rhombus */
|
||||
0 /* Rhombus */
|
||||
};
|
||||
|
||||
|
||||
/* Which shapes are filled? */
|
||||
|
||||
const int shape_filled[NUM_SHAPES] = {
|
||||
0, /* Square */
|
||||
1, /* Square */
|
||||
0, /* Rectangle */
|
||||
1, /* Rectangle */
|
||||
0, /* Circle */
|
||||
1, /* Circle */
|
||||
0, /* Ellipse */
|
||||
1, /* Ellipse */
|
||||
0, /* Triangle */
|
||||
1, /* Triangle */
|
||||
0, /* Pentagon */
|
||||
1, /* Pentagon */
|
||||
0, /* Rhombus */
|
||||
1 /* Rhombus */
|
||||
0, /* Square */
|
||||
1, /* Square */
|
||||
0, /* Rectangle */
|
||||
1, /* Rectangle */
|
||||
0, /* Circle */
|
||||
1, /* Circle */
|
||||
0, /* Ellipse */
|
||||
1, /* Ellipse */
|
||||
0, /* Triangle */
|
||||
1, /* Triangle */
|
||||
0, /* Pentagon */
|
||||
1, /* Pentagon */
|
||||
0, /* Rhombus */
|
||||
1 /* Rhombus */
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -114,46 +115,46 @@ const int shape_filled[NUM_SHAPES] = {
|
|||
/* Initial angles for shapes: */
|
||||
|
||||
const int shape_init_ang[NUM_SHAPES] = {
|
||||
45, /* Square */
|
||||
45, /* Square */
|
||||
45, /* Rectangle */
|
||||
45, /* Rectangle */
|
||||
0, /* Circle */
|
||||
0, /* Circle */
|
||||
0, /* Ellipse */
|
||||
0, /* Ellipse */
|
||||
210, /* Triangle */
|
||||
210, /* Triangle */
|
||||
162, /* Pentagon */
|
||||
162, /* Pentagon */
|
||||
0, /* Rhombus */
|
||||
0 /* Rhombus */
|
||||
45, /* Square */
|
||||
45, /* Square */
|
||||
45, /* Rectangle */
|
||||
45, /* Rectangle */
|
||||
0, /* Circle */
|
||||
0, /* Circle */
|
||||
0, /* Ellipse */
|
||||
0, /* Ellipse */
|
||||
210, /* Triangle */
|
||||
210, /* Triangle */
|
||||
162, /* Pentagon */
|
||||
162, /* Pentagon */
|
||||
0, /* Rhombus */
|
||||
0 /* Rhombus */
|
||||
};
|
||||
|
||||
|
||||
/* Shapes that don't make sense rotating (e.g., circles): */
|
||||
|
||||
const int shape_no_rotate[NUM_SHAPES] = {
|
||||
0, /* Square */
|
||||
0, /* Square */
|
||||
0, /* Rectangle */
|
||||
0, /* Rectangle */
|
||||
1, /* Circle */
|
||||
1, /* Circle */
|
||||
0, /* Ellipse */
|
||||
0, /* Ellipse */
|
||||
0, /* Triangle */
|
||||
0, /* Triangle */
|
||||
0, /* Pentagon */
|
||||
0, /* Pentagon */
|
||||
0, /* Rhombus */
|
||||
0 /* Rhombus */
|
||||
0, /* Square */
|
||||
0, /* Square */
|
||||
0, /* Rectangle */
|
||||
0, /* Rectangle */
|
||||
1, /* Circle */
|
||||
1, /* Circle */
|
||||
0, /* Ellipse */
|
||||
0, /* Ellipse */
|
||||
0, /* Triangle */
|
||||
0, /* Triangle */
|
||||
0, /* Pentagon */
|
||||
0, /* Pentagon */
|
||||
0, /* Rhombus */
|
||||
0 /* Rhombus */
|
||||
};
|
||||
|
||||
|
||||
/* Shape names: */
|
||||
|
||||
const char * const shape_names[NUM_SHAPES] = {
|
||||
const char *const shape_names[NUM_SHAPES] = {
|
||||
gettext_noop("Square"),
|
||||
gettext_noop("Square"),
|
||||
gettext_noop("Rectangle"),
|
||||
|
|
@ -173,27 +174,31 @@ const char * const shape_names[NUM_SHAPES] = {
|
|||
|
||||
/* Some text to write when each shape is selected: */
|
||||
|
||||
const char * const shape_tips[NUM_SHAPES] = {
|
||||
const char *const shape_tips[NUM_SHAPES] = {
|
||||
gettext_noop("A square is a rectangle with four equal sides."),
|
||||
gettext_noop("A square is a rectangle with four equal sides."),
|
||||
gettext_noop("A rectangle has four sides and four right angles."),
|
||||
gettext_noop("A rectangle has four sides and four right angles."),
|
||||
gettext_noop("A circle is a curve where all points have the same distance from the centre."),
|
||||
gettext_noop("A circle is a curve where all points have the same distance from the centre."),
|
||||
gettext_noop
|
||||
("A circle is a curve where all points have the same distance from the centre."),
|
||||
gettext_noop
|
||||
("A circle is a curve where all points have the same distance from the centre."),
|
||||
gettext_noop("An ellipse is a stretched circle."),
|
||||
gettext_noop("An ellipse is a stretched circle."),
|
||||
gettext_noop("A triangle has three sides."),
|
||||
gettext_noop("A triangle has three sides."),
|
||||
gettext_noop("A pentagon has five sides."),
|
||||
gettext_noop("A pentagon has five sides."),
|
||||
gettext_noop("A rhombus has four equal sides, and opposite sides are parallel."),
|
||||
gettext_noop("A rhombus has four equal sides, and opposite sides are parallel.")
|
||||
gettext_noop
|
||||
("A rhombus has four equal sides, and opposite sides are parallel."),
|
||||
gettext_noop
|
||||
("A rhombus has four equal sides, and opposite sides are parallel.")
|
||||
};
|
||||
|
||||
|
||||
/* Shape icon filenames: */
|
||||
|
||||
const char * const shape_img_fnames[NUM_SHAPES] = {
|
||||
const char *const shape_img_fnames[NUM_SHAPES] = {
|
||||
DATA_PREFIX "images/shapes/square.png",
|
||||
DATA_PREFIX "images/shapes/square_f.png",
|
||||
DATA_PREFIX "images/shapes/rectangle.png",
|
||||
|
|
@ -209,4 +214,3 @@ const char * const shape_img_fnames[NUM_SHAPES] = {
|
|||
DATA_PREFIX "images/shapes/diamond.png",
|
||||
DATA_PREFIX "images/shapes/diamond_f.png"
|
||||
};
|
||||
|
||||
|
|
|
|||
84
src/sounds.h
84
src/sounds.h
|
|
@ -35,59 +35,60 @@
|
|||
|
||||
#define SND_NONE -1
|
||||
|
||||
enum {
|
||||
SND_HARP, /* Begin / New */
|
||||
SND_CLICK, /* Tool selections */
|
||||
SND_BLEEP, /* Selector selection */
|
||||
SND_BUBBLE, /* Color selection */
|
||||
SND_STAMP, /* Using stamp tool */
|
||||
SND_LINE_START, /* Using line tool */
|
||||
enum
|
||||
{
|
||||
SND_HARP, /* Begin / New */
|
||||
SND_CLICK, /* Tool selections */
|
||||
SND_BLEEP, /* Selector selection */
|
||||
SND_BUBBLE, /* Color selection */
|
||||
SND_STAMP, /* Using stamp tool */
|
||||
SND_LINE_START, /* Using line tool */
|
||||
SND_LINE_END,
|
||||
SND_SCROLL, /* Selector scroll buttons */
|
||||
SND_PAINT1, /* Sound while painting */
|
||||
SND_SCROLL, /* Selector scroll buttons */
|
||||
SND_PAINT1, /* Sound while painting */
|
||||
SND_PAINT2,
|
||||
SND_PAINT3,
|
||||
SND_PAINT4,
|
||||
SND_ERASER1, /* Sound while erasing */
|
||||
SND_ERASER1, /* Sound while erasing */
|
||||
SND_ERASER2,
|
||||
SND_SAVE, /* Save sound effect */
|
||||
SND_PROMPT, /* Prompt animation sound effect */
|
||||
SND_DRIP, /* Magic drip */
|
||||
SND_CHALK, /* Magic chalk */
|
||||
SND_SPARKLES1, /* Magic sparkles */
|
||||
SND_SAVE, /* Save sound effect */
|
||||
SND_PROMPT, /* Prompt animation sound effect */
|
||||
SND_DRIP, /* Magic drip */
|
||||
SND_CHALK, /* Magic chalk */
|
||||
SND_SPARKLES1, /* Magic sparkles */
|
||||
SND_SPARKLES2,
|
||||
SND_THICK, /* Magic thick */
|
||||
SND_THIN, /* Magic thin */
|
||||
SND_FLIP, /* Magic flip */
|
||||
SND_MIRROR, /* Magic mirror */
|
||||
SND_NEGATIVE, /* Magic negative */
|
||||
SND_BLUR, /* Magic blur */
|
||||
SND_BLOCKS, /* Magic blocks */
|
||||
SND_FADE, /* Magic fade */
|
||||
SND_DARKEN, /* Magic darken */
|
||||
SND_RAINBOW, /* Magic rainbow */
|
||||
SND_SMUDGE, /* Magic smudge */
|
||||
SND_TINT, /* Magic tint */
|
||||
SND_CARTOON, /* Magic cartoon */
|
||||
SND_BRICK, /* Magic brick */
|
||||
SND_GRASS, /* Magic grass */
|
||||
SND_KEYCLICK, /* Text tool keyboard click feedback */
|
||||
SND_KEYCLICKRING, /* Text tool keyboard click feedback with bell ring */
|
||||
SND_RETURN, /* Text tool carriage return sound */
|
||||
SND_SHRINK, /* Stamp shrink */
|
||||
SND_GROW, /* Stamp grow */
|
||||
SND_ITALIC_ON, /* Italic on */
|
||||
SND_ITALIC_OFF, /* Italic off */
|
||||
SND_AREYOUSURE, /* "Are you sure?" */
|
||||
SND_YOUCANNOT, /* "No no no!" */
|
||||
SND_TUXOK, /* "Ok" */
|
||||
SND_THICK, /* Magic thick */
|
||||
SND_THIN, /* Magic thin */
|
||||
SND_FLIP, /* Magic flip */
|
||||
SND_MIRROR, /* Magic mirror */
|
||||
SND_NEGATIVE, /* Magic negative */
|
||||
SND_BLUR, /* Magic blur */
|
||||
SND_BLOCKS, /* Magic blocks */
|
||||
SND_FADE, /* Magic fade */
|
||||
SND_DARKEN, /* Magic darken */
|
||||
SND_RAINBOW, /* Magic rainbow */
|
||||
SND_SMUDGE, /* Magic smudge */
|
||||
SND_TINT, /* Magic tint */
|
||||
SND_CARTOON, /* Magic cartoon */
|
||||
SND_BRICK, /* Magic brick */
|
||||
SND_GRASS, /* Magic grass */
|
||||
SND_KEYCLICK, /* Text tool keyboard click feedback */
|
||||
SND_KEYCLICKRING, /* Text tool keyboard click feedback with bell ring */
|
||||
SND_RETURN, /* Text tool carriage return sound */
|
||||
SND_SHRINK, /* Stamp shrink */
|
||||
SND_GROW, /* Stamp grow */
|
||||
SND_ITALIC_ON, /* Italic on */
|
||||
SND_ITALIC_OFF, /* Italic off */
|
||||
SND_AREYOUSURE, /* "Are you sure?" */
|
||||
SND_YOUCANNOT, /* "No no no!" */
|
||||
SND_TUXOK, /* "Ok" */
|
||||
NUM_SOUNDS
|
||||
};
|
||||
|
||||
|
||||
/* Sound file filenames: */
|
||||
|
||||
static const char * sound_fnames[NUM_SOUNDS] = {
|
||||
static const char *sound_fnames[NUM_SOUNDS] = {
|
||||
DATA_PREFIX "sounds/harp.wav",
|
||||
DATA_PREFIX "sounds/click.wav",
|
||||
DATA_PREFIX "sounds/bleep.wav",
|
||||
|
|
@ -136,4 +137,3 @@ static const char * sound_fnames[NUM_SOUNDS] = {
|
|||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,8 @@
|
|||
|
||||
/* What tuxes are available: */
|
||||
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
TUX_DEFAULT,
|
||||
TUX_KISS,
|
||||
TUX_BORED,
|
||||
|
|
@ -31,7 +32,7 @@ enum {
|
|||
|
||||
/* Tux filenames: */
|
||||
|
||||
const char * const tux_img_fnames[NUM_TIP_TUX] = {
|
||||
const char *const tux_img_fnames[NUM_TIP_TUX] = {
|
||||
DATA_PREFIX "images/tux/default.png",
|
||||
DATA_PREFIX "images/tux/kiss.png",
|
||||
DATA_PREFIX "images/tux/bored.png",
|
||||
|
|
|
|||
|
|
@ -16,7 +16,8 @@
|
|||
|
||||
/* What titles are available: */
|
||||
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
TITLE_NONE,
|
||||
TITLE_NOCOLORS,
|
||||
TITLE_TOOLS,
|
||||
|
|
@ -33,7 +34,7 @@ enum {
|
|||
|
||||
/* Title names: */
|
||||
|
||||
const char * const title_names[NUM_TITLES] = {
|
||||
const char *const title_names[NUM_TITLES] = {
|
||||
"",
|
||||
"",
|
||||
gettext_noop("Tools"),
|
||||
|
|
@ -45,4 +46,3 @@ const char * const title_names[NUM_TITLES] = {
|
|||
gettext_noop("Letters"),
|
||||
gettext_noop("Magic")
|
||||
};
|
||||
|
||||
|
|
|
|||
16
src/tools.h
16
src/tools.h
|
|
@ -18,7 +18,8 @@
|
|||
|
||||
/* What tools are available: */
|
||||
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
TOOL_BRUSH,
|
||||
TOOL_STAMP,
|
||||
TOOL_LINES,
|
||||
|
|
@ -39,7 +40,7 @@ enum {
|
|||
|
||||
/* Tool names: */
|
||||
|
||||
const char * const tool_names[NUM_TOOLS] = {
|
||||
const char *const tool_names[NUM_TOOLS] = {
|
||||
gettext_noop("Paint"),
|
||||
gettext_noop("Stamp"),
|
||||
gettext_noop("Lines"),
|
||||
|
|
@ -59,12 +60,14 @@ const char * const tool_names[NUM_TOOLS] = {
|
|||
|
||||
/* Some text to write when each tool is selected: */
|
||||
|
||||
const char * const tool_tips[NUM_TOOLS] = {
|
||||
const char *const tool_tips[NUM_TOOLS] = {
|
||||
gettext_noop("Pick a color and a brush shape to draw with."),
|
||||
gettext_noop("Pick a picture to stamp around your drawing."),
|
||||
gettext_noop("Click to start drawing a line. Let go to complete it."),
|
||||
gettext_noop("Pick a shape. Click to pick the center, drag, then let go when it is the size you want. Move around to rotate it, and click to draw it."),
|
||||
gettext_noop("Choose a style of text. Click on your drawing and you can start typing."),
|
||||
gettext_noop
|
||||
("Pick a shape. Click to pick the center, drag, then let go when it is the size you want. Move around to rotate it, and click to draw it."),
|
||||
gettext_noop
|
||||
("Choose a style of text. Click on your drawing and you can start typing."),
|
||||
gettext_noop("Pick a magical effect to use on your drawing!"),
|
||||
/* Undo */ gettext_noop("Undo!"),
|
||||
/* Redo */ gettext_noop("Redo!"),
|
||||
|
|
@ -84,7 +87,7 @@ const char * const tool_tips[NUM_TOOLS] = {
|
|||
|
||||
/* Tool icon filenames: */
|
||||
|
||||
const char * const tool_img_fnames[NUM_TOOLS] = {
|
||||
const char *const tool_img_fnames[NUM_TOOLS] = {
|
||||
DATA_PREFIX "images/tools/brush.png",
|
||||
DATA_PREFIX "images/tools/stamp.png",
|
||||
DATA_PREFIX "images/tools/lines.png",
|
||||
|
|
@ -120,4 +123,3 @@ const int tool_tux[NUM_TOOLS] = {
|
|||
TUX_GREAT,
|
||||
TUX_DEFAULT
|
||||
};
|
||||
|
||||
|
|
|
|||
17256
src/tuxpaint.c
17256
src/tuxpaint.c
File diff suppressed because it is too large
Load diff
|
|
@ -1,16 +1,16 @@
|
|||
/****************************************************/
|
||||
/* */
|
||||
/* For Win32 that lacks Unix direct support. */
|
||||
/* - avoids including "windows.h" */
|
||||
/* */
|
||||
/* Copyright (c) 2002 John Popplewell */
|
||||
/* john@johnnypops.demon.co.uk */
|
||||
/* */
|
||||
/* Version 1.0.1 - fixed bug in opendir() */
|
||||
/* Version 1.0.0 - initial version */
|
||||
/* */
|
||||
/****************************************************/
|
||||
|
||||
/****************************************************/
|
||||
/* */
|
||||
/* For Win32 that lacks Unix direct support. */
|
||||
/* - avoids including "windows.h" */
|
||||
/* */
|
||||
/* Copyright (c) 2002 John Popplewell */
|
||||
/* john@johnnypops.demon.co.uk */
|
||||
/* */
|
||||
/* Version 1.0.1 - fixed bug in opendir() */
|
||||
/* Version 1.0.0 - initial version */
|
||||
/* */
|
||||
/****************************************************/
|
||||
|
||||
/*
|
||||
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
|
||||
|
|
@ -25,111 +25,104 @@
|
|||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
#include "win32_dirent.h"
|
||||
#include "debug.h"
|
||||
|
||||
DIR *opendir( const char *pSpec )
|
||||
{
|
||||
char pathname[MAX_PATH+2];
|
||||
DIR *pDir = calloc( 1, sizeof(DIR) );
|
||||
|
||||
if ( !pDir ) return NULL;
|
||||
strcpy( pathname, pSpec );
|
||||
strcat( pathname, "/*" );
|
||||
pDir->hFind = FindFirstFile(pathname, &pDir->wfd);
|
||||
if ( pDir->hFind == INVALID_HANDLE_VALUE )
|
||||
{
|
||||
free(pDir);
|
||||
pDir = NULL;
|
||||
}
|
||||
return pDir;
|
||||
}
|
||||
|
||||
|
||||
void closedir( DIR *pDir )
|
||||
{
|
||||
assert(pDir != NULL);
|
||||
free(pDir);
|
||||
}
|
||||
|
||||
|
||||
struct dirent *readdir(struct DIR *pDir)
|
||||
{
|
||||
assert(pDir != NULL);
|
||||
if (pDir->hFind)
|
||||
{
|
||||
strcpy(pDir->de.d_name, (const char *)pDir->wfd.cFileName);
|
||||
if (!FindNextFile(pDir->hFind, &pDir->wfd))
|
||||
{
|
||||
FindClose(pDir->hFind);
|
||||
pDir->hFind = NULL;
|
||||
}
|
||||
return &pDir->de;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
int alphasort(const void *a, const void *b)
|
||||
{
|
||||
return(strcmp((*(const struct dirent **)a)->d_name, (*(const struct dirent **)b)->d_name));
|
||||
}
|
||||
|
||||
|
||||
static int addToList( int i, struct dirent ***namelist, struct dirent *entry )
|
||||
{
|
||||
int size;
|
||||
struct dirent *block;
|
||||
|
||||
*namelist = (struct dirent**)realloc( (void*)(*namelist), (size_t)((i+1)*sizeof(struct dirent*)) );
|
||||
if ( *namelist == NULL ) return -1;
|
||||
|
||||
size = (((char*)&entry->d_name)-((char*)entry))+strlen(entry->d_name)+1;
|
||||
block = (struct dirent*)malloc( size );
|
||||
|
||||
if ( block == NULL ) return -1;
|
||||
|
||||
(*namelist)[i] = block;
|
||||
memcpy( block, entry, size );
|
||||
|
||||
return ++i;
|
||||
}
|
||||
|
||||
|
||||
int scandir( const char *dir, struct dirent ***namelist, selectCB select, comparCB compar)
|
||||
{
|
||||
DIR *pDir;
|
||||
int count;
|
||||
struct dirent *entry;
|
||||
|
||||
assert( (dir != NULL) && (namelist != NULL) );
|
||||
|
||||
pDir = opendir(dir);
|
||||
|
||||
if ( !pDir ) return -1;
|
||||
|
||||
count = 0;
|
||||
while( (entry = readdir(pDir)) != NULL )
|
||||
{
|
||||
if ( select == NULL || (select != NULL && select( entry )) )
|
||||
if ( (count = addToList( count, namelist, entry )) < 0 )
|
||||
break;
|
||||
}
|
||||
closedir( pDir );
|
||||
if ( count <= 0 ) return -1;
|
||||
|
||||
if ( compar != NULL )
|
||||
qsort( (void *)(*namelist), (size_t)count, sizeof(struct dirent *), compar );
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
DIR * opendir(const char *pSpec)
|
||||
{
|
||||
char pathname[MAX_PATH + 2];
|
||||
DIR * pDir = calloc(1, sizeof(DIR));
|
||||
if (!pDir)
|
||||
return NULL;
|
||||
strcpy(pathname, pSpec);
|
||||
strcat(pathname, "/*");
|
||||
pDir->hFind = FindFirstFile(pathname, &pDir->wfd);
|
||||
if (pDir->hFind == INVALID_HANDLE_VALUE)
|
||||
|
||||
{
|
||||
free(pDir);
|
||||
pDir = NULL;
|
||||
}
|
||||
return pDir;
|
||||
}
|
||||
void closedir(DIR * pDir)
|
||||
{
|
||||
assert(pDir != NULL);
|
||||
free(pDir);
|
||||
}
struct dirent *readdir(struct DIR *pDir)
|
||||
{
|
||||
assert(pDir != NULL);
|
||||
if (pDir->hFind)
|
||||
|
||||
{
|
||||
strcpy(pDir->de.d_name, (const char *) pDir->wfd.cFileName);
|
||||
if (!FindNextFile(pDir->hFind, &pDir->wfd))
|
||||
|
||||
{
|
||||
FindClose(pDir->hFind);
|
||||
pDir->hFind = NULL;
|
||||
}
|
||||
return &pDir->de;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
int alphasort(const void *a, const void *b)
|
||||
{
|
||||
return (strcmp
|
||||
((*(const struct dirent **) a)->d_name,
|
||||
(*(const struct dirent **) b)->d_name));
|
||||
}
static int addToList(int i, struct dirent ***namelist,
|
||||
struct dirent *entry)
|
||||
{
|
||||
int size;
|
||||
struct dirent *block;
|
||||
*namelist =
|
||||
(struct dirent **) realloc((void *) (*namelist),
|
||||
(size_t) ((i + 1) * sizeof(struct dirent *)));
|
||||
if (*namelist == NULL)
|
||||
return -1;
|
||||
size =
|
||||
(((char *) &entry->d_name) - ((char *) entry)) + strlen(entry->d_name) +
|
||||
1;
|
||||
block = (struct dirent *) malloc(size);
|
||||
if (block == NULL)
|
||||
return -1;
|
||||
(*namelist)[i] = block;
|
||||
memcpy(block, entry, size);
|
||||
return ++i;
|
||||
}
|
||||
int scandir(const char *dir, struct dirent ***namelist, selectCB select,
|
||||
comparCB compar)
|
||||
{
|
||||
DIR * pDir;
|
||||
int count;
|
||||
struct dirent *entry;
|
||||
assert((dir != NULL) && (namelist != NULL));
|
||||
pDir = opendir(dir);
|
||||
if (!pDir)
|
||||
return -1;
|
||||
count = 0;
|
||||
while ((entry = readdir(pDir)) != NULL)
|
||||
|
||||
{
|
||||
if (select == NULL || (select != NULL && select(entry)))
|
||||
if ((count = addToList(count, namelist, entry)) < 0)
|
||||
break;
|
||||
}
|
||||
closedir(pDir);
|
||||
if (count <= 0)
|
||||
return -1;
|
||||
if (compar != NULL)
|
||||
qsort((void *) (*namelist), (size_t) count, sizeof(struct dirent *),
|
||||
compar);
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,82 +1,73 @@
|
|||
/****************************************************/
|
||||
/* */
|
||||
/* For Win32 that lacks Unix direct support. */
|
||||
/* - avoids including "windows.h" */
|
||||
/* */
|
||||
/* Copyright (c) 2002 John Popplewell */
|
||||
/* john@johnnypops.demon.co.uk */
|
||||
/* */
|
||||
/****************************************************/
|
||||
/* $Id$ */
|
||||
|
||||
typedef long BOOL;
|
||||
typedef unsigned int DWORD;
|
||||
typedef wchar_t TCHAR;
|
||||
typedef void* HANDLE;
|
||||
|
||||
/****************************************************/
|
||||
/* */
|
||||
/* For Win32 that lacks Unix direct support. */
|
||||
/* - avoids including "windows.h" */
|
||||
/* */
|
||||
/* Copyright (c) 2002 John Popplewell */
|
||||
/* john@johnnypops.demon.co.uk */
|
||||
/* */
|
||||
/****************************************************/
|
||||
/* $Id$ */
|
||||
typedef long BOOL;
|
||||
typedef unsigned int DWORD;
|
||||
typedef wchar_t TCHAR;
|
||||
typedef void *HANDLE;
|
||||
|
||||
#define MAX_PATH 256
|
||||
#define INVALID_HANDLE_VALUE ((HANDLE)(-1))
|
||||
#define WINAPI __stdcall
|
||||
|
||||
typedef struct
|
||||
{
|
||||
DWORD dwLowDateTime;
|
||||
DWORD dwHighDateTime;
|
||||
} FILETIME;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
DWORD dwFileAttributes;
|
||||
FILETIME ftCreationTime;
|
||||
FILETIME ftLastAccessTime;
|
||||
FILETIME ftLastWriteTime;
|
||||
DWORD nFileSizeHigh;
|
||||
DWORD nFileSizeLow;
|
||||
DWORD dwReserved0;
|
||||
DWORD dwReserved1;
|
||||
TCHAR cFileName[ MAX_PATH ];
|
||||
TCHAR cAlternateFileName[ 14 ];
|
||||
} WIN32_FIND_DATA;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
DWORD dwLowDateTime;
|
||||
DWORD dwHighDateTime;
|
||||
} FILETIME;
|
||||
typedef struct
|
||||
{
|
||||
DWORD dwFileAttributes;
|
||||
FILETIME ftCreationTime;
|
||||
FILETIME ftLastAccessTime;
|
||||
FILETIME ftLastWriteTime;
|
||||
DWORD nFileSizeHigh;
|
||||
DWORD nFileSizeLow;
|
||||
DWORD dwReserved0;
|
||||
DWORD dwReserved1;
|
||||
TCHAR cFileName[MAX_PATH];
|
||||
TCHAR cAlternateFileName[14];
|
||||
} WIN32_FIND_DATA;
|
||||
|
||||
#define FindFirstFile FindFirstFileA
|
||||
#define FindNextFile FindNextFileA
|
||||
#define FindClose FindClose
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern HANDLE WINAPI FindFirstFile( const char*, WIN32_FIND_DATA* );
|
||||
extern BOOL WINAPI FindNextFile( HANDLE, WIN32_FIND_DATA* );
|
||||
extern BOOL WINAPI FindClose( HANDLE );
|
||||
|
||||
extern "C"
|
||||
{
|
||||
|
||||
#endif /*
*/
|
||||
extern HANDLE WINAPI FindFirstFile(const char *, WIN32_FIND_DATA *);
|
||||
extern BOOL WINAPI FindNextFile(HANDLE, WIN32_FIND_DATA *);
|
||||
extern BOOL WINAPI FindClose(HANDLE);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif /*
*/
|
||||
struct dirent
|
||||
{
|
||||
char d_name[MAX_PATH];
|
||||
};
|
||||
typedef struct
|
||||
{
|
||||
WIN32_FIND_DATA wfd;
|
||||
HANDLE hFind;
|
||||
struct dirent de;
|
||||
} DIR;
|
||||
extern DIR *opendir(const char *pSpec);
|
||||
extern void closedir(DIR * pDir);
|
||||
extern struct dirent *readdir(struct DIR *pDir);
|
||||
typedef int (*selectCB) (const struct dirent *);
|
||||
typedef int (*comparCB) (const void *, const void *);
|
||||
extern int alphasort(const void *a, const void *b);
|
||||
extern int scandir(const char *dir, struct dirent ***namelist,
|
||||
selectCB select, comparCB compar);
|
||||
|
||||
struct dirent
|
||||
{
|
||||
char d_name[MAX_PATH];
|
||||
};
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
WIN32_FIND_DATA wfd;
|
||||
HANDLE hFind;
|
||||
struct dirent de;
|
||||
} DIR;
|
||||
|
||||
|
||||
extern DIR *opendir(const char *pSpec);
|
||||
extern void closedir(DIR *pDir);
|
||||
extern struct dirent *readdir(struct DIR *pDir);
|
||||
|
||||
typedef int (*selectCB)(const struct dirent *);
|
||||
typedef int (*comparCB)(const void*, const void*);
|
||||
|
||||
extern int alphasort( const void *a, const void *b );
|
||||
extern int scandir( const char *dir, struct dirent ***namelist, selectCB select, comparCB compar);
|
||||
|
|
|
|||
|
|
@ -32,11 +32,11 @@
|
|||
|
||||
|
||||
#define NOREF(x) ((x)=(x))
|
||||
#define GETHINST(hWnd) ((HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE))
|
||||
#define GETHINST(hWnd) ((HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE))
|
||||
#define MIR(id) (MAKEINTRESOURCE(id))
|
||||
|
||||
|
||||
static PRINTDLG global_pd = {
|
||||
static PRINTDLG global_pd = {
|
||||
sizeof(PRINTDLG),
|
||||
NULL, NULL, NULL, NULL,
|
||||
PD_RETURNDC,
|
||||
|
|
@ -49,49 +49,50 @@ static PRINTDLG global_pd = {
|
|||
};
|
||||
|
||||
|
||||
static SDL_Surface *make24bitDIB(SDL_Surface *surf)
|
||||
static SDL_Surface *make24bitDIB(SDL_Surface * surf)
|
||||
{
|
||||
SDL_PixelFormat pixfmt;
|
||||
SDL_Surface *surf24;
|
||||
SDL_Surface *surfDIB;
|
||||
Uint8 *src,*dst;
|
||||
Uint32 linesize;
|
||||
int i;
|
||||
SDL_PixelFormat pixfmt;
|
||||
SDL_Surface *surf24;
|
||||
SDL_Surface *surfDIB;
|
||||
Uint8 *src, *dst;
|
||||
Uint32 linesize;
|
||||
int i;
|
||||
|
||||
memset(&pixfmt, 0, sizeof(pixfmt));
|
||||
pixfmt.palette = NULL;
|
||||
pixfmt.palette = NULL;
|
||||
pixfmt.BitsPerPixel = 24;
|
||||
pixfmt.BytesPerPixel= 3;
|
||||
pixfmt.Rmask = 0x00FF0000;
|
||||
pixfmt.Gmask = 0x0000FF00;
|
||||
pixfmt.Bmask = 0x000000FF;
|
||||
pixfmt.Amask = 0;
|
||||
pixfmt.Rshift = 16;
|
||||
pixfmt.Gshift = 8;
|
||||
pixfmt.Bshift = 0;
|
||||
pixfmt.Ashift = 0;
|
||||
pixfmt.Rloss = 0;
|
||||
pixfmt.Gloss = 0;
|
||||
pixfmt.Bloss = 0;
|
||||
pixfmt.Aloss = 0;
|
||||
pixfmt.colorkey = 0;
|
||||
pixfmt.alpha = 0;
|
||||
pixfmt.BytesPerPixel = 3;
|
||||
pixfmt.Rmask = 0x00FF0000;
|
||||
pixfmt.Gmask = 0x0000FF00;
|
||||
pixfmt.Bmask = 0x000000FF;
|
||||
pixfmt.Amask = 0;
|
||||
pixfmt.Rshift = 16;
|
||||
pixfmt.Gshift = 8;
|
||||
pixfmt.Bshift = 0;
|
||||
pixfmt.Ashift = 0;
|
||||
pixfmt.Rloss = 0;
|
||||
pixfmt.Gloss = 0;
|
||||
pixfmt.Bloss = 0;
|
||||
pixfmt.Aloss = 0;
|
||||
pixfmt.colorkey = 0;
|
||||
pixfmt.alpha = 0;
|
||||
|
||||
surf24 = SDL_ConvertSurface(surf, &pixfmt, SDL_SWSURFACE);
|
||||
surfDIB = SDL_CreateRGBSurface(SDL_SWSURFACE, surf24->w, surf24->h, 24,
|
||||
pixfmt.Rmask, pixfmt.Gmask, pixfmt.Bmask, pixfmt.Amask);
|
||||
pixfmt.Rmask, pixfmt.Gmask, pixfmt.Bmask,
|
||||
pixfmt.Amask);
|
||||
|
||||
linesize = surf24->w * 3; // Flip top2bottom
|
||||
linesize = surf24->w * 3; // Flip top2bottom
|
||||
dst = surfDIB->pixels;
|
||||
src = ((Uint8*)surf24->pixels)+((surf24->h-1)*surf24->pitch);
|
||||
src = ((Uint8 *) surf24->pixels) + ((surf24->h - 1) * surf24->pitch);
|
||||
for (i = 0; i < surf24->h; ++i)
|
||||
{
|
||||
memcpy(dst, src, linesize);
|
||||
src -= surf24->pitch;
|
||||
dst += surfDIB->pitch;
|
||||
memcpy(dst, src, linesize);
|
||||
src -= surf24->pitch;
|
||||
dst += surfDIB->pitch;
|
||||
}
|
||||
|
||||
SDL_FreeSurface(surf24); // Free temp surface
|
||||
SDL_FreeSurface(surf24); // Free temp surface
|
||||
|
||||
return surfDIB;
|
||||
}
|
||||
|
|
@ -99,25 +100,28 @@ static SDL_Surface *make24bitDIB(SDL_Surface *surf)
|
|||
/* returns 0 if failed */
|
||||
static int GetDefaultPrinterStrings(char *device, char *driver, char *output)
|
||||
{
|
||||
const char *section = "windows";
|
||||
const char *key = "device";
|
||||
const char *def = "NODEFAULTPRINTER";
|
||||
char buff[MAX_PATH];
|
||||
char *dev,*drv,*out;
|
||||
|
||||
const char *section = "windows";
|
||||
const char *key = "device";
|
||||
const char *def = "NODEFAULTPRINTER";
|
||||
char buff[MAX_PATH];
|
||||
char *dev, *drv, *out;
|
||||
|
||||
if (!GetProfileString(section, key, def, buff, sizeof(buff)))
|
||||
return 0;
|
||||
|
||||
|
||||
if (strcmp(buff, def) == 0)
|
||||
return 0;
|
||||
|
||||
if (((dev = strtok(buff, "," )) != NULL) &&
|
||||
if (((dev = strtok(buff, ",")) != NULL) &&
|
||||
((drv = strtok(NULL, ", ")) != NULL) &&
|
||||
((out = strtok(NULL, ", ")) != NULL))
|
||||
{
|
||||
if (device) strcpy(device, dev);
|
||||
if (driver) strcpy(driver, drv);
|
||||
if (output) strcpy(output, out);
|
||||
if (device)
|
||||
strcpy(device, dev);
|
||||
if (driver)
|
||||
strcpy(driver, drv);
|
||||
if (output)
|
||||
strcpy(output, out);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -127,15 +131,15 @@ static int GetDefaultPrinterStrings(char *device, char *driver, char *output)
|
|||
|
||||
static HANDLE LoadCustomPrinterHDEVMODE(HWND hWnd, const char *filepath)
|
||||
{
|
||||
char device[MAX_PATH];
|
||||
HANDLE hPrinter = NULL;
|
||||
int sizeof_devmode;
|
||||
char device[MAX_PATH];
|
||||
HANDLE hPrinter = NULL;
|
||||
int sizeof_devmode;
|
||||
HGLOBAL hDevMode = NULL;
|
||||
DEVMODE *devmode = NULL;
|
||||
int res;
|
||||
FILE *fp = NULL;
|
||||
int block_size;
|
||||
int block_read;
|
||||
int res;
|
||||
FILE *fp = NULL;
|
||||
int block_size;
|
||||
int block_read;
|
||||
|
||||
if ((fp = fopen(filepath, "rb")) == NULL)
|
||||
return NULL;
|
||||
|
|
@ -146,7 +150,7 @@ static HANDLE LoadCustomPrinterHDEVMODE(HWND hWnd, const char *filepath)
|
|||
if (!OpenPrinter(device, &hPrinter, NULL))
|
||||
return NULL;
|
||||
|
||||
sizeof_devmode = (int)DocumentProperties(hWnd, hPrinter, device,
|
||||
sizeof_devmode = (int) DocumentProperties(hWnd, hPrinter, device,
|
||||
NULL, NULL, 0);
|
||||
|
||||
if (!sizeof_devmode)
|
||||
|
|
@ -156,12 +160,12 @@ static HANDLE LoadCustomPrinterHDEVMODE(HWND hWnd, const char *filepath)
|
|||
if (!hDevMode)
|
||||
goto err_exit;
|
||||
|
||||
devmode = (DEVMODE*)GlobalLock(hDevMode);
|
||||
devmode = (DEVMODE *) GlobalLock(hDevMode);
|
||||
if (!devmode)
|
||||
goto err_exit;
|
||||
|
||||
res = DocumentProperties(hWnd, hPrinter, device, devmode, NULL,
|
||||
DM_OUT_BUFFER);
|
||||
res = DocumentProperties(hWnd, hPrinter, device, devmode, NULL,
|
||||
DM_OUT_BUFFER);
|
||||
if (res != IDOK)
|
||||
goto err_exit;
|
||||
|
||||
|
|
@ -171,8 +175,8 @@ static HANDLE LoadCustomPrinterHDEVMODE(HWND hWnd, const char *filepath)
|
|||
goto err_exit;
|
||||
fclose(fp);
|
||||
|
||||
res = DocumentProperties(hWnd, hPrinter, device, devmode, devmode,
|
||||
DM_IN_BUFFER|DM_OUT_BUFFER);
|
||||
res = DocumentProperties(hWnd, hPrinter, device, devmode, devmode,
|
||||
DM_IN_BUFFER | DM_OUT_BUFFER);
|
||||
if (res != IDOK)
|
||||
goto err_exit;
|
||||
|
||||
|
|
@ -181,27 +185,32 @@ static HANDLE LoadCustomPrinterHDEVMODE(HWND hWnd, const char *filepath)
|
|||
return hDevMode;
|
||||
|
||||
err_exit:
|
||||
if (fp) fclose(fp);
|
||||
if (devmode) GlobalUnlock(hDevMode);
|
||||
if (hDevMode) GlobalFree(hDevMode);
|
||||
if (hPrinter) ClosePrinter(hPrinter);
|
||||
if (fp)
|
||||
fclose(fp);
|
||||
if (devmode)
|
||||
GlobalUnlock(hDevMode);
|
||||
if (hDevMode)
|
||||
GlobalFree(hDevMode);
|
||||
if (hPrinter)
|
||||
ClosePrinter(hPrinter);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static int SaveCustomPrinterHDEVMODE(HWND hWnd, const char *filepath, HANDLE hDevMode)
|
||||
static int SaveCustomPrinterHDEVMODE(HWND hWnd, const char *filepath,
|
||||
HANDLE hDevMode)
|
||||
{
|
||||
FILE *fp = NULL;
|
||||
FILE *fp = NULL;
|
||||
|
||||
NOREF(hWnd);
|
||||
if ((fp = fopen(filepath, "wb")) != NULL)
|
||||
{
|
||||
DEVMODE *devmode = (DEVMODE*)GlobalLock(hDevMode);
|
||||
int block_size = devmode->dmSize + devmode->dmDriverExtra;
|
||||
int block_written;
|
||||
char devname[dmDeviceNameSize];
|
||||
DEVMODE *devmode = (DEVMODE *) GlobalLock(hDevMode);
|
||||
int block_size = devmode->dmSize + devmode->dmDriverExtra;
|
||||
int block_written;
|
||||
char devname[dmDeviceNameSize];
|
||||
|
||||
strcpy(devname, (const char*)devmode->dmDeviceName);
|
||||
strcpy(devname, (const char *) devmode->dmDeviceName);
|
||||
fwrite(devname, 1, sizeof(devname), fp);
|
||||
block_written = fwrite(devmode, 1, block_size, fp);
|
||||
GlobalUnlock(hDevMode);
|
||||
|
|
@ -215,12 +224,12 @@ static int SaveCustomPrinterHDEVMODE(HWND hWnd, const char *filepath, HANDLE hDe
|
|||
static HDC GetCustomPrinterDC(HWND hWnd, const char *printcfg, int show)
|
||||
{
|
||||
global_pd.hwndOwner = hWnd;
|
||||
global_pd.hDC = NULL;
|
||||
global_pd.hDC = NULL;
|
||||
global_pd.hDevNames = NULL;
|
||||
|
||||
if (global_pd.hDevMode == NULL)
|
||||
{
|
||||
global_pd.hDevMode = LoadCustomPrinterHDEVMODE(hWnd, printcfg);
|
||||
global_pd.hDevMode = LoadCustomPrinterHDEVMODE(hWnd, printcfg);
|
||||
}
|
||||
|
||||
if (show)
|
||||
|
|
@ -234,9 +243,10 @@ static HDC GetCustomPrinterDC(HWND hWnd, const char *printcfg, int show)
|
|||
}
|
||||
|
||||
{
|
||||
DEVMODE *devmode = (DEVMODE*)GlobalLock(global_pd.hDevMode);
|
||||
DEVMODE *devmode = (DEVMODE *) GlobalLock(global_pd.hDevMode);
|
||||
|
||||
global_pd.hDC = CreateDC(NULL, (const char*)devmode->dmDeviceName, NULL, devmode);
|
||||
global_pd.hDC =
|
||||
CreateDC(NULL, (const char *) devmode->dmDeviceName, NULL, devmode);
|
||||
GlobalUnlock(global_pd.hDevMode);
|
||||
}
|
||||
return global_pd.hDC;
|
||||
|
|
@ -245,7 +255,7 @@ static HDC GetCustomPrinterDC(HWND hWnd, const char *printcfg, int show)
|
|||
|
||||
static HDC GetDefaultPrinterDC(void)
|
||||
{
|
||||
char device[MAX_PATH],driver[MAX_PATH],output[MAX_PATH];
|
||||
char device[MAX_PATH], driver[MAX_PATH], output[MAX_PATH];
|
||||
|
||||
if (GetDefaultPrinterStrings(device, driver, output))
|
||||
return CreateDC(driver, device, output, NULL);
|
||||
|
|
@ -256,7 +266,8 @@ static HDC GetDefaultPrinterDC(void)
|
|||
|
||||
static HDC GetPrinterDC(HWND hWnd, const char *printcfg, int show)
|
||||
{
|
||||
if (!printcfg) return GetDefaultPrinterDC();
|
||||
if (!printcfg)
|
||||
return GetDefaultPrinterDC();
|
||||
return GetCustomPrinterDC(hWnd, printcfg, show);
|
||||
}
|
||||
|
||||
|
|
@ -264,11 +275,12 @@ static HDC GetPrinterDC(HWND hWnd, const char *printcfg, int show)
|
|||
static int IsBandingRequired(HDC hPrinter)
|
||||
{
|
||||
OSVERSIONINFO osvi;
|
||||
int indata = NEXTBAND;
|
||||
int indata = NEXTBAND;
|
||||
|
||||
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
||||
if (GetVersionEx(&osvi) && (osvi.dwPlatformId != VER_PLATFORM_WIN32_NT))
|
||||
return Escape(hPrinter, QUERYESCSUPPORT, sizeof(int), (LPCSTR)&indata, NULL);
|
||||
return Escape(hPrinter, QUERYESCSUPPORT, sizeof(int), (LPCSTR) & indata,
|
||||
NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -279,25 +291,26 @@ int IsPrinterAvailable(void)
|
|||
}
|
||||
|
||||
|
||||
const char *SurfacePrint(SDL_Surface *surf, const char *printcfg, int showdialog)
|
||||
const char *SurfacePrint(SDL_Surface * surf, const char *printcfg,
|
||||
int showdialog)
|
||||
{
|
||||
const char *res = NULL;
|
||||
HWND hWnd;
|
||||
DOCINFO di;
|
||||
int nError;
|
||||
SDL_SysWMinfo wminfo;
|
||||
HDC hDCwindow;
|
||||
HDC hDCprinter;
|
||||
BITMAPINFOHEADER bmih;
|
||||
SDL_Surface *surf24 = NULL;
|
||||
RECT rc;
|
||||
float fLogPelsX1, fLogPelsY1, fLogPelsX2, fLogPelsY2;
|
||||
float fScaleX, fScaleY;
|
||||
int cWidthPels, xLeft, yTop;
|
||||
float subscaler,subscalerx,subscalery;
|
||||
int hDCCaps;
|
||||
HBITMAP hbm = NULL;
|
||||
HDC hdcMem = NULL;
|
||||
const char *res = NULL;
|
||||
HWND hWnd;
|
||||
DOCINFO di;
|
||||
int nError;
|
||||
SDL_SysWMinfo wminfo;
|
||||
HDC hDCwindow;
|
||||
HDC hDCprinter;
|
||||
BITMAPINFOHEADER bmih;
|
||||
SDL_Surface *surf24 = NULL;
|
||||
RECT rc;
|
||||
float fLogPelsX1, fLogPelsY1, fLogPelsX2, fLogPelsY2;
|
||||
float fScaleX, fScaleY;
|
||||
int cWidthPels, xLeft, yTop;
|
||||
float subscaler, subscalerx, subscalery;
|
||||
int hDCCaps;
|
||||
HBITMAP hbm = NULL;
|
||||
HDC hdcMem = NULL;
|
||||
|
||||
SDL_VERSION(&wminfo.version);
|
||||
if (!SDL_GetWMInfo(&wminfo))
|
||||
|
|
@ -312,8 +325,8 @@ const char *SurfacePrint(SDL_Surface *surf, const char *printcfg, int showdialog
|
|||
|
||||
di.cbSize = sizeof(DOCINFO);
|
||||
di.lpszDocName = "Tux Paint";
|
||||
di.lpszOutput = (LPTSTR)NULL;
|
||||
di.lpszDatatype = (LPTSTR)NULL;
|
||||
di.lpszOutput = (LPTSTR) NULL;
|
||||
di.lpszDatatype = (LPTSTR) NULL;
|
||||
di.fwType = 0;
|
||||
|
||||
nError = StartDoc(hDCprinter, &di);
|
||||
|
|
@ -340,16 +353,16 @@ const char *SurfacePrint(SDL_Surface *surf, const char *printcfg, int showdialog
|
|||
}
|
||||
|
||||
memset(&bmih, 0, sizeof(bmih));
|
||||
bmih.biSize = sizeof(bmih);
|
||||
bmih.biPlanes = 1;
|
||||
bmih.biCompression = BI_RGB;
|
||||
bmih.biBitCount = 24;
|
||||
bmih.biWidth = surf24->w;
|
||||
bmih.biHeight = surf24->h;
|
||||
bmih.biSize = sizeof(bmih);
|
||||
bmih.biPlanes = 1;
|
||||
bmih.biCompression = BI_RGB;
|
||||
bmih.biBitCount = 24;
|
||||
bmih.biWidth = surf24->w;
|
||||
bmih.biHeight = surf24->h;
|
||||
|
||||
GetClientRect(hWnd, &rc);
|
||||
subscalerx = (float)rc.right/surf24->w;
|
||||
subscalery = (float)rc.bottom/surf24->h;
|
||||
subscalerx = (float) rc.right / surf24->w;
|
||||
subscalery = (float) rc.bottom / surf24->h;
|
||||
subscaler = subscalery;
|
||||
if (subscalerx < subscalery)
|
||||
subscaler = subscalerx;
|
||||
|
|
@ -368,62 +381,64 @@ const char *SurfacePrint(SDL_Surface *surf, const char *printcfg, int showdialog
|
|||
fLogPelsY2 = GetDeviceCaps(hDCprinter, LOGPIXELSY);
|
||||
|
||||
if (fLogPelsX1 > fLogPelsX2)
|
||||
fScaleX = (fLogPelsX1/fLogPelsX2);
|
||||
fScaleX = (fLogPelsX1 / fLogPelsX2);
|
||||
else
|
||||
fScaleX = (fLogPelsX2/fLogPelsX1);
|
||||
fScaleX = (fLogPelsX2 / fLogPelsX1);
|
||||
|
||||
if (fLogPelsY1 > fLogPelsY2)
|
||||
fScaleY = (fLogPelsY1/fLogPelsY2);
|
||||
fScaleY = (fLogPelsY1 / fLogPelsY2);
|
||||
else
|
||||
fScaleY = (fLogPelsY2/fLogPelsY1);
|
||||
fScaleY = (fLogPelsY2 / fLogPelsY1);
|
||||
|
||||
fScaleX *= subscaler;
|
||||
fScaleY *= subscaler;
|
||||
|
||||
yTop = 0;
|
||||
cWidthPels = GetDeviceCaps(hDCprinter, PHYSICALWIDTH);
|
||||
xLeft = ((cWidthPels - ((int)(fScaleX*bmih.biWidth)))/2)-
|
||||
GetDeviceCaps(hDCprinter, PHYSICALOFFSETX);
|
||||
xLeft = ((cWidthPels - ((int) (fScaleX * bmih.biWidth))) / 2) -
|
||||
GetDeviceCaps(hDCprinter, PHYSICALOFFSETX);
|
||||
|
||||
hDCCaps = GetDeviceCaps(hDCprinter, RASTERCAPS);
|
||||
|
||||
if (hDCCaps & RC_PALETTE)
|
||||
{
|
||||
res = "win32_print: printer context requires palette.";
|
||||
goto error;
|
||||
res = "win32_print: printer context requires palette.";
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (IsBandingRequired(hDCprinter))
|
||||
{
|
||||
RECT rcBand = { 0, 0, 0, 0 };
|
||||
RECT rcPrinter;
|
||||
RECT rcImage;
|
||||
RECT rcBand = { 0, 0, 0, 0 };
|
||||
RECT rcPrinter;
|
||||
RECT rcImage;
|
||||
|
||||
SetRect(&rcPrinter, xLeft, yTop, (int)(fScaleX*bmih.biWidth), (int)(fScaleY*bmih.biHeight));
|
||||
SetRect(&rcPrinter, xLeft, yTop, (int) (fScaleX * bmih.biWidth),
|
||||
(int) (fScaleY * bmih.biHeight));
|
||||
SetRect(&rcImage, 0, 0, bmih.biWidth, bmih.biHeight);
|
||||
|
||||
while (Escape(hDCprinter, NEXTBAND, 0, NULL, &rcBand))
|
||||
{
|
||||
if (IsRectEmpty(&rcBand)) break;
|
||||
if (IsRectEmpty(&rcBand))
|
||||
break;
|
||||
if (IntersectRect(&rcBand, &rcBand, &rcPrinter))
|
||||
{
|
||||
rcImage.top = (int)(0.5f+(float)rcBand.top/fScaleX);
|
||||
rcImage.bottom = (int)(0.5f+(float)rcBand.bottom/fScaleX);
|
||||
rcImage.top = (int) (0.5f + (float) rcBand.top / fScaleX);
|
||||
rcImage.bottom = (int) (0.5f + (float) rcBand.bottom / fScaleX);
|
||||
|
||||
SetStretchBltMode(hDCprinter, COLORONCOLOR);
|
||||
nError = StretchDIBits(hDCprinter, rcBand.left, rcBand.top,
|
||||
rcBand.right - rcBand.left,
|
||||
rcBand.bottom - rcBand.top,
|
||||
rcImage.left, rcImage.top,
|
||||
rcImage.right - rcImage.left,
|
||||
rcImage.bottom - rcImage.top,
|
||||
surf24->pixels, (BITMAPINFO*)&bmih,
|
||||
DIB_RGB_COLORS, SRCCOPY);
|
||||
if (nError == GDI_ERROR)
|
||||
{
|
||||
res = "win32_print: StretchDIBits() failed.";
|
||||
goto error;
|
||||
}
|
||||
SetStretchBltMode(hDCprinter, COLORONCOLOR);
|
||||
nError = StretchDIBits(hDCprinter, rcBand.left, rcBand.top,
|
||||
rcBand.right - rcBand.left,
|
||||
rcBand.bottom - rcBand.top,
|
||||
rcImage.left, rcImage.top,
|
||||
rcImage.right - rcImage.left,
|
||||
rcImage.bottom - rcImage.top,
|
||||
surf24->pixels, (BITMAPINFO *) & bmih,
|
||||
DIB_RGB_COLORS, SRCCOPY);
|
||||
if (nError == GDI_ERROR)
|
||||
{
|
||||
res = "win32_print: StretchDIBits() failed.";
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -434,15 +449,15 @@ const char *SurfacePrint(SDL_Surface *surf, const char *printcfg, int showdialog
|
|||
SetStretchBltMode(hDCprinter, COLORONCOLOR);
|
||||
|
||||
nError = StretchDIBits(hDCprinter, xLeft, yTop,
|
||||
(int)(fScaleX*bmih.biWidth),
|
||||
(int)(fScaleY*bmih.biHeight),
|
||||
0, 0, bmih.biWidth, bmih.biHeight,
|
||||
surf24->pixels, (BITMAPINFO*)&bmih,
|
||||
DIB_RGB_COLORS, SRCCOPY);
|
||||
(int) (fScaleX * bmih.biWidth),
|
||||
(int) (fScaleY * bmih.biHeight),
|
||||
0, 0, bmih.biWidth, bmih.biHeight,
|
||||
surf24->pixels, (BITMAPINFO *) & bmih,
|
||||
DIB_RGB_COLORS, SRCCOPY);
|
||||
if (nError == GDI_ERROR)
|
||||
{
|
||||
res = "win32_print: StretchDIBits() failed.";
|
||||
goto error;
|
||||
res = "win32_print: StretchDIBits() failed.";
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
@ -463,10 +478,13 @@ const char *SurfacePrint(SDL_Surface *surf, const char *printcfg, int showdialog
|
|||
|
||||
EndDoc(hDCprinter);
|
||||
|
||||
error:
|
||||
if (hdcMem) DeleteDC(hdcMem);
|
||||
if (hbm) DeleteObject(hbm);
|
||||
if (surf24) SDL_FreeSurface(surf24);
|
||||
error:
|
||||
if (hdcMem)
|
||||
DeleteDC(hdcMem);
|
||||
if (hbm)
|
||||
DeleteObject(hbm);
|
||||
if (surf24)
|
||||
SDL_FreeSurface(surf24);
|
||||
|
||||
EnableWindow(hWnd, TRUE);
|
||||
DeleteDC(hDCprinter);
|
||||
|
|
@ -477,21 +495,25 @@ error:
|
|||
/*
|
||||
Read access to Windows Registry
|
||||
*/
|
||||
static HRESULT ReadRegistry(const char *key, const char *option, char *value, int size)
|
||||
static HRESULT ReadRegistry(const char *key, const char *option, char *value,
|
||||
int size)
|
||||
{
|
||||
LONG res;
|
||||
HKEY hKey = NULL;
|
||||
LONG res;
|
||||
HKEY hKey = NULL;
|
||||
|
||||
res = RegOpenKeyEx(HKEY_CURRENT_USER, key, 0, KEY_READ, &hKey);
|
||||
if (res != ERROR_SUCCESS)
|
||||
goto err_exit;
|
||||
res = RegQueryValueEx(hKey, option, NULL, NULL, (LPBYTE)value, (LPDWORD)&size);
|
||||
res =
|
||||
RegQueryValueEx(hKey, option, NULL, NULL, (LPBYTE) value,
|
||||
(LPDWORD) & size);
|
||||
if (res != ERROR_SUCCESS)
|
||||
goto err_exit;
|
||||
res = ERROR_SUCCESS;
|
||||
|
||||
err_exit:
|
||||
if (hKey) RegCloseKey(hKey);
|
||||
if (hKey)
|
||||
RegCloseKey(hKey);
|
||||
return HRESULT_FROM_WIN32(res);
|
||||
}
|
||||
|
||||
|
|
@ -505,8 +527,8 @@ static char *remove_slash(char *path)
|
|||
if (!len)
|
||||
return path;
|
||||
|
||||
if (path[len-1] == '/' || path[len-1] == '\\')
|
||||
path[len-1] = 0;
|
||||
if (path[len - 1] == '/' || path[len - 1] == '\\')
|
||||
path[len - 1] = 0;
|
||||
|
||||
return path;
|
||||
}
|
||||
|
|
@ -518,10 +540,11 @@ static char *remove_slash(char *path)
|
|||
*/
|
||||
char *GetDefaultSaveDir(const char *suffix)
|
||||
{
|
||||
char prefix[MAX_PATH];
|
||||
char path[2*MAX_PATH];
|
||||
const char *key = "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders";
|
||||
const char *option = "AppData";
|
||||
char prefix[MAX_PATH];
|
||||
char path[2 * MAX_PATH];
|
||||
const char *key =
|
||||
"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders";
|
||||
const char *option = "AppData";
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
if (SUCCEEDED(hr = ReadRegistry(key, option, prefix, sizeof(prefix))))
|
||||
|
|
@ -540,9 +563,10 @@ char *GetDefaultSaveDir(const char *suffix)
|
|||
*/
|
||||
char *GetSystemFontDir(void)
|
||||
{
|
||||
char path[MAX_PATH];
|
||||
const char *key = "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders";
|
||||
const char *option = "Fonts";
|
||||
char path[MAX_PATH];
|
||||
const char *key =
|
||||
"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders";
|
||||
const char *option = "Fonts";
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
if (SUCCEEDED(hr = ReadRegistry(key, option, path, sizeof(path))))
|
||||
|
|
@ -552,5 +576,3 @@ char *GetSystemFontDir(void)
|
|||
}
|
||||
return strdup("C:\\WINDOWS\\FONTS");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -15,10 +15,9 @@
|
|||
#endif
|
||||
|
||||
/* if printcfg is NULL, uses the default printer */
|
||||
extern const char *SurfacePrint( SDL_Surface *surf,
|
||||
const char *printcfg,
|
||||
int showdialog );
|
||||
extern int IsPrinterAvailable( void );
|
||||
extern const char *SurfacePrint(SDL_Surface * surf,
|
||||
const char *printcfg, int showdialog);
|
||||
extern int IsPrinterAvailable(void);
|
||||
|
||||
/* additional windows functions requiring <windows.h> */
|
||||
extern char *GetDefaultSaveDir(const char *suffix);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue