[layers] Merged changes from trunk

git-svn-id: svn://pulkomandy.tk/GrafX2/branches/layers@1131 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
Yves Rizoud 2009-11-01 01:05:21 +00:00
commit f38fd068a2
36 changed files with 7076 additions and 6780 deletions

View File

@ -939,20 +939,8 @@ ENUM_VALUES_PER_LINE = 4
# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index # The GENERATE_TREEVIEW tag is used to specify whether a tree-like index
# structure should be generated to display hierarchical information. # structure should be generated to display hierarchical information.
# If the tag value is set to FRAME, a side panel will be generated
# containing a tree-like index structure (just like the one that
# is generated for HTML Help). For this to work a browser that supports
# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+,
# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are
# probably better off using the HTML help feature. Other possible values
# for this tag are: HIERARCHIES, which will generate the Groups, Directories,
# and Class Hierarchy pages using a tree view instead of an ordered list;
# ALL, which combines the behavior of FRAME and HIERARCHIES; and NONE, which
# disables this behavior completely. For backwards compatibility with previous
# releases of Doxygen, the values YES and NO are equivalent to FRAME and NONE
# respectively.
GENERATE_TREEVIEW = FRAME GENERATE_TREEVIEW = YES
# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be
# used to set the initial width (in pixels) of the frame in which the tree # used to set the initial width (in pixels) of the frame in which the tree

View File

@ -42,15 +42,16 @@ ifdef COMSPEC
RMDIR = rmdir RMDIR = rmdir
CP = cp CP = cp
BIN = grafx2.exe BIN = grafx2.exe
COPT = -W -Wall -Wdeclaration-after-statement -O$(OPTIM) -g -ggdb `sdl-config --cflags` $(TTFCOPT) $(JOYCOPT) COPT = -W -Wall -Wdeclaration-after-statement -O$(OPTIM) -g -ggdb `sdl-config --cflags` $(TTFCOPT) $(JOYCOPT) $(LUACOPT)
LOPT = `sdl-config --libs` -lSDL_image $(TTFLOPT) -lpng LOPT = `sdl-config --libs` -lSDL_image $(TTFLOPT) -lpng $(LUALOPT)
CC = gcc CC = gcc
OBJDIR = obj/win32 OBJDIR = obj/win32
# Resources (icon) # Resources (icon)
WINDRES = windres.exe WINDRES = windres.exe
PLATFORMOBJ = $(OBJDIR)/winres.o PLATFORMOBJ = $(OBJDIR)/winres.o
PLATFORM = win32 PLATFORM = win32
PLATFORMFILES = SDL.dll SDL_image.dll libpng13.dll zlib1.dll gfx2.ico $(TTFLIBS) #some misc files we have to add to the release archive under windows. #some misc files we have to add to the release archive under windows.
PLATFORMFILES = SDL.dll SDL_image.dll libpng13.dll zlib1.dll gfx2.ico $(TTFLIBS)
ZIP = zip ZIP = zip
else else
@ -227,8 +228,8 @@ else
# Compiles a regular linux exectutable for the native platform # Compiles a regular linux exectutable for the native platform
BIN = grafx2 BIN = grafx2
COPT = -W -Wall -Wdeclaration-after-statement -std=c99 -c -g `sdl-config --cflags` $(TTFCOPT) COPT = -W -Wall -Wdeclaration-after-statement -std=c99 -c -g `sdl-config --cflags` $(TTFCOPT) $(LUACOPT)
LOPT = `sdl-config --libs` -lSDL_image $(TTFLOPT) -lpng LOPT = `sdl-config --libs` -lSDL_image $(TTFLOPT) -lpng $(LUALOPT)
# Use gcc for compiling. Use ncc to build a callgraph and analyze the code. # Use gcc for compiling. Use ncc to build a callgraph and analyze the code.
CC = gcc CC = gcc
#CC = nccgen -ncgcc -ncld -ncfabs #CC = nccgen -ncgcc -ncld -ncfabs
@ -253,6 +254,17 @@ else
TTFLABEL = TTFLABEL =
endif endif
#Lua scripting is optional too
ifeq ($(NOLUA),1)
LUACOPT =
LUALOPT =
LUALABEL = -nolua
else
LUACOPT = -D__ENABLE_LUA__
LUALOPT = -llua5.1
LUALABEL =
endif
#To disable Joystick emulation of cursor, make NOJOY=1 (for input.o) #To disable Joystick emulation of cursor, make NOJOY=1 (for input.o)
#This can be necessary to test keyboard cursor code, because an existing #This can be necessary to test keyboard cursor code, because an existing
#joystick will keep reporting a contradicting position. #joystick will keep reporting a contradicting position.
@ -262,16 +274,12 @@ else
JOYCOPT = JOYCOPT =
endif endif
ifneq ($(PLATFORM),amiga-vbcc)
COPT += -DSVN_revision='"$(shell svnversion .)"' -DProgram_version='"$(LABEL)"'
endif
### And now for the real build rules ### ### And now for the real build rules ###
.PHONY : all debug release clean depend zip force install uninstall .PHONY : all debug release clean depend zip version force install uninstall
# This is the list of the objects we want to build. Dependancies are built by "make depend" automatically. # This is the list of the objects we want to build. Dependancies are built by "make depend" automatically.
OBJ = $(OBJDIR)/main.o $(OBJDIR)/init.o $(OBJDIR)/graph.o $(OBJDIR)/sdlscreen.o $(OBJDIR)/misc.o $(OBJDIR)/special.o $(OBJDIR)/buttons.o $(OBJDIR)/palette.o $(OBJDIR)/help.o $(OBJDIR)/operatio.o $(OBJDIR)/pages.o $(OBJDIR)/loadsave.o $(OBJDIR)/readline.o $(OBJDIR)/engine.o $(OBJDIR)/filesel.o $(OBJDIR)/op_c.o $(OBJDIR)/readini.o $(OBJDIR)/saveini.o $(OBJDIR)/shade.o $(OBJDIR)/keyboard.o $(OBJDIR)/io.o $(OBJDIR)/text.o $(OBJDIR)/SFont.o $(OBJDIR)/setup.o $(OBJDIR)/pxsimple.o $(OBJDIR)/pxtall.o $(OBJDIR)/pxwide.o $(OBJDIR)/pxdouble.o $(OBJDIR)/pxtriple.o $(OBJDIR)/pxtall2.o $(OBJDIR)/pxwide2.o $(OBJDIR)/pxquad.o $(OBJDIR)/windows.o $(OBJDIR)/brush.o $(OBJDIR)/realpath.o $(OBJDIR)/mountlist.o $(OBJDIR)/input.o $(OBJDIR)/hotkeys.o $(OBJDIR)/transform.o $(OBJDIR)/pversion.o $(PLATFORMOBJ) OBJ = $(OBJDIR)/main.o $(OBJDIR)/init.o $(OBJDIR)/graph.o $(OBJDIR)/sdlscreen.o $(OBJDIR)/misc.o $(OBJDIR)/special.o $(OBJDIR)/buttons.o $(OBJDIR)/palette.o $(OBJDIR)/help.o $(OBJDIR)/operatio.o $(OBJDIR)/pages.o $(OBJDIR)/loadsave.o $(OBJDIR)/readline.o $(OBJDIR)/engine.o $(OBJDIR)/filesel.o $(OBJDIR)/op_c.o $(OBJDIR)/readini.o $(OBJDIR)/saveini.o $(OBJDIR)/shade.o $(OBJDIR)/keyboard.o $(OBJDIR)/io.o $(OBJDIR)/version.o $(OBJDIR)/text.o $(OBJDIR)/SFont.o $(OBJDIR)/setup.o $(OBJDIR)/pxsimple.o $(OBJDIR)/pxtall.o $(OBJDIR)/pxwide.o $(OBJDIR)/pxdouble.o $(OBJDIR)/pxtriple.o $(OBJDIR)/pxtall2.o $(OBJDIR)/pxwide2.o $(OBJDIR)/pxquad.o $(OBJDIR)/windows.o $(OBJDIR)/brush.o $(OBJDIR)/realpath.o $(OBJDIR)/mountlist.o $(OBJDIR)/input.o $(OBJDIR)/hotkeys.o $(OBJDIR)/transform.o $(OBJDIR)/pversion.o $(OBJDIR)/factory.o $(PLATFORMOBJ) $(OBJDIR)/fileformats.o $(OBJDIR)/miscfileformats.o
SKIN_FILES = skins/skin_classic.png skins/skin_modern.png skins/font_Classic.png skins/font_Fun.png SKIN_FILES = skins/skin_classic.png skins/skin_modern.png skins/font_Classic.png skins/font_Fun.png
@ -307,15 +315,36 @@ ziprelease: version $(BIN) release
echo `sed "s/.*=\"\(.*\)\";/\1/" pversion.c`.`svnversion` | tr " :" "_-" | sed -e s/\\(wip\\)\\\\./\\1/I > $(OBJDIR)/versiontag echo `sed "s/.*=\"\(.*\)\";/\1/" pversion.c`.`svnversion` | tr " :" "_-" | sed -e s/\\(wip\\)\\\\./\\1/I > $(OBJDIR)/versiontag
tar cvzf "src-`cat $(OBJDIR)/versiontag`.tgz" --transform 's,^,src/,g' *.c *.h Makefile Makefile.dep gfx2.ico tar cvzf "src-`cat $(OBJDIR)/versiontag`.tgz" --transform 's,^,src/,g' *.c *.h Makefile Makefile.dep gfx2.ico
$(ZIP) $(ZIPOPT) "grafx2-`cat $(OBJDIR)/versiontag`$(TTFLABEL)-$(PLATFORM).$(ZIP)" $(BIN) gfx2def.ini $(SKIN_FILES) gfx2.gif doc/README.txt doc/COMPILING.txt doc/gpl-2.0.txt fonts/8pxfont.png doc/README-zlib1.txt doc/README-SDL.txt doc/README-SDL_image.txt doc/README-SDL_ttf.txt fonts/Tuffy.ttf src-`cat $(OBJDIR)/versiontag`.tgz $(PLATFORMFILES) $(ZIP) $(ZIPOPT) "grafx2-`cat $(OBJDIR)/versiontag`$(TTFLABEL)-$(PLATFORM).$(ZIP)" $(BIN) gfx2def.ini test.lua $(SKIN_FILES) gfx2.gif doc/README.txt doc/COMPILING.txt doc/gpl-2.0.txt fonts/8pxfont.png doc/README-zlib1.txt doc/README-SDL.txt doc/README-SDL_image.txt doc/README-SDL_ttf.txt doc/README-lua.txt fonts/Tuffy.ttf src-`cat $(OBJDIR)/versiontag`.tgz $(PLATFORMFILES)
$(DELCOMMAND) "src-`cat $(OBJDIR)/versiontag`.tgz" $(DELCOMMAND) "src-`cat $(OBJDIR)/versiontag`.tgz"
tar cvzf "grafx2-`cat $(OBJDIR)/versiontag`$(TTFLABEL)-src.tgz" --transform 's,^,grafx2/,g' *.c *.h Makefile Makefile.dep gfx2def.ini $(SKIN_FILES) gfx2.ico gfx2.gif doc/README.txt doc/COMPILING.txt doc/gpl-2.0.txt misc/grafx2.1 misc/grafx2.xpm misc/grafx2.desktop fonts/8pxfont.png fonts/Tuffy.ttf tar cvzf "grafx2-`cat $(OBJDIR)/versiontag`$(TTFLABEL)-src.tgz" --transform 's,^,grafx2/,g' *.c *.h Makefile Makefile.dep gfx2def.ini test.lua $(SKIN_FILES) gfx2.ico gfx2.gif doc/README.txt doc/COMPILING.txt doc/gpl-2.0.txt misc/grafx2.1 misc/grafx2.xpm misc/grafx2.desktop fonts/8pxfont.png fonts/Tuffy.ttf
$(DELCOMMAND) "$(OBJDIR)/versiontag" $(DELCOMMAND) "$(OBJDIR)/versiontag"
testsed : testsed :
$(BIN) : $(OBJ) $(BIN) : $(OBJ)
$(CC) $(OBJ) -o $(BIN) $(LOPT) $(CC) $(OBJ) -o $(BIN) $(LOPT)
# SVN revision number
version.c :
echo "char SVN_revision[]=\"`svnversion .`\";" > version.c
ifeq ($(LABEL),)
else
echo "char Program_version[]=\"$(LABEL)\";" > pversion.c
endif
version : delversion delpversion version.c pversion.c $(OBJDIR)/version.o $(OBJDIR)/pversion.o all
delversion :
$(DELCOMMAND) version.c
delpversion :
ifeq ($(LABEL),)
else
$(DELCOMMAND) pversion.c
endif
$(OBJDIR)/%.o : %.c $(OBJDIR)/%.o : %.c
$(if $(wildcard $(OBJDIR)),,$(MKDIR) $(OBJDIR)) $(if $(wildcard $(OBJDIR)),,$(MKDIR) $(OBJDIR))
$(CC) $(COPT) -c $*.c -o $(OBJDIR)/$*.o $(CC) $(COPT) -c $*.c -o $(OBJDIR)/$*.o

View File

@ -8,6 +8,10 @@ $(OBJDIR)/buttons.o: buttons.c const.h struct.h global.h misc.h graph.h engine.h
$(OBJDIR)/engine.o: engine.c const.h struct.h global.h graph.h misc.h special.h \ $(OBJDIR)/engine.o: engine.c const.h struct.h global.h graph.h misc.h special.h \
buttons.h operatio.h shade.h errors.h sdlscreen.h windows.h brush.h \ buttons.h operatio.h shade.h errors.h sdlscreen.h windows.h brush.h \
input.h engine.h pages.h input.h engine.h pages.h
$(OBJDIR)/factory.o: factory.c brush.h struct.h const.h buttons.h engine.h errors.h \
filesel.h global.h graph.h io.h misc.h readline.h sdlscreen.h windows.h
$(OBJDIR)/fileformats.o: fileformats.c errors.h global.h struct.h const.h \
loadsave.h misc.h
$(OBJDIR)/filesel.o: filesel.c const.h struct.h global.h misc.h errors.h io.h \ $(OBJDIR)/filesel.o: filesel.c const.h struct.h global.h misc.h errors.h io.h \
windows.h sdlscreen.h loadsave.h mountlist.h engine.h readline.h \ windows.h sdlscreen.h loadsave.h mountlist.h engine.h readline.h \
input.h help.h filesel.h input.h help.h filesel.h
@ -18,9 +22,10 @@ $(OBJDIR)/help.o: help.c const.h struct.h global.h misc.h engine.h helpfile.h \
help.h sdlscreen.h text.h keyboard.h windows.h input.h hotkeys.h \ help.h sdlscreen.h text.h keyboard.h windows.h input.h hotkeys.h \
errors.h pages.h errors.h pages.h
$(OBJDIR)/hotkeys.o: hotkeys.c struct.h const.h global.h hotkeys.h $(OBJDIR)/hotkeys.o: hotkeys.c struct.h const.h global.h hotkeys.h
$(OBJDIR)/init.o: init.c const.h struct.h global.h graph.h buttons.h palette.h \ $(OBJDIR)/init.o: init.c buttons.h struct.h const.h errors.h global.h graph.h \
help.h operatio.h misc.h errors.h keyboard.h io.h hotkeys.h setup.h \ init.h io.h factory.h help.h hotkeys.h keyboard.h loadsave.h misc.h \
windows.h sdlscreen.h mountlist.h loadsave.h init.h transform.h mountlist.h operatio.h palette.h sdlscreen.h setup.h transform.h \
windows.h
$(OBJDIR)/input.o: input.c global.h struct.h const.h keyboard.h sdlscreen.h \ $(OBJDIR)/input.o: input.c global.h struct.h const.h keyboard.h sdlscreen.h \
windows.h errors.h misc.h input.h windows.h errors.h misc.h input.h
$(OBJDIR)/io.o: io.c struct.h const.h io.h realpath.h $(OBJDIR)/io.o: io.c struct.h const.h io.h realpath.h
@ -33,6 +38,8 @@ $(OBJDIR)/main.o: main.c const.h struct.h global.h graph.h misc.h init.h buttons
io.h text.h setup.h windows.h brush.h palette.h realpath.h io.h text.h setup.h windows.h brush.h palette.h realpath.h
$(OBJDIR)/misc.o: misc.c struct.h const.h sdlscreen.h global.h errors.h buttons.h \ $(OBJDIR)/misc.o: misc.c struct.h const.h sdlscreen.h global.h errors.h buttons.h \
engine.h misc.h keyboard.h windows.h palette.h input.h engine.h misc.h keyboard.h windows.h palette.h input.h
$(OBJDIR)/miscfileformats.o: miscfileformats.c global.h struct.h const.h loadsave.h \
windows.h
$(OBJDIR)/mountlist.o: mountlist.c $(OBJDIR)/mountlist.o: mountlist.c
$(OBJDIR)/op_c.o: op_c.c op_c.h struct.h const.h errors.h $(OBJDIR)/op_c.o: op_c.c op_c.h struct.h const.h errors.h
$(OBJDIR)/operatio.o: operatio.c const.h struct.h global.h misc.h engine.h graph.h \ $(OBJDIR)/operatio.o: operatio.c const.h struct.h global.h misc.h engine.h graph.h \
@ -68,8 +75,8 @@ $(OBJDIR)/saveini.o: saveini.c const.h global.h struct.h readini.h io.h errors.h
$(OBJDIR)/sdlscreen.o: sdlscreen.c global.h struct.h const.h sdlscreen.h errors.h \ $(OBJDIR)/sdlscreen.o: sdlscreen.c global.h struct.h const.h sdlscreen.h errors.h \
misc.h misc.h
$(OBJDIR)/setup.o: setup.c struct.h const.h io.h setup.h $(OBJDIR)/setup.o: setup.c struct.h const.h io.h setup.h
$(OBJDIR)/shade.o: shade.c global.h struct.h const.h graph.h engine.h misc.h \ $(OBJDIR)/shade.o: shade.c global.h struct.h const.h graph.h engine.h errors.h \
readline.h help.h sdlscreen.h windows.h input.h shade.h misc.h readline.h help.h sdlscreen.h windows.h input.h shade.h
$(OBJDIR)/special.o: special.c const.h struct.h global.h graph.h engine.h windows.h \ $(OBJDIR)/special.o: special.c const.h struct.h global.h graph.h engine.h windows.h \
special.h pages.h misc.h buttons.h special.h pages.h misc.h buttons.h
$(OBJDIR)/text.o: text.c SFont.h struct.h const.h global.h sdlscreen.h io.h \ $(OBJDIR)/text.o: text.c SFont.h struct.h const.h global.h sdlscreen.h io.h \
@ -78,5 +85,5 @@ $(OBJDIR)/transform.o: transform.c global.h struct.h const.h transform.h engine.
sdlscreen.h windows.h input.h help.h misc.h readline.h buttons.h \ sdlscreen.h windows.h input.h help.h misc.h readline.h buttons.h \
pages.h pages.h
$(OBJDIR)/version.o: version.c $(OBJDIR)/version.o: version.c
$(OBJDIR)/windows.o: windows.c windows.h struct.h const.h global.h graph.h engine.h \ $(OBJDIR)/windows.o: windows.c windows.h struct.h const.h engine.h errors.h \
misc.h sdlscreen.h errors.h input.h global.h graph.h input.h misc.h readline.h sdlscreen.h

View File

@ -25,6 +25,8 @@
#ifndef __BRUSH_H_ #ifndef __BRUSH_H_
#define __BRUSH_H_ #define __BRUSH_H_
#include "struct.h"
/*! /*!
Gets the brush from the picture. Gets the brush from the picture.
@param start_x left edge coordinate in the picture @param start_x left edge coordinate in the picture

505
buttons.c
View File

@ -70,7 +70,7 @@
#define isHidden(x) ((x)->d_name[0]=='.') #define isHidden(x) ((x)->d_name[0]=='.')
#endif #endif
//extern char Program_version[]; // generated in pversion.c extern char Program_version[]; // generated in pversion.c
extern short Old_MX; extern short Old_MX;
extern short Old_MY; extern short Old_MY;
@ -309,8 +309,8 @@ void Button_Select_forecolor(void)
// Check if it's a double-click // Check if it's a double-click
if (time_click - time_previous < Config.Double_click_speed) if (time_click - time_previous < Config.Double_click_speed)
{ {
// Open palette window // Open palette window
Button_Palette(); Button_Palette();
} }
} }
else if (color!=-1) else if (color!=-1)
@ -715,43 +715,15 @@ void Settings_display_config(T_Config * conf)
Print_in_window(273, 31,(conf->Show_hidden_files)?YES:NO,MC_Black,MC_Light); Print_in_window(273, 31,(conf->Show_hidden_files)?YES:NO,MC_Black,MC_Light);
Print_in_window(273, 46,(conf->Show_hidden_directories)?YES:NO,MC_Black,MC_Light); Print_in_window(273, 46,(conf->Show_hidden_directories)?YES:NO,MC_Black,MC_Light);
// Print_in_window(273, 61,(conf->Show_system_directories)?YES:NO,MC_Black,MC_Light);
Print_in_window(223, 84,(conf->Safety_colors)?YES:NO,MC_Black,MC_Light); Print_in_window(223, 84,(conf->Safety_colors)?YES:NO,MC_Black,MC_Light);
Print_in_window(223, 99,(conf->Adjust_brush_pick)?YES:NO,MC_Black,MC_Light); Print_in_window(223, 99,(conf->Adjust_brush_pick)?YES:NO,MC_Black,MC_Light);
Print_in_window(223,114,(conf->Separate_colors)?YES:NO,MC_Black,MC_Light); Print_in_window(223,114,(conf->Auto_set_res)?YES:NO,MC_Black,MC_Light);
Print_in_window(223,129,(conf->Auto_set_res)?YES:NO,MC_Black,MC_Light); Print_in_window(183,129,(conf->Coords_rel)?"Relative":"Absolute",MC_Black,MC_Light);
Print_in_window(183,144,(conf->Coords_rel)?"Relative":"Absolute",MC_Black,MC_Light);
Print_in_window( 91, 84,(conf->Display_image_limits)?YES:NO,MC_Black,MC_Light); Print_in_window( 91, 84,(conf->Clear_palette)?YES:NO,MC_Black,MC_Light);
Print_in_window( 91, 99,(conf->Clear_palette)?YES:NO,MC_Black,MC_Light); Print_in_window( 91, 99,(conf->Maximize_preview)?YES:NO,MC_Black,MC_Light);
Print_in_window( 91,114,(conf->Maximize_preview)?YES:NO,MC_Black,MC_Light); Print_in_window( 91,114,(conf->Backup)?YES:NO,MC_Black,MC_Light);
Print_in_window( 91,129,(conf->Backup)?YES:NO,MC_Black,MC_Light);
/*
switch (conf->Cursor)
{
case 0 : Print_in_window(67,144," Solid",MC_Black,MC_Light); break;
case 1 : Print_in_window(67,144,"Transp",MC_Black,MC_Light); break;
default: Print_in_window(67,144," Thin",MC_Black,MC_Light);
}
*/
/*
if (conf->Font)
{ // Fun
Print_in_window( 8,31," ",MC_Black,MC_Light);
Print_in_window( 78,31," ",MC_Black,MC_Light);
Print_in_window( 82,31,"\020",MC_Black,MC_Light);
Print_in_window(152,31,"\021",MC_Black,MC_Light);
}
else
{ // Classic
Print_in_window( 82,31," ",MC_Black,MC_Light);
Print_in_window(152,31," ",MC_Black,MC_Light);
Print_in_window( 8,31,"\020",MC_Black,MC_Light);
Print_in_window( 78,31,"\021",MC_Black,MC_Light);
}
*/
Print_in_window(155,166,(conf->Auto_save)?YES:NO,MC_Black,MC_Light); Print_in_window(155,166,(conf->Auto_save)?YES:NO,MC_Black,MC_Light);
@ -795,15 +767,6 @@ void Button_Settings(void)
Window_display_frame(163, 16,139,48); // Show in filelist Window_display_frame(163, 16,139,48); // Show in filelist
Window_display_frame(253, 77, 49,82); // Mouse sens. Window_display_frame(253, 77, 49,82); // Mouse sens.
Window_display_frame( 5, 65,247,96); // |_ Misc. Window_display_frame( 5, 65,247,96); // |_ Misc.
/* Window_display_frame( 5, 65,157,14); // |
// On découpe le Frame bizarre des "Miscellaneous"
Pixel_in_window(6,77,MC_White);
Pixel_in_window(5,78,MC_Dark);
Block(Window_pos_X+(7*Menu_factor_X),Window_pos_Y+(77*Menu_factor_Y),
Menu_factor_X*154,Menu_factor_Y<<1,MC_Light);
Pixel_in_window(161,77,MC_Light);
Pixel_in_window(160,77,MC_Dark);
*/
// On affiche maintenant tout le blabla // On affiche maintenant tout le blabla
Print_in_window(169, 19,"Show in filelist",MC_Dark,MC_Light); Print_in_window(169, 19,"Show in filelist",MC_Dark,MC_Light);
Print_in_window( 9, 52,"Nb of UNDO pages",MC_Dark,MC_Light); Print_in_window( 9, 52,"Nb of UNDO pages",MC_Dark,MC_Light);
@ -817,43 +780,36 @@ void Button_Settings(void)
// Button Show/Hide dans le fileselect // Button Show/Hide dans le fileselect
Window_set_normal_button(167, 28,131,14,"Hidden files: ",0,1,SDLK_LAST); // 1 Window_set_normal_button(167, 28,131,14,"Hidden files: ",0,1,SDLK_LAST); // 1
Window_set_normal_button(167, 43,131,14,"Hidden dir. : ",0,1,SDLK_LAST); // 2 Window_set_normal_button(167, 43,131,14,"Hidden dir. : ",0,1,SDLK_LAST); // 2
// Window_set_normal_button(167, 58,131,14,"System dir. : ",0,1,SDLK_LAST);
// Button Show/Hide Picture limits Window_set_normal_button(9, 81, 107, 14, "Clear pal: ", 0, 1, SDLK_LAST); // 3
Window_set_normal_button( 9, 81,107,14,"Limits : ",0,1,SDLK_LAST); // 3 Window_set_normal_button(9, 96, 107, 14, "Max prev.: ", 0, 1, SDLK_LAST); // 4
// Button Show/Hide Picture limits
Window_set_normal_button( 9, 96,107,14,"Clear pal: ",0,1,SDLK_LAST); // 4
// Button Show/Hide Picture limits
Window_set_normal_button( 9,111,107,14,"Max prev.: ",0,1,SDLK_LAST); // 5
// Button Effectuer des backups à chaque sauvegarde // Button Effectuer des backups à chaque sauvegarde
Window_set_normal_button( 9,126,107,14,"Backup : ",0,1,SDLK_LAST); // 6 Window_set_normal_button( 9,111,107,14,"Backup : ",0,1,SDLK_LAST); // 5
// Button Safety colors // Button Safety colors
Window_set_normal_button(117, 81,131,14,"Safe. colors: ",0,1,SDLK_LAST); // 7 Window_set_normal_button(117, 81,131,14,"Safe. colors: ",0,1,SDLK_LAST); // 6
// Button Adjust Brush Pick // Button Adjust Brush Pick
Window_set_normal_button(117, 96,131,14,"AdjBrushPick: ",0,1,SDLK_LAST); // 8 Window_set_normal_button(117, 96,131,14,"AdjBrushPick: ",0,1,SDLK_LAST); // 7
// Button Separate colors
Window_set_normal_button(117,111,131,14,"Separate col: ",0,1,SDLK_LAST); // 9
// Button Passer dans la résolution appropriée après un chargement // Button Passer dans la résolution appropriée après un chargement
Window_set_normal_button(117,126,131,14,"Auto-set res: ",0,1,SDLK_LAST); // 10 Window_set_normal_button(117,111,131,14,"Auto-set res: ",0,1,SDLK_LAST); // 8
// Button Adapter la palette après un chargement (<=> Shift+BkSpc) // Button Adapter la palette après un chargement (<=> Shift+BkSpc)
Window_set_normal_button(117,141,131,14,"Coords: ",0,1,SDLK_LAST); // 11 Window_set_normal_button(117,126,131,14,"Coords: ",0,1,SDLK_LAST); // 9
// Button Reload // Button Reload
Window_set_normal_button( 6,163, 51,14,"Reload" ,0,1,SDLK_LAST); // 12 Window_set_normal_button( 6,163, 51,14,"Reload" ,0,1,SDLK_LAST); // 10
// Button Auto-save // Button Auto-save
Window_set_normal_button( 73,163,107,14,"Auto-save: ",0,1,SDLK_LAST); // 13 Window_set_normal_button( 73,163,107,14,"Auto-save: ",0,1,SDLK_LAST); // 11
// Button Save // Button Save
Window_set_normal_button(183,163, 51,14,"Save" ,0,1,SDLK_LAST); // 14 Window_set_normal_button(183,163, 51,14,"Save" ,0,1,SDLK_LAST); // 12
// Button Close // Button Close
Window_set_normal_button(250,163, 51,14,"Close" ,0,1,KEY_ESC); // 15 Window_set_normal_button(250,163, 51,14,"Close" ,0,1,KEY_ESC); // 13
// Jauges de sensibilité de la souris (X puis Y) // Jauges de sensibilité de la souris (X puis Y)
Window_set_scroller_button(265,99,56,4,1,0); // 16 Window_set_scroller_button(265,99,56,4,1,0); // 14
Window_set_scroller_button(279,99,56,4,1,0); // 17 Window_set_scroller_button(279,99,56,4,1,0); // 15
// Zone de saisie du nb de pages de Undo // Zone de saisie du nb de pages de Undo
Window_set_input_button(140,50,2); // 18 Window_set_input_button(140,50,2); // 16
Update_window_area(0,0,Window_width, Window_height); Update_window_area(0,0,Window_width, Window_height);
@ -874,54 +830,45 @@ void Button_Settings(void)
case 2 : // Hidden dir. case 2 : // Hidden dir.
Config_choisie.Show_hidden_directories=(Config_choisie.Show_hidden_directories)?0:-1; Config_choisie.Show_hidden_directories=(Config_choisie.Show_hidden_directories)?0:-1;
break; break;
// case 5 : // System dir. case 3 : // Clear palette
// Config_choisie.Show_system_directories=(Config_choisie.Show_system_directories)?0:-1;
// break;
case 3 : // Draw limits
Config_choisie.Display_image_limits=!Config_choisie.Display_image_limits;
break;
case 4 : // Clear palette
Config_choisie.Clear_palette=!Config_choisie.Clear_palette; Config_choisie.Clear_palette=!Config_choisie.Clear_palette;
break; break;
case 5 : // Maximize preview case 4 : // Maximize preview
Config_choisie.Maximize_preview=!Config_choisie.Maximize_preview; Config_choisie.Maximize_preview=!Config_choisie.Maximize_preview;
break; break;
case 6 : // Backup case 5 : // Backup
Config_choisie.Backup=!Config_choisie.Backup; Config_choisie.Backup=!Config_choisie.Backup;
break; break;
case 7 : // Safety colors case 6 : // Safety colors
Config_choisie.Safety_colors=!Config_choisie.Safety_colors; Config_choisie.Safety_colors=!Config_choisie.Safety_colors;
break; break;
case 8 : // Adjust brush pick case 7 : // Adjust brush pick
Config_choisie.Adjust_brush_pick=!Config_choisie.Adjust_brush_pick; Config_choisie.Adjust_brush_pick=!Config_choisie.Adjust_brush_pick;
break; break;
case 9 : // Separate colors case 8 : // Auto-set resolution
Config_choisie.Separate_colors=!Config_choisie.Separate_colors;
break;
case 10 : // Auto-set resolution
Config_choisie.Auto_set_res=!Config_choisie.Auto_set_res; Config_choisie.Auto_set_res=!Config_choisie.Auto_set_res;
break; break;
case 11 : // Coordonnées case 9 : // Coordonnées
Config_choisie.Coords_rel=!Config_choisie.Coords_rel; Config_choisie.Coords_rel=!Config_choisie.Coords_rel;
break; break;
case 12 : // Reload case 10 : // Reload
Settings_load_config(&Config_choisie); Settings_load_config(&Config_choisie);
config_is_reloaded=1; config_is_reloaded=1;
break; break;
case 13 : // Auto-save case 11 : // Auto-save
Config_choisie.Auto_save=!Config_choisie.Auto_save; Config_choisie.Auto_save=!Config_choisie.Auto_save;
break; break;
case 14 : // Save case 12 : // Save
Settings_save_config(&Config_choisie); Settings_save_config(&Config_choisie);
break; break;
// 15 : OK // 13 close
case 16 : // X Sensib. case 14 : // X Sensib.
Config_choisie.Mouse_sensitivity_index_x=Window_attribute2+1; Config_choisie.Mouse_sensitivity_index_x=Window_attribute2+1;
break; break;
case 17 : // Y Sensib. case 15 : // Y Sensib.
Config_choisie.Mouse_sensitivity_index_y=Window_attribute2+1; Config_choisie.Mouse_sensitivity_index_y=Window_attribute2+1;
break; break;
case 18 : // Nb pages Undo case 16 : // Nb pages Undo
Num2str(Config_choisie.Max_undo_pages,str,2); Num2str(Config_choisie.Max_undo_pages,str,2);
Readline(142,52,str,2,1); Readline(142,52,str,2,1);
Config_choisie.Max_undo_pages=atoi(str); Config_choisie.Max_undo_pages=atoi(str);
@ -951,15 +898,15 @@ void Button_Settings(void)
Spare_fileselector_offset=0; Spare_fileselector_offset=0;
} }
if ((clicked_button>=1) && (clicked_button<15)) if ((clicked_button>=1) && (clicked_button<13))
Settings_display_config(&Config_choisie); Settings_display_config(&Config_choisie);
if (Is_shortcut(Key,0x100+BUTTON_HELP)) if (Is_shortcut(Key,0x100+BUTTON_HELP))
Window_help(BUTTON_SETTINGS, NULL); Window_help(BUTTON_SETTINGS, NULL);
else if (Is_shortcut(Key,0x100+BUTTON_SETTINGS)) else if (Is_shortcut(Key,0x100+BUTTON_SETTINGS))
clicked_button=15; clicked_button=13;
} }
while ( (clicked_button!=15) && (Key!=SDLK_RETURN) ); while ( (clicked_button!=13) && (Key!=SDLK_RETURN) );
Config=Config_choisie; Config=Config_choisie;
@ -1016,11 +963,11 @@ void Add_font_or_skin(const char *name)
if (fname) if (fname)
fname++; fname++;
else else
fname=name; fname = name;
namelength = strlen(fname); namelength = strlen(fname);
if (namelength>=10 && fname[0]!='_' && !strncasecmp(fname, "skin_", 5) if (namelength>=10 && fname[0]!='_' && !strncasecmp(fname, "skin_", 5)
&& (!strcasecmp(fname+namelength-4,".png") && (!strcasecmp(fname + namelength - 4,".png")
|| !strcasecmp(fname+namelength-4,".gif"))) || !strcasecmp(fname + namelength - 4,".gif")))
{ {
Add_element_to_list(&Skin_files_list, name, 0); Add_element_to_list(&Skin_files_list, name, 0);
@ -1031,10 +978,11 @@ void Add_font_or_skin(const char *name)
strcpy(Skin_files_list.First->Full_name, fname); strcpy(Skin_files_list.First->Full_name, fname);
// Reformat the short name differently // Reformat the short name differently
strcpy(Skin_files_list.First->Short_name, strcpy(Skin_files_list.First->Short_name,
Format_filename(Skin_files_list.First->Full_name, 0) Format_filename(Skin_files_list.First->Full_name, 0)
); );
} }
else if (namelength>=10 && !strncasecmp(fname, "font_", 5) && (!strcasecmp(fname+namelength-4,".png"))) else if (namelength>=10 && !strncasecmp(fname, "font_", 5)
&& (!strcasecmp(fname + namelength - 4, ".png")))
{ {
Add_element_to_list(&Font_files_list, name, 0); Add_element_to_list(&Font_files_list, name, 0);
@ -1044,7 +992,8 @@ void Add_font_or_skin(const char *name)
// Remove directory from full name // Remove directory from full name
strcpy(Font_files_list.First->Full_name, fname); strcpy(Font_files_list.First->Full_name, fname);
// Reformat the short name differently // Reformat the short name differently
strcpy(Font_files_list.First->Short_name,Format_font_filename(Font_files_list.First->Full_name)); strcpy(Font_files_list.First->Short_name,
Format_font_filename(Font_files_list.First->Full_name));
} }
} }
@ -1057,10 +1006,16 @@ void Draw_one_skin_name(word x, word y, word index, byte highlighted)
if (Skin_files_list.Nb_elements) if (Skin_files_list.Nb_elements)
{ {
current_item = Get_item_by_index(&Skin_files_list, index); current_item = Get_item_by_index(&Skin_files_list, index);
Print_in_window(x,y,current_item->Short_name, MC_Black, (highlighted)?MC_Dark:MC_Light); Print_in_window(x, y, current_item->Short_name, MC_Black,
(highlighted)?MC_Dark:MC_Light);
} }
} }
#define SWAP_BYTES(a,b) { byte c=a; a=b; b=c;}
#define SWAP_WORDS(a,b) { word c=a; a=b; b=c;}
#define SWAP_SHORTS(a,b) { short c=a; a=b; b=c;}
#define SWAP_FLOATS(a,b) { float c=a; a=b; b=c;}
/// Skin selector window /// Skin selector window
void Button_Skins(void) void Button_Skins(void)
{ {
@ -1071,12 +1026,22 @@ void Button_Skins(void)
T_Dropdown_button * cursor_dropdown; T_Dropdown_button * cursor_dropdown;
T_List_button * skin_list; T_List_button * skin_list;
T_Scroller_button * file_scroller; T_Scroller_button * file_scroller;
int selected_font=0; int selected_font = 0;
int selected_cursor=Config.Cursor; int selected_cursor = Config.Cursor;
byte separatecolors = Config.Separate_colors;
byte showlimits = Config.Display_image_limits;
word x, y, x_pos, offs_y;
char * cursors[] = { "Solid", "Transparent", "Thin" }; char * cursors[] = { "Solid", "Transparent", "Thin" };
T_Gui_skin * gfx = NULL;
#define FILESEL_Y 52
#define FILESEL_Y 34
// Show preferred colors
Set_color(MC_Dark, Config.Fav_menu_colors[1].R, Config.Fav_menu_colors[1].G, Config.Fav_menu_colors[1].B);
Set_color(MC_Light, Config.Fav_menu_colors[2].R, Config.Fav_menu_colors[2].G, Config.Fav_menu_colors[2].B);
// --- Read the contents of skins/ directory ------------------ // --- Read the contents of skins/ directory ------------------
@ -1085,8 +1050,8 @@ void Button_Skins(void)
Free_fileselector_list(&Skin_files_list); Free_fileselector_list(&Skin_files_list);
Free_fileselector_list(&Font_files_list); Free_fileselector_list(&Font_files_list);
// Browse the "skins" directory // Browse the "skins" directory
strcpy(skinsdir,Data_directory); strcpy(skinsdir, Data_directory);
strcat(skinsdir,"skins"); strcat(skinsdir, "skins");
// Add each found file to the list // Add each found file to the list
For_each_file(skinsdir, Add_font_or_skin); For_each_file(skinsdir, Add_font_or_skin);
// Sort it // Sort it
@ -1095,47 +1060,63 @@ void Button_Skins(void)
selected_font = Find_file_in_fileselector(&Font_files_list, Config.Font_file); selected_font = Find_file_in_fileselector(&Font_files_list, Config.Font_file);
// -------------------------------------------------------------- // --------------------------------------------------------------
Open_window(178,155,"Skins"); Open_window(290, 140, "Skins");
// Frames // Frames
Window_display_frame_in(6,FILESEL_Y-2,148,84); // File selector Window_display_frame_in(6, FILESEL_Y - 2, 148, 84); // File selector
// Texts // Texts
Print_in_window( 6, 21,"Font" ,MC_Black,MC_Light); Print_in_window( 172, 33,"Font:" ,MC_Black,MC_Light);
Print_in_window( 6, 36,"Cursor" ,MC_Black,MC_Light); Print_in_window( 172, 59,"Cursor:" ,MC_Black,MC_Light);
// Ok button // Ok button
Window_set_normal_button(6,136, 51,14,"OK" ,0,1,SDLK_RETURN); // 1 Window_set_normal_button(6, 120, 51, 14, "OK", 0, 1, SDLK_RETURN); // 1
// List of skins // List of skins
skin_list = Window_set_list_button( skin_list = Window_set_list_button(
// Fileselector // Fileselector
Window_set_special_button(8,FILESEL_Y+1,144,80), // 2 Window_set_special_button(8, FILESEL_Y + 1, 144, 80), // 2
// Scroller for the fileselector // Scroller for the fileselector
(file_scroller = Window_set_scroller_button(160,FILESEL_Y+1,82, (file_scroller = Window_set_scroller_button(155, FILESEL_Y - 1, 82,
Skin_files_list.Nb_elements,10,0)), // 3 Skin_files_list.Nb_elements, 10, 0)), // 3
Draw_one_skin_name); // 4 Draw_one_skin_name); // 4
skin_list->Cursor_position = Find_file_in_fileselector(&Skin_files_list, Config.Skin_file); skin_list->Cursor_position = Find_file_in_fileselector(&Skin_files_list, Config.Skin_file);
// Buttons to choose a font // Buttons to choose a font
font_dropdown = Window_set_dropdown_button(60,19,104,11,0, Get_item_by_index(&Font_files_list,selected_font)->Short_name,1,0,1,RIGHT_SIDE|LEFT_SIDE); // 5 font_dropdown = Window_set_dropdown_button(172, 43, 104, 11, 0, Get_item_by_index(&Font_files_list,selected_font)->Short_name,1,0,1,RIGHT_SIDE|LEFT_SIDE); // 5
for (temp=0; temp<Font_files_list.Nb_files; temp++) for (temp=0; temp<Font_files_list.Nb_files; temp++)
Window_dropdown_add_item(font_dropdown,temp,Get_item_by_index(&Font_files_list,temp)->Short_name); Window_dropdown_add_item(font_dropdown,temp,Get_item_by_index(&Font_files_list,temp)->Short_name);
// Cancel // Cancel
Window_set_normal_button(62,136, 51,14,"Cancel",0,1,SDLK_ESCAPE); // 6 Window_set_normal_button(61, 120, 51,14,"Cancel",0,1,SDLK_ESCAPE); // 6
// Dropdown list to choose cursor type // Dropdown list to choose cursor type
cursor_dropdown = Window_set_dropdown_button(60,34,104,11,0,cursors[selected_cursor],1,0,1,RIGHT_SIDE|LEFT_SIDE); // 7 cursor_dropdown = Window_set_dropdown_button(172, 69, 104, 11, 0,
for (temp=0; temp<3; temp++) cursors[selected_cursor], 1, 0, 1, RIGHT_SIDE|LEFT_SIDE); // 7
Window_dropdown_add_item(cursor_dropdown,temp,cursors[temp]); for (temp = 0; temp<3; temp++)
Window_dropdown_add_item(cursor_dropdown, temp, cursors[temp]);
Window_set_normal_button(172, 87, 14, 14,
(Config.Display_image_limits)?"X":" ", -1, 1, SDLK_LAST); // 8
Print_in_window( 190, 85,"Draw picture", MC_Dark, MC_Light);
Print_in_window( 190, 94,"limits", MC_Dark, MC_Light);
Window_set_normal_button(172, 111, 14, 14,
(Config.Separate_colors)?"X":" ", -1, 1, SDLK_LAST); // 9
Print_in_window( 190, 109,"Separate", MC_Dark, MC_Light);
Print_in_window( 190, 118,"colors", MC_Dark, MC_Light);
Window_redraw_list(skin_list); Window_redraw_list(skin_list);
Update_window_area(0,0,Window_width, Window_height); for (y = 14, offs_y = 0; offs_y < 16; offs_y++, y++)
for (x = 6, x_pos = 0; x_pos<173; x_pos++, x++)
Pixel_in_window(x, y, Gfx->Preview[offs_y][x_pos]);
Update_window_area(0, 0, Window_width, Window_height);
Display_cursor(); Display_cursor();
@ -1145,175 +1126,118 @@ void Button_Skins(void)
switch(clicked_button) switch(clicked_button)
{ {
case 1 : // OK case 1 : // OK
break; break;
case 2 : // doesn't happen case 2 : // doesn't happen
break; break;
case 3 : // doesn't happen case 3 : // doesn't happen
break; break;
case 4 : // a file is selected case 4 : // a file is selected
break;
case 5 : // Font dropdown
selected_font=Window_attribute2; // Get the index of the chosen font.
break;
// 5: Cancel
case 7 : // Cursor
selected_cursor = Window_attribute2;
break;
}
switch (Key) // (Re-)load GUI graphics from selected skins
{ strcpy(skinsdir, Get_item_by_index(&Skin_files_list,
case SDLK_UNKNOWN : break; skin_list->List_start + skin_list->Cursor_position)->Full_name);
/*
case SDLK_DOWN : // Bas gfx = Load_graphics(skinsdir);
*quicksearch_filename=0; if (gfx == NULL) // Error
Hide_cursor();
Selector_scroll_down(&Main_fileselector_position,&Main_fileselector_offset);
if (file_scroller->Position!=Main_fileselector_position)
{
// Si c'est le cas, il faut mettre à jour la jauge
file_scroller->Position=Main_fileselector_position;
Window_draw_slider(file_scroller);
}
Key=0;
break;
case SDLK_UP : // Haut
*quicksearch_filename=0;
Hide_cursor();
Selector_scroll_up(&Main_fileselector_position,&Main_fileselector_offset);
if (file_scroller->Position!=Main_fileselector_position)
{
// Si c'est le cas, il faut mettre à jour la jauge
file_scroller->Position=Main_fileselector_position;
Window_draw_slider(file_scroller);
}
Key=0;
break;
case SDLK_PAGEDOWN : // PageDown
case KEY_MOUSEWHEELDOWN :
*quicksearch_filename=0;
Hide_cursor();
Selector_page_down(&Main_fileselector_position,&Main_fileselector_offset,9);
if (file_scroller->Position!=Main_fileselector_position)
{
// Si c'est le cas, il faut mettre à jour la jauge
file_scroller->Position=Main_fileselector_position;
Window_draw_slider(file_scroller);
}
Key=0;
break;
case SDLK_PAGEUP : // PageUp
case KEY_MOUSEWHEELUP :
*quicksearch_filename=0;
Hide_cursor();
Selector_page_up(&Main_fileselector_position,&Main_fileselector_offset,9);
if (file_scroller->Position!=Main_fileselector_position)
{
// Si c'est le cas, il faut mettre à jour la jauge
file_scroller->Position=Main_fileselector_position;
Window_draw_slider(file_scroller);
}
Key=0;
break;
case SDLK_END : // End
*quicksearch_filename=0;
Hide_cursor();
Selector_end(&Main_fileselector_position,&Main_fileselector_offset);
if (file_scroller->Position!=Main_fileselector_position)
{
// Si c'est le cas, il faut mettre à jour la jauge
file_scroller->Position=Main_fileselector_position;
Window_draw_slider(file_scroller);
}
Key=0;
break;
case SDLK_HOME : // Home
*quicksearch_filename=0;
Hide_cursor();
Selector_home(&Main_fileselector_position,&Main_fileselector_offset);
if (file_scroller->Position!=Main_fileselector_position)
{
// Si c'est le cas, il faut mettre à jour la jauge
file_scroller->Position=Main_fileselector_position;
Window_draw_slider(file_scroller);
}
Key=0;
break;
default: // Autre => On se place sur le nom de fichier qui correspond
if (clicked_button<=0)
{ {
if (Is_shortcut(Key,0x100+BUTTON_HELP)) Verbose_error_message(Gui_loading_error_message);
{ // Update preview
Window_help(BUTTON_SETTINGS, NULL); Window_rectangle(6, 14, 173, 16, MC_Light);
break;
}
temp=strlen(quicksearch_filename);
if (Key_ANSI>= ' ' && Key_ANSI < 255 && temp<50)
{
quicksearch_filename[temp]=Key_ANSI;
quicksearch_filename[temp+1]='\0';
most_matching_filename=Find_filename_match(Skin_files_list, quicksearch_filename);
if ( (most_matching_filename) )
{
temp=Main_fileselector_position+Main_fileselector_offset;
Hide_cursor();
Highlight_file(most_matching_filename);
Prepare_and_display_filelist(Main_fileselector_position,Main_fileselector_offset,file_scroller);
Display_cursor();
if (temp!=Main_fileselector_position+Main_fileselector_offset)
New_preview_is_needed=1;
}
else
*quicksearch_filename=0;
Key=0;
}
} }
else else
*quicksearch_filename=0; {
*/ // Update preview
// Display the bitmap according to its own color indices
for (y = 14, offs_y = 0; offs_y < 16; offs_y++, y++)
for (x = 6, x_pos = 0; x_pos<173; x_pos++, x++)
{
if (gfx->Preview[offs_y][x_pos] == gfx->Color_black)
Pixel_in_window(x, y, MC_Black);
else if (gfx->Preview[offs_y][x_pos] == gfx->Color_dark)
Pixel_in_window(x, y, MC_Dark);
else if (gfx->Preview[offs_y][x_pos] == gfx->Color_white)
Pixel_in_window(x, y, MC_White);
else if (gfx->Preview[offs_y][x_pos] == gfx->Color_light)
Pixel_in_window(x, y, MC_Light);
}
// Actualize current screen according to preferred GUI colors
Set_color(
MC_Dark,
gfx->Default_palette[gfx->Color_dark].R,
gfx->Default_palette[gfx->Color_dark].G,
gfx->Default_palette[gfx->Color_dark].B);
Set_color(
MC_Light,
gfx->Default_palette[gfx->Color_light].R,
gfx->Default_palette[gfx->Color_light].G,
gfx->Default_palette[gfx->Color_light].B);
}
Update_window_area(6, 14, 173, 16);
break;
case 5 : // Font dropdown
selected_font = Window_attribute2; // Get the index of the chosen font.
break;
// 6: Cancel
case 7 : // Cursor
selected_cursor = Window_attribute2;
break;
case 8: // Display limits
showlimits = !showlimits;
Hide_cursor();
Print_in_window(175, 90, (showlimits)?"X":" ", MC_Black, MC_Light);
Display_cursor();
break;
case 9: // Separate colors
separatecolors = !separatecolors;
Hide_cursor();
Print_in_window(175, 114, (separatecolors)?"X":" ", MC_Black, MC_Light);
Display_cursor();
break;
} }
} }
while ( (clicked_button!=1) && (clicked_button !=6) && (Key != SDLK_ESCAPE)); while ( (clicked_button!=1) && (clicked_button !=6) && (Key != SDLK_ESCAPE));
if(clicked_button == 1) if(clicked_button == 1)
{ {
T_Gui_skin * gfx;
byte * new_font; byte * new_font;
// (Re-)load GUI graphics from selected skins if (gfx != NULL)
strcpy(skinsdir, Get_item_by_index(&Skin_files_list, skin_list->List_start+skin_list->Cursor_position)->Full_name);
gfx=Load_graphics(skinsdir);
if (gfx == NULL) // Error
{ {
Verbose_error_message(Gui_loading_error_message); Set_current_skin(skinsdir, gfx);
}
else
{
free(Gfx);
Gfx = gfx;
free(Config.Skin_file);
Config.Skin_file = strdup(skinsdir);
} }
// (Re-)load the selected font // (Re-)load the selected font
new_font = Load_font(Get_item_by_index(&Font_files_list,selected_font)->Full_name); new_font = Load_font(Get_item_by_index(&Font_files_list,selected_font)->Full_name);
if (new_font) if (new_font)
{ {
const char * fname; const char * fname;
free(Menu_font); free(Menu_font);
Menu_font = new_font; Menu_font = new_font;
fname = Get_item_by_index(&Font_files_list,selected_font)->Full_name; fname = Get_item_by_index(&Font_files_list,selected_font)->Full_name;
free(Config.Font_file); free(Config.Font_file);
Config.Font_file = strdup(fname); Config.Font_file = strdup(fname);
} }
// Confirm the change of cursor shape // Confirm the change of cursor shape
Config.Cursor = selected_cursor; Config.Cursor = selected_cursor;
Config.Display_image_limits = showlimits;
Config.Separate_colors = separatecolors;
// Now find the best colors for the new skin in the current palette
// and remap the skin
Compute_optimal_menu_colors(Main_palette);
}
else
{
Set_palette(Main_palette);
} }
Close_window(); Close_window();
Unselect_button(BUTTON_SETTINGS); Unselect_button(BUTTON_SETTINGS);
// Raffichage du menu pour que les inscriptions qui y figurent soient retracées avec la nouvelle fonte // Raffichage du menu pour que les inscriptions qui y figurent soient retracées avec la nouvelle fonte
Display_menu(); Display_menu();
Display_cursor(); Display_cursor();
@ -1323,14 +1247,9 @@ void Button_Skins(void)
//---------------------------- Changement de page ---------------------------- //---------------------------- Changement de page ----------------------------
void Button_Page(void) void Button_Page(void)
{ {
byte factor_index; byte factor_index;
char Temp_buffer[256]; char Temp_buffer[256];
#define SWAP_BYTES(a,b) { byte c=a; a=b; b=c;}
#define SWAP_WORDS(a,b) { word c=a; a=b; b=c;}
#define SWAP_SHORTS(a,b) { short c=a; a=b; b=c;}
#define SWAP_FLOATS(a,b) { float c=a; a=b; b=c;}
Hide_cursor(); Hide_cursor();
// On dégrossit le travail avec les infos des listes de pages // On dégrossit le travail avec les infos des listes de pages
@ -1616,30 +1535,30 @@ void Display_modes_list(short list_start, short cursor_position)
if(Video_mode[current_mode].Fullscreen == 0) if(Video_mode[current_mode].Fullscreen == 0)
memcpy(str+9," Window ",20); memcpy(str+9," Window ",20);
else else
{ {
memcpy(str+9," Fullscreen ",13); memcpy(str+9," Fullscreen ",13);
if (Video_mode[current_mode].Width*3 == Video_mode[current_mode].Height*4) if (Video_mode[current_mode].Width*3 == Video_mode[current_mode].Height*4)
ratio=" 4:3"; ratio=" 4:3";
else if (Video_mode[current_mode].Width*9 == Video_mode[current_mode].Height*16) else if (Video_mode[current_mode].Width*9 == Video_mode[current_mode].Height*16)
ratio=" 16:9"; ratio=" 16:9";
else if (Video_mode[current_mode].Width*10 == Video_mode[current_mode].Height*16) else if (Video_mode[current_mode].Width*10 == Video_mode[current_mode].Height*16)
ratio=" 16:10"; ratio=" 16:10";
else if (Video_mode[current_mode].Width*145 == Video_mode[current_mode].Height*192) else if (Video_mode[current_mode].Width*145 == Video_mode[current_mode].Height*192)
ratio="192:145"; ratio="192:145";
else if (Video_mode[current_mode].Width*2 == Video_mode[current_mode].Height*3) else if (Video_mode[current_mode].Width*2 == Video_mode[current_mode].Height*3)
ratio=" 3:2"; ratio=" 3:2";
else if (Video_mode[current_mode].Width*3 == Video_mode[current_mode].Height*5) else if (Video_mode[current_mode].Width*3 == Video_mode[current_mode].Height*5)
ratio=" 5:3"; ratio=" 5:3";
else if (Video_mode[current_mode].Width*4 == Video_mode[current_mode].Height*5) else if (Video_mode[current_mode].Width*4 == Video_mode[current_mode].Height*5)
ratio=" 5:4"; ratio=" 5:4";
else if (Video_mode[current_mode].Width*16 == Video_mode[current_mode].Height*25) else if (Video_mode[current_mode].Width*16 == Video_mode[current_mode].Height*25)
ratio=" 25:16"; ratio=" 25:16";
else else
ratio=" "; ratio=" ";
strcpy(str+21,ratio); strcpy(str+21,ratio);
} }
Print_in_window(38,y_pos,str,text_color,background_color); Print_in_window(38,y_pos,str,text_color,background_color);
} }
@ -2812,7 +2731,7 @@ void Load_picture(byte image)
Brush_width=1; Brush_width=1;
*Brush=Fore_color; *Brush=Fore_color;
free(Smear_brush); free(Smear_brush);
Smear_brush=(byte *)malloc(MAX_PAINTBRUSH_SIZE*MAX_PAINTBRUSH_SIZE); Smear_brush=(byte *)malloc(MAX_PAINTBRUSH_SIZE*MAX_PAINTBRUSH_SIZE);
Smear_brush_height=MAX_PAINTBRUSH_SIZE; Smear_brush_height=MAX_PAINTBRUSH_SIZE;
Smear_brush_width=MAX_PAINTBRUSH_SIZE; Smear_brush_width=MAX_PAINTBRUSH_SIZE;
@ -5709,7 +5628,7 @@ void Button_Text()
cursor_position = font_list->Cursor_position; cursor_position = font_list->Cursor_position;
free(new_brush); free(new_brush);
new_brush = NULL; new_brush = NULL;
Close_window(); Close_window();
Unselect_button(BUTTON_TEXT); Unselect_button(BUTTON_TEXT);
Display_cursor(); Display_cursor();

View File

@ -17,10 +17,10 @@
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
///@file buttons.h ///@file buttons.h
/// Almost all the editor actions that are called by the menu are here. /// Almost all the editor actions that are called by the menu are here.
////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
#ifndef __BOUTONS_H_ #ifndef __BOUTONS_H_
#define __BOUTONS_H_ #define __BOUTONS_H_
@ -28,19 +28,21 @@
#include "struct.h" #include "struct.h"
/*! /*!
Displays an error message when there is no more memory for the requested operation. Displays an error message when there is no more memory for the requested
operation.
*/ */
void Message_out_of_memory(void); void Message_out_of_memory(void);
/*! /*!
Displays the splash screen at program startup. Displays the splash screen at program startup.
*/ */
void Button_Message_initial(void); void Button_Message_initial(void);
/*! /*!
Changes brush shape. Changes brush shape.
This function saves the current brush shape and swith to the default one (single pixel brush) for the filler and the color picker. This function saves the current brush shape and swith to the default one
These functions don't need (and will not work with) a custom brush. (single pixel brush) for the filler and the color picker.
These functions don't need (and will not work with) a custom brush.
*/ */
void Change_paintbrush_shape(byte shape); void Change_paintbrush_shape(byte shape);

View File

@ -241,8 +241,8 @@ enum CHUNKS_CFG
/// Identifiers for the 8x8 icons of ::Gfx->Icon_sprite (most are unused now) /// Identifiers for the 8x8 icons of ::Gfx->Icon_sprite (most are unused now)
enum ICON_TYPES enum ICON_TYPES
{ {
ICON_FLOPPY_3_5=0, ///< 3½" Floppy disk ICON_FLOPPY_3_5=0, ///< 3.5 Floppy disk
ICON_FLOPPY_5_25, ///< 5¼" Floppy disk ICON_FLOPPY_5_25, ///< 5.25 Floppy disk
ICON_HDD, ///< Hard disk drive ICON_HDD, ///< Hard disk drive
ICON_CDROM, ///< CD-ROM ICON_CDROM, ///< CD-ROM
ICON_NETWORK, ///< "Network" drive ICON_NETWORK, ///< "Network" drive

View File

@ -68,6 +68,11 @@ To compile a gp2x executable, type
This will only work on an UNIXsystem (Linux or FreeBSD). This will only work on an UNIXsystem (Linux or FreeBSD).
== Windows == == Windows ==
It is also possible to compile from linux, with this command :
make WIN32CROSS=1
You will need the mingw cross-compiler, and all the librairies listed above.
Here are the resources used to build the Windows version: Here are the resources used to build the Windows version:
4DOS 4DOS
@ -141,6 +146,14 @@ SDL_ttf:
SDL_ttf-2.0.9-win32.zip for DLLs: libfreetype-6.dll, SDL_ttf.dll, zlib1.dll SDL_ttf-2.0.9-win32.zip for DLLs: libfreetype-6.dll, SDL_ttf.dll, zlib1.dll
SDL_ttf-2.0.9.tar.gz SDL_ttf-2.0.9.tar.gz
It is also possible to compile from linux, with this command : Lua:
make WIN32CROSS=1 (optional)
You will need the mingw cross-compiler, and all the librairies listed above. http://www.lua.org/ftp/lua-5.1.4.tar.gz
Uncompress in temporary directory
Use sh shell
make mingw
(make install doesn't work, even with prefix)
Copy luaconf.h, lualib.h, lua.h, lauxlib.h to c:\msys\mingw\include\lua5.1
Copy liblua.a to c:\msys\mingw\lib RENAMED AS liblua5.1.a
Copy lua51.dll to c:\msys\mingw\bin

24
doc/README-lua.txt Normal file
View File

@ -0,0 +1,24 @@
The Windows distribution of Grafx2 is compiled and statically linked with
Lua v5.1.4
Lua is licensed with the MIT license:
Copyright © 1994-2008 Lua.org, PUC-Rio.
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
/// @file Window engine and interface management /// @file engine.c: Window engine and interface management
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
@ -80,7 +80,11 @@ char * Menu_tooltip[NB_BUTTONS]=
"Grad. spheres / ellipses", "Grad. spheres / ellipses",
"Brush grab. / Restore ", "Brush grab. / Restore ",
"Lasso / Restore brush ", "Lasso / Restore brush ",
#ifdef __ENABLE_LUA__
"Brush effects / factory ",
#else
"Brush effects ", "Brush effects ",
#endif
"Drawing modes (effects) ", "Drawing modes (effects) ",
"Text ", "Text ",
"Magnify mode / Menu ", "Magnify mode / Menu ",

View File

@ -49,38 +49,44 @@ void Window_draw_scroller_bouton(T_Scroller_button * button);
void Window_input_content(T_Special_button * button, char * content); void Window_input_content(T_Special_button * button, char * content);
void Window_clear_input_button(T_Special_button * button); void Window_clear_input_button(T_Special_button * button);
void Window_draw_input_bouton(word x_pos,word y_pos,word width_in_characters); void Window_draw_input_bouton(word x_pos, word y_pos, word width_in_characters);
T_Normal_button * Window_set_normal_button(word x_pos, word y_pos, T_Normal_button * Window_set_normal_button(word x_pos, word y_pos,
word width, word height, word width, word height, char * title, byte undersc_letter,
char * title,byte undersc_letter, byte clickable, word shortcut);
byte clickable, word shortcut);
T_Normal_button * Window_set_repeatable_button(word x_pos, word y_pos, T_Normal_button * Window_set_repeatable_button(word x_pos, word y_pos,
word width, word height, word width, word height, char * title, byte undersc_letter,
char * title,byte undersc_letter, byte clickable, word shortcut);
byte clickable, word shortcut);
T_Palette_button * Window_set_palette_button(word x_pos, word y_pos); T_Palette_button * Window_set_palette_button(word x_pos, word y_pos);
void Window_clear_tags(void); void Window_clear_tags(void);
void Tag_color_range(byte start,byte end); void Tag_color_range(byte start, byte end);
T_Scroller_button * Window_set_scroller_button(word x_pos, word y_pos, T_Scroller_button * Window_set_scroller_button(word x_pos, word y_pos,
word height, word nb_elements, word nb_elements_visible, word height, word nb_elements, word nb_elements_visible,
word initial_position); word initial_position);
T_Special_button * Window_set_special_button(word x_pos,word y_pos,word width,
T_Special_button * Window_set_special_button(word x_pos, word y_pos, word width,
word height); word height);
T_Special_button * Window_set_input_button(word x_pos,word y_pos,
T_Special_button * Window_set_input_button(word x_pos, word y_pos,
word width_in_characters); word width_in_characters);
T_Dropdown_button * Window_set_dropdown_button(word x_pos,word y_pos,word width,
word height,word dropdown_width,const char *label,byte display_choice, T_Dropdown_button * Window_set_dropdown_button(word x_pos, word y_pos,
byte display_centered,byte display_arrow,byte active_button); word width, word height, word dropdown_width, const char *label,
byte display_choice, byte display_centered, byte display_arrow,
byte active_button);
/// Adds an item to a dropdown menu
void Window_dropdown_add_item(T_Dropdown_button * dropdown, word btn_number, void Window_dropdown_add_item(T_Dropdown_button * dropdown, word btn_number,
const char *label); const char *label);
void Window_dropdown_clear_items(T_Dropdown_button * dropdown); void Window_dropdown_clear_items(T_Dropdown_button * dropdown);
T_List_button * Window_set_list_button(T_Special_button * entry_button, T_List_button * Window_set_list_button(T_Special_button * entry_button,
T_Scroller_button * scroller, Func_draw_list_item draw_list_item); T_Scroller_button * scroller, Func_draw_list_item draw_list_item);
void Window_redraw_list(T_List_button * list); void Window_redraw_list(T_List_button * list);
byte Window_click_in_rectangle(short start_x,short start_y,short end_x, byte Window_click_in_rectangle(short start_x, short start_y, short end_x,
short end_y); short end_y);
short Wait_click_in_palette(T_Palette_button * button); short Wait_click_in_palette(T_Palette_button * button);
void Get_color_behind_window(byte * color, byte * click); void Get_color_behind_window(byte * color, byte * click);

View File

@ -21,7 +21,7 @@
/// Functions and macros for tracing and error reporting. /// Functions and macros for tracing and error reporting.
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
#ifndef __func__ #ifdef __VBCC__
#define __func__ "stupid compiler !" #define __func__ "stupid compiler !"
#endif #endif

229
factory.c Normal file
View File

@ -0,0 +1,229 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2009 Adrien Destugues
Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2
of the License.
Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/
/*! \file factory.c
* \brief Brush factory - generates brush from lua scripts
*
* The brush factory allows you to generate brushes with Lua code.
*/
#include "brush.h"
#include "buttons.h"
#include "engine.h"
#include "errors.h"
#include "filesel.h" // Get_item_by_index
#include "global.h"
#include "graph.h"
#include "io.h" // find_last_slash
#include "misc.h"
#include "readline.h"
#include "sdlscreen.h"
#include "windows.h"
#ifdef __ENABLE_LUA__
#include <lua5.1/lua.h>
#include <lua5.1/lauxlib.h>
// Wrapper functions to call C from Lua
int L_SetBrushSize(lua_State* L)
{
Realloc_brush(lua_tonumber(L, 1), lua_tonumber(L, 2));
return 0;
}
int L_GetBrushSize(lua_State* L)
{
DEBUG("GBS",Brush_width);
lua_pushinteger(L, Brush_width);
lua_pushinteger(L, Brush_height);
return 2;
}
int L_PutBrushPixel(lua_State* L)
{
Pixel_in_brush(lua_tonumber(L, 1), lua_tonumber(L, 2), lua_tonumber(L, 3));
return 0; // no values returned for lua
}
int L_GetBrushPixel(lua_State* L)
{
uint8_t c = Read_pixel_from_brush(lua_tonumber(L, 1), lua_tonumber(L, 2));
lua_pushinteger(L, c);
return 1;
}
int L_SetPictureSize(lua_State* L)
{
Resize_image(lua_tonumber(L, 1), lua_tonumber(L, 2));
return 0;
}
int L_GetPictureSize(lua_State* L)
{
lua_pushinteger(L, Main_image_width);
lua_pushinteger(L, Main_image_height);
return 2;
}
int L_PutPicturePixel(lua_State* L)
{
Pixel_in_current_screen(lua_tonumber(L, 1), lua_tonumber(L, 2),
lua_tonumber(L, 3),1);
return 0; // no values returned for lua
}
int L_GetPicturePixel(lua_State* L)
{
uint8_t c = Read_pixel_from_current_screen(lua_tonumber(L, 1),
lua_tonumber(L, 2));
lua_pushinteger(L, c);
return 1;
}
int L_SetColor(lua_State* L)
{
Set_color(lua_tonumber(L, 1), lua_tonumber(L, 2), lua_tonumber(L, 3),
lua_tonumber(L, 4));
return 0;
}
int L_GetColor(lua_State* L)
{
T_Components couleur;
couleur = Main_palette[(int)(lua_tonumber(L,1))];
lua_pushinteger(L, couleur.R);
lua_pushinteger(L, couleur.G);
lua_pushinteger(L, couleur.B);
return 3;
}
int L_BrushEnable(__attribute__((unused)) lua_State* L)
{
Change_paintbrush_shape(PAINTBRUSH_SHAPE_COLOR_BRUSH);
return 0;
}
// Handlers for window internals
T_Fileselector Scripts_list;
// Callback to display a skin name in the list
void Draw_script_name(word x, word y, word index, byte highlighted)
{
T_Fileselector_item * current_item;
DEBUG("draw",index);
if (Scripts_list.Nb_elements)
{
current_item = Get_item_by_index(&Scripts_list, index);
Print_in_window(x, y, current_item->Short_name, MC_Black,
(highlighted)?MC_Dark:MC_Light);
}
}
// Add a skin to the list
void Add_script(const char *name)
{
Add_element_to_list(&Scripts_list, Find_last_slash(name)+1, 0);
}
void Button_Brush_Factory(void)
{
short clicked_button;
T_List_button* scriptlist;
T_Scroller_button* scriptscroll;
char scriptdir[MAX_PATH_CHARACTERS];
Open_window(175, 162, "Brush Factory");
// Here we use the same data container as the fileselectors.
// Reinitialize the list
Free_fileselector_list(&Scripts_list);
strcpy(scriptdir, Data_directory);
strcat(scriptdir, "scripts/");
// Add each found file to the list
For_each_file(scriptdir, Add_script);
// Sort it
Sort_list_of_files(&Scripts_list);
Window_set_normal_button(77, 141, 67, 14, "Cancel", 0, 1, KEY_ESC); // 1
Window_set_normal_button(10, 141, 67, 14, "Run", 0, 1, 0); // 2
#define FILESEL_Y 18
Window_display_frame_in(6, FILESEL_Y - 2, 148, 84); // File selector
scriptlist = Window_set_list_button(
// Fileselector
Window_set_special_button(8, FILESEL_Y + 1, 144, 80), // 3
// Scroller for the fileselector
(scriptscroll = Window_set_scroller_button(154, FILESEL_Y - 1, 82,
Scripts_list.Nb_elements, 10, 0)), // 4
Draw_script_name); // 5
Window_redraw_list(scriptlist);
Update_window_area(0, 0, Window_width, Window_height);
Display_cursor();
do {
clicked_button = Window_clicked_button();
switch (clicked_button)
{
default:
break;
}
} while (clicked_button <= 0 || clicked_button >= 3);
if (clicked_button == 2) // Run the script
{
lua_State* L = lua_open();
lua_register(L,"putbrushpixel",L_PutBrushPixel);
lua_register(L,"getbrushpixel",L_GetBrushPixel);
lua_register(L,"putpicturepixel",L_PutPicturePixel);
lua_register(L,"getpicturepixel",L_GetPicturePixel);
lua_register(L,"setbrushsize",L_SetBrushSize);
lua_register(L,"setpicturesize",L_SetPictureSize);
lua_register(L,"getbrushsize",L_GetBrushSize);
lua_register(L,"getpicturesize",L_GetPictureSize);
lua_register(L,"setcolor",L_SetColor);
lua_register(L,"getcolor",L_GetColor);
lua_register(L,"brushenable",L_BrushEnable);
// For debug only
// luaL_openlibs(L);
strcat(scriptdir, Get_item_by_index(&Scripts_list,
scriptlist->List_start + scriptlist->Cursor_position)
-> Full_name);
if (luaL_loadfile(L,scriptdir) != 0)
Verbose_error_message(lua_tostring(L, 1));
else if (lua_pcall(L, 0, 0, 0) != 0)
Verbose_error_message(lua_tostring(L, 1));
lua_close(L);
}
Close_window();
Unselect_button(BUTTON_BRUSH_EFFECTS);
Display_cursor();
}
#endif

1
factory.h Normal file
View File

@ -0,0 +1 @@
void Button_Brush_Factory(void);

3557
fileformats.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1644,6 +1644,9 @@ byte Button_Load_or_Save(byte load, byte image)
Prepare_and_display_filelist(Main_fileselector_position,Main_fileselector_offset,file_scroller); Prepare_and_display_filelist(Main_fileselector_position,Main_fileselector_offset,file_scroller);
Display_cursor(); Display_cursor();
New_preview_is_needed=1; New_preview_is_needed=1;
// On est dans un nouveau répertoire, donc on remet le quicksearch à 0
*quicksearch_filename=0;
} }
else // Sinon on essaye de charger ou sauver le fichier else // Sinon on essaye de charger ou sauver le fichier
{ {

View File

@ -32,7 +32,7 @@ void Add_element_to_list(T_Fileselector *list, const char * fname, int type);
/// ///
/// Formats a display name for a file, directory, or similar name (drive, volume). /// Formats a display name for a file, directory, or similar name (drive, volume).
/// The returned value is a pointer to a single static buffer of 19 characters /// The returned value is a pointer to a single static buffer of 19 characters
/// including the '\0'. /// including the '\\0'.
char * Format_filename(const char * fname, int type); char * Format_filename(const char * fname, int type);
void Free_fileselector_list(T_Fileselector *list); void Free_fileselector_list(T_Fileselector *list);

View File

@ -71,9 +71,6 @@ GFX2_GLOBAL byte MC_Light; ///< Index of color to use as "light grey" in the GUI
GFX2_GLOBAL byte MC_White; ///< Index of color to use as "white" in the GUI menus. GFX2_GLOBAL byte MC_White; ///< Index of color to use as "white" in the GUI menus.
GFX2_GLOBAL byte MC_Trans; ///< Index of color to use as "transparent" while loading the GUI file. GFX2_GLOBAL byte MC_Trans; ///< Index of color to use as "transparent" while loading the GUI file.
/// Favorite menu colors (RGB values).
GFX2_GLOBAL T_Components Fav_menu_colors[4];
// Input state // Input state
GFX2_GLOBAL word Mouse_X; ///< Current mouse cursor position. GFX2_GLOBAL word Mouse_X; ///< Current mouse cursor position.
GFX2_GLOBAL word Mouse_Y; ///< Current mouse cursor position. GFX2_GLOBAL word Mouse_Y; ///< Current mouse cursor position.

3
help.c
View File

@ -47,6 +47,9 @@
#include "errors.h" #include "errors.h"
#include "pages.h" #include "pages.h"
extern char Program_version[]; // generated in pversion.c
extern char SVN_revision[]; // generated in pversion.c
// Recherche un raccourci clavier: // Recherche un raccourci clavier:
word * Shortcut(word shortcut_number) word * Shortcut(word shortcut_number)
{ {

145
init.c
View File

@ -48,26 +48,27 @@
#include <signal.h> #include <signal.h>
#endif #endif
#include "buttons.h"
#include "const.h" #include "const.h"
#include "struct.h" #include "errors.h"
#include "global.h" #include "global.h"
#include "graph.h" #include "graph.h"
#include "buttons.h"
#include "palette.h"
#include "help.h"
#include "operatio.h"
#include "misc.h"
#include "errors.h"
#include "keyboard.h"
#include "io.h"
#include "hotkeys.h"
#include "setup.h"
#include "windows.h"
#include "sdlscreen.h"
#include "mountlist.h" // read_file_system_list
#include "loadsave.h" // Image_emergency_backup
#include "init.h" #include "init.h"
#include "io.h"
#include "factory.h"
#include "help.h"
#include "hotkeys.h"
#include "keyboard.h"
#include "loadsave.h" // Image_emergency_backup
#include "misc.h"
#include "mountlist.h" // read_file_system_list
#include "operatio.h"
#include "palette.h"
#include "sdlscreen.h"
#include "setup.h"
#include "struct.h"
#include "transform.h" #include "transform.h"
#include "windows.h"
char Gui_loading_error_message[512]; char Gui_loading_error_message[512];
@ -122,11 +123,11 @@ byte GUI_seek_right(SDL_Surface *gui, int *start_x, int start_y, byte neutral_co
return 1; return 1;
} }
byte Read_GUI_block(SDL_Surface *gui, int start_x, int start_y, void *dest, int width, int height, char * section, int type) byte Read_GUI_block(T_Gui_skin *gfx, SDL_Surface *gui, int start_x, int start_y, void *dest, int width, int height, char * section, int type)
{ {
// type: 0 = normal GUI element, only 4 colors allowed // type: 0 = normal GUI element, only 4 colors allowed
// type: 1 = mouse cursor, 4 colors allowed + transparent // type: 1 = mouse cursor, 4 colors allowed + transparent
// type: 2 = brush icon or sieve pattern (only MC_White and MC_Trans) // type: 2 = brush icon or sieve pattern (only gui->Color_white and gui->Color_trans)
// type: 3 = raw bitmap (splash screen) // type: 3 = raw bitmap (splash screen)
byte * dest_ptr=dest; byte * dest_ptr=dest;
@ -146,28 +147,28 @@ byte Read_GUI_block(SDL_Surface *gui, int start_x, int start_y, void *dest, int
for (x=start_x; x<start_x+width; x++) for (x=start_x; x<start_x+width; x++)
{ {
color=Get_SDL_pixel_8(gui,x,y); color=Get_SDL_pixel_8(gui,x,y);
if (type==0 && (color != MC_Black && color != MC_Dark && color != MC_Light && color != MC_White)) if (type==0 && (color != gfx->Color_black && color != gfx->Color_dark && color != gfx->Color_light && color != gfx->Color_white))
{ {
sprintf(Gui_loading_error_message, "Error in skin file: Was looking at %d,%d for a %d*%d object (%s) but at %d,%d a pixel was found with color %d which isn't one of the GUI colors (which were detected as %d,%d,%d,%d.\n", sprintf(Gui_loading_error_message, "Error in skin file: Was looking at %d,%d for a %d*%d object (%s) but at %d,%d a pixel was found with color %d which isn't one of the GUI colors (which were detected as %d,%d,%d,%d.\n",
start_x, start_y, height, width, section, x, y, color, MC_Black, MC_Dark, MC_Light, MC_White); start_x, start_y, height, width, section, x, y, color, gfx->Color_black, gfx->Color_dark, gfx->Color_light, gfx->Color_white);
return 1; return 1;
} }
if (type==1 && (color != MC_Black && color != MC_Dark && color != MC_Light && color != MC_White && color != MC_Trans)) if (type==1 && (color != gfx->Color_black && color != gfx->Color_dark && color != gfx->Color_light && color != gfx->Color_white && color != gfx->Color_trans))
{ {
sprintf(Gui_loading_error_message, "Error in skin file: Was looking at %d,%d for a %d*%d object (%s) but at %d,%d a pixel was found with color %d which isn't one of the mouse colors (which were detected as %d,%d,%d,%d,%d.\n", sprintf(Gui_loading_error_message, "Error in skin file: Was looking at %d,%d for a %d*%d object (%s) but at %d,%d a pixel was found with color %d which isn't one of the mouse colors (which were detected as %d,%d,%d,%d,%d.\n",
start_x, start_y, height, width, section, x, y, color, MC_Black, MC_Dark, MC_Light, MC_White, MC_Trans); start_x, start_y, height, width, section, x, y, color, gfx->Color_black, gfx->Color_dark, gfx->Color_light, gfx->Color_white, gfx->Color_trans);
return 1; return 1;
} }
if (type==2) if (type==2)
{ {
if (color != MC_White && color != MC_Trans) if (color != gfx->Color_white && color != gfx->Color_trans)
{ {
sprintf(Gui_loading_error_message, "Error in skin file: Was looking at %d,%d for a %d*%d object (%s) but at %d,%d a pixel was found with color %d which isn't one of the brush colors (which were detected as %d on %d.\n", sprintf(Gui_loading_error_message, "Error in skin file: Was looking at %d,%d for a %d*%d object (%s) but at %d,%d a pixel was found with color %d which isn't one of the brush colors (which were detected as %d on %d.\n",
start_x, start_y, height, width, section, x, y, color, MC_White, MC_Trans); start_x, start_y, height, width, section, x, y, color, gfx->Color_white, gfx->Color_trans);
return 1; return 1;
} }
// Conversion en 0/1 pour les brosses monochromes internes // Conversion en 0/1 pour les brosses monochromes internes
color = (color != MC_Trans); color = (color != gfx->Color_trans);
} }
*dest_ptr=color; *dest_ptr=color;
dest_ptr++; dest_ptr++;
@ -176,12 +177,12 @@ byte Read_GUI_block(SDL_Surface *gui, int start_x, int start_y, void *dest, int
return 0; return 0;
} }
byte Read_GUI_pattern(SDL_Surface *gui, int start_x, int start_y, word *dest, char * section) byte Read_GUI_pattern(T_Gui_skin *gfx, SDL_Surface *gui, int start_x, int start_y, word *dest, char * section)
{ {
byte buffer[256]; byte buffer[256];
int x,y; int x,y;
if (Read_GUI_block(gui, start_x, start_y, buffer, 16, 16, section, 2)) if (Read_GUI_block(gfx, gui, start_x, start_y, buffer, 16, 16, section, 2))
return 1; return 1;
for (y=0; y<16; y++) for (y=0; y<16; y++)
@ -208,7 +209,7 @@ void Center_GUI_cursor(T_Gui_skin *gfx, byte *cursor_buffer, int cursor_number)
{ {
for (y=0;y<29;y++) for (y=0;y<29;y++)
{ {
if (cursor_buffer[y*29+start_x]!=MC_Trans) if (cursor_buffer[y*29+start_x]!=gfx->Color_trans)
{ {
found=1; found=1;
break; break;
@ -223,7 +224,7 @@ void Center_GUI_cursor(T_Gui_skin *gfx, byte *cursor_buffer, int cursor_number)
{ {
for (x=0;x<29;x++) for (x=0;x<29;x++)
{ {
if (cursor_buffer[start_y*29+x]!=MC_Trans) if (cursor_buffer[start_y*29+x]!=gfx->Color_trans)
{ {
found=1; found=1;
break; break;
@ -270,7 +271,7 @@ byte Parse_skin(SDL_Surface * gui, T_Gui_skin *gfx)
Get_SDL_Palette(SDLPal, gfx->Default_palette); Get_SDL_Palette(SDLPal, gfx->Default_palette);
// Carré "noir" // Carré "noir"
MC_Black = Get_SDL_pixel_8(gui,cursor_x,cursor_y); gfx->Color_black = Get_SDL_pixel_8(gui,cursor_x,cursor_y);
do do
{ {
if (++cursor_x>=gui->w) if (++cursor_x>=gui->w)
@ -279,9 +280,9 @@ byte Parse_skin(SDL_Surface * gui, T_Gui_skin *gfx)
return 1; return 1;
} }
color=Get_SDL_pixel_8(gui,cursor_x,cursor_y); color=Get_SDL_pixel_8(gui,cursor_x,cursor_y);
} while(color==MC_Black); } while(color==gfx->Color_black);
// Carré "foncé" // Carré "foncé"
MC_Dark=color; gfx->Color_dark = color;
do do
{ {
if (++cursor_x>=gui->w) if (++cursor_x>=gui->w)
@ -290,9 +291,9 @@ byte Parse_skin(SDL_Surface * gui, T_Gui_skin *gfx)
return 1; return 1;
} }
color=Get_SDL_pixel_8(gui,cursor_x,cursor_y); color=Get_SDL_pixel_8(gui,cursor_x,cursor_y);
} while(color==MC_Dark); } while(color==gfx->Color_dark);
// Carré "clair" // Carré "clair"
MC_Light=color; gfx->Color_light = color;
do do
{ {
if (++cursor_x>gui->w) if (++cursor_x>gui->w)
@ -301,9 +302,9 @@ byte Parse_skin(SDL_Surface * gui, T_Gui_skin *gfx)
return 1; return 1;
} }
color=Get_SDL_pixel_8(gui,cursor_x,cursor_y); color=Get_SDL_pixel_8(gui,cursor_x,cursor_y);
} while(color==MC_Light); } while(color==gfx->Color_light);
// Carré "blanc" // Carré "blanc"
MC_White=color; gfx->Color_white = color;
do do
{ {
if (++cursor_x>=gui->w) if (++cursor_x>=gui->w)
@ -312,9 +313,9 @@ byte Parse_skin(SDL_Surface * gui, T_Gui_skin *gfx)
return 1; return 1;
} }
color=Get_SDL_pixel_8(gui,cursor_x,cursor_y); color=Get_SDL_pixel_8(gui,cursor_x,cursor_y);
} while(color==MC_White); } while(color==gfx->Color_white);
// Carré "transparent" // Carré "transparent"
MC_Trans=color; gfx->Color_trans=color;
do do
{ {
if (++cursor_x>=gui->w) if (++cursor_x>=gui->w)
@ -323,14 +324,14 @@ byte Parse_skin(SDL_Surface * gui, T_Gui_skin *gfx)
return 1; return 1;
} }
color=Get_SDL_pixel_8(gui,cursor_x,cursor_y); color=Get_SDL_pixel_8(gui,cursor_x,cursor_y);
} while(color==MC_Trans); } while(color==gfx->Color_trans);
// Reste : couleur neutre // Reste : couleur neutre
neutral_color=color; neutral_color=color;
cursor_x=0; cursor_x=0;
cursor_y=1; cursor_y=1;
while ((color=Get_SDL_pixel_8(gui,cursor_x,cursor_y))==MC_Black) while ((color=Get_SDL_pixel_8(gui,cursor_x,cursor_y))==gfx->Color_black)
{ {
cursor_y++; cursor_y++;
if (cursor_y>=gui->h) if (cursor_y>=gui->h)
@ -343,8 +344,14 @@ byte Parse_skin(SDL_Surface * gui, T_Gui_skin *gfx)
// Menu // Menu
if (GUI_seek_down(gui, &cursor_x, &cursor_y, neutral_color, "menu")) if (GUI_seek_down(gui, &cursor_x, &cursor_y, neutral_color, "menu"))
return 1; return 1;
if (Read_GUI_block(gui, cursor_x, cursor_y, gfx->Menu_block, MENU_WIDTH, MENU_HEIGHT,"menu",0)) if (Read_GUI_block(gfx, gui, cursor_x, cursor_y, gfx->Menu_block, MENU_WIDTH, MENU_HEIGHT,"menu",0))
return 1; return 1;
cursor_x += MENU_WIDTH;
if (GUI_seek_right(gui, &cursor_x, cursor_y, neutral_color, "logo"))
return 1;
if (Read_GUI_block(gfx, gui, cursor_x, cursor_y, gfx->Preview, 173, 16, "logo", 0))
return 1;
cursor_y+=MENU_HEIGHT; cursor_y+=MENU_HEIGHT;
// Effets // Effets
@ -360,7 +367,7 @@ byte Parse_skin(SDL_Surface * gui, T_Gui_skin *gfx)
if (GUI_seek_right(gui, &cursor_x, cursor_y, neutral_color, "effect sprite")) if (GUI_seek_right(gui, &cursor_x, cursor_y, neutral_color, "effect sprite"))
return 1; return 1;
} }
if (Read_GUI_block(gui, cursor_x, cursor_y, gfx->Effect_sprite[i], MENU_SPRITE_WIDTH, MENU_SPRITE_HEIGHT, "effect sprite",0)) if (Read_GUI_block(gfx, gui, cursor_x, cursor_y, gfx->Effect_sprite[i], MENU_SPRITE_WIDTH, MENU_SPRITE_HEIGHT, "effect sprite",0))
return 1; return 1;
cursor_x+=MENU_SPRITE_WIDTH; cursor_x+=MENU_SPRITE_WIDTH;
} }
@ -379,7 +386,7 @@ byte Parse_skin(SDL_Surface * gui, T_Gui_skin *gfx)
if (GUI_seek_right(gui, &cursor_x, cursor_y, neutral_color, "mouse cursor")) if (GUI_seek_right(gui, &cursor_x, cursor_y, neutral_color, "mouse cursor"))
return 1; return 1;
} }
if (Read_GUI_block(gui, cursor_x, cursor_y, mouse_cursor_area, 29, 29, "mouse cursor",1)) if (Read_GUI_block(gfx, gui, cursor_x, cursor_y, mouse_cursor_area, 29, 29, "mouse cursor",1))
return 1; return 1;
Center_GUI_cursor(gfx, (byte *)mouse_cursor_area,i); Center_GUI_cursor(gfx, (byte *)mouse_cursor_area,i);
cursor_x+=29; cursor_x+=29;
@ -399,7 +406,7 @@ byte Parse_skin(SDL_Surface * gui, T_Gui_skin *gfx)
if (GUI_seek_right(gui, &cursor_x, cursor_y, neutral_color, "menu sprite")) if (GUI_seek_right(gui, &cursor_x, cursor_y, neutral_color, "menu sprite"))
return 1; return 1;
} }
if (Read_GUI_block(gui, cursor_x, cursor_y, gfx->Menu_sprite[i], MENU_SPRITE_WIDTH, MENU_SPRITE_HEIGHT, "menu sprite",1)) if (Read_GUI_block(gfx, gui, cursor_x, cursor_y, gfx->Menu_sprite[i], MENU_SPRITE_WIDTH, MENU_SPRITE_HEIGHT, "menu sprite",1))
return 1; return 1;
cursor_x+=MENU_SPRITE_WIDTH; cursor_x+=MENU_SPRITE_WIDTH;
} }
@ -421,7 +428,7 @@ byte Parse_skin(SDL_Surface * gui, T_Gui_skin *gfx)
if (GUI_seek_right(gui, &cursor_x, cursor_y, neutral_color, "brush icon")) if (GUI_seek_right(gui, &cursor_x, cursor_y, neutral_color, "brush icon"))
return 1; return 1;
} }
if (Read_GUI_block(gui, cursor_x, cursor_y, gfx->Paintbrush_sprite[i], PAINTBRUSH_WIDTH, PAINTBRUSH_HEIGHT, "brush icon",2)) if (Read_GUI_block(gfx, gui, cursor_x, cursor_y, gfx->Paintbrush_sprite[i], PAINTBRUSH_WIDTH, PAINTBRUSH_HEIGHT, "brush icon",2))
return 1; return 1;
cursor_x+=PAINTBRUSH_WIDTH; cursor_x+=PAINTBRUSH_WIDTH;
} }
@ -440,7 +447,7 @@ byte Parse_skin(SDL_Surface * gui, T_Gui_skin *gfx)
if (GUI_seek_right(gui, &cursor_x, cursor_y, neutral_color, "sprite drive")) if (GUI_seek_right(gui, &cursor_x, cursor_y, neutral_color, "sprite drive"))
return 1; return 1;
} }
if (Read_GUI_block(gui, cursor_x, cursor_y, gfx->Icon_sprite[i], ICON_SPRITE_WIDTH, ICON_SPRITE_HEIGHT, "sprite drive",1)) if (Read_GUI_block(gfx, gui, cursor_x, cursor_y, gfx->Icon_sprite[i], ICON_SPRITE_WIDTH, ICON_SPRITE_HEIGHT, "sprite drive",1))
return 1; return 1;
cursor_x+=ICON_SPRITE_WIDTH; cursor_x+=ICON_SPRITE_WIDTH;
} }
@ -450,7 +457,7 @@ byte Parse_skin(SDL_Surface * gui, T_Gui_skin *gfx)
if (GUI_seek_down(gui, &cursor_x, &cursor_y, neutral_color, "logo menu")) if (GUI_seek_down(gui, &cursor_x, &cursor_y, neutral_color, "logo menu"))
return 1; return 1;
if (Read_GUI_block(gui, cursor_x, cursor_y, gfx->Logo_grafx2, 231, 56, "logo menu",3)) if (Read_GUI_block(gfx, gui, cursor_x, cursor_y, gfx->Logo_grafx2, 231, 56, "logo menu",3))
return 1; return 1;
cursor_y+=56; cursor_y+=56;
@ -467,7 +474,7 @@ byte Parse_skin(SDL_Surface * gui, T_Gui_skin *gfx)
if (GUI_seek_right(gui, &cursor_x, cursor_y, neutral_color, "sieve pattern")) if (GUI_seek_right(gui, &cursor_x, cursor_y, neutral_color, "sieve pattern"))
return 1; return 1;
} }
if (Read_GUI_pattern(gui, cursor_x, cursor_y, gfx->Sieve_pattern[i],"sieve pattern")) if (Read_GUI_pattern(gfx, gui, cursor_x, cursor_y, gfx->Sieve_pattern[i],"sieve pattern"))
return 1; return 1;
cursor_x+=16; cursor_x+=16;
} }
@ -489,7 +496,7 @@ byte Parse_skin(SDL_Surface * gui, T_Gui_skin *gfx)
if (GUI_seek_right(gui, &cursor_x, cursor_y, neutral_color, "help font (norm)")) if (GUI_seek_right(gui, &cursor_x, cursor_y, neutral_color, "help font (norm)"))
return 1; return 1;
} }
if (Read_GUI_block(gui, cursor_x, cursor_y, &(gfx->Help_font_norm[i][0][0]), 6, 8, "help font (norm)",0)) if (Read_GUI_block(gfx, gui, cursor_x, cursor_y, &(gfx->Help_font_norm[i][0][0]), 6, 8, "help font (norm)",0))
return 1; return 1;
cursor_x+=6; cursor_x+=6;
} }
@ -511,7 +518,7 @@ byte Parse_skin(SDL_Surface * gui, T_Gui_skin *gfx)
if (GUI_seek_right(gui, &cursor_x, cursor_y, neutral_color, "help font (bold)")) if (GUI_seek_right(gui, &cursor_x, cursor_y, neutral_color, "help font (bold)"))
return 1; return 1;
} }
if (Read_GUI_block(gui, cursor_x, cursor_y, &(gfx->Bold_font[i][0][0]), 6, 8, "help font (bold)",0)) if (Read_GUI_block(gfx, gui, cursor_x, cursor_y, &(gfx->Bold_font[i][0][0]), 6, 8, "help font (bold)",0))
return 1; return 1;
cursor_x+=6; cursor_x+=6;
} }
@ -546,15 +553,12 @@ byte Parse_skin(SDL_Surface * gui, T_Gui_skin *gfx)
else else
dest=&(gfx->Help_font_t1[char_1++][0][0]); dest=&(gfx->Help_font_t1[char_1++][0][0]);
if (Read_GUI_block(gui, cursor_x, cursor_y, dest, 6, 8, "help font (title)",0)) if (Read_GUI_block(gfx, gui, cursor_x, cursor_y, dest, 6, 8, "help font (title)",0))
return 1; return 1;
cursor_x+=6; cursor_x+=6;
} }
cursor_y+=8; cursor_y+=8;
Current_help_section=0;
Help_position=0;
gfx->Preset_paintbrush_width [ 0]= 1; gfx->Preset_paintbrush_width [ 0]= 1;
gfx->Preset_paintbrush_height[ 0]= 1; gfx->Preset_paintbrush_height[ 0]= 1;
gfx->Paintbrush_type [ 0]=PAINTBRUSH_SHAPE_SQUARE; gfx->Paintbrush_type [ 0]=PAINTBRUSH_SHAPE_SQUARE;
@ -1058,10 +1062,14 @@ void Init_buttons(void)
FAMILY_INTERRUPTION); FAMILY_INTERRUPTION);
Init_button(BUTTON_BRUSH_EFFECTS, Init_button(BUTTON_BRUSH_EFFECTS,
106,18, 106, 18,
16,16, 16, 16,
BUTTON_SHAPE_RECTANGLE, BUTTON_SHAPE_RECTANGLE,
Button_Brush_FX,Button_Brush_FX, #ifdef __ENABLE_LUA__
Button_Brush_FX, Button_Brush_Factory,
#else
Button_Brush_FX, Button_Brush_FX,
#endif
Do_nothing, Do_nothing,
FAMILY_INSTANT); FAMILY_INSTANT);
@ -2464,3 +2472,28 @@ void Init_brush_container(void)
Brush_container[i].Brush = NULL; Brush_container[i].Brush = NULL;
} }
} }
void Set_current_skin(const char *skinfile, T_Gui_skin *gfx)
{
// Free previous one
free(Gfx);
// Assign main skin pointer
Gfx = gfx;
// Change config
free(Config.Skin_file);
Config.Skin_file = strdup(skinfile);
Config.Fav_menu_colors[0] = gfx->Default_palette[gfx->Color_black];
Config.Fav_menu_colors[1] = gfx->Default_palette[gfx->Color_dark];
Config.Fav_menu_colors[2] = gfx->Default_palette[gfx->Color_light];
Config.Fav_menu_colors[3] = gfx->Default_palette[gfx->Color_white];
// Reassign GUI color indices
MC_Black = gfx->Color_black;
MC_Dark = gfx->Color_dark;
MC_Light = gfx->Color_light;
MC_White = gfx->Color_white;
MC_Trans = gfx->Color_trans;
}

1
init.h
View File

@ -23,6 +23,7 @@
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
T_Gui_skin *Load_graphics(const char * skin_file); T_Gui_skin *Load_graphics(const char * skin_file);
void Set_current_skin(const char *skinfile, T_Gui_skin *gfx);
void Init_buttons(void); void Init_buttons(void);
void Init_operations(void); void Init_operations(void);
void Init_brush_container(void); void Init_brush_container(void);

6177
loadsave.c

File diff suppressed because it is too large Load Diff

View File

@ -22,9 +22,9 @@
/// Also handles showing the preview in fileselectors. /// Also handles showing the preview in fileselectors.
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
void Pixel_load_in_current_screen(word x_pos,word y_pos,byte color); void Pixel_load_in_current_screen (word x_pos, word y_pos, byte color);
void Pixel_load_in_preview (word x_pos,word y_pos,byte color); void Pixel_load_in_preview (word x_pos, word y_pos, byte color);
void Pixel_load_in_brush (word x_pos,word y_pos,byte color); void Pixel_load_in_brush (word x_pos, word y_pos, byte color);
void Get_full_filename(char * filename, byte is_colorix_format); void Get_full_filename(char * filename, byte is_colorix_format);
@ -33,6 +33,7 @@ void Get_full_filename(char * filename, byte is_colorix_format);
/// Handles loading an image or a brush, or previewing only. /// Handles loading an image or a brush, or previewing only.
/// @param image true if the fileselector is the one for loading images (not brush) /// @param image true if the fileselector is the one for loading images (not brush)
void Load_image(byte image); void Load_image(byte image);
/// ///
/// High-level picture saving function. /// High-level picture saving function.
/// @param image true if the image should be saved (instead of the brush) /// @param image true if the image should be saved (instead of the brush)
@ -68,9 +69,31 @@ T_Format * Get_fileformat(byte format);
// -- File formats // -- File formats
#ifndef __no_pnglib__ #ifndef __no_pnglib__
#define NB_KNOWN_FORMATS 18 ///< Total number of known file formats. #define NB_KNOWN_FORMATS 18 ///< Total number of known file formats.
#else #else
// Without pnglib // Without pnglib
#define NB_KNOWN_FORMATS 17 ///< Total number of known file formats. #define NB_KNOWN_FORMATS 17 ///< Total number of known file formats.
#endif #endif
// This is here and not in fileformats.c because the emergency save uses it...
#pragma pack(1)
typedef struct
{
byte Filler1[6];
word Width;
word Height;
byte Filler2[118];
T_Palette Palette;
} T_IMG_Header;
#pragma pack()
// Données pour la gestion du chargement en 24b
#define FORMAT_24B 0x100
typedef void (* Func_24b_display) (short,short,byte,byte,byte);
extern int Image_24b;
extern T_Components * Buffer_image_24b;
extern Func_24b_display Pixel_load_24b;
void Pixel_load_in_24b_preview(short x_pos,short y_pos,byte r,byte g,byte b);
extern enum PIXEL_RATIO Ratio_of_loaded_image;

38
main.c
View File

@ -75,9 +75,6 @@
extern DECLSPEC int SDLCALL SDL_putenv(const char *variable); extern DECLSPEC int SDLCALL SDL_putenv(const char *variable);
#endif #endif
// filename for the current GUI skin file.
static char Gui_skin_file[MAX_PATH_CHARACTERS];
//--- Affichage de la syntaxe, et de la liste des modes vidéos disponibles --- //--- Affichage de la syntaxe, et de la liste des modes vidéos disponibles ---
void Display_syntax(void) void Display_syntax(void)
{ {
@ -278,7 +275,7 @@ void Analyze_command_line(int argc,char * argv[])
index++; index++;
if (index<argc) if (index<argc)
{ {
strcpy(Gui_skin_file,argv[index]); strcpy(Config.Skin_file,argv[index]);
} }
else else
{ {
@ -326,6 +323,7 @@ int Init_program(int argc,char * argv[])
int temp; int temp;
int starting_videomode; int starting_videomode;
char program_directory[MAX_PATH_CHARACTERS]; char program_directory[MAX_PATH_CHARACTERS];
T_Gui_skin *gfx;
// On crée dès maintenant les descripteurs des listes de pages pour la page // On crée dès maintenant les descripteurs des listes de pages pour la page
// principale et la page de brouillon afin que leurs champs ne soient pas // principale et la page de brouillon afin que leurs champs ne soient pas
@ -555,32 +553,34 @@ int Init_program(int argc,char * argv[])
Analyze_command_line(argc,argv); Analyze_command_line(argc,argv);
Current_help_section=0;
Help_position=0;
// Load sprites, palette etc. // Load sprites, palette etc.
strcpy(Gui_skin_file,Config.Skin_file); gfx = Load_graphics(Config.Skin_file);
Gfx = Load_graphics(Gui_skin_file); if (gfx == NULL)
if (Gfx == NULL)
{ {
Gfx = Load_graphics("skin_modern.png"); gfx = Load_graphics("skin_modern.png");
if (Gfx == NULL) if (gfx == NULL)
{ {
printf("%s", Gui_loading_error_message); printf("%s", Gui_loading_error_message);
Error(ERROR_GUI_MISSING); Error(ERROR_GUI_MISSING);
} }
} }
Set_current_skin(Config.Skin_file, gfx);
Fore_color=MC_White;
Back_color=MC_Black;
// Override colors
// Gfx->Default_palette[MC_Black]=Fav_menu_colors[0]=Config.Fav_menu_colors[0];
// Gfx->Default_palette[MC_Dark] =Fav_menu_colors[1]=Config.Fav_menu_colors[1];
// Gfx->Default_palette[MC_Light]=Fav_menu_colors[2]=Config.Fav_menu_colors[2];
// Gfx->Default_palette[MC_White]=Fav_menu_colors[3]=Config.Fav_menu_colors[3];
Compute_optimal_menu_colors(Gfx->Default_palette);
// Infos sur les trames (Sieve) // Infos sur les trames (Sieve)
Sieve_mode=0; Sieve_mode=0;
Copy_preset_sieve(0); Copy_preset_sieve(0);
// Transfert des valeurs du .INI qui ne changent pas dans des variables
// plus accessibles:
Gfx->Default_palette[MC_Black]=Fav_menu_colors[0]=Config.Fav_menu_colors[0];
Gfx->Default_palette[MC_Dark] =Fav_menu_colors[1]=Config.Fav_menu_colors[1];
Gfx->Default_palette[MC_Light]=Fav_menu_colors[2]=Config.Fav_menu_colors[2];
Gfx->Default_palette[MC_White]=Fav_menu_colors[3]=Config.Fav_menu_colors[3];
Compute_optimal_menu_colors(Gfx->Default_palette);
Fore_color=MC_White;
Back_color=MC_Black;
// Font // Font
if (!(Menu_font=Load_font(Config.Font_file))) if (!(Menu_font=Load_font(Config.Font_file)))
if (!(Menu_font=Load_font("font_Classic.png"))) if (!(Menu_font=Load_font("font_Classic.png")))

12
misc.c
View File

@ -159,7 +159,7 @@ void Set_color(byte color, byte red, byte green, byte blue)
comp.r=red; comp.r=red;
comp.g=green; comp.g=green;
comp.b=blue; comp.b=blue;
SDL_SetPalette(Screen_SDL, SDL_LOGPAL, &comp, color, 1); SDL_SetPalette(Screen_SDL, SDL_PHYSPAL | SDL_LOGPAL, &comp, color, 1);
} }
void Wait_end_of_click(void) void Wait_end_of_click(void)
@ -206,12 +206,12 @@ void Init_chrono(dword delay)
return; return;
} }
void Pixel_in_brush (word x,word y,byte color) void Pixel_in_brush (word x, word y, byte color)
{ {
*(Brush+y*Brush_width+x)=color; *(Brush + y * Brush_width + x)=color;
} }
byte Read_pixel_from_brush (word x,word y) byte Read_pixel_from_brush (word x, word y)
{ {
return *(Brush + y * Brush_width + x); return *(Brush + y * Brush_width + x);
} }
@ -782,12 +782,12 @@ unsigned long Memory_free(void)
len = sizeof(maxmem); len = sizeof(maxmem);
sysctl(mib,2,&maxmem,&len,NULL,0); sysctl(mib,2,&maxmem,&len,NULL,0);
return maxmem; return maxmem;
#elif defined(__BEOS__) || defined(__HAIKU__) || defined(__SKYOS__) || defined(__amigaos4__) || defined(__amigaos__) #elif defined(__BEOS__) || defined(__HAIKU__) || defined(__SKYOS__) || defined(__amigaos4__)
// No <sys/sysctl.h> on BeOS or Haiku // No <sys/sysctl.h> on BeOS or Haiku
// AvailMem is misleading on os4 (os4 caches stuff in memory that you can still allocate) // AvailMem is misleading on os4 (os4 caches stuff in memory that you can still allocate)
#warning "There is missing code there for your platform ! please check and correct :)" #warning "There is missing code there for your platform ! please check and correct :)"
return 10*1024*1024; return 10*1024*1024;
#elif defined(__AROS__) || defined(__MORPHOS__) #elif defined(__AROS__) || defined(__MORPHOS__) || defined(__amigaos__)
return AvailMem(MEMF_ANY); return AvailMem(MEMF_ANY);
#else #else
struct sysinfo info; struct sysinfo info;

2485
miscfileformats.c Normal file

File diff suppressed because it is too large Load Diff

2
op_c.c
View File

@ -1206,7 +1206,7 @@ void Convert_24b_bitmap_to_256_Floyd_Steinberg(T_Bitmap256 dest,T_Bitmap24B sour
} }
void Convert_24b_bitmap_to_256_nearest_neighbor(T_Bitmap256 dest, void Convert_24b_bitmap_to_256_nearest_neighbor(T_Bitmap256 dest,
T_Bitmap24B source, int width, int height, T_Components * palette, T_Bitmap24B source, int width, int height, __attribute__((unused)) T_Components * palette,
T_Conversion_table * tc) T_Conversion_table * tc)
{ {
T_Bitmap24B current; T_Bitmap24B current;

296
palette.c
View File

@ -433,9 +433,9 @@ void Set_nice_menu_colors(dword * color_usage,int not_picture)
rgb[index].R=Main_palette[color].R; rgb[index].R=Main_palette[color].R;
rgb[index].G=Main_palette[color].G; rgb[index].G=Main_palette[color].G;
rgb[index].B=Main_palette[color].B; rgb[index].B=Main_palette[color].B;
Main_palette[color].R=Fav_menu_colors[index].R; Main_palette[color].R=Config.Fav_menu_colors[index].R;
Main_palette[color].G=Fav_menu_colors[index].G; Main_palette[color].G=Config.Fav_menu_colors[index].G;
Main_palette[color].B=Fav_menu_colors[index].B; Main_palette[color].B=Config.Fav_menu_colors[index].B;
} }
// Maintenant qu'on a placé notre nouvelle palette, on va chercher quelles // Maintenant qu'on a placé notre nouvelle palette, on va chercher quelles
@ -752,68 +752,81 @@ void Draw_all_palette_sliders(T_Scroller_button * red_slider,
void Button_Palette(void) void Button_Palette(void)
{ {
static short reducer_index=0; static short reduce_colors_number = 256;
static short reduce_colors_number=256; short temp_color; // Variable pouvant reservir pour différents calculs intermédiaires
short temp_color; // Variable pouvant reservir pour différents calculs intermédiaires dword temp;
dword temp; byte color,click; // Variables pouvant reservir pour différents calculs intermédiaires
byte color,click; // Variables pouvant reservir pour différents calculs intermédiaires short clicked_button;
short clicked_button; word old_mouse_x;
word old_mouse_x; word old_mouse_y;
word old_mouse_y; byte old_mouse_k;
byte old_mouse_k; byte block_start;
byte block_start; byte block_end;
byte block_end; byte first_color;
byte first_color; byte last_color;
byte last_color; char str[10];
char str[10]; word i;
word i;
//short x_pos,y_pos;
T_Normal_button * button_used; T_Normal_button * button_used;
T_Scroller_button * red_slider; T_Scroller_button * red_slider;
T_Scroller_button * green_slider; T_Scroller_button * green_slider;
T_Scroller_button * blue_slider; T_Scroller_button * blue_slider;
T_Scroller_button * reduce_slider; T_Dropdown_button * reduce_dropdown;
byte image_is_backed_up=0; byte image_is_backed_up = 0;
byte need_to_remap=0; byte need_to_remap = 0;
dword color_usage[256]; dword color_usage[256];
short used_colors=-1; // -1 <=> Inconnu short used_colors = -1; // -1 <=> Inconnu
byte conversion_table[256]; byte conversion_table[256];
T_Components * backup_palette; T_Components * backup_palette;
T_Components * temp_palette; T_Components * temp_palette;
T_Components * working_palette; T_Components * working_palette;
backup_palette =(T_Components *)malloc(sizeof(T_Palette)); backup_palette =(T_Components *)malloc(sizeof(T_Palette));
temp_palette=(T_Components *)malloc(sizeof(T_Palette)); temp_palette=(T_Components *)malloc(sizeof(T_Palette));
working_palette=(T_Components *)malloc(sizeof(T_Palette)); working_palette=(T_Components *)malloc(sizeof(T_Palette));
Componant_unit(RGB_scale); Componant_unit(RGB_scale);
Open_window(299,188,"Palette"); Open_window(299, 188,"Palette");
memcpy(working_palette,Main_palette,sizeof(T_Palette)); memcpy(working_palette, Main_palette, sizeof(T_Palette));
memcpy(backup_palette ,Main_palette,sizeof(T_Palette)); memcpy(backup_palette, Main_palette, sizeof(T_Palette));
memcpy(temp_palette,Main_palette,sizeof(T_Palette)); memcpy(temp_palette, Main_palette, sizeof(T_Palette));
Window_set_palette_button(5,79); // 1 Window_set_palette_button(5, 79); // 1
Window_display_frame (173, 67,121,116); Window_display_frame (173, 67, 121, 116);
Window_display_frame (128, 16, 91, 39); Window_display_frame (128, 16, 91, 39);
Window_display_frame (221, 16, 73, 39);
// Frame creux destiné à l'affichage de la(les) couleur(s) sélectionnée(s)
Window_display_frame_in(259, 88, 26, 74);
// Graduation des jauges de couleur // Graduation des jauges de couleur
Block(Window_pos_X+(Menu_factor_X*179),Window_pos_Y+(Menu_factor_Y*109),Menu_factor_X*17,Menu_factor_Y,MC_Dark); Block(Window_pos_X + (Menu_factor_X * 179),
Block(Window_pos_X+(Menu_factor_X*206),Window_pos_Y+(Menu_factor_Y*109),Menu_factor_X*17,Menu_factor_Y,MC_Dark); Window_pos_Y + (Menu_factor_Y * 109), Menu_factor_X * 17, Menu_factor_Y,
Block(Window_pos_X+(Menu_factor_X*233),Window_pos_Y+(Menu_factor_Y*109),Menu_factor_X*17,Menu_factor_Y,MC_Dark); MC_Dark);
Block(Window_pos_X+(Menu_factor_X*179),Window_pos_Y+(Menu_factor_Y*125),Menu_factor_X*17,Menu_factor_Y,MC_Dark); Block(Window_pos_X + (Menu_factor_X * 206),
Block(Window_pos_X+(Menu_factor_X*206),Window_pos_Y+(Menu_factor_Y*125),Menu_factor_X*17,Menu_factor_Y,MC_Dark); Window_pos_Y + (Menu_factor_Y * 109), Menu_factor_X * 17, Menu_factor_Y,
Block(Window_pos_X+(Menu_factor_X*233),Window_pos_Y+(Menu_factor_Y*125),Menu_factor_X*17,Menu_factor_Y,MC_Dark); MC_Dark);
Block(Window_pos_X+(Menu_factor_X*179),Window_pos_Y+(Menu_factor_Y*141),Menu_factor_X*17,Menu_factor_Y,MC_Dark); Block(Window_pos_X + (Menu_factor_X * 233),
Block(Window_pos_X+(Menu_factor_X*206),Window_pos_Y+(Menu_factor_Y*141),Menu_factor_X*17,Menu_factor_Y,MC_Dark); Window_pos_Y + (Menu_factor_Y * 109), Menu_factor_X * 17, Menu_factor_Y,
Block(Window_pos_X+(Menu_factor_X*233),Window_pos_Y+(Menu_factor_Y*141),Menu_factor_X*17,Menu_factor_Y,MC_Dark); MC_Dark);
Block(Window_pos_X + (Menu_factor_X * 179),
Window_pos_Y + (Menu_factor_Y * 125), Menu_factor_X * 17, Menu_factor_Y,
MC_Dark);
Block(Window_pos_X + (Menu_factor_X * 206),
Window_pos_Y + (Menu_factor_Y * 125), Menu_factor_X * 17, Menu_factor_Y,
MC_Dark);
Block(Window_pos_X + (Menu_factor_X * 233),
Window_pos_Y + (Menu_factor_Y * 125), Menu_factor_X * 17, Menu_factor_Y,
MC_Dark);
Block(Window_pos_X + (Menu_factor_X * 179),
Window_pos_Y + (Menu_factor_Y * 141), Menu_factor_X * 17, Menu_factor_Y,
MC_Dark);
Block(Window_pos_X + (Menu_factor_X * 206),
Window_pos_Y + (Menu_factor_Y * 141), Menu_factor_X * 17, Menu_factor_Y,
MC_Dark);
Block(Window_pos_X + (Menu_factor_X * 233),
Window_pos_Y + (Menu_factor_Y * 141), Menu_factor_X * 17, Menu_factor_Y,
MC_Dark);
// Jauges de couleur // Jauges de couleur
red_slider = Window_set_scroller_button(182, 81, 88,Color_count,1,Color_max-working_palette[Fore_color].R*Color_max/255);// 2 red_slider = Window_set_scroller_button(182, 81, 88,Color_count,1,Color_max-working_palette[Fore_color].R*Color_max/255);// 2
green_slider = Window_set_scroller_button(209, 81, 88,Color_count,1,Color_max-working_palette[Fore_color].G*Color_max/255);// 3 green_slider = Window_set_scroller_button(209, 81, 88,Color_count,1,Color_max-working_palette[Fore_color].G*Color_max/255);// 3
@ -841,10 +854,9 @@ void Button_Palette(void)
// Affichage des valeurs de la couleur courante (pour 1 couleur) // Affichage des valeurs de la couleur courante (pour 1 couleur)
Display_sliders(red_slider,green_slider,blue_slider,(block_start!=block_end),working_palette); Display_sliders(red_slider,green_slider,blue_slider,(block_start!=block_end),working_palette);
Print_in_window(129,58,"Color number:",MC_Dark,MC_Light); Print_in_window(129, 58, "Color number:", MC_Dark, MC_Light);
Num2str(Fore_color,str,3); Num2str(Fore_color, str, 3);
Print_in_window(237,58,str,MC_Black,MC_Light); Print_in_window(237, 58, str, MC_Black, MC_Light);
Window_set_normal_button( 6,17,59,14,"Default",3,1,SDLK_f); // 5 Window_set_normal_button( 6,17,59,14,"Default",3,1,SDLK_f); // 5
Window_set_normal_button(66,17,29,14,"Gry" ,1,1,SDLK_g); // 6 Window_set_normal_button(66,17,29,14,"Gry" ,1,1,SDLK_g); // 6
@ -853,8 +865,16 @@ void Button_Palette(void)
Window_set_normal_button(66,32,29,14,"Cpy" ,1,1,SDLK_c); // 9 Window_set_normal_button(66,32,29,14,"Cpy" ,1,1,SDLK_c); // 9
Window_set_normal_button( 6,32,59,14,"Spread" ,4,1,SDLK_e); // 10 Window_set_normal_button( 6,32,59,14,"Spread" ,4,1,SDLK_e); // 10
Window_set_normal_button(239,20,51,14,"Reduce" ,1,1,SDLK_r); // 11 reduce_dropdown = Window_set_dropdown_button(222, 17, 60, 14, 60, "Reduce", 0,
Print_in_window(241,41,"to",MC_Dark,MC_Light); 0, 1, 1); // 11
Window_dropdown_add_item(reduce_dropdown, 0, "to 128");
Window_dropdown_add_item(reduce_dropdown, 1, "to 64");
Window_dropdown_add_item(reduce_dropdown, 2, "to 32");
Window_dropdown_add_item(reduce_dropdown, 3, "to 16");
Window_dropdown_add_item(reduce_dropdown, 4, "to 8");
Window_dropdown_add_item(reduce_dropdown, 5, "to 4");
Window_dropdown_add_item(reduce_dropdown, 6, "to 2");
Window_dropdown_add_item(reduce_dropdown, 7, "Other");
Window_set_normal_button( 6,168,35,14,"Undo" ,1,1,SDLK_u); // 12 Window_set_normal_button( 6,168,35,14,"Undo" ,1,1,SDLK_u); // 12
Window_set_normal_button( 62,168,51,14,"Cancel",0,1,KEY_ESC); // 13 Window_set_normal_button( 62,168,51,14,"Cancel",0,1,KEY_ESC); // 13
@ -863,23 +883,26 @@ void Button_Palette(void)
button_used = Window_set_normal_button(132,20,83,14,"Used: ???",4,1,SDLK_d);// 15 button_used = Window_set_normal_button(132,20,83,14,"Used: ???",4,1,SDLK_d);// 15
Window_set_normal_button(132,37,83,14,"Zap unused",0,1,SDLK_DELETE);//16 Window_set_normal_button(132,37,83,14,"Zap unused",0,1,SDLK_DELETE);//16
// Jauge de réduction de palette Window_set_repeatable_button(266, 74,12,11,"+",0,1,SDLK_KP_PLUS); // 17
reduce_slider = Window_set_scroller_button(225,20,31,7,1,reducer_index);// 17 Window_set_repeatable_button(266,165,12,11,"-",0,1,SDLK_KP_MINUS); // 18
Window_set_repeatable_button(266, 74,12,11,"+",0,1,SDLK_KP_PLUS); // 18 Window_set_normal_button(96,17,29,14,"Neg" ,1,1,SDLK_n); // 19
Window_set_repeatable_button(266,165,12,11,"-",0,1,SDLK_KP_MINUS); // 19 Window_set_normal_button(66,62,29,14,"Inv" ,1,1,SDLK_i); // 20
Window_set_normal_button( 6,62,59,14,"X-Inv." ,5,1,SDLK_v); // 21
Window_set_normal_button(96,17,29,14,"Neg" ,1,1,SDLK_n); // 20 Window_set_normal_button(96,32,29,14,"HSL" ,1,1,SDLK_h); // 22
Window_set_normal_button(66,62,29,14,"Inv" ,1,1,SDLK_i); // 21 Window_set_normal_button(96,47,29,14,"Srt" ,1,1,SDLK_s); // 23
Window_set_normal_button( 6,62,59,14,"X-Inv." ,5,1,SDLK_v); // 22
if (Config.Auto_nb_used)
{
Update_color_count(&used_colors,color_usage);
Num2str(color_usage[Fore_color], str, 6);
Print_in_window(222, 33, str, MC_Black, MC_Light);
Print_in_window(222, 42, "pixels", MC_Dark, MC_Light);
}
Window_set_input_button(263,39,3); // 23
Window_set_normal_button(96,32,29,14,"HSL" ,1,1,SDLK_h); // 24
Window_set_normal_button(96,47,29,14,"Srt" ,1,1,SDLK_s); // 25
// Affichage du facteur de réduction de la palette
Num2str(reduce_colors_number,str,3);
Print_in_window(265,41,str,MC_Black,MC_Light);
// Dessin des petits effets spéciaux pour les boutons [+] et [-] // Dessin des petits effets spéciaux pour les boutons [+] et [-]
Draw_thingumajig(263, 74,MC_White,-1); Draw_thingumajig(263, 74,MC_White,-1);
@ -891,9 +914,6 @@ void Button_Palette(void)
Display_cursor(); Display_cursor();
if (Config.Auto_nb_used)
Update_color_count(&used_colors,color_usage);
do do
{ {
old_mouse_x=Mouse_X; old_mouse_x=Mouse_X;
@ -942,6 +962,8 @@ void Button_Palette(void)
Block(Window_pos_X+(Menu_factor_X*237),Window_pos_Y+(Menu_factor_Y*58),Menu_factor_X*56,Menu_factor_Y*7,MC_Light); Block(Window_pos_X+(Menu_factor_X*237),Window_pos_Y+(Menu_factor_Y*58),Menu_factor_X*56,Menu_factor_Y*7,MC_Light);
Num2str(Fore_color,str,3); Num2str(Fore_color,str,3);
Print_in_window(237,58,str,MC_Black,MC_Light); Print_in_window(237,58,str,MC_Black,MC_Light);
Num2str(color_usage[Fore_color], str, 6);
Print_in_window(222, 33, str, MC_Black, MC_Light);
Update_rect(Window_pos_X+(Menu_factor_X*237),Window_pos_Y+(Menu_factor_Y*58),Menu_factor_X*56,Menu_factor_Y*7); Update_rect(Window_pos_X+(Menu_factor_X*237),Window_pos_Y+(Menu_factor_Y*58),Menu_factor_X*56,Menu_factor_Y*7);
// Affichage des jauges // Affichage des jauges
@ -972,6 +994,13 @@ void Button_Palette(void)
Num2str(block_end ,str+4,3); Num2str(block_end ,str+4,3);
str[3]=26; // Flèche vers la droite str[3]=26; // Flèche vers la droite
Print_in_window(237,58,str,MC_Black,MC_Light); Print_in_window(237,58,str,MC_Black,MC_Light);
{
int pixel_count = 0;
for (i = block_start; i <= block_end; i++)
pixel_count += color_usage[i];
Num2str(pixel_count, str, 6);
}
Print_in_window(222, 33, str, MC_Black, MC_Light);
// Affichage des jauges // Affichage des jauges
Display_sliders(red_slider,green_slider,blue_slider,1,NULL); Display_sliders(red_slider,green_slider,blue_slider,1,NULL);
@ -989,6 +1018,13 @@ void Button_Palette(void)
Num2str(block_end ,str+4,3); Num2str(block_end ,str+4,3);
str[3]=26; // Flèche vers la droite str[3]=26; // Flèche vers la droite
Print_in_window(237,58,str,MC_Black,MC_Light); Print_in_window(237,58,str,MC_Black,MC_Light);
{
int pixel_count = 0;
for (i = block_start; i <= block_end; i++)
pixel_count += color_usage[i];
Num2str(pixel_count, str, 6);
}
Print_in_window(222, 33, str, MC_Black, MC_Light);
// Affichage des jauges // Affichage des jauges
Display_sliders(red_slider,green_slider,blue_slider,1,NULL); Display_sliders(red_slider,green_slider,blue_slider,1,NULL);
@ -1005,6 +1041,8 @@ void Button_Palette(void)
Block(Window_pos_X+(Menu_factor_X*261),Window_pos_Y+(Menu_factor_Y*58),Menu_factor_X*32,Menu_factor_Y*7,MC_Light); Block(Window_pos_X+(Menu_factor_X*261),Window_pos_Y+(Menu_factor_Y*58),Menu_factor_X*32,Menu_factor_Y*7,MC_Light);
Num2str(Fore_color,str,3); Num2str(Fore_color,str,3);
Print_in_window(237,58,str,MC_Black,MC_Light); Print_in_window(237,58,str,MC_Black,MC_Light);
Num2str(Fore_color, str, 6);
Print_in_window(222, 33, str, MC_Black, MC_Light);
// Affichage des jauges // Affichage des jauges
Display_sliders(red_slider,green_slider,blue_slider,0,working_palette); Display_sliders(red_slider,green_slider,blue_slider,0,working_palette);
@ -1400,29 +1438,66 @@ void Button_Palette(void)
break; break;
case 11: // Reduce case 11: // Reduce
memcpy(backup_palette,working_palette,sizeof(T_Palette)); memcpy(backup_palette, working_palette, sizeof(T_Palette));
if (!image_is_backed_up) switch(Window_attribute2) // Get the dropdown value
{ {
Backup_layers(-1); case 0: // 128
image_is_backed_up=1; reduce_colors_number = 128;
} break;
Reduce_palette(&used_colors,reduce_colors_number,working_palette,color_usage); case 1: // 64
reduce_colors_number = 64;
break;
case 2: // 32
reduce_colors_number = 32;
break;
case 3: // 16
reduce_colors_number = 16;
break;
case 4: // 8
reduce_colors_number = 8;
break;
case 5: // 4
reduce_colors_number = 4;
break;
case 6: // 2
reduce_colors_number = 2;
break;
case 7: // other
reduce_colors_number
= Requester_window("Enter the max. number of colors",
reduce_colors_number);
if (reduce_colors_number < 2 || reduce_colors_number >= 256)
reduce_colors_number = -1;
break;
}
if (reduce_colors_number > 0)
{
if (!image_is_backed_up)
{
Backup_layers(-1);
image_is_backed_up=1;
}
if ((Config.Safety_colors) && (used_colors<4)) Reduce_palette(&used_colors, reduce_colors_number, working_palette,
{ color_usage);
memcpy(temp_palette,Main_palette,sizeof(T_Palette));
memcpy(Main_palette,working_palette,sizeof(T_Palette));
Set_nice_menu_colors(color_usage,0);
memcpy(working_palette,Main_palette,sizeof(T_Palette));
memcpy(Main_palette,temp_palette,sizeof(T_Palette));
}
Set_palette(working_palette); // On définit la nouvelle palette if ((Config.Safety_colors) && (used_colors<4))
Draw_all_palette_sliders(red_slider,green_slider,blue_slider,working_palette,block_start,block_end); {
memcpy(temp_palette,working_palette,sizeof(T_Palette)); memcpy(temp_palette, Main_palette, sizeof(T_Palette));
memcpy(Main_palette, working_palette, sizeof(T_Palette));
Set_nice_menu_colors(color_usage, 0);
memcpy(working_palette, Main_palette, sizeof(T_Palette));
memcpy(Main_palette, temp_palette, sizeof(T_Palette));
}
End_of_modification(); Set_palette(working_palette); // On définit la nouvelle palette
need_to_remap=1; Draw_all_palette_sliders(red_slider, green_slider, blue_slider,
working_palette, block_start, block_end);
memcpy(temp_palette, working_palette, sizeof(T_Palette));
End_of_modification();
need_to_remap = 1;
}
break; break;
case 12: // Undo case 12: // Undo
@ -1470,19 +1545,7 @@ void Button_Palette(void)
need_to_remap=1; need_to_remap=1;
break; break;
case 17 : // Jauge de réduction de palette case 17 : // [+]
if (reducer_index!=reduce_slider->Position)
{
reducer_index=reduce_slider->Position;
// Affichage du facteur de réduction de la palette
Hide_cursor();
Print_in_window(265,41,Palette_reduce_label[reducer_index],MC_Black,MC_Light);
Display_cursor();
reduce_colors_number=atoi(Palette_reduce_label[reducer_index]);
}
break;
case 18 : // [+]
if (!Palette_view_is_RGB) if (!Palette_view_is_RGB)
break; break;
Hide_cursor(); Hide_cursor();
@ -1607,7 +1670,7 @@ void Button_Palette(void)
Set_palette(working_palette); Set_palette(working_palette);
break; break;
case 19 : // [-] case 18 : // [-]
if (!Palette_view_is_RGB) if (!Palette_view_is_RGB)
break; break;
Hide_cursor(); Hide_cursor();
@ -1732,7 +1795,7 @@ void Button_Palette(void)
Set_palette(working_palette); Set_palette(working_palette);
break; break;
case 20 : // Negative case 19 : // Negative
// Backup // Backup
memcpy(backup_palette,working_palette,sizeof(T_Palette)); memcpy(backup_palette,working_palette,sizeof(T_Palette));
// Negative // Negative
@ -1750,8 +1813,8 @@ void Button_Palette(void)
need_to_remap=1; need_to_remap=1;
break; break;
case 21 : // Inversion case 20 : // Inversion
case 22 : // X-Inversion case 21 : // X-Inversion
// Backup // Backup
memcpy(backup_palette,working_palette,sizeof(T_Palette)); memcpy(backup_palette,working_palette,sizeof(T_Palette));
// On initialise la table de conversion // On initialise la table de conversion
@ -1795,30 +1858,7 @@ void Button_Palette(void)
need_to_remap=1; need_to_remap=1;
break; break;
case 23 : // Saisie du nombre de couleurs pour la réduction de palette case 22 : // HSL <> RGB
Num2str(reduce_colors_number,str,3);
if (Readline(265,41,str,3,1))
{
temp_color=atoi(str);
// Correction de la valeur lue
if ( (temp_color>256) || (temp_color<2) )
{
if (temp_color>256)
temp_color=256;
else
temp_color=2;
Num2str(temp_color,str,3);
Window_input_content(Window_special_button_list,str);
}
reduce_colors_number=temp_color;
}
Display_cursor();
break;
case 24 : // HSL <> RGB
// Acte les changements en cours sur une ou plusieurs couleurs // Acte les changements en cours sur une ou plusieurs couleurs
memcpy(temp_palette,working_palette,sizeof(T_Palette)); memcpy(temp_palette,working_palette,sizeof(T_Palette));
@ -1854,7 +1894,7 @@ void Button_Palette(void)
Update_window_area(265,73,14,103); Update_window_area(265,73,14,103);
break; break;
case 25 : // Sort palette case 23 : // Sort palette
{ {
byte h = 0, l = 0, s=0; byte h = 0, l = 0, s=0;
byte oh=0,ol=0,os=0; // Valeur pour la couleur précédente byte oh=0,ol=0,os=0; // Valeur pour la couleur précédente
@ -2028,7 +2068,7 @@ void Button_Palette(void)
image_is_backed_up=1; image_is_backed_up=1;
} }
if (used_colors==-1) if (used_colors==-1)
Update_color_count(&used_colors,color_usage); Update_color_count(&used_colors, color_usage);
memcpy(backup_palette,working_palette,sizeof(T_Palette)); memcpy(backup_palette,working_palette,sizeof(T_Palette));
memcpy(temp_palette,Main_palette,sizeof(T_Palette)); memcpy(temp_palette,Main_palette,sizeof(T_Palette));

7
scripts/test.lua Normal file
View File

@ -0,0 +1,7 @@
w, h = getbrushsize()
for x = 0, w - 1, 1 do
for y = 0, h - 1, 1 do
putbrushpixel(x, y, (x+y)%256);
end
end

30
shade.c
View File

@ -22,6 +22,7 @@
#include "global.h" #include "global.h"
#include "graph.h" #include "graph.h"
#include "engine.h" #include "engine.h"
#include "errors.h"
#include "misc.h" #include "misc.h"
#include "readline.h" #include "readline.h"
#include "help.h" #include "help.h"
@ -432,18 +433,18 @@ void Swap_shade(short block_1_start,short block_2_start,short block_size)
int Menu_shade(void) int Menu_shade(void)
{ {
short clicked_button; // Numéro du bouton sur lequel l'utilisateur a clické short clicked_button; // Numéro du bouton sur lequel l'utilisateur a clické
char str[4]; // str d'affichage du n° de shade actif et du Pas char str[4]; // str d'affichage du n° de shade actif et du Pas
word old_mouse_x,old_mouse_x2; // Mémo. de l'ancienne pos. du curseur word old_mouse_x, old_mouse_x2; // Mémo. de l'ancienne pos. du curseur
word old_mouse_y,old_mouse_y2; word old_mouse_y, old_mouse_y2;
byte old_mouse_k,old_mouse_k2; byte old_mouse_k, old_mouse_k2;
byte temp_color; // Variables de gestion des clicks dans la palette byte temp_color; // Variables de gestion des clicks dans la palette
byte first_color=0; byte first_color = Fore_color;
byte last_color=0; byte last_color = Fore_color;
word selection_start=0; word selection_start = 0;
word selection_end=0; word selection_end = 0;
T_Special_button * input_button; T_Special_button * input_button;
short temp,temp2; short temp, temp2;
word temp_cell; word temp_cell;
word * buffer; // buffer du Copy/Paste word * buffer; // buffer du Copy/Paste
word * undo_buffer; // buffer du Undo word * undo_buffer; // buffer du Undo
@ -477,7 +478,7 @@ int Menu_shade(void)
Window_set_normal_button(234,87,43,14,"Paste" ,1,1,SDLK_p); // 7 Window_set_normal_button(234,87,43,14,"Paste" ,1,1,SDLK_p); // 7
// On tagge le bloc // On tagge le bloc
Tag_color_range(0,0); Tag_color_range(Fore_color,Fore_color);
// Tracé d'un cadre creux autour du bloc dégradé // Tracé d'un cadre creux autour du bloc dégradé
Window_display_frame_in(171,26,18,66); Window_display_frame_in(171,26,18,66);
@ -614,6 +615,13 @@ int Menu_shade(void)
} }
break; break;
case 5: // Ok
if (selection_start == selection_end && Shade_list[Shade_current].List[selection_start] > 0)
Set_fore_color(Shade_list[Shade_current].List[selection_start]);
else if (first_color == last_color)
Set_fore_color(first_color);
break;
case 6 : // Copy case 6 : // Copy
memcpy(buffer,Shade_list[Shade_current].List,512*sizeof(word)); memcpy(buffer,Shade_list[Shade_current].List,512*sizeof(word));
break; break;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

BIN
skins/skin_remapped.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -436,6 +436,20 @@ typedef struct
/// A default 256-color palette. /// A default 256-color palette.
T_Palette Default_palette; T_Palette Default_palette;
/// Preview for displaying in the skin dialog
byte Preview[16][173];
/// Black GUI color index in skin palette
byte Color_black;
/// Dark GUI color index in skin palette
byte Color_dark;
/// Light GUI color index in skin palette
byte Color_light;
/// White GUI color index in skin palette
byte Color_white;
/// Transparent GUI color index in skin file
byte Color_trans;
} T_Gui_skin; } T_Gui_skin;

View File

@ -23,16 +23,19 @@
*/ */
#include <math.h> #include <math.h>
#include <stdlib.h> // atoi()
#include <string.h> // strncpy() strlen() #include <string.h> // strncpy() strlen()
#include "windows.h" #include "windows.h"
#include "engine.h"
#include "errors.h"
#include "global.h" #include "global.h"
#include "graph.h" #include "graph.h"
#include "engine.h"
#include "misc.h"
#include "sdlscreen.h"
#include "errors.h"
#include "input.h" #include "input.h"
#include "misc.h"
#include "readline.h"
#include "sdlscreen.h"
// L'encapsulation tente une percée...ou un dernier combat. // L'encapsulation tente une percée...ou un dernier combat.
@ -210,7 +213,7 @@ void Set_back_color(byte color)
/// ///
/// Redraw the cell in the menu palette for ::Fore_color. /// Redraw the cell in the menu palette for ::Fore_color.
/// This function checks bounds, it won't draw anything if Fore_color is not visible. /// This function checks bounds, it won't draw anything if Fore_color is not visible.
/// @param id:Color number to frame /// @param id: Color number to frame
void Frame_menu_color(byte id) void Frame_menu_color(byte id)
{ {
word start_x,start_y,end_x,end_y; word start_x,start_y,end_x,end_y;
@ -836,6 +839,49 @@ byte Confirmation_box(char * message)
} }
/// Window that allows you to enter a single value
int Requester_window(char* message, int initial_value)
{
short clicked_button = 0;
word window_width;
char str[10];
window_width=(strlen(message)<<3)+20;
if (window_width<120)
window_width = 120;
Open_window(window_width, 60, "Request");
Print_in_window((window_width>>1)-(strlen(message)<<2), 20, message,
MC_Black, MC_Light);
sprintf(str, "%d", initial_value);
Window_set_input_button(10, 37, 4); // 1
Print_in_window(11, 39, str, MC_Black, MC_Light);
Window_set_normal_button(60 ,37,40,14,"OK",1,1,SDLK_y); // 2
Window_set_normal_button(130,37,60,14,"Cancel" ,1,1,SDLK_n); // 3
Update_rect(Window_pos_X, Window_pos_Y, Menu_factor_X * window_width,
Menu_factor_Y * 60);
Display_cursor();
do
{
clicked_button = Window_clicked_button();
if (clicked_button == 1)
Readline(11, 39, str, 4, 1);
if (Key == SDLK_ESCAPE) clicked_button = 2;
}
while (clicked_button <= 0);
Key = 0;
Close_window();
Display_cursor();
return clicked_button==2?-1:atoi(str);
}
/// Window that show a warning message and wait for a click on the OK button /// Window that show a warning message and wait for a click on the OK button
void Warning_message(char * message) void Warning_message(char * message)
@ -864,7 +910,7 @@ void Warning_message(char * message)
} }
/// Window that shows a big message, and waits for a click on OK /// Window that shows a big message, and waits for a click on OK
void Verbose_error_message(char * message) void Verbose_error_message(const char * message)
{ {
short clicked_button; short clicked_button;
int line; int line;
@ -1120,7 +1166,7 @@ void Display_menu_palette_avoiding_window(byte * table)
if (table[real_color]!=real_color) if (table[real_color]!=real_color)
{ {
start_x=Palette_cell_X(real_color); start_x=Palette_cell_X(real_color);
start_y=Palette_cell_Y(real_color); //Menu_Y_before_window ??! start_y=Palette_cell_Y(real_color);
end_x=start_x+width; end_x=start_x+width;
end_y=start_y+height; end_y=start_y+height;
@ -2497,23 +2543,23 @@ void Remap_screen_after_menu_colors_change(void)
void Compute_optimal_menu_colors(T_Components * palette) void Compute_optimal_menu_colors(T_Components * palette)
{ {
byte table[4]; byte table[4];
short i,j,k; short i;
Old_black =MC_Black; Old_black =MC_Black;
Old_dark=MC_Dark; Old_dark = MC_Dark;
Old_light=MC_Light; Old_light = MC_Light;
Old_white=MC_White; Old_white = MC_White;
Old_trans=MC_Trans; Old_trans = MC_Trans;
// Recherche du noir // Recherche du noir
Compute_4_best_colors_for_1_menu_color Compute_4_best_colors_for_1_menu_color
(Fav_menu_colors[0].R, Fav_menu_colors[0].G, Fav_menu_colors[0].B,palette,table); (Config.Fav_menu_colors[0].R, Config.Fav_menu_colors[0].G, Config.Fav_menu_colors[0].B,palette,table);
MC_Black=table[0]; MC_Black=table[0];
// Recherche du blanc // Recherche du blanc
Compute_4_best_colors_for_1_menu_color Compute_4_best_colors_for_1_menu_color
(Fav_menu_colors[3].R, Fav_menu_colors[3].G, Fav_menu_colors[3].B,palette,table); (Config.Fav_menu_colors[3].R, Config.Fav_menu_colors[3].G, Config.Fav_menu_colors[3].B,palette,table);
if (MC_Black!=table[0]) if (MC_Black!=table[0])
MC_White=table[0]; MC_White=table[0];
else else
@ -2521,7 +2567,7 @@ void Compute_optimal_menu_colors(T_Components * palette)
// Recherche du gris clair // Recherche du gris clair
Compute_4_best_colors_for_1_menu_color Compute_4_best_colors_for_1_menu_color
(Fav_menu_colors[2].R, Fav_menu_colors[2].G, Fav_menu_colors[2].B,palette,table); (Config.Fav_menu_colors[2].R, Config.Fav_menu_colors[2].G, Config.Fav_menu_colors[2].B,palette,table);
if ( (MC_Black!=table[0]) && (MC_White!=table[0]) ) if ( (MC_Black!=table[0]) && (MC_White!=table[0]) )
MC_Light=table[0]; MC_Light=table[0];
else else
@ -2534,7 +2580,7 @@ void Compute_optimal_menu_colors(T_Components * palette)
// Recherche du gris foncé // Recherche du gris foncé
Compute_4_best_colors_for_1_menu_color Compute_4_best_colors_for_1_menu_color
(Fav_menu_colors[1].R, Fav_menu_colors[1].G, Fav_menu_colors[1].B,palette,table); (Config.Fav_menu_colors[1].R, Config.Fav_menu_colors[1].G, Config.Fav_menu_colors[1].B,palette,table);
if ( (MC_Black!=table[0]) && (MC_White!=table[0]) && (MC_Light!=table[0]) ) if ( (MC_Black!=table[0]) && (MC_White!=table[0]) && (MC_Light!=table[0]) )
MC_Dark=table[0]; MC_Dark=table[0];
else else
@ -2564,7 +2610,14 @@ void Compute_optimal_menu_colors(T_Components * palette)
for (MC_Trans=0; ((MC_Trans==MC_Black) || (MC_Trans==MC_Dark) || for (MC_Trans=0; ((MC_Trans==MC_Black) || (MC_Trans==MC_Dark) ||
(MC_Trans==MC_Light) || (MC_Trans==MC_White)); MC_Trans++); (MC_Trans==MC_Light) || (MC_Trans==MC_White)); MC_Trans++);
// Et maintenant, on "remappe" tous les sprites, etc... Remap_menu_sprites();
}
/// Remap all menu data when the palette changes or a new skin is loaded
void Remap_menu_sprites()
{
int i, j, k;
if ( (MC_Light!=Old_light) if ( (MC_Light!=Old_light)
|| (MC_Dark!=Old_dark) || (MC_Dark!=Old_dark)
|| (MC_White!=Old_white) || (MC_White!=Old_white)
@ -2621,6 +2674,11 @@ void Compute_optimal_menu_colors(T_Components * palette)
for (j=0; j<ICON_SPRITE_HEIGHT; j++) for (j=0; j<ICON_SPRITE_HEIGHT; j++)
for (i=0; i<ICON_SPRITE_WIDTH; i++) for (i=0; i<ICON_SPRITE_WIDTH; i++)
Remap_pixel(&Gfx->Icon_sprite[k][j][i]); Remap_pixel(&Gfx->Icon_sprite[k][j][i]);
// Skin preview
for (j = 0; j < 173; j++)
for (i = 0; i < 16; i++)
Remap_pixel(&Gfx->Preview[i][j]);
} }
Clear_border(MC_Black); Clear_border(MC_Black);
} }

View File

@ -39,6 +39,7 @@ void Hide_cursor(void);
void Remap_screen_after_menu_colors_change(void); void Remap_screen_after_menu_colors_change(void);
void Compute_optimal_menu_colors(T_Components * palette); void Compute_optimal_menu_colors(T_Components * palette);
void Remap_menu_sprites();
void Position_screen_according_to_zoom(void); void Position_screen_according_to_zoom(void);
void Compute_separator_data(void); void Compute_separator_data(void);
@ -70,7 +71,8 @@ void Print_counter(short x,short y,const char * str,byte text_color,byte backgro
byte Confirmation_box(char * message); byte Confirmation_box(char * message);
void Warning_message(char * message); void Warning_message(char * message);
void Verbose_error_message(char * message); void Verbose_error_message(const char * message);
int Requester_window(char* message, int initial_value);
void Display_image_limits(void); void Display_image_limits(void);
void Display_all_screen(void); void Display_all_screen(void);